Revert incorrect RCL_3 drop: RCL_3 PDK_3.0.2
authorPat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:29:17 +0100
branchRCL_3
changeset 19 e36f3802f733
parent 18 cad71a31b7fc
child 20 bf318c0ae8c0
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035
group/bld.inf
layers.sysdef.xml
speechsrv_plat/adaptation_hw_device_api/adaptation_hw_device_api.metaxml
speechsrv_plat/adaptation_hw_device_api/group/bld.inf
speechsrv_plat/adaptation_hw_device_api/inc/asrsadaptationhwdevice.h
speechsrv_plat/asrs_hw_device_api/asrs_hw_device_api.metaxml
speechsrv_plat/asrs_hw_device_api/group/bld.inf
speechsrv_plat/asrs_hw_device_api/inc/asrshwdevice.h
speechsrv_plat/grcompiler_hw_device_api/grcompiler_hw_device_api.metaxml
speechsrv_plat/grcompiler_hw_device_api/group/bld.inf
speechsrv_plat/grcompiler_hw_device_api/inc/asrsgrcompilerhwdevice.h
speechsrv_plat/group/bld.inf
speechsrv_plat/nlp_hw_device/group/bld.inf
speechsrv_plat/nlp_hw_device/inc/asrsnlphwdevice.h
speechsrv_plat/nlp_hw_device/nlp_hw_device.metaxml
speechsrv_plat/nss_devasr_api/group/bld.inf
speechsrv_plat/nss_devasr_api/inc/nssdevasr.h
speechsrv_plat/nss_devasr_api/inc/nssdevasrcommon.h
speechsrv_plat/nss_devasr_api/nss_devasr_api.metaxml
speechsrv_plat/nss_devtts_api/group/bld.inf
speechsrv_plat/nss_devtts_api/inc/nssdevtts.h
speechsrv_plat/nss_devtts_api/nss_devtts_api.metaxml
speechsrv_plat/nss_mmf_tts_custom_commands_api/group/bld.inf
speechsrv_plat/nss_mmf_tts_custom_commands_api/inc/nssttscustomcommandimplementor.h
speechsrv_plat/nss_mmf_tts_custom_commands_api/inc/nssttscustomcommandparser.h
speechsrv_plat/nss_mmf_tts_custom_commands_api/inc/nssttscustomcommands.h
speechsrv_plat/nss_mmf_tts_custom_commands_api/nss_mmf_tts_custom_commands_api.metaxml
speechsrv_plat/nss_si_speech_recognition_data_api/group/bld.inf
speechsrv_plat/nss_si_speech_recognition_data_api/inc/nsssispeechrecognitiondataclient.h
speechsrv_plat/nss_si_speech_recognition_data_api/inc/nsssispeechrecognitiondatacommon.h
speechsrv_plat/nss_si_speech_recognition_data_api/inc/nsssispeechrecognitiondatadevasr.h
speechsrv_plat/nss_si_speech_recognition_data_api/nss_si_speech_recognition_data_api.metaxml
speechsrv_plat/nss_srs_custom_commands_api/group/bld.inf
speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommandimplementor.h
speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommandparser.h
speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommands.h
speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommands_sinde.h
speechsrv_plat/nss_srs_custom_commands_api/nss_srs_custom_commands_api.metaxml
speechsrv_plat/nss_srs_utility_api/group/bld.inf
speechsrv_plat/nss_srs_utility_api/inc/nsssispeechrecognitionutility.h
speechsrv_plat/nss_srs_utility_api/inc/nsssispeechrecognitionutilityobserver.h
speechsrv_plat/nss_srs_utility_api/inc/nsssiutilitybase.h
speechsrv_plat/nss_srs_utility_api/nss_srs_utility_api.metaxml
speechsrv_plat/nss_tts_common_api/group/bld.inf
speechsrv_plat/nss_tts_common_api/inc/nssttscommon.h
speechsrv_plat/nss_tts_common_api/nss_tts_common_api.metaxml
speechsrv_plat/nss_tts_utility_api/group/bld.inf
speechsrv_plat/nss_tts_utility_api/inc/nssttsutility.h
speechsrv_plat/nss_tts_utility_api/inc/nssttsutilitybase.h
speechsrv_plat/nss_tts_utility_api/inc/nssttsutilityobserver.h
speechsrv_plat/nss_tts_utility_api/nss_tts_utility_api.metaxml
speechsrv_plat/recognition_hw_device_api/group/bld.inf
speechsrv_plat/recognition_hw_device_api/inc/asrsrecognitionhwdevice.h
speechsrv_plat/recognition_hw_device_api/recognition_hw_device_api.metaxml
speechsrv_plat/speech_synthesis_clientserver_api/group/bld.inf
speechsrv_plat/speech_synthesis_clientserver_api/inc/speechsynthesis.h
speechsrv_plat/speech_synthesis_clientserver_api/speech_synthesis_clientserver_api.metaxml
speechsrv_plat/srsf_cenrep_settings_api/group/bld.inf
speechsrv_plat/srsf_cenrep_settings_api/inc/srsfdomaincrkeys.h
speechsrv_plat/srsf_cenrep_settings_api/srsf_cenrep_settings_api.metaxml
speechsrv_plat/srsf_secondarydisplay_api/group/bld.inf
speechsrv_plat/srsf_secondarydisplay_api/inc/secondarydisplay/appcontrollersecondarydisplayapi.h
speechsrv_plat/srsf_secondarydisplay_api/srsf_secondarydisplay_api.metaxml
speechsrv_plat/ttp_hw_device_api/group/bld.inf
speechsrv_plat/ttp_hw_device_api/inc/asrsttphwdevice.h
speechsrv_plat/ttp_hw_device_api/ttp_hw_device_api.metaxml
speechsrv_plat/tts_hw_device_api/group/bld.inf
speechsrv_plat/tts_hw_device_api/inc/asrsttshwdevice.h
speechsrv_plat/tts_hw_device_api/tts_hw_device_api.metaxml
speechsrv_plat/ui_voice_recognition_api/group/bld.inf
speechsrv_plat/ui_voice_recognition_api/inc/secondarydisplay/vuisecondarydisplayapi.h
speechsrv_plat/ui_voice_recognition_api/inc/vuicvoicerecog.h
speechsrv_plat/ui_voice_recognition_api/inc/vuicvoicerecogdialog.h
speechsrv_plat/ui_voice_recognition_api/inc/vuivoicerecogdefs.h
speechsrv_plat/ui_voice_recognition_api/tsrc/conf/tctestdomuvrvoicerecog.cfg
speechsrv_plat/ui_voice_recognition_api/tsrc/conf/tctestdomuvrvoiregdiag.cfg
speechsrv_plat/ui_voice_recognition_api/tsrc/conf/ui_testdomuvrvoicerecog.cfg
speechsrv_plat/ui_voice_recognition_api/tsrc/conf/ui_testdomuvrvoiregdiag.cfg
speechsrv_plat/ui_voice_recognition_api/tsrc/group/bld.inf
speechsrv_plat/ui_voice_recognition_api/tsrc/group/testdomuivoicerengn.mmp
speechsrv_plat/ui_voice_recognition_api/tsrc/group/testdomuivoicerengn.pkg
speechsrv_plat/ui_voice_recognition_api/tsrc/inc/testdomuivoicerengn.h
speechsrv_plat/ui_voice_recognition_api/tsrc/init/testdomuivoicerengn.ini
speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuivoicerengn.cpp
speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuivoicerengnblocks.cpp
speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuvrblocksvoicerecog.cpp
speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuvrblocksvoiregdiag.cpp
speechsrv_plat/ui_voice_recognition_api/ui_voice_recognition_api.metaxml
speechsrv_plat/vas_api/group/bld.inf
speechsrv_plat/vas_api/inc/nssvasapi.h
speechsrv_plat/vas_api/inc/nssvascoreconstant.h
speechsrv_plat/vas_api/inc/nssvascrecognitionhandlerbuilder.h
speechsrv_plat/vas_api/inc/nssvascselectnotificationbuilder.h
speechsrv_plat/vas_api/inc/nssvasctrainingparameters.h
speechsrv_plat/vas_api/inc/nssvascvasdbevent.h
speechsrv_plat/vas_api/inc/nssvascvasdbmgr.h
speechsrv_plat/vas_api/inc/nssvasmadaptationeventhandler.h
speechsrv_plat/vas_api/inc/nssvasmadaptationitem.h
speechsrv_plat/vas_api/inc/nssvasmcontext.h
speechsrv_plat/vas_api/inc/nssvasmcontextmgr.h
speechsrv_plat/vas_api/inc/nssvasmdeletecontextclient.h
speechsrv_plat/vas_api/inc/nssvasmdeletetagclient.h
speechsrv_plat/vas_api/inc/nssvasmgetcontextclient.h
speechsrv_plat/vas_api/inc/nssvasmgettagclient.h
speechsrv_plat/vas_api/inc/nssvasmgettagreferenceclient.h
speechsrv_plat/vas_api/inc/nssvasmplayeventhandler.h
speechsrv_plat/vas_api/inc/nssvasmrecognitionhandler.h
speechsrv_plat/vas_api/inc/nssvasmrecognizeeventhandler.h
speechsrv_plat/vas_api/inc/nssvasmrecognizeinitcompletehandler.h
speechsrv_plat/vas_api/inc/nssvasmrejecttagcompletehandler.h
speechsrv_plat/vas_api/inc/nssvasmresetfactorymodelsclient.h
speechsrv_plat/vas_api/inc/nssvasmrrd.h
speechsrv_plat/vas_api/inc/nssvasmsavecontextclient.h
speechsrv_plat/vas_api/inc/nssvasmsavetagclient.h
speechsrv_plat/vas_api/inc/nssvasmspeechitem.h
speechsrv_plat/vas_api/inc/nssvasmtag.h
speechsrv_plat/vas_api/inc/nssvasmtagmgr.h
speechsrv_plat/vas_api/inc/nssvasmtagreference.h
speechsrv_plat/vas_api/inc/nssvasmtagselecthandler.h
speechsrv_plat/vas_api/inc/nssvasmtagselectnotification.h
speechsrv_plat/vas_api/inc/nssvasmtraintexteventhandler.h
speechsrv_plat/vas_api/inc/nssvasmtrainvoiceeventhandler.h
speechsrv_plat/vas_api/inc/nssvasmvasdatabaseobserver.h
speechsrv_plat/vas_api/inc/nssvasmvasdbeventnotifier.h
speechsrv_plat/vas_api/inc/vascvpbkhandler.h
speechsrv_plat/vas_api/inc/vasmbasepbkhandler.h
speechsrv_plat/vas_api/inc/vasmcontactobserver.h
speechsrv_plat/vas_api/vas_api.metaxml
speechsrv_plat/vas_contact_handler_api/group/bld.inf
speechsrv_plat/vas_contact_handler_api/inc/nssvasccontacthandler.h
speechsrv_plat/vas_contact_handler_api/vas_contact_handler_api.metaxml
speechsrv_plat/vas_vcommand_api/group/bld.inf
speechsrv_plat/vas_vcommand_api/inc/vcommandapi.h
speechsrv_plat/vas_vcommand_api/vas_vcommand_api.metaxml
speechsrv_plat/vcommand_settings_cenrep_api/group/bld.inf
speechsrv_plat/vcommand_settings_cenrep_api/inc/vcommanddomaincrkeys.h
speechsrv_plat/vcommand_settings_cenrep_api/vcommand_settings_cenrep_api.metaxml
speechsrv_plat/vocman_hw_device_api/group/bld.inf
speechsrv_plat/vocman_hw_device_api/inc/asrsvocmanhwdevice.h
speechsrv_plat/vocman_hw_device_api/vocman_hw_device_api.metaxml
speechsrv_plat/voice_commands_resource_header_api/group/bld.inf
speechsrv_plat/voice_commands_resource_header_api/inc/voicecommands.rh
speechsrv_plat/voice_commands_resource_header_api/voice_commands_resource_header_api.metaxml
speechsrv_plat/voice_ui_accessory_button_handling_api/group/bld.inf
speechsrv_plat/voice_ui_accessory_button_handling_api/inc/voiceuidomainpskeys.h
speechsrv_plat/voice_ui_accessory_button_handling_api/voice_ui_accessory_button_handling_api.metaxml
speechsrv_plat/voice_ui_plugin_api/group/bld.inf
speechsrv_plat/voice_ui_plugin_api/inc/nssvoiceevent.h
speechsrv_plat/voice_ui_plugin_api/inc/nssvoicestatus.h
speechsrv_plat/voice_ui_plugin_api/inc/nssvoiceuiplugin.h
speechsrv_plat/voice_ui_plugin_api/inc/nssvuipf.hrh
speechsrv_plat/voice_ui_plugin_api/voice_ui_plugin_api.metaxml
srsf/cenrep/keys_srsf.xls
srsf/conf/srsf.confml
srsf/conf/srsf_10281c7d.crml
srsf/devasr/bwins/nssdevasru.def
srsf/devasr/eabi/nssdevasru.def
srsf/devasr/group/bld.inf
srsf/devasr/group/nssdevasr.mmp
srsf/devasr/src/devasr.cpp
srsf/devasr/src/devasrcenrep.cpp
srsf/devasr/src/devasrcenrep.h
srsf/devasr/src/devasrrecognitionalgmgr.cpp
srsf/devasr/src/devasrrecognitionalgmgr.h
srsf/devasr/src/devasrresourcehandler.cpp
srsf/devasr/src/devasrresourcehandler.h
srsf/devasr/src/devasrsrsalgorithmmanager.cpp
srsf/devasr/src/devasrsrsalgorithmmanager.h
srsf/devasr/src/devasrutil.cpp
srsf/devasr/src/devasrutil.h
srsf/devasr/src/devasrvmalgorithmmanager.cpp
srsf/devasr/src/devasrvmalgorithmmanager.h
srsf/devasr/src/nssdevasr.rh
srsf/devasr/src/nssdevasr.rss
srsf/devtts/bwins/nssdevttsu.def
srsf/devtts/eabi/nssdevttsu.def
srsf/devtts/group/bld.inf
srsf/devtts/group/nssdevtts.mmp
srsf/devtts/src/devttsalgorithmmanager.cpp
srsf/devtts/src/devttsalgorithmmanager.h
srsf/devtts/src/devttsaudio.cpp
srsf/devtts/src/devttsaudio.h
srsf/devtts/src/devttscenrep.cpp
srsf/devtts/src/devttscenrep.h
srsf/devtts/src/nssdevtts.cpp
srsf/devtts/src/nssdevtts.rh
srsf/devtts/src/nssdevtts.rss
srsf/group/10201aee.txt
srsf/group/backup_registration.xml
srsf/group/backup_registration_plugin.xml
srsf/group/bld.inf
srsf/group/exports.inc
srsf/group/srsfbldvariant.hrh
srsf/inc/srsfinternalcrkeys.h
srsf/inc/srsfprivatecrkeys.h
srsf/loc/defaultvoicecommands.loc
srsf/nssvasapi/bwins/nssvasapiu.def
srsf/nssvasapi/eabi/nssvasapiu.def
srsf/nssvasapi/group/bld.inf
srsf/nssvasapi/group/exports.inc
srsf/nssvasapi/group/nssvasapi.mmp
srsf/nssvasapi/group/nssvasresource.rss
srsf/nssvasapi/nssvascore/inc/nssvasccontext.h
srsf/nssvasapi/nssvascore/inc/nssvasccontextbuilder.h
srsf/nssvasapi/nssvascore/inc/nssvasccontextsrsportal.h
srsf/nssvasapi/nssvascore/inc/nssvascrrd.h
srsf/nssvasapi/nssvascore/inc/nssvascspeechitem.h
srsf/nssvasapi/nssvascore/inc/nssvascspeechitembuilder.h
srsf/nssvasapi/nssvascore/inc/nssvascspeechitemsrsportal.h
srsf/nssvasapi/nssvascore/inc/nssvascspeechitemtrainer.h
srsf/nssvasapi/nssvascore/inc/nssvasctag.h
srsf/nssvasapi/nssvascore/inc/nssvasctagreference.h
srsf/nssvasapi/nssvascore/inc/nssvasctrainingactiontracker.h
srsf/nssvasapi/nssvascore/inc/nssvassiutilitywrapper.h
srsf/nssvasapi/nssvascore/inc/nssvastspeechitemconstant.h
srsf/nssvasapi/nssvascore/inc/nssvasttsutilitywrapper.h
srsf/nssvasapi/nssvascore/src/nssvasapimain.cpp
srsf/nssvasapi/nssvascore/src/nssvasccontext.cpp
srsf/nssvasapi/nssvascore/src/nssvasccontextbuilder.cpp
srsf/nssvasapi/nssvascore/src/nssvasccontextsrsportal.cpp
srsf/nssvasapi/nssvascore/src/nssvascrrd.cpp
srsf/nssvasapi/nssvascore/src/nssvascspeechitem.cpp
srsf/nssvasapi/nssvascore/src/nssvascspeechitembuilder.cpp
srsf/nssvasapi/nssvascore/src/nssvascspeechitemsrsportal.cpp
srsf/nssvasapi/nssvascore/src/nssvascspeechitemtrainer.cpp
srsf/nssvasapi/nssvascore/src/nssvasctag.cpp
srsf/nssvasapi/nssvascore/src/nssvasctagreference.cpp
srsf/nssvasapi/nssvascore/src/nssvasctrainingactiontracker.cpp
srsf/nssvasapi/nssvascore/src/nssvasctrainingparams.cpp
srsf/nssvasapi/nssvascore/src/nssvassiutilitywrapper.cpp
srsf/nssvasapi/nssvascore/src/nssvasttsutilitywrapper.cpp
srsf/nssvasapi/nssvascore/src/vascvpbkhandler.cpp
srsf/nssvasapi/nssvasdb/inc/10201afe.spd
srsf/nssvasapi/nssvasdb/inc/nssvasccontextmgr.h
srsf/nssvasapi/nssvasdb/inc/nssvascdbtagselectnotifier.h
srsf/nssvasapi/nssvasdb/inc/nssvascresourcehandler.h
srsf/nssvasapi/nssvasdb/inc/nssvasctagmgr.h
srsf/nssvasapi/nssvasdb/inc/nssvascvasdatabase.h
srsf/nssvasapi/nssvasdb/inc/nssvascvasdb.h
srsf/nssvasapi/nssvasdb/inc/nssvascvasdbbuilder.h
srsf/nssvasapi/nssvasdb/inc/nssvascvasdbdataexchanger.h
srsf/nssvasapi/nssvasdb/inc/nssvascvasdbsrvdef.h
srsf/nssvasapi/nssvasdb/inc/nssvasdbkonsts.h
srsf/nssvasapi/nssvasdb/inc/nssvasmcoresrsdbeventhandler.h
srsf/nssvasapi/nssvasdb/inc/nssvasmcoresyncrecoveryhandler.h
srsf/nssvasapi/nssvasdb/inc/nssvasmdbtagselectnotifierclient.h
srsf/nssvasapi/nssvasdb/inc/nssvasmintercompcontextmgrclient.h
srsf/nssvasapi/nssvasdb/inc/nssvasmintercomptagmgrclient.h
srsf/nssvasapi/nssvasdb/inc/nssvasmvasdatabaseclient.h
srsf/nssvasapi/nssvasdb/inc/nssvasresource.rh
srsf/nssvasapi/nssvasdb/inc/nssvasrvasdbsession.h
srsf/nssvasapi/nssvasdb/inc/nssvastvasdbcreator.h
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/group/bld.inf
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/group/exports.inc
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/group/nssvasdbeventnotifier.mmp
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/inc/nssvascvasdbeventmonitor.h
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/inc/nssvascvasdbeventnotifier.h
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/src/nssvascvasdbevent.cpp
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/src/nssvascvasdbeventmonitor.cpp
srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/src/nssvascvasdbeventnotifier.cpp
srsf/nssvasapi/nssvasdb/src/10201afe.txt
srsf/nssvasapi/nssvasdb/src/nssvasbackupobserver.cpp
srsf/nssvasapi/nssvasdb/src/nssvasbackupobserver.h
srsf/nssvasapi/nssvasdb/src/nssvasccontextmgr.cpp
srsf/nssvasapi/nssvasdb/src/nssvascdbtagselectnotifier.cpp
srsf/nssvasapi/nssvasdb/src/nssvascresourcehandler.cpp
srsf/nssvasapi/nssvasdb/src/nssvasctagmgr.cpp
srsf/nssvasapi/nssvasdb/src/nssvascvasdatabase.cpp
srsf/nssvasapi/nssvasdb/src/nssvascvasdb.cpp
srsf/nssvasapi/nssvasdb/src/nssvascvasdbbuilder.cpp
srsf/nssvasapi/nssvasdb/src/nssvascvasdbmgr.cpp
srsf/nssvasapi/nssvasdb/src/nssvasrvasdbsession.cpp
srsf/nssvasapi/nssvasdb/src/nssvastvasdbcreator.cpp
srsf/nssvasapi/nssvasrecognition/inc/nssvascadaptationitem.h
srsf/nssvasapi/nssvasrecognition/inc/nssvascrecognitionhandler.h
srsf/nssvasapi/nssvasrecognition/inc/nssvasctagselectdata.h
srsf/nssvasapi/nssvasrecognition/inc/nssvasctagselectnotification.h
srsf/nssvasapi/nssvasrecognition/src/nssvascadaptationitem.cpp
srsf/nssvasapi/nssvasrecognition/src/nssvascrecognitionhandler.cpp
srsf/nssvasapi/nssvasrecognition/src/nssvascrecognitionhandlerbuilder.cpp
srsf/nssvasapi/nssvasrecognition/src/nssvascselectnotificationbuilder.cpp
srsf/nssvasapi/nssvasrecognition/src/nssvasctagselectdata.cpp
srsf/nssvasapi/nssvasrecognition/src/nssvasctagselectnotification.cpp
srsf/nssvascontacthdlr/bmarm/nssvascontacthdlru.def
srsf/nssvascontacthdlr/bwins/nssvascontacthdlru.def
srsf/nssvascontacthdlr/data/nssvascontacthandler.rss
srsf/nssvascontacthdlr/eabi/nssvascontacthdlru.def
srsf/nssvascontacthdlr/group/bld.inf
srsf/nssvascontacthdlr/group/exports.inc
srsf/nssvascontacthdlr/group/nssvascontacthdlr.mmp
srsf/nssvascontacthdlr/loc/sindextensioncommands.loc
srsf/nssvascontacthdlr/src/nsschbackupobserver.cpp
srsf/nssvascontacthdlr/src/nsschbackupobserver.h
srsf/nssvascontacthdlr/src/nssvasccontacthandler.cpp
srsf/nssvascontacthdlr/src/nssvasccontacthandlerimpl.cpp
srsf/nssvascontacthdlr/src/nssvasccontacthandlerimpl.h
srsf/nssvascontacthdlr/src/nssvasdatasyncwatcher.cpp
srsf/nssvascontacthdlr/src/nssvasdatasyncwatcher.h
srsf/profileobserverplugin/data/10281ced.rss
srsf/profileobserverplugin/data/vcprofileobserver.rh
srsf/profileobserverplugin/data/vcprofileobserver.rss
srsf/profileobserverplugin/group/bld.inf
srsf/profileobserverplugin/group/vuipprofileobserverplugin.mmp
srsf/profileobserverplugin/inc/vcommandprofileobserver.h
srsf/profileobserverplugin/inc/vuipprofileobserverplugin.h
srsf/profileobserverplugin/src/vcommandprofileobserver.cpp
srsf/profileobserverplugin/src/vuipprofileobserverecomsupport.cpp
srsf/profileobserverplugin/src/vuipprofileobserverplugin.cpp
srsf/rom/exports.inc
srsf/rom/srsf.iby
srsf/rom/srsf_variant.iby
srsf/rom/srsfresources.iby
srsf/rubydebug/rubydebug.cpp
srsf/rubydebug/rubydebug.h
srsf/rubydebug/rubydebug.inl
srsf/rubydebug/rubydebugcfg.h
srsf/rubydebug/rubydebugconfigselector.h
srsf/sicc/bwins/nsssispeechrecognitioncustomcommands_sindeu.def
srsf/sicc/bwins/nsssispeechrecognitioncustomcommandsu.def
srsf/sicc/eabi/nsssispeechrecognitioncustomcommands_sindeu.def
srsf/sicc/eabi/nsssispeechrecognitioncustomcommandsu.def
srsf/sicc/group/bld.inf
srsf/sicc/group/nsssispeechrecognitioncustomcommands.mmp
srsf/sicc/src/nsssicustomcommanddata.cpp
srsf/sicc/src/nsssicustomcommanddata.h
srsf/sicc/src/nsssispeechrecognitioncustomcommandcommon.h
srsf/sicc/src/nsssispeechrecognitioncustomcommandparser.cpp
srsf/sicc/src/nsssispeechrecognitioncustomcommands.cpp
srsf/sispeechrecognitiondata/bmarm/nsssispeechrecognitiondatau.def
srsf/sispeechrecognitiondata/bwins/nsssispeechrecognitiondatau.def
srsf/sispeechrecognitiondata/eabi/nsssispeechrecognitiondatau.def
srsf/sispeechrecognitiondata/group/bld.inf
srsf/sispeechrecognitiondata/group/nsssispeechrecognitiondata.mmp
srsf/sispeechrecognitiondata/inc/nsssispeechrecognitiondatatest.h
srsf/sispeechrecognitiondata/src/nsssidataserialize.cpp
srsf/sispeechrecognitiondata/src/nsssidataserialize.h
srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondataclient.cpp
srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondatacommon.cpp
srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondatadevasr.cpp
srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondatatest.cpp
srsf/sisrscontrollerplugin/data/101ff930.rss
srsf/sisrscontrollerplugin/data/nsssisrscontrollerplugin.rss
srsf/sisrscontrollerplugin/group/bld.inf
srsf/sisrscontrollerplugin/group/sicontrollerplugin.mmp
srsf/sisrscontrollerplugin/inc/10201aff.spd
srsf/sisrscontrollerplugin/src/10201aff.txt
srsf/sisrscontrollerplugin/src/asrplugindataloader.cpp
srsf/sisrscontrollerplugin/src/asrplugindataloader.h
srsf/sisrscontrollerplugin/src/nssbackupobserver.cpp
srsf/sisrscontrollerplugin/src/nssbackupobserver.h
srsf/sisrscontrollerplugin/src/sicommondb.cpp
srsf/sisrscontrollerplugin/src/sicommondb.h
srsf/sisrscontrollerplugin/src/siconsoletest.h
srsf/sisrscontrollerplugin/src/sicontrollerplugin.cpp
srsf/sisrscontrollerplugin/src/sicontrollerplugin.h
srsf/sisrscontrollerplugin/src/sicontrollerplugininterface.cpp
srsf/sisrscontrollerplugin/src/sicontrollerplugininterface.h
srsf/sisrscontrollerplugin/src/sicontrollerresource.rh
srsf/sisrscontrollerplugin/src/sidatabase.cpp
srsf/sisrscontrollerplugin/src/sidatabase.h
srsf/sisrscontrollerplugin/src/sigrammardb.cpp
srsf/sisrscontrollerplugin/src/sigrammardb.h
srsf/sisrscontrollerplugin/src/silexicondb.cpp
srsf/sisrscontrollerplugin/src/silexicondb.h
srsf/sisrscontrollerplugin/src/simodelbankdb.cpp
srsf/sisrscontrollerplugin/src/simodelbankdb.h
srsf/sisrscontrollerplugin/src/sindetraining.cpp
srsf/sisrscontrollerplugin/src/sindetraining.h
srsf/sisrscontrollerplugin/src/sipluginimplementationuids.hrh
srsf/sisrscontrollerplugin/src/siresourcehandler.cpp
srsf/sisrscontrollerplugin/src/siresourcehandler.h
srsf/sisrscontrollerplugin/src/sysconfigprovider.h
srsf/siutility/bwins/nsssispeechrecognitionutilityu.def
srsf/siutility/eabi/nsssispeechrecognitionutilityu.def
srsf/siutility/group/bld.inf
srsf/siutility/group/nsssispeechrecognitionutility.mmp
srsf/siutility/src/nsssispeechrecognitionutility.cpp
srsf/speechsynthesis/client/bwins/speechsynthesisu.def
srsf/speechsynthesis/client/eabi/speechsynthesisu.def
srsf/speechsynthesis/client/group/bld.inf
srsf/speechsynthesis/client/group/speechsynthesis.mmp
srsf/speechsynthesis/client/src/speechsynthesis.cpp
srsf/speechsynthesis/server/group/bld.inf
srsf/speechsynthesis/server/group/speechsynthesisserver.mmp
srsf/speechsynthesis/server/inc/speechsynthesisclientserver.h
srsf/speechsynthesis/server/inc/speechsynthesisserver.h
srsf/speechsynthesis/server/inc/speechsynthesisserverutilities.h
srsf/speechsynthesis/server/inc/speechsynthesissession.h
srsf/speechsynthesis/server/src/speechsynthesisserver.cpp
srsf/speechsynthesis/server/src/speechsynthesisserverutilities.cpp
srsf/speechsynthesis/server/src/speechsynthesissession.cpp
srsf/speechsynthesis/tsrc/speechsynthesistest/bwins/speechsynthesistestu.def
srsf/speechsynthesis/tsrc/speechsynthesistest/data/speechsynthesistest.cfg
srsf/speechsynthesis/tsrc/speechsynthesistest/data/testframework.ini
srsf/speechsynthesis/tsrc/speechsynthesistest/eabi/speechsynthesistestu.def
srsf/speechsynthesis/tsrc/speechsynthesistest/group/bld.inf
srsf/speechsynthesis/tsrc/speechsynthesistest/group/create_signed_sis.bat
srsf/speechsynthesis/tsrc/speechsynthesistest/group/export.inc
srsf/speechsynthesis/tsrc/speechsynthesistest/group/speechsynthesistest.mmp
srsf/speechsynthesis/tsrc/speechsynthesistest/group/speechsynthesistest.pkg
srsf/speechsynthesis/tsrc/speechsynthesistest/inc/speechsynthesistest.h
srsf/speechsynthesis/tsrc/speechsynthesistest/inc/speechsynthesistester.h
srsf/speechsynthesis/tsrc/speechsynthesistest/src/speechsynthesistest.cpp
srsf/speechsynthesis/tsrc/speechsynthesistest/src/speechsynthesistestblocks.cpp
srsf/speechsynthesis/tsrc/speechsynthesistest/src/speechsynthesistester.cpp
srsf/speechsynthesis/tsrc/testapplication/data/testapplication.rss
srsf/speechsynthesis/tsrc/testapplication/data/testapplication_reg.rss
srsf/speechsynthesis/tsrc/testapplication/group/bld.inf
srsf/speechsynthesis/tsrc/testapplication/group/create_signed_sis.bat
srsf/speechsynthesis/tsrc/testapplication/group/testapp.mmp
srsf/speechsynthesis/tsrc/testapplication/group/testapplication.pkg
srsf/speechsynthesis/tsrc/testapplication/inc/testapp.hrh
srsf/speechsynthesis/tsrc/testapplication/inc/testappapp.h
srsf/speechsynthesis/tsrc/testapplication/inc/testappappui.h
srsf/speechsynthesis/tsrc/testapplication/inc/testappcontainer.h
srsf/speechsynthesis/tsrc/testapplication/inc/testappdocument.h
srsf/speechsynthesis/tsrc/testapplication/inc/testappengine.h
srsf/speechsynthesis/tsrc/testapplication/src/testappapp.cpp
srsf/speechsynthesis/tsrc/testapplication/src/testappappui.cpp
srsf/speechsynthesis/tsrc/testapplication/src/testappcontainer.cpp
srsf/speechsynthesis/tsrc/testapplication/src/testappdocument.cpp
srsf/speechsynthesis/tsrc/testapplication/src/testappengine.cpp
srsf/speechsynthesis/tsrc/texttospeech/data/texttospeech.loc
srsf/speechsynthesis/tsrc/texttospeech/data/texttospeech.rss
srsf/speechsynthesis/tsrc/texttospeech/data/texttospeech_reg.rss
srsf/speechsynthesis/tsrc/texttospeech/gfx/qgn_menu_texttospeech.svg
srsf/speechsynthesis/tsrc/texttospeech/group/bld.inf
srsf/speechsynthesis/tsrc/texttospeech/group/icons_scalable_dc.mk
srsf/speechsynthesis/tsrc/texttospeech/group/texttospeech.mmp
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeech.hrh
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechapplication.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechappui.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechdocument.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechengine.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechsettingitemlist.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechsettingitemlistsettings.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechsettingitemlistview.h
srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechuid.hrh
srsf/speechsynthesis/tsrc/texttospeech/sis/texttospeech.pkg
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechapplication.cpp
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechappui.cpp
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechdocument.cpp
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechengine.cpp
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechsettingitemlist.cpp
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechsettingitemlistsettings.cpp
srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechsettingitemlistview.cpp
srsf/tsrc/public/basic/conf/ttscontrollerplugintest.cfg
srsf/tsrc/public/basic/conf/ttsutilitytest.cfg
srsf/tsrc/public/basic/data/ttscontrollerplugintestdata.txt
srsf/tsrc/public/basic/data/ttsutilitytestdata.txt
srsf/tsrc/public/basic/group/bld.inf
srsf/tsrc/public/basic/group/test.pkg
srsf/tsrc/public/basic/init/test.ini
srsf/tsrc/public/basic/ttscontrollerplugintest/bwins/ttscontrollerplugintestu.def
srsf/tsrc/public/basic/ttscontrollerplugintest/eabi/ttscontrollerplugintestu.def
srsf/tsrc/public/basic/ttscontrollerplugintest/group/bld.inf
srsf/tsrc/public/basic/ttscontrollerplugintest/group/export.inc
srsf/tsrc/public/basic/ttscontrollerplugintest/group/ttscontrollerplugintest.ini
srsf/tsrc/public/basic/ttscontrollerplugintest/group/ttscontrollerplugintest.mmp
srsf/tsrc/public/basic/ttscontrollerplugintest/inc/ttscontrollerplugintest.h
srsf/tsrc/public/basic/ttscontrollerplugintest/src/ttscontrollerplugintest.cpp
srsf/tsrc/public/basic/ttscontrollerplugintest/src/ttscontrollerplugintestblocks.cpp
srsf/tsrc/public/basic/ttsutilitytest/bwins/ttsutilitytestu.def
srsf/tsrc/public/basic/ttsutilitytest/eabi/ttsutilitytestu.def
srsf/tsrc/public/basic/ttsutilitytest/group/bld.inf
srsf/tsrc/public/basic/ttsutilitytest/group/export.inc
srsf/tsrc/public/basic/ttsutilitytest/group/ttsutilitytest.ini
srsf/tsrc/public/basic/ttsutilitytest/group/ttsutilitytest.mmp
srsf/tsrc/public/basic/ttsutilitytest/inc/ttsutilitytest.h
srsf/tsrc/public/basic/ttsutilitytest/src/ttsutilitytest.cpp
srsf/tsrc/public/basic/ttsutilitytest/src/ttsutilitytestblocks.cpp
srsf/ttscommon/bwins/nssttscommonu.def
srsf/ttscommon/eabi/nssttscommonu.def
srsf/ttscommon/group/bld.inf
srsf/ttscommon/group/nssttscommon.mmp
srsf/ttscommon/group/std.lnt
srsf/ttscommon/src/nssttscommon.cpp
srsf/ttscommon/src/ttscommonbody.cpp
srsf/ttscommon/src/ttscommonbody.h
srsf/ttscontrollerplugin/group/bld.inf
srsf/ttscontrollerplugin/group/nssttscontrollerplugin.mmp
srsf/ttscontrollerplugin/src/101ff933.rss
srsf/ttscontrollerplugin/src/nssttscontrollerplugin.rh
srsf/ttscontrollerplugin/src/ttsplugin.cpp
srsf/ttscontrollerplugin/src/ttsplugin.h
srsf/ttscontrollerplugin/src/ttspluginbody.cpp
srsf/ttscontrollerplugin/src/ttspluginbody.h
srsf/ttscontrollerplugin/src/ttsplugindataloader.cpp
srsf/ttscontrollerplugin/src/ttsplugindataloader.h
srsf/ttscontrollerplugin/src/ttspluginimplementationuids.hrh
srsf/ttscontrollerplugin/src/ttspluginresourcehandler.cpp
srsf/ttscontrollerplugin/src/ttspluginresourcehandler.h
srsf/ttscontrollerplugin/src/ttspluginsettings.rss
srsf/ttscustomcommands/bwins/nssttscustomcommandsu.def
srsf/ttscustomcommands/eabi/nssttscustomcommandsu.def
srsf/ttscustomcommands/group/bld.inf
srsf/ttscustomcommands/group/nssttscustomcommands.mmp
srsf/ttscustomcommands/src/nssttscustomcommandcommon.h
srsf/ttscustomcommands/src/nssttscustomcommandparser.cpp
srsf/ttscustomcommands/src/nssttscustomcommands.cpp
srsf/ttsutility/bwins/nssttsutilityu.def
srsf/ttsutility/eabi/nssttsutilityu.def
srsf/ttsutility/group/bld.inf
srsf/ttsutility/group/nssttsutility.mmp
srsf/ttsutility/src/nssttsutility.cpp
srsf/ttsutility/src/ttsutilitybody.cpp
srsf/ttsutility/src/ttsutilitybody.h
srsf/vcexecutorapp/data/vcexecutorapp.rss
srsf/vcexecutorapp/data/vcexecutorapp_reg.rss
srsf/vcexecutorapp/group/bld.inf
srsf/vcexecutorapp/group/exports.inc
srsf/vcexecutorapp/group/vcexecutorapp.mmp
srsf/vcexecutorapp/inc/appcontroller.h
srsf/vcexecutorapp/inc/appcontroller.hrh
srsf/vcexecutorapp/inc/appcontrolleractiveobject.h
srsf/vcexecutorapp/inc/appcontrollerconstants.h
srsf/vcexecutorapp/inc/appcontrollerpropertyhandler.h
srsf/vcexecutorapp/inc/vcexecutorapp.h
srsf/vcexecutorapp/inc/vcexecutorappdocument.h
srsf/vcexecutorapp/inc/vcexecutorappui.h
srsf/vcexecutorapp/loc/vcexecutorapp.loc
srsf/vcexecutorapp/src/appcontroller.cpp
srsf/vcexecutorapp/src/appcontrolleractiveobject.cpp
srsf/vcexecutorapp/src/appcontrollerpropertyhandler.cpp
srsf/vcexecutorapp/src/vcexecutorapp.cpp
srsf/vcexecutorapp/src/vcexecutorappdocument.cpp
srsf/vcexecutorapp/src/vcexecutorappui.cpp
srsf/vcommandexecutor/data/nss_voicecommands.rh
srsf/vcommandexecutor/data/nss_voicecommands.rss
srsf/vcommandexecutor/data/vcommandexecutor.rh
srsf/vcommandexecutor/data/vcommandexecutor.rss
srsf/vcommandexecutor/group/bld.inf
srsf/vcommandexecutor/group/nssvcexecutor.rss
srsf/vcommandexecutor/group/nssvcommandexecutor.mmp
srsf/vcommandexecutor/inc/nssvcapplauncher.h
srsf/vcommandexecutor/inc/nssvcapplauncher.hrh
srsf/vcommandexecutor/inc/nssvcapplauncherconstants.h
srsf/vcommandexecutor/src/nssvcapplauncher.cpp
srsf/vcommandexecutor/src/nssvcommandexecutor.cpp
srsf/vcommandexecutorbearer/group/10281c7e.rss
srsf/vcommandexecutorbearer/group/bld.inf
srsf/vcommandexecutorbearer/group/nssvcexecutorbearer.mmp
srsf/vcommandexecutorbearer/inc/nssvcexecutorbearer.hrh
srsf/vcommandexecutorbearer/inc/nssvcexecutorbearerimpl.h
srsf/vcommandexecutorbearer/src/nssvcexecutorbearerimpl.cpp
srsf/vcommandexecutorbearer/src/nssvcexecutorbearermain.cpp
srsf/vcommandhandler/bwins/vcommandhandleru.def
srsf/vcommandhandler/eabi/vcommandhandleru.def
srsf/vcommandhandler/group/bld.inf
srsf/vcommandhandler/group/testexports.inc
srsf/vcommandhandler/group/testmmpfiles.inc
srsf/vcommandhandler/group/vcommandhandler.mmp
srsf/vcommandhandler/inc/asyncworker.h
srsf/vcommandhandler/inc/contextprovider.h
srsf/vcommandhandler/inc/desarrayconverter.h
srsf/vcommandhandler/inc/intpropertywatcher.h
srsf/vcommandhandler/inc/tagcommandconverter.h
srsf/vcommandhandler/inc/taggetter.h
srsf/vcommandhandler/inc/tagnameset.h
srsf/vcommandhandler/inc/tagplayer.h
srsf/vcommandhandler/inc/vcommandinternalapi.h
srsf/vcommandhandler/inc/vcommandrecoghandler.h
srsf/vcommandhandler/inc/vcommandrecogmanager.h
srsf/vcommandhandler/inc/vcommandservices.h
srsf/vcommandhandler/src/asyncworker.cpp
srsf/vcommandhandler/src/contextprovider.cpp
srsf/vcommandhandler/src/desarrayconverter.cpp
srsf/vcommandhandler/src/intpropertywatcher.cpp
srsf/vcommandhandler/src/storedvcommand.cpp
srsf/vcommandhandler/src/tagcommandconverter.cpp
srsf/vcommandhandler/src/taggetter.cpp
srsf/vcommandhandler/src/tagnameset.cpp
srsf/vcommandhandler/src/tagplayer.cpp
srsf/vcommandhandler/src/vcfolderinfo.cpp
srsf/vcommandhandler/src/vcommand.cpp
srsf/vcommandhandler/src/vcommandarray.cpp
srsf/vcommandhandler/src/vcommandhandler.cpp
srsf/vcommandhandler/src/vcommandrecoghandler.cpp
srsf/vcommandhandler/src/vcommandrecogmanager.cpp
srsf/vcommandhandler/src/vcommandrunnable.cpp
srsf/vcommandhandler/src/vcommandservices.cpp
srsf/vcommandhandler/src/vcommandui.cpp
srsf/vcommandmanager/data/defaultvoicecommands.rss
srsf/vcommandmanager/data/vcommandmanager.rss
srsf/vcommandmanager/data/vcommandmanager_reg.rss
srsf/vcommandmanager/data/voicecommands.rss
srsf/vcommandmanager/group/bld.inf
srsf/vcommandmanager/group/exports.inc
srsf/vcommandmanager/group/vcommandmanager.mmp
srsf/vcommandmanager/inc/btvoicecommands.xml
srsf/vcommandmanager/inc/defaultvoicecommands.xml
srsf/vcommandmanager/inc/dictvoicecommands.xml
srsf/vcommandmanager/inc/emailvoicecommands.xml
srsf/vcommandmanager/inc/imvoicecommands.xml
srsf/vcommandmanager/inc/locationvoicecommands.xml
srsf/vcommandmanager/inc/mmspostcardvoicecommands.xml
srsf/vcommandmanager/inc/radiovoicecommands.xml
srsf/vcommandmanager/inc/realplayervoicecommands.xml
srsf/vcommandmanager/inc/remconradiovoicecommands.xml
srsf/vcommandmanager/inc/remconvoicecommands.xml
srsf/vcommandmanager/inc/vrvoicecommands.xml
srsf/vcommandmanager/src/vcmanagerapp.cpp
srsf/vcommandmanager/src/vcmanagerapp.h
srsf/vcommandmanager/src/vcmanagerappui.cpp
srsf/vcommandmanager/src/vcmanagerappui.h
srsf/vcommandmanager/src/vcmanagerbackupobserver.cpp
srsf/vcommandmanager/src/vcmanagerbackupobserver.h
srsf/vcommandmanager/src/vcmanagercontactselecthandler_aiw.cpp
srsf/vcommandmanager/src/vcmanagercontactselecthandler_aiw.h
srsf/vcommandmanager/src/vcmanagerdialer_aiw.cpp
srsf/vcommandmanager/src/vcmanagerdialer_aiw.h
srsf/vcommandmanager/src/vcmanagerdocument.cpp
srsf/vcommandmanager/src/vcmanagerdocument.h
srsf/vcommandmanager/src/vcmanagervoiceheadsetlauncher.cpp
srsf/vcommandmanager/src/vcmanagervoiceheadsetlauncher.h
srsf/vcommandmanager/src/vcmanagervoicekeylauncher.cpp
srsf/vcommandmanager/src/vcmanagervoicekeylauncher.h
srsf/vcommandmanager/src/vcommandmanager.cpp
srsf/vcommandmanager/src/vcommandmanager.h
srsf/vcommandmanager/src/vcommandmerger.cpp
srsf/vcommandmanager/src/vcommandmerger.h
srsf/vcommandmanager/src/vcresource.cpp
srsf/vcommandmanager/src/vcresource.h
srsf/vcommandmanager/src/vcxmlparser.cpp
srsf/vcommandmanager/src/vcxmlparser.h
srsf/vuiphandler/bmarm/nssvoiceuipluginhandleru.def
srsf/vuiphandler/bwins/nssvoiceuipluginhandleru.def
srsf/vuiphandler/eabi/nssvoiceuipluginhandleru.def
srsf/vuiphandler/group/bld.inf
srsf/vuiphandler/group/nssvoiceuipluginhandler.mmp
srsf/vuiphandler/inc/nssvoiceuipluginhandler.h
srsf/vuiphandler/src/nssvoiceuipluginhandler.cpp
sysdef_1_4_0.dtd
tsrc/group/bld.inf
voiceui/aiwpbkinfoviewprovider/group/aiwpbkinfoviewprovider.mmp
voiceui/aiwpbkinfoviewprovider/group/bld.inf
voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewprovider.h
voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewprovider.rh
voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewproviderdebug.h
voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewprovideruids.hrh
voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewproviderutil.h
voiceui/aiwpbkinfoviewprovider/src/10281c81.rss
voiceui/aiwpbkinfoviewprovider/src/aiwpbkinfoviewprovider.cpp
voiceui/aiwpbkinfoviewprovider/src/aiwpbkinfoviewprovider.rss
voiceui/group/bld.inf
voiceui/group/exports.inc
voiceui/group/icons.mk
voiceui/group/icons_scalable.mk
voiceui/group/voiceuibldvariant.hrh
voiceui/pbkinfoviewimpl/bwins/pbkinfoviewu.def
voiceui/pbkinfoviewimpl/eabi/pbkinfoviewu.def
voiceui/pbkinfoviewimpl/group/bld.inf
voiceui/pbkinfoviewimpl/group/pbkinfoview.mmp
voiceui/pbkinfoviewimpl/inc/pbkinfoview.rh
voiceui/pbkinfoviewimpl/inc/pbkinfoviewapi.h
voiceui/pbkinfoviewimpl/inc/pbkinfoviewdialog.h
voiceui/pbkinfoviewimpl/inc/pbkinfoviewdialogutil.h
voiceui/pbkinfoviewimpl/inc/pbkinfoviewreshandler.h
voiceui/pbkinfoviewimpl/inc/pbkinfoviewsindhandler.h
voiceui/pbkinfoviewimpl/inc/pbkinfoviewutil.h
voiceui/pbkinfoviewimpl/loc/pbkinfoview.loc
voiceui/pbkinfoviewimpl/src/pbkinfoview.rss
voiceui/pbkinfoviewimpl/src/pbkinfoviewapi.cpp
voiceui/pbkinfoviewimpl/src/pbkinfoviewdefines.h
voiceui/pbkinfoviewimpl/src/pbkinfoviewdialog.cpp
voiceui/pbkinfoviewimpl/src/pbkinfoviewdialogutil.cpp
voiceui/pbkinfoviewimpl/src/pbkinfoviewreshandler.cpp
voiceui/pbkinfoviewimpl/src/pbkinfoviewsindhandler.cpp
voiceui/pbkinfoviewimpl/src/pbkinfoviewutil.cpp
voiceui/rom/exports.inc
voiceui/rom/vcommand.iby
voiceui/rom/vcommandresources.iby
voiceui/rom/voiceui.iby
voiceui/rom/voiceuiresources.iby
voiceui/rubydebug/rubydebug.cpp
voiceui/rubydebug/rubydebug.h
voiceui/rubydebug/rubydebug.inl
voiceui/rubydebug/rubydebugcfg.h
voiceui/rubydebug/rubydebugconfigselector.h
voiceui/vccontrolpanelplugin/data/10282c40.rss
voiceui/vccontrolpanelplugin/data/vccontrolpanelpluginrsc.rss
voiceui/vccontrolpanelplugin/group/bld.inf
voiceui/vccontrolpanelplugin/group/vccontrolpanelplugin.mmp
voiceui/vccontrolpanelplugin/group/vccp_icons_scalable_dc.mk
voiceui/vccontrolpanelplugin/inc/vccontrolpanelplugin.h
voiceui/vccontrolpanelplugin/inc/vccontrolpanelpluginuids.hrh
voiceui/vccontrolpanelplugin/src/vccontrolpanelplugin.cpp
voiceui/vccontrolpanelplugin/src/vccontrolpanelpluginimplementationtable.cpp
voiceui/vcommand/aif/context_pane_icon.bmp
voiceui/vcommand/aif/context_pane_icon_mask.bmp
voiceui/vcommand/aif/list_icon.bmp
voiceui/vcommand/aif/list_icon_mask.bmp
voiceui/vcommand/aif/qgn_indi_voice_add.bmp
voiceui/vcommand/aif/qgn_indi_voice_add_mask.bmp
voiceui/vcommand/aif/qgn_menu_vc_cxt.bmp
voiceui/vcommand/aif/qgn_menu_vc_cxt_mask.bmp
voiceui/vcommand/aif/qgn_menu_vc_lst.bmp
voiceui/vcommand/aif/qgn_menu_vc_lst_mask.bmp
voiceui/vcommand/aif/qgn_prop_folder_small.bmp
voiceui/vcommand/aif/qgn_prop_folder_small_mask.bmp
voiceui/vcommand/aif/qgn_vc_transparent_icon.bmp
voiceui/vcommand/aif/qgn_vc_transparent_icon_mask.bmp
voiceui/vcommand/aif/qgn_vc_voice_icon.bmp
voiceui/vcommand/aif/qgn_vc_voice_icon_mask.bmp
voiceui/vcommand/aif/vcommandaif.rss
voiceui/vcommand/cenrep/keys_vcommand.xls
voiceui/vcommand/conf/vcommand.confml
voiceui/vcommand/conf/vcommand_10207267.crml
voiceui/vcommand/data/vcommand.rh
voiceui/vcommand/data/vcommand.rss
voiceui/vcommand/data/vcommand_caption.rss
voiceui/vcommand/data/vcommand_reg.rss
voiceui/vcommand/group/bld.inf
voiceui/vcommand/group/icons_aif_bitmaps_dc.mk
voiceui/vcommand/group/icons_aif_scalable_dc.mk
voiceui/vcommand/group/icons_dc.mk
voiceui/vcommand/group/icons_scalable_dc.mk
voiceui/vcommand/group/vcommand.mmp
voiceui/vcommand/help/data/xhtml.zip
voiceui/vcommand/help/group/bld.inf
voiceui/vcommand/help/inc/vc.hlp.hrh
voiceui/vcommand/help/rom/vcommandhelps_variant.iby
voiceui/vcommand/inc/accessorybuttonmonitor.h
voiceui/vcommand/inc/backup_registration.xml
voiceui/vcommand/inc/headsetbuttonmonitor.h
voiceui/vcommand/inc/uiarraysgenerator.h
voiceui/vcommand/inc/vcapp.h
voiceui/vcommand/inc/vcappui.h
voiceui/vcommand/inc/vcdocument.h
voiceui/vcommand/inc/vcdoublelargestylelistbox.h
voiceui/vcommand/inc/vcfolderview.h
voiceui/vcommand/inc/vcgenericcontainer.h
voiceui/vcommand/inc/vcgenericview.h
voiceui/vcommand/inc/vcmodel.h
voiceui/vcommand/inc/vcmodelappuiinterface.h
voiceui/vcommand/inc/vcommand.hrh
voiceui/vcommand/inc/vcommandconstants.h
voiceui/vcommand/inc/vcommandinternalcrkeys.h
voiceui/vcommand/inc/vcommanduientry.h
voiceui/vcommand/inc/vcommanduientryarray.h
voiceui/vcommand/inc/vcplaybackdialog.h
voiceui/vcommand/inc/vcsettingscontainer.h
voiceui/vcommand/inc/vcsettingsengine.h
voiceui/vcommand/inc/vcsettingslist.h
voiceui/vcommand/inc/vcsettingsview.h
voiceui/vcommand/inc/vctextquerydialog.h
voiceui/vcommand/inc/vctoneplayer.h
voiceui/vcommand/inc/vctonereader.h
voiceui/vcommand/loc/vcommand.loc
voiceui/vcommand/rubydebug/rubydebug.cpp
voiceui/vcommand/rubydebug/rubydebug.h
voiceui/vcommand/rubydebug/rubydebug.inl
voiceui/vcommand/rubydebug/rubydebugcfg.h
voiceui/vcommand/rubydebug/rubydebugconfigselector.h
voiceui/vcommand/src/accessorybuttonmonitor.cpp
voiceui/vcommand/src/headsetbuttonmonitor.cpp
voiceui/vcommand/src/uiarraysgenerator.cpp
voiceui/vcommand/src/vcapp.cpp
voiceui/vcommand/src/vcappui.cpp
voiceui/vcommand/src/vcdocument.cpp
voiceui/vcommand/src/vcdoublelargestylelistbox.cpp
voiceui/vcommand/src/vcfolderview.cpp
voiceui/vcommand/src/vcgenericcontainer.cpp
voiceui/vcommand/src/vcgenericview.cpp
voiceui/vcommand/src/vcmodel.cpp
voiceui/vcommand/src/vcommanduientry.cpp
voiceui/vcommand/src/vcommanduientryarray.cpp
voiceui/vcommand/src/vcplaybackdialog.cpp
voiceui/vcommand/src/vcsettingscontainer.cpp
voiceui/vcommand/src/vcsettingsengine.cpp
voiceui/vcommand/src/vcsettingslist.cpp
voiceui/vcommand/src/vcsettingsview.cpp
voiceui/vcommand/src/vctextquerydialog.cpp
voiceui/vcommand/src/vctonereader.cpp
voiceui/voiceuivoicerecognition/bmarm/voiceuirecognitionu.def
voiceui/voiceuivoicerecognition/bwins/voiceuirecognitionu.def
voiceui/voiceuivoicerecognition/bwinscw/voiceuirecognitionu.def
voiceui/voiceuivoicerecognition/bwinscw/voiceuivoicerecognitionau.def
voiceui/voiceuivoicerecognition/bwinscw/voiceuivoicerecognitionu.def
voiceui/voiceuivoicerecognition/data/btnamediallerstarttone.wav
voiceui/voiceuivoicerecognition/data/namediallerconfirmtone.wav
voiceui/voiceuivoicerecognition/data/namediallerstarttone.wav
voiceui/voiceuivoicerecognition/data/vuivoicerecognition.rss
voiceui/voiceuivoicerecognition/data/vuivoicerecognition_caption.rss
voiceui/voiceuivoicerecognition/data/vuivoicerecognition_reg.rss
voiceui/voiceuivoicerecognition/eabi/voiceuirecognitionu.def
voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionasu.def
voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionau.def
voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionsu.def
voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionu.def
voiceui/voiceuivoicerecognition/group/bld.inf
voiceui/voiceuivoicerecognition/group/exports.inc
voiceui/voiceuivoicerecognition/group/vui_icons_aif_scalable_dc.mk
voiceui/voiceuivoicerecognition/group/vuivoicerecognition.mmp
voiceui/voiceuivoicerecognition/group/vuivoicerecognitionwrapper.mmp
voiceui/voiceuivoicerecognition/inc/vuicabortstate.h
voiceui/voiceuivoicerecognition/inc/vuicadaptstate.h
voiceui/voiceuivoicerecognition/inc/vuicapp.h
voiceui/voiceuivoicerecognition/inc/vuicappui.h
voiceui/voiceuivoicerecognition/inc/vuiccalldetector.h
voiceui/voiceuivoicerecognition/inc/vuiccontactresultsstate.h
voiceui/voiceuivoicerecognition/inc/vuiccontextcheckstate.h
voiceui/voiceuivoicerecognition/inc/vuicdatastorage.h
voiceui/voiceuivoicerecognition/inc/vuicdocument.h
voiceui/voiceuivoicerecognition/inc/vuicerrorstate.h
voiceui/voiceuivoicerecognition/inc/vuicexecutestate.h
voiceui/voiceuivoicerecognition/inc/vuicexitstate.h
voiceui/voiceuivoicerecognition/inc/vuicfoldobserver.h
voiceui/voiceuivoicerecognition/inc/vuicglobalnote.h
voiceui/voiceuivoicerecognition/inc/vuicglobalprogressdialog.h
voiceui/voiceuivoicerecognition/inc/vuicinitstate.h
voiceui/voiceuivoicerecognition/inc/vuickeygrabber.h
voiceui/voiceuivoicerecognition/inc/vuiclistquerydialog.h
voiceui/voiceuivoicerecognition/inc/vuicmessagequerydialog.h
voiceui/voiceuivoicerecognition/inc/vuicnbestlistdialog.h
voiceui/voiceuivoicerecognition/inc/vuicnotificationobserver.h
voiceui/voiceuivoicerecognition/inc/vuicplaystate.h
voiceui/voiceuivoicerecognition/inc/vuicprecheckstate.h
voiceui/voiceuivoicerecognition/inc/vuicpropertyhandler.h
voiceui/voiceuivoicerecognition/inc/vuicrecordstate.h
voiceui/voiceuivoicerecognition/inc/vuicresultsstate.h
voiceui/voiceuivoicerecognition/inc/vuicstate.h
voiceui/voiceuivoicerecognition/inc/vuictoneplayer.h
voiceui/voiceuivoicerecognition/inc/vuicttsplayer.h
voiceui/voiceuivoicerecognition/inc/vuictutorial.h
voiceui/voiceuivoicerecognition/inc/vuictutorialmessagedialog.h
voiceui/voiceuivoicerecognition/inc/vuictutorialstate.h
voiceui/voiceuivoicerecognition/inc/vuicuimodel.h
voiceui/voiceuivoicerecognition/inc/vuicverificationdialog.h
voiceui/voiceuivoicerecognition/inc/vuicverificationinitstate.h
voiceui/voiceuivoicerecognition/inc/vuicverificationstate.h
voiceui/voiceuivoicerecognition/inc/vuicverificationtrainingstate.h
voiceui/voiceuivoicerecognition/inc/vuicvoicerecogdialogimpl.h
voiceui/voiceuivoicerecognition/inc/vuimcalldetectorobserver.h
voiceui/voiceuivoicerecognition/inc/vuimkeycallback.h
voiceui/voiceuivoicerecognition/inc/vuimvoicerecogdialogcallback.h
voiceui/voiceuivoicerecognition/inc/vuivoiceicondefs.h
voiceui/voiceuivoicerecognition/inc/vuivoicerecognition.hrh
voiceui/voiceuivoicerecognition/loc/vuivoicerecognition.loc
voiceui/voiceuivoicerecognition/src/vuicabortstate.cpp
voiceui/voiceuivoicerecognition/src/vuicadaptstate.cpp
voiceui/voiceuivoicerecognition/src/vuicapp.cpp
voiceui/voiceuivoicerecognition/src/vuicappui.cpp
voiceui/voiceuivoicerecognition/src/vuiccalldetector.cpp
voiceui/voiceuivoicerecognition/src/vuiccontactresultsstate.cpp
voiceui/voiceuivoicerecognition/src/vuiccontextcheckstate.cpp
voiceui/voiceuivoicerecognition/src/vuicdatastorage.cpp
voiceui/voiceuivoicerecognition/src/vuicdocument.cpp
voiceui/voiceuivoicerecognition/src/vuicerrorstate.cpp
voiceui/voiceuivoicerecognition/src/vuicexecutestate.cpp
voiceui/voiceuivoicerecognition/src/vuicexitstate.cpp
voiceui/voiceuivoicerecognition/src/vuicfoldobserver.cpp
voiceui/voiceuivoicerecognition/src/vuicglobalnote.cpp
voiceui/voiceuivoicerecognition/src/vuicglobalprogressdialog.cpp
voiceui/voiceuivoicerecognition/src/vuicinitstate.cpp
voiceui/voiceuivoicerecognition/src/vuickeygrabber.cpp
voiceui/voiceuivoicerecognition/src/vuiclistquerydialog.cpp
voiceui/voiceuivoicerecognition/src/vuicmessagequerydialog.cpp
voiceui/voiceuivoicerecognition/src/vuicnbestlistdialog.cpp
voiceui/voiceuivoicerecognition/src/vuicnotificationobserver.cpp
voiceui/voiceuivoicerecognition/src/vuicplaystate.cpp
voiceui/voiceuivoicerecognition/src/vuicprecheckstate.cpp
voiceui/voiceuivoicerecognition/src/vuicpropertyhandler.cpp
voiceui/voiceuivoicerecognition/src/vuicrecordstate.cpp
voiceui/voiceuivoicerecognition/src/vuicresultsstate.cpp
voiceui/voiceuivoicerecognition/src/vuicstate.cpp
voiceui/voiceuivoicerecognition/src/vuictoneplayer.cpp
voiceui/voiceuivoicerecognition/src/vuicttsplayer.cpp
voiceui/voiceuivoicerecognition/src/vuictutorial.cpp
voiceui/voiceuivoicerecognition/src/vuictutorialmessagedialog.cpp
voiceui/voiceuivoicerecognition/src/vuictutorialstate.cpp
voiceui/voiceuivoicerecognition/src/vuicuimodel.cpp
voiceui/voiceuivoicerecognition/src/vuicverificationdialog.cpp
voiceui/voiceuivoicerecognition/src/vuicverificationinitstate.cpp
voiceui/voiceuivoicerecognition/src/vuicverificationstate.cpp
voiceui/voiceuivoicerecognition/src/vuicverificationtrainingstate.cpp
voiceui/voiceuivoicerecognition/src/vuicvoicerecog.cpp
voiceui/voiceuivoicerecognition/src/vuicvoicerecogdialog.cpp
voiceui/voiceuivoicerecognition/src/vuicvoicerecogdialogimpl.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for all speechservices
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+#include "../speechsrv_plat/group/bld.inf"
+#include "../srsf/group/bld.inf"
+#include "../voiceui/group/bld.inf"
+
+
+PRJ_TESTMMPFILES
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/app/speechsrv" >
+]>
+
+<SystemDefinition name="speechsrv" schema="1.4.0">
+  <systemModel>
+    <layer name="app_layer">
+      <module name="speechsrv">
+        <unit unitID="MuiDo.speechsrv" mrp="" bldFile="&layer_real_source_path;/group" name="speechsrv" />
+      </module>
+    </layer>
+    <layer name="api_test_layer">
+      <module name="speechsrv.ui_voice_recognition_api">
+        <unit unitID="MuiDo.speechsrv.ui_voice_recognition_api" mrp="" bldFile="&layer_real_source_path;/speechsrv_plat/ui_voice_recognition_api/tsrc/group" name="speechsrv.ui_voice_recognition_api" />
+      </module>
+      <module name="speechsrv.speech_synthesis_clientserver_api">
+        <unit unitID="MuiDo.speechsrv.speech_synthesis_clientserver_api" mrp="" bldFile="&layer_real_source_path;/srsf/speechsynthesis/tsrc/speechsynthesistest/group" name="speechsrv.speech_synthesis_clientserver_api" />
+      </module>
+      <module name="speechsrv.nss_tts_utility_api">
+        <unit unitID="MuiDo.speechsrv.nss_tts_utility_api" mrp="" bldFile="&layer_real_source_path;/srsf/tsrc/public/basic/group" name="speechsrv.nss_tts_utility_api" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/adaptation_hw_device_api/adaptation_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="94ad4eb5a2cc8f421c09bbbb67e6cdeb" dataversion="2.0">
+  <name>Adaptation HW Device API</name>
+  <description>Interface for adaptation algorithm  for speaker independent speech recognition</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="asrsadaptationhwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/adaptation_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Adaptation HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsadaptationhwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsadaptationhwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/adaptation_hw_device_api/inc/asrsadaptationhwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,216 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     ARM hardware device for grammar compiling
+*
+*/
+
+
+
+
+
+
+#ifndef ASRADAPTATIONHWDEVICE_H
+#define ASRADAPTATIONHWDEVICE_H
+
+//  INCLUDES
+#include <asrshwdevice.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+
+// Implementation
+class CAsrAdaptationAlgorithm;
+ 
+// CLASS DECLARATION
+/**
+*  Callback class for adaptation.
+*
+*  !!@lib asrsadaptationhwdevice.lib
+*  @since 2.8
+*/
+class MASRAdaptationHwDeviceObserver
+    {
+public:
+	    /**!!!
+        *  
+        * @since 2.8
+        * @param none
+        * @return  
+        */
+     
+	virtual void MaahdAdaptationComplete(TInt aError) = 0; 
+};
+
+
+
+/**
+*  Adaptation class 
+*
+*  !!@lib asrsadaptationhwdevice.lib
+*  @since 2.8
+*/
+class  CASRSAdaptHwDevice : public CASRSHwDevice
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CASRSAdaptHwDevice* NewL(         
+         MASRAdaptationHwDeviceObserver& aObserver  );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CASRSAdaptHwDevice();
+
+    public: // New functions
+
+		/**
+        * Retrieve a custom interface
+        * @since 2.8
+        * @param none
+        * @return Pointer to a custom interface
+        */
+        IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
+
+		/**
+        * Initializes the device. Subsequent calls reset the device.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void InitializeL();
+
+		/**
+        * Clears the device.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void Clear();
+
+	 
+		/**
+        * Start the adaptation.  It will adapt the acoustic models given the feature vector set and phoneme sequences 
+		* of a correctly recognized utterance
+        * @since 2.8
+ 		* @param 		aAdaptationData: Buffer that stores data(feature vector) for the speaker adaptation.
+		* @param 		aModelBank: Model bank, which is the acoustic model to be adapted.
+		* @param 		aPronunciation: Pronunciation of the adaptation utterance.
+		* @param 		aLanguage : adaptation language
+        * @return		none
+        */
+        IMPORT_C void StartAdaptationL(const TDesC8& aAdaptationData, 
+										CSIModelBank& aModelBank, 
+										  CSIPronunciation& aPronunciation,TLanguage aLanguage);
+		
+	 
+
+	 	/**
+        * Cancel the Adaptation process. No callback is sent to the client.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void CancelAdaptation();
+
+		/**
+        * Cancels adaptation. No callback is sent to the client.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+/*        IMPORT_C void CancelCombination();*/
+ 
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+         CASRSAdaptHwDevice(MASRAdaptationHwDeviceObserver& anObserver);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+
+		
+       
+        // Prohibit copy constructor if not deriving from CBase.
+        // CASRGrCompilerHwDevice( const CASRGrCompilerHwDevice& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CASRGrCompilerHwDevice& operator=( const CASRGrCompilerHwDevice& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // pronunciation tree builder algorithm
+        // CPTBAlgorithm* iPtb;
+
+        // The observer
+        MASRAdaptationHwDeviceObserver& iObserver;
+
+        // Implementation-specific functions and data
+        CAsrAdaptationAlgorithm *iAlgorithm;
+ 
+        // Has Initialize() been called
+        TBool iIsInitialised;
+
+        // Reserved pointer for future extension.
+        TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+#endif      // ?INCLUDE_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/asrs_hw_device_api/asrs_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="cba71882da4ac7d325eaa472bfada7c8" dataversion="2.0">
+  <name>ASRS HW Device API</name>
+  <description>Base class definition for HW Device APIs</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/asrs_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                ASRS HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrshwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrshwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/asrs_hw_device_api/inc/asrshwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  TTP hardware device
+*
+*/
+
+
+
+#ifndef ASRHWDEVICE_H
+#define ASRHWDEVICE_H
+
+//  INCLUDES
+#include <e32base.h>
+ 
+// CLASS DECLARATION
+
+/**
+*  Base class for all hw devices
+*   
+*
+*  @lib asrsadaptationhwdevice.lib
+*  @since 2.8
+*/
+class CASRSHwDevice : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CASRSHwDevice* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CASRSHwDevice();
+
+    public: // New functions
+        
+        /**
+        * Use to initilize HW device
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C virtual void InitializeL();
+
+        /**
+        * Use to clear HW device
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C virtual void Clear();
+
+		/**
+        * Use to get custom interface
+        * @since 2.8
+        * @param aInterfaceId Identifier of the intercace implementation
+        * @return Pointer to the interface implementation or NULL.
+        */
+        IMPORT_C virtual TAny* CustomInterface( TUid aInterfaceId );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+
+
+        /**
+        * C++ default constructor.
+        */
+        CASRSHwDevice();
+
+    private:
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // ?INCLUDE_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/grcompiler_hw_device_api/grcompiler_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="1dd0740aff5fc603ee8f9b2a89de4b10" dataversion="2.0">
+  <name>GrCompiler HW Device API</name>
+  <description>Interface for grammar compilation algorithms</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="asrsgrcompilerhwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/grcompiler_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                GrCompiler HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsgrcompilerhwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsgrcompilerhwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/grcompiler_hw_device_api/inc/asrsgrcompilerhwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,233 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     ARM hardware device for grammar compiling
+*
+*/
+
+
+
+
+
+
+#ifndef ASRSGRCOMPILERHWDEVICE_H
+#define ASRSGRCOMPILERHWDEVICE_H
+
+//  INCLUDES
+#include <asrshwdevice.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+
+// FORWARD DECLARATIONS
+class CAsrsGrCompilerAlgorithm;
+class CSDCompiledGrammar; // For future extensions; the class doesn't exist yet.
+class CSDLexicon;
+class CSDModelBank;
+class CSDResultSet;
+
+// CLASS DECLARATION
+/**
+*  Callback class for Grammar Compiler.
+*
+*  @lib asrgrcompilerhwdevice.lib
+*  @since 2.8
+*/
+class MASRSGrCompilerHwDeviceObserver
+    {
+public: // New functions
+
+    /**
+    * Called after grammar compilation has finished or stopped.
+    * @since 2.8
+    * @param aError KErrNone or a system-wide error code
+    * @return none
+    */
+    virtual void MghdoGrammarCompilerComplete(TInt aError) = 0;
+
+    /**
+    * Called after grammar combination has finished or stopped.
+    * @since 2.8
+    * @param aResult The compiled grammar. Format dependes on the technology provider.
+    * @param aError KErrNone or a system-wide error code
+    * @return none
+    */
+    virtual void MghdoGrammarCombinerComplete(HBufC8* aResult, TInt aError) = 0;
+
+    /**
+    * Combination and compilation operations require lexicons. To provide those
+    * lexicons when needed, the client must implement these functions.
+    * CASRGrCompilerHwDevice takes ownership of the data.
+    * @since 2.8
+    * @param aID The lexicon identifier
+    * @return The lexicon. CASRGrCompiler takes ownership.
+    */
+    virtual CSILexicon* MghdoSILexiconL(TSILexiconID aID) = 0;
+
+    /**
+    * Callback function to load configuration data.
+    * Client provides an implementation.
+    *
+    * @param aPackageType Type identifier.
+    * @param aPackageID Package identifier.
+    * @param aStartPosition First byte.
+    * @param aEndPosition Last byte. If greater than the size of 
+    *                               the data, rest of the data is given.
+    * @return Pointer to the data buffer, HW Device takes ownership.
+    */	
+    virtual HBufC8* MghdoConfigurationData( TUint32 aPackageType,
+                                            TUint32 aPackageID,
+                                            TUint32 aStartPosition = 0,
+                                            TUint32 aEndPosition = KMaxTUint32 ) = 0;
+
+    };
+
+/**
+*  Grammar compilation algortithms
+*
+*  @lib asrgrcompilerhwdevice.lib
+*  @since 2.8
+*/
+class CASRSGrCompilerHwDevice : public CASRSHwDevice
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CASRSGrCompilerHwDevice* NewL(
+            MASRSGrCompilerHwDeviceObserver& aObserver
+            );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CASRSGrCompilerHwDevice();
+
+    public: // New functions
+
+		/**
+        * Compiles a speaker independent grammar. Asynchronous.
+        * Callback is MghdoGrammarCompilerComplete.
+        * @since 2.8
+        * @param aSICompiledGrammar The grammar to be compiled.
+        * @return none
+        */
+        IMPORT_C void CompileGrammarL( CSICompiledGrammar& aSICompiledGrammar );
+
+		/**
+        * Combines several speaker independent grammars. The result is a combined grammar
+        * in internal data format.
+        * If some rules are excluded (blacklisted), then they are absent from the combined
+        * grammar, but the compiled grammars are left untouched.
+        * @since 2.8
+        * @param aCompiledGrammars Array of previously compiled grammar
+        * @param aExcludedRules    Rules to be blacklisted.
+        * @return none
+        */
+        IMPORT_C void CombineGrammarL(const RPointerArray<CSICompiledGrammar>& aCompiledGrammars,
+                                      const RPointerArray<TSIRuleVariantInfo>& aExcludedRules);
+
+		/**
+        * Cancels grammar compilation. No callback is sent to the client.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void CancelCompilation();
+
+		/**
+        * Cancels grammar combination. No callback is sent to the client.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void CancelCombination();
+
+		/**
+        * Decodes an N-Best list from internal format into a recognition result.
+        * @since 2.8
+        * @param aNBestIDs     - N-Best result, as it came from the Recognition HW Device
+        * @param aSIResultSet  - Empty recognition result to be populated.
+        * @param aSICompiledGrammar - The grammars, which were combined to get aCombinedGrammar
+        * @param aCombinedData - The combined grammar, which was used in recognition
+        * @return none
+        */
+        IMPORT_C void ResolveResult(const RArray<TUint>& aNBestIDs,
+                                    CSIResultSet& aSIResultSet,
+                                    const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar,
+                                    const TDesC8& aCombinedData
+                                    ) const;
+
+    public: // Functions from base classes
+
+		/**
+        * From CASRSHwDevice
+        * Retrieve a custom interface
+        * @since 2.8
+        * @param aInterfaceId - UID of the interface
+        * @return Pointer to a custom interface
+        */
+        IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
+
+		/**
+        * From CASRSHwDevice
+        * Initializes the device. Subsequent calls reset the device.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void InitializeL();
+
+		/**
+        * From CASRSHwDevice
+        * Clears the device.
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void ClearL();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CASRSGrCompilerHwDevice(MASRSGrCompilerHwDeviceObserver& aObserver);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CASRSGrCompilerHwDevice( const CASRSGrCompilerHwDevice& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CASRSGrCompilerHwDevice& operator=( const CASRSGrCompilerHwDevice& );
+
+    private:    // Data
+
+        // The observer
+        MASRSGrCompilerHwDeviceObserver& iObserver;
+
+        // Implementation-specific functions and data
+        CAsrsGrCompilerAlgorithm *iAlgorithm;
+
+        // Has Initialize() been called
+        TBool iIsInitialised;
+
+        // Reserved pointer for future extension.
+        TAny* iReserved;
+    };
+
+#endif      // ASRSGRCOMPILERHWDEVICE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Includes all the Domain API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+#include "../vas_api/group/bld.inf"
+#include "../nss_devasr_api/group/bld.inf"
+#include "../tts_hw_device_api/group/bld.inf"
+#include "../voice_commands_resource_header_api/group/bld.inf"
+#include "../nss_mmf_tts_custom_commands_api/group/bld.inf"
+#include "../srsf_cenrep_settings_api/group/bld.inf"
+#include "../voice_ui_plugin_api/group/bld.inf"
+#include "../nss_tts_utility_api/group/bld.inf"
+#include "../nss_srs_custom_commands_api/group/bld.inf"
+#include "../srsf_secondarydisplay_api/group/bld.inf"
+#include "../asrs_hw_device_api/group/bld.inf"
+#include "../vas_vcommand_api/group/bld.inf"
+#include "../adaptation_hw_device_api/group/bld.inf"
+#include "../nss_devtts_api/group/bld.inf"
+#include "../nss_srs_utility_api/group/bld.inf"
+#include "../recognition_hw_device_api/group/bld.inf"
+#include "../vas_contact_handler_api/group/bld.inf"
+#include "../nlp_hw_device/group/bld.inf"
+#include "../nss_si_speech_recognition_data_api/group/bld.inf"
+#include "../nss_tts_common_api/group/bld.inf"
+#include "../grcompiler_hw_device_api/group/bld.inf"
+#include "../ttp_hw_device_api/group/bld.inf"
+#include "../vocman_hw_device_api/group/bld.inf"
+#include "../speech_synthesis_clientserver_api/group/bld.inf"
+#include "../voice_ui_accessory_button_handling_api/group/bld.inf"
+
+#include "../ui_voice_recognition_api/group/bld.inf"
+#include "../vcommand_settings_cenrep_api/group/bld.inf"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nlp_hw_device/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NLP HW Device
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsnlphwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsnlphwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nlp_hw_device/inc/asrsnlphwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Algorithms for text normalization
+*
+*/
+
+
+
+
+
+#ifndef NLPHWDEVICE_H
+#define NLPHWDEVICE_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <nssttscommon.h>
+#include <asrshwdevice.h>
+
+// FORWARD DECLARATIONS
+class CNlpAlgorithm;
+
+// CLASS DECLARATION
+/**
+*  Class to define callback functions
+*
+*  @lib asrsttshwdevice.lib
+*  @since 3.0
+*/
+class MNlpHwDeviceObserver
+    { 
+    public: // New functions
+
+        /**
+        * Called by the HW device when the asynchronous text processing 
+        * has been completed.
+        * @since 3.0
+        * @param aStatus Error code, KErrNone if success
+        * @return none
+        */
+        virtual void MnhdoNlpCompleted( TInt aStatus ) = 0;
+
+
+        /**
+        * Invoked by Nlp Hw Device when it needs a configuration data package.
+        * @since 3.0
+        * @param aPackageType Type identifier. 
+        * @param aPackageID Identifier of package
+        * @param aStartPosition Start index in bytes
+        * @param aEndPosition End index in bytes. If the position is bigger 
+        *         than the size of data package, the end part will be returned.
+        * @return Data package in a buffer
+        */
+        virtual HBufC8* MnhdoConfigurationData( TUint32 aPackageType, 
+                                                TUint32 aPackageID, 
+                                                TUint32 aStartPosition = 0, 
+                                                TUint32 aEndPosition = KMaxTUint32 
+                                              ) = 0;
+                                              
+
+        /**
+        * Returns style given the style id.
+        * @since 3.0
+        * @param aStyleID The style id.
+        * @return A reference to TTtsStyle.
+        */
+        virtual const TTtsStyle& MnhdoStyleL( TTtsStyleID aStyleID ) = 0; 
+
+    };
+
+
+/**
+*  Class to provide text normalization
+*
+*  @lib asrsnlphwdevice.lib
+*  @since 3.0
+*/
+class CNlpHwDevice : public CASRSHwDevice
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @param aObserver Observer which implements callback functions.
+        * @param aSamplingRate Sampling rate for output audio
+        * @param aBufferSize Buffer size for output audio
+        */
+        IMPORT_C static CNlpHwDevice* NewL( MNlpHwDeviceObserver& aObserver );
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CNlpHwDevice();
+
+    public: // New functions
+
+        /**
+        * Ask if a language is supported or not.
+        * @since 3.0
+        * @param aLanguage Synthesizing language.
+        * @return ETrue language is supported otherwise EFalse
+        */
+        IMPORT_C TBool IsLanguageSupported( TLanguage aLanguage );
+
+	
+		/**
+        * Normalize given text, text is not splits into segments.
+        * @since 3.0
+        * @param aText 
+        */
+        IMPORT_C void NormalizeTextL( CTtsParsedText& aText );
+
+
+		/**
+        * Normalize given text asynchronously, text is not splits into segments.
+        * @since 3.0
+        * @param aText 
+        */
+        IMPORT_C void NormalizeTextAsyncL( CTtsParsedText& aText );
+
+    
+        /**
+        * Normalize given text, text is split into segments
+        * @since 3.0
+        * @param aText 
+        */      
+       	IMPORT_C void NormalizeAndSegmentTextL( CTtsParsedText& aText );
+       	
+        /**
+        * Normalize given text asynchronously, text is split into segments
+        * @since 3.0
+        * @param aText 
+        */      
+       	IMPORT_C void NormalizeAndSegmentTextAsyncL( CTtsParsedText& aText );
+       
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CNlpHwDevice();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( MNlpHwDeviceObserver& aObserver );
+
+    private: // Data
+
+		// Actual algorithm where all processing happens
+		CNlpAlgorithm* iAlgorithm;
+
+		// Reserved pointer for future extension
+        TAny* iReserved;
+
+    };
+
+#endif // NLPHWDEVICE_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nlp_hw_device/nlp_hw_device.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="114da26eb5f92d52ec0d8c53e66bc868" dataversion="2.0">
+  <name>NLP HW Device</name>
+  <description>Interface for natural language processing algorithm</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssnlphwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devasr_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS DevASR API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssdevasrcommon.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssdevasrcommon.h)
+../inc/nssdevasr.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssdevasr.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devasr_api/inc/nssdevasr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,450 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definition of the DevASR API.
+*
+*/
+
+
+#ifndef NSSDEVASRAPI_H
+#define NSSDEVASRAPI_H
+
+//#define AUDIOBUFFER_TO_FILE
+
+//  INCLUDES
+#include <e32base.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+#include <nssdevasrcommon.h>
+
+// FORWARD DECLARATIONS
+class CSRSAlgorithmManager;
+class CVMAlgorithmManager;
+class TMMFPrioritySettings;
+
+/**
+*  Interface for the DevASR callbacks that are implemented by DevASR observers.
+*
+*  @lib NssDevASR.lib
+*  @since 2.8
+*/
+class MDevASRObserver
+    {
+    public:
+        /**
+        * DevASR calls this method to get configuration data.
+        *
+        * @since 2.8
+        * @param "TUint32 aPackageType" Type identifier.
+        * @param "TUint32 aPackageID" Identifier of package.
+        * @param "TUint32 aStartPosition" Starting position within package in bytes.
+        * @param "TUint32 aEndPosition" Ending position within package in bytes.
+        * @return Pointer to created buffer containing the request data.
+        */
+        virtual HBufC8* ConfigurationData( TUint32 aPackageType, 
+                                           TUint32 aPackageID,
+                                           TUint32 aStartPosition = 0,
+                                           TUint32 aEndPosition = KMaxTUint32 ) = 0;
+        
+        /**
+        * DevASR notifies object implementing this interface whenever a spontaneous or non-spontaneous
+        * event occurs in DevASR.
+        *
+        * @since 2.8
+        * @param "TDevASREvent aEvent" DevASR event code.
+        * @param "TDevASRError aError" DevASR error code.
+        */
+        virtual void DevASREvent( TDevASREvent aEvent, TDevASRError aError ) = 0;
+        
+        /**
+        * DevASR notifies object implementing this interface when feature vectors are available.
+        *
+        * @since 2.8
+        * @param "TDesC16& aFV" Buffer containing the feature vector data.
+        * @param "TInt32 aSNR" Signal-to-noise ratio.
+        * @param "TInt32 aPosition" Indicates whether the feature vector is the first, middle, or end.
+        */
+        virtual void FeatureVectorDataRcvd( const TDesC8& aFV, TInt32 aSNR, TInt32 aPosition ) = 0;
+        
+        /**
+        * DevASR calls this method to send a message in response to a custom command.
+        *
+        * @since 2.8
+        * @param "TDesC8& aMsg" Buffer containing the message.
+        */
+        virtual void DevASRMessage( TDesC8& aMsg ) = 0;
+        
+        /**
+        * Called when DevASR needs a SI lexicon.
+        *
+        * @since 2.8
+        * @param "TSILexiconID aLexiconID" Lexicon ID of requested lexicon.
+        * @return Pointer to created lexicon.
+        */
+        virtual CSILexicon* SILexiconL( TSILexiconID aLexiconID ) = 0;
+
+        /**
+        * Invoked by DevASR when it needs utterance data. The response is sent
+        * using SendSpeechData().
+        *
+        * @since 2.8
+        */
+        virtual void RequestSpeechData() = 0;
+    };
+
+/**
+*  Interface Class for the DevASR API.
+*
+*  @lib NssDevASR.lib
+*  @since 2.8
+*/
+class CDevASR : public CBase
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructors.
+        *
+        * @param "MDevASRObserver& aObserver" Reference to callback observer.
+        */
+        IMPORT_C static CDevASR* NewL( MDevASRObserver& aObserver );
+        IMPORT_C static CDevASR* NewLC( MDevASRObserver& aObserver );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CDevASR();
+        
+    public: // New functions
+        
+        /**
+        * Activates a grammar.
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" A grammar identifier.
+        */
+        IMPORT_C void ActivateGrammarL( TSIGrammarID aGrammarID );
+        
+        /**
+        * Adapts vocabulary and models after successful recognition.
+        *
+        * @since 2.8
+        * @param "CSIResultSet& aResultSet" Reco result set.
+        * @param "TInt aResultIndex" Index of correct result.
+        */
+        IMPORT_C void AdaptL( const CSIResultSet& aResultSet, TInt aResultIndex );
+        
+        /**
+        * Cancels the current or started tasks.
+        * @since 2.8
+        */
+        IMPORT_C void Cancel();
+        
+        /**
+        * Compiles an SI grammar.
+        *
+        * @since 2.8
+        * @param "CSICompiledGrammar& aGrammar" Reference to a grammar to be compiled.
+        */
+        IMPORT_C void CompileGrammarL( CSICompiledGrammar& aGrammar );
+
+        /**
+        * Computes number of rule variants for grammar.
+        *
+        * @since 2.8
+        * @param "CSIGrammar& aGrammar" A grammar where to add new rules.
+        * @param "TUint32 aTargetNRuleVariants" Preferable target number of all 
+        *         rule variants after adding new rule variants.
+        * @param "TUint32 aMaxNRuleVariants" Maximum number of all rule variants.
+        * @param "RArray<TUint>& aNewRuleScores" Scores for each new rule. The 
+        *         size of array tells also how many new rules will be added. 
+        *         Based on the scores some rules can get more rule variants than
+        *         others. If there is no scores available, the array should 
+        *         initialize with constant values.
+        * @param "RArray<TUint>& aNewRuleVariants" Array where to add number 
+        *         of new rule variants for new rules. The order is equivalent 
+        *         to aNewRuleScores.
+        * @param "TUint32& aNPrune" Number of rule variants which should be 
+        *         pruned before adding new rule variants.
+        */
+        IMPORT_C void ComputeNewGrammarSizeL( const CSIGrammar& aGrammar, 
+											  const TUint32 aTargetNRuleVariants,
+                                              const TUint32 aMaxNRuleVariants,
+                                              const RArray<TUint>& aNewRuleScores,
+                                              RArray<TUint>& aNewRuleVariants,
+                                              TUint32& aNPrune );
+
+        /**
+        * Use to request a custom interface implementation from the component.
+        * through the DevASR API.
+        *
+        * @since 2.8
+        * @param "TUid aInterfaceId" Interface UID, defined with the custom 
+        *         interface.
+        * @return A pointer to the interface implementation, or NULL if the 
+        *         requested interface is not implemented. The return value must
+        *         be cast to the correct type by the user.
+        */
+        IMPORT_C TAny* CustomInterface( TUid aInterfaceId );
+        
+        /**
+        * Deactivates a grammar.
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" A grammar identifier.
+        */
+        IMPORT_C void DeactivateGrammarL( TSIGrammarID aGrammarID );
+        
+        /**
+        * Requests to end recording and a result will be resolved.
+        *
+        * @since 2.8
+        */
+        IMPORT_C void EndRecord();
+
+        /**
+        * This method is used to indicate the end of a recognition session. All loaded grammars,
+        * lexicon, and models become invalid after this call.
+        *
+        * @since 2.8
+        */
+        IMPORT_C void EndRecSession();
+        
+        /**
+        * Retreive the properties of the underlying speech recognition engine.
+        *
+        * @since 2.8
+        * @param "RArray<TInt>& aPropertyId" An array of identifiers being querried.
+        * @param "RArray<TInt>& aPropertyValue" An array of values corresponding
+        *         to the querried identifiers.
+        */
+        IMPORT_C void GetEnginePropertiesL( const RArray<TInt>& aPropertyId, 
+                                            RArray<TInt>& aPropertyValue );
+        
+        /**
+        * Retreive the raw audio data accumulated during recording.
+        *
+        * @since 2.8
+        * @param "TDes8* aBuffer" The buffer where utterance data will be 
+        *        written.
+        * @param "TTimeIntervalMicroSeconds32& aDuration" Duration of the 
+        *        utterance.
+        */
+        IMPORT_C void GetUtteranceData( TDes8* aBuffer, 
+                                        TTimeIntervalMicroSeconds32& aDuration );
+        
+        /**
+        * Initializes the front-end module in the speech recognition engine.
+        * The frontend module used during training/recognition functions is started
+        * as a result. This method is intended to be used in conjunction with InitTrainBE().
+        *
+        * @since 2.8
+        * @param "TRecognizerMode aMode" Mode of the recognizer.
+        */
+        IMPORT_C void InitFrontEnd( TRecognizerMode aMode );
+        
+        /**
+        * Initialize the recognition engine back-end. The module responsible for recognition
+        * function is started as a result. This method must be used before any recognition
+        * operations and intended to be used in conjunction with InitFrontEnd().
+        *
+        * @since 2.8
+        * @param "CSIResultSet& aResult" A reference to an object where the 
+        *        recognition result will be written.
+        */
+        IMPORT_C void InitRecognizerBE( CSIResultSet& aResult );
+        
+        /**
+        * Load the specified recognizer parameter(s). These parameters are used to alter the
+        * recognizer's default parameters. The parameters are specified as attribute-value pairs.
+        *
+        * @since 2.8
+        * @param "RArray<TInt>& aParameterId" An array of parameter identifiers.
+        * @param "RArray<TInt>& aParameterValue" An array of parameter values.
+        */
+        IMPORT_C void LoadEngineParametersL( const RArray<TInt>& aParameterId, 
+                                             const RArray<TInt>& aParameterValue );
+        
+        /**
+        * Load the specified grammar into the recognizer.
+        *
+        * @since 2.8
+        * @param "CSIGrammar& aGrammar" A reference to a SI grammar.
+        */
+        IMPORT_C void LoadGrammar( const CSIGrammar& aGrammar );
+        
+        /**
+        * Load the specified grammar into the recognizer.
+        *
+        * @since 2.8
+        * @param "CSICompiledGrammar& aGrammar" A reference to a compiled 
+        *         SI grammar
+        */
+        IMPORT_C void LoadGrammar( const CSICompiledGrammar& aGrammar );
+        
+        /**
+        * Unloads the specified grammar from the recognizer.
+        *
+        * @since 2.8
+        * @param "CSIGrammar& aGrammar" A reference to a SI grammar.
+        */
+        IMPORT_C void UnloadGrammar( const CSIGrammar& aGrammar );
+        
+        /**
+        * Unloads the specified grammar from the recognizer.
+        *
+        * @since 2.8
+        * @param "CSICompiledGrammar& aGrammar" A reference to a compiled 
+        *         SI grammar
+        */
+        IMPORT_C void UnloadGrammar( const CSICompiledGrammar& aGrammar );
+
+        /**
+        * Load the specified SI lexicon into the recognizer.
+        *
+        * @since 2.8
+        * @param "CSILexicon& aLexicon" A reference to a SI lexicon.
+        */
+        IMPORT_C void LoadLexicon( const CSILexicon& aLexicon );
+        
+        /**
+        * Load the specified model bank into the recognizer.
+        *
+        * @since 2.8
+        * @param "CSIModelBank& aModels" A reference to a SI model bank.
+        */
+        IMPORT_C void LoadModels( const CSIModelBank& aModels );
+        
+        /**
+        * Determines which rule variants can be removed.
+        *
+        * @since 2.8
+        * @param "CSIGrammar& aGrammar" A grammar to be pruned.
+        * @param "TUint32 aMinNumber" Minimum number of pruned items.
+        * @param "RArray<TSIRuleVariantInfo>" A array where to put information 
+        *        which variants can be pruned.
+        */
+        IMPORT_C TBool PruneGrammar( const CSIGrammar& aGrammar, 
+                                     const TUint32 aMinNumber, 
+                                     RArray<TSIRuleVariantInfo>& aPrunedRuleVariants );
+      
+        /**
+        * Request to begin recognition.
+        *
+        * @since 2.8
+        * @param "TTimeIntervalMicroSeconds32 aRecordDuration" Length of time
+        *        to record, expressed in microseconds. Zero means infinite
+        *        duration.
+        */
+        IMPORT_C void Record( TTimeIntervalMicroSeconds32 aRecordDuration );
+
+        /**
+        * Starts sampling before Record call.
+        * 
+        * @since 3.2
+        */
+        IMPORT_C void PreStartSamplingL();
+
+        /**
+        * Use to send the utterance data as a response to the RequestSpeechData().
+        *
+        * @since 2.8
+        * @param "TDesC8& aBuffer" Buffer containing utterance data.
+        * @param "TBool aEnd" Flag to tell if given buffer is the last one.
+        */
+        IMPORT_C void SendSpeechData( TPtrC8& aBuffer, TBool aEnd );
+        
+        /**
+        * Use to set the priority of the sound device.
+        *
+        * @since 2.8
+        * @param "TMMFPrioritySettings& aPrioritySettings" Priority settings 
+        *        structure.
+        */
+        IMPORT_C void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings );
+       
+        /**
+        * This method is used to start a recognition session with the recognition engine.
+        *
+        * @since 2.8
+        * @param "TRecognizerMode aMode" Mode of the recognizer.
+        * @return Result code of operation.
+        */
+        IMPORT_C TInt StartRecSession( TRecognizerMode aMode );
+        
+        /**
+        * Starts training from text
+        *
+        * @since 2.8
+        * @param "CSITtpWordList& aWordList" List of text entries for training.
+        * @param "RArray<TLanguage>& aDefaultLanguage" Default language for 
+        *        pronunciations.
+        * @param "RArray<TUint>& aMaxNPronunsForWord" Maximum number of 
+        *        pronunciation per word.
+        */
+        IMPORT_C void StartTrainingFromTextL( CSITtpWordList& aWordList, 
+                                              const RArray<TLanguage>& aDefaultLanguage, 
+                                              const RArray<TUint32>& aMaxNPronunsForWord );
+   
+        /**
+        * Request to unload the specified rule in the grammar from recognizer.
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" Identifer of the grammar to operate on.
+        * @param "TSIRuleID aRuleID" Identifier of the rule to remove.
+        */
+        IMPORT_C void UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+        
+        /**
+        * Checks if grammar is loaded or not
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" Grammar ID
+        * @return ETrue if grammar is currently loaded, EFalse otherwise.
+        */
+        IMPORT_C TBool IsGrammarLoaded( TSIGrammarID aGrammarID );
+        
+        /**
+        * Checks if grammar is active or not
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" Grammar ID
+        * @return ETrue if grammar is active, EFalse otherwise.
+        */
+        IMPORT_C TBool IsGrammarActive( TSIGrammarID aGrammarID );
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CDevASR();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL(MDevASRObserver& aObserver);
+        
+    private: // Data
+        
+        // Pointer to recognition algorithm manager
+        CSRSAlgorithmManager* iSRSAlgorithmManager;
+       
+        // Reserved for future use
+        TAny* iReserved1;
+        TAny* iReserved2;
+
+    };
+    
+#endif // NSSDEVASRAPI_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devasr_api/inc/nssdevasrcommon.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common definitions used by the DevASR module.
+*
+*/
+
+
+#ifndef NSSDEVASRCOMMON_H
+#define NSSDEVASRCOMMON_H
+
+// TYPEDEFS
+typedef TInt TDevASRError;
+
+// CONSTANTS
+// Pre-defined Engine Parameter Identifiers starts from index 0x01
+// User-define Engine Parameter Identifiers starts from index 0x10000 and end at index KMaxTInt.
+
+// Property identifiers
+// Flag to tell if DevASR should call FeatureVectorDataRcvd callback or not
+const TInt KDevASRSendFeatures = 0x1F000;
+// Flag to tell if result set should contain adaptation data or not
+const TInt KDevASRAdaptation = 0x1F001;
+
+// DATA TYPES
+
+/**
+* DevASR Event codes
+*/
+enum TDevASREvent
+	{
+    EDevASREouDetected = 1,
+    EDevASRInitFrontend,
+    EDevASRInitRecognitionBackend,
+    EDevASRInitTrainBackend,
+    EDevASRLoadGrammar,
+    EDevASRLoadLexicon,
+    EDevASRLoadModels,
+    EDevASRUnloadRule,
+    EDevASRPlay,
+    EDevASRPlayStarted,
+    EDevASRRecognize,
+    EDevASRRecord,
+    EDevASRRecordStarted,
+    EDevASRTrain,
+    EDevASRTrainFromText,
+    EDevASRActivateGrammar,
+    EDevASRDeactivateGrammar,
+    EDevASRAdapt,
+    EDevASRGrammarCompile,
+    EDevASRUnloadGrammar
+	};
+
+/**
+* Mode used to initialize the recognizer
+*/
+enum TRecognizerMode
+	{
+	ESiRecognition,
+	ESdRecognition,
+	ESdTraining,
+	ESiRecognitionTest,
+	ESdRecognitionTest,
+	ESdTrainingTest,
+	ESiRecognitionSpeechInput,
+    ESdRecognitionSpeechInput,
+    ESdTrainingSpeechInput,
+    ESiRecognitionTestSpeechInput,
+    ESdRecognitionTestSpeechInput,
+    ESdTrainingTestSpeechInput,
+	};
+
+#endif // NSSDEVASRCOMMON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devasr_api/nss_devasr_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="3d0c695f203f4adb628ab4fd5d970a62" dataversion="2.0">
+  <name>NSS DevASR API</name>
+  <description>Low-level speech recognition API.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssdevasr.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devtts_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS DevTTS API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssdevtts.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssdevtts.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devtts_api/inc/nssdevtts.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,487 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DevTTS interface for Text-to-Speech
+*
+*/
+
+
+#ifndef DEVTTS_H
+#define DEVTTS_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32def.h>
+// TTSCommon include
+#include <nssttscommon.h>
+
+// CONSTANTS
+const TInt KDevTTSBalanceRight = 100;
+const TInt KDevTTSBalanceRightMiddle = 50;
+const TInt KDevTTSBalanceMiddle = 0;
+const TInt KDevTTSBalanceLeftMiddle = -50;
+const TInt KDevTTSBalanceLeft = -100;
+
+// DATA TYPES
+enum TDevTTSEvent
+    {
+    EDevTTSEventComplete
+    };
+
+enum TDevTTSOutputMode
+    {
+    EDevTTSSoundDeviceMode = 0,
+    EDevTTSClientMode
+    };
+
+enum TDevTTSAudioPreference
+    {
+    EDevTTSPriorityPreferenceNone = 0,
+    EDevTTSPriorityPreferenceTime, 
+    EDevTTSPriorityPreferenceQuality,
+    EDevTTSPriorityPreferenceTimeAndQuality 
+    };
+
+// FORWARD DECLARATIONS
+class CTTSAlgorithmManager;
+
+// CLASS DECLARATIONS
+
+/**
+*  MDevTTSObserver
+*
+*  Interface for a set of DevTTS callback functions.
+*
+*  This mixin class is intended to be inherited by the DevTTS client. Functions
+*  of this class get called when DevTTS specific events occur.
+*
+*  @lib nssdevtts.lib
+*  @since 2.8
+*/
+class MDevTTSObserver
+    {
+    
+    public:  // New functions
+        
+        /**
+        * Invoked by DevTTS when it needs a configuration data package.
+        *
+        * @since 2.8
+        * @param "TUint32 aPackageType" Packege type identifier
+        * @param "TUint32 aPackageID" Package identifier
+        * @param "TUint32 aStartPosition" Start position in bytes from beginning of data
+        * @param "TUint32 aEndPosition" End index in bytes. If the position is bigger 
+        *         than the size of data package, the end part will be returned.
+        *
+        * @return Pointer to created data buffer. NULL if failure. User must 
+        *         take care of the buffer deletion after usage.
+        */
+        virtual HBufC8* MdtoConfigurationData( TUint32 aPackageType, 
+                                               TUint32 aPackageID, 
+                                               TUint32 aStartPosition, 
+                                               TUint32 aEndPosition ) = 0;
+        
+        /**
+        * Called by DevTTS when an event occured. EDevTTSEventComplete is the only
+        * event that can happen currently.
+        *
+        * @since 2.8
+        * @param "TDevTTSEvent aEvent"
+        *         Event code
+        * @param "TInt aStatus"
+        *         Error code. KErrNone if success, one of the system level
+        *         error codes otherwise.
+        */
+        virtual void MdtoEvent( TDevTTSEvent aEvent, TInt aStatus ) = 0;
+        
+        /**
+        * Called by DevTTS device when output mode is EDevTTSClientMode and a 
+        * new audio buffer has been filled by the synthesizer. 
+        *
+        * @since 2.8
+        * @param "TDesC8& aBuffer"
+        *         Synthesized audio buffer.
+        */
+        virtual void MdtoProcessBuffer( const TDesC8& aBuffer ) = 0;
+    };
+
+/**
+*  CDevTTS is the interface towards DevTTS module. Actual implementation is
+*  not included in this class.
+*
+*  @lib nssdevtts.lib
+*  @since 2.8
+*/
+class CDevTTS : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDevTTS* NewL( MDevTTSObserver& aObserver/*, CConsoleBase* console*/ );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C ~CDevTTS();
+        
+    public: // New functions
+        
+        /**
+        * Adds a new style to the collection. If equal style exists already,
+        * new style is not added.
+        * Will leave if an error occurs. Likely errors are: KErrNoMemory,
+        * not enough memory to add new style. KErrNotSupported, the style 
+        * is not supported. KErrArgument, the style contains an imposible 
+        * value.
+        *
+        * @since 2.8
+        * @param "TTtsStyle& aStyle"
+        *        Reference to the style which will be added to the style 
+        *        collection.
+        *
+        * @return Identifier of added style.
+        */
+        IMPORT_C TTtsStyleID AddStyleL( const TTtsStyle& aStyle );
+        
+        /**
+        * Returns the current balance setting.
+        *
+        * @since 2.8
+        * @return Balance value.
+        */
+        IMPORT_C TInt Balance();
+
+        /**
+        * Notifies that the buffer has been processed. The 
+        * method is used if output mode of synthesizing is 
+        * EDevTTSClientMode.
+        *
+        * @since 2.8
+        * @param "TDesC8& aBuffer"
+        *        The buffer which has been processed.
+        */
+        IMPORT_C void BufferProcessed( const TDesC8& aBuffer );
+        
+        /**
+        * Request a pointer to the custom interface. Currently not in use.
+        * 
+        * @since 2.8
+        * @param "TUid aInterfaceID"
+        *        Custom interface identifier.
+        *
+        * @return Pointer to custom interface. NULL if interface is not 
+        *         found or initiation failures.
+        */
+        IMPORT_C TAny* CustomInterface( TUid aInterfaceID );
+        
+        /**
+        * Deletes style.
+        * 
+        * @since 2.8
+        * @param "TTtsStyleID aStyleID" Identifier of style to be deleted.
+        */
+        IMPORT_C void DeleteStyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Gives current position of synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing.
+        * 
+        * @since 2.8
+        * @param "TTimeIntervalMicroSeconds& aTime"
+        *        Time of the synthesizing position
+        */
+        IMPORT_C void GetPositionL( TTimeIntervalMicroSeconds& aTime ) const;
+        
+        /**
+        * Gives current position of synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing.
+        * 
+        * @since 2.8
+        * @param "TTtsSegment& aSegment"
+        *        Current segment which is synthesized, out parameter
+        * @param "TInt& aWordIndex"
+        *        Index of the current word, starting from the begining of 
+        *        current segment
+        */
+        IMPORT_C void GetPositionL( TTtsSegment& aSegment, TInt& aWordIndex ) const;
+        
+        /**
+        * Tells if language is supported by the TTS engine or not.
+        * 
+        * @since 2.8
+        * @param "TLanguage aLanguage"
+        *        Language code
+        *
+        * @return ETrue if supported, EFalse otherwise
+        */
+        IMPORT_C TBool IsLanguageSupported( TLanguage aLanguage ) const;
+        
+        /**
+        * Returns maximum volume value.
+        * 
+        * @since 2.8
+        * @return Maximum volume.
+        */
+        IMPORT_C TInt MaxVolume();
+
+        /**
+        * Gives number of styles.
+        * 
+        * @since 2.8
+        * @return Number of styles.
+        */
+        IMPORT_C TUint16 NumberOfStyles() const;
+        
+        /**
+        * Pauses synthesis process.
+        * @since 2.8
+        */
+        IMPORT_C void Pause();
+        
+        /**
+        * Prepares for synthesis. The method will leave if an 
+        * error occurs. Likely errors are: KErrInUse, synthesizing is 
+        * currently ongoing. KErrNoMemory, not enough memory to start 
+        * synthesis. KErrNotSupport, requested function is not supported.
+        * 
+        * @since 2.8
+        * @param "MTtsSegmentStream& aStream"
+        *        Stream to be synthesized.
+        */
+        IMPORT_C void PrimeSynthesisL( MTtsSegmentStream& aStream );
+        
+        /**
+        * Prepares for synthesis. The method will leave if an 
+        * error occurs. Likely errors are: KErrInUse, synthesizing is 
+        * currently ongoing. KErrNoMemory, not enough memory to start 
+        * synthesis. KErrNotSupport, requested function is not supported.
+        * 
+        * @since 2.8
+        * @param "CTtsParsedText& aText"
+        *        Text containing multiple segments to be synthesized.
+        */
+        IMPORT_C void PrimeSynthesisL( CTtsParsedText& aText );
+        
+        /**
+        * Sets the priority for audio playback if in EDevTTSSoundDeviceMode.
+        * 
+        * @since 2.8
+        * @param "TInt aPriority"
+        *        Priority value.
+        * @param "TDevTTSAudioPreference aPref"'
+        *        Preference setting. Quality, time or both.
+        */
+        IMPORT_C void SetAudioPriority( TInt aPriority, TDevTTSAudioPreference aPref );
+        
+        /**
+        * Sets the audio output routing
+        * 
+        * @since 3.2
+        * @param "TInt aAudioOutput"
+        *        New output.
+        */
+        IMPORT_C void SetAudioOutputL( TInt aAudioOutput );
+        
+        /**
+        * Sets the playback device balance. Affects only when DevTTS is in 
+        * EDevTTSSoundDeviceMode. Illegal values are neglected.
+        * 
+        * @since 2.8
+        * @param "TInt aBalance" Balance to be set. 
+        */
+        IMPORT_C void SetBalance( TInt aBalance );
+       
+        /**
+        * Sets new position for synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing. KErrArgument, position cannot be set.
+        * 
+        * @since 2.8
+        * @param "TTimeIntervalMicroSeconds& aTime"
+        *        Time of the synthesizing postion.
+        */
+        IMPORT_C void SetPositionL( const TTimeIntervalMicroSeconds& aTime );
+        
+        /**
+        * Sets new position for synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing. KErrArgument, position cannot be set.
+        * 
+        * @since 2.8
+        * @param "TTtsSegment& aSegment"
+        *        The segment being synthesized.
+        * @param "TInt aWordIndex"
+        *        The index of word being synthesized.
+        */
+        IMPORT_C void SetPositionL( const TTtsSegment& aSegment, TInt aWordIndex );
+        
+        /**
+        * Sets the playback device volume. Affects only when DevTTS is in 
+        * EDevTTSSoundDeviceMode. Range is from 0..MaxVolume(). Illegal values 
+        * are neglected.
+        * 
+        * @since 2.8
+        * @param "TInt aVolume" Volume setting.
+        */
+        IMPORT_C void SetVolume( TInt aVolume );
+
+        /**
+        * Sets the volume ramp duration. Start and end volumes must be set with
+        * SetVolume() function.
+        * 
+        * @since 2.8
+        * @param "TTimeIntervalMicroSeconds& aRampDuration" 
+        *        Ramp duration in microseconds.
+        */
+        IMPORT_C void SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration );
+
+        /**
+        * Stops synthesizing and releases resources of synthesizing. 
+        * The method does nothing if already stopped.
+        * @since 2.8
+        */
+        IMPORT_C void Stop();
+        
+        /**
+        * Receives style information. The method will leave if an error 
+        * occurs. Likely errors are: KErrNotFound, style identifier not 
+        * found. 
+        * 
+        * @since 2.8
+        * @param "TTtsStyle& aStyle"
+        *        Reference to style object where to assign the requested style.
+        * @param "TTtsStyleID aStyleID"
+        *        Style identifier.
+        */
+        IMPORT_C TTtsStyle& StyleL( TTtsStyleID aStyleID ) const;
+        
+        /**
+        * Receives style information. The method will leave if an error 
+        * occurs. Likely errors are: KErrArgument, index is out of bounds.
+        * 
+        * @since 2.8
+        * @param "TTtsStyle& aStyle"
+        *        Reference to style object where to assign the requested style.
+        * @param "TUint16 aIndex"
+        *        Index to style: 0..NumberOfStyles().
+        */
+        IMPORT_C TTtsStyle& StyleL( TUint16 aIndex ) const;
+        
+        /**
+        * Starts synthesizing the text. The method is asynchronous, as soon
+        * as the request has been placed, function call will return. 
+        * MDevTTSObserver::MdtoEvent will be called when synthesizing finishes.
+        * The method will leave if an error occurs. Likely errors are: 
+        * KErrNoMemory, not enough memory. 
+        * KErrInUse, synthesizing is currently ongoing
+        * 
+        * @since 2.8
+        * @param "TDevTTSOutputMode aOutputMode"
+        *        Either use a sound device (EDevTTSSoundDeviceMode) or client 
+        *        using callback (EDevTTSClientMode)
+        */
+        IMPORT_C void SynthesizeL( TDevTTSOutputMode aOutputMode );
+        
+        /**
+        * Returns current playback volume.
+        * 
+        * @since 2.8
+        * @return Volume setting.
+        */       
+        IMPORT_C TInt Volume();
+
+        /** 
+        * Calls language identification for a given text.
+        *
+        * @since 3.0M
+        * @param "CTtsParsedText& aText" Text
+        * @param "TInt aNumberOfGuesses" Maximum number of guesses that will be provided
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which will contain the languages
+        * @param "RArray<TInt>& aScores" Scores
+        */
+        IMPORT_C void LanguageIdentificationL( CTtsParsedText& aText, 
+                                               TInt aNumberOfGuesses, 
+                                               RArray<TLanguage>& aLanguages,
+                                               RArray<TInt>& aScores );
+
+        /**
+        * Calls Natural Language Processing (NLP) to normalize text.
+        *
+        * @since 3.0M
+        * @param "CTtsParsedText& aText" Text which will be normalized
+        */
+        IMPORT_C void NormalizeTextL( CTtsParsedText& aText );
+
+        /**
+        * Calls Natural Language Processing (NLP) to normalize and segment text.
+        *
+        * @since 3.0M
+        * @param "CTtsParsedText& aText" Text which will be normalized
+        */
+        IMPORT_C void NormalizeAndSegmentTextL( CTtsParsedText& aText );
+
+    public: // Functions from base classes
+        
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CDevTTS();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( MDevTTSObserver& aObserver/*, CConsoleBase* console*/ );
+        
+        /**
+        * Prohibit copy constructor
+        */
+        CDevTTS( const CDevTTS& );
+        
+        /** 
+        * Prohibit assignment operator
+        */
+        CDevTTS& operator=( const CDevTTS& );
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        
+        // Pointer to the implementation class
+        CTTSAlgorithmManager* iImpl;
+        
+        // Reserved pointer for future extension
+        TAny* iReserved;
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+    };
+    
+#endif // DEVTTS_H   
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_devtts_api/nss_devtts_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="51b96d5e1648f0ba44aaa66c6e6ff07d" dataversion="2.0">
+  <name>NSS DevTTS API</name>
+  <description>Low level access to speech synthesis</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssdevtts.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_mmf_tts_custom_commands_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS MMF TTS Custom Commands API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssttscustomcommandimplementor.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttscustomcommandimplementor.h)
+../inc/nssttscustomcommands.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttscustomcommands.h)
+../inc/nssttscustomcommandparser.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttscustomcommandparser.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_mmf_tts_custom_commands_api/inc/nssttscustomcommandimplementor.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mixin class which will be implemented by the TTS plugin.
+*
+*/
+
+
+#ifndef NSSTTSCUSTOMCOMMANDIMPLEMENTOR_H
+#define NSSTTSCUSTOMCOMMANDIMPLEMENTOR_H
+
+// INCLUDES
+#include <nssttscommon.h>
+
+// CLASS DECLARATION
+
+/**
+* Mixin class which should be implemented by the controller plugin.
+*
+* @lib nssttscustomcommands.lib
+* @since 2.8
+*/
+class MTtsCustomCommandImplementor
+    {
+    
+    public:
+        /**
+        * Adds a new style.
+        *
+        * @since 2.8
+        * @param "TTtsStyle& aStyle" Style to add.
+        */
+        virtual TTtsStyleID MttscAddStyleL( const TTtsStyle& aStyle ) = 0;
+
+        /**
+        * Deletes a style based on style ID.
+        *
+        * @since 2.8
+        * @param "TTtsStyleID aID" Style ID to be deleted.
+        */
+        virtual TInt MttscDeleteStyle( TTtsStyleID aID ) = 0;
+
+        /**
+        * Gets the synthesis position.
+        *
+        * @since 2.8
+        * @retval "TInt& aWordIndex" Returned position of synthesis.
+        */
+        virtual void MttscGetPositionL( TInt& aWordIndex ) = 0;
+
+        /**
+        * Returns the number of registered styles.
+        *
+        * @since 2.8
+        * @return Number of styles.
+        */
+        virtual TUint16 MttscNumberOfStyles() = 0;
+
+        /**
+        * Opens parsed text as source.
+        *
+        * @since 2.8
+        * @param "CTtsParsedText& aText" Reference to parsed text.
+        */
+        virtual void MttscOpenParsedTextL( CTtsParsedText& aText ) = 0;
+
+        /**
+        * Sets the synthesis position based on word index.
+        *
+        * @since 2.8
+        * @param "TInt aWordIndex" Word index.
+        */
+        virtual void MttscSetPositionL( TInt aWordIndex ) = 0;
+
+        /**
+        * Returns the style based on ID.
+        *
+        * @since 2.8
+        * @param "TTtsStyleID aStyleID" Style ID.
+        * @return Reference to style object.
+        */
+        virtual TTtsStyle& MttscStyleL( TTtsStyleID aStyleID ) = 0;
+
+        /**
+        * Returns the style based on index.
+        *
+        * @since 2.8
+        * @param "TUint16 aIndex" Style index.
+        * @return Reference to style object.
+        */
+        virtual TTtsStyle& MttscStyleL( TUint16 aIndex ) = 0;
+        
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        * @since 3.2        
+        */        
+        virtual void MttscSetDefaultStyleL( const TTtsStyle& aStyle ) = 0;
+        
+        /**
+        * Returns the registered default style
+        *
+        * @return Style reference
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2             
+        */
+        virtual TTtsStyle& MttscDefaultStyleL() = 0;
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @param TInt aRate Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @since 3.2        
+        */        
+        virtual void MttscSetSpeakingRateL( TInt aRate ) = 0;
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        virtual TInt MttscSpeakingRateL() = 0;
+      
+        /**
+        * Returns the list of supported languages.
+        * 
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which contains the languages
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        virtual void MttscGetSupportedLanguagesL( RArray<TLanguage>& aLanguages ) = 0;
+        
+        /**
+        * Returns the list of supported voices for a certain language.
+        * 
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TTtsStyle>& aVoices" Output parameter which contains the voices
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2
+        */        
+        virtual void MttscGetSupportedVoicesL( TLanguage aLanguage, RArray<TTtsStyle>& aVoices ) = 0;
+
+    };
+
+#endif // NSSTTSCUSTOMCOMMANDIMPLEMENTOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_mmf_tts_custom_commands_api/inc/nssttscustomcommandparser.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface towards Tts custom command parser, public methods
+*                called by the MMF
+*
+*/
+
+
+#ifndef TTSCUSTOMCOMMANDPARSER_H
+#define TTSCUSTOMCOMMANDPARSER_H
+
+// INCLUDE FILES
+#include <mmfcontroller.h>
+#include <nssttscustomcommandimplementor.h>
+
+// CLASS DECLARATION
+
+/**
+* Server side parser for TTS custom commands. 
+*
+* @since 2.8
+* @lib nssttscustomcommands.lib
+*/
+class CTtsCustomCommandParser : public CMMFCustomCommandParserBase
+    {
+    
+    public:
+        
+        /** 
+        * Factory function for creating this class.
+        *
+        * @since 2.8
+        * @param "MTtsCustomCommandImplementor& aImplementor" Rreference to 
+        *        custom commands implementor.
+        * @return Pointer to CSpeechRecognitionCustomCommandParser object.
+        */
+        IMPORT_C static CTtsCustomCommandParser* NewL( MTtsCustomCommandImplementor& aImplementor );
+        
+        /**
+        * Destructor
+        */
+        IMPORT_C  ~CTtsCustomCommandParser();
+        
+        /**
+        * Handles the request from the client
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" Message containing the CC information.
+        */
+        void HandleRequest( TMMFMessage& aMessage );
+        
+    private:
+        
+        /**
+        * C++ constructor for CSpeechRecognitionCustomCommandParser class.
+        *
+        * @since 2.8
+        * @param "MTtsCustomCommandImplementor& aImplementor" Reference to 
+        *        custom commands implementor.
+        */
+        CTtsCustomCommandParser( MTtsCustomCommandImplementor& aImplementor );
+        
+        /**
+        * Private method to handle the request from the client.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" Message containing the information
+        *        of the request.
+        */
+        void DoHandleRequestL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to add a new style.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoAddStyleL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to delete a style.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoDeleteStyleL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get the synthesis position.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetPositionL( TMMFMessage& aMessage );
+      
+        /**
+        * Uses plugin to get the number of registered styles.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoNumberOfStylesL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to open a parsed text source.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoOpenParsedTextL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to set synthesis position.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoSetPositionL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get style based on its ID.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoStyleIDL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get style based on its index.
+        *
+        * @since 2.8
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoStyleIndexL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to set default style to be used in synthesis
+        * if not set otherwise. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoSetDefaultStyleL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get the default style in use. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetDefaultStyleL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to set speaking rate. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoSetSpeakingRateL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get spekaing rate in use. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetSpeakingRateL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get supported synthesis languages. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetSupportedLanguagesL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get number of supported synthesis languages. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetSupportedLanguagesCountL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get supported voices of particular language. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetSupportedVoicesL( TMMFMessage& aMessage );
+
+        /**
+        * Uses plugin to get number of supported voices of particular language. 
+        *
+        * @since 3.2
+        * @param "TMMFMessage& aMessage" MMF message.
+        */
+        void DoGetSupportedVoicesCountL( TMMFMessage& aMessage );
+
+    private:
+    
+        // Reference to the Custom Command Implementor class
+        MTtsCustomCommandImplementor& iImplementor; 
+  
+        TAny* iReservedPtr1; // Reserved for future expansion
+        TAny* iReservedPtr2; // Reserved for future expansion
+};
+
+#endif // TTSCUSTOMCOMMANDPARSER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_mmf_tts_custom_commands_api/inc/nssttscustomcommands.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side interface to TTS custom commands.
+*
+*/
+
+
+#ifndef NSSTTSCUSTOMCOMMANDS_H
+#define NSSTTSCUSTOMCOMMANDS_H
+
+// INCLUDE FILES
+#include <mmfcontroller.h>
+#include <nssttscommon.h>
+
+// CLASS DECLARATION
+
+/**
+* TTS custom command client side interface.
+*
+* @lib nssttscustomcommands.lib.lib
+* @since 2.8
+*/
+// CLASS DECLARATION
+class RTtsCustomCommands : public RMMFCustomCommandsBase
+	{
+	public: // Constructors and destructor
+
+		/**
+		* Public C++ constructor for RSpeechRecognitionCustomCommands class.
+        *
+        * @since 2.8
+        * @param "RMMFController& aController" Reference to RMMFController object.
+		*/
+		IMPORT_C RTtsCustomCommands( RMMFController& aController );
+
+	public: // New functions
+
+        /**
+        * Adds a style to the style collection.
+        *
+        * @since 2.8
+        * @param "TTtsStyle& aStyle" Style to be added.
+        * @retval "TTtsStyleID& aID" Returns: style ID.
+        * @return Error code.
+        */
+        IMPORT_C TInt AddStyle( const TTtsStyle& aStyle, TTtsStyleID& aID );
+
+        /**
+        * Deletes a style based on identifier.
+        *
+        * @since 2.8
+        * @param "TTtsStyleID aID" Style ID which should be deleted.
+        * @return Error code.
+        */
+        IMPORT_C TInt DeleteStyle( TTtsStyleID aID );
+
+        /**
+        * Gets the current synthesis position in words.
+        *
+        * @since 2.8
+        * @retval "TInt& aWordIndex" Return; position in words.
+        * @return Error code.
+        */
+        IMPORT_C TInt GetPosition( TInt& aWordIndex );
+
+        /**
+        * Gets the overall number of registered styles.
+        *
+        * @since 2.8
+        * @retval "TUint16& aNumber" Return; number of styles.
+        * @return Error code.
+        */
+        IMPORT_C TInt NumberOfStyles( TUint16& aNumber );
+
+        /**
+        * Opens parsed text object as synthesis source.
+        *
+        * @since 2.8
+        * @param "CTtsParsedText& aText" Parsed text to open.
+        * @return Error code.
+        */
+        IMPORT_C TInt OpenParsedText( CTtsParsedText& aText );
+
+        /**
+        * Sets synthesis position in words.
+        *
+        * @since 2.8
+        * @param "TInt aWordIndex" Position to set.
+        * @return Error code.
+        */
+        IMPORT_C TInt SetPosition( TInt aWordIndex );
+
+        /**
+        * Gets a registered style based on style identifier.
+        *
+        * @since 2.8
+        * @param "TTtsStyleID aStyleID" Style ID.
+        * @retval "TTtsStyle& aStyle" Returns: reference to style object.
+        * @return Error code.
+        */
+        IMPORT_C TInt Style( TTtsStyleID aStyleID, TTtsStyle& aStyle );
+
+        /**
+        * Gets a registered style based on index.
+        *
+        * @since 2.8
+        * @param "TUint16 aIndex" Index.
+        * @retval "TTtsStyle& aStyle" Returns: reference to style object.
+        * @return Error code.
+        */
+        IMPORT_C TInt Style( TUint16 aIndex, TTtsStyle& aStyle );
+
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @since 3.2 
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        * @return Error code.
+        */
+        IMPORT_C TInt SetDefaultStyle( const TTtsStyle& aStyle );
+        
+        /**
+        * Returns the registered default style
+        *
+        * @since 3.2 
+        * @retval "TTtsStyle& aStyle" Returns: reference to style object.
+        * @return Error code.
+        */
+        IMPORT_C TInt GetDefaultStyle( TTtsStyle& aStyle );
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @since 3.2 
+        * @param TInt aRate Speaking rate value
+        * @return Error code.
+        */        
+        IMPORT_C TInt SetSpeakingRate( TInt aRate );
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @since 3.2 
+        * @return Speaking rate value
+        * @retval "TInt aRate" Return; Speaking rate value.
+        * @return Error code.
+        */
+        IMPORT_C TInt GetSpeakingRate( TInt& aRate );
+        
+        /**
+        * Gets the list of supported languages.
+        * 
+        * @since 3.2
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which 
+        *         contains the languages
+        * @return Error code.
+        */
+        IMPORT_C TInt GetSupportedLanguages( RArray<TLanguage>& aLanguages );
+        
+        /**
+        * Gets the list of supported voices for a certain language.
+        * 
+        * @since 3.2
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TTtsStyle>& aVoices" Output parameter which contains the voices
+        * @return Error code.
+        */        
+        IMPORT_C TInt GetSupportedVoices( TLanguage aLanguage, 
+                                          RArray<TTtsStyle>& aVoices );
+
+private:
+	
+		TAny* iReservedPtr_1;	// reserved for future expansion
+		TAny* iReservedPtr_2;	// reserved for future expansion
+};
+
+#endif // NSSTTSCUSTOMCOMMANDS_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_mmf_tts_custom_commands_api/nss_mmf_tts_custom_commands_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="a2fa23d670d4e2050bd512940e6742cb" dataversion="2.0">
+  <name>NSS MMF TTS Custom Commands API</name>
+  <description>MMF extension for speechs synthesis</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssttscustomcommands.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_si_speech_recognition_data_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS SI Speech Recognition Data API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nsssispeechrecognitiondatadevasr.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitiondatadevasr.h)
+../inc/nsssispeechrecognitiondataclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitiondataclient.h)
+../inc/nsssispeechrecognitiondatacommon.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitiondatacommon.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_si_speech_recognition_data_api/inc/nsssispeechrecognitiondataclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,213 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     This file contains definition of the SISpeechRecognitionDataClient structure and API.
+*
+*/
+
+
+
+
+
+#ifndef __SRSSIDATA_CLIENT_H__
+#define __SRSSIDATA_CLIENT_H__
+
+//  INCLUDES
+#include <nsssispeechrecognitiondatacommon.h>
+ 
+
+// FORWARD DECLARATION
+class  CSIResultSet;
+
+
+// CLASS DECLARATION
+
+/**
+*  Class to encapsulate a client recognition result.
+*  The result is formulated for client consumption.
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.5
+*/
+
+class CSIClientResult : public CBase
+{
+public:	 // Constructors and destructor
+        /**
+        * Destructor.
+        */
+	IMPORT_C ~CSIClientResult();
+        /**
+        * Two-phased constructor.
+        */
+	IMPORT_C static CSIClientResult* NewL();
+	IMPORT_C static CSIClientResult* NewLC();
+	IMPORT_C static CSIClientResult* NewL(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+	IMPORT_C static CSIClientResult* NewLC(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+
+		/**
+        * Use to set the grammar Id on the result.
+        * @since 2.5
+        * @param aGrammarID - grammar identifier.
+        * @return None.
+		*/
+	IMPORT_C void SetGrammarID(TSIGrammarID aGrammarID);
+
+		/**
+        * Use to retrieve the grammar Id of the result.
+        * @since 2.5
+		* @param None.
+        * @return Grammar identifier.
+        */
+	IMPORT_C TSIGrammarID GrammarID() const;
+
+		/**
+        * Use to set the rule Id of the result.
+        * @since 2.5
+        * @param aRuleID - rule identifier.
+		* @return None.
+        */
+	IMPORT_C void SetRuleID(TSIRuleID aRuleID);
+
+		/**
+        * Use to retrieve the rule Id of the result.
+        * @since 2.5
+		* @param None.
+        * @return Rule identifier.
+        */ 
+	IMPORT_C TSIRuleID RuleID() const;
+
+private:
+	void ConstructL();
+	CSIClientResult();
+	CSIClientResult(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+
+private:
+	TSIGrammarID iGrammarID;
+	TSIRuleID iRuleID;
+};
+
+
+/**
+*  Class to encapsulate a client recogntion result set
+*  This is a lightweight result set formulated for client consumption
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.5
+*/
+
+class CSIClientResultSet : public CBase
+{
+public:	// Constructors and destructor
+        /**
+        * Destructor.
+        */
+	IMPORT_C ~CSIClientResultSet();
+
+	    /**
+        * Two-phased constructor.
+        */
+	IMPORT_C static CSIClientResultSet* NewL();
+	IMPORT_C static CSIClientResultSet* NewLC();
+
+		/**
+			* Use to add a result to the result set.
+			* @since 2.5
+			* @param aResult - reference to the result object to be added.
+			* @return KErrNone, if the insertion is successful, otherwise one of the system wide error codes.
+		*/
+		IMPORT_C void AddL( const  CSIClientResult* aResult); 
+		
+		
+		/**
+			* Use to delete a result to the result set.
+			* @since 2.5
+			* @param aIndex Index of  .
+			* @return 
+			*/
+		IMPORT_C void DeleteL(TInt aIndex) ;	
+		/**
+        * Sets the maximum number of best matches (N-best) expected in the recognition result after recognition.
+        * @since 2.5
+        * @param aMaxResults - the maximum number of matches expected in the recognition result.
+		* @return None.
+        */
+	IMPORT_C void SetMaxResultsL(TInt aMaxResults);
+
+		/**
+        * Use to retrieve the current value of the max number of expected after recognition.
+        * @since 2.5
+        * @param None.
+		* @return The maximum number of best matches (N-best) expected in the recognition result.
+        */ 
+	IMPORT_C TInt MaxResults() const;
+
+		/**
+        * Use to retrieve a result at a given index within the result set.
+        * @since 2.5
+        * @param None.
+		* @return Pointer to CSIClientResult object.
+        */
+	IMPORT_C const CSIClientResult& AtL(TInt anIndex) const;
+
+		/**
+        * Use to set the number of results actually returned after recogntion.
+        * @since 2.5
+        * @param aResultCount - number of results returned by the recognizer.
+		* @return None.
+        */
+	IMPORT_C void SetResultCount(TInt aResultCount);
+
+		/**
+        * Use to retrieve the number of results actually returned after recogntion.
+        * @since 2.5
+        * @param None.
+		* @return Number of results actually returned after recogntion.
+        */
+	IMPORT_C TInt ResultCount() const;
+ 
+
+	IMPORT_C  CSIResultSet& SIResultSet() const;
+
+	
+	IMPORT_C void SetSIResultSet(CSIResultSet* aSIResultSet);
+
+		/**
+        * Internalize to a data stream
+        * @since 2.8
+		* @param aStream Data stream
+        * @return  None
+        */ 
+	IMPORT_C virtual void InternalizeL( RReadStream& aStream );
+
+		/**
+        * Externalize from a data stream
+        * @since 2.8
+		* @param None
+        * @return  aStream Data stream
+        */ 
+	IMPORT_C virtual void ExternalizeL( RWriteStream& aStream ) const;
+
+private:
+	void ConstructL();
+	CSIClientResultSet();
+
+private:
+	TInt iMaxResults;
+	TInt iResultCount;
+	RPointerArray<CSIClientResult> iResultArray;
+	CSIResultSet* iSIResultSet;
+};
+
+#endif
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_si_speech_recognition_data_api/inc/nsssispeechrecognitiondatacommon.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,228 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     This file contains common data shared between SISpeechRecognitionDataClient
+*     %version: 10 %
+*               and SISpeechRecognitionDataDevASR.
+*
+*  Copyright © 2002-2006 Nokia Corporation.
+*/
+
+
+
+
+
+#ifndef NSSSISPEECHRECOGNITIONDATACOMMON_H
+#define NSSSISPEECHRECOGNITIONDATACOMMON_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// For externalize/internalize 
+#include  <s32strm.h>
+// For 
+#include <bamdesca.h> 
+
+// TYPEDEFS
+typedef TUint16 TSIModelBankID;
+typedef TUint16 TSIModelID;
+
+typedef TUint16 TSILexiconID;
+typedef TUint32 TSIPronunciationID;
+
+typedef TUint16 TSIGrammarID;
+typedef TUint32 TSIRuleID;
+typedef TUint8  TSIRuleVariantID;
+
+typedef RArray<TSIPronunciationID> TSIPronunciationIDSequence;
+
+// Language array which is used as an element of another RArray
+typedef RArray<TLanguage> RLanguageArray;
+
+// CONSTANTS
+const TSIPronunciationID KUndefinedPronounciationID = 0x0;
+
+const TSIModelBankID     KInvalidModelBankID = 0x7fff;
+const TSIModelID         KInvalidModelID     = 0x7fff;
+const TSILexiconID       KInvalidLexiconID     = 0x7fff;
+const TSIPronunciationID KInvalidPronunciationID=0x7fffffff;
+const TSIGrammarID       KInvalidGrammarID     = 0x7fff;
+const TSIRuleID          KInvalidRuleID        = 0x7fffffff;
+const TSIRuleVariantID   KInvalidRuleVariantID = 0x7f;
+
+// ASCII phonemes can't be longer than this.
+const TInt   KMaxPhonemeLength = 7;
+
+const TUint8 KPhonemeSeparator = '-';
+
+
+
+// CONSTANTS
+const TInt KUidAsrEventTrainReadyVal 				= 0x101FBF9E;
+const TInt KUidAsrEventTrainVal 					= 0x101FBF9F;
+const TInt KUidAsrEventAddPronunciationVal 			= 0x101FBFA0;
+const TInt KUidAsrEventAddRuleVal 					= 0x101FBFA1;
+const TInt KUidAsrEventLoadModelsVal 				= 0x101FBFA2;
+const TInt KUidAsrEventLoadLexiconVal 				= 0x101FBFA3;
+const TInt KUidAsrEventLoadGrammarVal 				= 0x101FBFA4;
+const TInt KUidAsrEventRecognitionReadyVal 			= 0x101FBFA5;
+const TInt KUidAsrEventRecognitionVal 				= 0x101FBFA6;
+const TInt KUidAsrEventUnloadRuleVal 				= 0x101FBFA7;
+const TInt KUidAsrEventRecordStartedVal 			= 0x101FBFA8;
+const TInt KUidAsrEventRecordVal 					= 0x101FBFA9;
+const TInt KUidAsrEventEouDetectedVal 				= 0x101FBFAA;
+const TInt KUidAsrEventPlayStartedVal	 			= 0x101FBFAB;
+const TInt KUidAsrEventPlayVal			 			= 0x101FBFAC;
+const TInt KUidAsrEventCreateGrammarVal 			= 0x101FBFAD;
+const TInt KUidAsrEventCreateLexiconVal 			= 0x101FBFAE;
+const TInt KUidAsrEventCreateModelBankVal 			= 0x101FBFAF;
+const TInt KUidAsrEventRemoveGrammarVal 			= 0x101FBFB0;
+const TInt KUidAsrEventRemoveLexiconVal 			= 0x101FBFB1;
+const TInt KUidAsrEventRemoveModelBankVal 			= 0x101FBFB2;
+const TInt KUidAsrEventRemoveRuleVal 				= 0x101FBFB3;
+const TInt KUidAsrEventRemovePronunciationVal 		= 0x101FBFB4;
+const TInt KUidAsrEventRemoveModelVal 				= 0x101FBFB5;
+const TInt KUidAsrEventGetAvailableStorageVal 		= 0x101FBFB6;
+const TInt KUidAsrEventGetRuleValidityVal 			= 0x101FBFB7;
+const TInt KUidAsrEventGetUtteranceDurationVal 		= 0x101FBFB8;
+const TInt KUidAsrEventGetModelCountVal 			= 0x101FBFB9;
+const TInt KUidAsrEventGetAllRuleIDsVal 			= 0x101FBFBA;
+const TInt KUidAsrEventGetAllPronunciationIDsVal 	= 0x101FBFBB;
+const TInt KUidAsrEventGetAllModelIDsVal 			= 0x101FBFBC;
+const TInt KUidAsrEventGetAllClientGrammarIDsVal 	= 0x101FBFBD;
+const TInt KUidAsrEventGetAllClientLexiconIDsVal 	= 0x101FBFBE;
+const TInt KUidAsrEventGetAllClientModelBankIDsVal 	= 0x101FBFBF;
+const TInt KUidAsrEventGetAllGrammarIDsVal 			= 0x101FBFC0;
+const TInt KUidAsrEventGetAllLexiconIDsVal 			= 0x101FBFC1;
+const TInt KUidAsrEventGetAllModelBankIDsVal 		= 0x101FBFC2;
+
+// SI event values 
+// !!!! There are not unique! Just successors of SD numbers.
+const TInt KUidAsrEventAdaptVal         = 0x101FBFC3;
+const TInt KUidAsrEventAddVoiceTagVal   = 0x101FBFC4;
+const TInt KUidAsrEventAddVoiceTagsVal  = 0x101FBFC5;
+const TInt KUidAsrEventSIRecognitionVal = 0x101FBFC6;
+const TInt KUidAsrEventAddRuleVariantVal= 0x101FBFC7;
+const TInt KUidAsrEventCreateRuleVal    = 0x101FBFC8;
+const TInt KUidAsrEventEndRecordVal     = 0x101FBFC9;
+const TInt KUidAsrEventUnloadGrammarVal = 0x101FBFCA;
+
+
+const TInt KUidAsrEventUpdateGrammarAndLexiconVal = 0x101FBFCB;
+const TInt KUidAsrEventActivateGrammarVal         = 0x101FBFCC;
+const TInt KUidAsrEventDeactivateGrammarVal       = 0x101FBFCD;
+const TInt KUidAsrEventRemoveRulesVal             = 0x101FBFCE;
+
+const TInt KUidAsrEventGetPronunciationCountVal 	= 0x101FBFCF;
+const TInt KUidAsrEventGetRuleCountVal 				= 0x101FBFD0;
+
+const TInt KUidAsrEventPreStartSamplingVal          = 0x101FBFD1;
+
+const TUid KUidAsrEventTrainReady 					= {KUidAsrEventTrainReadyVal};
+const TUid KUidAsrEventTrain 						= {KUidAsrEventTrainVal};
+const TUid KUidAsrEventAddPronunciation 			= {KUidAsrEventAddPronunciationVal};
+const TUid KUidAsrEventAddRule 						= {KUidAsrEventAddRuleVal};
+const TUid KUidAsrEventLoadModels	 				= {KUidAsrEventLoadModelsVal};
+const TUid KUidAsrEventLoadLexicon	 				= {KUidAsrEventLoadLexiconVal};
+const TUid KUidAsrEventLoadGrammar	 				= {KUidAsrEventLoadGrammarVal};
+const TUid KUidAsrEventRecognitionReady	 			= {KUidAsrEventRecognitionReadyVal};
+const TUid KUidAsrEventRecognition	 				= {KUidAsrEventRecognitionVal};
+const TUid KUidAsrEventUnloadRule	 				= {KUidAsrEventUnloadRuleVal};
+const TUid KUidAsrEventRecordStarted	 			= {KUidAsrEventRecordStartedVal};
+const TUid KUidAsrEventRecord	 					= {KUidAsrEventRecordVal};
+const TUid KUidAsrEventEouDetected	 				= {KUidAsrEventEouDetectedVal};
+const TUid KUidAsrEventPlayStarted	 				= {KUidAsrEventPlayStartedVal};
+const TUid KUidAsrEventPlay			 				= {KUidAsrEventPlayVal};
+const TUid KUidAsrEventCreateGrammar	 			= {KUidAsrEventCreateGrammarVal};
+const TUid KUidAsrEventCreateLexicon	 			= {KUidAsrEventCreateLexiconVal};
+const TUid KUidAsrEventCreateModelBank				= {KUidAsrEventCreateModelBankVal};
+const TUid KUidAsrEventRemoveGrammar				= {KUidAsrEventRemoveGrammarVal};
+const TUid KUidAsrEventRemoveLexicon				= {KUidAsrEventRemoveLexiconVal};
+const TUid KUidAsrEventRemoveModelBank				= {KUidAsrEventRemoveModelBankVal};
+const TUid KUidAsrEventRemoveRule					= {KUidAsrEventRemoveRuleVal};
+const TUid KUidAsrEventRemovePronunciation			= {KUidAsrEventRemovePronunciationVal};
+const TUid KUidAsrEventRemoveModel					= {KUidAsrEventRemoveModelVal};
+const TUid KUidAsrEventGetAvailableStorage			= {KUidAsrEventGetAvailableStorageVal};
+const TUid KUidAsrEventGetRuleValidity				= {KUidAsrEventGetRuleValidityVal};
+const TUid KUidAsrEventGetUtteranceDuration			= {KUidAsrEventGetUtteranceDurationVal};
+
+const TUid KUidAsrEventGetModelCount				= {KUidAsrEventGetModelCountVal};
+const TUid KUidAsrEventGetPronunciationCount		= {KUidAsrEventGetPronunciationCountVal};
+const TUid KUidAsrEventGetRuleCount					= {KUidAsrEventGetRuleCountVal};
+
+const TUid KUidAsrEventGetAllRuleIDs				= {KUidAsrEventGetAllRuleIDsVal};
+const TUid KUidAsrEventGetAllPronunciationIDs		= {KUidAsrEventGetAllPronunciationIDsVal};
+const TUid KUidAsrEventGetAllModelIDs				= {KUidAsrEventGetAllModelIDsVal};
+const TUid KUidAsrEventGetAllClientGrammarIDs		= {KUidAsrEventGetAllClientGrammarIDsVal};
+const TUid KUidAsrEventGetAllClientLexiconIDs		= {KUidAsrEventGetAllClientLexiconIDsVal};
+const TUid KUidAsrEventGetAllClientModelBankIDs		= {KUidAsrEventGetAllClientModelBankIDsVal};
+const TUid KUidAsrEventGetAllGrammarIDs				= {KUidAsrEventGetAllGrammarIDsVal};
+const TUid KUidAsrEventGetAllLexiconIDs				= {KUidAsrEventGetAllLexiconIDsVal};
+const TUid KUidAsrEventGetAllModelBankIDs			= {KUidAsrEventGetAllModelBankIDsVal};
+
+// SI event UIDs
+const TUid KUidAsrEventAdapt         = {KUidAsrEventAdaptVal};
+const TUid KUidAsrEventAddVoiceTag   = {KUidAsrEventAddVoiceTagVal};
+const TUid KUidAsrEventAddVoiceTags  = {KUidAsrEventAddVoiceTagsVal};
+const TUid KUidAsrEventSIRecognition = {KUidAsrEventSIRecognitionVal};
+const TUid KUidAsrEventAddRuleVariant= {KUidAsrEventAddRuleVariantVal};
+const TUid KUidAsrEventCreateRule    = {KUidAsrEventCreateRuleVal};
+const TUid KUidAsrEventEndRecord     = {KUidAsrEventEndRecordVal};
+const TUid KUidAsrEventUnloadGrammar = {KUidAsrEventUnloadGrammarVal};
+const TUid KUidAsrEventUpdateGrammarAndLexicon = {KUidAsrEventUpdateGrammarAndLexiconVal};
+                                                       
+const TUid KUidAsrEventActivateGrammar = {KUidAsrEventActivateGrammarVal};
+const TUid KUidAsrEventDeactivateGrammar = {KUidAsrEventDeactivateGrammarVal};
+const TUid KUidAsrEventRemoveRules = {KUidAsrEventRemoveRulesVal};
+
+const TInt KUidMediaTypeSIVal = 0x101FF932;
+const TUid KUidMediaTypeSI    = {KUidMediaTypeSIVal};
+
+const TUid KUidAsrEventPreStartSampling = {KUidAsrEventPreStartSamplingVal};
+
+// Speech Recognition Errors
+const TInt KErrAsrNoSpeech 				= -12050;
+const TInt KErrAsrSpeechTooEarly 		= -12051;
+const TInt KErrAsrSpeechTooLong 		= -12052;
+const TInt KErrAsrSpeechTooShort		= -12053;
+const TInt KErrAsrNoMatch				= -12054;
+const TInt KErrAsrDataRightViolation	= -12055;
+const TInt KErrAsrNotRegisted			= -12056;
+const TInt KErrAsrInvalidState			= -12057;
+const TInt KErrAsrInitializationFailure	= -12058;
+
+// Pre-defined Engine Parameter Identifiers starts from index 0x01
+// User-define Engine Parameter Identifiers starts from index 0x10000 and end at index KMaxTInt.
+const TInt KRecognizerMode = 0x01;
+const TInt KGrammarSupport = 0x02;
+const TInt KLoadMultipleGrammars = 0x03;
+const TInt KLoadMultipleLexicons = 0x04;
+const TInt KLoadMultipleModelBanks = 0x05;
+const TInt KModelStorageCapacity = 0x06;
+const TInt KMaxLoadableModels = 0x07;
+const TInt KMaxFrontEndBackEndDelay 		= 0x08;
+const TInt KSamplingRate 					= 0x09;
+const TInt KBitsPerSample 					= 0x0A;
+
+// Lexicon reference counter identifier
+const TInt KLexiconReferenceCounter = 0x0B;
+
+
+enum TNSSRecognitionMode
+{
+	ENSSSdMode,
+	ENSSSiMode,
+	ENSSSdSiMode
+};
+
+#endif // NSSSISPEECHRECOGNITIONDATACOMMON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_si_speech_recognition_data_api/inc/nsssispeechrecognitiondatadevasr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1303 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     This file contains definition of the SISpeechRecognitionDataDevASR structure and API.
+*
+*/
+
+
+
+
+
+#ifndef __SRSIDATA_DEVASR_H__
+#define __SRSIDATA_DEVASR_H__
+
+//  INCLUDES
+#include <nsssispeechrecognitiondatacommon.h>
+ 
+// FORWARD DECLARATION
+class CSILexicon;
+class CSICompiledGrammar;
+
+
+// CLASS DECLARATION
+
+/**
+*  Class to encapsulate a user defined parameters
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIParameters : public CBase
+	{
+	public: // Constructors and destructor
+		/**
+		* Destructor.
+        */
+		IMPORT_C virtual ~CSIParameters();
+
+		/**
+		* Two-phased constructor.
+		*/
+		IMPORT_C static CSIParameters* NewL();
+
+		IMPORT_C static CSIParameters* NewLC();
+	public: // New functions
+		
+		/**
+        * Use to set an internal parameter.
+        * @since 2.8
+		* @param aParameterIndex Parameter index
+		* @param aParameter Parameter value
+        * @return None.
+        */ 
+		IMPORT_C virtual void SetParameterL( const TInt aParameterID, const TInt aParameterValue );
+		
+		/**
+        * Use to retrieve an internal parameter.
+        * @since 2.8
+		* @param aParameterIndex Parameter index
+        * @return Parameter value.
+        */ 
+		IMPORT_C virtual TInt ParameterL( const TInt aParameterID ) const;
+	
+		/**
+        * Internalize to a data stream
+        * @since 2.8
+		* @param aStream Data stream
+        * @return  None
+        */ 
+		IMPORT_C virtual void InternalizeL(RReadStream& aStream );
+
+		/**
+        * Externalize from a data stream
+        * @since 2.8
+		* @param None
+        * @return  aStream Data stream
+        */ 
+		IMPORT_C virtual void ExternalizeL(RWriteStream& aStream ) const;
+
+        /**
+        * Returns all set parameters and their values.
+        * @since 2.8
+        * @param "RArray<TInt>& aParameterIDs" This array will contain parameter IDs after call.
+        * @param "RArray<TInt>& aParameterValues" This array will contain parameter values after call.
+        */
+        IMPORT_C virtual void ListParametersL( RArray<TInt>& aParameterIDs, RArray<TInt>& aParameterValues ) const;
+
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIParameters();
+		
+	private:
+		RArray<TInt> iParameterIDs;
+		RArray<TInt> iParameterValues;	
+	};
+
+/**
+*  Class to encapsulate a Speaker Independent Rule variant
+*
+*  @lib nsssispeechRecognitionData.lib
+*  @since 2.8
+*/
+class CSIRuleVariant : public CSIParameters
+	{
+	public: // Constructors and destructor
+		/**
+		* Destructor.
+        */
+		IMPORT_C virtual ~CSIRuleVariant();
+		
+        /**
+        * Two-phased constructor.
+        */
+		IMPORT_C static CSIRuleVariant* NewL( const TSIRuleVariantID aRuleVariantID, 
+											  const TSILexiconID aLexiconID);
+	    IMPORT_C static CSIRuleVariant* NewLC( const TSIRuleVariantID aRuleVariantID, 
+											  const TSILexiconID aLexiconID);
+     	 
+	public: // New functions
+		
+		/**
+        * Use to get the pronunciation Ids.
+        * @since 2.8
+		* @param None.
+        * @return Pronunciation identifier.
+        */ 
+		IMPORT_C virtual void GetPronunciationIDsL( TSIPronunciationIDSequence& aPronunciationIDs ) const;
+
+		/**
+        * Use to set the pronunciation Ids.
+        * @since 2.8
+		* @param Pronunciation identifier .
+        */ 
+		IMPORT_C virtual void SetPronunciationIDsL( const TSIPronunciationIDSequence& aPronunciationIDs );
+
+		/**
+        * Get Language of the rule variant
+        * @since 2.8
+        * @return Language of the rule variant
+        */ 
+		IMPORT_C virtual TLanguage Language() const;  
+		
+		/**
+        * Set Language of the rule variant
+        * @since 2.8
+        * @param Language of the rule variant
+        * @return None
+        */ 
+		IMPORT_C virtual void SetLanguage(TLanguage aLanguage);
+		
+		
+		/**
+        * Use to retrieve the lexicon Id.
+        * @since 2.8
+		* @param None.
+        * @return Lexicon identifier.
+        */ 
+		IMPORT_C virtual TSILexiconID LexiconID() const;
+		
+		/**
+        * Use to retrieve the rule variant Id.
+        * @since 2.8
+        * @param None.
+        * @return Rule identifier.
+        */ 
+		IMPORT_C virtual TSIRuleVariantID RuleVariantID() const;
+		
+		
+		
+		
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIRuleVariant( const TSIRuleVariantID aRuleVariantID, 
+			const TSILexiconID aLexiconID );
+		
+	private:
+		TSIRuleVariantID iRuleVariantID;
+		TSIPronunciationIDSequence iPronunciationIDs;
+		TSILexiconID iLexiconID;
+		TLanguage iLanguage;
+		TInt* iParameterArray;
+		TInt iNParameters;
+		TAny* iReserved;
+	};
+
+/**
+*  Class to encapsulate a Speaker Independent Rule
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIRule : public CBase
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+        */
+		IMPORT_C virtual ~CSIRule();
+		
+        /**
+        * Two-phased constructor.
+        */
+		IMPORT_C static CSIRule* NewL( const TSIRuleID aRuleID );
+	    IMPORT_C static CSIRule* NewLC( const TSIRuleID aRuleID );
+       	
+	public: // New functions
+		/**
+			* Use to retrieve the rule Id.
+			* @since 2.8
+			* @param None.
+			* @return Rule identifier.
+        */ 
+		IMPORT_C virtual TSIRuleID RuleID() const;
+	/**
+		* Use to retrieve number of rule variants.
+		* @since 2.8
+		* @param None.
+		* @return Number of rule variants.
+       */
+		IMPORT_C virtual TInt Count() const;
+		
+ 		/**
+		* Use to retrieve the rule variant based on index.
+		* @since 2.8
+		* @param aIndex Index of rule variant.
+		* @return Rule variant.
+        */
+		IMPORT_C virtual CSIRuleVariant& AtL(TInt aIndex) const;	
+		
+	
+			/**
+		* Use to add new rule variant.
+		* @since 2.8
+		* @param aRuleVariant New rule variant.
+		* @return None.
+        */
+		IMPORT_C virtual void AddL(CSIRuleVariant* aRuleVariant);
+	
+	/**
+		* Use to retrieve the rule variant index based on Id.
+		* @since 2.8
+			* @param aRuleVariantID Identifier of rule variant.
+		* @return Rule variant.
+        */
+		IMPORT_C virtual TInt Find(TSIRuleVariantID aRuleVariantID) const;
+	
+
+		IMPORT_C virtual CSIRuleVariant&  RuleVariantL(TSIRuleVariantID aRuleVariantID) const;
+	
+		/**
+		* Use to delete rule variant.
+		* @since 2.8
+		* @param aRuleVariant Rule variant identifier.
+			* @return None.
+        */
+		IMPORT_C virtual void DeleteL(TSIRuleVariantID aRuleVariantID);
+	 	 
+        /**
+        * Compares two CSIRule objects.
+        * Returns 0 if rule ids are equal.
+        * Returns -1 if first id is smaller.
+        * Returns 1 if second id is smaller.
+        *
+        * @param "const CSIRule& aFirst" First rule to compare
+        * @param "const CSIRule& aSecond" Second rule to compare
+        * @return 0, -1 or 1
+        */
+		static TInt Compare( const CSIRule& aFirst, const CSIRule& aSecond );
+
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIRule( const TSIRuleID aRuleID );
+		
+	private:
+		TSIRuleID iRuleID;
+		RPointerArray<CSIRuleVariant> iRuleVariantArray;
+		TAny* iReserved;
+	};
+
+
+/**
+*  Class to encapsulate a Speaker Independent Grammar
+*  A grammar consist of a list of rules
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIGrammar : public CBase
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+        */
+		IMPORT_C virtual ~CSIGrammar();
+		
+        /**
+        * Two-phased constructor.
+        */
+		IMPORT_C static CSIGrammar* NewL(const TSIGrammarID aGrammarID);
+		IMPORT_C static CSIGrammar* NewLC(const TSIGrammarID aGrammarID);
+ 		
+	public: // New functions
+
+		/**
+        * Use to add a rule to the grammar.
+        * @since 2.8
+		* @param aRule - reference to CSIRule object.
+        * @return KErrNone, if the insertion is successful, otherwise one of the system wide error codes.
+        */
+		IMPORT_C virtual void AddL(CSIRule* aRule);
+		
+		
+		/**
+        * Use to return a rule based at an index.
+        * @since 2.8
+		* @param aIndex: an index. Value must not be negative and must not be greater than the number of rules currently in the grammar, otherwise it raises a USER-130 panic.
+        * @return Reference to CSIRule object.
+        */
+		IMPORT_C virtual CSIRule& AtL(TInt aIndex) const;
+
+		/**
+        * Use to delete a rule to the grammar.
+        * @since 2.8
+		* @param aRuleID - rule identifier.
+        * @return None.
+        */
+		IMPORT_C virtual void DeleteL(const TSIRuleID aRuleID);
+ 		
+		/**
+        * Use to get the number of rules in the grammar
+        * @since 2.8
+		* @param None.
+        * @return Number of rules.
+        */  
+		IMPORT_C virtual TInt Count() const;
+		
+		/**
+			* Use to retrieve the grammar Id of the result.
+			* @since 2.8
+			* @param None.
+			* @return Grammar identifier.
+        */
+		IMPORT_C virtual TSIGrammarID GrammarID() const;
+
+		/**
+        * Use to find a rule in the grammar based on rule Id.
+        * @since 2.8
+		* @param aRuleID - rule identifier.
+        * @return The index of the first matching rule within the grammar.  KErrNotFound, if no matching rule can be found.
+        */ 
+		
+		IMPORT_C virtual TInt Find(const TSIRuleID aRuleID) const;
+
+		IMPORT_C virtual CSIRule&  RuleL(TSIRuleID aRuleID) const;
+
+		/**
+        * Internalize to a data stream
+        * @since 2.8
+		* @param aStream Data stream
+        * @return  None
+        */ 
+		IMPORT_C virtual void InternalizeL(RReadStream& aStream );
+
+		/**
+        * Externalize from a data stream
+        * @since 2.8
+		* @param None
+        * @return  aStream Data stream
+        */ 
+		IMPORT_C virtual void ExternalizeL(RWriteStream& aStream ) const;
+
+ 	protected:
+		
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIGrammar(const TSIGrammarID aGrammarID);
+		
+	private:
+		TSIGrammarID iGrammarID;
+		RPointerArray<CSIRule> iRuleArray;
+		TAny* iReserved;
+	};
+
+/**
+*  Class to encapsulate a compiled grammar (ready for recognition)
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/ 
+class CSICompiledGrammar : public CSIGrammar
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+        */
+		IMPORT_C virtual ~CSICompiledGrammar();
+		
+        /**
+        * Two-phased constructor.
+        */
+		IMPORT_C static CSICompiledGrammar* NewL(const TSIGrammarID aGrammarID); 
+		
+		IMPORT_C static CSICompiledGrammar* NewLC(const TSIGrammarID aGrammarID); 
+	public: // New functions
+ 		
+
+				/**
+        * Use to delete a rule to the grammar.
+        * @since 2.8
+		* @param aRuleID - rule identifier.
+        * @return None.
+        */
+		IMPORT_C virtual void DeleteL(const TSIRuleID aRuleID);
+		/**
+        * Use to add a rule to the grammar.
+        * @since 2.8
+		* @param aRule - reference to CSIRule object.
+        * @return KErrNone, if the insertion is successful, otherwise one of the system wide error codes.
+        */
+		IMPORT_C virtual void AddL(CSIRule* aRule);
+ 		
+
+		/**
+        * Use to retrieve the recognition data.
+        * @since 2.8
+		* @param None.
+        * @return Reference to the recognition data.
+        */ 
+ 		IMPORT_C virtual void SetCompiledData( HBufC8* aCompilerData);
+		
+		/**
+        * Function to get compiler data
+        * @since 2.8
+        * @param None
+        * @return Pointer to data
+        */	
+		IMPORT_C virtual TDesC8&  CompiledData() const;
+		
+		/**
+        * Internalize to a data stream
+        * @since 2.8
+		* @param aStream Data stream
+        * @return  None
+        */ 
+		IMPORT_C virtual void InternalizeL(RReadStream& aStream );
+
+		/**
+        * Externalize from a data stream
+        * @since 2.8
+		* @param None
+        * @return  aStream Data stream
+        */ 
+		IMPORT_C virtual void ExternalizeL(RWriteStream& aStream ) const;
+
+	protected:
+		IMPORT_C virtual void ConstructL();
+		
+		IMPORT_C CSICompiledGrammar(const TSIGrammarID aGrammarID);
+		
+	private:
+		// is compiled data valid
+		TBool iValidData;
+		 
+		// data of grammar compiler
+		HBufC8*  iGrammarCompilerData;
+		TAny* iReserved;
+		
+	protected:
+		
+	};
+
+/**
+*  Class to define rule variant info
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class TSIRuleVariantInfo
+	{
+	public:  // Constructors and destructor
+		
+        /**
+        * C++ default constructor.
+        */
+        IMPORT_C TSIRuleVariantInfo( const TSIGrammarID aGrammarID, 
+                                     const TSIRuleID aRuleID, 
+                                     const TSIRuleVariantID aRuleVariantID );
+		
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~TSIRuleVariantInfo();
+		
+	public: // New functions
+		
+			/**
+			* Use to get Grammar ID
+			* @since 2.8
+			* @return Identifier of Grammar
+		*/
+		IMPORT_C virtual TSIGrammarID GrammarID() const;
+		
+
+			/**
+			* Use to get rule ID
+			* @since 2.8
+			* @return Identifier of rule
+		*/
+		IMPORT_C virtual TSIRuleID RuleID() const;
+		
+		/**
+		* Use to get rule variant ID
+		* @since 2.8
+		* @return Identifier of rule variant
+		*/
+		IMPORT_C virtual TSIRuleVariantID RuleVariantID() const;
+		
+	protected:    // Data
+		
+		
+		// rule identifier
+		const TSIGrammarID iGrammarID;
+		// rule identifier
+		const TSIRuleID iRuleID;
+		
+		// rule variant identifier
+		const TSIRuleVariantID iRuleVariantID;
+		
+	};
+	
+/**
+*  Class to encapsulate a Speaker Independent Pronunciation
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIPronunciation : public CSIParameters
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+		*/
+		IMPORT_C virtual ~CSIPronunciation();
+		
+		/**
+		* Two-phased constructor.
+		*/
+		IMPORT_C static CSIPronunciation* NewL(const TSIPronunciationID aPronunciationID, 
+											   const TSIModelBankID aModelBankID );
+		IMPORT_C static CSIPronunciation* NewLC(const TSIPronunciationID aPronunciationID, 
+												const TSIModelBankID aModelBankID );
+		
+	public: // New functions
+		/**
+		* Use to retrieve the model bank Id of the model bank.
+		* @since 2.8
+		* @param None.
+		* @return Model bank identifier.
+		*/ 
+		IMPORT_C virtual TSIModelBankID ModelBankID() const;
+ 			/**
+			* Use to set the pronunciation Id of this lexicon entry.
+			* @since 2.8
+			* @param Pronunciation identifier.
+			* @return None.
+		*/ 
+		 IMPORT_C virtual void SetPronunciationID(TSIPronunciationID aPronunciationID); 
+		
+		
+			/**
+			* Use to retrieve the pronunciation Id of this lexicon entry.
+			* @since 2.8
+			* @param None.
+			* @return Pronunciation identifier.
+		*/ 
+		IMPORT_C virtual TSIPronunciationID PronunciationID() const;
+		/**
+		* Use to set phoneme sequence.
+		* @since 2.8
+		* @param aPhonemeSequence Phoneme sequence.
+		* @return None.
+		*/  
+		IMPORT_C virtual void SetPhonemeSequenceL( const TDesC8& aPhonemeSequence );
+		
+
+		/**
+		* Use to retrieve the phoneme sequence.
+		* @since 2.8
+		* @param None.
+		* @return Phoneme sequence.
+		*/  
+		IMPORT_C virtual const TDesC8& PhonemeSequence() const;
+
+        /**
+        * Compares two CSIPronunciation objects.
+        * Returns 0 if prununciation ids are equal.
+        * Returns -1 if first id is smaller.
+        * Returns 1 if second id is smaller.
+        *
+        * @param "const CSIPronunciation& aFirst" First pronunciation to compare
+        * @param "const CSIPronunciation& aSecond" Second pronunciation to compare
+        * @return 0, -1 or 1
+        */
+		static TInt Compare( const CSIPronunciation& aFirst, const CSIPronunciation& aSecond );
+
+        /**
+        * Compares two CSIPronunciation objects.
+        * Returns 0 if phoneme sequences are equal.
+        * Returns -1 if first phoneme sequence is smaller.
+        * Returns 1 if second phoneme sequence is smaller.
+        *
+        * @param "const CSIPronunciation& aFirst" First pronunciation to compare
+        * @param "const CSIPronunciation& aSecond" Second pronunciation to compare
+        * @return 0, -1 or 1
+        */
+		static TInt ComparePhonemes( const CSIPronunciation& aFirst, const CSIPronunciation& aSecond );
+
+
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIPronunciation(const TSIPronunciationID aPronunciationID, 
+								  const TSIModelBankID aModelBankID );
+		
+	private:
+		TSIPronunciationID iPronunciationID;
+		TSIModelBankID iModelBankID;
+		HBufC8* iPhonemeSequence;
+		TAny* iReserved;
+	};
+
+
+/**
+*  Class to encapsulate a Speaker Independent Lexicon
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSILexicon : public CBase
+	{
+	public:// Constructors and destructor
+	
+        /**
+        * Destructor.
+		*/
+		IMPORT_C virtual ~CSILexicon();
+		
+		/**
+		* Two-phased constructor.
+		* @param aLexiconID Lexicon ID
+		* @return Created instance
+		*/
+		IMPORT_C static CSILexicon* NewL( const TSILexiconID aLexiconID );
+		IMPORT_C static CSILexicon* NewLC( const TSILexiconID aLexiconID );
+		
+	public: // New functions
+		
+		/**
+		* Use to add a lexicon entry to the lexicon.
+		* Leaves with KErrNoMemory if maximal allowed amount of pronunciations
+		* is already stored in this lexicon
+		* @since 2.8
+		* @param aPronunciation pointer to CSIPronunciation object.
+		*/
+    	IMPORT_C virtual void AddL( CSIPronunciation* aPronunciation );
+		
+		/**
+		* Use to return a pronunciation based at an index.
+		* @since 2.8
+		* @param aIndex Value must not be negative and must not be greater than
+		*               the number of pronunciations currently in the lexicon.
+		* @return Reference to CSIPronunciation object.
+		*/
+		IMPORT_C virtual CSIPronunciation& AtL( TInt aIndex ) const;
+
+        /**
+		* Deletes a pronunciation based on identifier.
+		* @since 2.8
+		* @param aPronunciationID pronunciation variant identifier.
+        */
+		IMPORT_C virtual void DeleteL( TSIPronunciationID aPronunciationID );
+		 
+		/**
+		* Use to find a pronunciation based on pronunciation Id.
+		* @since 2.8
+		* @param aPronunciationID: pronunciation identifier.
+		* @return The index of the first matching pronunciation within the lexicon.
+		*         KErrNotFound, if no matching pronunciation can be found.
+		*/ 
+		IMPORT_C virtual TInt Find( const TSIPronunciationID aPronunciationID ) const;
+		
+		/**
+		* Use to find a pronunciation based on phoneme sequence.
+		* @since 2.8
+		* @param aPronunciation: phoneme sequence.
+		* @return The index of the first matching pronunciation within the lexicon.
+		*         KErrNotFound, if no matching pronunciation can be found.
+		*/ 
+		IMPORT_C virtual TInt Find( const TDesC8& aPhonemeSequence ) const;
+		
+		/**
+		* Use to count the number of lexicon entries in the lexicon.
+		* @since 2.8
+		* @return Number of pronunciations.
+		*/
+		IMPORT_C virtual TInt Count() const;
+
+		/**
+		* Use to retrieve the model bank Id of the model bank.
+		* @since 2.8
+		* @return Model bank identifier.
+		*/  
+		IMPORT_C virtual TSILexiconID LexiconID() const;
+ 		
+		/**
+        * Internalize to a data stream
+        * @since 2.8
+		* @param aStream Data stream
+        */ 
+		IMPORT_C virtual void InternalizeL( RReadStream& aStream );
+
+		/**
+        * Externalize from a data stream
+        * @since 2.8
+		* @param aStream Data stream
+        */ 
+		IMPORT_C virtual void ExternalizeL( RWriteStream& aStream ) const;
+
+	protected:
+		IMPORT_C void ConstructL();
+		IMPORT_C CSILexicon( const TSILexiconID aLexiconID );
+		
+    private:
+    
+        /**
+        * Utility function to add pronunciation to the end of ID-ordered array
+        *
+        * @param "CSIPronunciation* aPronunciation" Pronunciation which should be added.
+        */
+        void AddPronunciationToEndL( CSIPronunciation* aPronunciation );
+		
+	private:
+        // ID of the lexicon
+        TSILexiconID iLexiconID;
+        // Pronunciations in the order of IDs
+		RPointerArray<CSIPronunciation> iPronunciationArray;
+		// Pronunciations in the order of the phoneme sequence
+		RPointerArray<CSIPronunciation> iPronunOrder;
+		// For future extensions
+		TAny* iReserved;
+	};
+
+
+/**
+*  Class to encapsulate a Speaker Independent Model
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIModel : public CSIParameters
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+		*/
+		IMPORT_C virtual ~CSIModel();
+		
+		/**
+		* Two-phased constructors.
+		*/
+		//IMPORT_C static CSIModel* NewL();
+		//IMPORT_C static CSIModel* NewLC();
+		IMPORT_C static CSIModel* NewL( const TSIModelID aModelID );
+		IMPORT_C static CSIModel* NewLC( const TSIModelID aModelID );
+		
+	public: // New functions
+			/**
+			* Use to set the phoneme Id of this model.
+			* @since 2.8
+			* @param aModelID: phoneme identifier.
+			* @return None.
+		*/ 
+		IMPORT_C virtual void SetModelID( const TSIModelID aModelID);
+		
+		/**
+		* Use to retreive the phoneme Id of this model.
+		* @since 2.8
+		* @param None.
+		* @return Phoneme identifier.
+		*/ 
+		IMPORT_C virtual TSIModelID ModelID() const;
+		
+		/**
+		* Use to get a pointer to the acoustic model of this model.
+		* @since 2.8
+		* @param None.
+		* @return A descriptor to the acoustic model data.
+		*/
+		IMPORT_C virtual   TDesC8& AcousticModel() const;
+	
+		/**
+		* Use to set the acoustic model of the model.
+		* @since 2.8
+		* @param aAcousticModel: pointer descriptor containing the acoustic model (binary).
+		* @return None.
+		*/ 
+		IMPORT_C virtual void SetAcousticModel(  HBufC8* aAcousticModel );
+		
+		
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIModel( );
+		IMPORT_C CSIModel( const TSIModelID aModelID );
+		
+	private:
+		TSIModelID iModelID;
+		HBufC8* iAcousticModel;
+		TAny* iReserved;
+	};
+
+/**
+*  Class to encapsulate a Speaker Independent Model Bank
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIModelBank : public CBase
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+		*/
+		IMPORT_C virtual ~CSIModelBank();
+		
+		/**
+		* Two-phased constructor.
+		*/
+		IMPORT_C static CSIModelBank* NewL(const TSIModelBankID aModelBankID);
+		IMPORT_C static CSIModelBank* NewLC(const TSIModelBankID aModelBankID);
+		
+	public: // New functions	
+		 
+
+
+		/**
+		* Use to add a model to the model bank.
+		* @since 2.8
+		* @param aModel: reference to CSIModel object.
+		* @return None
+		*/ 
+		IMPORT_C virtual void AddL(const CSIModel* aModel);
+		
+		/**
+		* Use to return a model at the given index.
+		* @since 2.8
+		* @param Reference to CSIModel object.
+		* @return None
+		 */ 
+		IMPORT_C virtual CSIModel& AtL(TInt aIndex) const;
+		
+		/**
+		* Deletes  a model from model bank.
+		* @since 2.8
+		* @param ID of the model 
+		* @return None 
+		*/ 
+		IMPORT_C virtual void DeleteL(TSIModelID aModelID); 
+
+		/**
+		* Use to find a model based on phoneme Id.
+		* @since 2.8
+		* @param None.
+		* @return Index of the first matching model within the model bank.  KErrNotFound, if no matching model can be found..
+		*/ 
+		IMPORT_C virtual TInt Find(TSIModelID aModelID) const;
+		
+		/**
+		* Use to retreive the number of models in the model bank.
+		* @since 2.8
+		* @param None.
+		* @return Number of models in the model bank.
+		*/
+		IMPORT_C virtual TInt Count() const;
+		
+			/**
+			* Use to return the model bank Id of the model bank.
+			* @since 2.8
+			* @param None.
+			* @return Model bank identifier.
+		*/
+		IMPORT_C virtual TSIModelBankID ModelBankID() const;
+		
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIModelBank(const TSIModelBankID aModelBankID);
+		
+	private:
+		TSIModelBankID iModelBankID;
+		RPointerArray<CSIModel> iModelArray;
+		TAny* iReserved;
+	};
+
+/**
+*  Class to define pronunciation type.
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIPronunciationInfo : public CSIParameters
+	{
+	public:  // Constructors and destructor
+
+		/**
+		* Two-phased constructor.
+		*/
+		IMPORT_C static CSIPronunciationInfo* NewL(RPointerArray<HBufC8>  aPronunciationArray,
+			TLanguage aLanguage );
+		IMPORT_C static CSIPronunciationInfo* NewLC(RPointerArray<HBufC8>  aPronunciationArray,
+			TLanguage aLanguage );
+		
+		/**
+		* Destructor.
+		*/
+		IMPORT_C virtual ~CSIPronunciationInfo();
+		
+	public: // New functions
+		
+			/**
+			* Use to get phoneme sequence data
+			* @since 2.8
+			* @return Phoneme sequence
+		*/
+		IMPORT_C virtual TDesC8& PronunciationL(TInt aIndex) const;
+
+			/**
+			* Use to set phoneme sequence data
+			* @since 2.8
+			* @return Phoneme sequence
+		*/
+		
+		IMPORT_C virtual void SetPronunciationL( TInt aIndex, HBufC8* aPronunciation);
+
+		IMPORT_C virtual TLanguage Language() const;
+
+		IMPORT_C virtual TInt Count() const;
+		
+
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIPronunciationInfo( RPointerArray<HBufC8> aPronunciationArray,TLanguage aLanguage);	
+
+	private:    // Data
+		
+		// phoneme sequence
+		//HBufC8* iPronunciation;
+		RPointerArray<HBufC8> iPronunciationArray;
+			
+		TLanguage iLanguage;
+		TAny* iReserved;
+	};
+
+/**
+*  Class to define word list. The list is used as input parameter for TTP.
+*
+*  @lib SiSpeechRecognitionData.lib
+*  @since 2.8
+*/
+class CSITtpWordList : public CBase
+	{
+	public:  // Constructors and destructor
+		
+			 /**
+			 * Two-phased constructor.
+		*/
+		IMPORT_C static CSITtpWordList* NewL();
+		IMPORT_C static CSITtpWordList* NewLC();
+		
+		/**
+		* Destructor.
+		*/
+		IMPORT_C virtual ~CSITtpWordList();
+		
+	public: // New functions
+		
+			/**
+			* Use to add a new word
+			* @since 2.8
+			* @param aWord Word to be added
+		*/
+		IMPORT_C virtual void AddL(  MDesCArray* aWords );
+		
+		/**
+		* Use to get number of words
+		* @since 2.8
+		* @return number of words
+		*/
+		IMPORT_C virtual TInt Count() const;
+		
+		/**
+		* Use to return word at an index
+		* @since 2.8
+		* @param aIndex Index of word
+		* @return reference to word sequence
+		*/
+		IMPORT_C virtual  MDesCArray& AtL( const TInt aIndex ) const;
+		
+		
+		/**
+		* Use to delete word at an index
+		* @since 2.8
+		* @param aIndex Index of word 		
+		* @return None
+		*/
+		IMPORT_C virtual void DeleteL(TInt aIndex);
+		
+ 
+
+		/**
+		* Use to set pronunciation for a word
+		* @since 2.8
+		* @param aIndex Index of word seqence
+		* @param aPronunciation Pronunciation to be added
+		*/
+		IMPORT_C virtual void AppendPronunciationL(TInt aIndex, 
+			CSIPronunciationInfo* aPronunciation);
+
+		
+			/**
+			* Use to get pronunciations for a word
+			* @since 2.8
+			* @param aIndex Index of word sequence
+			* @param aPronunciations Array where to put pronunciations
+		*/
+		IMPORT_C virtual void GetPronunciationsL( const TInt aIndex, 
+			RPointerArray<CSIPronunciationInfo>& aPronunciations ) const; 
+
+	protected:
+		
+	/**
+	* C++ default constructor.
+		*/
+		IMPORT_C CSITtpWordList();
+		
+		/**
+		* By default Symbian 2nd phase constructor is private.
+		*/
+		IMPORT_C void ConstructL();
+		
+	private:    // Data
+		
+		// word array
+	//	RArray<TPtrC> iWordArray;
+ 		RPointerArray<MDesCArray> iWordArray;
+		// index array for pronunciations
+		RArray<TInt> iIndexArray; 
+		// pronunciation array
+		RPointerArray<CSIPronunciationInfo> iPronunciationArray;
+		
+		// Reserved pointer for future extension
+		TAny* iReserved;
+    };
+
+/**
+*  Class to encapsulate a Recognition Result
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIResult : public CSIParameters
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+		*/
+		IMPORT_C virtual ~CSIResult();
+		
+		/**
+		* Two-phased constructor.
+		*/
+		IMPORT_C static CSIResult* NewL();
+		IMPORT_C static CSIResult* NewLC();
+		
+	public: // New functions	
+			/**
+			* Use to set the grammar Id on the result.
+			* @since 2.8
+			* @param aGrammarID - grammar identifier.
+			* @return None.
+		*/
+		IMPORT_C virtual void SetGrammarID(const TSIGrammarID aGrammarID);
+		
+		/**
+		* Use to retrieve the grammar Id of the result.
+		* @since 2.8
+		* @param None.
+		* @return Grammar identifier.
+		*/
+		IMPORT_C virtual TSIGrammarID GrammarID() const;
+		
+		/**
+		* Use to set the rule Id of the result.
+		* @since 2.8
+		* @param aRuleID - rule identifier.
+		* @return None.
+		*/
+		IMPORT_C virtual void SetRuleID(const TSIRuleID aRuleID);
+		
+		/**
+		* Use to retrieve the rule Id of the result.
+		* @since 2.8
+		* @param None.
+		* @return Rule identifier.
+		*/ 
+		IMPORT_C virtual TSIRuleID RuleID() const;
+		
+		/**
+		* Use to set the rule variant Id of the result.
+		* @since 2.8
+		* @param aRuleID - rule variant identifier.
+		* @return None.
+		*/
+		IMPORT_C virtual void SetRuleVariantID(const TSIRuleVariantID aRuleVariantID);
+		
+		/**
+		* Use to retrieve the rule variant Id of the result.
+		* @since 2.8
+		* @param None.
+		* @return Rule variant identifier.
+		*/ 
+		IMPORT_C virtual TSIRuleVariantID RuleVariantID() const;
+		
+		/**
+		* Use to set the score for this result.
+		* @since 2.8
+		* @param aScore: score of this result.
+		* @return None.
+		*/ 
+		IMPORT_C virtual void SetScore(const TInt32 aScore);
+		
+		/**
+		* Use to retreive the score of this result.
+		* @since 2.8
+		* @param None.
+		* @return Score of this result.
+		*/ 
+		IMPORT_C virtual TInt32 Score() const;
+		
+		/**
+		* Sets the pronunciation information needed for speaker adaptation and playback.  
+		* @since 2.8
+		* @param aSIPronunciationInfo  Pronunciation information,  needed for speaker adaptation and playback  
+		* @return  None.
+		*/ 
+		IMPORT_C virtual void SetPronunciation(  CSIPronunciation* aSIPronunciation);
+
+		/**
+		* Gets the pronunciation information needed for speaker adaptation and playback.  
+		* @since 2.8
+		* @param None
+		* @return aSIPronunciationInfo  Pronunciation information,  needed for speaker adaptation and playback  
+		*/ 
+ 		IMPORT_C virtual CSIPronunciation& Pronunciation() const ;
+	protected:
+		IMPORT_C virtual void ConstructL();
+		IMPORT_C CSIResult();
+		
+	private:
+		TSIGrammarID iGrammarID;
+		TSIRuleID iRuleID;
+		TSIRuleVariantID iRuleVariantID;
+		TInt32 iScore;
+		CSIPronunciation* iSIPronunciation;
+		TAny* iReserved;
+	};
+
+
+/**
+*  Class to encapsulate a a set of Recognition Result
+*
+*  @lib nsssispeechrecognitiondata.lib
+*  @since 2.8
+*/
+class CSIResultSet : public CBase
+	{
+	public:// Constructors and destructor
+		   /**
+		   * Destructor.
+		*/        
+		IMPORT_C virtual ~CSIResultSet();
+		/**
+		* Two-phased constructor.
+		*/
+		IMPORT_C static CSIResultSet* NewL();
+		IMPORT_C static CSIResultSet* NewLC();
+		
+	public: // New functions		
+			/**
+			* Use to add a result to the rule set.
+			* @since 2.8
+			* @param aResult - reference to the result object to be added.
+			* @return KErrNone, if the insertion is successful, otherwise one of the system wide error codes.
+		*/
+		IMPORT_C virtual void AddL( const CSIResult* aResult); 
+
+		/**
+		* Use to return a result at a given index within the result set.
+		* @since 2.8
+		* @param aIndex - index in the result set.
+		* @return  A reference to CSIResult object.
+		*/
+		IMPORT_C virtual  CSIResult& AtL(const TInt aIndex);
+
+        /**
+		* Use to return a result at a given index within the result set.
+		* @since 2.8
+		* @param aIndex - index in the result set.
+		* @return  A constant reference to CSIResult object.
+		*/
+		IMPORT_C virtual const CSIResult& AtL(const TInt aIndex) const;
+		
+		/**
+		* Use to retreive the number of result in the result set.
+		* @since 2.8
+		* @param None.
+		* @return Number of results in the result set.
+		*/ 
+		IMPORT_C virtual TInt Count() const;
+	
+		
+		/**
+		* Delete a result in the result set.
+		* @since 2.8
+		* @param  index of a result
+		* @return None
+		*/ 
+		IMPORT_C virtual void DeleteL(TInt aIndex);
+		
+		/**
+		* Sets the data needed for speaker adaptation. CSIResultSet takes ownership of the data.		
+		* @since 2.8
+		* @param   Adaptation data
+		* @return None
+		*/  
+		IMPORT_C virtual void SetAdaptationData( HBufC8* aAdaptationData );
+
+
+		/**
+		* Gets the data needed for speaker adaptation. CSIResultSet takes ownership of the data.		
+		* @since 2.8
+		* @param None  		
+		* @return   Adaptation data
+		*/  
+		IMPORT_C virtual TDesC8& AdaptationData();
+
+        /**
+        * Stores the object to the stream.
+        * @since 2.8
+        * @param aWriteStream The stream to write to.
+        * @return None
+        */
+        IMPORT_C virtual void ExternalizeL( RWriteStream& aWriteStream ) const;
+
+        /**
+        * Resurrects an object from the stream.
+        * @since 2.8
+        * @param aReadStream The stream to read from.
+        * @return None
+        */
+        IMPORT_C virtual void InternalizeL( RReadStream& aReadStream );
+
+	private:
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		IMPORT_C virtual void ConstructL();
+
+        /**
+        * C++ constructor
+        */
+		IMPORT_C CSIResultSet();
+		
+	private:
+        // The results
+		RPointerArray<CSIResult> iResultArray;
+
+        // Speaker adaptation data
+		HBufC8* iAdaptationData;
+
+        // Reserved for future extensions
+		TAny* iReserved;
+	};
+
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_si_speech_recognition_data_api/nss_si_speech_recognition_data_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="2b3b14eefd6fda66b0321fcc84dbc7e0" dataversion="2.0">
+  <name>NSS SI Speech Recognition Data API</name>
+  <description>Definitions of data classes for speaker independent speech recognition</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nsssispeechrecognitiondata.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_custom_commands_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS SRS Custom Commands API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nsssispeechrecognitioncustomcommandimplementor.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitioncustomcommandimplementor.h)
+../inc/nsssispeechrecognitioncustomcommandparser.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitioncustomcommandparser.h)
+../inc/nsssispeechrecognitioncustomcommands_sinde.h     APP_LAYER_PLATFORM_EXPORT_PATH( nsssispeechrecognitioncustomcommands.h )
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommandimplementor.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,511 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the definition of the server side for the
+*			    speaker independent controller.
+*
+*/
+
+
+
+#ifndef NSSSISPEECHRECOGNITIONCUSTOMCOMMANDIMPLEMENTOR_H
+#define NSSSISPEECHRECOGNITIONCUSTOMCOMMANDIMPLEMENTOR_H
+
+// INCLUDES
+
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitiondatacommon.h>
+
+// CLASS DECLARATION
+
+/**
+*  This is the main class of Speaker Independent Custom Commands Implementor
+*
+*  @lib NssSiSpeechRecognitionCustomCommands.lib
+*  @since 2.8
+*/
+
+class MSISpeechRecognitionCustomCommandImplementor
+{
+
+public:
+
+		/**
+		*	Adapts speaker independent models according using a correct recognition result.
+        * 
+        * @since	2.8
+        * @param	aResultSet          The result N-Best containing feature vectors
+		*			aCorrect            The correct index
+		*/
+        virtual void MSrAdaptL(CSIClientResultSet& aResultSet, TInt aCorrect) = 0;
+
+		/**
+		*	Adds a pronunciation to the given lexicon.
+        * 
+        * @since	2.8
+		* @param	aLexiconID			The lexicon Id
+        * @param    aTrainText          Text to be pronounced
+        * @param    aLanguage           Pronunciation language
+		* @param	aPronunciationID	Reference where a new pronunciation Id is assigned to.
+		*/
+        virtual void MSrAddPronunciationL(TSILexiconID aLexiconID,
+                                          const TDesC& aTrainText,
+                                          TLanguage aLanguage,
+                                          TSIPronunciationID& aPronunciationID) = 0;
+
+		/**
+        *	Adds a rule variant to a grammar.
+        * 
+        * @since 2.8
+        * @param 	aGrammarID          Grammar identifier
+        * @param    aRuleID             Rule identifier; variant is added here.
+        * @param    aPronunciations     Sequence of pronunciations; these get concatenated.
+        *                               in the rule variant.
+        * @param    aRuleVariantID      Reference where the new variant
+        *                               identifier is assigned to.
+		*/
+		virtual void MSrAddRuleVariantL(
+            TSIGrammarID aGrammarID,
+            TSILexiconID aLexiconID,
+            RArray<TSIPronunciationID>& aPronunciationIDs,
+            TSIRuleID aRuleID,
+            TSIRuleVariantID& aRuleVariantID ) = 0;
+
+        /**
+		*	Trains a voice tag. Adds the text to the lexicon, and creates the required
+        *   rules and rule variants.
+        * 
+        * @since 2.8
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciaiton languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Reference, where the new rule identifier is assigned to.
+        */
+        virtual void MSrAddVoiceTagL(
+            MDesCArray& aTrainArray,
+            RArray<TLanguage>& aLanguageArray,
+            TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID,
+            TSIRuleID& aRuleID) = 0;
+
+        /**
+		*	Trains voice tags. If the training fails for some of the names (but not all),
+        *   it is signaled by setting the Rule ID to KInvalidRuleID.
+        * 
+        * @since 2.8
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciation languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Referenceto an array, where the new
+        *                               Rule identifiers are assigned to.
+        */
+        virtual void MSrAddVoiceTagsL(
+            RPointerArray<MDesCArray>* aTrainArray,
+            RArray<TLanguage>& aLanguageArray,
+            TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID,
+            RArray<TSIRuleID>& aRuleID) = 0;
+
+        /**
+        *	Creates a new rule.
+        * 
+        * @since 2.8
+        * @param 	aGrammarID          Grammar identifier
+        * @param 	aRuleID             Reference where rule ID is stored
+        */
+        virtual void MSrCreateRuleL(TSIGrammarID aGrammarID, TSIRuleID& aRuleID) = 0;
+
+		/**
+        *   Starts recognition
+        *
+        * @since 2.8
+        * @param 	aResultSet          Recognition result is placed here, when ready.
+        */
+		virtual void MSrRecognizeL( CSIClientResultSet& aResultSet ) = 0;
+
+        /**
+		*	Stops recognition. Unlike Cancel(), this function gives
+        *   the recognition result, if it can be guessed.
+        *
+        * @since	2.8
+        */
+		virtual void MSrEndRecordL() = 0;
+
+		/**
+		*   Deactivates a grammar.
+		*
+        * @since	2.8
+        * @param	aGrammarID          Grammar identifier
+        */
+        virtual void MSrUnloadGrammarL( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+		* Trains one SINDE voice tag. Adds the text to the lexicon, and 
+        * creates the required rules and rule variants.
+        * 
+        * @since 3.1
+        * @param aTrainArray The phrase to be trained, split into subwords
+        * @param aLanguageArray The pronunciation languages for each of the 
+        * @param aLexiconID Lexicon identifier
+        * @param aGrammarID Grammar identifier
+        * @param aRuleID Reference, where the new rule identifier is assigned to.
+        */
+        virtual void MSrAddSindeVoiceTagL( MDesCArray& aTrainArray,
+                                           RArray<RLanguageArray>& aLanguageArray,
+                                           TSILexiconID aLexiconID,
+                                           TSIGrammarID aGrammarID,
+                                           TSIRuleID& aRuleID ) = 0;
+
+        /**
+		* Trains SINDE voice tags. If the training fails for some of the names
+        * (but not all), it is signaled by setting the Rule ID to KInvalidRuleID.
+        * 
+        * @since 3.1
+        * @param aTrainArray The phrase to be trained, split into subwords
+        * @param aLanguageArray The pronunciation languages
+        * @param aLexiconID Lexicon identifier
+        * @param aGrammarID Grammar identifier
+        * @param aRuleID Referenceto an array, where the new
+        *                rule identifiers are assigned to.
+        */
+        virtual void MSrAddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,
+                                            RArray<RLanguageArray>& aLanguageArray,
+                                            TSILexiconID aLexiconID,
+                                            TSIGrammarID aGrammarID,
+                                            RArray<TSIRuleID>& aRuleID ) = 0;
+
+/***************************** SD Legacy functions ***********************/
+
+		/**
+		*	Adds a new rule for the given pronunciation into the specified 
+		*	grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id, where the new rule is 
+		*								added to
+		* @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+		* @param	aRuleID				reference where a new rule Id is 
+		*								assigned to
+		*/
+		virtual void MSrAddRuleL( TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+						TSIPronunciationID aPronunciationID, 
+						TSIRuleID& aRuleID ) = 0;
+
+		/**
+        * 
+        *	Cancels the current operation
+        * @since 2.0
+		*/
+		virtual void MSrCancel() = 0;
+
+        /**
+		*	Saves the current changes into a permanent storage.
+        * @since 2.0
+        */
+		virtual void MSrCommitChangesL() = 0;
+
+		/**
+        * 
+        *	Creates a new grammar.
+        * @since 2.0
+        * @param 	aGrammarID			reference where grammar ID is stored
+        */
+		virtual void MSrCreateGrammarL( TSIGrammarID& aGrammarID ) = 0;
+
+		/**
+        * 
+        *	Creates a new lexicon.
+        * @since 2.0
+        * @param 	aLexiconID			reference where lexicon ID is stored
+        */
+		virtual void MSrCreateLexiconL( TSILexiconID& aLexiconID ) = 0;
+
+        /**
+		*	Creates a new model bank.
+        * @since	2.0
+        * @param	aModelBankID		reference where a new model bank Id 
+		*								is assigned to
+        */
+		virtual void MSrCreateModelBankL( TSIModelBankID& aModelBankID ) = 0;
+
+		/**
+		*	Ends the current recognition session. Resources allocated 
+		*	for recognition are freed.
+        * @since	2.0
+        * @param	aModelBankID		reference where a new model bank
+		*								Id is assigned to
+        */
+		virtual void MSrEndRecSessionL() = 0;
+
+		/**
+        *	Returns all grammar Ids that belong to the current client, 
+		*	whose UID was set with MSrSetClientUid().
+        * @since 2.0
+		* @param	aGrammarIDs			reference where grammar Ids are stored
+        */
+		virtual void MSrGetAllClientGrammarIDsL( 
+						RArray<TSIGrammarID>& aGrammarIDs ) = 0;
+
+		/**
+ 		*	Returns all lexicon Ids that belong to the current client,
+		*	whose UID was set with MSrSetClientUid().
+        * @since 2.0
+		* @param	aLexiconIDs			reference where lexicon Ids are stored
+        */
+		virtual void MSrGetAllClientLexiconIDsL( 
+						RArray<TSILexiconID>& aLexiconIDs ) = 0;
+
+		/**
+        *	Returns all model bank Ids that belong to the current client, 
+		*	whose UID was set with MSrSetClientUid().
+        * @since 2.0
+		* @param	aModelBankIDs		reference where model bank Ids are stored
+        */
+		virtual void MSrGetAllClientModelBankIDsL( 
+						RArray<TSIModelBankID>& aModelBankIDs ) = 0;
+
+		/**
+		*	Returns all grammar Ids that exist (for all clients).
+        * @since 2.0
+		* @param	aGrammarIDs			reference where grammar Ids are stored
+        */
+		virtual void MSrGetAllGrammarIDsL( 
+						RArray<TSIGrammarID>& aGrammarIDs ) = 0;
+
+		/**
+		*	Returns all lexicon Ids that exist (for all clients).
+        * @since 2.0
+		* @param	aLexiconIDs			reference where lexicon Ids are stored
+        */
+		virtual void MSrGetAllLexiconIDsL( 
+						RArray<TSILexiconID>& aLexiconIDs ) = 0;
+
+		/**
+ 		*	Returns all model bank Ids that exist (for all clients).
+        * @since 2.0
+		* @param	aModelBankIDs		reference where model bank Ids are stored
+        */
+		virtual void MSrGetAllModelBankIDsL( 
+						RArray<TSIModelBankID>& aModelBankIDs ) = 0;
+
+		/**
+		*	Returns all pronunciation Ids that exist in the specified lexicon.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+		*			aPronunciationIDs	reference where pronunciation Ids 
+		*			are stored
+        */
+		virtual void MSrGetAllPronunciationIDsL( TSILexiconID aLexiconID, 
+						RArray<TSIPronunciationID>& aPronunciationIDs ) = 0;
+
+		/**
+		*	Returns all rule Ids that exist in the specified grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		*			aRuleIDs			reference where rule Ids are stored
+        */
+		virtual void MSrGetAllRuleIDsL( TSIGrammarID aGrammarID, 
+						RArray<TSIRuleID>& aRuleIDs ) = 0;
+
+		/**
+        * 
+        *	Returns the engine properties specified by the engine property 
+		*	ID array. On return aPropertyValue contains an array of engine 
+		*	properties.
+        * @since 2.0
+        * @param 	aPropertyId		constant reference to array of engine 
+		*							property Ids
+		* @param	aPropertyValue	reference to array of engine property 
+		*							values
+        */
+		virtual void MSrGetEnginePropertiesL( const RArray<TInt>& aPropertyId, 
+						RArray<TInt>& aPropertyValue ) = 0;
+		
+		/**
+		*	Checks if the rule is valid or not.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		*			aRuleID				rule Id
+		*			aValid				reference where the validity of the 
+		*								rule is set
+        */
+		virtual void MSrGetRuleValidityL( TSIGrammarID aGrammarID, 
+						TSIRuleID aRuleID, TBool& aValid ) = 0;
+
+		/**
+		*	Loads the specified grammar into the reocgnizer;
+        *   done prior to recognition.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+        */
+		virtual void MSrLoadGrammarL( TSIGrammarID aGrammarID ) = 0;
+
+		/**
+		*	Activates the specified grammar,
+        *   which has been previously deactivated.
+        *
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+        */
+		virtual void MSrActivateGrammarL( TSIGrammarID aGrammarID ) = 0;
+
+		/**
+		*	Deactivates a loaded grammar so that it is not recognized.
+        *
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+        */
+		virtual void MSrDeactivateGrammarL( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+        * 
+        *	Loads the specified lexicon into the recognizer; 
+		*	done prior to recognition.
+        * @since 2.0
+        * @param 	aLexiconID			lexicon ID
+        */
+		virtual void MSrLoadLexiconL( TSILexiconID aLexiconID ) = 0;
+
+		/**
+        * 
+        *	Loads the specified model bank into the recognizer; 
+		*	done prior to recognition..
+        * @since 2.0
+        * @param 	ModelBankID			model bank Id
+        */
+		virtual void MSrLoadModelsL( TSIModelBankID aModelBankID ) = 0;
+
+		/**
+		*	Records an utterance for training and recognition.
+        * @since	2.0
+        * @param	aRecordTime			recording time in microseconds
+        */
+		virtual void MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime ) = 0;
+
+        /**
+        * Pre-starts sampling before MSrRecordL call.
+        *
+        * @since 3.2
+        */
+        virtual void MSrPreStartSamplingL() = 0;
+
+		/**
+		*	Removes the specified grammar from the permanent storage.
+		*	Removing a grammar will remove all rules and rule variants
+        *   within the grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+        */
+		virtual void MSrRemoveGrammarL( TSIGrammarID aGrammarID ) = 0;
+
+		/**
+		*	Removes the specified lexicon from the permanent storage.
+		*	Removing a lexicon will remove all pronunciations within the 
+		*	lexicon.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+        */
+		virtual void MSrRemoveLexiconL( TSILexiconID aLexiconID ) = 0;
+
+		/**
+		*	Removes the specified model bank from the permanent storage.
+		*	Removing a model bank will remove all models within the model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+        */
+		virtual void MSrRemoveModelBankL( TSIModelBankID aModelBankID ) = 0;
+
+		/**
+		*	Removes the specified model from the specified model bank 
+		*	permanently.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+        */
+		virtual void MSrRemoveModelL( TSIModelBankID aModelBankID, 
+						TSIModelID aModelID ) = 0;
+
+		/**
+		*	Removes the specified pronunciation from the specified lexicon 
+		*	permanently.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+        */
+		virtual void MSrRemovePronunciationL( TSILexiconID aLexiconID, 
+						TSIPronunciationID aPronunciationID ) = 0;
+
+		/**
+		*	Removes the specified rule from the specified grammar permanently.
+        *   If the rule contains rule variants, they are also destoryed.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        */
+		virtual void MSrRemoveRuleL( TSIGrammarID aGrammarID, 
+						TSIRuleID aRuleID ) = 0;
+
+		/**
+		*	Removes the specified rules from the specified grammar permanently.
+        *   If the rule contains rule variants, they are also destoryed.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleIDs			array of rule ids
+        */
+		virtual void MSrRemoveRulesL( TSIGrammarID aGrammarID, 
+						RArray<TSIRuleID>& aRuleIDs ) = 0;
+
+		/**
+        *	Sets the client's UID for data ownership identification.
+        * @since 2.0
+        * @param	aClientUid			client's UID
+        */
+		virtual void MSrSetClientUid( TUid aClientUid ) = 0;
+
+		/**
+		*	Starts a new recognition session.
+        * @since	2.0
+        * @param	aMode				recognition mode
+        */
+		virtual void MSrStartRecSessionL( TNSSRecognitionMode aMode ) = 0;
+
+		/**
+		*	Unloads the specified rule from the specified grammar in temporary 
+		*	memory, previously loaded with LoadGrammarL.  The rule in the 
+		*	permanent storage remains intact.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        */
+		virtual void MSrUnloadRuleL( TSIGrammarID aGrammarID, 
+						TSIRuleID aRuleID ) = 0;
+
+		/**
+		*	Unloads the specified parameters to the engine.
+        * @since	2.0
+        * @param	aParameterId		array of parameter IDs
+		* @param	aParameterValue		array of parameter values
+        */
+		virtual void MSrLoadEngineParametersL( 
+						const RArray<TInt>& aParameterId, 
+						const RArray<TInt>& aParameterValue ) = 0;
+
+private:
+		TAny* iReservedPtr_1;	// reserved for future expansion
+		TAny* iReservedPtr_2;	// reserved for future expansion
+
+};
+
+#endif  // NSSSISPEECHRECOGNITIONCUSTOMCOMMANDIMPLEMENTOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommandparser.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,695 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the definition of the server side for the
+*               speaker independent controller.
+*
+*/
+
+
+#ifndef NSSSISPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H
+#define NSSSISPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H
+
+// INCLUDE FILES
+#include <mmfcontroller.h>
+#include <nsssispeechrecognitioncustomcommandimplementor.h>
+
+// FORWARD DECLARATIONS
+class CSDClientResultSet;
+
+// CLASS DECLARATION
+
+/**
+*  This is the main class of Speaker Independent Custom Commands Parser
+*
+*  @lib nsssispeechrecognitioncustomcommands.lib
+*  @since 2.8
+*/
+class CSISpeechRecognitionCustomCommandParser : public CMMFCustomCommandParserBase
+{
+
+public:
+	    /**
+        * 
+        *	Factory function for creating this class.
+        * @since 2.0
+        * @param 	aImplementor		reference to custom commands 
+		*								implementor
+        * @return	pointer to CSISpeechRecognitionCustomCommandParser object
+        */
+		IMPORT_C static CSISpeechRecognitionCustomCommandParser* NewL(
+							MSISpeechRecognitionCustomCommandImplementor& 
+							aImplementor);
+
+		/**
+        * 
+        *	Destructor
+        * @since 2.0
+        */
+		IMPORT_C  ~CSISpeechRecognitionCustomCommandParser();
+
+		/**
+        * 
+        *	Handles the request from the client
+        * @since 2.0
+        * @param 	aMessage			message containing the information of the
+		*								request.
+        */
+		void HandleRequest(TMMFMessage& aMessage);
+
+private:
+	    /**
+        * 
+        *	C++ constructor for CSISpeechRecognitionCustomCommandParser class.
+        * @since 2.0
+        * @param 	aImplementor		reference to custom commands 
+		*								implementor
+        */
+		CSISpeechRecognitionCustomCommandParser(
+			MSISpeechRecognitionCustomCommandImplementor& aImplementor);
+
+		/**
+        * 
+        *	Private method to handle the request from the client
+        * @since 2.0
+        * @param 	aMessage			message containing the information
+		*								of the request.
+        */
+		void  DoHandleRequestL(TMMFMessage& aMessage);
+
+		/**
+        * 
+		*	Adds a new pronunciation for the given model into the specified
+		*	lexicon.
+        * @since	2.0
+        * @param 	aMessage			message containing the information of 
+		*								the request.
+		*/
+		void DoAddPronunciationL(TMMFMessage& aMessage);
+
+		/**
+		*	Adds a new rule for the given pronunciation into the 
+		*	specified grammar.
+        * @since	2.0
+        * @param 	aMessage			message containing the information
+		*								of the request.
+		*/
+		void DoAddRuleL(TMMFMessage& aMessage);
+
+		/**
+        * 
+        *	Cancels the current operation
+        * @since 2.0
+        * @param 	-
+		*/
+		void DoCancel();
+
+        /**
+		*	Saves the current changes into a permanent storage.
+        * @since 2.0
+        * @param	-
+        */
+		void DoCommitChangesL();
+
+		/**
+        * 
+        *	Creates a new grammar.
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoCreateGrammarL(TMMFMessage& aMessage);
+
+		/**
+        * 
+        *	Creates a new lexicon.
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoCreateLexiconL(TMMFMessage& aMessage);
+
+        /**
+		*	Creates a new model bank.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCreateModelBankL(TMMFMessage& aMessage);
+
+		/**
+		*	Ends the current recognition session. Resources allocated for 
+		*	recognition are freed.
+        * @since	2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoEndRecSessionL();
+
+		/**
+        *	Returns all grammar Ids that belong to the current client, 
+		*	whose UID was set with SetClientUid().
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllClientGrammarIDsL();
+
+		/**
+ 		*	Returns all lexicon Ids that belong to the current client, 
+		*	whose UID was set with SetClientUid().
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllClientLexiconIDsL();
+
+		/**
+        *	Returns all model bank Ids that belong to the current client, 
+		*	whose UID was set with SetClientUid().
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllClientModelBankIDsL();
+
+		/**
+		*	Returns all grammar Ids that exist (for all clients).
+        * @since 2.0
+        */
+		void DoGetAllGrammarIDsL();
+
+		/**
+		*	Returns all lexicon Ids that exist (for all clients).
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllLexiconIDsL();
+
+		/**
+ 		*	Returns all model bank Ids that exist (for all clients).
+        * @since 2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllModelBankIDsL();
+
+		/**
+		*	Returns all model Ids that exist in the specified model bank.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoGetAllModelIDsL(TMMFMessage& aMessage);
+
+		/**
+		*	Returns all pronunciation Ids that exist in the specified lexicon.
+        * @since	2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllPronunciationIDsL(TMMFMessage& aMessage);
+
+		/**
+		*	Returns all rule Ids that exist in the specified grammar.
+        * @since	2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetAllRuleIDsL(TMMFMessage& aMessage);
+
+		/**
+		*	Returns the number of models available for training system wide, 
+		*	based on available disk space.
+        * @since	2.0
+        * @param 	aMessage				message containing the information of
+		*									the request.
+        */
+		void DoGetAvailableStorageL(TMMFMessage& aMessage);
+
+		/**
+        * 
+        *	Returns the engine properties.
+        * @since 2.0
+        * @param 	aMessage				message containing the information of
+		*									the request.
+        */
+		void DoGetEnginePropertiesL(TMMFMessage& aMessage);
+
+		/**
+		*	Returns the number of models in the specified model bank.
+        * @since	2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoGetModelCountL(TMMFMessage& aMessage);
+
+		/**
+		*	Checks if the rule is valid or not.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoGetRuleValidityL(TMMFMessage& aMessage);
+
+		/**
+        * 
+        *	Returns the duration of the utterance for the specified model.
+        * @since 2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoGetUtteranceDurationL(TMMFMessage& aMessage);
+
+		/**
+        * Loads a gramamr. Grammars must be loaded prior to recognition.
+        *
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoLoadGrammarL(TMMFMessage& aMessage);
+
+		/**
+		*	Activates a previously deactivated gramamr.
+        *
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoActivateGrammarL(TMMFMessage& aMessage);
+
+		/**
+        *   Deactivates a loaded gramamr, so that it is not recognized.
+        *
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoDeactivateGrammarL(TMMFMessage& aMessage);
+
+        /**
+        * 
+        *	Loads the specified lexicon into the recognizer; done prior to 
+		*	recognition.
+        * @since 2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoLoadLexiconL(TMMFMessage& aMessage);
+
+		/**
+        * 
+        *	Loads the specified model bank into the recognizer; done prior 
+		*	to recognition..
+        * @since 2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoLoadModelsL(TMMFMessage& aMessage);
+
+		/**
+		*	Plays the previously trained utterance.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoPlayUtteranceL(TMMFMessage& aMessage);
+
+		/**
+		*	Initiates recognition; performed following loading of model bank, 
+		*	lexicon, and grammar.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRecognizeL(TMMFMessage& aMessage);
+
+		/**
+		*	Records uder utterance for training and recognition.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRecordL(TMMFMessage& aMessage);
+
+		/**
+		*	Removes the specified grammar from the permanent storage.
+		*	Removing a grammar will remove all rules within the grammar.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRemoveGrammarL(TMMFMessage& aMessage);
+
+		/**
+		*	Removes the specified lexicon from the permanent storage.
+		*	Removing a lexicon will remove all pronunciations within 
+		*	the lexicon.
+        * @since	2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoRemoveLexiconL(TMMFMessage& aMessage);
+
+		/**
+		*	Removes the specified model bank from the permanent storage.
+		*	Removing a model bank will remove all models within the model
+		*	bank.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRemoveModelBankL(TMMFMessage& aMessage);
+
+		/**
+		*	Removes the specified model from the specified model bank 
+		*	permanently.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRemoveModelL(TMMFMessage& aMessage);
+
+		/**
+		*	Removes the specified pronunciation from the specified 
+		*	lexicon permanently.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRemovePronunciationL(TMMFMessage& aMessage);
+
+		/**
+		*	Removes the specified rule from the specified grammar permanently.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoRemoveRuleL(TMMFMessage& aMessage);
+		
+		/**
+		* Removes the specified rules from the specified grammar permanently
+		* @param 	aMessage				message containing the information
+		*									of the request.
+		*/
+		void DoRemoveRulesL( TMMFMessage& aMessage );	
+
+
+		/**
+        *	Sets the client's UID for data ownership identification.
+        * @since 2.0
+        * @param	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoSetClientUidL(TMMFMessage& aMessage);
+
+		/**
+		*	Starts a new recognition session.
+        * @since	2.0
+        * @param 	aMessage				message containing the information 
+		*									of the request.
+        */
+		void DoStartRecSessionL(TMMFMessage& aMessage);
+
+        /**
+		*	Trains a new model into the specified model bank.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoTrainL(TMMFMessage& aMessage);
+
+		/**
+		*	Unloads the specified rule from the specified grammar in temporary 
+		*	memory, previously loaded with LoadGrammarL.  The rule in the permanent 
+		*	storage remains intact.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoUnloadRuleL(TMMFMessage& aMessage);
+
+		/**
+		*	Loads the specified parameters into the engine.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoLoadEngineParametersL(TMMFMessage& aMessage);
+
+// ================================ SI Extensions ============================ //
+
+		/**
+		*	Adapts acoustic models to a user's voice.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoAdaptL(TMMFMessage& aMessage);
+
+		/**
+		*	Adds a speaker independent pronunciation.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoAddPronunciationSIL(TMMFMessage& aMessage);
+
+		/**
+		*	Adds a rule variant.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoAddRuleVariantL(TMMFMessage& aMessage);
+
+		/**
+		*	Adds a voice tag.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoAddVoiceTagL(TMMFMessage& aMessage);
+
+		/**
+		*	Adds several voice tags.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoAddVoiceTagsL(TMMFMessage& aMessage);
+
+		/**
+		*	Creates an empty rule.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoCreateRuleL(TMMFMessage& aMessage);
+
+		/**
+		*	Stops recording (recognizing).
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoEndRecordL(TMMFMessage& aMessage);
+
+		/**
+		*	Starts speaker independent recognition.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoRecognizeSIL(TMMFMessage& aMessage);
+
+		/**
+		*	Deactivates a grammar from the recognition vocabulary.
+        * @since	2.8
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+        void DoUnloadGrammarL(TMMFMessage& aMessage);
+
+        /**
+        * Adds one SINDE voice tag.
+        *
+        * @since 3.1
+        * @param aMessage Message containing the information of the request.
+        */
+        void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL( TMMFMessage& aMessage );
+
+        /**
+        * Adds an array of voice tags.
+        *
+        * @since 3.1
+        * @param aMessage Message containing the information of the request.
+        */
+        void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL( TMMFMessage& aMessage );
+
+        /**
+        * Pre-starts sampling
+        *
+        * @since 3.2
+        * @param aMessage Message containing the information of the request.
+        */
+        void DoPreStartSamplingL( TMMFMessage& aMessage );
+
+private:
+
+		/**
+		*	Copy the pronunciation ID array to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyPronunciationIDArrayL(TMMFMessage& aMessage);
+
+		/**
+		*	Copy the model ID array to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyModelIDArrayL(TMMFMessage& aMessage);
+
+		/**
+		*	Copy the rule ID array to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyRuleIDArrayL(TMMFMessage& aMessage);
+	
+		/**
+		*	Copy the grammar ID array to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyGrammarIDArrayL(TMMFMessage& aMessage);
+
+		/**
+		*	Copy the lexicon ID array to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyLexiconIDArrayL(TMMFMessage& aMessage);
+
+		/**
+		*	Copy the model bank ID array to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyModelBankIDArrayL(TMMFMessage& aMessage);
+
+		/**
+		*	Externalize the recognition result set.
+        * @since	2.0
+        */
+		void DoExternalizeResultSetL();
+
+		/**
+		*	Externalize the speaker independent recognition result set.
+        * @since	2.0
+        */
+        void DoExternalizeSIResultSetL();
+
+		/**
+		*	Copy the recognition result set to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+        */
+		void DoCopyResultSetL(TMMFMessage& aMessage);
+
+
+		/**
+		*	Extract an integer array from client data 1.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+		* @param	aArray					RArray to contain the data on exit.
+        */
+		void DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray<TInt>& aArray);
+	
+
+		/**
+		*	Extract an integer array from client data 2.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+		* @param	aArray					RArray to contain the data on exit.
+        */
+		void DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray<TInt>& aArray);
+
+		/**
+		*	Extract an integer array from a descriptor into an RArray.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+		* @param	aArray					RArray to contain the data on exit.
+        */
+		void DoExtractIntArrayL(TDes8& aDescriptor, RArray<TInt>& aArray);
+
+		/**
+		*	Copy data from an RArray to the client.
+        * @since	2.0
+        * @param 	aMessage				message containing the information
+		*									of the request.
+		* @param	aArray					RArray copied to the client.
+        */
+		void DoCopyIntArrayL(TMMFMessage& aMessage, const RArray<TInt>& aArray);
+
+		// reference to the Custom Command Implementor class
+		MSISpeechRecognitionCustomCommandImplementor& iImplementor; 
+
+		// Contains the array of pronunciation IDs
+		RArray<TSIPronunciationID> iPronunciationIDs;
+		// Contains the array of model IDs
+		RArray<TSIModelID> iModelIDs;
+		// Contains the array of rule IDs
+		RArray<TSIRuleID> iRuleIDs;
+		// Contains the array of grammar IDs
+		RArray<TSIGrammarID> iGrammarIDs;
+		// Contains the array of lexicon IDs
+		RArray<TSILexiconID> iLexiconIDs;
+		// Contains the array of model bank IDs
+		RArray<TSIModelBankID> iModelBankIDs;
+        // Contains the language array
+        RArray<TLanguage> iLanguageArray;
+        // Contains the array of language arrays
+        RArray<RLanguageArray> iLanguageArrayArray;
+		// Contains the client result set !!!! Obsolete
+		CSDClientResultSet* iResultSet;
+        // Contains the client result set for SI recognition
+        CSIClientResultSet* iSIResultSet;
+		// temporary copy buffer
+		CBufFlat* iResultCopyBuffer;
+        // Contains the word array of AddVoiceTag
+        MDesCArray* iWordArray;
+        // Contains the result set, which is used in adaptation.
+        CSIClientResultSet* iAdaptationSet;
+
+		TAny* iReservedPtr_1;	// reserved for future expansion
+		TAny* iReservedPtr_2;	// reserved for future expansion
+
+};
+
+#endif  // NSSSISPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommands.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,661 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the definition of the client interface for the
+*			    speaker independent extensions to speech recognition custom commands.
+*
+*/
+
+
+#ifndef NSS_SI_SPEECH_RECOGNITION_CUSTOM_COMMANDS_H
+#define NSS_SI_SPEECH_RECOGNITION_CUSTOM_COMMANDS_H
+
+//  INCLUDES
+#include	<mmfcontroller.h>
+#include 	<nsssispeechrecognitiondataclient.h>
+
+// FORWARD DECLARATIONS
+class CSDClientResultSet;
+
+/**
+*  This is the main class of NSS Speaker Independent Speech Recognition Custom Commands
+*
+*  @lib nsssispeechrecognitioncustomcommands.lib
+*  @since 2.8
+*/
+
+// CLASS DECLARATION
+class RSISpeechRecognitionCustomCommands : public RMMFCustomCommandsBase
+	{
+
+	public:
+		/**
+		*	Public C++ constructor for RSpeechRecognitionCustomCommands class.
+        *
+        * @since	2.8
+        * @param	aController			reference to RMMFController object
+        * @return	-
+		*/
+		IMPORT_C RSISpeechRecognitionCustomCommands(RMMFController& aController);
+
+		/**
+		*	Adapts speaker independent models according using a correct recognition result.
+        * 
+        * @since	2.8
+        * @param	aResultSet          The result N-Best containing feature vectors
+		*			aCorrect            The correct index
+        * @return	-
+		*/
+        IMPORT_C TInt Adapt(const CSIClientResultSet& aResultSet, TInt aCorrect);
+
+		/**
+		*	Adds a pronunciation to the given lexicon.
+        * 
+        * @since	2.8
+		* @param	aLexiconID			The lexicon Id
+        * @param    aTrainText          Text to be pronounced
+        * @param    aLanguage           Pronunciation language
+		* @param	aPronunciationID	Reference where a new pronunciation Id is assigned to.
+		*								
+        * @return	-
+		*/
+        IMPORT_C TInt AddPronunciation(TSILexiconID aLexiconID,
+                                       const TDesC& aTrainText,
+                                       TLanguage aLanguage,
+                                       TSIPronunciationID& aPronunciationID);
+
+		/**
+        *	Adds a rule variant to a grammar.
+        * 
+        * @since 2.8
+        * @param 	aGrammarID          Grammar identifier
+        * @param    aRuleID             Rule identifier; variant is added here.
+        * @param    aPronunciations     Sequence of pronunciations; these get concatenated.
+        *                               in the rule variant.
+        * @param    aRuleVariantID      Reference where the new variant
+        *                               identifier is assigned to.
+        * @return	-
+		*/
+		IMPORT_C TInt AddRuleVariant(
+            TSIGrammarID aGrammarID,
+            TSILexiconID aLexiconID,
+            const RArray<TSIPronunciationID>& aPronunciationIDs,
+            TSIRuleID aRuleID,
+            TSIRuleVariantID& aRuleVariantID );
+
+        /**
+		*	Trains a voice tag. Adds the text to the lexicon, and creates the required
+        *   rules and rule variants.
+        * 
+        * @since 2.8
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciaiton languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Reference, where the new rule identifier is assigned to.
+        * @return	-
+        */
+        IMPORT_C TInt AddVoiceTag(
+            const MDesCArray& aTrainArray,
+            const RArray<TLanguage>& aLanguageArray,
+            TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID,
+            TSIRuleID& aRuleID);
+
+        /**
+		*	Trains voice tags. If the training fails for some of the names (but not all),
+        *   it is signaled by setting the Rule ID to KInvalidRuleID.
+        * 
+        * @since 2.8
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciation languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Referenceto an array, where the new
+        *                               Rule identifiers are assigned to.
+        * @return	-
+        */
+        IMPORT_C TInt AddVoiceTags(
+            const RPointerArray<MDesCArray>& aTrainArray,
+            const RArray<TLanguage>& aLanguageArray,
+            TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID,
+            RArray<TSIRuleID>& aRuleID);
+
+        /**
+        *	Creates a new rule.
+        * 
+        * @since 2.8
+        * @param 	aGrammarID          Grammar identifier
+        * @param 	aRuleID             Reference where rule ID is stored
+        * @return	-
+        */
+        IMPORT_C TInt CreateRule(TSIGrammarID aGrammarID, TSIRuleID& aRuleID);
+
+		/**
+        *   Starts recognition
+        *
+        * @since 2.8
+        * @param 	aResultSet          Recognition result is placed here, when ready.
+        * @return	-
+        */
+		IMPORT_C TInt Recognize( CSIClientResultSet& aResultSet );
+
+        /**
+		*	Stops recognition. Unlike Cancel(), this function gives
+        *   the recognition result, if it can be guessed.
+        *
+        * @since	2.8
+        * @param	- 
+        * @return	-
+        */
+		IMPORT_C TInt EndRecord();
+
+		/**
+		*   Deactivates a grammar.
+		*
+        * @since	2.8
+        * @param	aGrammarID          Grammar identifier
+        * @return	-
+        */
+        IMPORT_C TInt UnloadGrammar( TSIGrammarID aGrammarID );
+
+/************************ SD Legacy functions *******************************/
+
+		/**
+		*	Adds a new rule for the given pronunciation into 
+		*	the specified grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id, where the new rule is 
+		*								added to
+		* @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+		* @param	aRuleID				reference where a new rule Id is 
+		*								assigned to
+        * @return	System-wide errors
+		*/
+		IMPORT_C TInt AddRule(TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+						TSIPronunciationID aPronunciationID, TSIRuleID& aRuleID);
+
+		/**
+        *
+        *	Cancels the current operation
+        * @since 2.0
+        * @param 	-
+        * @return	-
+		*/
+		IMPORT_C void Cancel();
+
+        /**
+		*	Saves the current changes into permanent storage.
+        * @since 2.0
+        * @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CommitChanges();
+
+		/**
+        *
+        *	Creates a new grammar.
+        * @since 2.0
+        * @param 	aGrammarID			reference where grammar ID is stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CreateGrammar(TSIGrammarID& aGrammarID);
+
+		/**
+        *
+        *	Creates a new lexicon.
+        * @since 2.0
+        * @param 	aLexiconID			reference where lexicon ID is stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CreateLexicon(TSILexiconID& aLexiconID);
+
+        /**
+		*	Creates a new model bank.
+        * @since	2.0
+        * @param	aModelBankID		reference where a new model 
+		*								bank Id is assigned to
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CreateModelBank(TSIModelBankID& aModelBankID);
+
+		/**
+		*	Ends the current recognition session.  Resources allocated for 
+		*	recognition are freed.
+        * @since	2.0
+        * @param	aModelBankID		reference where a new model bank Id 
+		*								is assigned to
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt EndRecSession();
+
+		/**
+        *	Returns all grammar Ids that belong to the current client.
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllClientGrammarIDs();
+
+		/**
+ 		*	Returns all lexicon Ids that belong to the current client.
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllClientLexiconIDs();
+
+		/**
+        * Returns all model bank Ids that belong to the current client.
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllClientModelBankIDs();
+
+		/**
+		*	Returns all grammar Ids that exist (for all clients).
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllGrammarIDs();
+
+		/**
+		*	Returns all lexicon Ids that exist (for all clients).
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllLexiconIDs();
+
+		/**
+ 		*	Returns all model bank Ids that exist (for all clients).
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllModelBankIDs();
+
+		/**
+		*	Returns all model Ids that exist in the specified model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllModelIDs(TSIModelBankID aModelBankID);
+						
+		/**
+		*	Returns all pronunciation Ids that exist in the specified lexicon.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+		* @param	aPronunciationIDs	reference where pronunciation Ids 
+		*								are stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllPronunciationIDs(TSILexiconID aLexiconID);
+					
+		/**
+		*	Returns all rule Ids that exist in the specified grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleIDs			reference where rule Ids are stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllRuleIDs(TSIGrammarID aGrammarID); 
+		
+		/**
+        * 
+        *	Returns the engine properties specified by the engine property 
+		*	ID array. On return aPropertyValue contains an array of engine 
+		*	properties.
+        * @since 2.0
+        * @param 	aPropertyId		constant reference to array of engine 
+		*							property Ids
+		* @param	aPropertyValue	reference to array of engine property 
+		*							values
+        * @return	system wide error code
+        */
+		IMPORT_C TInt GetEngineProperties(const RArray<TInt>& aPropertyId, 
+						RArray<TInt>& aPropertyValue);
+
+		/**
+		*	Returns the number of models in the specified model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aCount				reference where the number of models 
+		*								is set
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetModelCount(TSIModelBankID aModelBankID, 
+						TInt& aModelCount);
+
+		/**
+		*	Checks if the rule is valid or not.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+		* @param	aValid				reference where the validity of the 
+		*								rule is set
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetRuleValidity(TSIGrammarID aGrammarID, TSIRuleID aRuleID, 
+						TBool& aValid);
+
+		/**
+		*	Loads a grammar. Grammars are loaded between StartRecSession()
+        *   and Recognize()
+        *
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadGrammar( TSIGrammarID aGrammarID );
+
+		/**
+		*	Activates a loaded and deactivated grammar.
+        *
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt ActivateGrammar( TSIGrammarID aGrammarID );
+
+		/**
+        *   Deactivates a loaded grammar so that it is not recognized.
+        *
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt DeactivateGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        *
+        *	Loads the specified lexicon into the recognizer; 
+		*	done prior to recognition.
+        * @since 2.0
+        * @param 	aLexiconID			lexicon ID
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadLexicon(TSILexiconID aLexiconID);
+
+		/**
+        *
+        *	Loads the specified model bank into the recognizer; done prior 
+		*	to recognition..
+        * @since 2.0
+        * @param 	aModelBankID		model bank Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadModels(TSIModelBankID aModelBankID);
+
+		/**
+		*	Records uder utterance for training and recognition.
+        * @since	2.0
+        * @param	aRecordTime			recording time in microseconds
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt Record(TTimeIntervalMicroSeconds32 aRecordTime);
+
+		/**
+		*	Removes the specified grammar from the permanent storage.
+		*	Removing a grammar will remove all rules within the grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveGrammar(TSIGrammarID aGrammarID);
+
+		/**
+		*	Removes the specified lexicon from the permanent storage.
+		*	Removing a lexicon will remove all pronunciations within the 
+		*	lexicon.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+        * @return	-
+        */
+		IMPORT_C TInt RemoveLexicon(TSILexiconID aLexiconID);
+
+		/**
+		*	Removes the specified model bank from the permanent storage.
+		*	Removing a model bank will remove all models within the model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+        * @return	-
+        */
+		IMPORT_C TInt RemoveModelBank(TSIModelBankID aModelBankID);
+
+		/**
+		*	Removes the specified model from the specified model bank 
+		*	permanently.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveModel(TSIModelBankID aModelBankID, 
+									TSIModelID aModelID);
+
+		/**
+		*	Removes the specified pronunciation from the specified lexicon
+		*	permanently.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemovePronunciation(TSILexiconID aLexiconID, 
+									TSIPronunciationID aPronunciationID);
+
+		/**
+		*	Removes the specified rule from the specified grammar permanently.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveRule(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+
+		/**
+		*	Removes the specified rule from the specified grammar permanently.
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleIDs			array of rule ids
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveRules(TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs);
+
+		/**
+        *	Sets the client's UID for data ownership identification.
+        * @since 2.0
+        * @param	aClientUid			client's UID
+        * @return	-
+        */
+		IMPORT_C TInt SetClientUid( TUid aClientUid );
+
+		/**
+		*	Starts a new recognition session.
+        * @since	2.0
+        * @param	aMode				recognition mode
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt StartRecSession(TNSSRecognitionMode aMode);
+
+		/**
+		*	Unloads the specified rule from the specified grammar in temporary 
+		*	memory, previously loaded with LoadGrammarL. The rule in the 
+		*	permanent storage remains intact.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt UnloadRule(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+
+		/**
+		*	Uploads the specified parameters into the engine.
+        * @since	2.0
+        * @param	aParameterId		array of parameter IDs
+		* @param	aParameterValue		array of parameter values
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadEngineParameters(const RArray<TInt>& aParameterId, 
+									const RArray<TInt>& aParameterValue);
+
+		/**
+		*	Get the pronunciation ID array. On return aPronunciationIDs contains
+		*	an array of pronunciation IDs.
+        * @since	2.0
+        * @param	aPronunciationIDs		array of pronunciation IDs
+		* @return	-
+        */
+		IMPORT_C void GetPronunciationIDArrayL(RArray<TSIPronunciationID>& aPronunciationIDs);
+
+		/**
+		*	Get the rule ID array. On return aRuleIDs contains
+		*	an array of rule IDs.
+        * @since	2.0
+        * @param	aRuleIDs				array of rule IDs
+		* @return	-
+        */
+		IMPORT_C void GetRuleIDArrayL(RArray<TSIRuleID>& aRuleIDs);
+
+		/**
+		*	Get the model ID array. On return aModelIDs contains
+		*	an array of model IDs.
+        * @since	2.0
+        * @param	aModelIDs				array of model IDs
+		* @return	-
+        */
+		IMPORT_C void GetModelIDArrayL(RArray<TSIModelID>& aModelIDs);
+	
+		/**
+		*	Get the grammar ID array. On return aGrammarIDs contains
+		*	an array of rule IDs.
+        * @since	2.0
+        * @param	aGrammar				array of grammar IDs
+		* @return	-
+        */
+		IMPORT_C void GetGrammarIDArrayL(RArray<TSIGrammarID>& aGrammarIDs);
+
+		/**
+		*	Get the lexicon ID array. On return aLexiconIDs contains
+		*	an array of lexicon IDs.
+        * @since	2.0
+        * @param	aLexicon				array of lexicon IDs
+		* @return	-
+        */
+		IMPORT_C void GetLexiconIDArrayL(RArray<TSILexiconID>& aLexiconIDs);
+
+		/**
+		*	Get the model bank ID array. On return aModelBankIDs contains
+		*	an array of model bank IDs.
+        * @since	2.0
+        * @param	aModelBank				array of model bank IDs
+		* @return	-
+        */
+		IMPORT_C void GetModelBankIDArrayL(RArray<TSIModelBankID>& aModelBankIDs);
+
+		/**
+		*	Get the client result set. This function should be called after recognition.
+		*	On return aResultSet contains client result set.
+        * @since	2.8
+        * @param	aResultSet Result set to be populated.
+		* @return	-
+        */
+		IMPORT_C void GetSIResultSetL(CSIClientResultSet& aResultSet);
+
+
+private:
+		/**
+        * 
+        *	Returns the engine properties specified by the engine property 
+		*	ID array. On return aPropertyValue contains an array of engine 
+		*	properties. This function does the actual work.
+        * @since 2.0
+        * @param 	aPropertyId		constant reference to array of engine 
+		*							property Ids
+		* @param	aPropertyValue	reference to array of engine property 
+		*							values
+        * @return	-
+        */
+		void DoGetEnginePropertiesL(const RArray<TInt>& aPropertyId, 
+						RArray<TInt>& aPropertyValue);
+
+		/**
+		*	Uploads the specified parameters into the engine. This function does
+		*	the actual work.
+        * @since	2.0
+        * @param	aParameterId		array of parameter IDs
+		* @param	aParameterValue		array of parameter values
+        * @return	-
+        */
+		void DoLoadEngineParametersL(const RArray<TInt>& aParameterId, 
+									const RArray<TInt>& aParameterValue);
+
+		/**
+		*	Externalize an integer array.
+        * @since	2.0
+        * @param	aArray				array to externalize
+        * @return	Pointer to externalized array.
+        */
+		CBufFlat* ExternalizeIntArrayL(const RArray<TInt>& aArray);
+
+		/**
+		*	Internalize an integer array.
+        * @since	2.0
+        * @param	aDes				descriptor containing the data to internalize
+		* @param	aNumberElements		number of elements to internalize
+		* @param	aArray				contains the internalized array on exit
+        * @return	-
+        */
+		void InternalizeIntArrayL(TDes8& aDes, TInt aNumberElements, RArray<TInt>& aArray);
+
+private:
+		/**
+		*	Initiates recognition; performed following loading of model bank,
+		*	lexicon, and grammar. This function does the actual work and is trapped
+		*	by the public Recognize() function.
+        * @since	2.0
+        * @param	aResultSet			reference where the recognition result 
+		*								is set
+        * @return	-
+        */
+		void DoRecognizeL(CSDClientResultSet& aResultSet);
+
+		/**
+		*	Initiates speaker independent recognition; performed following
+        *   loading of model bank, lexicon, and grammar. This function does
+        *   the actual work and is trapped by the public Recognize() function.
+        * @since	2.8
+        * @param	aResultSet			reference where the recognition result 
+		*								is set
+        * @return	-
+        */
+		void DoRecognizeSIL(CSIClientResultSet& aResultSet);
+
+/****************************************************************************/
+private:
+
+		TAny* iReservedPtr_1;	// reserved for future expansion
+		TAny* iReservedPtr_2;	// reserved for future expansion
+
+
+};
+
+#endif  // NSS_SI_SPEECH_RECOGNITION_CUSTOM_COMMANDS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_custom_commands_api/inc/nsssispeechrecognitioncustomcommands_sinde.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,707 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the definition of the client interface for the
+*			    speaker independent extensions to speech recognition custom commands.
+*
+*/
+
+
+#ifndef NSS_SI_SPEECH_RECOGNITION_CUSTOM_COMMANDS_H
+#define NSS_SI_SPEECH_RECOGNITION_CUSTOM_COMMANDS_H
+
+//  INCLUDES
+#include <mmfcontroller.h>
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitiondatacommon.h>
+
+// FORWARD DECLARATIONS
+class CSDClientResultSet;
+
+/**
+*  This is the main class of NSS Speaker Independent Speech Recognition Custom Commands
+*
+*  @lib nsssispeechrecognitioncustomcommands.lib
+*  @since 2.8
+*/
+
+// CLASS DECLARATION
+class RSISpeechRecognitionCustomCommands : public RMMFCustomCommandsBase
+	{
+
+	public:
+		/**
+		*	Public C++ constructor for RSpeechRecognitionCustomCommands class.
+        *
+        * @since	2.8
+        * @param	aController			reference to RMMFController object
+        * @return	-
+		*/
+		IMPORT_C RSISpeechRecognitionCustomCommands(RMMFController& aController);
+
+		/**
+		*	Adapts speaker independent models according using a correct recognition result.
+        * 
+        * @since	2.8
+        * @param	aResultSet          The result N-Best containing feature vectors
+		*			aCorrect            The correct index
+        * @return	-
+		*/
+        IMPORT_C TInt Adapt(const CSIClientResultSet& aResultSet, TInt aCorrect);
+
+		/**
+		*	Adds a pronunciation to the given lexicon.
+        * 
+        * @since	2.8
+		* @param	aLexiconID			The lexicon Id
+        * @param    aTrainText          Text to be pronounced
+        * @param    aLanguage           Pronunciation language
+		* @param	aPronunciationID	Reference where a new pronunciation Id is assigned to.
+		*								
+        * @return	-
+		*/
+        IMPORT_C TInt AddPronunciation(TSILexiconID aLexiconID,
+                                       const TDesC& aTrainText,
+                                       TLanguage aLanguage,
+                                       TSIPronunciationID& aPronunciationID);
+
+		/**
+        *	Adds a rule variant to a grammar.
+        * 
+        * @since 2.8
+        * @param 	aGrammarID          Grammar identifier
+        * @param    aRuleID             Rule identifier; variant is added here.
+        * @param    aPronunciations     Sequence of pronunciations; these get concatenated.
+        *                               in the rule variant.
+        * @param    aRuleVariantID      Reference where the new variant
+        *                               identifier is assigned to.
+        * @return	-
+		*/
+		IMPORT_C TInt AddRuleVariant(
+            TSIGrammarID aGrammarID,
+            TSILexiconID aLexiconID,
+            const RArray<TSIPronunciationID>& aPronunciationIDs,
+            TSIRuleID aRuleID,
+            TSIRuleVariantID& aRuleVariantID );
+
+        /**
+		*	Trains a voice tag. Adds the text to the lexicon, and creates the required
+        *   rules and rule variants.
+        * 
+        * @since 2.8
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciaiton languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Reference, where the new rule identifier is assigned to.
+        * @return	System wide error code
+        */
+        IMPORT_C TInt AddVoiceTag(
+            const MDesCArray& aTrainArray,
+            const RArray<TLanguage>& aLanguageArray,
+            TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID,
+            TSIRuleID& aRuleID);
+
+        /**
+		*	Trains voice tags. If the training fails for some of the names (but not all),
+        *   it is signaled by setting the Rule ID to KInvalidRuleID.
+        * 
+        * @since 2.8
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciation languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Referenceto an array, where the new
+        *                               Rule identifiers are assigned to.
+        * @return	System wide error code
+        */
+        IMPORT_C TInt AddVoiceTags(
+            const RPointerArray<MDesCArray>& aTrainArray,
+            const RArray<TLanguage>& aLanguageArray,
+            TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID,
+            RArray<TSIRuleID>& aRuleID);
+
+        /**
+		*	Trains a voice tag. Adds the text to the lexicon, and creates the required
+        *   rules and rule variants.
+        * 
+        * @since 3.1
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciaiton languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Reference, where the new rule identifier is assigned to.
+        * @return	System wide error code
+        */
+        IMPORT_C TInt AddVoiceTag( const MDesCArray& aTrainArray,
+                                   const RArray<RLanguageArray>& aLanguageArray,
+                                   TSILexiconID aLexiconID,
+                                   TSIGrammarID aGrammarID,
+                                   TSIRuleID& aRuleID );
+
+        /**
+		*	Trains voice tags. If the training fails for some of the names (but not all),
+        *   it is signaled by setting the Rule ID to KInvalidRuleID.
+        * 
+        * @since 3.1
+        * @param	aTrainArray         The phrase to be trained, split into subwords
+        * @param	aLanguageArray      The pronunciation languages
+        * @param	aLexiconID          Lexicon identifier
+        * @param	aGrammarID          Grammar identifier
+        * @param	aRuleID             Referenceto an array, where the new
+        *                               Rule identifiers are assigned to.
+        * @return	System wide error code
+        */
+        IMPORT_C TInt AddVoiceTags( const RPointerArray<MDesCArray>& aTrainArray,
+                                    const RArray<RLanguageArray>& aLanguageArray,
+                                    TSILexiconID aLexiconID,
+                                    TSIGrammarID aGrammarID,
+                                    RArray<TSIRuleID>& aRuleID );
+
+        /**
+        *	Creates a new rule.
+        * 
+        * @since 2.8
+        * @param 	aGrammarID          Grammar identifier
+        * @param 	aRuleID             Reference where rule ID is stored
+        * @return	-
+        */
+        IMPORT_C TInt CreateRule(TSIGrammarID aGrammarID, TSIRuleID& aRuleID);
+
+		/**
+        *   Starts recognition
+        *
+        * @since 2.8
+        * @param 	aResultSet          Recognition result is placed here, when ready.
+        * @return	-
+        */
+		IMPORT_C TInt Recognize( CSIClientResultSet& aResultSet );
+
+        /**
+		*	Stops recognition. Unlike Cancel(), this function gives
+        *   the recognition result, if it can be guessed.
+        *
+        * @since	2.8
+        * @param	- 
+        * @return	-
+        */
+		IMPORT_C TInt EndRecord();
+
+		/**
+		*   Deactivates a grammar.
+		*
+        * @since	2.8
+        * @param	aGrammarID          Grammar identifier
+        * @return	-
+        */
+        IMPORT_C TInt UnloadGrammar( TSIGrammarID aGrammarID );
+
+/************************ SD Legacy functions *******************************/
+
+		/**
+		*	Adds a new rule for the given pronunciation into 
+		*	the specified grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id, where the new rule is 
+		*								added to
+		* @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+		* @param	aRuleID				reference where a new rule Id is 
+		*								assigned to
+        * @return	System-wide errors
+		*/
+		IMPORT_C TInt AddRule(TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+						TSIPronunciationID aPronunciationID, TSIRuleID& aRuleID);
+
+		/**
+        *
+        *	Cancels the current operation
+        * @since 2.0
+        * @param 	-
+        * @return	-
+		*/
+		IMPORT_C void Cancel();
+
+        /**
+		*	Saves the current changes into permanent storage.
+        * @since 2.0
+        * @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CommitChanges();
+
+		/**
+        *
+        *	Creates a new grammar.
+        * @since 2.0
+        * @param 	aGrammarID			reference where grammar ID is stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CreateGrammar(TSIGrammarID& aGrammarID);
+
+		/**
+        *
+        *	Creates a new lexicon.
+        * @since 2.0
+        * @param 	aLexiconID			reference where lexicon ID is stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CreateLexicon(TSILexiconID& aLexiconID);
+
+        /**
+		*	Creates a new model bank.
+        * @since	2.0
+        * @param	aModelBankID		reference where a new model 
+		*								bank Id is assigned to
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt CreateModelBank(TSIModelBankID& aModelBankID);
+
+		/**
+		*	Ends the current recognition session.  Resources allocated for 
+		*	recognition are freed.
+        * @since	2.0
+        * @param	aModelBankID		reference where a new model bank Id 
+		*								is assigned to
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt EndRecSession();
+
+		/**
+        *	Returns all grammar Ids that belong to the current client.
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllClientGrammarIDs();
+
+		/**
+ 		*	Returns all lexicon Ids that belong to the current client.
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllClientLexiconIDs();
+
+		/**
+        * Returns all model bank Ids that belong to the current client.
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllClientModelBankIDs();
+
+		/**
+		*	Returns all grammar Ids that exist (for all clients).
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllGrammarIDs();
+
+		/**
+		*	Returns all lexicon Ids that exist (for all clients).
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllLexiconIDs();
+
+		/**
+ 		*	Returns all model bank Ids that exist (for all clients).
+        * @since 2.0
+		* @param	-
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllModelBankIDs();
+
+		/**
+		*	Returns all model Ids that exist in the specified model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllModelIDs(TSIModelBankID aModelBankID);
+						
+		/**
+		*	Returns all pronunciation Ids that exist in the specified lexicon.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+		* @param	aPronunciationIDs	reference where pronunciation Ids 
+		*								are stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllPronunciationIDs(TSILexiconID aLexiconID);
+					
+		/**
+		*	Returns all rule Ids that exist in the specified grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleIDs			reference where rule Ids are stored
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetAllRuleIDs(TSIGrammarID aGrammarID); 
+		
+		/**
+        * 
+        *	Returns the engine properties specified by the engine property 
+		*	ID array. On return aPropertyValue contains an array of engine 
+		*	properties.
+        * @since 2.0
+        * @param 	aPropertyId		constant reference to array of engine 
+		*							property Ids
+		* @param	aPropertyValue	reference to array of engine property 
+		*							values
+        * @return	system wide error code
+        */
+		IMPORT_C TInt GetEngineProperties(const RArray<TInt>& aPropertyId, 
+						RArray<TInt>& aPropertyValue);
+
+		/**
+		*	Returns the number of models in the specified model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aCount				reference where the number of models 
+		*								is set
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetModelCount(TSIModelBankID aModelBankID, 
+						TInt& aModelCount);
+
+		/**
+		*	Checks if the rule is valid or not.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+		* @param	aValid				reference where the validity of the 
+		*								rule is set
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt GetRuleValidity(TSIGrammarID aGrammarID, TSIRuleID aRuleID, 
+						TBool& aValid);
+
+		/**
+		*	Loads a grammar. Grammars are loaded between StartRecSession()
+        *   and Recognize()
+        *
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadGrammar( TSIGrammarID aGrammarID );
+
+		/**
+		*	Activates a loaded and deactivated grammar.
+        *
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt ActivateGrammar( TSIGrammarID aGrammarID );
+
+		/**
+        *   Deactivates a loaded grammar so that it is not recognized.
+        *
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt DeactivateGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        *
+        *	Loads the specified lexicon into the recognizer; 
+		*	done prior to recognition.
+        * @since 2.0
+        * @param 	aLexiconID			lexicon ID
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadLexicon(TSILexiconID aLexiconID);
+
+		/**
+        *
+        *	Loads the specified model bank into the recognizer; done prior 
+		*	to recognition..
+        * @since 2.0
+        * @param 	aModelBankID		model bank Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadModels(TSIModelBankID aModelBankID);
+
+		/**
+		*	Records uder utterance for training and recognition.
+        * @since	2.0
+        * @param	aRecordTime			recording time in microseconds
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt Record(TTimeIntervalMicroSeconds32 aRecordTime);
+
+        /**
+        * Pre-starts recording before Record() call.
+        *
+        * @since 3.2
+        * @return System-wide error
+        */
+        IMPORT_C TInt PreStartSampling();
+    
+		/**
+		*	Removes the specified grammar from the permanent storage.
+		*	Removing a grammar will remove all rules within the grammar.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveGrammar(TSIGrammarID aGrammarID);
+
+		/**
+		*	Removes the specified lexicon from the permanent storage.
+		*	Removing a lexicon will remove all pronunciations within the 
+		*	lexicon.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+        * @return	-
+        */
+		IMPORT_C TInt RemoveLexicon(TSILexiconID aLexiconID);
+
+		/**
+		*	Removes the specified model bank from the permanent storage.
+		*	Removing a model bank will remove all models within the model bank.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+        * @return	-
+        */
+		IMPORT_C TInt RemoveModelBank(TSIModelBankID aModelBankID);
+
+		/**
+		*	Removes the specified model from the specified model bank 
+		*	permanently.
+        * @since	2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveModel(TSIModelBankID aModelBankID, 
+									TSIModelID aModelID);
+
+		/**
+		*	Removes the specified pronunciation from the specified lexicon
+		*	permanently.
+        * @since	2.0
+        * @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemovePronunciation(TSILexiconID aLexiconID, 
+									TSIPronunciationID aPronunciationID);
+
+		/**
+		*	Removes the specified rule from the specified grammar permanently.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveRule(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+
+		/**
+		*	Removes the specified rule from the specified grammar permanently.
+        * @since	2.8
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleIDs			array of rule ids
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt RemoveRules(TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs);
+
+		/**
+        *	Sets the client's UID for data ownership identification.
+        * @since 2.0
+        * @param	aClientUid			client's UID
+        * @return	-
+        */
+		IMPORT_C TInt SetClientUid( TUid aClientUid );
+
+		/**
+		*	Starts a new recognition session.
+        * @since	2.0
+        * @param	aMode				recognition mode
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt StartRecSession(TNSSRecognitionMode aMode);
+
+		/**
+		*	Unloads the specified rule from the specified grammar in temporary 
+		*	memory, previously loaded with LoadGrammarL. The rule in the 
+		*	permanent storage remains intact.
+        * @since	2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt UnloadRule(TSIGrammarID aGrammarID, TSIRuleID aRuleID);
+
+		/**
+		*	Uploads the specified parameters into the engine.
+        * @since	2.0
+        * @param	aParameterId		array of parameter IDs
+		* @param	aParameterValue		array of parameter values
+        * @return	System-wide errors
+        */
+		IMPORT_C TInt LoadEngineParameters(const RArray<TInt>& aParameterId, 
+									const RArray<TInt>& aParameterValue);
+
+		/**
+		*	Get the pronunciation ID array. On return aPronunciationIDs contains
+		*	an array of pronunciation IDs.
+        * @since	2.0
+        * @param	aPronunciationIDs		array of pronunciation IDs
+		* @return	-
+        */
+		IMPORT_C void GetPronunciationIDArrayL(RArray<TSIPronunciationID>& aPronunciationIDs);
+
+		/**
+		*	Get the rule ID array. On return aRuleIDs contains
+		*	an array of rule IDs.
+        * @since	2.0
+        * @param	aRuleIDs				array of rule IDs
+		* @return	-
+        */
+		IMPORT_C void GetRuleIDArrayL(RArray<TSIRuleID>& aRuleIDs);
+
+		/**
+		*	Get the model ID array. On return aModelIDs contains
+		*	an array of model IDs.
+        * @since	2.0
+        * @param	aModelIDs				array of model IDs
+		* @return	-
+        */
+		IMPORT_C void GetModelIDArrayL(RArray<TSIModelID>& aModelIDs);
+	
+		/**
+		*	Get the grammar ID array. On return aGrammarIDs contains
+		*	an array of rule IDs.
+        * @since	2.0
+        * @param	aGrammar				array of grammar IDs
+		* @return	-
+        */
+		IMPORT_C void GetGrammarIDArrayL(RArray<TSIGrammarID>& aGrammarIDs);
+
+		/**
+		*	Get the lexicon ID array. On return aLexiconIDs contains
+		*	an array of lexicon IDs.
+        * @since	2.0
+        * @param	aLexicon				array of lexicon IDs
+		* @return	-
+        */
+		IMPORT_C void GetLexiconIDArrayL(RArray<TSILexiconID>& aLexiconIDs);
+
+		/**
+		*	Get the model bank ID array. On return aModelBankIDs contains
+		*	an array of model bank IDs.
+        * @since	2.0
+        * @param	aModelBank				array of model bank IDs
+		* @return	-
+        */
+		IMPORT_C void GetModelBankIDArrayL(RArray<TSIModelBankID>& aModelBankIDs);
+
+		/**
+		*	Get the client result set. This function should be called after recognition.
+		*	On return aResultSet contains client result set.
+        * @since	2.8
+        * @param	aResultSet Result set to be populated.
+		* @return	-
+        */
+		IMPORT_C void GetSIResultSetL(CSIClientResultSet& aResultSet);
+
+
+private:
+		/**
+        * 
+        *	Returns the engine properties specified by the engine property 
+		*	ID array. On return aPropertyValue contains an array of engine 
+		*	properties. This function does the actual work.
+        * @since 2.0
+        * @param 	aPropertyId		constant reference to array of engine 
+		*							property Ids
+		* @param	aPropertyValue	reference to array of engine property 
+		*							values
+        * @return	-
+        */
+		void DoGetEnginePropertiesL(const RArray<TInt>& aPropertyId, 
+						RArray<TInt>& aPropertyValue);
+
+		/**
+		*	Uploads the specified parameters into the engine. This function does
+		*	the actual work.
+        * @since	2.0
+        * @param	aParameterId		array of parameter IDs
+		* @param	aParameterValue		array of parameter values
+        * @return	-
+        */
+		void DoLoadEngineParametersL(const RArray<TInt>& aParameterId, 
+									const RArray<TInt>& aParameterValue);
+
+		/**
+		*	Externalize an integer array.
+        * @since	2.0
+        * @param	aArray				array to externalize
+        * @return	Pointer to externalized array.
+        */
+		CBufFlat* ExternalizeIntArrayL(const RArray<TInt>& aArray);
+
+		/**
+		*	Internalize an integer array.
+        * @since	2.0
+        * @param	aDes				descriptor containing the data to internalize
+		* @param	aNumberElements		number of elements to internalize
+		* @param	aArray				contains the internalized array on exit
+        * @return	-
+        */
+		void InternalizeIntArrayL(TDes8& aDes, TInt aNumberElements, RArray<TInt>& aArray);
+
+private:
+		/**
+		*	Initiates recognition; performed following loading of model bank,
+		*	lexicon, and grammar. This function does the actual work and is trapped
+		*	by the public Recognize() function.
+        * @since	2.0
+        * @param	aResultSet			reference where the recognition result 
+		*								is set
+        * @return	-
+        */
+		void DoRecognizeL(CSDClientResultSet& aResultSet);
+
+		/**
+		*	Initiates speaker independent recognition; performed following
+        *   loading of model bank, lexicon, and grammar. This function does
+        *   the actual work and is trapped by the public Recognize() function.
+        * @since	2.8
+        * @param	aResultSet			reference where the recognition result 
+		*								is set
+        * @return	-
+        */
+		void DoRecognizeSIL(CSIClientResultSet& aResultSet);
+
+/****************************************************************************/
+private:
+
+		TAny* iReservedPtr_1;	// reserved for future expansion
+		TAny* iReservedPtr_2;	// reserved for future expansion
+
+
+};
+
+#endif  // NSS_SI_SPEECH_RECOGNITION_CUSTOM_COMMANDS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_custom_commands_api/nss_srs_custom_commands_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="454de192a2deb50cc0d393383b5ba42b" dataversion="2.0">
+  <name>NSS SRS Custom Commands API</name>
+  <description>MMF extension for speaker dependent and independent speech recognition</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssspeechrecognitioncustomcommands.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_utility_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS SRS Utility API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nsssispeechrecognitionutility.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitionutility.h)
+../inc/nsssiutilitybase.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssiutilitybase.h)
+../inc/nsssispeechrecognitionutilityobserver.h     APP_LAYER_PLATFORM_EXPORT_PATH(nsssispeechrecognitionutilityobserver.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_utility_api/inc/nsssispeechrecognitionutility.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,819 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the definition of the speech recognition utility.
+*
+*/
+
+
+#ifndef NSSSISPEECHRECOGNITIONUTILITY_H
+#define NSSSISPEECHRECOGNITIONUTILITY_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <mmfcontroller.h>
+#include <nsssispeechrecognitioncustomcommands.h>
+#include <nsssispeechrecognitionutilityobserver.h>
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitiondatacommon.h>
+#include <nsssiutilitybase.h>
+
+// FORWARD DECLARATIONS
+class CSDClientResultSet;
+
+// CLASS DECLARATION
+
+/**
+*  This is the main class of Speech Recognition Utility 
+*
+*  @lib nsssispeechrecognitionutility.lib
+*  @since 2.0
+*/
+
+class CSISpeechRecognitionUtility : public CBase,
+                                    public MSISpeechRecognitionUtilityBase, 
+                                    public MMMFControllerEventMonitorObserver
+{
+
+public:
+
+        /*
+        * Creates instance of CSISpeechRecognitionUtility
+        * Needed when dynamically loading nsssispeechrecognitionutility.dll
+        * Direct users of CSISpeechRecognitionUtility should not use this.
+        * Returns M-class pointer to MSISpeechRecognitionUtilityBase as TAny*
+        *
+        * @return Created instance
+        */        
+        IMPORT_C static TAny* CreateInstanceL();
+
+        /**
+        * Second phase of construction after CreateInstanceL call.
+        * Needed when dynamically loading nsssispeechrecognitionutility.dll
+        * Direct users of CSISpeechRecognitionUtility should not use this.
+        *
+        * @since 3.1
+        * @param aClientUid Client UID for data ownership, other clients won't
+        *                   be able to modify the data registered to certain client
+        * @param aPluginUid UID of the plugin which will be used, KNullUid to 
+        *                    search for suitable plugin
+        * @param aObserver Callback observer reference
+        */
+        IMPORT_C void CreateInstanceSecondPhaseL( TUid aClientUid, 
+                                                  TUid aPluginUid, 
+                                                  MSISpeechRecognitionUtilityObserver& aObserver );
+
+        /**
+        * Factory function for creating this class.
+        *
+        * @since 2.0
+        * @param    aSpeechRecognitionUtilityObserver    reference to event 
+        *                                                observer class
+        * @param    aClientUid                           client UID for data 
+        *                                                ownership
+        * @return   pointer to CSISpeechRecognitionUtility object
+        */
+        IMPORT_C static CSISpeechRecognitionUtility* NewL( 
+                            MSISpeechRecognitionUtilityObserver& 
+                            aSpeechRecognitionUtilityObserver, TUid aClientUid );
+
+        /**
+        * Factory function for creating this class.
+        * Searches for a plugin, which supports the given
+        * recognition mode. If no such plugin is found, leaves.
+        *
+        * @since 2.8
+        * @param     aSpeechRecognitionUtilityObserver    reference to the event observer class
+        * @param    aClientUid                            client UID for data ownership
+        * @param    aPreferredMode                      Recognition technology (speaker
+        *                                               independent or dependent)
+        * @return    pointer to CSISpeechRecognitionUtility object
+        */
+        IMPORT_C static CSISpeechRecognitionUtility* NewL( 
+                            MSISpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver,
+                            TUid aClientUid,
+                            TNSSRecognitionMode aPreferredMode );
+
+        /**
+        * Factory function for creating this class.
+        * Loads the plugin with the given ID.
+        *
+        * @since 2.8
+        * @param     aSpeechRecognitionUtilityObserver    reference to the event observer class
+        * @param     aClientUid                           client UID for data ownership
+        * @param     aMmfPluginUid                        UID of the speech recognition plugin
+        * @return    pointer to CSISpeechRecognitionUtility object
+        */
+        IMPORT_C static CSISpeechRecognitionUtility* NewL( 
+                            MSISpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver,
+                            TUid aClientUid,
+                            TUid aMmfPluginUid );
+
+        /**
+        * Factory function for creating this class. Leaves a pointer 
+        * on the cleanup 
+        *
+        * @since 2.0
+        * @param    aSpeechRecognitionUtilityObserver     reference to event
+        *                                                 observer class
+        * @param    aClientUid                            client UID for data 
+        *                                                 ownership
+        * @return    pointer to CSISpeechRecognitionUtility object
+        */
+        IMPORT_C static CSISpeechRecognitionUtility* NewLC( 
+                            MSISpeechRecognitionUtilityObserver& 
+                            aSpeechRecognitionUtilityObserver, TUid aClientUid );
+
+        /**
+        * Destructor
+        *
+        * @since 2.0
+        */
+        IMPORT_C ~CSISpeechRecognitionUtility();
+
+        /**
+        * Returns the engine properties specified by the engine property 
+        * ID array. On return aPropertyValue contains an array of engine 
+        * properties.
+        *
+        * @since 2.0
+        * @param    aPropertyId      constant reference to array of engine 
+        *                            property Ids
+        * @param    aPropertyValue   reference to array of engine property 
+        *                            values
+        * @return   system wide error code
+        */
+        IMPORT_C TInt GetEngineProperties( const RArray<TInt>& aPropertyId, 
+                        RArray<TInt>& aPropertyValue );
+
+        /**
+        * Adapts the speaker independent models to a specific speaker's voice.
+        *
+        * @since  2.8
+        * @param  aResultSet     Recognition result N-Best
+        * @param  aCorrect       Index to N-Best pointing the correct result.
+        * @return system wide error code
+        */
+        IMPORT_C TInt Adapt( const CSIClientResultSet& aResultSet,
+                             TInt aCorrect );
+
+        /**
+        * Adds a new pronunciation for the given text phrase into the 
+        * specified lexicon.
+        *
+        * @since    2.8
+        * @param    aLexiconID          lexicon Id, where the new 
+        *                               pronunciation is added to
+        *           aTextForTraining    Text to be trained
+        *           aLanguage           Pronunciation language
+        *           aPronunciationID    reference where a new pronunciation 
+        *                               Id is assigned to
+        * @return   system wide error code
+        */
+        IMPORT_C TInt AddPronunciation( TSILexiconID aLexiconID,
+                        const TDesC& aTextForTraining,
+                        TLanguage aLanguage,
+                        TSIPronunciationID& aPronunciationID);
+
+        /**
+        * Adds a new rule for the given pronunciation into the 
+        * specified grammar.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id, where the new rule is 
+        *                                added to
+        * @param    aLexiconID            lexicon Id
+        * @param    aPronunciationID    pronunciation Id
+        * @param    aRuleID                reference where a new rule Id is 
+        *                                assigned to
+        * @return    system wide error code
+        */
+        IMPORT_C TInt AddRule( TSIGrammarID aGrammarID,
+                        TSILexiconID aLexiconID,
+                        TSIPronunciationID aPronunciationID,
+                        TSIRuleID& aRuleID );
+
+        /**
+        * Adds a new rule variant for the given pronunciation into the 
+        * specified grammar.
+        *
+        * @since    2.8
+        * @param    aGrammarID            grammar Id, where the new rule is 
+        *                                added to
+        * @param    aRuleID                the rule Id, which will contain this variant
+        * @param    aPronunciationIDs    the phrase is the concatenation
+        *                               of these pronunciation IDs
+        * @param    aRuleVariantID        reference where a new rule variant
+        *                               Id is assigned to
+        * @return    system wide error code
+        */
+        IMPORT_C TInt AddRuleVariant( TSIGrammarID aGrammarID,
+                        TSILexiconID aLexiconID,
+                        RArray<TSIPronunciationID>& aPronunciationIDs,
+                        TSIRuleID aRuleID,
+                        TSIRuleVariantID& aRuleVariantID );
+
+        /**
+        * Adds a new rule for the given phrase into the 
+        * specified grammar.
+        *
+        * @since    2.8
+        * @param    aTextArray            the text to be trained, divided in to words.
+        *                               The phrase is the concatenation of these words.
+        * @param    aLanguageArray      pronunciations will be generated for these languages
+        * @param    aLexiconID          lexicon, where to add pronunciations
+        * @param    aGrammarID          grammar, where to add rules
+        * @param    aRuleID             the ID of the rule will be placed on this variable.
+        * @return    system wide error code
+        */
+        IMPORT_C TInt AddVoiceTag( MDesCArray& aTextArray,
+                                   const RArray<TLanguage>& aLanguageArray,
+                                   TSILexiconID aLexiconID,
+                                   TSIGrammarID aGrammarID,
+                                   TSIRuleID& aRuleID );
+
+        /**
+        * Adds a new rules for the given phrases into the 
+        * specified grammar.
+        *
+        * @since    2.8
+        * @param    aTextArrayArray     Array of text arrays. The phrase k is the concatenation
+        *                               of texts in array k.
+        * @param    aLanguageArray      pronunciations will be generated for these languages
+        * @param    aLexiconID          lexicon, where to add pronunciations
+        * @param    aGrammarID          grammar, where to add rules
+        * @param    aRuleID             the ID of the rule will be placed on this variable.
+        *                               If some of the names fail while others succeed,
+        *                               KInvalidRuleID will be placed to the array.
+        * @return    system wide error code
+        */
+        IMPORT_C TInt AddVoiceTags( const RPointerArray<MDesCArray> &aTextArrayArray,
+                                    const RArray<TLanguage> &aLanguageArray,
+                                    TSILexiconID aLexiconID,
+                                    TSIGrammarID aGrammarID, 
+                                    RArray<TSIRuleID>& aRuleIDArray );
+
+        /**
+        * Adds a new rule for the given phrase into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aTextArray        The text to be trained, divided in to words.
+        *                          The phrase is the concatenation of these words.
+        * @param aLanguageArray    Pronunciations will be generated for these languages
+        * @param aLexiconID        Lexicon, where to add pronunciations
+        * @param aGrammarID        Grammar, where to add rules
+        * @param aRuleID           The ID of the rule will be placed on this variable.
+        *
+        * @return System wide error code
+        */
+        IMPORT_C TInt AddVoiceTag( MDesCArray& aTextArray,
+                                   const RArray<RLanguageArray>& aLanguageArray,
+                                   TSILexiconID aLexiconID,
+                                   TSIGrammarID aGrammarID,
+                                   TSIRuleID& aRuleID );
+
+        /**
+        * Adds a new rules for the given phrases into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aTextArrayArray     Array of text arrays. The phrase k is the concatenation
+        *                            of texts in array k.
+        * @param aLanguageArray      pronunciations will be generated for these languages
+        * @param aLexiconID          lexicon, where to add pronunciations
+        * @param aGrammarID          grammar, where to add rules
+        * @param aRuleID             the ID of the rule will be placed on this variable.
+        *                            If some of the names fail while others succeed,
+        *                            KInvalidRuleID will be placed to the array.
+        * @return System wide error code
+        */
+        IMPORT_C TInt AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                    const RArray<RLanguageArray>& aLanguageArray,
+                                    TSILexiconID aLexiconID,
+                                    TSIGrammarID aGrammarID, 
+                                    RArray<TSIRuleID>& aRuleIDArray );
+
+        /**
+        * Cancels the current operation
+        *    
+        * @since 2.0
+        */
+        IMPORT_C void Cancel();
+
+        /**
+        * Saves the changes into a permanent storage.
+        *
+        * @since 2.0
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt CommitChanges();
+
+        /**
+        * Creates a new grammar.
+        *    
+        * @since 2.0
+        * @param     aGrammarID            reference where grammar ID is stored
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt CreateGrammar( TSIGrammarID& aGrammarID );
+
+        /**
+        * Creates a new lexicon.
+        *    
+        * @since 2.0
+        * @param     aLexiconID            reference where lexicon ID is stored
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt CreateLexicon( TSILexiconID& aLexiconID );
+
+        /**
+        * Creates a new rule.
+        *    
+        * @since 2.8
+        * @param    aGrammarID          grammar, where the new rule is to be added
+        * @param     aRuleID                reference where rule ID is stored
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt CreateRule( TSIGrammarID aGrammarID, TSIRuleID& aRuleID );
+
+        /**
+        * Loads the specified model bank into the recognizer;
+        * done prior to recognition.
+        *
+        * @since 2.0
+        * @param     ModelBankID            model bank Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt LoadModels( TSIModelBankID aModelBankID );
+
+        /**
+        * Loads the specified grammar into the recognizer;
+        * done prior to recognition.
+        *
+        * @since 2.0
+        * @param     aGrammarID            grammar ID
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt LoadGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        * Reactivates a previously deactivated grammar.
+        *
+        * @since 2.0
+        * @param     aGrammarID            grammar ID
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt ActivateGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        * Deactivates a loaded grammar, so that it is not recognized.
+        *
+        * @since 2.0
+        * @param     aGrammarID            grammar ID
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt DeactivateGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        * Loads the specified lexicon into the recognizer; 
+        * done prior to recognition.
+        *
+        * @since 2.0
+        * @param     aLexiconID            lexicon ID
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt LoadLexicon( TSILexiconID aLexiconID );
+
+        /**
+        * Returns the number of models in the specified model bank.
+        * @since    2.0
+        * @param    aModelBankID        model bank Id
+        * @param    aCount                reference where the number of 
+        *                                models is set
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt GetModelCount( TSIModelBankID aModelBankID, 
+                            TInt& aModelCount );
+
+        /**
+        * Ends the current recognition session. Resources allocated 
+        * for recognition are freed.
+        *
+        * @since    2.0
+        * @param    aModelBankID        reference where a new model bank Id is 
+        *                                assigned to
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt EndRecSession();
+
+        /**
+        * Starts a new recognition session.
+        *
+        * @since    2.0
+        * @param    aMode                recognition mode
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt StartRecSession( TNSSRecognitionMode aMode );
+
+        /**
+        * Initiates speaker independent recognition; performed
+        * following loading of model bank, lexicon, and grammar.
+        *
+        * @since    2.8
+        * @param    aResultSet            reference where the recognition
+        *                                result is set
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt Recognize( CSIClientResultSet& aResultSet );
+
+        /**
+        * Records uder utterance for training and recognition.
+        *
+        * @since    2.0
+        * @param    aRecordTime            recording time in microseconds
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt Record( TTimeIntervalMicroSeconds32 aRecordTime );
+
+        /**
+        * Stops the recording. The difference with Cancel is that if
+        * enough samples were recorded, a recognition result will be produced.
+        *
+        * @since    2.8
+        * @param    aRecordTime            recording time in microseconds
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt EndRecord();
+
+        /**
+        * Pre-starts samping before Record call.
+        * 
+        * @since 3.2
+        * @return System wide error code
+        */
+        IMPORT_C TInt PreStartSampling();
+
+        /**
+        * Removes the specified grammar from the permanent storage.
+        * Removing a grammar will remove all rules within the grammar.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemoveGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        * Removes the specified pronunciation from the 
+        * specified lexicon permanently.
+        *
+        * @since    2.0
+        * @param    aLexiconID            lexicon Id
+        * @param    aPronunciationID    pronunciation Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemovePronunciation( TSILexiconID aLexiconID, 
+                        TSIPronunciationID aPronunciationID );
+
+        /**
+        * Removes the specified lexicon from the permanent storage.
+        * Removing a lexicon will remove all pronunciations within the 
+        * lexicon.
+        *
+        * @since    2.0
+        * @param    aLexiconID            lexicon Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemoveLexicon( TSILexiconID aLexiconID );
+
+        /**
+        * Removes the specified model from the specified model bank 
+        * permanently.
+        *
+        * @since    2.0
+        * @param    aModelBankID        model bank Id
+        * @param    aModelID            model Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemoveModel( TSIModelBankID aModelBankID, 
+                        TSIModelID aModelID );
+
+        /**
+        * Removes the specified rule from the specified grammar permanently.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id
+        * @param    aRuleID                rule Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemoveRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+        /**
+        * Removes multiple rules from the specified grammar permanently.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id
+        * @param    aRuleID                rule Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemoveRules( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+
+        /**
+        * Unloads the specified rule from the specified grammar
+        * in temporary memory, previously loaded with LoadGrammarL.  
+        * The rule in the permanent storage remains intact.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id
+        * @param    aRuleID               rule Id
+        * @return   system wide error codes
+        */
+        IMPORT_C TInt UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+        /**
+        * Unloads the specified grammar from the list of grammars
+        * in temporary memory, previously loaded with LoadGrammarL.  
+        * The grammar in the permanent storage remains intact.
+        *
+        * @since    2.8
+        * @param    aGrammarID            grammar Id
+        * @return   system wide error codes
+        */
+        IMPORT_C TInt UnloadGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        * Set the event handler for asynchronous events
+        *
+        * @since    2.0
+        * @param    aSpeechRecognitionUtilityObserver        pointer to observer
+        */
+        IMPORT_C void SetEventHandler( MSISpeechRecognitionUtilityObserver*
+                        aSpeechRecognitionUtilityObserver );
+
+        /**
+        * Returns all pronunciation Ids that exist in the specified lexicon.
+        *
+        * @since    2.0
+        * @param    aLexiconID            lexicon Id
+        *           aPronunciationIDs     reference where pronunciation 
+        *                                 Ids are stored
+        * @return   system wide error codes
+        */
+        IMPORT_C TInt GetAllPronunciationIDs( TSILexiconID aLexiconID, 
+                        RArray <TSIPronunciationID>& aPronunciationIDs );
+
+        /**
+        * Returns all grammar Ids that belong to the current client.
+        *
+        * @since 2.0
+        * @param    aGrammarIDs            reference where grammar Ids are stored
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt GetAllClientGrammarIDs( RArray<TSIGrammarID>& aGrammarIDs );
+
+        /**
+        * Returns all lexicon Ids that belong to the current client.
+        *
+        * @since 2.0
+        * @param    aLexiconIDs            reference where lexicon Ids are stored
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt GetAllClientLexiconIDs( RArray<TSILexiconID>& aLexiconIDs );
+
+        /**
+        *    Returns all model bank Ids that belong to the current client.
+        * @since 2.0
+        * @param    aModelBankIDs        reference where model bank 
+        *                                Ids are stored
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt GetAllClientModelBankIDs( 
+                            RArray<TSIModelBankID>& aModelBankIDs );
+
+        /**
+        * Returns all grammar Ids that exist (for all clients).
+        *
+        * @since 2.0
+        * @param    aGrammarIDs            reference where grammar Ids are stored
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt GetAllGrammarIDs( RArray<TSIGrammarID>& aGrammarIDs );
+
+        /**
+        * Returns all lexicon Ids that exist (for all clients).
+        *
+        * @since 2.0
+        * @param    aLexiconIDs            reference where lexicon Ids are stored
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt GetAllLexiconIDs( RArray<TSILexiconID>& aLexiconIDs );
+
+        /**
+        * Returns all model bank Ids that exist (for all clients).
+        *
+        * @since 2.0
+        * @param    aModelBankIDs        reference where model bank 
+        *                                Ids are stored
+        * @return    System-wide errors
+        */
+        IMPORT_C TInt GetAllModelBankIDs( 
+                            RArray<TSIModelBankID>& aModelBankIDs );
+
+        /**
+        * Returns all model Ids that exist in the specified model bank.
+        *
+        * @since    2.0
+        * @param    aModelBankID        model bank Id
+        *            aModelIDs            reference where model Ids are stored
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt GetAllModelIDs( TSIModelBankID aModelBankID, 
+                        RArray <TSIModelID>& aModelIDs );
+
+        /**
+        * Checks if the rule is valid or not.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id
+        *            aRuleID                rule Id
+        *            aValid                reference where the validity of 
+        *                                the rule is set
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt GetRuleValidity( TSIGrammarID aGrammarID, TSIRuleID aRuleID,
+                        TBool& aValid ); 
+
+        /**
+        * Returns all rule Ids that exist in the specified grammar.
+        *
+        * @since    2.0
+        * @param    aGrammarID            grammar Id
+        *            aRuleIDs            reference where rule Ids are stored
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt GetAllRuleIDs( TSIGrammarID aGrammarID, 
+                        RArray <TSIRuleID>& aRuleIDs );
+
+        /**
+        * Creates a new model bank.
+        *
+        * @since    2.0
+        * @param    aModelBankID        reference where a new model 
+        *                                bank Id is assigned to
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt CreateModelBank( TSIModelBankID& aModelBankID );
+
+        /**
+        *    Removes the specified model bank from the permanent storage.
+        *    Removing a model bank will remove all models within the model bank.
+        * @since    2.0
+        * @param    aModelBankID        model bank Id
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt RemoveModelBank( TSIModelBankID aModelBankID );
+
+        /**
+        * Uploads the specified parameters into the engine.
+        *
+        * @since    2.0
+        * @param    aParameterId        array of parameter IDs
+        * @param    aParameterValue        array of parameter values
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt LoadEngineParameters( const RArray<TInt>& aParameterId, 
+                                    const RArray<TInt>& aParameterValue );
+
+        /**
+        * Set the audio priority and preference for train, playback 
+        *  and recognition
+        *
+        * @since    2.0
+        * @param    aPriority                priority for voice recognition
+        * @param    aTrainPreference        preference for training
+        * @param    aPlaybackPreference        preference for playback
+        * @param    aRecognitionPreference    preference for recognition
+        * @return    system wide error codes
+        */
+        IMPORT_C TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference, 
+                        TInt aPlaybackPreference, TInt aRecognitionPreference );
+
+        /**
+        * From MSISpeechRecognitionUtilityObserver
+        *    
+        * @since    2.0
+        * @param    aEvent                    event code indicating what 
+        *                                    asynchronous event occurred
+        */
+        void HandleEvent( const TMMFEvent& aEvent );
+
+private: // Functions
+
+        /**
+        * Private C++ constructor for this class.
+        *
+        * @since    2.0
+        * @param    aSpeechRecognitionUtilityObserver    reference to event 
+        *                                                observer class
+        */
+        CSISpeechRecognitionUtility( MSISpeechRecognitionUtilityObserver& 
+                        aSpeechRecognitionUtilityObserver );
+
+        /**
+        * Default C++ constructor
+        */
+        CSISpeechRecognitionUtility();
+        
+        /**
+        * Second phase constructor for this class.
+        *
+        * @since 2.0
+        * @param aClientUid Client UID for data ownership, other clients won't
+        *                   be able to modify the data registered to certain client
+        * @param aPluginUid UID of the plugin which will be used, KNullUid to 
+        *                    search for suitable plugin
+        * @param aObserver Callback observer reference
+        */
+        void ConstructL( TUid aClientUid, 
+                         TUid aPluginUid, 
+                         MSISpeechRecognitionUtilityObserver& aObserver );
+
+
+private: // Member variables
+
+        // member variable MMF controller
+        RMMFController iMMFController;
+
+        // member variable for custom commands
+        RSISpeechRecognitionCustomCommands iSrCustomCommands;
+        // member variable pointer for observer class
+        MSISpeechRecognitionUtilityObserver* iSpeechRecognitionUtilityObserver;
+        // member variable pointer for controller event monitor class
+        CMMFControllerEventMonitor* iControllerEventMonitor;
+        // used to indicate if an event is the result of an internal command
+        TBool iInternalCommand;
+
+        // member variable pointer for array of rule IDs
+        RArray <TSIRuleID>* iRuleIDs;
+        // member variable pointer for array of pronunciation IDs
+        RArray <TSIPronunciationID>* iPronunciationIDs;
+        // member variable pointer for array of model IDs
+        RArray <TSIModelID>* iModelIDs;
+        // member variable pointer for array of grammar IDs
+        RArray <TSIGrammarID>* iGrammarIDs;
+        // member variable pointer for array of lexicon IDs
+        RArray <TSILexiconID>* iLexiconIDs;
+        // member variable pointer for array of model bank IDs
+        RArray <TSIModelBankID>* iModelBankIDs;
+        // member variable for model bank IDs
+        TSIModelBankID iModelBankID;
+        // member variable for grammar IDs
+        TSIGrammarID iGrammarID;
+        // member variable for lexicon IDs
+        TSILexiconID iLexiconID;
+        // member variable for pronunciation count
+        TInt iPronunciationCount;
+        // member variable for rule count
+        TInt iRuleCount;
+        // member variable for model count
+        TInt iModelCount;
+        
+        // member variable for audio priority
+        TInt iAudioPriority;
+        // member variable for train preference
+        TInt iTrainPreference; 
+        // member variable for playback preference
+        TInt iPlaybackPreference;
+        // member variable for recognition preference
+        TInt iRecognitionPreference;
+
+        // member variable pointer for array of client result sets
+        CSDClientResultSet* iResultSet;
+
+        // member variable for client UID
+        TUid iClientUid;
+
+        // For SI: N-Best list
+        CSIClientResultSet* iSIResultSet;
+
+        // reserved for future expansion
+        TAny* iReservedPtr_1;
+        // reserved for future expansion
+        TAny* iReservedPtr_2;
+};
+
+#endif    // of NSSSISPEECHRECOGNITIONUTILITY_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_utility_api/inc/nsssispeechrecognitionutilityobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the definition of the speech recognition utility.observer
+*
+*/
+
+
+
+#ifndef NSSSISPEECHRECOGNITIONUTILITYOBSERVER_H
+#define NSSSISPEECHRECOGNITIONUTILITYOBSERVER_H
+
+//  INCLUDES
+
+#include <nsssispeechrecognitiondataclient.h>
+
+
+// CLASS DECLARATION
+
+/**
+*  This is the main class of Speech Recognition Utility Observer
+*
+*  @lib SpeechRecognitionUtility.lib
+*  @since 2.0
+*/
+
+class MSISpeechRecognitionUtilityObserver
+{
+
+public:
+      /**
+        * 
+        *	Pure virtual function that receives speech recognition utility events.
+        * @since 2.0
+        * @param 	aEvent			event code indicating the event type.
+        * @return	-
+        */
+		virtual void MsruoEvent( TUid aEvent, TInt aResult )=0;
+
+};
+
+#endif	// of SPEECHRECOGNITIONUTILITYOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_utility_api/inc/nsssiutilitybase.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,615 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for TTS utility API
+*
+*/
+
+
+#ifndef NSSSIUTILITYBASE_H
+#define NSSSIUTILITYBASE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitionutilityobserver.h>
+
+// CLASS DECLARATION
+
+/**
+* MSISpeechRecognitionUtilityBase
+* Interface class for CSISpeechRecognitionUtility
+* @since 3.1
+*/
+class MSISpeechRecognitionUtilityBase
+    {
+    public:     
+   
+        /**
+        * Second phase construction.
+        * Needed when dynamically loading nsssispeechrecognitionutility.dll
+        * Direct users of CSISpeechRecognitionUtility should not use this.
+        *
+        * @since 3.1
+        * @param aClientUid Client UID for data ownership, other clients won't
+        *                   be able to modify the data registered to certain client
+        * @param aPluginUid UID of the plugin which will be used, KNullUid to 
+        *                    search for suitable plugin
+        * @param aObserver Callback observer reference
+        */
+        virtual void CreateInstanceSecondPhaseL( TUid aClientUid, 
+                                                 TUid aPluginUid, 
+                                                 MSISpeechRecognitionUtilityObserver& aObserver ) = 0;
+                                                 
+        /**
+        * Destructor. Defined here so that client can use M-class pointer to destroy
+        * the concrete C-object
+        */                                         
+        virtual ~MSISpeechRecognitionUtilityBase() {};
+           
+        /**
+        * Returns the engine properties specified by the engine property 
+        * ID array. On return aPropertyValue contains an array of engine 
+        * properties.
+        *
+        * @since 3.1
+        * @param aPropertyId constant reference to array of engine property Ids
+        * @param aPropertyValue reference to array of engine property values
+        * @return system wide error code
+        */
+        virtual TInt GetEngineProperties( const RArray<TInt>& aPropertyId, 
+                                          RArray<TInt>& aPropertyValue ) = 0;
+
+        /**
+        * Adapts the speaker independent models to a specific speaker's voice.
+        *
+        * @since 3.1
+        * @param aResultSet Recognition result N-Best
+        * @param aCorrect Index to N-Best pointing the correct result.
+        * @return system wide error code
+        */
+        virtual TInt Adapt( const CSIClientResultSet& aResultSet,
+                            TInt aCorrect ) = 0;
+
+        /**
+        * Adds a new pronunciation for the given text phrase into the 
+        * specified lexicon.
+        *
+        * @since 3.1
+        * @param aLexiconID lexicon Id, where the new pronunciation is added to
+        * @param aTextForTraining Text to be trained
+        * @param aLanguage Pronunciation language
+        * @param aPronunciationID reference where a new pronunciation Id is assigned to
+        * @return system wide error code
+        */
+        virtual TInt AddPronunciation( TSILexiconID aLexiconID,
+                                       const TDesC& aTextForTraining,
+                                       TLanguage aLanguage,
+                                       TSIPronunciationID& aPronunciationID ) = 0;
+
+        /**
+        * Adds a new rule for the given pronunciation into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id, where the new rule is added to
+        * @param aLexiconID lexicon Id
+        * @param aPronunciationID pronunciation Id
+        * @param aRuleID reference where a new rule Id is assigned to
+        * @return system wide error code
+        */
+        virtual TInt AddRule( TSIGrammarID aGrammarID,
+                              TSILexiconID aLexiconID,
+                              TSIPronunciationID aPronunciationID,
+                              TSIRuleID& aRuleID ) = 0;
+
+        /**
+        * Adds a new rule variant for the given pronunciation into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id, where the new rule is added to
+        * @param aRuleID the rule Id, which will contain this variant
+        * @param aPronunciationIDs the phrase is the concatenation of these pronunciation IDs
+        * @param aRuleVariantID reference where a new rule variant Id is assigned to
+        * @return system wide error code
+        */
+        virtual TInt AddRuleVariant( TSIGrammarID aGrammarID,
+                                     TSILexiconID aLexiconID,
+                                     RArray<TSIPronunciationID>& aPronunciationIDs,
+                                     TSIRuleID aRuleID,
+                                     TSIRuleVariantID& aRuleVariantID ) = 0;
+
+        /**
+        * Adds a new rule for the given phrase into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aTextArray the text to be trained, divided in to words.
+        *                   The phrase is the concatenation of these words.
+        * @param aLanguageArray pronunciations will be generated for these languages
+        * @param aLexiconID lexicon, where to add pronunciations
+        * @param aGrammarID grammar, where to add rules
+        * @param aRuleID the ID of the rule will be placed on this variable.
+        * @return system wide error code
+        */
+        virtual TInt AddVoiceTag( MDesCArray& aTextArray,
+                                  const RArray<TLanguage>& aLanguageArray,
+                                  TSILexiconID aLexiconID,
+                                  TSIGrammarID aGrammarID,
+                                  TSIRuleID& aRuleID ) = 0;
+
+        /**
+        * Adds a new rules for the given phrases into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aTextArrayArray Array of text arrays. The phrase k is the concatenation
+        *                        of texts in array k.
+        * @param aLanguageArray pronunciations will be generated for these languages
+        * @param aLexiconID lexicon, where to add pronunciations
+        * @param aGrammarID grammar, where to add rules
+        * @param aRuleID the ID of the rule will be placed on this variable.
+        *                If some of the names fail while others succeed,
+        *                KInvalidRuleID will be placed to the array.
+        * @return system wide error code
+        */
+        virtual TInt AddVoiceTags( const RPointerArray<MDesCArray> &aTextArrayArray,
+                                   const RArray<TLanguage> &aLanguageArray,
+                                   TSILexiconID aLexiconID,
+                                   TSIGrammarID aGrammarID, 
+                                   RArray<TSIRuleID>& aRuleIDArray ) = 0;
+
+        /**
+        * Adds a new rule for the given phrase into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aTextArray The text to be trained, divided in to words.
+        *                   The phrase is the concatenation of these words.
+        * @param aLanguageArray Pronunciations will be generated for these languages
+        * @param aLexiconID Lexicon, where to add pronunciations
+        * @param aGrammarID Grammar, where to add rules
+        * @param aRuleID The ID of the rule will be placed on this variable.
+        * @return System wide error code
+        */
+        virtual TInt AddVoiceTag( MDesCArray& aTextArray,
+                                  const RArray<RLanguageArray>& aLanguageArray,
+                                  TSILexiconID aLexiconID,
+                                  TSIGrammarID aGrammarID,
+                                  TSIRuleID& aRuleID ) = 0;
+
+        /**
+        * Adds a new rules for the given phrases into the 
+        * specified grammar.
+        *
+        * @since 3.1
+        * @param aTextArrayArray Array of text arrays. The phrase k is the concatenation
+        *                        of texts in array k.
+        * @param aLanguageArray pronunciations will be generated for these languages
+        * @param aLexiconID lexicon, where to add pronunciations
+        * @param aGrammarID grammar, where to add rules
+        * @param aRuleID the ID of the rule will be placed on this variable.
+        *                If some of the names fail while others succeed,
+        *                KInvalidRuleID will be placed to the array.
+        * @return System wide error code
+        */
+        virtual TInt AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                   const RArray<RLanguageArray>& aLanguageArray,
+                                   TSILexiconID aLexiconID,
+                                   TSIGrammarID aGrammarID, 
+                                   RArray<TSIRuleID>& aRuleIDArray ) = 0;
+
+        /**
+        * Cancels the current operation
+        *    
+        * @since 3.1
+        */
+        virtual void Cancel() = 0;
+
+        /**
+        * Saves the changes into a permanent storage.
+        *
+        * @since 3.1
+        * @return System-wide errors
+        */
+        virtual TInt CommitChanges() = 0;
+
+        /**
+        * Creates a new grammar.
+        *    
+        * @since 3.1
+        * @param aGrammarID reference where grammar ID is stored
+        * @return system wide error codes
+        */
+        virtual TInt CreateGrammar( TSIGrammarID& aGrammarID ) = 0;
+
+        /**
+        * Creates a new lexicon.
+        *    
+        * @since 3.1
+        * @param aLexiconID reference where lexicon ID is stored
+        * @return system wide error codes
+        */
+        virtual TInt CreateLexicon( TSILexiconID& aLexiconID ) = 0;
+
+        /**
+        * Creates a new rule.
+        *    
+        * @since 3.1
+        * @param aGrammarID grammar, where the new rule is to be added
+        * @param aRuleID reference where rule ID is stored
+        * @return system wide error codes
+        */
+        virtual TInt CreateRule( TSIGrammarID aGrammarID, TSIRuleID& aRuleID ) = 0;
+
+        /**
+        * Loads the specified model bank into the recognizer.
+        * done prior to recognition.
+        *
+        * @since 3.1
+        * @param ModelBankID model bank Id
+        * @return system wide error codes
+        */
+        virtual TInt LoadModels( TSIModelBankID aModelBankID ) = 0;
+
+        /**
+        * Loads the specified grammar into the recognizer.
+        * done prior to recognition.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar ID
+        * @return system wide error codes
+        */
+        virtual TInt LoadGrammar( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+        * Reactivates a previously deactivated grammar.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar ID
+        * @return system wide error codes
+        */
+        virtual TInt ActivateGrammar( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+        * Deactivates a loaded grammar, so that it is not recognized.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar ID
+        * @return system wide error codes
+        */
+        virtual TInt DeactivateGrammar( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+        * Loads the specified lexicon into the recognizer; 
+        * done prior to recognition.
+        *
+        * @since 3.1
+        * @param aLexiconID lexicon ID
+        * @return system wide error codes
+        */
+        virtual TInt LoadLexicon( TSILexiconID aLexiconID ) = 0;
+
+        /**
+        * Returns the number of models in the specified model bank.
+        *
+        * @since 3.1
+        * @param aModelBankID model bank Id
+        * @param aCount reference where the number of 
+        *               models is set
+        * @return system wide error codes
+        */
+        virtual TInt GetModelCount( TSIModelBankID aModelBankID, 
+                                    TInt& aModelCount ) = 0;
+
+        /**
+        * Ends the current recognition session. Resources allocated 
+        * for recognition are freed.
+        *
+        * @since 3.1
+        * @param aModelBankID reference where a new model bank Id is assigned to
+        * @return system wide error codes
+        */
+        virtual TInt EndRecSession() = 0;
+
+        /**
+        * Starts a new recognition session.
+        *
+        * @since 3.1
+        * @param aMode recognition mode
+        * @return system wide error codes
+        */
+        virtual TInt StartRecSession( TNSSRecognitionMode aMode ) = 0;
+
+        /**
+        * Initiates speaker independent recognition; performed
+        * following loading of model bank, lexicon, and grammar.
+        *
+        * @since 3.1
+        * @param aResultSet reference where the recognition result is set
+        * @return system wide error codes
+        */
+        virtual TInt Recognize( CSIClientResultSet& aResultSet ) = 0;
+
+        /**
+        * Records utterance for recognition.
+        *
+        * @since 3.1
+        * @param aRecordTime recording time in microseconds
+        * @return system wide error codes
+        */
+        virtual TInt Record( TTimeIntervalMicroSeconds32 aRecordTime ) = 0;
+
+        /**
+        * Stops the recording. The difference with Cancel is that if
+        * enough samples were recorded, a recognition result will be produced.
+        *
+        * @since 3.1
+        * @param aRecordTime recording time in microseconds
+        * @return system wide error codes
+        */
+        virtual TInt EndRecord() = 0;
+
+        /**
+        * Pre-starts samping before Record call.
+        * 
+        * @since 3.2
+        * @return System wide error code
+        */
+        virtual TInt PreStartSampling() = 0;
+
+        /**
+        * Removes the specified grammar from the permanent storage.
+        * Removing a grammar will remove all rules within the grammar.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @return system wide error codes
+        */
+        virtual TInt RemoveGrammar( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+        * Removes the specified pronunciation from the 
+        * specified lexicon permanently.
+        *
+        * @since 3.1
+        * @param aLexiconID lexicon Id
+        * @param aPronunciationID pronunciation Id
+        * @return system wide error codes
+        */
+        virtual TInt RemovePronunciation( TSILexiconID aLexiconID, 
+                                          TSIPronunciationID aPronunciationID ) = 0;
+
+        /**
+        * Removes the specified lexicon from the permanent storage.
+        * Removing a lexicon will remove all pronunciations within the 
+        * lexicon.
+        * 
+        * @since 3.1
+        * @param aLexiconID lexicon Id
+        * @return system wide error codes
+        */
+        virtual TInt RemoveLexicon( TSILexiconID aLexiconID ) = 0;
+
+        /**
+        * Removes the specified model from the specified model bank 
+        * permanently.
+        *
+        * @since 3.1
+        * @param aModelBankID model bank Id
+        * @param aModelID model Id
+        * @return system wide error codes
+        */
+        virtual TInt RemoveModel( TSIModelBankID aModelBankID, 
+                                  TSIModelID aModelID ) = 0;
+
+        /**
+        * Removes the specified rule from the specified grammar permanently.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @param aRuleID rule Id
+        * @return system wide error codes
+        */
+        virtual TInt RemoveRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID ) = 0;
+
+        /**
+        * Removes multiple rules from the specified grammar permanently.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @param aRuleID rule Id
+        * @return system wide error codes
+        */
+        virtual TInt RemoveRules( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs ) = 0;
+
+        /**
+        * Unloads the specified rule from the specified grammar
+        * in temporary memory, previously loaded with LoadGrammarL.  
+        * The rule in the permanent storage remains intact.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @param aRuleID rule Id
+        * @return system wide error codes
+        */
+        virtual TInt UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID ) = 0;
+
+        /**
+        * Unloads the specified grammar from the list of grammars
+        * in temporary memory, previously loaded with LoadGrammarL.  
+        * The grammar in the permanent storage remains intact.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @return system wide error codes
+        */
+        virtual TInt UnloadGrammar( TSIGrammarID aGrammarID ) = 0;
+
+        /**
+        * Set the event handler for asynchronous events
+        *
+        * @since 3.1
+        * @param aSpeechRecognitionUtilityObserver pointer to observer
+        */
+        virtual void SetEventHandler( MSISpeechRecognitionUtilityObserver*
+                                      aSpeechRecognitionUtilityObserver ) = 0;
+
+        /**
+        * Returns all pronunciation Ids that exist in the specified lexicon.
+        *
+        * @since 3.1
+        * @param aLexiconID lexicon Id
+        * @param aPronunciationIDs reference where pronunciation Ids are stored
+        * @return system wide error codes
+        */
+        virtual TInt GetAllPronunciationIDs( TSILexiconID aLexiconID, 
+                                             RArray <TSIPronunciationID>& aPronunciationIDs ) = 0;
+
+        /**
+        * Returns all grammar Ids that belong to the current client.
+        *
+        * @since 3.1
+        * @param aGrammarIDs reference where grammar Ids are stored
+        * @return System-wide errors
+        */
+        virtual TInt GetAllClientGrammarIDs( RArray<TSIGrammarID>& aGrammarIDs ) = 0;
+
+        /**
+        * Returns all lexicon Ids that belong to the current client.
+        *
+        * @since 3.1
+        * @param aLexiconIDs reference where lexicon Ids are stored
+        * @return System-wide errors
+        */
+        virtual TInt GetAllClientLexiconIDs( RArray<TSILexiconID>& aLexiconIDs ) = 0;
+
+        /**
+        * Returns all model bank Ids that belong to the current client.
+        *
+        * @since 3.1
+        * @param aModelBankIDs reference where model bank Ids are stored
+        * @return System-wide errors
+        */
+        virtual TInt GetAllClientModelBankIDs( RArray<TSIModelBankID>& aModelBankIDs ) = 0;
+
+        /**
+        * Returns all grammar Ids that exist (for all clients).
+        *
+        * @since 3.1
+        * @param aGrammarIDs reference where grammar Ids are stored
+        * @return System-wide errors
+        */
+        virtual TInt GetAllGrammarIDs( RArray<TSIGrammarID>& aGrammarIDs ) = 0;
+
+        /**
+        * Returns all lexicon Ids that exist (for all clients).
+        *
+        * @since 3.1
+        * @param aLexiconIDs reference where lexicon Ids are stored
+        * @return System-wide errors
+        */
+        virtual TInt GetAllLexiconIDs( RArray<TSILexiconID>& aLexiconIDs ) = 0;
+
+        /**
+        * Returns all model bank Ids that exist (for all clients).
+        *
+        * @since 3.1
+        * @param aModelBankIDs reference where model bank Ids are stored
+        * @return System-wide errors
+        */
+        virtual TInt GetAllModelBankIDs( RArray<TSIModelBankID>& aModelBankIDs ) = 0;
+
+        /**
+        * Returns all model Ids that exist in the specified model bank.
+        * 
+        * @since 3.1
+        * @param aModelBankID model bank Id
+        * @param aModelIDs reference where model Ids are stored
+        * @return system wide error codes
+        */
+        virtual TInt GetAllModelIDs( TSIModelBankID aModelBankID, 
+                                     RArray <TSIModelID>& aModelIDs ) = 0;
+
+        /**
+        * Checks if the rule is valid or not.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @param aRuleID rule Id
+        * @param aValid reference where the validity of the rule is set
+        * @return system wide error codes
+        */
+        virtual TInt GetRuleValidity( TSIGrammarID aGrammarID, TSIRuleID aRuleID,
+                                      TBool& aValid ) = 0; 
+
+        /**
+        * Returns all rule Ids that exist in the specified grammar.
+        *
+        * @since 3.1
+        * @param aGrammarID grammar Id
+        * @param aRuleIDs reference where rule Ids are stored
+        * @return system wide error codes
+        */
+        virtual TInt GetAllRuleIDs( TSIGrammarID aGrammarID, 
+                                    RArray <TSIRuleID>& aRuleIDs ) = 0;
+
+        /**
+        * Creates a new model bank.
+        *
+        * @since 3.1
+        * @param aModelBankID reference where a new model bank Id is assigned to
+        * @return system wide error codes
+        */
+        virtual TInt CreateModelBank( TSIModelBankID& aModelBankID ) = 0;
+
+        /**
+        * Removes the specified model bank from the permanent storage.
+        * Removing a model bank will remove all models within the model bank.
+        *
+        * @since 3.1
+        * @param aModelBankID model bank Id
+        * @return system wide error codes
+        */
+        virtual TInt RemoveModelBank( TSIModelBankID aModelBankID ) = 0;
+
+        /**
+        * Uploads the specified parameters into the engine.
+        *
+        * @since 3.1
+        * @param aParameterId array of parameter IDs
+        * @param aParameterValue array of parameter values
+        * @return system wide error codes
+        */
+        virtual TInt LoadEngineParameters( const RArray<TInt>& aParameterId, 
+                                           const RArray<TInt>& aParameterValue ) = 0;
+
+        /**
+        * Set the audio priority and preference recognition
+        * 
+        * @since 3.1
+        * @param aPriority priority for voice recognition
+        * @param aTrainPreference preference for training
+        * @param aPlaybackPreference preference for playback
+        * @param aRecognitionPreference preference for recognition
+        * @return system wide error codes
+        */
+        virtual TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference, 
+                                       TInt aPlaybackPreference, TInt aRecognitionPreference ) = 0;
+
+    };
+
+#endif // NSSSIUTILITYBASE_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_srs_utility_api/nss_srs_utility_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="725f06d425e6900fc210922903e00f13" dataversion="2.0">
+  <name>NSS SRS Utility API</name>
+  <description>Client API for speech recognition</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssspeechrecognitionutility.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_common_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS TTS Common API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssttscommon.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttscommon.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_common_api/inc/nssttscommon.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,437 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Data type defininitions for TTS
+*     %version: 13 %
+*
+*  Copyright © 2004-2006 Nokia Corporation.
+*/
+
+
+
+
+
+#ifndef TTSCOMMON_H
+#define TTSCOMMON_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+// CONSTANTS
+// Undefined synthesizing language. The default language of TTS processor will be used.
+const TLanguage KTtsUndefinedLanguage( ELangOther );
+
+// Undefined duration of segment. The duration will be defined using other properties.
+const TInt32 KTtsUndefinedDuration( -1 );
+
+// Undefined rate
+const TInt KTtsRateUndefined( -1 );
+
+// Default volume, which is maximum volume (100%). 
+const TInt KTtsDefaultVolume( 100 );
+
+// Max length of voice name
+const TInt KVoiceNameMaxLength( 50 );
+
+// Maximum speaking rate
+const TInt KTtsMaxSpeakingRate( 100 ); 
+
+// 
+_LIT( KDefaultVoiceNameMale,   "DefaultMale" );
+_LIT( KDefaultVoiceNameFemale, "DefaultFemale" );
+
+// DATA TYPES
+
+// Style identifier
+typedef TUint32 TTtsStyleID;
+
+// Voice identifier
+typedef TBuf<KVoiceNameMaxLength> TTtsVoice;
+    
+// Preferred quality of TTS output
+enum TTtsQuality
+    {
+    ETtsQualityLowOnly, // Low quality
+    ETtsQualityHighOnly, // High quality
+    ETtsQualityHighPreferred, // High quality preferred, low quality fall back can be used
+    ETtsQualityLowPreferred, // Low quality preferred
+    ETtsQualityUndefined // Default quality will be used
+    };
+
+// Custom command ids for CTtsUtility::CustomCommand(As|S)ync()
+enum TTtsCustomCommandId
+    {
+    ETtsCustomCommandSetAudioOutput      = 0, // For setting audio output routing
+    ETtsCustomCommandSetPluginParameter  = 1, // For setting plugin parameter
+    };
+
+// FORWARD DECLARATIONS
+class CTtsParsedTextBody;
+
+// CLASS DECLARATION
+
+/**
+*  Class to encapsulate speaking style
+*
+*  @lib nssttscommon.lib
+*  @since 2.8
+*/
+class TTtsStyle 
+    {
+    public: // Constructor and destructor
+        
+        /**
+        * C++ default constructor.
+        */
+        IMPORT_C TTtsStyle();
+                
+    public: // Data
+    
+        // Synthesizing language
+        TLanguage iLanguage;
+
+        // Voice identifier
+        TTtsVoice iVoice;
+             
+        // Speaking rate in words-per-minute. See TTtsRate.
+        TInt iRate;
+        
+        // Volume scale in percentages. The range is 0..100.
+        // Zero means silent and 100 maximum volume. 
+        TInt iVolume;
+        
+        // Sampling rate
+        TInt iSamplingRate;
+        
+        // TTS quality (preferred or exclusive)
+        TTtsQuality iQuality;
+        
+        // Desired time to take to read the segment in microseconds
+        TTimeIntervalMicroSeconds32 iDuration;
+        
+        // Natural languagege processing on/off
+        TBool iNlp;
+        
+    };
+
+/**
+*  Class to store segment information
+*
+*  @lib nssttscommon.lib
+*  @since 2.8
+*/
+class TTtsSegment
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * C++ default constructor.
+        * @since 2.8
+        * @param aStyleID Indentifier of style.
+        * @param aText Text for segment
+        * @param aPhonemeSequence Corresponding phoneme sequence for text
+        * @param aTrailingSilenceDuration The duration of trailing silence.
+        */
+        IMPORT_C TTtsSegment( const TTtsStyleID aStyleID, 
+            const TDesC& aText = KNullDesC, 
+            const TDesC8& aPhonemeSequence = KNullDesC8, 
+            const TTimeIntervalMicroSeconds32& aTrailingSilenceDuration = KTtsUndefinedDuration );
+                
+    public: // New functions
+        
+        /**
+        * Sets duration of trailing silence.
+        * @since 2.8
+        * @param aDuration Duration of silence.
+        * @return None
+        */
+        IMPORT_C void SetTrailingSilenceL( const TTimeIntervalMicroSeconds32& aDuration );
+        
+        /**
+        * Sets phoneme sequence pointer. The phoneme sequence cannot be deleted 
+        * during the life time of this object.
+        * @since 2.8
+        * @param aPhonemeSequence Phoneme sequence.
+        * @return None
+        */
+        IMPORT_C void SetPhonemeSequencePtr( const TDesC8& aPhonemeSequence );
+        
+        /**
+        * Returns phoneme sequence pointer of the segment.
+        * @since 2.8
+        * @param None
+        * @return Pointer to phoneme sequence
+        */
+        IMPORT_C const TDesC8& PhonemeSequencePtr() const;
+        
+        /**
+        * Sets text pointer. The text cannot be deleted
+        * during the life time of this object.
+        * @since 2.8
+        * @param aText Text.
+        * @return None
+        */
+        IMPORT_C void SetTextPtr( const TDesC& aText );
+        
+        /**
+        * Returns text pointer of the segment.
+        * @since 2.8
+        * @param None
+        * @return Pointer to text.
+        */
+        IMPORT_C const TDesC& TextPtr() const;
+        
+        /**
+        * Gets duration of trailing silence.
+        * @since 2.8
+        * @param None
+        * @return Duration of silence.
+        */
+        IMPORT_C const TTimeIntervalMicroSeconds32& TrailingSilence() const;
+        
+        /**
+        * Sets style for segment. The style cannot be deleted 
+        * during this object life time.
+        * @since 2.8
+        * @param aStyleID The identifier of the style.
+        * @return None
+        */
+        IMPORT_C void SetStyleID( TTtsStyleID aStyleID );
+        
+        /**
+        * Returns identifier of used style.
+        * @since 2.8
+        * @param None
+        * @return Identifier of style.
+        */
+        IMPORT_C TTtsStyleID StyleID() const;
+
+        /**
+        * Sets style object for segment.
+        *
+        * @since 3.1
+        * @param aStyle Style reference.
+        */
+        IMPORT_C void SetStyle( TTtsStyle& aStyle );
+        
+        /**
+        * Returns style object.
+        *
+        * @since 3.1
+        * @return Reference to style.
+        */
+        IMPORT_C TTtsStyle& StyleL();
+
+        /**
+        * Resets previously set style and segment will use the style ID.
+        *
+        * @since 3.1
+        */
+        IMPORT_C void ResetStyle();
+      
+    private:    // Data
+    
+        // Style identifier for segment
+        TTtsStyleID iStyleID;
+        
+        // Pointer to text associated for segment
+        TPtrC iText;
+        
+        // Pointer to phoneme sequence associated for segment
+        TPtrC8 iPhonemeSequence;
+        
+        // Duration of trailing silence
+        TTimeIntervalMicroSeconds32 iTrailingSilenceDuration;
+
+        // Style assigned directly to segment
+        TTtsStyle iStyle;
+
+        // On if style is directly assigned to the segment
+        TBool iIncludesStyle;
+    };
+    
+/**
+*  Class to define functions for TTS segment stream. 
+*  Using the class, a client can implement similar classes to CParsedText.
+*
+*  @lib nssttscommon.lib
+*  @since 2.8
+*/
+class MTtsSegmentStream
+    {
+    public: // New functions
+        
+        /**
+        * Returns used phoneme notation of the stream.
+        * @since 2.8
+        * @return Descriptor of used phoneme notation.
+        */
+        virtual TDesC& MTtsPhonemeNotation() = 0;
+        
+        /**
+        * Returns the next segment in the stream.
+        * @since 2.8
+        * @param aSegment The requested segment.
+        * @return System wide error code. KErrNone if success. 
+        *         KErrUnderflow if there is no available segment.
+        */
+        virtual TInt MTtsReceiveSegment( TTtsSegment& aSegment ) = 0;
+        
+        /**
+        * Notifies that the segment has been processed and it can be released.
+        * @since 2.8
+        * @param aSegment The processed segment.
+        */
+        virtual void MTtsSegmentDone( TTtsSegment& aSegment ) = 0;
+        
+    };
+
+/**
+*  Class to store parsed text for TTS.
+*
+*  @lib nssttscommon.lib
+*  @since 2.8
+*/
+class CTtsParsedText : public CBase
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @since 2.8
+        * @param aText Text to be parsed.
+        * @param aPhonemeSequence Corresponding phoneme sequence. 
+        *        If the sequence is not given, it will be determined automatically.
+        * @param aPhonemeNotation Identifier of phoneme notation. 
+        *		 If the descriptor is empty, the TTS engine will use default notation.
+        * @return Created instance of CTtsParsedText
+        */
+        IMPORT_C static CTtsParsedText* NewL( const TDesC& aText = KNullDesC, 
+            const TDesC8& aPhonemeSequence = KNullDesC8, 
+            const TDesC& aPhonemeNotation = KNullDesC );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CTtsParsedText();
+        
+    public: // New functions
+        
+        /**
+        * Adds new segment and takes its ownership.
+        * @since 2.8
+        * @param aSegment A new segment.
+        * @param aIndex Index where to add segment. If index is equal or larger 
+        *        than NumberOfSegments(), the segment will be added into end.
+        */
+        IMPORT_C void AddSegmentL( const TTtsSegment& aSegment, TInt aIndex = KMaxTInt );
+        
+        /**
+        * Deletes a segment
+        * @since 2.8
+        * @param aIndex The index of segment to be deleted. The index must be 0..NumberOfSegments()-1.
+        */
+        IMPORT_C void DeleteSegmentL( TInt aIndex );
+        
+        /**
+        * Checks that the internal structure is valid. 
+        * @since 2.8
+        * @return ETrue if valid and EFalse if invalid.
+        */
+        IMPORT_C TBool IsValid() const;
+        
+        /**
+        * Returns the number of segments.
+        * @since 2.8
+        * @return The number of segments
+        */
+        IMPORT_C TInt NumberOfSegments() const;
+        
+        /**
+        * Returns phoneme notation definition.
+        * @since 2.8
+        * @return Notation descriptor. KNullDesC8 if none.
+        */
+        IMPORT_C const TDesC& PhonemeNotation() const;
+        
+        /**
+        * Returns phoneme sequence.
+        * @since 2.8
+        * @return Phoneme sequence. KNullDesC8 if none.
+        */
+        IMPORT_C const TDesC8& PhonemeSequence() const;
+        
+        /**
+        * Returns segment from given index
+        * @since 2.8
+        * @param aIndex The index of segment to be returned. The index must be 0..NumberOfSegments()-1.
+        * @return Requested segment.
+        */
+        IMPORT_C const TTtsSegment& SegmentL( TInt aIndex ) const;
+        
+        /**
+        * Sets a phoneme notation. The descriptor is copied and can be released after the function call.
+        * @since 2.8
+        * @param aPhonemeNotation Phoneme notation.
+        */
+        IMPORT_C void SetPhonemeNotationL( const TDesC& aPhonemeNotation );
+        
+        /**
+        * Sets a phoneme sequence. The descriptor is copied and can be released after the function call.
+        * @since 2.8
+        * @param aPhonemeSequence Phoneme sequence.
+        */
+        IMPORT_C void SetPhonemeSequenceL( const TDesC8& aPhonemeSequence );
+        
+        /**
+        * Sets a text. The descriptor is copied and can be released after the function call.
+        * @since 2.8
+        * @param aText Text.
+        */
+        IMPORT_C void SetTextL( const TDesC& aText );
+        
+        /**
+        * Returns text.
+        * @since 2.8
+        * @return Text. KNullDesC8 if none.
+        */
+        IMPORT_C const TDesC& Text() const;
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CTtsParsedText();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( const TDesC& aText, 
+                         const TDesC8& aPhonemeSequence, 
+                         const TDesC& aPhonemeNotation );
+        
+        
+    private: // Data
+    
+        // Implementation for the class
+        CTtsParsedTextBody* iBody;
+        
+        // Reserved pointer for future extension
+        TAny* iReserved;
+        
+    };   
+#endif // TTSCOMMON_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_common_api/nss_tts_common_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="8332dbd77d95cc88d1ad45fb80cda549" dataversion="2.0">
+  <name>NSS TTS Common API</name>
+  <description>Definitions of data classes for TTS</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssttscommon.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_utility_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                NSS TTS Utility API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssttsutilitybase.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttsutilitybase.h)
+../inc/nssttsutility.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttsutility.h)
+../inc/nssttsutilityobserver.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssttsutilityobserver.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_utility_api/inc/nssttsutility.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,598 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility API for client to access TTS functionality.
+*
+*/
+
+
+#ifndef NSSTTSUTILITY_H
+#define NSSTTSUTILITY_H
+
+// INCLUDES
+#include <mdaaudiosampleplayer.h>
+#include <nssttscommon.h>
+#include <nssttsutilitybase.h>
+#include <nssttsutilityobserver.h>
+
+// FORWARD DECLARATIONS
+class CTtsUtilityBody;
+
+// CLASS DECLARATION
+
+/**
+* Tts Utility interface.  
+*
+* @lib nssttsutility.lib
+* @since 2.8
+*/
+class CTtsUtility : public CBase, public MTtsUtilityBase
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @since 2.8
+        * @param "MTtsClientUtilityObserver& aObserver" Observer reference.
+        * @return Pointer to created object.
+        */
+        IMPORT_C static CTtsUtility* NewL( MTtsClientUtilityObserver& aObserver );
+ 
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CTtsUtility();
+
+        /*
+        * Creates instance of CTtsUtility
+        * Needed when dynamically loading nssttsutility.dll
+        * Direct users of nssttsutility.lib should not use this.
+        * Returns M-class pointer to MTtsUtilityBase as TAny*        
+        *
+        * @return Created instance
+        * @see CreateInstanceSecondPhaseL
+        */
+        IMPORT_C static TAny* CreateInstanceL();
+
+        /**
+        * Does the second phase initialization of CTtsUtility
+        * Needed when dynamically loading nssttsutility.dll
+        * Direct users of nssttsutility.lib should not use this        
+        *
+        * @param "const MTtsClientUtilityObserver& aObserver" Observer reference
+        */
+        IMPORT_C void CreateInstanceSecondPhaseL( MTtsClientUtilityObserver& aObserver );   
+        
+    public: // New functions in 3.2
+
+        /**
+        * Opens connection to a specific plugin.
+        *
+        * @param "TUid aUid" Plugin UID which will be instantiated
+        * @since 3.2        
+        */
+        IMPORT_C void OpenPluginL( TUid aUid );
+        
+        /**
+        * Lists UIDs of available Text-To-Speech plugins.
+        *
+        * @param "RArray<TUid>& aUids" Output parameter which will contain the
+        *                              list of plugin UIDs after function call.
+        * @since 3.2         
+        */
+        IMPORT_C void ListPluginsL( RArray<TUid>& aUids );              
+                       
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        * @since 3.2        
+        */
+        IMPORT_C void SetDefaultStyleL( const TTtsStyle& aStyle );
+        
+        /**
+        * Returns the registered default style
+        *
+        * @return Style reference
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2             
+        */
+        IMPORT_C TTtsStyle& DefaultStyleL();
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @param TInt aRate Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @since 3.2        
+        */        
+        IMPORT_C void SetSpeakingRateL( TInt aRate );
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        IMPORT_C TInt SpeakingRateL();
+       
+        /**
+        * Open a descriptor ready for playback
+        *
+        * @param "const TDesC& aDescriptor" Descriptor containing the text to be synthesized.
+        * @since 3.2        
+        */
+        IMPORT_C void OpenDesL( const TDesC& aDescriptor ); 
+
+        /**
+        * Opens a descriptor and plays it.
+        *
+        * @param "const TDesC& aDescriptor" Descriptor to play 
+        * @since 3.2        
+        */
+        IMPORT_C void OpenAndPlayDesL( const TDesC& aDescriptor );  
+        
+        /**
+        * Returns the list of supported languages.
+        * 
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which contains the languages
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        IMPORT_C void GetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+        
+        /**
+        * Returns the list of supported voices for a certain language.
+        * 
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TTtsStyle>& aVoices" Output parameter which contains the voices
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2
+        */        
+        IMPORT_C void GetSupportedVoicesL( TLanguage aLanguage, RArray<TTtsStyle>& aVoices );
+        
+        /**
+        * Sets data sink to be a file for the next synthesis event
+        *
+        * @param "RFile& aFile" Open file handle where the output is written 
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2
+        */
+        IMPORT_C void SetOutputFileL( const RFile& aFile ); 
+        
+    public: // New functions          
+        
+        /**
+        * Adds new style to style collection.
+        *
+        * @since 2.8
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Assigned style ID.
+        */
+        IMPORT_C TTtsStyleID AddStyleL( const TTtsStyle& aStyle );
+
+        /**
+        * Deletes style from the style collection.
+        *
+        * @since 2.8
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Error code.
+        */
+        IMPORT_C TInt DeleteStyle( TTtsStyleID aID );
+
+        /**
+        * Returns number of styles.
+        *
+        * @since 2.8
+        * @return Number of styles.
+        */
+        IMPORT_C TUint16 NumberOfStyles();
+
+        /**
+        * Returns style based on style ID
+        *
+        * @since 2.8
+        * @param "TTtsStyleID aStyleID" Style identifier.
+        * @return Reference to found style.
+        */
+        IMPORT_C TTtsStyle& StyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Returns style based on index.
+        *
+        * @since 2.8
+        * @param "TUint16 aIndex" Index.
+        * @return Reference to found style.
+        */
+        IMPORT_C TTtsStyle& StyleL( TUint16 aIndex );
+
+        /**
+        * Begins playback of the initialised audio sample at the current volume
+        * and priority levels.
+        *
+        * When playing of the audio sample is complete, successfully or
+        * otherwise, the callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is
+        * called. 
+        *
+        * @since 2.8
+        */
+        IMPORT_C void Play();
+
+        /**
+        * Stops playback of the audio sample as soon as possible.
+        *
+        * If the audio sample is playing, playback is stopped as soon as
+        * possible. If playback is already complete, nothing further happens as
+        * a result of calling this function. The callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is not
+        * called.
+        *
+        * @since 2.8
+        */
+        IMPORT_C void Stop();
+        
+        /**
+        * Changes the current playback volume to a specified value.
+        *
+        * The volume can be changed before or during playback and is effective
+        * immediately. The function raises a CMdaAudioPlayerUtility 1 panic if
+        * the audio player utility is not initialised.
+        *
+        * @since 2.8
+        * @param	"TInt aVolume"
+        *          The volume setting. This can be any value from zero to
+        *          the value returned by a call to
+        *          <code>CMdaAudioPlayerUtility::MaxVolume()</code>.
+        *          Setting a zero value mutes the sound. Setting the
+        *          maximum value results in the loudest possible sound.
+        */
+        IMPORT_C void SetVolume( TInt aVolume );
+        
+        /**
+        * Sets the number of times the audio sample is to be repeated during the
+        * playback operation.
+        *
+        * A period of silence can follow each playing of the sample. The audio
+        * sample can be repeated indefinitely.
+        *
+        * @since 2.8
+        * @param	"TInt aRepeatNumberOfTimes"
+        *          The number of times the audio sample, together with
+        *          the trailing silence, is to be repeated. If this is
+        *          set to <code>KMdaRepeatForever</code>, then the audio
+        *          sample, together with the trailing silence, is
+        *          repeated indefinitely or until <code>Stop()</code> is
+        *          called. If this is set to zero, then the audio sample
+        *          is not repeated.
+        * @param   "const TTimeIntervalMicroSeconds& aTrailingSilence"
+        *          The time interval of the trailing silence.
+        */
+        IMPORT_C void SetRepeats( TInt aRepeatNumberOfTimes, 
+                                  const TTimeIntervalMicroSeconds& aTrailingSilence );
+        
+        /**
+        * Returns the duration of the audio sample.
+        *
+        * The function raises a CMdaAudioPlayerUtility 1 panic if the audio
+        * player utility is not initialised.
+        *
+        * @since 2.8
+        * @returns "TTimeIntervalMicroSeconds&"
+        *          The duration in microseconds
+        */
+        IMPORT_C const TTimeIntervalMicroSeconds& Duration();
+        
+        /**
+        * Returns an integer representing the maximum volume.
+        *
+        * This is the maximum value which can be passed to
+        * <code>CMdaAudioPlayerUtility::SetVolume()</code>. The function raises a
+        * CMdaAudioPlayerUtility 1 panic if the audio player utility is not
+        * initialised.
+        *
+        * @since 2.8
+        * @returns "TInt"
+        *          The maximum volume. This value is platform dependent
+        *          but is always greater than or equal to one.
+        */
+        IMPORT_C TInt MaxVolume();
+        
+        /**
+        * Opens a descriptor source and plays it.
+        *
+        * @since 2.8
+        * @param "TDesC8& aDescriptor" Descriptor to play (in UTF-8 format).
+        */
+        IMPORT_C void OpenAndPlayDesL( const TDesC8& aDescriptor );
+
+        /**
+        * Opens a file source and plays it.
+        *
+        * @since 2.8
+        * @param "TDesC& aFileName" File to play.
+        */
+        IMPORT_C void OpenAndPlayFileL( const TDesC& aFileName );
+
+        /**
+        * Opens a parsed text source and plays it.
+        *
+        * @since 2.8
+        * @param "CTtsParsedText& aText" Parsed text object to play.
+        */
+        IMPORT_C void OpenAndPlayParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Open a clip from a file
+        *
+        * @since 2.8
+        * @param	"const TDesC& aFileName" 
+        *			File to open
+        * @leave	Leaves with one of the system wide error codes if a problem is encountered
+        *			opening the file
+        */
+        IMPORT_C void OpenFileL( const TDesC& aFileName );
+
+        /**
+        * Open a clip from a descriptor
+        *
+        * @since 2.8
+        * @param	"const TDesC8& aDescriptor" 
+        *			Descriptor containing audio clip
+        * @leave	Leaves with one of the system wide error codes if a problem is encountered
+        *			opening the file
+        */
+        IMPORT_C void OpenDesL( const TDesC8& aDescriptor );
+
+        /**
+        * Open parsed text source.
+        *
+        * @since 2.8
+        * @param "CTtsParsedText& aText" Reference to parsed text object.
+        */
+        IMPORT_C void OpenParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Pauses playback of text to speech
+        *
+        * @since 2.8
+        * @returns One of the system-wide error codes
+        */
+        IMPORT_C TInt Pause();
+        
+        /**
+        * Closes the connection to the controller plugin.
+        *
+        * @since 2.8
+        */
+        IMPORT_C void Close();
+        
+        /**
+        * Returns the current playback position in microseconds
+        *
+        * @since 2.8
+        * @retval "TTimeIntervalMicroSeconds& aPosition"
+        *          The current time position in microseconds from the start of the file
+        * @returns One of the global error codes
+        */
+        IMPORT_C TInt GetPosition( TTimeIntervalMicroSeconds& aPosition );
+        
+        /**
+        * Returns the current playback position in word index.
+        *
+        * @since 2.8
+        * @retval "TInt& aWordIndex" The current position in words.
+        * @return Error code.
+        */
+        IMPORT_C TInt GetPosition( TInt& aWordIndex );
+
+        /**
+        * Set the current playback position in microseconds from the start of the file
+        *
+        * @since 2.8
+        * @param "TTimeIntervalMicroSeconds& aPosition"
+        *          The position to move to in microseconds past the start of the file
+        */
+        IMPORT_C void SetPosition( const TTimeIntervalMicroSeconds& aPosition );
+        
+        /**
+        * Set the current playback position in word index.
+        *
+        * @since 2.8
+        * @param "TInt aWordIndex" Playback position.
+        */
+        IMPORT_C void SetPosition( TInt aWordIndex );
+
+        /**
+        *
+        * Set the priority for playback. This is used to arbitrate between multiple 
+        * objects trying to access a single sound device
+        *
+        * @since 2.8
+        * @param "TInt aPriority" Audio priority for playback
+        * @param "TMdaPriorityPreference aPref" Preference value for playback
+        * 
+        * @returns "TInt" One of the global error codes
+        */
+        IMPORT_C TInt SetPriority( TInt aPriority, TMdaPriorityPreference aPref );
+        
+        /**
+        * Returns the current playback volume
+        *
+        * @since 2.8
+        * @retval "TInt& aVolume"
+        *          A volume value between 0 and the value returned by <code>MaxVolume()</code>
+        * @returns "TInt" One of the global error codes
+        */
+        IMPORT_C TInt GetVolume( TInt& aVolume );
+        
+        /**
+        * Sets the current playback balance
+        *
+        * @since 2.8
+        * @param "TInt& aBalance"
+        *        A value between <code>KMMFBalanceMaxLeft</code> 
+        *        and <code>KMMFBalanceMaxRight</code>. The default value is 
+        *        <code>KMMFBalanceCenter</code>
+        * @returns "TInt" One of the global error codes
+        */
+        IMPORT_C TInt SetBalance( TInt aBalance = KMMFBalanceCenter );
+        
+        /**
+        * Returns the current playback balance
+        *
+        * @since 2.8
+        * @retval "TInt& aBalance"
+        *         A value between <code>KMMFBalanceMaxLeft</code> 
+        *         and <code>KMMFBalanceMaxRight</code>
+        * @returns "TInt" One of the global error codes
+        */
+        IMPORT_C TInt GetBalance( TInt& aBalance );
+        
+        /**
+        * Send a synchronous custom command to the controller
+        *
+        * @since 2.8
+        * @param "aDestination"	"The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataFrom" "A reference to an area of memory to which the controller framework will 
+        *        write any data to be passed back to the client.  Can't be KNullDesC8."
+        * @return "The result of the request. Exact range of values is dependent on the interface."
+        */
+        IMPORT_C TInt CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2, 
+                                         TDes8& aDataFrom);
+        /**
+        * Send a synchronous custom command to the controller
+        *
+        * @since 2.8
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *		 the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *         framework. The exact contents of the data are dependent on the 
+        *         interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *         framework. The exact contents of the data are dependent on the 
+        *         interface being called.  Can be KNullDesC8."
+        * @return "The result of the request. Exact range of values is dependent on the interface."
+        */
+        IMPORT_C TInt CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2 );
+        /**
+        * Send a asynchronous custom command to the controller
+        * Note: This method will return immediately.  The RunL of the active object owning the 
+        * <code>aStatus<\code> parameter will be called when the command is completed by the 
+        * controller framework.
+        *
+        * @since 2.8
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataFrom" "A reference to an area of memory to which the controller framework will 
+        *        write any data to be passed back to the client.  Can't be KNullDesC8."
+        * @param "aStatus" "The TRequestStatus of an active object.  This will contain the 
+        *        result of the request on completion.  The exact range of 
+        *        result values is dependent on the interface."
+        */
+        IMPORT_C void CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination,  
+                                          TInt aFunction, 
+                                          const TDesC8& aDataTo1, 
+                                          const TDesC8& aDataTo2, 
+                                          TDes8& aDataFrom, 
+                                          TRequestStatus& aStatus );
+        /**
+        * Send a asynchronous custom command to the controller
+        * Note: This method will return immediately.  The RunL of the active object owning the 
+        * <code>aStatus<\code> parameter will be called when the command is completed by the 
+        * controller framework.
+        *
+        * @since 2.8
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aStatus" "The TRequestStatus of an active object.  This will contain the 
+        *        result of the request on completion.  The exact range of 
+        *        result values is dependent on the interface."
+        */
+        IMPORT_C void CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination, 
+                                          TInt aFunction, 
+                                          const TDesC8& aDataTo1, 
+                                          const TDesC8& aDataTo2, 
+                                          TRequestStatus& aStatus );
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        *
+        * @since 2.8
+        */
+        CTtsUtility();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        * 
+        * @since 2.8
+        * @param "MTtsClientUtilityObserver& aObserver" Observer reference.
+        */
+        void ConstructL( MTtsClientUtilityObserver& aObserver );
+        
+        // Prohibit copy constructor
+        CTtsUtility( const CTtsUtility& );
+        // Prohibit assigment operator
+        CTtsUtility& operator=( const CTtsUtility& );
+        
+    private: // Data
+
+        // Real implementation
+        CTtsUtilityBody* iBody;
+
+        // Reserved pointer for future extension
+        TAny* iReserved;
+        
+    };
+
+#endif // NSSTTSUTILITY_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_utility_api/inc/nssttsutilitybase.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,541 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for TTS Utility API
+*
+*/
+
+
+#ifndef NSSTTSUTILITYBASE_H
+#define NSSTTSUTILITYBASE_H
+
+// INCLUDES
+#include <mdaaudiosampleplayer.h>
+#include <nssttscommon.h>
+#include <nssttsutilityobserver.h>
+
+// CLASS DECLARATION
+
+/**
+* Tts Utility interface.  
+*
+* @since 3.1
+*/
+class MTtsUtilityBase
+    {
+    public: // New functions
+        
+        /**
+        * 2nd phase constructor which can be called from outside.
+        * 
+        * @since 3.1
+        * @param "const MTtsClientUtilityObserver& aObserver" Observer reference.
+        */
+        virtual void CreateInstanceSecondPhaseL( MTtsClientUtilityObserver& aObserver ) = 0;   
+        
+        /**
+        * Destructor. Defined here so that client can use M-class pointer to destroy
+        * the concrete C-object
+        */                                         
+        virtual ~MTtsUtilityBase() {};        
+        
+        /**
+        * Opens connection to a specific plugin.
+        *
+        * @param "TUid aUid" Plugin UID which will be instantiated
+        * @since 3.2        
+        */
+        virtual void OpenPluginL( TUid aUid ) = 0;
+        
+        /**
+        * Lists UIDs of available Text-To-Speech plugins.
+        *
+        * @param "RArray<TUid>& aUids" Output parameter which will contain the
+        *                              list of plugin UIDs after function call.
+        * @since 3.2         
+        */
+        virtual void ListPluginsL( RArray<TUid>& aUids ) = 0;              
+                       
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        * @since 3.2        
+        */
+        virtual void SetDefaultStyleL( const TTtsStyle& aStyle ) = 0;
+        
+        /**
+        * Returns the registered default style
+        *
+        * @return Style reference
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2             
+        */
+        virtual TTtsStyle& DefaultStyleL() = 0;
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @param TInt aRate Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @since 3.2        
+        */        
+        virtual void SetSpeakingRateL( TInt aRate ) = 0;
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        virtual TInt SpeakingRateL() = 0;
+       
+        /**
+        * Open a descriptor ready for playback
+        *
+        * @param "const TDesC& aDescriptor" Descriptor containing the text to be synthesized.
+        * @since 3.2        
+        */
+        virtual void OpenDesL( const TDesC& aDescriptor ) = 0; 
+
+        /**
+        * Opens a descriptor and plays it.
+        *
+        * @param "const TDesC& aDescriptor" Descriptor to play 
+        * @since 3.2        
+        */
+        virtual void OpenAndPlayDesL( const TDesC& aDescriptor ) = 0;    
+        
+        /**
+        * Returns the list of supported languages.
+        * 
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which contains the languages
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        virtual void GetSupportedLanguagesL( RArray<TLanguage>& aLanguages ) = 0;
+        
+        /**
+        * Returns the list of supported voices for a certain language.
+        * 
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TTtsStyle>& aVoices" Output parameter which contains the voices
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2
+        */        
+        virtual void GetSupportedVoicesL( TLanguage aLanguage, RArray<TTtsStyle>& aVoices ) = 0;        
+        
+        /**
+        * Sets data sink to be a file for the next synthesis event
+        *
+        * @param "RFile& aFile" Open file handle where the output is written
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2
+        */
+        virtual void SetOutputFileL( const RFile& aFile ) = 0; 
+        
+        /**
+        * Adds new style to style collection.
+        *
+        * @since 3.1
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Assigned style ID.
+        */
+        virtual TTtsStyleID AddStyleL( const TTtsStyle& aStyle ) = 0;
+
+        /**
+        * Deletes style from the style collection.
+        *
+        * @since 3.1
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Error code.
+        */
+        virtual TInt DeleteStyle( TTtsStyleID aID ) = 0;
+
+        /**
+        * Returns number of styles.
+        *
+        * @since 3.1
+        * @return Number of styles.
+        */
+        virtual TUint16 NumberOfStyles() = 0;
+
+        /**
+        * Returns style based on style ID
+        *
+        * @since 3.1
+        * @param "TTtsStyleID aStyleID" Style identifier.
+        * @return Reference to found style.
+        */
+        virtual TTtsStyle& StyleL( TTtsStyleID aStyleID ) = 0;
+
+        /**
+        * Returns style based on index.
+        *
+        * @since 3.1
+        * @param "TUint16 aIndex" Index.
+        * @return Reference to found style.
+        */
+        virtual TTtsStyle& StyleL( TUint16 aIndex ) = 0;
+
+        /**
+        * Begins playback of the initialised audio sample at the current volume
+        * and priority levels.
+        *
+        * When playing of the audio sample is complete, successfully or
+        * otherwise, the callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is
+        * called. This function raises a CMdaAudioPlayerUtility 1 panic if the
+        * audio player utility is not initialised.
+        *
+        * @since 3.1
+        */
+        virtual void Play() = 0;
+
+        /**
+        * Stops playback of the audio sample as soon as possible.
+        *
+        * If the audio sample is playing, playback is stopped as soon as
+        * possible. If playback is already complete, nothing further happens as
+        * a result of calling this function. The callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is not
+        * called.The function raises a CMdaAudioPlayerUtility 1 panic if the
+        * audio player utility is not initialised.
+        *
+        * @since 3.1
+        */
+        virtual void Stop() = 0;
+        
+        /**
+        * Changes the current playback volume to a specified value.
+        *
+        * The volume can be changed before or during playback and is effective
+        * immediately. The function raises a CMdaAudioPlayerUtility 1 panic if
+        * the audio player utility is not initialised.
+        *
+        * @since 3.1
+        * @param	"TInt aVolume"
+        *          The volume setting. This can be any value from zero to
+        *          the value returned by a call to
+        *          <code>CMdaAudioPlayerUtility::MaxVolume()</code>.
+        *          Setting a zero value mutes the sound. Setting the
+        *          maximum value results in the loudest possible sound.
+        */
+        virtual void SetVolume( TInt aVolume ) = 0;
+        
+        /**
+        * Sets the number of times the audio sample is to be repeated during the
+        * playback operation.
+        *
+        * A period of silence can follow each playing of the sample. The audio
+        * sample can be repeated indefinitely.
+        *
+        * @since 3.1
+        * @param	"TInt aRepeatNumberOfTimes"
+        *          The number of times the audio sample, together with
+        *          the trailing silence, is to be repeated. If this is
+        *          set to <code>KMdaRepeatForever</code>, then the audio
+        *          sample, together with the trailing silence, is
+        *          repeated indefinitely or until <code>Stop()</code> is
+        *          called. If this is set to zero, then the audio sample
+        *          is not repeated.
+        * @param   "const TTimeIntervalMicroSeconds& aTrailingSilence"
+        *          The time interval of the trailing silence.
+        */
+        virtual void SetRepeats( TInt aRepeatNumberOfTimes, 
+                                 const TTimeIntervalMicroSeconds& aTrailingSilence ) = 0;
+        
+        /**
+        * Returns the duration of the audio sample.
+        *
+        * The function raises a CMdaAudioPlayerUtility 1 panic if the audio
+        * player utility is not initialised.
+        *
+        * @since 3.1
+        * @returns "TTimeIntervalMicroSeconds&"
+        *          The duration in microseconds
+        */
+        virtual const TTimeIntervalMicroSeconds& Duration() = 0;
+        
+        /**
+        * Returns an integer representing the maximum volume.
+        *
+        * This is the maximum value which can be passed to
+        * <code>CMdaAudioPlayerUtility::SetVolume()</code>. The function raises a
+        * CMdaAudioPlayerUtility 1 panic if the audio player utility is not
+        * initialised.
+        *
+        * @since 3.1
+        * @returns "TInt"
+        *          The maximum volume. This value is platform dependent
+        *          but is always greater than or equal to one.
+        */
+        virtual TInt MaxVolume() = 0;
+        
+        /**
+        * Opens a descriptor source and plays it.
+        *
+        * @since 3.1
+        * @param "TDesC8& aDescriptor" Descriptor to play.
+        */
+        virtual void OpenAndPlayDesL( const TDesC8& aDescriptor ) = 0;
+
+        /**
+        * Opens a file source and plays it.
+        *
+        * @since 3.1
+        * @param "TDesC& aFileName" File to play.
+        */
+        virtual void OpenAndPlayFileL( const TDesC& aFileName ) = 0;
+
+        /**
+        * Opens a parsed text source and plays it.
+        *
+        * @since 3.1
+        * @param "CTtsParsedText& aText" Parsed text object to play.
+        */
+        virtual void OpenAndPlayParsedTextL( CTtsParsedText& aText ) = 0;
+
+        /**
+        * Open a clip from a file
+        *
+        * @since 3.1
+        * @param	"const TDesC& aFileName" 
+        *			File to open
+        * @leave	Leaves with one of the system wide error codes if a problem is encountered
+        *			opening the file
+        */
+        virtual void OpenFileL( const TDesC& aFileName ) = 0;
+
+        /**
+        * Open a clip from a descriptor
+        *
+        * @since 3.1
+        * @param	"const TDesC8& aDescriptor" 
+        *			Descriptor containing audio clip
+        * @leave	Leaves with one of the system wide error codes if a problem is encountered
+        *			opening the file
+        */
+        virtual void OpenDesL( const TDesC8& aDescriptor ) = 0;
+
+        /**
+        * Open parsed text source.
+        *
+        * @since 3.1
+        * @param "CTtsParsedText& aText" Reference to parsed text object.
+        */
+        virtual void OpenParsedTextL( CTtsParsedText& aText ) = 0;
+
+        /**
+        * Pauses playback of the audio clip
+        *
+        * @since 3.1
+        * @returns One of the system-wide error codes
+        */
+        virtual TInt Pause() = 0;
+        
+        /**
+        * Closes the current audio clip (allowing another clip to be opened)
+        *
+        * @since 3.1
+        */
+        virtual void Close() = 0;
+        
+        /**
+        * Returns the current playback position in microseconds
+        *
+        * @since 3.1
+        * @retval "TTimeIntervalMicroSeconds& aPosition"
+        *          The current time position in microseconds from the start of the file
+        * @returns One of the global error codes
+        */
+        virtual TInt GetPosition( TTimeIntervalMicroSeconds& aPosition ) = 0;
+        
+        /**
+        * Returns the current playback position in word index.
+        *
+        * @since 3.1
+        * @retval "TInt& aWordIndex" The current position in words.
+        * @return Error code.
+        */
+        virtual TInt GetPosition( TInt& aWordIndex ) = 0;
+
+        /**
+        * Set the current playback position in microseconds from the start of the file
+        *
+        * @since 3.1
+        * @param "TTimeIntervalMicroSeconds& aPosition"
+        *          The position to move to in microseconds past the start of the file
+        */
+        virtual void SetPosition( const TTimeIntervalMicroSeconds& aPosition ) = 0;
+        
+        /**
+        * Set the current playback position in word index.
+        *
+        * @since 3.1
+        * @param "TInt aWordIndex" Playback position.
+        */
+        virtual void SetPosition( TInt aWordIndex ) = 0;
+
+        /**
+        *
+        * Set the priority for playback. This is used to arbitrate between multiple 
+        * objects trying to access a single sound device
+        *
+        * @since 3.1
+        * @param "TInt aPriority"
+        * @param "TMdaPriorityPreference aPref"
+        *         Quality/time preference tradeoff
+        * 
+        * @returns "TInt" One of the global error codes
+        */
+        virtual TInt SetPriority( TInt aPriority, TMdaPriorityPreference aPref ) = 0;
+        
+        /**
+        * Returns the current playback volume
+        *
+        * @since 3.1
+        * @retval "TInt& aVolume"
+        *          A volume value between 0 and the value returned by <code>MaxVolume()</code>
+        * @returns "TInt" One of the global error codes
+        */
+        virtual TInt GetVolume( TInt& aVolume ) = 0;
+        
+        /**
+        * Sets the current playback balance
+        *
+        * @since 3.1
+        * @param "TInt& aBalance"
+        *        A value between <code>KMMFBalanceMaxLeft</code> 
+        *        and <code>KMMFBalanceMaxRight</code>. The default value is 
+        *        <code>KMMFBalanceCenter</code>
+        * @returns "TInt" One of the global error codes
+        */
+        virtual TInt SetBalance( TInt aBalance = KMMFBalanceCenter ) = 0;
+        
+        /**
+        * Returns the current playback balance
+        *
+        * @since 3.1
+        * @retval "TInt& aBalance"
+        *         A value between <code>KMMFBalanceMaxLeft</code> 
+        *         and <code>KMMFBalanceMaxRight</code>
+        * @returns "TInt" One of the global error codes
+        */
+        virtual TInt GetBalance( TInt& aBalance ) = 0;
+        
+        /**
+        * Send a synchronous custom command to the controller
+        *
+        * @since 3.1
+        * @param "aDestination"	"The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataFrom" "A reference to an area of memory to which the controller framework will 
+        *        write any data to be passed back to the client.  Can't be KNullDesC8."
+        * @return "The result of the request. Exact range of values is dependent on the interface."
+        */
+        virtual TInt CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                        TInt aFunction, 
+                                        const TDesC8& aDataTo1, 
+                                        const TDesC8& aDataTo2, 
+                                        TDes8& aDataFrom) = 0;
+        /**
+        * Send a synchronous custom command to the controller
+        *
+        * @since 3.1
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *		 the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *         framework. The exact contents of the data are dependent on the 
+        *         interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *         framework. The exact contents of the data are dependent on the 
+        *         interface being called.  Can be KNullDesC8."
+        * @return "The result of the request. Exact range of values is dependent on the interface."
+        */
+        virtual TInt CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                        TInt aFunction, 
+                                        const TDesC8& aDataTo1, 
+                                        const TDesC8& aDataTo2 ) = 0;
+        /**
+        * Send a asynchronous custom command to the controller
+        * Note: This method will return immediately.  The RunL of the active object owning the 
+        * <code>aStatus<\code> parameter will be called when the command is completed by the 
+        * controller framework.
+        *
+        * @since 3.1
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataFrom" "A reference to an area of memory to which the controller framework will 
+        *        write any data to be passed back to the client.  Can't be KNullDesC8."
+        * @param "aStatus" "The TRequestStatus of an active object.  This will contain the 
+        *        result of the request on completion.  The exact range of 
+        *        result values is dependent on the interface."
+        */
+        virtual void CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination,  
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2, 
+                                         TDes8& aDataFrom, 
+                                         TRequestStatus& aStatus ) = 0;
+        /**
+        * Send a asynchronous custom command to the controller
+        * Note: This method will return immediately.  The RunL of the active object owning the 
+        * <code>aStatus<\code> parameter will be called when the command is completed by the 
+        * controller framework.
+        *
+        * @since 3.1
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aStatus" "The TRequestStatus of an active object.  This will contain the 
+        *        result of the request on completion.  The exact range of 
+        *        result values is dependent on the interface."
+        */
+        virtual void CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2, 
+                                         TRequestStatus& aStatus ) = 0;
+    };
+
+#endif // NSSTTSUTILITYBASE_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_utility_api/inc/nssttsutilityobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Observer mixin class for TtsUtility
+*
+*/
+
+
+#ifndef NSSTTSUTILITYOBSERVER_H
+#define NSSTTSUTILITYOBSERVER_H
+
+// INCLUDES
+#include <mdaaudiosampleplayer.h>
+
+// CLASS DECLARATION
+
+/**
+* Tts Utility callback observer
+*
+* @lib nssttsutility.lib
+* @since 2.8
+*/
+class MTtsClientUtilityObserver : public MMdaAudioPlayerCallback
+    {
+    public:
+        /**
+        * Called when asynchronous custom command finishes.
+        *
+        * @since 2.8
+        * @param "TInt aEvent" Event code.
+        * @param "TInt aError" Error code.
+        */
+        virtual void MapcCustomCommandEvent( TInt aEvent, TInt aError ) = 0;
+    };
+
+#endif // NSSTTSUTILITYOBSERVER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/nss_tts_utility_api/nss_tts_utility_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="98e210801116e9c582466dc15976dfac" dataversion="2.0">
+  <name>NSS TTS Utility API</name>
+  <description>Client API for speech synthesis</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssttsutility.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/recognition_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Recognition HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsrecognitionhwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsrecognitionhwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/recognition_hw_device_api/inc/asrsrecognitionhwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,254 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     HW Device for speech recognition
+*
+*/
+
+
+
+
+
+
+#ifndef ASRSRECOGNITIONHWDEVICE_H
+#define ASRSRECOGNITIONHWDEVICE_H
+
+//  INCLUDES
+#include <asrshwdevice.h>
+
+// FORWARD DECLARATIONS
+class CSDModelBank;
+class CSIModelBank;
+class CRecognitionAlgorithm;
+
+// CLASS DECLARATION
+/**
+*  Observer for recognition HW device
+*
+*  @lib asrsrecognitionhwdevice.lib
+*  @since 2.8
+*/
+class MASRSRecognitionHwDeviceObserver 
+    {
+        
+    public: // New functions
+        
+        /**
+        * Called by the hardware device when the InitializeL() method has completed.
+        * @since 2.8
+        * @param aError Initialization result code. 
+        *               KErrNone if successful otherwise a system-wide error code.
+        * @return none
+        */
+        virtual void MarhdoInitializationComplete( TInt aError ) = 0;
+
+        /**
+        * Called by the hardware device when the  InitializeL() method has completed.
+        * @since 2.8
+        * @param aError Initialization result code. 
+        *               KErrNone if successful otherwise a system-wide error code.
+        * @return none
+        */
+        virtual void MarhdoInitRecognizerFEComplete( TInt aError ) = 0;
+
+        /**
+        * Called by the hardware device when backend initialization is completed.
+        * @since 2.8
+        * @param aError Initialization result code. 
+        *               KErrNone if successful otherwise a system-wide error code.
+        * @return none
+        */
+        virtual void MarhdoInitRecognizerBEComplete( TInt aError ) = 0;
+
+        /**
+        * Called by the hardware device when recognition result is available.
+        * @since 2.8
+        * @param aError Recognition result code. KErrNone if successful.  
+        *               KErrRejected if the recognition result is rejected, 
+        *               otherwise a system-wide error code
+        * @return none
+        */ 
+        virtual void MarhdoRecognitionComplete( TInt aError ) = 0;
+
+        /**
+        * Called by the hardware device when end-of-utterance is detected by the 
+        * acoustic frontend. This method must be called before MarhdoRecognitionComplete().
+        * @since 2.8
+        * @param aError Recognition result code. KErrNone if successful, otherwise KErrTooLong, 
+        *               KErrTooShort, KErrAsrSpeechTooEarly, KErrNoSpeech
+        * @return none
+        */
+        virtual void MarhdoEouDetected( TInt aError ) = 0;
+
+        /**
+        * Called by the hardware device when a feature vector is extracted by acoustic frontend.
+        * @since 2.8
+        * @param aFV A buffer containing a feature vector.
+        * @param aSNR Signal-to-noise ratio.
+        * @param aPosition Indicates whether this is the first, subsequent or last feature vector in a series.
+        * @return none
+        */
+        virtual void MarhdoFeatureVector( const TDesC8& aFV, TInt32 aSNR, TInt32 aPosition ) = 0;
+
+        /**
+        * Called by the hardware device to request for utterance data. 
+        * The response to the request is sent in SendSpeechData().
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        virtual void MarhdoRequestSpeechData () = 0;
+    };
+
+/**
+*  Recognition HW Device
+*
+*  @lib asrsrecognitionhwdevice.lib
+*  @since 2.8
+*/
+class CASRSRecognitionHwDevice : public CASRSHwDevice
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CASRSRecognitionHwDevice* NewL( MASRSRecognitionHwDeviceObserver& aObserver );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CASRSRecognitionHwDevice();
+        
+    public: // New functions
+        
+        /**
+        * This method initializes the backend of the recognition Hw device.
+        * @since 2.8
+        * @param aRecognitionData A recognition data generated by grammar compilation.
+        * @param aModels A model bank containing acoustic models 
+        * @return none
+        */
+        IMPORT_C void InitRecognizerBEL( const TDesC8& aRecognitionData, 
+                               const CSIModelBank& aModels );
+
+        /**
+        * This method initialize the frontend of the recognition Hwdevice
+        * @since 2.8
+        * @param none
+        * @return none
+        */  
+        IMPORT_C void InitRecognizerFEL( TBool aSendFeatureVectors = EFalse );
+
+        /**
+        * Sets the maximum number of entries wanted in the ranked list of recognition results. 
+        * @since 2.8
+        * @param aNBest The n-best number.
+        * @return none
+        */ 
+    	IMPORT_C void SetNBest( TUint32 aNBest );
+    	
+    	/**
+        * Sets the rejection threshold. 
+        * @since 3.2
+        * @param aRejection Rejection threshold value.
+        * @return none
+        */ 
+    	IMPORT_C void SetRejection( TUint32 aRejection );
+    	
+    	/**
+        * Gets the rejection threshold. 
+        * @since 2.8
+        * @param none
+        * @return Rejection threshold value.
+        */ 
+    	IMPORT_C TUint32 GetRejection();
+
+        /**
+        * Start recognition
+        * @since 2.8
+        * @param aNBestList At the end of recognition, this object will contain Nbest list IDs.
+        * @param aScore At the end of recognition, this object will contain scores for Nbest list.
+        * @param aSendFeatureVectors ETrue send feature vector to client, EFalse do not send feature vector to client.
+        * @return none
+        */ 
+        IMPORT_C void StartRecognitionL( RArray<TUint>& aNBestList, RArray<TInt>& aScore );
+
+        /**
+        * Stop a started recognition process.
+        * @since 2.8
+        * @param none
+        * @return none
+        */ 
+        IMPORT_C void StopRecognition();
+ 
+        /**
+        * Use to send utterance data
+        * @since 2.8
+        * @param aBuffer Buffer containing utterance data.
+        * @param aEnd End of utterance data indicator. ETrue indicates end of data or no data.
+        * @return none
+        */ 
+        IMPORT_C void SendSpeechData( TPtrC8& aBuffer, TBool aEnd );
+        
+    public: // Functions from base classes
+
+        /**
+        * From CASRSHwDevice Use to initilize HW device
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C virtual void InitializeL();
+
+        /**
+        * From CASRSHwDevice Use to clear HW device
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C virtual void Clear();
+
+		/**
+        * From CASRSHwDevice Use to get custom interface
+        * @since 2.8
+        * @param aInterfaceId Identifier of the intercace implementation
+        * @return Pointer to the interface implementation or NULL.
+        */
+        IMPORT_C virtual TAny* CustomInterface( TUid aInterfaceId );
+               
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CASRSRecognitionHwDevice();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( MASRSRecognitionHwDeviceObserver& aObserver );
+                
+    private:    // Data
+
+        // Actual implementation of recognition
+        CRecognitionAlgorithm* iRecAlgorithm;
+        
+        // Reserved pointer for future extension
+        TAny* iReserved;
+        
+    };
+
+#endif      // ASRSRECOGNITIONHWDEVICE  
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/recognition_hw_device_api/recognition_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="b69ede9e78d066e62c1f0f1cae18d6c8" dataversion="2.0">
+  <name>Recognition HW Device API</name>
+  <description>Interface for speech recognition algorithm</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="asrsrecognitionhwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/speech_synthesis_clientserver_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                speech synthesis clientserver api
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/speechsynthesis.h             APP_LAYER_PLATFORM_EXPORT_PATH( speechsynthesis.h )
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/speech_synthesis_clientserver_api/inc/speechsynthesis.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,428 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side header of Speech synthesis server
+*
+*/
+
+
+#ifndef SPEECHSYNTHESIS_H
+#define SPEECHSYNTHESIS_H
+
+// INCLUDES
+
+#include <e32std.h>
+
+
+// CONSTANTS
+
+/**
+* Maximum length of text-to-speech voice name. 
+* 
+* @see TVoiceName
+*/
+const TInt KMaxNameLength = 64;
+
+/**
+* Text-to-speech voice name type definition. 
+* 
+* @see TVoice
+*/
+typedef TBuf<KMaxNameLength> TVoiceName;
+
+
+// CLASSES
+
+/**
+* Class containing basic information of text-to-speech voice. 
+*/
+class TVoice
+    {
+
+    public:
+
+        /**
+        * Language spoken by the voice
+        */
+        TLanguage               iLanguage;
+
+        /**
+        * Name of the voice
+        */
+        TVoiceName              iVoiceName;
+    
+        /**
+        * Sampling rate of the voice
+        */
+        TInt                    iSamplingRate;
+
+        /**
+        * TVoice constructor
+        */
+        inline TVoice():
+            iLanguage( ELangNone ),
+            iSamplingRate( KErrNotFound )
+            {
+            // Nothing
+            }
+    };
+
+/**
+* Speech synthesis client side interface
+*
+
+* @code
+* // Simple example how to use synthesis server synchronously
+* _LIT( KText, "This is a text sample" );
+* RSpeechSynthesis s;
+* TRequestStatus status;
+*
+* // Open connection
+* s.Open();
+*
+* // Initialise
+* s.InitialiseSynthesis( KText, status );
+* User::WaitForRequest( status );
+*
+* // Start synthesis when initialisation is ready
+* s.Synthesise( status );
+* User::WaitForRequest( status );
+*
+* // Close connection
+* s.Close();
+* @endcode
+*
+* @code
+* // Another example how to use synthesis server synchronously
+* _LIT( KText, "Second text sample" );
+* RSpeechSynthesis s;
+* TRequestStatus status;
+*
+* // Open connection
+* s.Open();
+*
+* // Set volume to maximum value    
+* s.SetVolumeL( * s.MaxVolumeL() );
+*
+* // Set speaking rate to half of maximum value
+* s.SetSpeakingRateL( * s.MaxSpeakingRateL() / 2 );
+* 
+* // Set synthesis language but leave voice name open
+* TVoice voice;
+* voice.iLanguage = User::Language();
+* s.SetVoiceL( voice );
+*
+* // Initialise
+* s.InitialiseSynthesis( KText, status );
+* User::WaitForRequest( status );
+* 
+* // Ask estimated duration of synthesis. 
+* // Note: Leaves if current TVoice doesn't support duration
+* TTimeIntervalMicroSeconds duration = s.DurationL();
+*
+* // Start synthesis when initialisation is ready
+* s.Synthesise( status );
+* User::WaitForRequest( status );
+*
+* // Close connection
+* s.Close();
+* @endcode
+*/
+class RSpeechSynthesis : public RSessionBase
+    {
+    
+    public:
+        
+        /**
+        * Possible parameter values for SetAudioOutputL()
+        * 
+        * @see RSpeechSynthesis::SetAudioOutputL()
+        */
+        enum TTtsAudioOutput
+        	{
+        	ETtsOutputDefault = 0,  ///< Default
+        	ETtsOutputAll = 1,      ///< All output devices are used
+        	ETtsOutputNoOutput = 2, ///< No output
+        	ETtsOutputPrivate = 3,  ///< Private output device is used
+        	ETtsOutputPublic = 4    ///< Public output device is used
+        	};
+        
+    public:
+        
+        /**
+        * Constructor
+        */
+        IMPORT_C RSpeechSynthesis();
+        
+        /**
+        * Connect to synthesis server
+        *
+        * @return KErrNone if successful, otherwise system-wide error code. 
+        */
+        IMPORT_C TInt Open();
+        
+        /**
+        * Close connection to synthesis server
+        */    
+        IMPORT_C void Close();
+        
+        /**
+        * Initialise text to be synthesised. If there is synthesis already 
+        * ongoing aStatus will be completed with KErrInUse. 
+        * 
+        *
+        * @param aText Text to be synthesized. Text has to be valid until 
+        *        aStatus is completed because this function is asynchronous 
+        *        and the request that it represents may not complete until 
+        *        some time after the call to the function has returned. 
+        *        It is important, therefore, that this descriptor remain valid, 
+        *        or remain in scope, until you have been notified that 
+        *        the request is complete.
+        * @param aStatus Status of priming. 
+        */
+        IMPORT_C void InitialiseSynthesis( const TDesC& aText,
+                                           TRequestStatus& aStatus );
+        
+        /**
+        * Initialise text to be synthesised to the file. If there is synthesis 
+        * already ongoing aStatus will be completed with KErrInUse. 
+        *
+        * @param aText Text to be synthesized. Text has to be valid until 
+        *        aStatus is completed because this function is asynchronous 
+        *        and the request that it represents may not complete until 
+        *        some time after the call to the function has returned. 
+        *        It is important, therefore, that this descriptor remain valid, 
+        *        or remain in scope, until you have been notified that 
+        *        the request is complete.
+        * @param aFileName Output is written to this file. File name has to be
+        *        valid until aStatus is completed. Client should have capabilities 
+        *        needed for writing location defined in aFileName, otherwise aStatus
+        *        will be completed by KErrPermissionDenied. 
+        * @param aStatus Status of priming
+        */
+        IMPORT_C void InitialiseSynthesis( const TDesC& aText, 
+                                           const TFileName& aFileName,
+                                           TRequestStatus& aStatus ); 
+        
+        /** 
+        * @todo Not supported. aStatus will be always completed with KErrNotSupported.
+        *
+        * Initialise text to be synthesised to the descriptor. If there is synthesis 
+        * already ongoing aStatus will be completed with KErrInUse. 
+        *
+        * @param aText Text to be synthesized. Text has to be valid until 
+        *        aStatus is completed because this function is asynchronous 
+        *        and the request that it represents may not complete until 
+        *        some time after the call to the function has returned. 
+        *        It is important, therefore, that this descriptor remain valid, 
+        *        or remain in scope, until you have been notified that 
+        *        the request is complete.
+        * @param aDataBuffer Reference to a descriptor where output is stored
+        *        after Synthesise() is called. If all the data does not fit 
+        *        into aDataBuffer Synthesise can be called several times. 
+        * @param aStatus Status of priming
+        */
+        IMPORT_C void InitialiseSynthesis( const TDesC& aText,
+                                           TDes8& aDataBuffer, 
+                                           TRequestStatus& aStatus );
+        
+        /**
+        * Synthesise the text or resume paused synthesis. 
+        * InitialiseSynthesis() has to be called succesfully before call to 
+        * this function will succeed. aStatus is completed with KErrNotReady 
+        * if initialisation has not been done. 
+        *
+        * @param aStatus Status of synthesis
+        *
+        * @see RSpeechSynthesis::InitialiseSynthesis() 
+        * @see RSpeechSynthesis::PauseL() 
+        */
+        IMPORT_C void Synthesise( TRequestStatus& aStatus );     
+        
+        /**
+        * Stop ongoing synthesis. Ongoing synthesis request is completed 
+        * with KErrAbort. Does nothing if there is no synthesis ongoing. 
+        *
+        * @leave KErrInUse if request is made to stop other client's synthesis. 
+        */
+        IMPORT_C void StopL();
+        
+        /**
+        * Pause synthesis. Resuming can be done by calling Synthesize(). 
+        * Ongoing synthesis request is completed with KErrCancel. 
+        *
+        * @leave KErrNotSupported if trying to pause synthesis to file. 
+        * @leave KErrNotReady if there is no synthesis ongoing. 
+        */
+        IMPORT_C void PauseL();
+        
+        /**
+        * Returns estimated duration of synthesis. This function returns valid 
+        * duration only after synthesis is initialised and before synthesis has
+        * completed. 
+        *
+        * @return Estimated duration of speech synthesis playback. 
+        *
+        * @leave KErrNotReady if state is incorrect
+        * @leave KErrNotSupported if current voice settings doesn't support 
+        *        duration information
+        */
+        IMPORT_C TTimeIntervalMicroSeconds DurationL();
+        
+        /**
+        * Get supported synthesis languages
+        *
+        * @param aLanguages Contains supported languages after function call
+        *
+        */
+        IMPORT_C void GetLanguagesL( RArray<TLanguage>& aLanguages );
+        
+        /**
+        * Get available voices 
+        *
+        * @param aVoices Contains supported voices in TVoice structure after 
+        *        the function call. 
+        * @param aLanguage Defines a language that returned voices can speak. 
+        *
+        */
+        IMPORT_C void GetVoicesL( RArray<TVoice>& aVoices, TLanguage aLanguage );
+        
+        /**
+        * Get current voice. 
+        *
+        * @return Current voice. 
+        *
+        */
+        IMPORT_C TVoice VoiceL();
+        
+        /**
+        * Change voice. Change is effective after next InitialiseSynthesis() call 
+        * is made and until new SetVoiceL() call is made or Close() is called. 
+        *
+        * @param aVoice New voice to be set. aVoice.iLanguage is the only mandatory 
+        *        parameter,others can be undefined and server may ignore 
+        *        those if invalid values are given. 
+        *
+        * @leave KErrArgument if aVoice is not valid
+        */
+        IMPORT_C void SetVoiceL( const TVoice& aVoice ); 
+        
+        /**
+        * Returns maximum speaking rate.
+        *
+        * @return Maximum speaking rate
+        *
+        */
+        IMPORT_C TInt MaxSpeakingRateL(); 
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Current speaking rate
+        *
+        */
+        IMPORT_C TInt SpeakingRateL(); 
+        
+        /**
+        * Sets the speaking rate. Range is 1..MaxSpeakingRateL(). Setting will 
+        * be effective after next InitialiseSynthesis() call and until new rate 
+        * is set or Close() is called. Note: All voices doesn't support speaking 
+        * rate changes and in that case there is no audible change. 
+        *
+        * @param aSpeakingRate Rate value
+        *
+        * @leave KErrArgument if speaking rate is out of range. 
+        *
+        * @see MaxSpeakingRateL()
+        */
+        IMPORT_C void SetSpeakingRateL( TInt aSpeakingRate ); 
+        
+        /**
+        * Get maximum volume
+        *
+        * @return Maximum volume
+        *
+        */
+        IMPORT_C TInt MaxVolumeL(); 
+        
+        /**
+        * Get current volume.
+        *
+        * @return Volume level between 0 and MaxVolumeL()
+        *
+        */
+        IMPORT_C TInt VolumeL(); 
+        
+        /**
+        * Change volume. Will be effective until new volume is set or Close()
+        * is called.
+        *
+        * @param aVolume New volume, accepted values are in range from 0 to MaxVolumeL()
+        *
+        * @leave KErrArgument if volume value is out of range, 
+        *
+        * @see MaxVolumeL()
+        */
+        IMPORT_C void SetVolumeL( TInt aVolume ); 
+        
+        /**
+        * Sets the playback priority and preference values. Setting will 
+        * be effective after next InitialiseSynthesis() call and until new priority 
+        * is set or Close() is called. Client needs Nokia VID to use
+        * this function. 
+        *
+        * @param aPriority Audio priority
+        * @param aPreference Audio preference
+        *
+        * @leave KErrPermissionDenied if client doesn't have Nokia VID. 
+        */
+        IMPORT_C void SetAudioPriorityL( TInt aPriority, TInt aPreference ); 
+        
+        /**
+      	* Sets the audio output. Setting will be effective immediately and until
+      	* new value is set or connection closed. Client needs WriteDeviceData 
+      	* capability if setting output to ETtsOutputAll
+        *
+      	* @param aAudioOutput - where the audio is routed. 
+      	*
+      	* @leave KErrPermissionDenied if client doesn't have WriteDeviceData when
+      	*        setting output to ETtsOutputAll. 
+        *
+      	*/
+        IMPORT_C void SetAudioOutputL( TTtsAudioOutput aAudioOutput );
+        
+        /**
+        * Send custom command to the server. By using this function it is possible 
+        * to make adjustments to the synthesis process. 
+        * Note: Currently there is no supported commands. 
+        *
+        * @param aCommand A custom command 
+        * @param aValue Parameter value for aCommand 
+        * 
+        * @leave KErrNotSupported aCommand is not supported. 
+        * @leave KErrArgument if aValue is not valid. 
+        */
+        IMPORT_C void CustomCommandL( TInt aCommand, TInt aValue ); 
+        
+    private:
+        
+        /**
+        * Internal function used for handling initialisation. 
+        */
+        void DoInitialiseSynthesisL( const TDesC& aText, 
+                                     const TFileName& aFileName, 
+                                     TRequestStatus& aStatus ); 
+        
+    };
+    
+#endif // SPEECHSYNTHESIS_H 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/speech_synthesis_clientserver_api/speech_synthesis_clientserver_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<api id="5f00aa78581f17157af65d3a57d5ecf5" dataversion="2.0">
+<name>Speech synthesis client-server API</name>
+<description>Client-server API for speech synthesis. Main interface for applications using TTS</description>
+<type>c++</type>
+<collection>srsf</collection>
+<libs><lib name="speechsynthesis.lib"/>
+</libs>
+<release category="platform" sinceversion="0"/>
+<attributes>
+<htmldocprovided>no</htmldocprovided>
+<adaptation>no</adaptation>
+</attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/srsf_cenrep_settings_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                SRSF CenRep settings API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/srsfdomaincrkeys.h     APP_LAYER_PLATFORM_EXPORT_PATH(srsfdomaincrkeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/srsf_cenrep_settings_api/inc/srsfdomaincrkeys.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Domain CenRep keys for SRSF
+*
+*/
+
+
+#ifndef SRSFDOMAINCRKEYS_H
+#define SRSFDOMAINCRKEYS_H
+
+// SRSF Settings API
+// Used for SRSF/SIND settings/status storage
+const TUid KCRUidSRSFSettings = {0x10281C7D};
+
+// TTS playback volume setting
+const TUint32 KSRSFPlaybackVolume = 0x00000002;
+
+// Rejection sensitivity setting
+const TUint32 KSRSFRejection = 0x00000003;
+
+// Language which was used in voice verification training
+const TUint32 KSRSFVoiceUiLanguage = 0x00000004;
+
+#endif // SRSFDOMAINCRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/srsf_cenrep_settings_api/srsf_cenrep_settings_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="81fead861fbe6b66a0a48906a807c42e" dataversion="2.0">
+  <name>SRSF CenRep settings API</name>
+  <description>Defines a set of CenRep keys which are used for TTS and recognition settings. Used in SRSF and in VoiceUI.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/srsf_secondarydisplay_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                SRSF SecondaryDisplay API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/secondarydisplay/appcontrollersecondarydisplayapi.h     APP_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/appcontrollersecondarydisplayapi.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/srsf_secondarydisplay_api/inc/secondarydisplay/appcontrollersecondarydisplayapi.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The set of messages provided to Secondary Display software by
+*              : Application controller.
+*
+*/
+
+#ifndef APPCONTROLLERSECONDARYDISPLAYAPI_H
+#define APPCONTROLLERSECONDARYDISPLAYAPI_H
+
+// INCLUDES
+#include <e32base.h>
+
+/*
+* ==============================================================================
+* This file contains the following sections:
+*   - Dialog definitions
+*   - Command definitions
+*   - Event definitions
+*   - Parameter definitions
+* ==============================================================================
+*/
+
+namespace SecondaryDisplay
+{
+	
+// The category UID for the messages in this header file.
+//
+const TUid KCatAppController = {0x10281D15};
+
+/*
+* ==============================================================================
+* Dialogs shown by VCExecutorApp subsystem. These messages are handled using the
+* Secondary Display support in Avkon.
+* ==============================================================================
+*/
+enum TAppControllerSecondaryDisplayDialogs
+    {
+    /**
+    * No note. Error condition if this comes to CoverUI
+    */
+    ECmdAppControllerNoNote = 0,
+    
+    /**
+    * A command for showing BT activation note on secondary display.
+    */
+    ECmdShowOfflineBtActivationQuery,
+
+    /**
+    * A command for showing BT disabled in offline on secondary display.
+    */
+    ECmdShowBtDisabledOfflineNote,
+
+    /**
+    * A command for showing BT general error on secondary display.
+    */
+    ECmdShowBtGeneralErrorNote,
+    
+    /**
+    * A command for showing leave offline profile note on secondary display.
+    */
+    ECmdShowLeaveOfflineProfileQuery
+    };
+}
+
+#endif      // APPCONTROLLERSECONDARYDISPLAYAPI_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/srsf_secondarydisplay_api/srsf_secondarydisplay_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="78bebeab03145f5a21a9aa9a2bbe1906" dataversion="2.0">
+  <name>SRSF SecondaryDisplay API</name>
+  <description>Defines a set CoverUI messages.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ttp_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                TTP HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsttphwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsttphwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ttp_hw_device_api/inc/asrsttphwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,237 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Exported interface towards TTP HW Device.
+*
+*/
+
+
+
+
+
+#ifndef ASRSTTPHWDEVICE_H
+#define ASRSTTPHWDEVICE_H
+
+// INCLUDES
+// Base class for all HW Devices
+#include <asrshwdevice.h>
+// SI Data
+#include <nsssispeechrecognitiondatadevasr.h>
+
+// FORWARD DECLARATIONS
+class CTTPAlgorithm;
+class CTtpCallback;
+
+
+// CLASS DECLARATION
+
+/**
+* Class which defines callback functions. Client must implement this in order
+* to receive callbacks.
+*
+* @lib asrsttphwdevice.lib
+*/
+class MASRSTtpHwDeviceObserver 
+    {
+    public: // New functions
+        
+        /**
+        * Callback function to load configuration data.
+        * Client provides an implementation.
+        *
+        * @param aPackageType Type identifier.
+        * @param aPackageID Package identifier.
+        * @param aStartPosition First byte.
+        * @param aEndPosition Last byte. If greater than the size of 
+        *                     the data, rest of the data is given.
+        * @return Pointer to the data buffer, TTP HW Device takes ownership.
+        */	
+        virtual HBufC8* MathdoConfigurationData( TUint32 aPackageType, TUint32 aPackageID,
+                                                 TUint32 aStartPosition = 0,
+                                                 TUint32 aEndPosition = KMaxTUint32 ) = 0;
+
+		/**
+        * Callback function to notify that word list is converted.
+        * Client provides an implementation.
+        *
+        * @param aError Error code, KErrNone if successful.
+        */	
+		virtual void MathdoWordListReady( const TInt aError ) = 0;
+	};
+
+/**
+* TTP HW Device interface.
+*
+* @lib asrsttphwdevice.lib
+*/
+class CASRSTtpHwDevice : public CASRSHwDevice
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param aObserver Reference to callback observer.
+        */
+        IMPORT_C static CASRSTtpHwDevice* NewL( MASRSTtpHwDeviceObserver& aObserver );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CASRSTtpHwDevice();
+
+    public: // New functions
+        
+        /**
+        * Use to convert text to phonemes.
+        *
+        * @param aText Text to be converted
+		* @param aLanguage Used language
+        * @return Phoneme sequence, client gains ownership
+        */
+		IMPORT_C HBufC8* ConvertTextL( const TDesC& aText, 
+							           TLanguage& aLanguage );
+
+		/**
+        * Use to convert list of words to pronunciation sequences.
+        * 
+        * @param aWordList Initialized word list to where 
+        *        pronunciations will be added. Client will keep the ownership
+        *        of CSITtpWordList also after this call.
+		* @param aDefaultLanguage Language which overrides the first identified language. 
+        *        Iflanguage is ELangOther, language identification will be used.
+    	* @param aMaxNPronunsForWord Maximum number of pronunciations (languages) for each word.
+        */
+		IMPORT_C void ConvertWordListL( CSITtpWordList& aWordList,
+								        const RArray<TLanguage> aDefaultLanguage,
+								        const RArray<TUint32> aMaxNPronunsForWord );
+		
+        /**
+        * Use to cancel running word list conversion.
+        */
+		IMPORT_C void CancelWordListConversion();
+
+        /**
+        * Sets the phoneme notation used in output.
+        *
+        * @param aNotation Phoneme notation identifier.
+        */
+        IMPORT_C void SetPhonemeNotationL( const TDesC& aNotation );
+
+        /**
+        * Gets the current phoneme notation indentifier.
+        *
+        * @return Phoneme notation identifier.
+        */
+        IMPORT_C const TDesC& PhonemeNotation();
+
+    public: // From CASRSHwDevice
+
+        /**
+        * From CASRSHwDevice
+        * Custom interface
+        *
+        * @param aInterfaceId ID of wanted custom interface
+        * @return A pointer to the interface implementation, NULL if not found.
+        */
+        IMPORT_C TAny* CustomInterface( TUid aInterfaceId );
+
+        /**
+        * From CASRSHwDevice
+        * Initializes Hw Device.
+        */
+        IMPORT_C void InitializeL();
+
+        /**
+        * From CASRSHwDevice
+        * Clears Hw Device, counter part for InitializeL()
+        */
+        IMPORT_C void Clear();
+
+    public: // New methods for SIND increment 3
+
+        /**
+        * Tries to identify the language of given text
+        *
+        * @param "const TDesC& aText" Text
+        * @param "TInt aNumberOfGuesses" Maximum number of guesses that will be provided
+        * @param "RArray<TLanguage>& aLanguages" Output parameter, will contain list of guessed languages
+        * @param "RArray<TInt>& aScores" Output parameter, scores
+        */
+        IMPORT_C void LanguageIdentificationL( const TDesC& aText,
+                                               TInt aNumberOfGuesses,
+                                               RArray<TLanguage>& aLanguages,
+                                               RArray<TInt>& aScores );
+ 
+    private:
+
+        /**
+        * C++ default constructor.
+        * @param aObserver Reference to observer.
+        */
+        CASRSTtpHwDevice( MASRSTtpHwDeviceObserver& aObserver );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CASRSTtpHwDevice( const CASRSTtpHwDevice& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CASRSTtpHwDevice& operator=( const CASRSTtpHwDevice& );
+
+		/**
+        * Function to notify that word list is converted
+        * Called by CTtpCallback.
+        *
+        * @param aError Error code
+        */	
+		void WordListReady( const TInt aError );
+
+        /**
+        * Function to notify that configuration data is needed.
+        * Called by CTtpCallback.
+        *
+        * @param aPackageType Type identifier.
+        * @param aPackageID Package identifier.
+        * @param aStartPosition First byte.
+        * @param aEndPosition Last byte. If greater than the size of 
+        *                     the data, rest of the data is given.
+        * @return Pointer to the data buffer.
+        */	
+        virtual HBufC8* ConfigurationData( TUint32 aPackageType, TUint32 aPackageID,
+                                           TUint32 aStartPosition = 0,
+                                           TUint32 aEndPosition = KMaxTUint32 );
+
+    private: // Data
+		// Observer
+		MASRSTtpHwDeviceObserver& iObserver;
+
+        // algorithm implementation
+        CTTPAlgorithm* iTTPAlgorithm;
+         
+		// Implements call backs from CTTPAlgorithm
+		CTtpCallback* iTTPAlgObserver;
+
+        // Reserved pointer for future extension
+        TAny* iReserved;
+
+    private: // Friend classes
+        friend class CTtpCallback;
+
+    };
+
+#endif // ASRSTTPHWDEVICE_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ttp_hw_device_api/ttp_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="371860a17b0ed716c99c09bcf50adcf9" dataversion="2.0">
+  <name>TTP HW Device API</name>
+  <description>Interface for text-to-phoneme conversion algorithm</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="asrsttphwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/tts_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                TTS HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsttshwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsttshwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/tts_hw_device_api/inc/asrsttshwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,293 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Algorithms for Speech Synthesis
+*
+*/
+
+
+
+
+
+#ifndef TTSHWDEVICE_H
+#define TTSHWDEVICE_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <nssttscommon.h>
+#include <asrshwdevice.h>
+
+// FORWARD DECLARATIONS
+class CTtsAlgorithm;
+
+// CLASS DECLARATION
+/**
+*  Class to define callback functions
+*
+*  @lib asrsttshwdevice.lib
+*  @since 2.8
+*/
+class MTtsHwDeviceObserver
+    {
+    public: // New functions
+
+		/**
+        * Called by the HW device when the synthesis has been completed.
+        * @since 2.8
+        * @param aStatus Error code, KErrNone if success
+        * @return none
+        */
+		virtual void MthdTtsCompleted( TInt aStatus ) = 0;
+
+		/**
+        * Invoked by TTS HW Device when it needs a configuration data package.
+        * @since 2.8
+        * @param aPackageType Type identifier. 
+        * @param aPackageID Identifier of package
+        * @param aStartPosition Start index in bytes
+        * @param aEndPosition End index in bytes. If the position is bigger 
+        *         than the size of data package, the end part will be returned.
+        * @return Data package in a buffer
+        */
+        virtual HBufC8* MthdoConfigurationData( TUint32 aPackageType, 
+                                                TUint32 aPackageID, 
+                                                TUint32 aStartPosition, 
+                                                TUint32 aEndPosition) = 0;
+		/**
+        * Called by the HW device when custom command implementation wants to notify a client.
+        * @since 2.8
+        * @param aEvent Event code aStatus Error code, KErrNone if success.
+        * @param aParameter Optional parameter 
+        * @return none
+        */
+		virtual void MthdCustomEvent( TInt aEvent, 
+                                      TInt aStatus, 
+                                      const TDesC8& aParameter = KNullDesC8 ) = 0;
+
+        /**
+        * Called by the HW device when the HW device has synthesized a new audio buffer.
+        * @since 2.8
+        * @param aBuffer Synthesized audio buffer.
+        * @return none
+        */
+        virtual void MthdProcessBuffer( const TDesC8& aBuffer ) = 0;
+
+	};
+
+
+
+/**
+*  Class to provide speech synthesis
+*
+*  @lib asrsttshwdevice.lib
+*  @since 2.8
+*/
+class CTtsHwDevice : public CASRSHwDevice
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @param aObserver Observer which implements callback functions.
+        * @param aSamplingRate Sampling rate for output audio
+        * @param aBufferSize Buffer size for output audio
+        */
+        IMPORT_C static CTtsHwDevice* NewL( MTtsHwDeviceObserver& aObserver,
+                                            TUint aSamplingRate, 
+                                            TUint aBufferSize );
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CTtsHwDevice();
+
+    public: // New functions
+
+        /**
+        * Adds new style to the collection. If equal style exists already, new style is not added.
+        * @since 2.8
+        * @param aStyle Style to be added.
+        * @return Identifier of added style. If equal style exists already, identifier to the old style will be returned.
+        */
+        IMPORT_C TTtsStyleID AddStyleL( const TTtsStyle& aStyle );
+
+        /**
+        * Analyses stucture of text and adds style information.
+        * @since 2.8
+        * @param aText Updates text object by dividing it into segments with new styles.
+        * @return none
+        */
+        IMPORT_C void AnalyzeProsodyL( CTtsParsedText& aText );
+
+        /**
+        * Analyses stucture of text by finding paragraphs and sentences.
+        * @since 2.8
+        * @param aText Updates text object by segmenting it into paragraphs and sentences.
+        * @return none
+        */
+        IMPORT_C void AnalyzeStructureL( CTtsParsedText& aText );
+
+        /**
+        * Notifies that the buffer has been processed
+        * @since 2.8
+        * @param aBuffer The buffer which has been processed
+        * @return none
+        */
+        IMPORT_C void BufferProcessed( const TDesC8& aBuffer );
+
+        /**
+        * Deletes style.
+        * @since 2.8
+        * @param aStyleID Identifier of style to be deleted.
+        * @return none
+        */
+        IMPORT_C void DeleteStyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Gives current position of synthesizing.
+        * @since 2.8
+        * @param aTime Time of the synthesizing position.
+        * @return none
+        */
+        IMPORT_C void GetPositionL( TTimeIntervalMicroSeconds& aTime );
+
+        /**
+        * Gives current position of synthesizing.
+        * @since 2.8
+        * @param aSegment The segment being synthesizing
+        * @param aWordIndex The index of word being synthesizing
+        * @return none
+        */
+        IMPORT_C void GetPositionL( TTtsSegment& aSegment, 
+                                    TInt& aWordIndex );
+
+        /**
+        * Ask if a language is supported or not.
+        * @since 2.8
+        * @param aLanguage Synthesizing language.
+        * @return ETrue language is supported otherwise EFalse
+        */
+        IMPORT_C TBool IsLanguageSupported( TLanguage aLanguage );
+
+        /**
+        * Gives number of styles.
+        * @since 2.8
+        * @param none
+        * @return Number of styles.
+        */
+        IMPORT_C TUint16 NumberOfStyles() const;
+
+        /**
+        * Pauses synthesizing. 
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void Pause();
+
+        /**
+        * Prepares for synthesizing.
+        * @since 2.8
+        * @param aStream Stream to be synthesized.
+        * @return none
+        */
+        IMPORT_C void PrimeSynthesisL( MTtsSegmentStream& aStream );
+
+        /**
+        * Prepares for synthesizing. 
+        * @since 2.8
+        * @param aText Text containing segments to be synthesized.
+        * @return none
+        */
+        IMPORT_C void PrimeSynthesisL( CTtsParsedText& aText );
+
+        /**
+        * Sets new position for synthesizing.
+        * @since 2.8
+        * @param aTime Time of the synthesizing postion.
+        * @return none
+        */
+        IMPORT_C void SetPositionL( const TTimeIntervalMicroSeconds& aTime );
+
+        /**
+        * Sets new position for synthesizing.
+        * @since 2.8
+        * @param aSegment The segment being synthesizing
+        * @param aWordIndex The index of word being synthesizing
+        * @return none
+        */
+        IMPORT_C void SetPositionL( const TTtsSegment& aSegment, 
+                                    TInt aWordIndex );
+
+        /**
+        * Stops synthesizing and releases resources of synthesizing. 
+        * The method does nothing if already stopped.
+        * @since 2.8
+        * @param 
+        * @return none
+        */
+        IMPORT_C void Stop();
+
+        /**
+        * Receives style information
+        * @since 2.8
+        * @param aStyleID Style identifier
+        * @return Style
+        */
+        IMPORT_C TTtsStyle& StyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Receives style information
+        * @since 2.8
+        * @param aIndex Index to style: 0..NumberOfStyles()
+        * @return Style
+        */
+        IMPORT_C TTtsStyle& StyleL( TUint16 aIndex );
+
+        /**
+        * Starts waveform production. The synthesized audio buffers are send back 
+        * to client using MthdProcessBuffer().
+        * @since 2.8
+        * @param none
+        * @return none
+        */
+        IMPORT_C void SynthesizeL();
+       
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTtsHwDevice();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( MTtsHwDeviceObserver& aObserver,
+                         TUint aSamplingRate, 
+                         TUint aBufferSize );
+
+    private: // Data
+
+		// Actual algorithm where all processing happens
+		CTtsAlgorithm* iAlgorithm;
+
+		// Reserved pointer for future extension
+        TAny* iReserved;
+
+    };
+
+#endif // TTSHWDEVICE_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/tts_hw_device_api/tts_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="4b711a7e17dd588eb61537bb0998ccc7" dataversion="2.0">
+  <name>TTS HW Device API</name>
+  <description>Algorithms for speech synthesis</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="asrsttshwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                UI Voice Recognition API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/vuivoicerecogdefs.h     APP_LAYER_PLATFORM_EXPORT_PATH(vuivoicerecogdefs.h)
+../inc/vuicvoicerecogdialog.h     APP_LAYER_PLATFORM_EXPORT_PATH(vuicvoicerecogdialog.h)
+../inc/vuicvoicerecog.h     APP_LAYER_PLATFORM_EXPORT_PATH(vuicvoicerecog.h)
+../inc/secondarydisplay/vuisecondarydisplayapi.h     APP_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/vuisecondarydisplayapi.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/inc/secondarydisplay/vuisecondarydisplayapi.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUISECONDARYDISPLAYAPI_H
+#define VUISECONDARYDISPLAYAPI_H
+
+// INCLUDES
+#include <e32base.h>
+
+#include "vuivoicerecogdefs.h"
+
+/*
+* ==============================================================================
+* This file contains the following sections:
+*   - Dialog definitions
+*   - Command definitions
+*   - Event definitions
+*   - Parameter definitions
+* ==============================================================================
+*/
+
+namespace SecondaryDisplay
+{
+	
+// The category UID for the messages in this header file.
+//
+const TUid KCatVoiceUi = {0x101F8543};
+
+/*
+* ==============================================================================
+* Dialogs shown by VoiceUi subsystem. These messages are handled using the
+* Secondary Display support in Avkon.
+* ==============================================================================
+*/
+enum TVUISecondaryDisplayDialogs
+    {
+    /**
+    * No note. Error condition if this comes to CoverUI
+    */
+    ECmdVoiceNoNote = 0,
+    
+    /**
+    * A command for showing the "Speak now" note on secondary display.
+    */
+    ECmdShowVoiceSpeakNowNote,
+    
+    /**
+    * A command for showing the "No match found" note on secondary display.
+    */
+    ECmdShowVoiceNoMatchesNote,
+
+    /**
+    * A command for showing the "Voice system error" note on secondary display.
+    */
+    ECmdShowVoiceSystemErrorNote,
+
+    /**
+    * A command for showing the "Call in progress" note on secondary display.
+    */
+    ECmdShowCallInProgressNote,
+
+    /**
+    * A command for showing the "Not recognized" note on secondary display.
+    */
+    ECmdShowVoiceNotRecognizedNote,
+
+    /**
+    * A command for showing the "No voice tags saved" note on secondary display.
+    */
+    ECmdShowVoiceNoTagNote,
+
+    /**
+    * A command for showing the matched item note on secondary display.
+    */
+    ECmdShowMatchedItemNote,
+
+    /**
+    * A command for showing the N-best list query on secondary display.
+    */
+    ECmdShowNBestListQuery,
+
+    /**
+    * A command for showing the voice verification query on secondary display.
+    */
+    ECmdShowVoiceVerificationQuery,
+    
+    /**
+    * A command for showing the first time activation query on secondary display.
+    */
+    ECmdShowFirstTimeActivationQuery
+    };
+
+/*
+* ==============================================================================
+* Parameter definitions for the messages in this file.
+* ==============================================================================
+*/
+
+// Package definition for Matched Item
+struct TMatchData
+    {
+    TUid iType;
+    TName iName;
+    
+    TBuf<KMaxPhoneNumberLength> iNumber;
+    };    
+
+typedef TPckgBuf<TMatchData> TMatchDataPckg;
+
+// Package definition for Verification Item
+struct TVerificationData
+    {
+    TName iName;
+    };    
+
+typedef TPckgBuf<TVerificationData> TVerificationDataPckg;
+
+} // namespace SecondaryDisplay
+
+#endif      // VUISECONDARYDISPLAYAPI_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/inc/vuicvoicerecog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#ifndef VUICVOICERECOG_H
+#define VUICVOICERECOG_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Loads the resource file for voice recognition
+*  This class must be instantiated before performing recognition
+* @lib VoiceUiRecognition.lib
+* @since 2.8
+*/
+class CVoiceRecog : public CBase
+    {
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CVoiceRecog* NewLC();
+        IMPORT_C static CVoiceRecog* NewL(); 
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVoiceRecog();
+
+
+    private:
+
+        /**
+        * By default constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+        CVoiceRecog();
+
+    private: // Data
+    
+    };
+
+#endif  // VUICVOICERECOG_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/inc/vuicvoicerecogdialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the recognition dialog for clients
+*
+*/
+
+
+#ifndef VUICVOICERECOGDIALOG_H
+#define VUICVOICERECOGDIALOG_H
+
+#include <e32base.h>
+
+//  FORWARD DECLARATIONS
+
+
+// CLASS DECLARATION
+/**
+* The voice recognition dialog
+* @lib VoiceUiRecognition.lib
+* @since 3.2
+*/
+class CVoiceRecognitionDialog : public CBase                           
+    {
+    
+    public:     // Constructors and Destructors
+
+        /**
+        * C++ default constructor.
+        */
+        IMPORT_C CVoiceRecognitionDialog();
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CVoiceRecognitionDialog();
+
+    public:     // New functions
+    
+        /**
+        * Executes the dialog
+        * @return Exit status
+        */
+        IMPORT_C TInt ExecuteLD();
+        
+        /**
+        * Stops voice dialling process
+        */
+        IMPORT_C void Cancel();
+        
+   private:     // Data
+
+   };
+
+#endif    // VUICVOICERECOGDIALOG_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/inc/vuivoicerecogdefs.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constant definitions 
+*
+*/
+
+
+#ifndef VUIVOICERECOGDEFS_H
+#define VUIVOICERECOGDEFS_H
+
+const TInt KRecogFinal = 32;
+const TInt KRecogInterval = 1;
+const TInt KRecogIncrement = 1;
+const TInt KRecogDelay = 1;
+const TInt KKRecogInterval = 125000;
+
+const TInt KMaxPhoneNumberLength = 48;  // taken from Phonebook
+const TInt KMaxNameLength = 110;    // taken from Phonebook
+const TInt KMaxFieldLength = 150;    // taken from Phonebook, EMail address length
+
+const TInt KSindMaxResults = 6;    // The number of voice tags needed for the N-Best List.
+
+const TInt KTimeoutMicroseconds = 4*1000000; // 4 seconds
+const TInt KErrorMessageTimeoutMicroseconds = 3*1000000; // 3 seconds
+const TInt KPlaybackTimeout = 45;    // ~2.5s depending on HW
+
+const TInt KVerificationCommands = 3;
+const TInt KVerificationResults = 3;
+const TInt KVerificationTries = 3;
+
+_LIT( KVoiceDialContext, "NAMEDIAL" );    // context for phonebook contact voice tags
+_LIT( KVoiceCommandContext, "COMMAND" );    // context for voice commands application tags
+_LIT( KVoiceVerificationContext, "VERIFICATION" );    // context for voice verification commands tags
+
+_LIT( KDirAndFile,"z:voiceui.mbm" );
+
+_LIT8( KVoiceUiMode, "DEVICELOCKMODE" );    // Startup mode for device lock functionality
+
+const TUid KVCommandAppUid = { 0x101F8555 };
+const TUid KVoiceUiUID = { 0x101F8543 };
+
+const TInt KProfileValue = 200;
+
+// Voice Ui error codes
+const TInt KErrInit                     = -1000;
+const TInt KErrNoMatch                  = -1001;
+const TInt KErrNoResults                = -1002;
+const TInt KErrCallInProgress           = -1003;
+const TInt KErrNoContacts               = -1004;
+const TInt KErrRecogFailed              = -1005;
+const TInt KErrNoSpeech                 = -1006;
+const TInt KErrTooEarly                 = -1007;
+const TInt KErrTooLong                  = -1008;
+const TInt KErrTooShort                 = -1009;
+const TInt KErrNoVerificationTrained    = -1009;
+
+// Verification modes
+enum TVuiVerificationMode
+    {
+    EAutomatic = 0,
+    EManual,
+    EVoice
+    };
+
+// Voice Ui keypress codes
+enum TVuiKeypress
+    {
+    ENoKeypress = 1000,
+    EShortKeypress,
+    ELongKeypress,
+    EEndCallKeypress,
+    EUpKeypress,
+    EDownKeypress,
+    ESelectKeypress,
+    EDirectSelectKeypress,
+    EOpenKeypress,
+    EMoreKeypress,
+    EOptionsKeypress,
+    EScrollKeypress,
+    EDragKeypress
+    };
+
+struct VTimerModel
+    {
+    TInt iFinalValue;
+    TInt iHundreths;
+    TInt iIncrement;
+    TBool iRunning;
+    };
+    
+// Read capability: ReadDeviceData.
+_LIT_SECURITY_POLICY_C1( KVoiceUiReadPolicy, ECapabilityReadDeviceData );
+    
+// Write capability: WriteDeviceData.
+_LIT_SECURITY_POLICY_C1( KVoiceUiWritePolicy, ECapabilityWriteDeviceData );
+
+#endif    // VUIVOICERECOGDEFS_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/conf/tctestdomuvrvoicerecog.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,13 @@
+[Test]#1
+title TestVuicVocRecogNewL
+run testscripter c:\testframework\ui_testdomuvrvoicerecog.cfg 1
+[Endtest] 
+
+[Test]#2
+title TestVuicVocRecogNewLCL
+run testscripter c:\testframework\ui_testdomuvrvoicerecog.cfg 2
+[Endtest] 
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/conf/tctestdomuvrvoiregdiag.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,19 @@
+[Test]#1
+title TestVoceRegDalgCVoceRegDialogL
+run testscripter c:\testframework\ui_testdomuvrvoiregdiag.cfg 1
+[Endtest] 
+
+[Test]#2
+title TestVoceRegDalgDestructor
+run testscripter c:\testframework\ui_testdomuvrvoiregdiag.cfg 2
+[Endtest] 
+
+[Test]#3
+title TestVoceRegDalgExecuteLDL
+run testscripter c:\testframework\ui_testdomuvrvoiregdiag.cfg 3
+[Endtest]
+
+[Test]#4
+title TestVoceRegDalgCancel
+run testscripter c:\testframework\ui_testdomuvrvoiregdiag.cfg 4
+[Endtest]
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/conf/ui_testdomuvrvoicerecog.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,14 @@
+[Test]#1
+title TestVuicVocRecogNewL
+create testdomuivoicerengn test
+test TestVuicVocRecogNewL
+delete test
+[Endtest] 
+
+[Test]#2
+title TestVuicVocRecogNewLCL
+create testdomuivoicerengn test
+test TestVuicVocRecogNewLCL
+delete test
+[Endtest]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/conf/ui_testdomuvrvoiregdiag.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+[Test]#1
+title TestVoceRegDalgCVoceRegDialogL
+create testdomuivoicerengn test
+test TestVoceRegDalgCVoceRegDialogL
+delete test
+[Endtest]
+
+[Test]#2
+title TestVoceRegDalgDestructor
+create testdomuivoicerengn test
+test TestVoceRegDalgCVoceRegDialogL
+test TestVoceRegDalgDestructor
+delete test
+[Endtest]
+
+[Test]#3
+title TestVoceRegDalgExecuteLDL
+create testdomuivoicerengn test
+test TestVoceRegDalgCVoceRegDialogL
+test TestVoceRegDalgExecuteLDL
+delete test
+[Endtest]
+
+[Test]#4 
+title TestVoceRegDalgCancel
+create testdomuivoicerengn test
+test TestVoceRegDalgCVoceRegDialogL
+test TestVoceRegDalgCancel
+delete test
+[Endtest]
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test ui voice recognition api modules
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+../init/testdomuivoicerengn.ini                      /epoc32/wins/c/TestFramework/testdomuivoicerengn.ini
+../init/testdomuivoicerengn.ini                      /epoc32/winscw/c/TestFramework/testdomuivoicerengn.ini
+../init/testdomuivoicerengn.ini                      /epoc32/data/z/system/data/testdomuivoicerengn.ini
+
+../conf/ui_testdomuvrvoicerecog.cfg                   /epoc32/wins/c/TestFramework/ui_testdomuvrvoicerecog.cfg
+../conf/ui_testdomuvrvoicerecog.cfg                   /epoc32/winscw/c/TestFramework/ui_testdomuvrvoicerecog.cfg
+../conf/ui_testdomuvrvoicerecog.cfg                   /epoc32/data/z/system/data/ui_testdomuvrvoicerecog.cfg
+
+../conf/tctestdomuvrvoicerecog.cfg                    /epoc32/wins/c/TestFramework/tctestdomuvrvoicerecog.cfg
+../conf/tctestdomuvrvoicerecog.cfg                    /epoc32/winscw/c/TestFramework/tctestdomuvrvoicerecog.cfg
+../conf/tctestdomuvrvoicerecog.cfg                    /epoc32/data/z/system/data/tctestdomuvrvoicerecog.cfg
+
+../conf/ui_testdomuvrvoiregdiag.cfg                   /epoc32/wins/c/TestFramework/ui_testdomuvrvoiregdiag.cfg
+../conf/ui_testdomuvrvoiregdiag.cfg                   /epoc32/winscw/c/TestFramework/ui_testdomuvrvoiregdiag.cfg
+../conf/ui_testdomuvrvoiregdiag.cfg                   /epoc32/data/z/system/data/ui_testdomuvrvoiregdiag.cfg
+
+../conf/tctestdomuvrvoiregdiag.cfg                    /epoc32/wins/c/TestFramework/tctestdomuvrvoiregdiag.cfg
+../conf/tctestdomuvrvoiregdiag.cfg                    /epoc32/winscw/c/TestFramework/tctestdomuvrvoiregdiag.cfg
+../conf/tctestdomuvrvoiregdiag.cfg                    /epoc32/data/z/system/data/tctestdomuvrvoiregdiag.cfg
+
+PRJ_EXPORTS
+
+
+PRJ_TESTMMPFILES
+testdomuivoicerengn.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/group/testdomuivoicerengn.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#include <data_caging_paths.hrh> 
+#include <platform_paths.hrh>
+
+TARGET          testdomuivoicerengn.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2001CB80
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         testdomuivoicerengn.def
+
+USERINCLUDE     ../inc 
+SYSTEMINCLUDE   /epoc32/include/domain/applications
+    
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          testdomuivoicerengn.cpp
+SOURCE          testdomuivoicerengnblocks.cpp 
+SOURCE          testdomuvrblocksvoicerecog.cpp 
+SOURCE          testdomuvrblocksvoiregdiag.cpp
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         VoiceUiRecognition.lib 
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/group/testdomuivoicerengn.pkg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,42 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+&EN
+
+; Header
+#{"testdomuivoicerengn"}, (0x2001CB80), 1, 0, 0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+
+;Copying ordinary file (not language dependent) to fixed drive drive.
+
+"..\init\testdomuivoicerengn.ini"-"c:\Testframework\testdomuivoicerengn.ini"
+"..\conf\tctestdomuvrvoicerecog.cfg"-"c:\Testframework\tctestdomuvrvoicerecog.cfg"
+"..\conf\ui_testdomuvrvoicerecog.cfg"-"c:\Testframework\ui_testdomuvrvoicerecog.cfg"
+"..\conf\tctestdomuvrvoiregdiag.cfg"-"c:\Testframework\tctestdomuvrvoiregdiag.cfg"
+"..\conf\ui_testdomuvrvoiregdiag.cfg"-"c:\Testframework\ui_testdomuvrvoiregdiag.cfg"
+"\epoc32\RELEASE\ARMV5\urel\testdomuivoicerengn.dll"-"c:\sys\bin\testdomuivoicerengn.dll"
+
+
+
+; Trim For Mms
+; ------------
+; to be added later
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/inc/testdomuivoicerengn.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test ui voice recognition api modules
+*
+*/
+
+
+
+#ifndef C_TESTDOMUIVOICERENGN_H
+#define C_TESTDOMUIVOICERENGN_H
+
+//  INCLUDES
+#include <stiflogger.h>
+#include <testscripterinternal.h>
+#include <stiftestmodule.h>
+#include <testclassassert.h>
+#include <vuicvoicerecog.h>
+#include <vuicvoicerecogdialog.h>
+
+// MACROS
+#define TEST_CLASS_VERSION_MAJOR 0
+#define TEST_CLASS_VERSION_MINOR 0
+#define TEST_CLASS_VERSION_BUILD 0
+
+// Logging path
+_LIT( KtestdomuivoicerengnLogPath, "\\logs\\testframework\\testdomuivoicerengn\\" ); 
+// Log file
+_LIT( KtestdomuivoicerengnLogFile, "testdomuivoicerengn.txt" ); 
+_LIT( KtestdomuivoicerengnLogFileWithTitle, "testdomuivoicerengn_[%S].txt" );
+
+class CVoiceRecog;
+class CVoiceRecognitionDialog;
+
+/**
+*  CTestDOMUiVoiceRengn test class for STIF Test Framework TestScripter.
+*  @since S60 5.0
+*/
+NONSHARABLE_CLASS( CTestDOMUiVoiceRengn ) : public CScriptBase
+    {
+public:  // Constructors and destructor
+
+    /**
+    * Two-phased constructor.
+    */
+    static CTestDOMUiVoiceRengn* NewL( CTestModuleIf& aTestModuleIf );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CTestDOMUiVoiceRengn();
+
+public: // Functions from base classes
+
+    /**
+    * From CScriptBase Runs a script line.
+    * @since S60 5.0
+    * @param aItem Script line containing method name and parameters
+    * @return Symbian OS error code
+    */
+    virtual TInt RunMethodL( CStifItemParser& aItem );
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CTestDOMUiVoiceRengn( CTestModuleIf& aTestModuleIf );
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL();
+    
+    /**
+     * Method used to log version of test class
+     */
+    void SendTestClassVersion();
+    
+        /**
+     * Turn off ScreenSaver
+     * @since S60 5.0
+     * @return Symbian OS error code.
+     */
+    void TurnOffScreenSaver();
+
+    /**
+     * Restore ScreenSaver
+     * @since S60 5.0
+     * @return Symbian OS error code.
+     */
+    void RestoreScreenSaver();
+
+	// [TestMethods]
+private:// for testing the vuicvoicerecog.h
+	
+    /**
+    * TestVuicVocRecogNewL test method for testing the NewL method
+    * @since S60 5.0
+    * @param aItem Script line containing parameters.
+    * @return Symbian OS error code.
+    */
+    virtual TInt TestVuicVocRecogNewL( CStifItemParser& aItem );
+    
+    /**
+    * TestVuicVocRecogNewLC test method for testing the NewLC method
+    * @since S60 5.0
+    * @param aItem Script line containing parameters.
+    * @return Symbian OS error code.
+    */
+    virtual TInt TestVuicVocRecogNewLCL( CStifItemParser& aItem );
+    
+    // for testing the vuicvoicerecogdialog.h
+    /**
+    * TestVoceRegDalgCVoceRegDialogL test method for testing the CVoiceRecognitionDialog method
+    * @since S60 5.0
+    * @param aItem Script line containing parameters.
+    * @return Symbian OS error code.
+    */
+    virtual TInt TestVoceRegDalgCVoceRegDialogL( CStifItemParser& aItem );
+    
+    /**
+    * TestVoceRegDalgDestructor test method for testing the ~CVoiceRecognitionDialog method
+    * @since S60 5.0
+    * @param aItem Script line containing parameters.
+    * @return Symbian OS error code.
+    */
+    virtual TInt TestVoceRegDalgDestructor( CStifItemParser& aItem );
+    /**
+    * TestVoceRegDalgExecuteLD test method for testing the ExecuteLD method
+    * @since S60 5.0
+    * @param aItem Script line containing parameters.
+    * @return Symbian OS error code.
+    */
+    virtual TInt TestVoceRegDalgExecuteLDL( CStifItemParser& aItem );
+    /**
+    * TestVoceRegDalgCancel test method for testing the Cancel method
+    * @since S60 5.0
+    * @param aItem Script line containing parameters.
+    * @return Symbian OS error code.
+    */
+    virtual TInt TestVoceRegDalgCancel( CStifItemParser& aItem );
+private:    // Data
+
+    /**
+     * ScreenSaver Property
+     */
+    TInt iOldScreenSaverProperty;
+
+    /**
+     * Own Member
+     *
+     */
+    CVoiceRecog* iVoiceRecog;
+    /**
+     * Own Member
+     *
+     */
+    CVoiceRecognitionDialog* iVoiceRecogDialog;
+
+    };
+
+#endif      // C_TESTDOMUIVOICERENGN_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/init/testdomuivoicerengn.ini	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,184 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+# - Set Test Reporting mode. TestReportMode's possible values are:
+#     + 'Summary': Summary of the tested test cases.
+#     + 'Environment': Hardware and software info.
+#     + 'TestCases': Test case report.
+#     + 'FullReport': Set of all above ones.
+#     + Example 'TestReportMode= Summary TestCases'
+#
+#     - CreateTestReport setting controls report creation mode
+#     + YES, Test report will created.
+#     + NO, No Test report.
+#
+#     - File path indicates the base path of the test report.
+#     - File name indicates the name of the test report.
+#
+#     - File format indicates the type of the test report.
+#     + TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#     + HTML, Test report will be html type, for example 'TestReport.html'.
+#
+#     - File output indicates output source of the test report.
+#     + FILE, Test report logging to file.
+#     + RDEBUG, Test report logging to using rdebug.
+#
+#     - File Creation Mode indicates test report overwriting if file exist.
+#     + OVERWRITE, Overwrites if the Test report file exist.
+#     + APPEND, Continue logging after the old Test report information if 
+#           report exist.
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 
+                              # 'Summary', 'Environment', 'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT         # Possible values: TXT or HTML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE    # Possible values: OVERWRITE or APPEND
+UITestingSupport= Yes
+SeparateProcesses= YES
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= testdomuivoicerengntestdomuivoicerengntestdomuivoicerengn
+# Modules might have initialisation file, specified as
+# IniFile= YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= NormalCases.txt
+# TestCaseFile= SmokeCases.txt
+# TestCaseFile= ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testcombiner
+TestCaseFile= c:\testframework\tctestdomuvrvoicerecog.cfg
+TestCaseFile= c:\testframework\tctestdomuvrvoiregdiag.cfg
+[End_Module]
+
+#[New_Module]
+#ModuleName= testscripter
+#TestCaseFile= c:\testframework\ui_testdomuvrvoicerecog.cfg
+#TestCaseFile= c:\testframework\ui_testdomuvrvoiregdiag.cfg
+#[End_Module]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+#Load testmoduletestdomuivoicerengn, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuletestdomuivoicerengn used initialization file
+#IniFile= init.txt
+
+#TestModuletestdomuivoicerengn used configuration file(s)
+#TestCaseFile= testcases1.cfg
+#TestCaseFile= testcases2.cfg
+#TestCaseFile= manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIFTestFramework logging overwrite parameters for Logger.
+# Hardware and emulator environment logging path and styles can
+# be configured from here to overwrite the Logger's implemented values.
+#	
+# Settings description:
+# - Indicates option for creation log directory/directories. If log directory/directories
+#       is/are not created by user they will make by software.
+#     + YES, Create log directory/directories if not allready exist.
+#     + NO, Log directory/directories not created. Only created one is used.
+#
+# - Overwrite emulator path setting.
+#     + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#       Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#       will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+# - Overwrite emulator's logging format.
+#     + TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#     + HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+# - Overwrited emulator logging output source.
+#     + FILE, Logging to file(s).
+#     + RDEBUG, Logging to using rdebug(s).
+#
+# - Overwrite hardware path setting (Same description as above in emulator path).
+# - Overwrite hardware's logging format(Same description as above in emulator format).
+# - Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+# - File Creation Mode indicates file overwriting if file exist.
+#     + OVERWRITE, Overwrites if file(s) exist.
+#     + APPEND, Continue logging after the old logging information if file(s) exist.
+#
+# - Will thread id include to the log filename.
+#     + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#     + NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+# - Will time stamps include the to log file.
+#     + YES, Time stamp added to each line in log file(s). Time stamp is 
+#       for example'12.Nov.2003 115958 LOGGING INFO'
+#     + NO, No time stamp(s).
+#
+# - Will line breaks include to the log file.
+#     + YES, Each logging event includes line break and next log event is in own line.
+#     + NO, No line break(s).
+#
+# - Will event ranking include to the log file.
+#     + YES, Event ranking number added to each line in log file(s). Ranking number 
+#       depends on environment's tics, for example(includes time stamp also)
+#       '012   12.Nov.2003 115958    LOGGING INFO'
+#     + NO, No event ranking.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' 
+
+CreateLogDirectories= YES    # Possible values: YES or NO
+
+EmulatorBasePath= C:\LOGS\TestFramework\
+EmulatorFormat= HTML         # Possible values: TXT or HTML
+EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML        # Possible values: TXT or HTML
+#HardwareOutput= FILE        # Possible values: FILE or RDEBUG
+
+FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES      # Possible values: YES or NO
+#WithTimeStamp= YES          # Possible values: YES or NO
+#WithLineBreak= YES          # Possible values: YES or NO
+#WithEventRanking= YES       # Possible values: YES or NO
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuivoicerengn.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,194 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test ui voice recognition api modules
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <stiftestinterface.h>
+#include <settingserverclient.h>
+#include <screensaverinternalpskeys.h>
+#include <e32property.h>
+
+#include "testdomuivoicerengn.h"
+
+// CONSTANTS
+_LIT( KModuleName, "testdomuivoicerengn.dll" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::CTestDOMUiVoiceRengn
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTestDOMUiVoiceRengn::CTestDOMUiVoiceRengn( CTestModuleIf& aTestModuleIf ):
+    CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::~CTestDOMUiVoiceRengn
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTestDOMUiVoiceRengn::~CTestDOMUiVoiceRengn()
+    {
+    // Delete logger
+    delete iLog; 
+    if( iVoiceRecog )
+        {
+        delete iVoiceRecog;
+        iVoiceRecog = NULL;
+        }
+    if( iVoiceRecogDialog )
+        {
+        delete iVoiceRecogDialog;
+        iVoiceRecogDialog = NULL;
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTestDOMUiVoiceRengn::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    CleanupClosePushL( settingServer );
+    TInt ret = settingServer.Connect();
+    if ( ret != KErrNone )
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings( loggerSettings );
+    if ( ret != KErrNone )
+        {
+        User::Leave( ret );
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    CleanupStack::PopAndDestroy( &settingServer );
+
+    TFileName logFileName;
+    
+    if ( loggerSettings.iAddTestCaseTitle )
+        {
+        TName title;
+        TestModuleIf().GetTestCaseTitleL( title );
+        logFileName.Format( KtestdomuivoicerengnLogFileWithTitle, &title );
+        }
+    else
+        {
+        logFileName.Copy( KtestdomuivoicerengnLogFile );
+        }
+
+    iLog = CStifLogger::NewL( KtestdomuivoicerengnLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    
+    SendTestClassVersion();
+    
+    TurnOffScreenSaver();
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTestDOMUiVoiceRengn* CTestDOMUiVoiceRengn::NewL( CTestModuleIf& aTestModuleIf )
+    {
+    CTestDOMUiVoiceRengn* self = new( ELeave ) CTestDOMUiVoiceRengn( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+
+    }
+
+//-----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CTestDOMUiVoiceRengn::SendTestClassVersion()
+    {
+    TVersion moduleVersion;
+    moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
+    moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
+    moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
+
+    TFileName moduleName;
+    moduleName = KModuleName;
+
+    TBool newVersionOfMethod = ETrue;
+    TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, 
+        newVersionOfMethod );
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+    return ( CScriptBase* ) CTestDOMUiVoiceRengn::NewL( aTestModuleIf );
+    }
+
+// -----------------------------------------------------------------------------
+// Turn off ScreenSaver
+// -----------------------------------------------------------------------------
+//
+void CTestDOMUiVoiceRengn::TurnOffScreenSaver()
+    {
+    TInt err1 = RProperty::Get( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
+        iOldScreenSaverProperty );
+    TInt err2 = RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
+        KScreenSaverAllowScreenSaver );    
+    RDebug::Printf( "screensaver property=%d err1=%d err2=%d\n", 
+        iOldScreenSaverProperty, err1, err2 );
+    }
+
+// -----------------------------------------------------------------------------
+// Restore ScreenSaver
+// -----------------------------------------------------------------------------
+//
+void CTestDOMUiVoiceRengn::RestoreScreenSaver()
+    {
+    RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
+        iOldScreenSaverProperty );
+    User::ResetInactivityTime();
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuivoicerengnblocks.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test ui voice recognition api modules
+*
+*/
+
+
+
+// [INCLUDE FILES]
+#include <e32svr.h>
+#include <stifparser.h>
+#include <stiftestinterface.h>
+#include <vuicvoicerecog.h>
+#include <vuicvoicerecogdialog.h>
+
+#include "testdomuivoicerengn.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::RunMethodL( CStifItemParser& aItem ) 
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {  
+        // First string is the function name used in TestScripter script file.
+        // Second is the actual implementation member function. 
+        ENTRY( "TestVuicVocRecogNewL", 
+               CTestDOMUiVoiceRengn::TestVuicVocRecogNewL ),
+        ENTRY( "TestVuicVocRecogNewLCL", 
+                CTestDOMUiVoiceRengn::TestVuicVocRecogNewLCL ),
+        ENTRY( "TestVoceRegDalgCVoceRegDialogL", 
+                CTestDOMUiVoiceRengn::TestVoceRegDalgCVoceRegDialogL ),
+        ENTRY( "TestVoceRegDalgDestructor", 
+                CTestDOMUiVoiceRengn::TestVoceRegDalgDestructor ),
+        ENTRY( "TestVoceRegDalgExecuteLDL", 
+                CTestDOMUiVoiceRengn::TestVoceRegDalgExecuteLDL ),
+        ENTRY( "TestVoceRegDalgCancel", 
+                CTestDOMUiVoiceRengn::TestVoceRegDalgCancel ),
+        // [test cases entries]
+
+        };
+
+    const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+//  [End of File]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuvrblocksvoicerecog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test ui voice recognition api modules
+*
+*/
+
+
+
+// [INCLUDE FILES]
+#include <e32svr.h>
+#include <stifparser.h>
+#include <stiftestinterface.h>
+#include <vuicvoicerecog.h>
+#include <vuicvoicerecogdialog.h>
+
+#include "testdomuivoicerengn.h"
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::TestVuicVocRecogNewL
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::TestVuicVocRecogNewL( CStifItemParser& /*aItem*/ )
+    {
+
+    // Print to UI
+    _LIT( Ktestdomuivoicerecgnin, "testdomuivoicerecgnin" );
+    _LIT( KTestVuicVocRecogNewL, "In TestVuicVocRecogNewL" );
+    TestModuleIf().Printf( 0, Ktestdomuivoicerecgnin, KTestVuicVocRecogNewL );
+    // Print to log file
+    iLog->Log( KTestVuicVocRecogNewL );
+
+    TInt Err = KErrNone;
+    
+    iVoiceRecog = CVoiceRecog::NewL();
+    STIF_ASSERT_NOT_NULL( iVoiceRecog );
+    
+    return Err;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::TestVuicVocRecogNewLCL
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::TestVuicVocRecogNewLCL( CStifItemParser& /*aItem*/ )
+    {
+
+    // Print to UI
+    _LIT( Ktestdomuivoicerecgnin, "testdomuivoicerecgnin" );
+    _LIT( KTestVuicVocRecogNewLC, "In TestVuicVocRecogNewLC" );
+    TestModuleIf().Printf( 0, Ktestdomuivoicerecgnin, KTestVuicVocRecogNewLC );
+    // Print to log file
+    iLog->Log( KTestVuicVocRecogNewLC );
+
+    TInt Err = KErrNone;
+    
+    iVoiceRecog = CVoiceRecog::NewLC();
+    CleanupStack::Pop( iVoiceRecog );
+    STIF_ASSERT_NOT_NULL( iVoiceRecog );
+    
+    return Err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/tsrc/src/testdomuvrblocksvoiregdiag.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test ui voice recognition api modules
+*
+*/
+
+
+
+// [INCLUDE FILES]
+#include <e32svr.h>
+#include <stifparser.h>
+#include <stiftestinterface.h>
+#include <vuicvoicerecog.h>
+#include <vuicvoicerecogdialog.h>
+
+#include "testdomuivoicerengn.h"
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::TestVoceRegDalgCVoceRegDialogL
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::TestVoceRegDalgCVoceRegDialogL( CStifItemParser& /*aItem*/ )
+    {
+
+    // Print to UI
+    _LIT( Ktestdomuivoicerecgnin, "testdomuivoicerecgnin" );
+    _LIT( KTestVoceRegDalgCVoceRegDialog, "In TestVoceRegDalgCVoceRegDialog" );
+    TestModuleIf().Printf( 0, Ktestdomuivoicerecgnin, KTestVoceRegDalgCVoceRegDialog );
+    // Print to log file
+    iLog->Log( KTestVoceRegDalgCVoceRegDialog );
+
+    TInt Err = KErrNone;
+    
+    iVoiceRecogDialog = new (ELeave) CVoiceRecognitionDialog();
+    STIF_ASSERT_NOT_NULL( iVoiceRecogDialog );
+    
+    return Err;
+    }
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::TestVoceRegDalgDestructor
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::TestVoceRegDalgDestructor( CStifItemParser& /*aItem*/ )
+    {
+
+    // Print to UI
+    _LIT( Ktestdomuivoicerecgnin, "testdomuivoicerecgnin" );
+    _LIT( KTestVoceRegDalgDestructor, "In TestVoceRegDalgDestructor" );
+    TestModuleIf().Printf( 0, Ktestdomuivoicerecgnin, KTestVoceRegDalgDestructor );
+    // Print to log file
+    iLog->Log( KTestVoceRegDalgDestructor );
+
+    TInt Err = KErrNone;
+      
+    delete iVoiceRecogDialog;
+    iVoiceRecogDialog = NULL;
+    
+    return Err;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::TestVoceRegDalgExecuteLDL
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::TestVoceRegDalgExecuteLDL( CStifItemParser& /*aItem*/ )
+    {
+
+    // Print to UI
+    _LIT( Ktestdomuivoicerecgnin, "testdomuivoicerecgnin" );
+    _LIT( KTestVoceRegDalgExecuteLD, "In TestVoceRegDalgExecuteLD" );
+    TestModuleIf().Printf( 0, Ktestdomuivoicerecgnin, KTestVoceRegDalgExecuteLD );
+    // Print to log file
+    iLog->Log( KTestVoceRegDalgExecuteLD );
+
+    TInt Err = KErrNone;
+      
+    iVoiceRecogDialog->ExecuteLD();
+    iVoiceRecogDialog = NULL;
+    
+    return Err;
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDOMUiVoiceRengn::TestVoceRegDalgCancel
+// -----------------------------------------------------------------------------
+//
+TInt CTestDOMUiVoiceRengn::TestVoceRegDalgCancel( CStifItemParser& /*aItem*/ )
+    {
+
+    // Print to UI
+    _LIT( Ktestdomuivoicerecgnin, "testdomuivoicerecgnin" );
+    _LIT( KTestVoceRegDalgCancel, "In TestVoceRegDalgCancel" );
+    TestModuleIf().Printf( 0, Ktestdomuivoicerecgnin, KTestVoceRegDalgCancel );
+    // Print to log file
+    iLog->Log( KTestVoceRegDalgCancel );
+
+    TInt Err = KErrNone;
+      
+    iVoiceRecogDialog->Cancel();
+    iVoiceRecogDialog = NULL;
+    
+    return Err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/ui_voice_recognition_api/ui_voice_recognition_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="a6f43bff71d50ea895ef6be5687f5318" dataversion="2.0">
+  <name>UI Voice Recognition API</name>
+  <description>The Recognition portion of UI</description>
+  <type>c++</type>
+  <collection>voiceui</collection>
+  <libs>
+    <lib name="VoiceUiRecognition.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                VAS API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssvasmdeletetagclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmdeletetagclient.h)
+../inc/nssvasmplayeventhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmplayeventhandler.h)
+../inc/nssvascrecognitionhandlerbuilder.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvascrecognitionhandlerbuilder.h)
+../inc/nssvasmadaptationitem.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmadaptationitem.h)
+../inc/nssvasmgettagreferenceclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmgettagreferenceclient.h)
+../inc/nssvasmsavecontextclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmsavecontextclient.h)
+../inc/nssvasmgettagclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmgettagclient.h)
+../inc/nssvasmtag.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtag.h)
+../inc/nssvasmsavetagclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmsavetagclient.h)
+../inc/vascvpbkhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(vascvpbkhandler.h)
+../inc/nssvasmdeletecontextclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmdeletecontextclient.h)
+../inc/nssvasmrecognizeinitcompletehandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmrecognizeinitcompletehandler.h)
+../inc/nssvasmgetcontextclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmgetcontextclient.h)
+../inc/nssvasmrejecttagcompletehandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmrejecttagcompletehandler.h)
+../inc/vasmbasepbkhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(vasmbasepbkhandler.h)
+../inc/nssvascvasdbmgr.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvascvasdbmgr.h)
+../inc/nssvasmspeechitem.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmspeechitem.h)
+../inc/nssvasctrainingparameters.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasctrainingparameters.h)
+../inc/nssvasmvasdbeventnotifier.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmvasdbeventnotifier.h)
+../inc/nssvasmtagmgr.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtagmgr.h)
+../inc/nssvasmcontextmgr.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmcontextmgr.h)
+../inc/nssvasmadaptationeventhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmadaptationeventhandler.h)
+../inc/nssvasmcontext.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmcontext.h)
+../inc/nssvasapi.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasapi.h)
+../inc/nssvasmvasdatabaseobserver.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmvasdatabaseobserver.h)
+../inc/nssvasmrrd.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmrrd.h)
+../inc/nssvasmtagselecthandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtagselecthandler.h)
+../inc/nssvasmrecognizeeventhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmrecognizeeventhandler.h)
+../inc/nssvascoreconstant.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvascoreconstant.h)
+../inc/nssvasmresetfactorymodelsclient.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmresetfactorymodelsclient.h)
+../inc/vasmcontactobserver.h     APP_LAYER_PLATFORM_EXPORT_PATH(vasmcontactobserver.h)
+../inc/nssvasmtrainvoiceeventhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtrainvoiceeventhandler.h)
+../inc/nssvasmtagselectnotification.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtagselectnotification.h)
+../inc/nssvascvasdbevent.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvascvasdbevent.h)
+../inc/nssvasmtagreference.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtagreference.h)
+../inc/nssvasmrecognitionhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmrecognitionhandler.h)
+../inc/nssvasmtraintexteventhandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasmtraintexteventhandler.h)
+../inc/nssvascselectnotificationbuilder.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvascselectnotificationbuilder.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasapi.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains a list of headers constituting the VAS APIs
+*               A VAS client can choose to include all headers at once, or include
+*               a header corresponding to the service required.
+*
+*/
+
+
+// for Tag and Context management
+#include <nssvascvasdbmgr.h>
+#include <nssvasmtagmgr.h>				
+#include <nssvasmcontextmgr.h>	
+
+// for operations on a Tag, Context, RRD, and SpeechItem
+#include <nssvasmtag.h>
+#include <nssvasmcontext.h>			
+#include <nssvasmrrd.h>
+#include <nssvasmspeechitem.h>	
+#include <nssvascoreconstant.h>
+#include <nssvasmtagreference.h>
+
+// for Tag train and playback call backs			
+#include <nssvasmplayeventhandler.h>	
+#include <nssvasmtrainvoiceeventhandler.h>
+#include <nssvasmtraintexteventhandler.h>
+		
+// for Tag and Context: get, save and delete call backs
+#include <nssvasmgettagclient.h>
+#include <nssvasmsavetagclient.h>	
+#include <nssvasmdeletetagclient.h>
+#include <nssvasmgetcontextclient.h>			
+#include <nssvasmsavecontextclient.h>	
+#include <nssvasmdeletecontextclient.h>
+#include <nssvasmgettagreferenceclient.h>			
+	
+// for NssVAS DB change notification
+#include <nssvasmvasdatabaseobserver.h>
+#include <nssvasmvasdbeventnotifier.h>
+#include <nssvascvasdbevent.h>	
+
+// for Tag recognition, and recognition call backs
+#include <nssvascrecognitionhandlerbuilder.h>
+#include <nssvasmrecognitionhandler.h>		
+#include <nssvasmrecognizeeventhandler.h>
+#include <nssvasmrecognizeinitcompletehandler.h>
+#include <nssvasmrejecttagcompletehandler.h>
+
+// for Tag selection, and tag selection call backs
+#include <nssvascselectnotificationbuilder.h>
+#include <nssvasmtagselecthandler.h>	
+#include <nssvasmtagselectnotification.h>
+
+// for Contact Handler
+#include <nssvasccontacthandler.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvascoreconstant.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The TNssVasCoreConstant provides constant values used by the VAS.
+*
+*/
+
+
+#ifndef NSSVASCORECONSTANT_H
+#define NSSVASCORECONSTANT_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+
+// CONSTANTS
+// default DB value for new item
+const TInt KNssVASDbDefaultValue = -1;     
+
+// this value is used for recording time [micro second]
+const TInt KNssVASRecordTime = 5000000; //4000000;    
+
+// this value is used for Vas API's UID
+const TUid KNssVASApiUid = { 0x101F853F };    
+
+_LIT( KVasDatabaseName, "c:nssvasdatabase.db");
+_LIT( KVasDatabaseFormatString, "SECURE[10201AFE]");
+static const TInt KVasDatabaseDrive = 'C';
+
+
+// Char used to separate firstname-lastname
+// Note that first and only first symbol is used.
+// Do not make it empty (""), it will cause run-time error in 
+// CNssContactHandlerImplementation 
+_LIT ( KNameSeparator, "_" );
+
+
+// Indexes for extension training
+_LIT( KNameTrainingIndex, "1" );
+_LIT( KExtensionTrainingIndex, "2" );
+
+// Number of characters required by escape character (separator) and index
+const TInt KTrainingIndexSize = 2;
+
+// Format string which is substituted with name
+_LIT( KExtensionFormatString, "%U" );
+
+
+// Indexes of RRD data
+// Contact ID
+const TInt KVasContactIdRrdLocation = 0;
+// Field ID
+const TInt KVasFieldIdRrdLocation = 1;
+// Type of the extension command (SINDE action)
+const TInt KVasExtensionRrdLocation = 2;
+// Type of the voice tag (see TVasTagType)
+const TInt KVasTagTypeRrdLocation = 3;
+// Extension command id
+const TInt KVasExtensionCommandRrdLocation = 4;
+
+// SINDE command
+enum TVasExtensionCommand
+    {
+    EDefaultCommand,
+    EMobileCommand,
+    EGeneralCommand,
+    EWorkCommand,
+    EHomeCommand,
+    EEmailCommand,
+    EVideoCommand,
+    EVoipCommand,
+    EMessageCommand
+    };
+
+// Extension action of the voice tag
+// Located in KVasExtensionRrdLocation
+enum TVasExtensionAction
+    {
+    EDial,
+    ENewMessage,
+    ENewEmail
+    }; 
+
+// Type of the voice tag which is saved to VAS database
+// Located in KVasTagTypeRrdLocation
+enum TVasTagType
+    {
+    ETagTypeUnknown = 0,
+    ETagTypeName,
+    ETagTypeCompanyName,
+    ETagTypeNickName
+    };
+
+// Publish & Subscribe constants
+
+// All the SIND values are part of the whole system state. Should be set
+// and read by various Nokia processes
+// Therefore SIND properties are published in the system category
+const TUid KSINDUID = {KUidSystemCategoryValue};
+
+enum TSINDKeys
+    {    
+    ERecognitionState=0,   
+    ETrainingContactsState,
+    EVoiceTagSelectionTagId,
+    EVoiceTagSelectionContextId,
+    // Key used for cache sync updates between the VCommandHandler instances
+    ECommandHandlerTickKey
+    };
+
+// Recognition state values for P&S
+enum TRecognitionStateValues
+    {
+    ERecognitionStarted = 0, 
+    ERecognitionSpeechEnd, 
+    ERecognitionSuccess, 
+    ERecognitionFail
+    };
+
+// Contact handler state values for P&S
+// Tell if contact handler is busy training contacts and other clients
+// should delay VAS operations    
+enum TTrainingContactsStateValues
+    {
+    EContactsNoTraining = 0,
+    EContactsTraining
+    };
+
+_LIT( KNssVASDBOutOfSync, "VASDB OutOfSync" );
+ 
+/**
+* The TNssVasCoreConstant provides constant values used by the VASAPI methods and clients.
+*
+* @lib NssVasApi.lib
+* @since 2.0
+*/
+class TNssVasCoreConstant
+{
+public:
+
+    /**
+    * TNssTrainedType will have all the enums to represent the trained type.
+    */    
+    enum TNssTrainedType
+        {
+        EVasNotTrained,
+        EVasTrainVoice,
+        EVasTrainText
+        };
+
+
+    /**
+    * TNssTrainingCapability will have all the enums to represent the training capabilities
+    * 
+    */    
+    enum TNssTrainingCapability
+        {
+        EVasTrainCapVoice
+        };
+        
+    // For Virtual Phonebook compliance
+    // (Not used inside VAS)
+    enum TNssVASErrorCode
+        {	
+        EVasSuccess,
+        EVasFailure
+        };
+
+    enum TNssVASPanicCodes
+        {
+        EVasDBSrsDBOutOfSync
+        };
+};
+
+#endif /* __VASCORECONSTANT_H__ */
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvascrecognitionhandlerbuilder.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssRecognitionHandlerBuilder class performs initialization 
+*                for CNssRecognitionHandler the  class. 
+*
+*/
+
+
+#ifndef CNSSRECOGNITIONHANDLERBUILDER_H
+#define CNSSRECOGNITIONHANDLERBUILDER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32def.h>
+#include "nssvasmrecognitionhandler.h"
+
+// FORWARD DECLARATIONS
+
+class CNssRecognitionHandler;
+
+
+// CLASS DECLARATION
+
+/**
+*
+*  The CNssRecognitionHandlerBuilder class performs initialization for the 
+*  CNssRecognitionHandler class.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssRecognitionHandlerBuilder :public CBase
+    {
+
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */		
+		IMPORT_C static CNssRecognitionHandlerBuilder* NewL();
+
+        /**
+        * Two-phased constructor.
+        */			
+		IMPORT_C static CNssRecognitionHandlerBuilder* NewLC();
+        
+        /**
+        * Destructor.
+        */				
+		~CNssRecognitionHandlerBuilder();
+
+    public: // New functions
+        
+         /**
+        * Initialize RecognitionHandler object 
+        * @since 2.0
+        * @return void
+        */ 
+        IMPORT_C void InitializeL();
+
+        /**
+        * Get a Pointer to Recognition Handler object.
+        * @since 2.0
+        * @return MNssRecognitionHandler* Pointer to the MNssRecognitionHandler
+		*                              object.
+        */
+        IMPORT_C MNssRecognitionHandler* GetRecognitionHandler();
+
+    private:
+
+		/**
+        * Constructor.
+        */	
+		CNssRecognitionHandlerBuilder();
+
+    private:    // Data
+
+		// Pointer to the Recognition Handler object.
+		CNssRecognitionHandler  * iRecognitionHandler;
+
+    };
+
+#endif      // CRECOGNITIONHANDLERBUILDER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvascselectnotificationbuilder.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSelectNotificationBuilder class performs initialization 
+*                for the CNssTagSelectNotification class. 
+*
+*/
+
+
+#ifndef CNSSSELECTNOTIFICATIONBUILDER_H
+#define CNSSSELECTNOTIFICATIONBUILDER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+#include <e32def.h>
+#include "nssvasmtagselectnotification.h"
+
+// FORWARD DECLARATIONS
+
+class CNssTagSelectNotification; 
+
+// CLASS DECLARATION
+
+/**
+*
+*  The CNssSelectNotificationBuilder class performs initialization for the 
+*  CNssTagSelectNotification class.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssSelectNotificationBuilder :public CBase
+    {
+    public:  // Constructors and destructor
+			 
+        /**
+        * Two-phased constructor.
+        */		
+        IMPORT_C static CNssSelectNotificationBuilder* NewL();
+
+        /**
+        * Two-phased constructor.
+        */	
+        IMPORT_C static CNssSelectNotificationBuilder* NewLC();
+
+        /**
+        * Destructor.
+        */	
+        ~CNssSelectNotificationBuilder();
+
+    public: // New functions
+
+        /**
+        * Initialize Tag Select Notification object 
+        * @since 2.0
+        * @return no return value.
+        */ 
+        IMPORT_C void InitializeL();
+
+        /**
+        * Get a Pointer to Tag Select Notification object.
+        * @since 2.0
+        * @return MNssTagSelectNotification* Pointer to the MNssTagSelectNotification
+		*                                 object.
+        */ 
+        IMPORT_C MNssTagSelectNotification* GetTagSelectNotification();
+
+    private:
+
+        /**
+        * Constructor. 
+        */ 
+        CNssSelectNotificationBuilder();
+
+    private:    // Data
+
+		// Pointer to the Tag Select Notification object.
+        CNssTagSelectNotification* iTagSelectNotification;
+
+    };
+
+#endif      // CNSSSELECTNOTIFICATIONBUILDER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasctrainingparameters.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CTag implements MTag. In addition, it provides members for use
+*               by VAS internal components.
+*
+*/
+
+
+#ifndef NSSVASCTRAININGPARAMETERS_H
+#define NSSVASCTRAININGPARAMETERS_H
+
+// includes
+#include <nssvasmspeechitem.h>
+#include "nssvasmtag.h"
+#include "nssvasmcontext.h"
+#include "nssvasmrrd.h"
+#include "nssvascoreconstant.h"
+
+// TYPEDEFS
+typedef RArray<TLanguage> RTrainingLanguageArray;
+
+// CLASS DECLARATION
+
+/**
+*  CTag is the implementation class for MTag interface. 
+*  It encapsulates tag data. A tag cannot be directly created by a client. 
+*  A client has to own an instance of Tag Manager which has methods for creating 
+*  tag objects. The CTag class also provides additional members for internal 
+*  use by VAS.
+*  @lib VASApi.lib
+*  @since 2.8
+*/
+class CNssTrainingParameters: public CBase
+    {
+    public:
+
+        /**
+        * Two-phased constructor
+        * @since 2.8
+        * @return Created instance
+        */
+        IMPORT_C static CNssTrainingParameters* NewL();
+
+        /**
+        * Two-phased constructor
+        * @since 2.8
+        * @return Created instance
+        */
+        IMPORT_C static CNssTrainingParameters* NewLC();
+
+        /**
+        * Virtuous destructor. Inherited from CBase.
+        * @since 2.8
+        */
+        IMPORT_C virtual ~CNssTrainingParameters();
+
+        /**
+        * When text is transformed into pronunciation, the outcome depends on
+        * language. List the languages, for which pronunciations should be
+        * generated.
+        * @since 2.8
+        * @param aLanguageArray The list of languages
+        */
+        IMPORT_C void SetLanguages( RArray<TLanguage>* aLanguageArray );
+
+        /**
+        * When text is transformed into pronunciation, the outcome depends on
+        * language. List the languages, for which pronunciations should be
+        * generated.
+        * @since 2.8
+        * @return Array of languages.
+        */
+        IMPORT_C const RArray<TLanguage>& Languages() const;
+
+        /**
+        * Set the separator between the first name and the last name.
+        * @since 2.8
+        * @param aSeparator The separator
+        */
+        IMPORT_C void SetSeparator( TChar aSeparator );
+
+        /**
+        * Returns the separator character.
+        * @since 2.8
+        * @return The separator between the first name and the last name.
+        */
+        IMPORT_C TChar Separator() const;
+        
+        /**
+        * Sets languages for SINDE type of training
+        * @since 3.1
+        * @param aLanguageArray Two dimensional language array
+        */
+        IMPORT_C void SetSindeLanguages( const RArray<RTrainingLanguageArray>& aLanguageArray );
+        
+        /**
+        * Returns the list of SIND training languages.
+        * @since 3.1
+        * @return Array of language arrays
+        */
+        IMPORT_C const RArray<RTrainingLanguageArray>& SindeLanguagesL() const;
+
+    private:
+    
+        /**
+        * C++ constructor.
+        */
+        CNssTrainingParameters();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+        
+        /**
+        * Destroys SIND language array.
+        */
+        void CNssTrainingParameters::ResetSindeLanguageArray();
+
+    private:
+
+        // Word separator
+        TChar iSeparator;
+
+        // Language array, owned
+        RArray<TLanguage>* iLanguages;
+        
+        // Array of language arrays for SINDE training, owned
+        RArray<RTrainingLanguageArray> iSindeLanguages;
+};
+
+#endif // NSSVASCTRAININGPARAMETERS_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvascvasdbevent.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssVASDBEvent encapsulates events occuring on the VAS DB.
+*
+*/
+
+
+#ifndef TNSSVASDBEVENT_H
+#define TNSSVASDBEVENT_H
+
+//  INCLUDES
+#include <nssvasmtag.h>
+
+// CLASS DECLARATION
+
+/**
+*  CNssVASDBEvent class encapsulates a VAS DB event.
+*  A VAS DB evnt consists of the type of event and the tag object on which the event occured. 
+*  The enumeration above shows the event types. Symbian DBMS event types do not have tag
+*  tag with them (set to NULL). The client is responsible for deleting the event object,
+*  otherwise a memory leak would occur.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssVASDBEvent: public CBase
+    {
+	public:
+
+	// ENUMS
+	enum TVASDBEventType
+	{
+		// standard Symbian DBMS event types (from RDBNotifier)
+		// event notification across threads possible,
+		EVASDatabaseEventNull, 
+		EVASDatabaseEventDatabaseClose,
+		EVASDatabaseEventDatabaseUnlock,
+		EVASDatabaseEventDatabaseCommit,
+		EVASDatabaseEventDatabaseRollback,
+		EVASDatabaseEventDatabaseRecover,
+		// In addition, following event types are also supported by VAS.
+		// These events are notifieds only within the same thread. The
+		// observers and event originator must be on the same thread.
+		// future releases would allow event noification across threads
+		EVASDatabaseEventTagAdded, 
+		EVASDatabaseEventTagChanged, 
+		EVASDatabaseEventTagDeleted
+	};
+    
+	public:  // Constructors and destructor
+     
+        /**
+        * 2Phase Constructor
+		* @param aType - event type, 
+		* @param aTag - tag on which the event occured
+		* @return 
+        */
+        static CNssVASDBEvent* NewL(TVASDBEventType& aType, MNssTag *aTag);
+
+		 /**
+        * 2Phase Constructor
+		* @param aType - event type, 
+		* @param aTag - tag on which the event occured
+		* @return 
+        */
+        static CNssVASDBEvent* NewLC(TVASDBEventType& aType, MNssTag *aTag);
+
+		/**
+        * C++ destructor
+		* @param 
+		* @return 
+        */
+        ~CNssVASDBEvent();
+
+        /**
+        * Get function to determine the type of event
+		* @since 2.0
+        * @param void
+        * @return Type of event
+        */
+        IMPORT_C TVASDBEventType Type();
+
+		/**
+        * Function to get the tag object on which the event took place.
+		* Deleting the event, deletes the tag associated with it.
+		* @since 2.0
+        * @param void
+        * @return Pointer to a tag object on which event occured
+        */
+        IMPORT_C MNssTag* Tag();
+		
+
+	private:
+		
+		/**
+        * C++ constructor.
+        */
+        CNssVASDBEvent();
+
+		/**
+        * EPOC Constructor
+		* @param aType - event type, 
+		* @param aTag - tag on which the event occured
+		* @return 
+        */
+		void ConstructL(TVASDBEventType& aType, MNssTag *aTag);
+
+		// Data
+        TVASDBEventType		iType;
+		MNssTag*				iTag;	// NULL for standard Symbian DBMS events.
+    };
+
+#endif      // TVASDBEVENT_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvascvasdbmgr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVASDBMgr is the starting point to begin interaction with VAS. 
+*               The client must first create and Initialize the CNssVASDBMgr; then 
+*               request the ContextMgr, TagMgr, VASDBEventNotifier, or 
+*               TagSelectNotifier to begin using VAS services. 
+*
+*/
+
+
+#ifndef CNSSVASDBMGR_H
+#define CNSSVASDBMGR_H
+
+
+// includes
+#include <e32def.h>
+#include <e32std.h>
+#include <e32base.h>
+
+#include "nssvascoreconstant.h"
+#include "nssvasmcontextmgr.h"
+#include "nssvasmtagmgr.h"
+#include "nssvasmvasdbeventnotifier.h"
+
+//FORWARD DECLARATIONS
+class CNssVASDBBuilder;
+class CNssVASDBEventNotifier;
+class CNssDBTagSelectNotifier;
+class MNssResetFactoryModelsClient;
+
+// CLASS DECLARATIONS
+/**
+*  CNssVASDBMgr is the entry point for VAS services. 
+*  It provides methods for creation of managers that
+*  provide the pertinent services.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssVASDBMgr : public CBase
+{
+public:
+   /**
+   * 2 phase constructor
+   * @param 
+   * @return pointer to created CNssVASDBMgr
+   */
+   IMPORT_C static CNssVASDBMgr* NewL ();
+
+   /**
+   * 2 phase constructor
+   * @param 
+   * @return pointer to created CNssVASDBMgr
+   */
+   IMPORT_C static CNssVASDBMgr* NewLC ();
+   
+	/**
+   * Destructor.
+   * @param 
+   * @return
+   */	
+   ~CNssVASDBMgr();
+   
+#ifdef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY   
+	/**
+   * Initializes VAS DB class attributes.
+   * @since 3.2
+   */
+   IMPORT_C void InitializeL(); 
+#else
+	/**
+   * Initializes VAS DB class attributes.
+   * @since 2.0
+   * @return Error code
+   */
+   IMPORT_C TInt InitializeL();
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY 
+   
+   /**
+   * Gets the Context Manager.
+   * @since 2.0
+   * @param None
+   * @return pointer to MNssContextMgr
+   */	
+   IMPORT_C MNssContextMgr* GetContextMgr();
+   
+   /**
+   * Gets the Tag Manager.
+   * @since 2.0
+   * @param None
+   * @return pointer to MNssTagMgr
+   */	
+   IMPORT_C MNssTagMgr* GetTagMgr();
+   
+   /**
+   * Gets the Vas Db event notifier.
+   * @since 2.0
+   * @param None
+   * @return pointer to MNssVASDBEventNotifier
+   */    
+   IMPORT_C MNssVASDBEventNotifier* GetVASDBEventNotifier();
+
+	/**
+   * Gets the tag select notifier.
+   * @since 2.0
+   * @param None
+   * @return pointer to MNssVASDBEventNotifier
+   */    
+   IMPORT_C CNssDBTagSelectNotifier* GetTagSelectNotifier();
+
+   /**
+   * Reset speaker-adapted models to speaker independent ones.
+   * @since 2.0
+   * @param None
+   * @return None
+   */
+   IMPORT_C void ResetFactoryModelsL( MNssResetFactoryModelsClient* aClient );
+
+private:
+
+	/**
+   * C++ constructor
+   * @param 
+   * @return 
+   */    
+	CNssVASDBMgr();
+
+	/**
+   * EPOC constructor
+   * @param 
+   * @return 
+   */    
+	void ConstructL ();
+
+private:
+	// owns the VAS DB Builder
+	CNssVASDBBuilder *iVasDBBuilder;
+
+
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmadaptationeventhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssAdaptationEventHandler class provides the call back methods to handle 
+*               the events after adptation.
+*
+*/
+
+
+#ifndef NSSVASMADAPTATIONEVENTHANDLER_H
+#define NSSVASMADAPTATIONEVENTHANDLER_H
+
+/**
+* The MNssAdaptationEventHandler class provides the call back methods to handle 
+*  the after adaptation.
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssAdaptationEventHandler
+    {        
+    public: 
+        
+    /**
+	* Adapt Complete Event - Adaptation was successful
+	* @since 2.0
+	* @param aErrorCode KErrNone if adaptation was successfull
+	* @return no return value
+	*/       
+    virtual void HandleAdaptComplete( TInt aErrorCode ) = 0;
+    };
+
+#endif // NSSVASMADAPTATIONEVENTHANDLER  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmadaptationitem.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssAdaptationItem interface class handles speaker adaptation,
+*               when the client wants to decide herself, when to adapt.
+*
+*/
+
+
+#ifndef NSSVASMADAPTATIONITEM_H
+#define NSSVASMADAPTATIONITEM_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <nssvasmadaptationeventhandler.h>
+#include <nssvasmtag.h>
+
+// CLASS DECLARATION
+
+/**
+*  MNssAdaptationItem event handler class.
+*  Contains adaptation data.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class MNssAdaptationItem
+    {
+
+    public:  //enum
+
+	  enum TNssRejectTagError
+        {
+        EVasErrorNone,
+        EVasRejectTagFailed,
+        EVasNoTagInContexts,
+        EVasRecognizeUndefinedError10,   // for place holder
+        EVasRecognizeUndefinedError9,
+        EVasRecognizeUndefinedError8,
+        EVasRecognizeUndefinedError7,
+        EVasRecognizeUndefinedError6,
+        EVasRecognizeUndefinedError5,
+        EVasRecognizeUndefinedError4,
+        EVasRecognizeUndefinedError3,
+        EVasRecognizeUndefinedError2,
+        EVasRecognizeUndefinedError1
+        };
+	
+    public: // New functions
+
+        /**
+        * AdaptL - Adapts the models using utterance and result, from which the ad
+        *
+        * @since 2.0
+        * @param aHandler Event handler for this adaptation
+        * @param aCorrect Index of correct result in the list of results
+        */      		
+        virtual void AdaptL( MNssAdaptationEventHandler *aHandler, TInt aCorrect ) = 0;
+
+        /**
+        * Adapts the models using the tag information
+        * 
+        * @since 3.2
+        * @param aHandler Event handler for this adaptation
+        * @param aTag Selected tag
+        */ 
+        virtual void AdaptL( MNssAdaptationEventHandler* aHandler,
+                             MNssTag& aTag ) = 0;
+                             
+        /**
+        * ~MNssAdaptationItem - Destructor  
+        * @since 2.0
+        */
+        virtual ~MNssAdaptationItem() {};
+
+    };
+
+#endif // NSSVASMADAPTATIONITEM_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmcontext.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssContext is a pure interface for context processing. A "context" 
+*               refers to a collection of voice  tags used by an application 
+*               for a classification of operations (for example a collection of 
+*               Name Dial voice tags could be contained in one context and 
+*               Command voice tags could be contained in another context). 
+*
+*/
+
+
+#ifndef NSSVASMCONTEXT_H
+#define NSSVASMCONTEXT_H
+
+//  INCLUDES
+#include<e32base.h>
+
+// CLASS DECLARATION
+
+/**
+*  MNssContext is a pure interface for context processing. 
+*  MNssContext provides methods for setting & getting context name and setting & 
+*  getting context global flag. A context can only be created using the context 
+*  manager. The context manager returns an empty context, and the client had to 
+*  populate its name and global flag using the methods below. A context can be 
+*  destroyed using delete on the context pointer.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssContext
+    {
+public:
+
+    /**
+    * Get the name of the context
+    * @since 2.0
+    * @param 
+    * @return reference to name of context
+    */  
+	virtual TDesC& ContextName() = 0;
+
+
+	/**
+    * Is the context global
+    * @since 2.0
+    * @param 
+    * @return ETrue if context is global, EFalse otherwise
+    */  
+	virtual TBool IsGlobal() = 0;
+
+	/**
+    * Sets the name of the context
+    * @since 2.0
+    * @param aName name of the context as a descriptor
+    * @return 
+    */  
+	virtual void SetNameL( const TDesC& aName ) = 0;
+
+    /**
+    * Sets/Resets the global flag for the context
+    * @since 2.0
+    * @param aGlobal ETrue to set the context as global, EFalse as not global 
+    * @return 
+    */  
+	virtual void SetGlobal( TBool aGlobal ) = 0;
+
+    /**
+    * Sets/Resets the client data. The data must be saved with
+    * MNssContextMgr::SaveClientData after this call.
+    * @since 2.8
+    * @param aData At most 100 bytes of serialized client data.
+    */
+    virtual void SetClientData( const TDesC8& aData ) = 0;
+
+    /**
+    * Gets the client data.
+    * @since 2.8
+    * @return At most 100 bytes of data.
+    */
+    virtual const TDesC8& ClientData() = 0;
+
+    /**
+    * virutal destructor to ensure proper cleanup 
+    * @since 2.0
+    * @param 
+    * @return 
+    */  
+	virtual ~MNssContext(){}
+
+    };
+
+
+#endif // NSSVASMCONTEXT_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmcontextmgr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssContextManager interface provides context processing methods for 
+*				 the client. The client  gets an instance of the context manager 
+*				 from the vas db manager. The vas db manager owns the context manager 
+*				 and is responsible for deleting the context manager. Clients should not 
+*				 directly delete the context manager. The context manager is simply a 
+*				 colllection of utility methods  that are pure virtuals. These methods are implemented
+*				 internal to VAS, and thus transparent to the client.
+*
+*/
+
+
+
+#ifndef MNSSCONTEXTMGR_H
+#define MNSSCONTEXTMGR_H
+
+#include <e32std.h>
+
+#include "nssvascoreconstant.h"
+
+//FORWARD DECLARATIONS
+class MNssGetContextClient;
+class MNssDeleteContextClient;
+class MNssSaveContextClient;
+class MNssContext;
+
+
+
+// CLASS DECLARATIONS
+/**
+*  MNssContextMgr is the public interface class for context management.
+*  It provides methods for context creation, saving context into the
+*  VAS database, retriving contexts from VAS database, and deletion of 
+*  context from the VAS database. A context manager cannot be instantiated
+*  directly but needs to be got from the VAS DB manager.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*  
+*/
+class MNssContextMgr
+   {
+public:
+    /**
+    * Create a new empty context
+    * @since 2.0
+    * @param 
+    * @return a reference to a new context object.
+    */
+    virtual MNssContext* CreateContextL()=0;
+
+    /**
+    * GetContext is called to retrieve a context from the VAS DB. 
+    * This method is asynchronous. A call back will be made to 
+    * either GetContextCompleted() or GetContextFailed() as
+    * defined in the MNssGetContextClient interface. It also returns an
+    * error code validating success of call to VAS DB.
+    * @since 2.0
+    * @param aContextClient - call back address
+    * @param aName          - name of context to retreive
+    * @return - syncronous error code from function return
+    */    
+    virtual TInt GetContext( MNssGetContextClient* aContextClient, const TDesC& aName ) = 0;
+
+    /**
+    * GetContextList is called to retrieve a context list from the VAS DB. 
+    * This method is asynchronous. A call back will be made to 
+    * either GetContextListCompleted() or GetContextFailed() as
+    * defined in the MNssGetContextClient interface. It also returns an
+    * error code validating success of call to VAS DB.
+    * @since 2.0
+    * @param aContextClient - call back address 
+    * @param  
+    * @return - syncronous error code from function return
+    */    
+    virtual TInt GetContextList( MNssGetContextClient* aContextClient ) = 0;
+
+    /**
+    * DeleteContext is called to remove a context from the VAS DB. 
+    * This method is asynchronous. A call back will be made to 
+    * either DeleteContextCompleted() or DeleteContextFailed() as
+    * defined in the MNssDeleteContextClient interface. It also returns an
+    * error code validating success of call to VAS DB.
+    * @since 2.0
+    * @param aContextClient - call back address
+    * @param aContext       - context object to delete
+    * @return syncronous error code from function return
+    */     
+    virtual TInt DeleteContext( MNssDeleteContextClient* aContextClient,
+                                MNssContext* aContext ) = 0;
+    
+    /**
+    * SaveContext is called to store a context to the VAS DB. 
+    * This method is asynchronous. A call back will be made to 
+    * either SaveContextCompleted() or SaveContextFailed() as
+    * defined in the MNssSaveContextClient interface. It also returns an
+    * error code validating success of call to VAS DB.
+    * @since 2.0
+    * @param aContextClient - call back address
+    * @param aContext       - context object to save
+    * @return - syncronous error code from function return
+    */
+    virtual TInt SaveContext( MNssSaveContextClient* aContextClient, MNssContext* aContext ) = 0;
+
+    /**
+    * SaveClientData is called to save client-specific data about the context.
+    * This method is asynchronous. A call back will be made to either
+    * SaveContextCompleted or SaveContextFailed() as defined in the
+    * MNssSaveContextClient interface. It also returns an error code validating
+    * success of call to VAS DB.
+    * @since 2.8
+    * @param aContextClient - call back address.
+    * @param aContext       - the client data of this context will be updated.
+    * @param aClientData    - buffer of serialized client data, at most 100 bytes.
+    */
+    virtual TInt SaveClientData( MNssContext* aContext ) = 0;
+    
+    /**
+    * Cancel get context / get context list / get global contexts 
+    * @since 3.2
+    * @param none
+    * @return none
+    */     
+    virtual void CancelGetContext() = 0;
+    
+    };
+
+#endif // MNSSCONTEXTMGR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmdeletecontextclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssDeleteContextClient provides the public callback interfaces for 
+*				 clients that want to delete contexts from the VAS Db. The client 
+*				 must inherit and override the DeleteContextCompleted() and 
+*				 DeleteContextFailed() methods to handle VAS Db responses for 
+*				 deleting context(s).
+*
+*/
+
+
+#ifndef MNSSDELETECONTEXTCLIENT_H
+#define MNSSDELETECONTEXTCLIENT_H
+
+#include <e32std.h>
+
+
+// CLASS DECLARATIONS
+/**
+*  MNssDeleteContextClient defines the call back methods used by VAS DB
+*  when replying to an asynchronous DeleteContext() request.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssDeleteContextClient
+{
+public:
+
+   /*enum TNssDeleteContextClientFailCode
+   {
+	  EVASDBItemNotFound = 1,
+	  EVASDBNoMemory,
+	  EVASDBDiskFull,
+	  EVASDBFailure,
+	  EVASSRSFailure
+   };*/
+
+   /**
+   * Callback to indicate a context was deleted successfully.
+   * @since 2.0
+   * @param 
+   * @return 
+   */
+   virtual void DeleteContextCompleted( TInt aErrorCode ) = 0;
+   
+   /**
+   * Callback to indicate deleting a context failed.
+   * @since 2.0
+   * @param aFailCode - The reason the deletion failed
+   * @return None
+   */   
+   //virtual void DeleteContextFailed(TNssDeleteContextClientFailCode aFailCode)=0;
+   
+ 
+ 
+
+ 
+
+ 
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmdeletetagclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssDeleteTagClient provides the public callback interfaces for 
+*				 clients that want to delete tags from the VAS Db. The client must 
+*				 inherit and override the DeleteTagCompleted() and DeleteTagFailed() 
+*				 methods to handle VAS Db responses for deleting tag(s).
+*
+*/
+
+
+#ifndef MNSSDELETETAGCLIENT_H
+#define MNSSDELETETAGCLIENT_H
+#include <e32std.h>
+
+// CLASS DECLARATIONS
+/**
+*  MNssDeleteTagClient defines the call back methods used by VAS DB
+*  in response to an asynchronous DeleteTag() request.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssDeleteTagClient
+{
+public:
+
+   /*enum TNssDeleteTagClientFailCode
+   {
+	  EVASDBItemNotFound = 1,
+	  EVASDBNoMemory,
+	  EVASDBDiskFull,
+	  EVASDBFailure,
+	  EVASSRSFailure
+   };*/
+   /**
+   * Callback to indicate a tag was deleted successfully.
+   * @since 2.0
+   * @param aErrorCode KErrNone if deletetion was successfull
+   * @return 
+   */
+   virtual void DeleteTagCompleted( TInt aErrorCode )=0;
+  /**
+   * Callback to indicate deleting a tag failed.
+   * @since 2.0
+   * @param aFailCode - The reason the deletion failed
+   * @return 
+   */  
+   //virtual void DeleteTagFailed(TNssDeleteTagClientFailCode aFailCode)=0;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmgetcontextclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssGetContextClient provides the public callback interfaces for 
+*               clients that want to retrieve contexts from the VAS Db. The 
+*               client must inherit and override the GetContextCompleted() and 
+*               GetContextFailed() methods to handle VAS Db responses for 
+*               retrieving context(s).
+*
+*/
+
+
+#ifndef NSSVASMGETCONTEXTCLIENT_H
+#define NSSVASMGETCONTEXTCLIENT_H
+#include <e32std.h>
+#include <e32base.h>
+
+//FORWARD DECLARATIONS
+class MNssContext;
+
+typedef CArrayPtrFlat<MNssContext> MNssContextListArray;
+
+// CLASS DECLARATIONS
+/**
+*  MNssGetContextClient defines the call back methods used by VAS DB
+*  when replying to an asynchronous GetContext() request.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssGetContextClient
+{
+public:
+#ifdef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to delete the context after using the context.
+   * @since 3.2
+   * @param aContext 
+   * @return None
+   */
+  virtual void GetContextCompleted( MNssContext* aContext,
+                                    TInt aErrorCode ) = 0;
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to ResetAndDestroy() after using the list.
+   * @since 3.2
+   * @param aContextList A list of contexts. 
+   * @return None
+   */
+  virtual void GetContextListCompleted( MNssContextListArray *aContextList,
+                                        TInt aErrorCode ) = 0;
+
+#else
+
+  enum TNssGetContextClientFailCode
+  {
+	  EVASDBItemNotFound = 1,
+	  EVASDBNoMemory,
+	  EVASDBDiskFull,
+	  EVASDBFailure
+  };
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to delete the context after using the context.
+   * @since 2.0
+   * @param aContext 
+   */
+  virtual void GetContextCompleted( MNssContext* /*aContext*/,
+                                    TInt /*aErrorCode*/ ) {};
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to ResetAndDestroy() after using the list.
+   * @since 2.0
+   * @param aContextList A list of contexts. 
+   */
+  virtual void GetContextListCompleted( MNssContextListArray* /*aContextList*/,
+                                        TInt /*aErrorCode*/ ) {};
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to delete the context after using the context.
+   * @since 2.0
+   * @param aContext 
+   */
+  virtual void GetContextCompleted( MNssContext* /*aContext*/ ) {};
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to ResetAndDestroy() after using the list.
+   * @since 2.0
+   * @param aContextList A list of contexts. 
+   */
+  virtual void GetContextListCompleted( MNssContextListArray* /*aContextList*/ ) {};
+
+   /**
+   * Callback to indicate GetContext failed.
+   * @since 2.0
+   * @param aFailCode The reason GetContext failed
+   * @return None
+   */  
+  virtual void GetContextFailed( TNssGetContextClientFailCode /*aFailCode*/ ) {};
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmgettagclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssGetTagClient provides the public callback interfaces for clients 
+*               that want to retrieve tags from the VAS Db. The client must inherit 
+*               and override the GetTagCompleted() and GetTagFailed() methods to 
+*               handle VAS Db responses for retrieving tag(s).
+*
+*/
+
+
+#ifndef MNSSGETTAGCLIENT_H
+#define MNSSGETTAGCLIENT_H
+
+// includes 
+#include <e32std.h>
+#include <e32base.h>
+
+// forward declarations
+class MNssTag;
+
+//typedef 
+typedef CArrayPtrFlat<MNssTag> MNssTagListArray;
+
+// CLASS DECLARATIONS
+/**
+*  MNssGetTagClient defines the call back methods used by VAS DB
+*  when replying to an asynchronous GetTag() request.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssGetTagClient
+{
+public:
+#ifdef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY
+
+   /**
+   * Callback to indicate GetTag successed.
+   * client has to delete the tag list
+   * @since 3.2
+   * @param aTagList 
+   */
+   virtual void GetTagListCompleted( MNssTagListArray* aTagList,
+                                     TInt aErrorCode ) = 0;
+#else
+   enum TNssGetTagClientFailCode
+   {
+	  EVASDBItemNotFound = 1, 
+	  EVASDBNoMemory,
+	  EVASDBDiskFull,
+	  EVASDBFailure
+   };
+   
+   /**
+   * Callback to indicate GetTag successed.
+   * client has to delete the tag list
+   * @since 2.0
+   * @param aTagList 
+   */
+   virtual void GetTagListCompleted( MNssTagListArray* /*aTagList*/,
+                                     TInt /*aErrorCode*/ ) {};   
+   
+   /**
+   * Callback to indicate GetTag successed.
+   * client has to delete the tag list
+   * @since 2.0
+   * @param aTagList 
+   */
+   virtual void GetTagListCompleted( MNssTagListArray* /*aTagList*/ ) {};
+   
+   /**
+   * Callback to indicate GetTag failed.
+   * @since 2.0
+   * @param aFailCode - The reason GetTag failed
+   */ 
+   virtual void GetTagFailed( TNssGetTagClientFailCode /*aFailCode*/ ) {};
+ 
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY   
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmgettagreferenceclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssGetTagReference Client is the public callback interfaces for
+*                clients that want to retrieve tag references from the VAS Db.
+*                The client must inherit and override the GetTagCompleted() and
+*                GetTagFailed() methods to handle VAS Db responses for
+*                retrieving tag reference(s).
+*
+*/
+
+#ifndef MNSSGETTAGREFCLIENT_H
+#define MNSSGETTAGREFCLIENT_H
+
+// includes 
+#include <e32std.h>
+#include <e32base.h>
+
+// forward declarations
+class MNssTagReference;
+
+//typedef 
+typedef CArrayPtrFlat<MNssTagReference> NssTagReferenceListArray;
+
+// CLASS DECLARATIONS
+/**
+*  MNssGetTagReferenceClient defines the call back methods used by VAS DB
+*  when replying to an asynchronous GetTagReference() request.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssGetTagReferenceClient
+{
+public:
+
+   /*enum TNssGetTagReferenceClientFailCode
+   {
+	  EVASDBItemNotFound = 1, 
+	  EVASDBNoMemory,
+	  EVASDBDiskFull,
+	  EVASDBFailure
+   };*/
+   
+   /**
+   * Callback to indicate GetTagReference successed.
+   * client has to delete the tagref list
+   * @since 2.0
+   * @param aTagRefList 
+   * @return None
+   */
+   virtual void GetTagReferenceListCompleted(
+       CArrayPtrFlat<MNssTagReference>* aTagRefList, TInt aErrorCode ) = 0;
+   
+   /**
+   * Callback to indicate GetTagReference failed.
+   * @since 2.0
+   * @param aFailCode - The reason GetTagReference failed
+   * @return None
+   */ 
+   //virtual void GetTagReferenceFailed(TNssGetTagReferenceClientFailCode aFailCode)=0;
+   
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmplayeventhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssPlayEventHandler class provides the call back methods to handle 
+*               the events during Play operation.
+*
+*/
+
+
+
+#ifndef NSSVASMPLAYEVENTHANDLER_H
+#define NSSVASMPLAYEVENTHANDLER_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <nssvascoreconstant.h>
+
+
+/**
+* The MNssPlayEventHandler class provides the call back methods to handle 
+*  the events during Play operation.
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssPlayEventHandler
+{
+
+  public:
+
+    /**
+    * TPlayResult will have all the enums to represent the result values from
+    * HandlePlayError method.
+    * 
+    * NOTE:
+    * The HandlePlayError() should handle the undefined error for TPlayResult.
+    */         
+    enum TNssPlayResult
+        {
+        EVasErrorNone,
+        EVasPlayFailed,
+        EVasPlayNoMemory,
+        EVasPlayAccessDeny,
+        EVasPlayUndefinedError10,   // for place holder
+        EVasPlayUndefinedError9,
+        EVasPlayUndefinedError8,
+        EVasPlayUndefinedError7,
+        EVasPlayUndefinedError6,
+        EVasPlayUndefinedError5,
+        EVasPlayUndefinedError4,
+        EVasPlayUndefinedError3,
+        EVasPlayUndefinedError2,
+        EVasPlayUndefinedError1
+        };
+
+    /**
+    * The HandlePlayStarted method is a virtual method implemented by the
+    * client and is called when play is started
+    * @since 2.0
+    * @param aDuration - the duration of the utterance data
+    * @return no return value
+    */       
+    virtual void HandlePlayStarted( TTimeIntervalMicroSeconds32 aDuration ) = 0;
+
+    /**
+    * The HandlePlayComplete method is a virtual method implemented by the
+    * client and is called when play is completed
+    * @since 2.0
+    * @param aErrorCode EVasErrorNone if playing was successfull
+    * @return no return value
+    */       
+    virtual void HandlePlayComplete( TNssPlayResult aErrorCode ) = 0;
+};
+
+
+
+#endif // NSSVASMPLAYEVENTHANDLER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmrecognitionhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssRecognitionHandler class performs the recognition function.  
+*
+*/
+
+
+#ifndef NSSVASMRECOGNITIONHANDLER_H
+#define NSSVASMRECOGNITIONHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32def.h>
+#include <nssvasmtag.h>
+#include <nssvasmcontext.h>
+#include <nssvasmadaptationitem.h>
+#include <nssvasmrecognizeeventhandler.h>
+#include <nssvasmrecognizeinitcompletehandler.h>
+#include <nssvasmrejecttagcompletehandler.h>
+#include <nssvasmadaptationeventhandler.h>
+
+// CLASS DEFINITIONS
+
+/**
+*
+*  The MNssRecognitionHandler class performs the recognition function.
+*  CNssRecognitionHandler class.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class MNssRecognitionHandler
+{
+
+public:
+
+        enum TNssRecognitionResult
+        {
+        EVasErrorNone,
+        EVasRecognitionInitFailed,
+        EVasRecognitionFailed,
+        EVasSelectTagFailed,
+        EVasRejectTagFailed,
+        EVasUnexpectedRequest,
+        EVasInvalidParameter
+        };
+
+        /**
+        * Initiate the Select Tag event.
+        * @since 2.0
+        * @param aClientTag The voice tag which was selected. The tag is owned
+        *                   by the client.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult SelectTagL( MNssTag* aClientTag ) = 0;
+
+        /**
+        * Initiate the Select Tag event.
+        * @since 2.0
+        * @param aClientTag The voice tag which was selected. The tag is owned
+        *                   by the client.
+        * @param aShouldNotifyHandlers If this is false, then handlers which
+        *                              monitor tag's context won't be notified.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult SelectTagL(MNssTag* aClientTag, TBool aNotifyHandlers ) = 0;
+
+        /**
+        * Perform the recognize function.
+        * @since 2.0
+        * @param aEventHandler The event call back to receive recognize events.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult Recognize( MNssRecognizeEventHandler* aEventHandler ) = 0;
+
+        /**
+        * Perform initialization for the recognize funtion.
+        * @since 2.0
+        * @param aInitCompleteHandler The event call back to receive recognize
+        *                             init events.
+        * @param aMaxResults The maximum number of voice tags to be recognized.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult 
+                RecognizeInitL( MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+                                TInt aMaxResults ) = 0;
+
+        /**
+        * Perform initialization for the recognize function.
+        * @since 2.0
+        * @param aInitCompleteHandler The event call back to receive recognize
+        *                             init events.
+        * @param aContextArray The list of contexts to be active in
+        *                      recognition, i.e. recognition vocabulary.
+        * @param aMaxResults The maximum number of voice tags to be recognized.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult RecognizeInitL(
+                MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+                const CArrayPtrFlat<MNssContext>& aContextArray,
+                TInt aMaxResults ) = 0;
+
+        /**
+        * Starts sampling already before RecognizeInitL and Recognize calls.
+        * This is used to ensure that there is no delay between user notification
+        * and sampling start.
+        * Asynchronous: MNssRecognizeInitCompleteHandler::HandlePreSamplingStarted
+        * will be called when ready.
+        *
+        * @since 3.2
+        * @param aInitCompleteHandler Callback handler        
+        * @return Return value indicating if request was valid 
+        */
+        virtual TNssRecognitionResult PreStartSampling( MNssRecognizeInitCompleteHandler* aInitCompleteHandler ) = 0;
+
+        /**
+        * Cancel the last recognition function.
+        * @since 2.0
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult Cancel() = 0;
+
+        /**
+        * Request Reject Tag, i.e. blacklisting.
+        * @since 2.0
+        * @param aClientTagList The list of voice tags which is to be rejected, i.e. 
+        *                       blacklisted. The tag list is owned by the client.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        virtual TNssRecognitionResult RejectTagL(
+                MNssRejectTagCompleteHandler* aRejectTagCompleteHandler,
+                CArrayPtrFlat<MNssTag>* aClientTagList ) = 0;        
+        /**
+        * Get adaptation item to allow later adaptation.
+        * @since 2.0
+        * @return MNssAdaptationItem* The adaptation item. Client takes ownership.
+        */
+        virtual MNssAdaptationItem *GetAdaptationItemL() = 0;
+};
+
+#endif // NSSVASMRECOGNITIONHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmrecognizeeventhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssRecognizeEventHandler interface class handles events 
+*                generated by RecognizeHandler::Recognize().
+*
+*/
+
+
+#ifndef MNSSRECOGNIZEEVENTHANDLER_H
+#define MNSSRECOGNIZEEVENTHANDLER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+#include <e32def.h>
+#include "nssvasmtag.h"
+
+// CLASS DECLARATION
+
+/**
+*
+*  The MNssRecognizeEventHandler class provides the call back methods to handle 
+*  the events generated by MNssRecognitionHandler::recognize().
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssRecognizeEventHandler
+    {
+
+   public:  //enum
+
+        enum TNssRecognizeError
+        {
+        EVasErrorNone,
+        EVasRecognizeFailed,
+	    EVasRecognitionFailedNoSpeech,
+	    EVasRecognitionFailedTooEarly,
+	    EVasRecognitionFailedTooLong,
+	    EVasRecognitionFailedTooShort,
+	    EVasRecognitionFailedNoMatch,
+        EVasRecognizeAccessDeny,
+        EVasRecognizeUndefinedError10,   // for place holder
+        EVasRecognizeUndefinedError9,
+        EVasRecognizeUndefinedError8,
+        EVasRecognizeUndefinedError7,
+        EVasRecognizeUndefinedError6,
+        EVasRecognizeUndefinedError5,
+        EVasRecognizeUndefinedError4,
+        EVasRecognizeUndefinedError3,
+        EVasRecognizeUndefinedError2,
+        EVasRecognizeUndefinedError1
+        };
+
+    public: // New functions
+        
+        /**
+        * Record Started Event - Recognizer is recording and ready to
+		*                        receive the input speech
+        * @since 2.0
+        * @return void
+        */      		
+        virtual void HandleRecordStarted() = 0;
+
+        /**
+        * End Of Utterance Event - Recognizer has received the input speech
+        * @since 2.0
+        * @return void
+        */
+		virtual void HandleEouDetected() = 0;
+
+        /**
+        * Recognize Complete Event - Recognizer has analyzed the input speech.
+        * @since 2.0
+        * @param aClientTagList A list of recognized voice tags returned by 
+		*                       Recognize. The client is responsible for 
+		*                       deleting the list and its associated tags.
+		* @param EVasErrorNone if recognition completed successfully
+        * @return void
+        */
+		virtual void HandleRecognizeComplete(
+           CArrayPtrFlat<MNssTag> *aClientTagList,
+           TNssRecognizeError aErrorCode ) = 0;
+
+    };
+
+#endif      // MRECOGNIZEEVENTHANDLER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmrecognizeinitcompletehandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssRecognizeInitCompleteHandler interface class handles events 
+*               generated by RecognizeHandler::RecognizeInit().
+*
+*/
+
+
+#ifndef NSSVASMRECOGNIZEINITCOMPLETEHANDLER_H
+#define NSSVASMRECOGNIZEINITCOMPLETEHANDLER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+#include <e32def.h>
+
+// CLASS DECLARATION
+
+/**
+*  RecognizezInit event handler class.
+*  Handles events generated by MNssRecognitionHandler::RecognizeInit().
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssRecognizeInitCompleteHandler
+    {
+
+    public:  //enum
+
+        enum TNssRecognizeInitError
+        {
+        EVasErrorNone,
+        EVasRecognizeInitFailed,
+        EVasNoTagInContexts,
+        EVasRecognizeUndefinedError10,   // for place holder
+        EVasRecognizeUndefinedError9,
+        EVasRecognizeUndefinedError8,
+        EVasRecognizeUndefinedError7,
+        EVasRecognizeUndefinedError6,
+        EVasRecognizeUndefinedError5,
+        EVasRecognizeUndefinedError4,
+        EVasRecognizeUndefinedError3,
+        EVasRecognizeUndefinedError2,
+        EVasRecognizeUndefinedError1
+        };
+    
+    public: // New functions
+
+        /**
+        * Recognizer Initialization Complete Event -  The Recognizer 
+        * has been initialized. 
+        *
+        * @since 2.0
+        * @param aErrorCode EVasErrorNone if initialization was successfull
+        */              
+        virtual void HandleRecognizeInitComplete( TNssRecognizeInitError aErrorCode ) = 0;
+        
+        /**
+        * Pre-sampling has been started. Samples will be discarded until
+        * MNssRecognitionHandler::Recognize is called.
+        *
+        * @since 3.2
+        * @param "TInt aErrorCode" KErrNone if start of pre sampling was successful
+        */
+        virtual void HandlePreSamplingStarted( TInt /*aErrorCode*/ ) {};
+
+    };
+
+#endif // NSSVASMRECOGNIZEINITCOMPLETEHANDLER_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmrejecttagcompletehandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MRejectTagCompleteHandler interface class handles events 
+*                generated by RecognizeHandler::RejectTagL().
+*
+*/
+
+
+#ifndef MNSSREJECTTAGCOMPLETEHANDLER_H
+#define MNSSREJECTTAGCOMPLETEHANDLER_H
+
+//  INCLUDES
+
+
+// CLASS DECLARATION
+
+/**
+*  RejectTag event handler class.
+*  Handles events generated by MNssRecognitionHandler::RejectTagL().
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssRejectTagCompleteHandler
+    {
+
+    public:  //enum
+
+	    enum TNssRejectTagError
+        {
+        EVasErrorNone,
+        EVasRejectTagFailed,
+		EVasNoTagInContexts,
+        EVasRecognizeUndefinedError10,   // for place holder
+        EVasRecognizeUndefinedError9,
+        EVasRecognizeUndefinedError8,
+        EVasRecognizeUndefinedError7,
+        EVasRecognizeUndefinedError6,
+        EVasRecognizeUndefinedError5,
+        EVasRecognizeUndefinedError4,
+        EVasRecognizeUndefinedError3,
+        EVasRecognizeUndefinedError2,
+        EVasRecognizeUndefinedError1
+        };
+	
+    public: // New functions
+
+		/**
+		* RejectTag Complete Event -  The requested tags have been rejected, i.e. blacklisted. 
+        * @since 2.0
+        * @param 
+        * @return void
+        */      		
+		virtual void HandleRejectTagComplete( TNssRejectTagError aErrorCode ) = 0;
+
+		/**
+		* RejectTag Error Event - A RejectTag error has occurred  
+        * @since 2.0
+        * @param aErrorCode The RejectTag error code. 
+        * @return void
+        */
+		//virtual void HandleRejectTagError( TNssRejectTagError aErrorCode ) = 0;
+
+    };
+
+#endif      // MREJECTTAGCOMPLETEHANDLER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmresetfactorymodelsclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssResetFactoryModelsClient class provides the call back 
+*               methods to handle the events after resetting factory models.
+*
+*/
+
+
+#ifndef NSSVASMRESETFACTORYMODELSCLIENT_H
+#define NSSVASMRESETFACTORYMODELSCLIENT_H
+
+/**
+* The MNssResetFactoryModelsClient class provides the call back methods to handle 
+* the after adaptation.
+*
+* @lib NssVASApi.lib
+* @since 2.8
+*/
+class MNssResetFactoryModelsClient
+    {
+    public: 
+      
+
+    /**
+	* Resetting factory models is completed
+	*
+	* @param aErrorCode KErrNone if resetting was successfull
+	*/       
+    virtual void HandleResetComplete( TInt aErrorCode ) = 0;
+
+    };
+
+#endif // NSSVASMRESETFACTORYMODELSCLIENT_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmrrd.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MRRD class encapsulated a Recognition Result Data (RRD). RRD serves 
+*               as a container for client defined data (text and integers) that 
+*               needs to be associated with a voice tag.
+*
+*/
+
+
+#ifndef NSSVASMRRD_H
+#define NSSVASMRRD_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// maximum length for RRD Text
+const TInt KNssVASMAXRRDTextLength = 64;
+
+// typedef
+typedef TBuf<KNssVASMAXRRDTextLength> NssRRDText;
+
+// CLASS DECLARATION
+
+/**
+* MRRD is the interface for Recognition Result Data (RRD) processing. It provides methods 
+* for setting and getting the text and integer array that comprise the RRD. A RRD
+* is part of Tag. RRD is not created by the client, it is created when a tag is created
+* and destroyed when the tag is destroyed. Thus, a client doesnot delete an RRD.
+* @lib NssVASApi.lib
+* @since 2.0
+*/
+class MNssRRD
+{
+public:
+
+    /**
+    * Get the text array in RRD
+	* @since 2.0
+    * @param 
+    * @return an array of text
+    */
+	virtual CArrayFixFlat<NssRRDText>* TextArray() = 0;
+
+    /**
+    * Get the integer array in RRD
+	* @since 2.0
+    * @param 
+    * @return an array of integers
+    */
+	virtual CArrayFixFlat<TInt>* IntArray() = 0;
+
+    /**
+    * Set the text array in RRD
+	* @since 2.0
+    * @param aTextArray pointer to an array of text
+    * @return
+    */
+	virtual void SetTextArrayL(CArrayFixFlat<NssRRDText>* aTextArray) = 0;
+
+    /**
+    * Set the integer array in RRD
+	* @since 2.0
+    * @param aIntArray pointer to an array of integers
+    * @return 
+    */
+	virtual void SetIntArrayL(CArrayFixFlat<TInt>* aIntArray) = 0;
+
+};
+
+#endif // NSSVASMRRD_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmsavecontextclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssSaveContextClient provides the public callback interfaces for 
+*				 clients that want to store contexts to the VAS Db. The client must 
+*				 inherit and override the SaveContextCompleted() and SaveContextFailed()
+*				 methods to handle VAS Db responses for storing context(s).
+*
+*/
+
+
+#ifndef MNSSSAVECONTEXTCLIENT_H
+#define MNSSSAVECONTEXTCLIENT_H
+#include <e32std.h>
+
+
+// CLASS DECLARATIONS
+/**
+*  MNssSaveContextClient is the interface for save context call backs.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssSaveContextClient
+{
+public:
+
+   /*enum TNssSaveContextClientFailCode
+   {
+	  EVASDBNoMemory = 2,
+	  EVASDBDiskFull,
+	  EVASDBFailure,
+	  EVASSRSFailure
+   };*/
+   /**
+   * Callback to indicate SaveContext successed.
+   * @since 2.0
+   * @param aErrorCode KErrNone if saving of context has completed successfully
+   * @return None
+   */
+   virtual void SaveContextCompleted( TInt aErrorCode ) = 0;
+   
+   /**
+   * Callback to indicate SaveContext failed.
+   * @since 2.0
+   * @param aFailCode - The reason SaveContext failed.
+   * @return None
+   */
+   //virtual void SaveContextFailed(TNssSaveContextClientFailCode aFailCode)=0;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmsavetagclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssSaveTagClient provides the public callback interfaces for clients 
+*				 that want to store tags to the VAS Db. The client must inherit and 
+*				 override the SaveTagCompleted() and SaveTagFailed() methods to handle 
+*				 VAS Db responses for saving tag(s).
+*
+*/
+
+
+#ifndef MNSSSAVETAGCLIENT_H
+#define MNSSSAVETAGCLIENT_H
+#include <e32std.h>
+
+
+// CLASS DECLARATIONS
+/**
+*  MNssSaveTagClient defines the call back methods used by VAS DB
+*  when replying to an asynchronous SaveTag() request.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssSaveTagClient
+{
+public:
+
+   /*enum TNssSaveTagClientFailCode
+   {
+ 	  EVASDBNoMemory = 2,
+	  EVASDBDiskFull,
+	  EVASDBFailure,
+	  EVASSRSFailure
+   };*/
+   
+   /**
+   * Callback to indicate SaveTag successed.
+   * @since 2.0
+   * @param None
+   * @return None
+   */
+   virtual void SaveTagCompleted( TInt aErrorCode ) = 0;
+  
+   /**
+   * Callback to indicate SaveTag failed.
+   * @since 2.0
+   * @param aFailCode - The reason SaveContext failed.
+   * @return None
+   */  
+   //virtual void SaveTagFailed(TNssSaveTagClientFailCode aFailCode)=0;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmspeechitem.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MSeechItem provides speech methods to the client.
+*               The methods are used by the client to request speech services from SRS. 
+*
+*/
+
+
+#ifndef NSSVASMSPEECHITEM_H
+#define NSSVASMSPEECHITEM_H
+
+// INCLUDE FILES
+#include <nssvascoreconstant.h>
+
+// FORWARD DECLARATIONS
+class MNssPlayEventHandler;
+class MNssTrainVoiceEventHandler;
+class MNssTrainTextEventHandler;
+class CNssTrainingParameters;
+
+/**
+* The MSpeechItem class represents the speech part of a voice tag. The
+* MSeechItem provides speech methods to  the client. The methods are used by
+* the client  to request speech services from SRS
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssSpeechItem
+{
+  public:  //enum
+
+    /**
+    * TNssSpeechItemResult will have all the enums to represent the return values from
+    * MSpeechItem's methods.
+    * 
+    * NOTE:
+    * The caller functions should be able to handle the unknown TNssSpeechItemResult enum values.
+    */         
+    enum TNssSpeechItemResult
+     {
+        EVasErrorNone,
+        EVasUnexpectedRequest,  // Unexpected request from client, when the state is not Idle
+        EVasInUse,              // VAS resource is currently in use.
+        EVasInvalidParameter,
+        EVasPlayFailed,
+        EVasTrainFailed
+     };
+
+
+  public:
+
+    /**
+    * The Record method is used by the client to record input speech.
+    *
+    * @since 2.0
+    * @param aTrainVoiceEventHandler A call back object to handle the record events
+    * @return TNssSpeechItemResult, synchronous return value to identify whether the
+    *         synchronous process is success or fail
+    */    
+    virtual TNssSpeechItemResult RecordL( 
+                MNssTrainVoiceEventHandler* aTrainVoiceEventHandler ) = 0;
+
+
+    /**
+    * Method called by the client to indicate to SRS that a playback is
+    * needed.
+    *
+    * @since 2.0
+    * @param aPlayEventHandler A call back object to handle the play events
+    * @return TNssSpeechItemResult, synchronous return value to identify whether the
+    *         synchronous process is success or fail
+    */    
+    virtual TNssSpeechItemResult PlayL( MNssPlayEventHandler* aPlayEventHandler ) = 0;
+
+    /**
+    * Method called by the client to indicate to SRS that a playback is
+    * needed with a certain language.
+    *
+    * @since 2.8
+    * @param aPlayEventHandler A call back object to handle the play events
+    * @param aLanguage Language which will be used in playback
+    * @return TNssSpeechItemResult, synchronous return value to identify whether the
+    *         synchronous process is success or fail
+    */    
+    virtual TNssSpeechItemResult PlayL( MNssPlayEventHandler* aPlayEventHandler,
+                                        TLanguage aLanguage ) = 0;
+
+   /**
+    * Method called by the client to indicate to SRS that training is
+    * needed.
+    *
+    * @since 2.0
+    * @param aTrainVoiceEventHandler A call back object to handle the train events
+    * @return TNssSpeechItemResult, synchronous return value to identify whether the
+    *         synchronous process is success or fail
+    */    
+    virtual TNssSpeechItemResult TrainVoiceL( 
+                MNssTrainVoiceEventHandler* aTrainVoiceEventHandler ) = 0;
+
+    /**
+    * Method called by the client to  cancel the previous operation.
+    *
+    * @since 2.0
+    * @return TNssSpeechItemResult, synchronous return value to identify whether the
+    *         synchronous process is success or fail
+    */    
+    virtual TNssSpeechItemResult CancelL() = 0;
+
+
+    /**
+    * The GetTrainingCapabilities member fucntion is used by the client 
+    * to get training capabilities to beused in Speaker Independent voice 
+    * recognition.
+    *
+    * @since 2.0
+    * @return the pointer to the array of Training capabilities data
+    */    
+    virtual CArrayFixFlat<TNssVasCoreConstant::TNssTrainingCapability>* TrainingCapabilities() = 0;
+
+
+    /**
+    * The GetTrainedType member function is used by the client to get 
+    * train type  to be used in Speaker Independent voice recognition. 
+    * 
+    * @since 2.0
+    * @return the enum for the trained type
+    */    
+    virtual TNssVasCoreConstant::TNssTrainedType TrainedType() = 0;
+
+
+    /**
+    * The Text member fucntion is used by the client to get text to be
+    * used in Speaker Independent voice recognition. The text can also be
+    * used to identify the voice tag, and can be used for user display by
+    * the client.
+    *
+    * @since 2.0
+    * @return A text buffer
+    */    
+    virtual TDesC& Text() = 0;
+
+
+    /**
+    * The SetTextL method is used by the client to initialize the Text
+    * data member
+    *
+    * @since 2.0
+    * @param aText the reference of a text buffer
+    */    
+    virtual void SetTextL( const TDesC& aText ) = 0;
+
+
+    /**
+    * Playing a tag is not supported, if the recognition technology is speaker
+    * independent and speech synthesis is not present.
+    *
+    * @since 2.0
+    * @return ETrue Playing is supported.
+    *         EFalse PlayL() will leave with KErrNotSupported.
+    */
+    virtual TBool IsPlayingSupported() = 0;
+
+
+    /**
+    * Trains the speech model. The model is based on the text
+    * which was given earlier at SetTextL.
+    *
+    * @since 2.0
+    * @param aEventHandler To inform the client when the training has finished.
+    * @param aTrainingParams Training parameters 
+    * @return TNssSpeechItemResult Success status
+    */
+    virtual TNssSpeechItemResult TrainTextL( MNssTrainTextEventHandler* aEventHandler,
+                                             CNssTrainingParameters* aTrainingParams ) = 0;
+
+    /**
+    * Returns the raw training text from where escape characters are not removed.
+    * Should not be used by clients who want to display the string.
+    *
+    * @since 3.2
+    * @return Reference to the text buffer
+    */    
+    virtual TDesC& RawText() = 0;
+    
+    /**
+    * Returns the part of text which identified with the given id.
+    * If RawText() is for example "_1Amy_1Harris_2mobile" then 
+    * PartialText( _L( "1" ) ) call will return "Amy Harris".
+    *
+    * @since 3.2
+    * @param aIdentifier ID of the text part to return
+    * @return Text, ownership is transferred to client
+    */
+    virtual HBufC* PartialTextL( const TDesC& aIdentifier ) = 0;
+};
+
+#endif // NSSVASMSPEECHITEM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtag.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MTag is an abstraction for a voice tag. MTag memebrs consist of 
+*               a context, speech item, and RRD. 
+*
+*/
+
+
+#ifndef NSSVASMTAG_H
+#define NSSVASMTAG_H
+
+// include 
+
+#include <nssvasmcontext.h>
+#include <nssvasmrrd.h>
+#include <nssvasmspeechitem.h>
+
+/**
+* MTag is the interface class for tag processing.
+* A voice tag consists of a context, a RRD, and a speech item. A context can have
+* multiple voice tags. Context represents the category (application) to which the tag
+* belongs. RRD represents the result data for a tag. Speech item represents the speech
+* speech data and speech activities for a tag. A client will not create a tag diectly, 
+* but use the methods in tag manager to get a tag. After getting a tag, the client can
+* get the RRD and speech item objects using the following methods in MTag. A context needs
+* to be created before creating a tag. After a tag is used, it needs to be deleted. Deleting
+* a tag deletes its RRD and speech item, and thus they donot have to be deleted expicitly,
+* @lib NssVASApi.lib
+* @since 2.0
+*/
+class MNssTag
+    {
+    public:
+    
+        /**
+        * Get the context 
+    	* @since 2.0
+        * @return context object to which this tag belongs
+        */	
+        virtual MNssContext* Context() = 0;
+
+        /**
+        * Get the RRD
+    	* @since 2.0
+        * @return RRD object for this tag
+        */
+    	virtual MNssRRD* RRD() = 0;
+
+        /**
+        * Get the speech item
+    	* @since 2.0
+        * @return speech item for this tag
+        */
+    	virtual MNssSpeechItem* SpeechItem() = 0;
+
+        /**
+        * virtual destructor for proper clean up
+        */
+    	virtual ~MNssTag(){}
+    	
+    };
+
+#endif // NSSVASMTAG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtagmgr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssTagMgr provides services for tag management. Clients obtain a
+*				 tag manager from the VAS DB Manager. VAS DB Manager owns the tag 
+*				 manager and is responsible for deleting it when the VAS DB manager is
+*				 deleted. Clienst should not directly delete the tag manager. Through
+*				 the tag manager, a client can create a tag, save it to the VAS DB, 
+*				 retreive a tag (or tag list) from the VAS DB, and delete tag from VAS DB.
+*
+*/
+
+
+#ifndef MNSSTAGMGR_H
+#define MNSSTAGMGR_H
+
+// INCLUDES
+#include <e32std.h>
+#include <nssvascoreconstant.h>
+
+
+//FORWARD DECLARATIONS
+class MNssGetTagClient;
+class MNssDeleteTagClient;
+class MNssSaveTagClient;
+class MNssTag;
+class MNssRRD;
+class MNssContext;
+class MNssGetTagReferenceClient;
+class MNssTagReference;
+
+// CLASS DECLARATIONS
+/**
+*  MNssTagMgr is the interface class for tag management. 
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssTagMgr
+{
+public:
+   /**
+   * Creates a new tag. A context needs to be created prior to creating a tag.
+   * @since 2.0
+   * @param aContext - context for the tag
+   * @return newly created tag pointer
+   */
+   virtual MNssTag* CreateTagL(MNssContext* aContext)=0;
+   
+   /**
+   * Gets tag list associated with a context. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aContext - context for which to get the tags
+   * @return synchronous return error code
+   */   
+   virtual TInt GetTagList(MNssGetTagClient* aTagClient, MNssContext* aContext)=0;
+
+   /**
+   * Gets tag list with a given name. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aContext - context for which to get the tags
+   * @param aName - name for which to get the tags
+   * @return synchronous return error code
+   */   
+   virtual TInt GetTagList( MNssGetTagClient* aTagClient, MNssContext* aContext,
+                            const TDesC& aName)=0;
+      
+   /**
+   * Delete tag from VAS DB. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTag - tag to delete
+   * @return synchronous return error code
+   */   
+   virtual TInt DeleteTag(MNssDeleteTagClient* aTagClient,MNssTag* aTag)=0;
+
+   /**
+   * Save tag to VAS DB. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTag - tag to save
+   * @return synchronous return error code
+   */   
+   virtual TInt SaveTag(MNssSaveTagClient* aTagClient,MNssTag* aTag)=0;
+   
+   /**
+   * Get tag count from VAS DB. Synchronous.
+   * @since 2.0
+   * @param aContext - context for which to get tag count.
+   * @return synchronous return error code or tagCount
+   */   
+   virtual TInt TagCount(MNssContext* aContext)=0;
+
+   /**
+   * Get the tag(s) based on partial rrd int data. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTInt - a rrd int value
+   * @param aPosition - the rrd int value position in the rrd intarray 
+   * @return asynchronous return error code
+   */
+   virtual TInt GetTagList( MNssGetTagClient* aTagClient,MNssContext* aContext,
+                            TInt aNum,TInt aPosition )=0;
+   /**
+   * Get the tag(s) based on partial rrd text data. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTInt - a rrd text value
+   * @param aPosition - the rrd text value position in the rrd textarray
+   * @return asynchronous return error code
+   */
+   virtual TInt GetTagList( MNssGetTagClient* aTagClient,MNssContext* aContext,
+                            TDesC& aText,TInt aPosition )=0;
+                            
+   /**
+   * Get a list of tag references based on context. Asynchronous.
+   * @since 2.0
+   * @param aTagReferenceClient - call back address
+   * @param aContext - a context
+   * @return asynchronous return error code
+   */
+   virtual TInt GetTagReferenceList( MNssGetTagReferenceClient* aTagRefClient,
+                                     MNssContext* aContext )=0;
+   
+   /**
+   * Get a tag based on tagreference. Asynchronous.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTagReference - a tagreferenc
+   * @return asynchronous return error code
+   */
+   virtual TInt GetTag(MNssGetTagClient* aTagClient,MNssTagReference* aTagReference)=0;
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtagreference.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssTagReference is an abstraction for a voice tag reference. 
+*               MNssTagReference consist of a tag name, which can be
+*               used to receive the full tag when need. 
+*
+*/
+
+
+#ifndef NSSVASMTAGREFERENCE_H
+#define NSSVASMTAGREFERENCE_H
+
+#include <e32std.h>
+
+/**
+* MNssTagReference is the interface class for a tag reference.
+* From a tagreference a full tag can be retrieved with
+* the GetTag(MNssGetTagClient* aClient,MNssTagReference* aTagRef);
+* method.
+* @lib NssVASApi.lib
+* @since 2.0
+*/
+class MNssTagReference
+    {
+    public:
+    
+        /**
+        * Get the tagname
+        * @since 2.0
+        * @return tagname for this tag
+        */
+        virtual TDesC& TagName()=0; 
+
+        /**
+        * virtual destructor for proper clean up
+        */
+    	virtual ~MNssTagReference(){}
+    };
+
+#endif // NSSVASMTAGREFERENCE_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtagselecthandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssTagSelectHandler interface class handles voice tag select 
+*                event, generaed when a voice tag is selected as a result of
+*                recognition via MNssRecognitionHandler::SelectTag().
+*                To receive the event the client must register via
+*                MNssTagSelectNotification::Register().
+*				 The client is responsible for deleting the returned voice tag.
+*
+*/
+
+
+#ifndef MNSSTAGSELECTHANDLER_H
+#define MNSSTAGSELECTHANDLER_H
+
+// INCLUDES
+
+#include "nssvasmtag.h"
+
+// CLASS DEFINITIONS
+
+/**
+*  Voice Tag Selection Handler class.
+*  Handles the voice tag select notification event generated by
+*  MNssRecognitionHandler::SelectTag(). The client is resonsible for deleting the
+*  returned voice tag.
+*
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssTagSelectHandler
+{
+
+public:
+
+    /**
+    * Handle Tag Select Event - Event indicating a voice tag has been selected.
+    * @since 2.0
+    * @param aClientTag The voice tag which has been selected. The client is
+	*                   resonsible for deleting aClientTag.
+    * @return void
+    */
+	virtual void HandleTagSelect( MNssTag* aClientTag ) = 0;
+
+};
+
+#endif //  MTAGSELECTHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtagselectnotification.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MTagSelectNotification interface class allows the client to
+*                register and deregister for a voice tag select event.
+*                See MTagSelectHandler class for event handler. 
+*
+*/
+
+
+#ifndef MNSSTAGSELECTNOTIFICATION_H
+#define MNSSTAGSELECTNOTIFICATION_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32def.h>
+#include "nssvasmcontext.h"
+#include "nssvasmtagselecthandler.h"
+
+// CLASS DEFINITIONS
+
+/**
+*  Voice Tag Select Notification class.
+*  Allows the client to register and deregister for a voice tag select event.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class MNssTagSelectNotification
+{
+
+public:
+
+
+   public:  //enum
+
+        enum TNssSelectResult
+        {
+        EVasErrorNone,
+        EVasSelectFailed  
+        };
+
+        /**
+        * Register for voice tag select notification
+        * @since 2.0
+        * @param aContext The voice tag context which determines notification.
+        * @param aTagSelectHandler The event handler for tag select notification.
+        * @return TSelectError Return code to indicate request was valid.
+        */
+        virtual TNssSelectResult RegisterL(
+            MNssContext* aContext,
+			MNssTagSelectHandler* aTagSelectHandler) = 0;
+
+       /**
+        * Deegister from voice tag select notification
+        * @since 2.0
+        * @param aContext The voice tag context which determines notification.
+        * @param aTagSelectHandler The event handler for tag select notification,
+		*                          used to deregister the correct client.
+        * @return TSelectError Return code to indicate request was valid.
+        */
+        virtual TNssSelectResult Deregister(
+            MNssContext* aContext,
+			MNssTagSelectHandler * aTagSelectHandler) = 0;
+
+};
+
+#endif // MNSSTAGSELECTNOTIFICATION_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtraintexteventhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssTrainTextEventHandler class provides the call back methods to handle 
+*               the events during Train From Text operation.
+*
+*/
+
+
+#ifndef NSSVASMTRAINTEXTEVENTHANDLER_H
+#define NSSVASMTRAINTEXTEVENTHANDLER_H
+
+/**
+* The MNssTrainTextEventHandler class provides the call back methods to handle 
+* the events during Train From Text operation.
+*
+* @lib NssVASApi.lib
+* @since 2.0
+*/
+class MNssTrainTextEventHandler
+  {     
+   public: 
+   
+    /**
+	* Train Complete Event - Training was successful
+	* @since 2.0
+	* @param aErrorCode KErrNone if training was successfull
+	*/       
+    virtual void HandleTrainComplete( TInt aErrorCode ) = 0;
+};
+
+#endif // NSSVASMTRAINTEXTEVENTHANDLER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmtrainvoiceeventhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssTrainVoiceEventHandler class provides the call back methods to handle 
+*               the events during Train operation.
+*
+*/
+
+
+#ifndef NSSVASMTRAINVOICEEVENTHANDLER_H
+#define NSSVASMTRAINVOICEEVENTHANDLER_H
+
+/**
+* The MNssTrainVoiceEventHandler class provides the call back methods to handle 
+* the events during Train operation.
+*
+* @lib NssVASApi.lib
+* @since 2.0
+*/
+class MNssTrainVoiceEventHandler
+  {
+   public:  //enum
+
+    /**
+    * TNssTrainResult will have all the enums to represent the result values from
+    * HandleTrainFailed method.
+    * 
+    * NOTE:
+    * The HandleTrainFailed() should handle the undefined error for TNssTrainResult.
+    */         
+    enum TNssTrainResult
+        {
+        EVasTrainFailed = 1,  
+        EVasRecordFailed,
+        EVasTrainFailedNoSpeech,
+        EVasTrainFailedTooEarly,
+        EVasTrainFailedTooLong,
+        EVasTrainFailedTooShort,
+        EVasTagSpaceUnavailable,
+        EVasTrainNoMemory,
+        EVasTrainAccessDeny,
+        EVasTrainUndefinedError10,   // for place holder
+        EVasTrainUndefinedError9,
+        EVasTrainUndefinedError8,
+        EVasTrainUndefinedError7,
+        EVasTrainUndefinedError6,
+        EVasTrainUndefinedError5,
+        EVasTrainUndefinedError4,
+        EVasTrainUndefinedError3,
+        EVasTrainUndefinedError2,
+        EVasTrainUndefinedError1
+        };
+
+        
+   public: 
+        
+
+    /**
+    * Ready To Record Event - Recognizer is ready to receive the input speech
+    * @since 2.0
+    * @param no parameter
+    * @return no return value
+    */       
+    virtual void HandleReadyToRecord() = 0;
+
+		
+	/**
+	* Record Started Event - Recognizer is receiving the input speech 
+    * @since 2.0
+    * @param no parameter
+    * @return no return value
+    */
+	virtual void HandleRecordStarted() = 0;
+
+	/**
+	* End Of Utterance Event - Recognizer has finished receiving the input speech 
+    * @since 2.0
+    * @param no parameter
+    * @return no return value
+    */
+	virtual void HandleEouDetected() = 0;
+
+	/**
+	* Train Complete Event - Recognizer has trained the input speech
+	* by creating a model.
+    * @since 2.0
+    * @param aErrorCode KErrNone if training was successfull
+    * @return no return value
+	*/
+	virtual void HandleTrainComplete( TInt aErrorCode ) = 0;
+
+};
+
+#endif // NSSVASMTRAINVOICEEVENTHANDLER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmvasdatabaseobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssVASDatabaseObserver is the interface class for VAS DB event 
+*				 notification to observers. An observer must derive from 
+*				 MNssVASDatabaseObserver and implement its HandleVASDBEvent
+*				 (TVASDBEVent aEvent) method to handle the event. 
+*
+*/
+
+
+#ifndef MNSSVASDATABASEOBSERVER_H
+#define MNSSVASDATABASEOBSERVER_H
+
+//  INCLUDES
+#include <nssvascvasdbevent.h>
+
+// CLASS DECLARATION
+
+/**
+* MNssVASDatabaseObserver is the interface class for VAS DB event notification. 
+* An observer must derive from MNssVASDatabaseObserver and implement 
+* its HandleVASDBEvent(CNssVASDBEvent aEvent) method to handle the event.
+* The clint is responsible for deleting the event object. 
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class MNssVASDatabaseObserver 
+    {
+    public: 
+      /**
+      * Callback for event notification
+      * @since 2.0
+      * @param aEvent 
+      * @return 
+      */
+	  virtual void HandleVASDBEvent(CNssVASDBEvent *aEvent) = 0;
+    };
+
+#endif      // MNSSVASDATABASEOBSERVER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/nssvasmvasdbeventnotifier.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssVASDBEventNotifier is the interface class for clients to add 
+*				 or remove observers to the VAS database. 
+*
+*/
+
+
+#ifndef NSSMVASDBEVENTNOTIFIER_H
+#define NSSMVASDBEVENTNOTIFIER_H
+
+//  INCLUDES
+#include <nssvascoreconstant.h>
+#include <nssvasmvasdatabaseobserver.h>
+
+
+// CLASS DECLARATION
+
+/**
+*  MNssVASDBEventNotifier is the interface class for clients to add/remove observers.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class MNssVASDBEventNotifier 
+    {
+    public:  
+      /**
+      * Adds an observer to VAS DB
+      * @since 2.0
+      * @param call back address
+      * @return none
+      */
+	  virtual void AddObserverL(MNssVASDatabaseObserver* aObserver) = 0;
+
+	  /**
+      * Removes an observer from VAS DB
+      * @param call back address
+      * @leave KErrNotFound if given observer has never been added
+      */
+	  virtual void RemoveObserverL(MNssVASDatabaseObserver* aObserver) = 0;
+
+    };
+
+#endif      // MVASDBEVENTNOTIFIER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/vascvpbkhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,423 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Phonebook handler that uses Virtual phonebook to access phonebook data
+*
+*/
+
+
+#ifndef VASCVPBKHANDLER_H
+#define VASCVPBKHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+
+#include <cntdef.h> 
+
+#include <VPbkFieldType.hrh>
+
+#include <MVPbkContactStoreListObserver.h>
+#include <MVPbkSingleContactOperationObserver.h>
+#include <MVPbkContactObserver.h>
+#include <MVPbkContactAttributeManager.h>
+#include <MVPbkBatchOperationObserver.h> 
+#include <MVPbkContactViewObserver.h> 
+
+#include <vasmbasepbkhandler.h>
+#include <vasmcontactobserver.h>
+
+// CONSTANTS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CVPbkContactManager;
+class CVPbkContactIdConverter;
+class MVPbkContactOperationBase;
+class MVPbkStoreContact;
+class MVPbkStoreContactField;
+class MNssTag;
+class MVasContactObserver;
+
+// CLASS DECLARATION
+
+/**
+* Phonebook handler that uses Virtual phonebook to access phonebook data
+*
+* @since 3.2
+*/
+class CVasVPbkHandler : public CBase,
+                        public MVasBasePbkHandler,
+                        public MVPbkContactStoreListObserver,
+                        public MVPbkSingleContactOperationObserver,
+                        public MVPbkContactObserver,
+                        public MVPbkSetAttributeObserver,
+                        public MVPbkBatchOperationObserver,
+                        public MVPbkContactViewObserver
+    {
+    public:  // Constructors and destructor
+   
+        /**
+        * Two-phased constructor.
+        *
+        * @since 3.2
+        */
+        IMPORT_C static CVasVPbkHandler* NewL();
+        
+        /**
+        * Destructor.
+        *
+        * @since 3.2
+        */
+        IMPORT_C virtual ~CVasVPbkHandler();
+
+    public: // New functions
+
+        /**
+        * Opens phonebook connection and contact stores
+        *
+        * @since 3.2
+        */
+        IMPORT_C void InitializeL();
+        
+        /**
+        * Creates the contact change notifier and sets observer as a listener
+        *
+        * @since 3.2
+        * @param aObserver Contact change listener
+        */
+        IMPORT_C void CreateContactObserverL( MVasContactObserver* aObserver );
+        
+        /**
+        * Compresses database
+        *
+        * @since 3.2
+        */
+        IMPORT_C void CompressL();
+        
+        /**
+        * Returns all contact ids from database
+        *
+        * @since 3.2
+        * @return Contact id array
+        */
+        IMPORT_C CContactIdArray* ContactIdArrayLC();
+        
+        
+        /**
+        * Finds a contact from phonebook
+        *
+        * @since 3.2
+        * @param aTag Tag that is used as a search parameter
+        */
+        IMPORT_C void FindContactL( MNssTag* aTag );
+        
+        /**
+        * Finds a contact from phonebook
+        *
+        * @since 3.2
+        * @param aContactId Id of the contact that should be found
+        * @param aReadOnly ETrue if contact will not be edited else EFalse
+        */
+        IMPORT_C void FindContactL( TInt32 aContactId, TBool aReadOnly );
+        
+        /**
+        * Closes contact with or without saving changes
+        *
+        * @since 3.2
+        * @param aSaveChanges ETrue to save changes else EFalse
+        */
+        IMPORT_C void CloseContactL( TBool aSaveChanges );
+        
+        /**
+        * Finds a field from contact
+        *
+        * @since 3.2
+        * @param aTag Tag that is used as a search parameter
+        */
+        IMPORT_C void FindFieldL( MNssTag* aTag );
+        
+        /**
+        * Finds a field from contact
+        *
+        * @since 3.2
+        * @param aFieldId Field id that is used as a search parameter
+        */
+        IMPORT_C void FindFieldL( TInt aFieldId );
+        
+        /**
+        * Finds a field from contact
+        *
+        * @since 3.2
+        * @param aTag Tag that is used as a search parameter
+        */
+        IMPORT_C void FindContactFieldL( MNssTag* aTag );
+        
+        /**
+        * Searches for a default field of a given type
+        *
+        * @param aCommandType Command type that is used as a select parameter
+        *                     Must be one of TVasExtensionCommand types
+        */
+        IMPORT_C void FindDefaultContactFieldL( TInt aCommandType );
+        
+        /**
+        * Changes current field's voice tag field status
+        *
+        * @since 3.2
+        * @param aSet If ETrue field is set else field is removed
+        */   
+        IMPORT_C void ChangeVoiceTagFieldL( TBool aSet );
+        
+        /**
+        * Returns the field label
+        *
+        * @since 3.2
+        * @return Field label
+        */
+        IMPORT_C TPtrC LabelL();
+        
+        /**
+        * Returns the field text
+        *
+        * @since 3.2
+        * @return Field text
+        */
+        IMPORT_C TPtrC TextL();
+        
+        /**
+        * Returns the field type
+        *
+        * @since 3.2
+        * @return Field type
+        */
+        IMPORT_C TFieldType FieldTypeL();
+        
+        /**
+        * Returns the field id
+        *
+        * @since 3.2
+        * @return Field id
+        */
+        IMPORT_C TInt FieldIdL();
+        
+        /**
+        * Returns information if current field is empty
+        *
+        * @since 3.2
+        * @return ETrue if field is empty else EFalse
+        */
+        IMPORT_C TBool IsFieldEmptyL();
+
+    public: // Functions from base classes
+
+        /**
+        * From MVPbkContactStoreListObserver
+        * @see MVPbkContactStoreListObserver
+        */
+        void StoreReady( MVPbkContactStore& aContactStore );
+
+        /**
+        * From MVPbkContactStoreListObserver
+        * @see MVPbkContactStoreListObserver
+        */
+        void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
+
+        /**
+        * From MVPbkContactStoreListObserver
+        * @see MVPbkContactStoreListObserver
+        */
+        void HandleStoreEventL( MVPbkContactStore& aContactStore,
+                                TVPbkContactStoreEvent aStoreEvent );
+        
+        /**
+        * From MVPbkContactStoreListObserver
+        * @see MVPbkContactStoreListObserver
+        */
+        void OpenComplete();
+        
+        /**
+        * From MVPbkSingleContactOperationObserver
+        * @see MVPbkSingleContactOperationObserver
+        */
+        void VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation,
+                                                 MVPbkStoreContact* aContact );
+                                                 
+        /**
+        * From MVPbkSingleContactOperationObserver
+        * @see MVPbkSingleContactOperationObserver
+        */                                         
+        void VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation,
+                                               TInt aError );
+        
+        /**
+        * From MVPbkContactObserver
+        * @see MVPbkContactObserver
+        */                                         
+        void ContactOperationCompleted( TContactOpResult aResult );
+
+        /**
+        * From MVPbkContactObserver
+        * @see MVPbkContactObserver
+        */  
+        void ContactOperationFailed( TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified );
+
+        /**
+        * From MVPbkSetAttributeObserver
+        * @see MVPbkSetAttributeObserver
+        */                                       
+        void AttributeOperationComplete( MVPbkContactOperationBase& aOperation ); 
+        
+        /**
+        * From MVPbkSetAttributeObserver
+        * @see MVPbkSetAttributeObserver
+        */
+        void AttributeOperationFailed( MVPbkContactOperationBase& aOperation, TInt aError );
+        
+        /**
+        * From MVPbkBatchOperationObserver
+        * @see MVPbkBatchOperationObserver
+        */
+        void StepComplete( MVPbkContactOperationBase& aOperation, TInt aStepSize );
+        
+        /**
+        * From MVPbkBatchOperationObserver
+        * @see MVPbkBatchOperationObserver
+        */
+        TBool StepFailed( MVPbkContactOperationBase& aOperation, TInt aStepSize, TInt aError );
+        
+        /**
+        * From MVPbkBatchOperationObserver
+        * @see MVPbkBatchOperationObserver
+        */
+        void OperationComplete( MVPbkContactOperationBase& aOperation );
+        
+        /**
+        * From MVPbkContactViewObserver
+        * @see MVPbkContactViewObserver
+        */
+        void ContactViewReady( MVPbkContactViewBase& aView );
+        
+        /**
+        * From MVPbkContactViewObserver
+        * @see MVPbkContactViewObserver
+        */
+        void ContactViewUnavailable( MVPbkContactViewBase& aView );
+        
+        /**
+        * From MVPbkContactViewObserver
+        * @see MVPbkContactViewObserver
+        */
+        void ContactAddedToView( MVPbkContactViewBase& aView, TInt aIndex, const MVPbkContactLink& aContactLink );
+        
+        /**
+        * From MVPbkContactViewObserver
+        * @see MVPbkContactViewObserver
+        */
+        void ContactRemovedFromView( MVPbkContactViewBase& aView, TInt aIndex, const MVPbkContactLink& aContactLink );
+        
+        /**
+        * From MVPbkContactViewObserver
+        * @see MVPbkContactViewObserver
+        */
+        void ContactViewError( MVPbkContactViewBase& aView, TInt aError, TBool aErrorNotified );
+                
+    private:  // New functions
+
+        /**
+        * C++ default constructor.
+        */
+        CVasVPbkHandler();
+
+        /**
+        * By default constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Selects default field type for the given tag
+        *
+        * @param aCommandType Command type that is used as a select parameter
+        *                     Must be one of TVasExtensionCommand types
+        * @return Default field type
+        */
+        TVPbkDefaultType SelectDefaultType( TInt aCommandType );
+        
+        /**
+        * Checks if given field should be used
+        *
+        * @param aField Field that is checked
+        * @param aCommandType Command type that is used as a select parameter
+        *                     Must be one of TVasExtensionCommand types
+        * @return ETrue if field is accepted else EFalse
+        */
+        TBool AcceptDefaultField( MVPbkStoreContactField& aField, TInt aCommandType );
+        
+        /**
+        * Converts field id to old phonebook id
+        *
+        * @param aField Field to be converted
+        * @return Old phonebook field id
+        */
+        TInt ConvertFieldId( MVPbkStoreContactField& aField );
+        
+        /**
+        * Converts contact event type
+        *
+        * @param aEvent Event to be converted
+        * @return Corresponding vas contact event
+        */
+        TVasContactEvent ConvertEvent( const TVPbkContactStoreEvent& aEvent );
+        
+        /**
+        * Gets the priority of the given field
+        *
+        * @param aField Field which priority is returned
+        * @return Field priority
+        */
+        TInt FieldPriority( MVPbkStoreContactField& aField );
+
+    private:    // Data
+
+        // Contact manager
+        CVPbkContactManager*        iContactManager;
+        
+        // Contact id converter
+        CVPbkContactIdConverter*    iConverter;
+        
+        // Current operation
+        MVPbkContactOperationBase*  iOperation;
+        
+        // Found contact
+        MVPbkStoreContact*          iContact;
+        
+        // Found field
+        MVPbkStoreContactField*     iField;
+        
+        // Contact change observer
+        MVasContactObserver*        iObserver;
+        
+        // For waiting callbacks
+        CActiveSchedulerWait        iWait;
+        
+        // Possible error code
+        TInt                        iError;
+        
+        // Is mms supported or not
+        TBool                       iMMSSupported;
+
+        };
+
+#endif      // VASCVPBKHANDLER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/vasmbasepbkhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Abstract base class for phonebook data access
+*
+*/
+
+
+#ifndef VASMBASEPBKHANDLER_H
+#define VASMBASEPBKHANDLER_H
+
+// INCLUDES
+#include <cntdef.h>
+
+// CONSTANTS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class MNssTag;
+class MVasContactObserver;
+
+// CLASS DECLARATION
+
+/**
+* Abstract base class for phonebook data access
+*
+* @since 3.2
+*/
+class MVasBasePbkHandler
+    {
+    public:  // Constructors and destructor
+    
+        /**
+        * Destructor. Defined here so that client can use M-class pointer to destroy
+        * the concrete C-object
+        *
+        * @since 3.2
+        */
+        virtual ~MVasBasePbkHandler() {};
+   
+    public: // New functions
+
+        /**
+        * Opens phonebook connection and contact stores
+        *
+        * @since 3.2
+        */
+        virtual void InitializeL() = 0;
+        
+        /**
+        * Creates the contact change notifier and sets observer as a listener
+        *
+        * @since 3.2
+        * @param aObserver Contact change listener
+        */
+        virtual void CreateContactObserverL( MVasContactObserver* aObserver ) = 0;
+        
+        /**
+        * Compresses database
+        *
+        * @since 3.2
+        */
+        virtual void CompressL() = 0;
+        
+        /**
+        * Returns all contact ids from database
+        *
+        * @since 3.2
+        * @return Contact id array
+        */
+        virtual CContactIdArray* ContactIdArrayLC() = 0;
+        
+        /**
+        * Finds a contact from phonebook
+        *
+        * @since 3.2
+        * @param aTag Tag that is used as a search parameter
+        */
+        virtual void FindContactL( MNssTag* aTag ) = 0;
+        
+        /**
+        * Finds a contact from phonebook
+        *
+        * @since 3.2
+        * @param aContactId Id of the contact that should be found
+        * @param aReadOnly ETrue if contact will not be edited else EFalse
+        */
+        virtual void FindContactL( TInt32 aContactId, TBool aReadOnly ) = 0;
+        
+        /**
+        * Closes contact with or without saving changes
+        *
+        * @since 3.2
+        * @param aSaveChanges ETrue to save changes else EFalse
+        */
+        virtual void CloseContactL( TBool aSaveChanges ) = 0;
+        
+        /**
+        * Finds a field from contact
+        *
+        * @since 3.2
+        * @param aTag Tag that is used as a search parameter
+        */
+        virtual void FindFieldL( MNssTag* aTag ) = 0;
+        
+        /**
+        * Finds a field from contact
+        *
+        * @since 3.2
+        * @param aFieldId Field id that is used as a search parameter
+        */
+        virtual void FindFieldL( TInt aFieldId ) = 0;
+        
+        /**
+        * Finds a field from contact
+        *
+        * @since 3.2
+        * @param aTag Tag that is used as a search parameter
+        */
+        virtual void FindContactFieldL( MNssTag* aTag ) = 0;
+        
+        /**
+        * Searches for a default field of a given type
+        *
+        * @param aCommandType Command type that is used as a select parameter
+        *                     Must be one of TVasExtensionCommand types
+        */
+        virtual void FindDefaultContactFieldL( TInt aCommandType ) = 0;
+        
+        /**
+        * Changes current field's voice tag field status
+        *
+        * @since 3.2
+        * @param aSet If ETrue field is set else field is removed
+        */   
+        virtual void ChangeVoiceTagFieldL( TBool aSet ) = 0;
+        
+        /**
+        * Returns the field label
+        *
+        * @since 3.2
+        * @return Field label
+        */
+        virtual TPtrC LabelL() = 0;
+        
+        /**
+        * Returns the field text
+        *
+        * @since 3.2
+        * @return Field text
+        */
+        virtual TPtrC TextL() = 0;
+        
+        /**
+        * Returns the field type
+        *
+        * @since 3.2
+        * @return Field type
+        */
+        virtual TFieldType FieldTypeL() = 0;
+        
+        /**
+        * Returns the field id
+        *
+        * @since 3.2
+        * @return Field id
+        */
+        virtual TInt FieldIdL() = 0;
+        
+        /**
+        * Returns information if current field is empty
+        *
+        * @since 3.2
+        * @return ETrue if field is empty else EFalse
+        */
+        virtual TBool IsFieldEmptyL() = 0;
+                
+    public: // Functions from base classes
+        
+    private:  // New functions
+               
+    private:    // Data
+    
+        };
+
+#endif      // VASMBASEPBKHANDLER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/inc/vasmcontactobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contact observer interface
+*
+*/
+
+
+#ifndef VASMCONTACTOBSERVER_H
+#define VASMCONTACTOBSERVER_H
+
+// INCLUDES
+#include <e32std.h>
+
+#include <cntdef.h>
+
+// CONSTANTS
+
+// DATA TYPES
+   
+// Contact event
+enum TVasContactEvent
+    {
+    ENullEvent,                     // No event occured.  
+    EContactAdded,                  // A contact has been added to the contact store.  
+    EContactDeleted,                // A contact has been deleted from the contact store.  
+    EContactChanged,                // An existing contact in the contact store has been changed.  
+    EGroupAdded,                    // A contact group has been added to the contact store.  
+    EGroupDeleted,                  // A contact group has been deleted from the contact store.  
+    EGroupChanged,                  // An existing contact group in the contact store has been changed.  
+    EStoreBackupBeginning,          // Contact store backup is beginning.  
+    EStoreRestoreBeginning,         // Contact store restore is beginning.  
+    EStoreBackupRestoreCompleted,   // Contact store backup or restore is completed.  
+    EUnknownChanges,                // There has been some unknown changes in the contact store.  
+    ENotSupported                   // Other kind of changes that are not supported
+    };
+    
+struct TPhonebookEvent
+    {
+    TTime iTime;
+    TVasContactEvent iType;
+    TContactItemId iContactId;
+     
+    TPhonebookEvent()
+        {
+        iType = EContactChanged;
+        iContactId = 0;
+        iTime.UniversalTime();
+        }
+    };
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+* Contact observer interface
+*
+* @since 3.2
+*/
+class MVasContactObserver
+    {
+    public:  // Constructors and destructor
+   
+    public: // New functions
+
+        /**
+        * Called when a contact change event occurs
+        *
+        * @since 3.2
+        */
+        virtual void HandleEventL( const TPhonebookEvent& aEvent ) = 0;
+        
+    public: // Functions from base classes
+        
+    private:  // New functions
+               
+    private:    // Data
+    
+        };
+
+#endif      // VASMCONTACTOBSERVER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_api/vas_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="619514c387e474fcf5b76cd83c03b28a" dataversion="2.0">
+  <name>VAS API</name>
+  <description>A composite of all Voice Application Services APIs.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssvasapi.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_contact_handler_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                VAS Contact Handler API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssvasccontacthandler.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvasccontacthandler.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_contact_handler_api/inc/nssvasccontacthandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VAS contact handler interface
+*
+*/
+
+
+#ifndef NSSCONTACTHANDLER_H
+#define NSSCONTACTHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CNssContactHandlerImplementation;
+class CContactHandlerStopper;
+
+/**
+*  Contact handler creates voice tags out of phonebook contacts and keeps
+*  SIND data in sync with the phonebook
+*
+*  @lib NssVASContactHdlr.dll
+*  @since 2.8
+*/
+class CNssContactHandler :  public CBase
+    {
+   public:  // Constructors and destructor
+
+      /**
+      * Two-phased constructor.
+      */
+      IMPORT_C static CNssContactHandler* NewL();
+        
+      /**
+      * Destructor.
+      */
+      IMPORT_C virtual ~CNssContactHandler();
+
+   public: // New functions
+      
+      /**
+      * Disables the contact handler until EnableEventHandling is called
+      * Typically this means 'until reboot'
+      * Is used in case of unrecoverable error.
+      * 
+      * @todo Move to private?
+      * @return void
+      */
+      IMPORT_C void DisableEventHandling();
+
+      /**
+      * Enables the contact handler. 
+      * 
+      * @deprecated Move to private?
+      * @return void
+      */
+      IMPORT_C void EnableEventHandling();
+
+      /**
+      * Sets pointer to object which handles ContactHandler thread stopping.
+      * 
+      * @param "CContactHandlerStopper* aStopper" Pointer to stopper object
+      * @return void
+      */
+      void SetStopperPointer( CContactHandlerStopper* aStopper );
+
+   private:
+       
+      /**
+      * C++ default constructor.
+      */
+      CNssContactHandler();
+        
+      /**
+      * Second-phase constructor
+      */
+      void ConstructL();
+        
+      // Prohibit copy constructor if not deriving from CBase.
+      /** @todo why? */
+      CNssContactHandler( const CNssContactHandler& );
+        
+      // Prohibit assigment operator if not deriving from CBase.
+      CNssContactHandler& operator= ( const CNssContactHandler& );
+        
+      /**
+      * Thread function.
+      *
+      * @param "TAny* aParams" Void pointer given in the thread startup phase.
+      */
+      static TInt CHThreadFunction( TAny* aParams );
+        
+   private:
+
+       // ContactHandler thread name
+       TBuf<125> iThreadNameBuf;
+
+       // Pointer to ContactHandler thread stopper
+       CContactHandlerStopper* iStopper;
+    };
+
+#endif // CONTACTHANDLER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_contact_handler_api/vas_contact_handler_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="9ebdd1524bca3d4fb7d09cb36b5cba67" dataversion="2.0">
+  <name>VAS Contact Handler API</name>
+  <description>The API used to launch the contact handler,which maintains synchronization between the contact DB and the name dialing voice tags.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="nssvascontacthdlr.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_vcommand_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                VAS VCommand API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/vcommandapi.h     APP_LAYER_PLATFORM_EXPORT_PATH(vcommandapi.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_vcommand_api/inc/vcommandapi.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,748 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice command service interfaces
+*
+*/
+
+
+
+#ifndef VCOMMANDAPI_H
+#define VCOMMANDAPI_H
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <s32strm.h>
+#include <nssvasmrrd.h>  // For KNssVASMAXRRDTextLength only
+
+/** 
+* Maximal length of the exe arguments string
+* @todo If longer arguments needed, reengineer the storage scheme. 
+*       Currently argument string has to fit into the VAS DB rrdtext column
+*       @see CTagCommandConverter
+*/
+const TInt KMaxVCArgumentLength = KNssVASMAXRRDTextLength;
+
+class MNssPlayEventHandler;
+class CStoredVCommand;
+class MVCService;
+class CVCommandHandler;
+class CGulIcon;
+
+/**
+ * Container for the voice command folder information. Note that every command can
+ * have its own folder information
+ */
+class CVCFolderInfo : public CBase
+    {
+    public:
+        /**
+         * This object does not take an ownership of the passed descriptors, 
+         * but makes own copies. 
+         * 
+         * @param aTitle Folder title. It is shown at the top of the screen,
+         *        when the folder is opened in the VCommand application
+         * @param aListedName Version of a title shown when the folder is
+         *        is displayed in the list of VCommands in the VCommand app
+         * @param aHelpTopicId Topic to open when help is requested for the 
+         *        given folder
+         * @param aIconIndex Zero based index of the folder icon in the folder icons mbm file
+         *        each index correspods to two images - the actual icon and its mask
+         * @param aIconFile Mbm file where the icons are obtained from. If KNullDesC, 
+         * 		  the default icon file is used
+         * 
+         */
+        IMPORT_C static CVCFolderInfo* NewL( const TDesC& aTitle,
+                const TDesC& aListedName, TUint32 aHelpTopicId, TUint aIconIndex,
+                const TDesC& aIconFile = KNullDesC );
+                
+        /**
+         * Constructs the folder information from stream
+         * @leave KErrNotSupported if the stream data format is unsupported
+         */
+        IMPORT_C static CVCFolderInfo* NewL( RReadStream& aStream );
+        
+        /**
+         * Cloning constructor
+         */
+        IMPORT_C static CVCFolderInfo* NewL( const CVCFolderInfo& aOriginal );
+        
+        IMPORT_C ~CVCFolderInfo();
+        
+        /** 
+        * Saves the folder information to stream.
+        * Descriptor components are saved as <length><descriptor> pairs, where 
+        * <length> is TInt32 and <descriptor> is the default descriptor represetation
+        */
+        IMPORT_C void ExternalizeL( RWriteStream &aStream ) const;
+        
+        /**
+         * Returns folder title. It is shown at the top of the screen,
+         *        when the folder is opened in the VCommand application
+         */
+        IMPORT_C const TDesC& Title() const;
+        
+        /**
+         * Version of a title shown when the folder is
+         * is displayed in the list of VCommands in the VCommand app
+         */
+        IMPORT_C const TDesC& ListedName() const;
+        
+        IMPORT_C TUint32 HelpTopicId() const;
+        
+	/**
+        * Creates an icon to represent this folder. Works only if CEikonEnv is available
+	* @return Icon for the folder
+	*/
+	IMPORT_C CGulIcon* IconLC() const;
+        
+        IMPORT_C TBool operator==( const CVCFolderInfo& aFolderInfo ) const;
+    
+    protected:
+        CVCFolderInfo( TUint32 aHelpTopicId, TUint aIconIndex );
+        // unhiding inherited parameterless constructor
+        CVCFolderInfo() {}
+        
+        /**
+         * Zero based index of the folder icon in the icon file
+         * @see IconFile
+         */
+        TUint IconIndex() const;
+        
+        /**
+         * Full file name of the file name, where the folder icon is obtained from
+         * Is always no longer, than KMaxFileName
+         * If KNullDesC is returned, the default icon file is used
+         */
+        TDesC& IconFile() const;
+
+    private:
+        /** @see NewL */
+        void ConstructL( const TDesC& aTitle, 
+                         const TDesC& aListedName,
+                         const TDesC& aIconFile );
+                
+        void ConstructL( RReadStream& aStream );
+        
+    private:
+        HBufC* iTitle;
+        
+        HBufC* iListedName;
+        
+        HBufC* iIconFile;
+        
+        TUint32 iHelpTopicId;
+        
+        TUint iIconIndex;
+        
+    };
+
+/** 
+* Container for VC app specific "human-visible" parts of the voice command:
+* tooltip, displayable text, folder, icon, etc
+*/ 
+class CVCCommandUi : public CBase
+    {
+    public:
+        /**
+        * This object does not take an ownership of the passed descriptors, 
+        * but makes own copies. 
+        * 
+        * @param aWrittenText Text to display
+        * @param aTooltip Second line of the text if ant
+        * @param aFolderInfo Folder-related details
+        * @param aModifiable If user can modify the command
+        * @param aConfirmationNeeded If EFalse, when the command is recognized,
+        *        it is immediately executed
+        *        If ETrue, when the command is recognized, it is played back and
+        *        user is asked to confirm the recognition results
+        * @see
+        * @todo Add "see" reference to the recognition-side function that uses the
+        *       "confirmation needed information"
+        * @todo aModifiable param is "hanging in the air" and never actually used
+        *       Clarify its existence and responsibilities
+        * @param aUserText Optional user-specified shortcut for the command
+        */
+        IMPORT_C static CVCCommandUi* NewL( const TDesC& aWrittenText, 
+                const CVCFolderInfo& aFolderInfo, TBool aModifiable, 
+                const TDesC& aTooltip, const TUid& aIconUid, 
+                const TDesC& aUserText = KNullDesC,
+                TBool aConfirmationNeeded = ETrue );
+                
+        /**
+        * Factory function that constructs a CVCCommandUi from the stream
+        * @leave KErrNotSupported if the stream data format is unsupported
+        *        e.g. if it has been written by newer implementation
+        */
+        IMPORT_C static CVCCommandUi* NewL( RReadStream& aStream );
+        
+        /**
+        * Copy the existing CVCCommandUi
+        */
+        IMPORT_C static CVCCommandUi* NewL( const CVCCommandUi& aOriginal );
+                
+        /** Destructor */
+        IMPORT_C ~CVCCommandUi();
+
+        /** 
+		* Saves the command to stream.
+		* Descriptor components are saved as <length><descriptor> pairs, where 
+		* <length> is TInt32 and <descriptor> is the default descriptor represetation
+		* TBools are saved as TInt32 either
+		*/
+		IMPORT_C void ExternalizeL( RWriteStream &aStream ) const;
+
+        // Accessor methods
+        
+        /**
+        * @return Unmodifiable written text
+        */
+        IMPORT_C const TDesC& WrittenText() const;
+        
+        /**
+        * @return Unmodifiable user-specified shortcut for the command
+        *         KNullDesC if none
+        */
+        IMPORT_C const TDesC& UserText() const;
+        
+        /**
+        * @return Unmodifiable folder name
+        */
+        IMPORT_C const CVCFolderInfo& FolderInfo() const;
+        
+        /**
+        * @return ETrue if the command is modifiable by user
+        *         EFalse otherwise
+        */
+        IMPORT_C TBool Modifiable() const;
+        
+        /**
+        * @return EFalse, if when the command is recognized,
+        *         it is immediately executed
+        *         ETrue, if when the command is recognized, it is played back and
+        *         user is asked to confirm the recognition results
+        * @see
+        * @todo Add "see" reference to the recognition-side function that uses the
+        *       "confirmation needed information"
+        **/
+        IMPORT_C TBool ConfirmationNeeded() const;
+        
+        /**
+        * @return Unmodifiable extra text
+        */
+        IMPORT_C const TDesC& Tooltip() const;
+        
+
+        /**
+        * @return global icon id
+        * @todo AVKON-global? What kind of global?
+        */ 
+        IMPORT_C const TUid& IconUid() const;
+
+	    /**
+        * Creates the command icon. Takes into account the skin-specifics
+	    * Works only if CEikonEnv is available
+        * @return The command icon pushed to the cleanup stack
+        */
+	    IMPORT_C CGulIcon* IconLC() const;
+        
+        IMPORT_C TBool operator==( const CVCCommandUi& aCommandUi ) const;
+        
+        /**
+         * Tells if all non user-changeable parts of aCommandUi are equal to this object's
+         * @return ETrue if equal, EFalse otherwise
+         */
+        IMPORT_C TBool EqualNonUserChangeableData( const CVCCommandUi& aCommandUi ) const;
+        
+        
+    private:
+        /** 
+        * Second-phase constructor 
+        * @see NewL for guard conditions
+        */
+        void ConstructL( const TDesC& aWrittenText, 
+                const CVCFolderInfo& aFolderInfo, TBool aModifiable, 
+                const TDesC& aTooltip, const TUid& aIconUid, 
+                const TDesC& aUserText, TBool aConfirmationNeeded );
+                
+        void ConstructL( RReadStream& aStream );
+                
+    private: // Data
+
+        // Text shown on screen
+        HBufC* iWrittenText;
+        
+        // User-specified alternative command text
+        HBufC* iUserText;
+
+        // Text shown on screen
+        HBufC* iTooltip;
+
+        // Folder-related details
+        CVCFolderInfo* iFolderInfo;
+
+        // Tells if this command is user modifiable
+        TBool iUserCanModify;
+        
+        // Ask user to confirm the recognition result
+        TBool iConfirmationNeeded;
+        
+        // global icon id
+        /** @todo AVKON-global? What kind of global? */
+        TUid iIconUid;
+    };
+
+/**
+* Container for the information on how the command should be executed:
+* 1) app uid OR exe filename; 2) optional command line arguments
+*/    
+class CVCRunnable : public CBase
+    {
+    public:
+        /**
+        * Factory function
+        * @param aAppUid UID of the application to start. Cannot be KNullUidValue
+        * @param aArguments Command line to pass to the application. This object makes
+        *        a copy of the passed string
+        * @leave KErrOverflow if aArguments is longer, than KMaxVCArgumentLength
+        * @leave KErrArgument if aAppUid is KNullUidValue
+        */
+        IMPORT_C static CVCRunnable* NewL( TUid aAppUid, const TDesC8& aArguments = KNullDesC8 );
+        
+        /**
+        * Factory function
+        * @param aExeName Exe-file to start. Can be full or partical name according to 
+        *        the RProcess::Create rules. Cannot be KNullDesC
+        * @param aArguments Command line to pass to the application. This object makes
+        *        a copy of the passed string
+        * @leave KErrOverflow if aArguments is longer, than KMaxVCArgumentLength or 
+        *		 aExeName is longer, than KMaxFileName
+        * @leave KErrUndeflow if aExeName is empty
+        */
+        IMPORT_C static CVCRunnable* NewL( const TDesC& aExeName, 
+        								   const TDesC8& aArguments = KNullDesC8 );
+        
+        /** 
+        * Internalizes the object from stream 
+        * @leave KErrNotSupported if the stream data format is unsupported
+        *        e.g. if it has been written by newer implementation of CVCommandUi
+        */
+        IMPORT_C static CVCRunnable* NewL( RReadStream &aStream );
+        
+        /**
+        * Copy the existing CVRunnable
+        */
+        IMPORT_C static CVCRunnable* NewL( const CVCRunnable& aOriginal );
+        
+        
+        /** Destructor */
+        IMPORT_C ~CVCRunnable();
+        
+        /** 
+        * Run the command. In case of aAppUid specified during the construction
+        * application is started via the RApaLsSession::StartApp, otherwise
+        * via the RProcess::Create
+        * @leave System-wide error code. In particular KErrNotFound if there is
+        *        no such app in the system
+        */
+        IMPORT_C void ExecuteL() const;
+        
+        /** Saves the object to stream */
+        IMPORT_C void ExternalizeL( RWriteStream &aStream ) const;
+
+        /**
+        * @return The uid of the application to be started. KNullUid if there is none
+        */
+        IMPORT_C const TUid Uid() const;
+        
+        /**
+        * @return The filename of the application to be started. KNullDesC if there is none
+        */
+        IMPORT_C const TDesC& ExeName() const;
+        
+        /**
+        * The arguments to be passed to the application. This object keeps
+        * the ownership of the returned value
+        */
+        IMPORT_C const TDesC8& Arguments() const;
+        
+        IMPORT_C TBool operator==( const CVCRunnable& aRunnable ) const;
+        
+    private:
+        void ConstructL( TUid aAppUid, const TDesC8& aArguments );
+        void ConstructL( const TDesC& aExeName, const TDesC8& aArguments );
+        void ConstructL( RReadStream& aStream );
+        
+    private:
+        // UID of the application to be run, when the vcommand is recognized
+        // KNullUidValue if none specified
+        TUid iExeUid;
+        
+        // Filename to pass to RProcess::Create or NULL
+        HBufC* iExeName;
+        
+        // Arguments string
+        HBufC8* iArguments;
+    };
+
+/**
+* The packaged VCommand storable/retriavable to/from VAS
+*/
+class CVCommand : public CBase
+    {
+    public:
+        /**
+        * Factory function. Create a const snapshop of exe-ui-vastext collection
+        * @param aText Text to be trained by VAS. Can be of any length, however
+        *        only first KNssVasDbTagName characters will be trained by VAS
+        * @see KNssVasDbTagName in nssvasdbkonsts.h
+        * @param aRunnable Executable to be fired when the command is recognized. 
+        *        VCommand takes the ownership on the aRunnable
+        * @param aUi visible strings to be displayed in VC App. VCommand takes 
+        *        the ownership on the aUi
+        */
+        IMPORT_C static CVCommand* NewL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                                         const CVCCommandUi& aUi );
+        
+		/** 
+        * Internalizes the command from stream 
+        * @leave KErrNotSupported if the stream data format is unsupported
+        *        e.g. if it has been written by newer implementation
+        */
+        IMPORT_C static CVCommand* NewL( RReadStream &aStream );
+        
+        /**
+        * Copy the existing CVCommand
+        */
+        IMPORT_C static CVCommand* NewL( const CVCommand& aOriginal );
+        
+        /** Destructor */
+        IMPORT_C ~CVCommand();
+        
+        /**
+		* Saves the command to stream 
+		* Format: <protocol version: int32><SpokenTextLength: int32><SpokenText descriptor>
+		*         <runnable><commandui>
+		*/
+        IMPORT_C void ExternalizeL( RWriteStream &aStream ) const;
+        
+        /**
+        * @return the Runnable component of the command
+        */
+        IMPORT_C const CVCRunnable& Runnable() const;
+
+        /**
+        * @return the UI-related component of the command
+        */
+        IMPORT_C const CVCCommandUi& CommandUi() const;
+        
+        /**
+        * @return the text, that user is expected to pronounce
+        *         It is different from the CVCommandUi::WrittenText
+        */
+        IMPORT_C const TDesC& SpokenText() const;
+        
+        /**
+        * @return the user specified text, that user can pronounce to
+        *         recognize the command. Is always identical to the 
+        *         CVCommandUi::UserText()
+        *         Can be KNullDesC
+        *
+        * @todo Responsibilities of SpokenText, AlternativeSpokenText,
+        *       WrittenText and UserText are mixed. The source of problems
+        *       is the fact that WrittenText can really be different from the
+        *       default spoken text while User supplied text is always what's
+        *       expected to be [alternatively] recognized
+        *       A better structuring would be very welcome
+        */
+        IMPORT_C const TDesC& AlternativeSpokenText() const;
+        
+        /**
+        * Asynchronous
+        * Attempts to play back the text expected to be recognized. 
+        * To be playable command has to be added to CVCommandHandler AND
+        * then retrieved back
+        *
+        * @param aHandler CVCommandHandler where the command is stored
+        * @todo Consider storing link to CVCommandHandler within the CVCommand (CStoredVCommand)
+        *       Pros: No clumsy aHandler argument for the playback
+        *       Pros: No need to remember in which handler the command is stored
+        *             and why specifying storage is needed during the playback
+        *       Cons: In case of internal link the linked handler should still
+        *             exist. It cannot be e.g. destroyed and recreated later even
+        *             if the latter one is using the same VAS
+        *
+        * @param aPlayEventHandler Entity that handles the playback callbacks
+        * @see NssVasMPlayEventHandler.h
+        *
+        * @leave KErrBadHandle if the current command has not been retrieved 
+        *        from CVCommandHandler (i.e. was not trained for recognition)
+        * @leave KErrNotFound if this command cannot be found in aHandler
+        * @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasUnexpectedRequest
+        * @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInUse
+        * @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInvalidParameter
+        * @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                             EVasPlayFailed
+        */
+        IMPORT_C virtual void PlaySpokenTextL( const CVCommandHandler& aHandler, 
+                                   MNssPlayEventHandler& aPlayEventHandler ) const;
+        
+        /**
+        * Asynchronous
+        * Plays back the user-specified alternative spoken text. 
+        * Otherwise is identical to PlaySpokenTextL
+        * @see PlaySpokenTextL
+        * @leave KErrNotFound if this command cannot be found in aHandler of if 
+        *        it doesn't have a user-specified text
+        */ 
+        IMPORT_C virtual void PlayAlternativeSpokenTextL( const CVCommandHandler& aHandler, 
+                                   MNssPlayEventHandler& aPlayEventHandler ) const;
+        
+        /**
+        * Cancels playback of a spoken or alternative spoken text
+        * To be playable command has to be added to CVCommandHandler AND
+        * then retrieved back. After this function neither HandlePlayStarted,
+        * nor HandlePlayComplete will be called
+        *
+        * @param aHandler CVCommandHandler where the command is stored
+        *
+        * @leave KErrBadHandle if the current command has not been retrieved 
+        *        from CVCommandHandler (i.e. was not trained for recognition)
+        * @leave KErrNotReady if playback has never been started
+        *
+        */                                   
+        IMPORT_C virtual void CancelPlaybackL( const CVCommandHandler& aHandler ) const;
+        
+        IMPORT_C TBool operator==( const CVCommand& aCommand ) const;
+        
+        /**
+         * Tells if all non user-changeable parts of aCommand are equal to this command
+         * @return ETrue if equal, EFalse otherwise
+         */
+        IMPORT_C TBool EqualNonUserChangeableData( const CVCommand& aCommand ) const;
+        
+    protected:
+    	/**
+    	* @leave KErrOverflow if aText is longer, than KMaxVCTextLength
+    	*/ 
+        void ConstructL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                         const CVCCommandUi& aUi );
+        /**
+        * @see NewL( RReadStream& aStream )
+        */
+        void ConstructL( RReadStream& aStream );
+        
+        /**
+        * Clone itself
+        * Is used for copying via NewL( CVCommand& aOriginal )
+        * To be overridden by descendants
+        */
+        virtual CVCommand* CloneL() const; 
+
+    private:
+    	// Text to be recognized
+        HBufC* iSpokenText;
+        CVCRunnable* iRunnable;
+        CVCCommandUi* iCommandUi;
+        
+    };
+    
+/** Array of pointers to CVCommands */
+typedef RPointerArray<CVCommand> RVCommandArray;
+
+/**
+* Non-modifiable list of VCommands
+*/
+class CVCommandArray : public CBase
+	{
+	public:
+		/** 
+		* Constructs the non-modifiable CVCommandArray
+		* @param aSource Commands to store. CVCommandArray makes
+		*        copies of them
+		*/
+		IMPORT_C static CVCommandArray* NewL( const RVCommandArray& aSource );
+		
+		/**
+		* Destructor
+		*/
+		IMPORT_C ~CVCommandArray();
+		
+		/**
+		* Returns the reference to the command stored in this
+		* CVCommandArray
+		* @param aIndex Zero-based index of the command. If aIndex is out of
+		*               bounds, this method will panic with USER 130
+		* @return Unmodifiable reference to CVCommand
+		*/
+		IMPORT_C const CVCommand& At( TInt aIndex ) const;
+		
+		/**
+		* Equivalent to the operator At
+		* @see At()
+		*/
+		IMPORT_C const CVCommand& operator[]( TInt aIndex ) const;
+
+		/** 
+		* Returns the number of commands
+		*/
+		IMPORT_C TInt Count() const;
+		
+		/**
+		* For the compatibility with routines, requiring RVCommandArray
+		* @return Unmodifiable array of pointers to VCommands
+		*/
+		IMPORT_C const RVCommandArray& PointerArray() const;
+        
+        /**
+         * Figures out which commands have to untrained (removed from the system)
+         * if this command set is merged with aUpdates.
+         * Merging is performed on the basis of comapring the commands' Runnable component
+         * If runnables are equal, the commands are considered being equal.
+         * It is useful e.g. when figuring out what to (un)train after the language change
+         * 
+         * @param aUpdates Set of commands to merge in. 
+         * @return Set of commands to be removed from the system if the merging takes place
+         * @see ProduceTrainSetByRunnables
+         */
+        IMPORT_C CVCommandArray* ProduceUntrainSetByRunnablesLC( 
+                                    const RVCommandArray& aUpdates ) const;
+        
+        /**
+         * Figures out which commands have to trained (removed added to the system)
+         * if this command set is merged with aUpdates.
+         * Merging is performed on the basis of comapring the commands' Runnable component
+         * If runnables are equal, the commands are considered being equal.
+         * It is useful e.g. when figuring out what to (un)train after the language change
+         * 
+         * @param aUpdates Set of commands to merge in. 
+         * @return Set of commands to be added to the system if the merging takes place
+         * @see ProduceUntrainSetByRunnables
+         */
+        IMPORT_C CVCommandArray* ProduceTrainSetByRunnablesLC( 
+                                    const RVCommandArray& aUpdates ) const;
+		
+	private:
+		void ConstructL( const RVCommandArray& aSource );
+
+	private:
+		RVCommandArray iCommands;
+	};
+
+/**
+ * Allows the CVCommandHandler clients be notified about the vcommand set
+ * changes by another instances of the CVCommandHandler
+ */
+class MVCommandHandlerObserver 
+	{
+	public:
+		/**
+		* Is called whenever the VCommand set is changed
+    	* by *another* instance of CVCommandHandler. I.e. lets the client know if
+    	* his understanding of the VCommand set is up to date
+    	*/
+		virtual void CommandSetChanged() = 0;
+	};
+
+/**
+* Provider of the voice command services
+*/
+class CVCommandHandler : public CBase
+    {
+    public:
+    	/** 
+    	* Factory function
+    	* @param aObserver Listener to be notified whenever the VCommand set is changed
+    	* 		 by *another* instance of CVCommandHandler. I.e. lets the client know if
+    	* 		 his understanding of the VCommand set is up to date
+    	*/ 
+    	IMPORT_C static CVCommandHandler* NewL(  MVCommandHandlerObserver* aObserver = NULL );
+    	
+        IMPORT_C virtual ~CVCommandHandler();
+
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copy
+        * Duplicates can be added
+        * @todo should we check for duplicates and leave with KErrAlreadyExists?
+        */
+        IMPORT_C virtual void AddCommandL( const CVCommand& aCommand );
+        
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copies
+        * Duplicates can be added
+        * @todo should we check for duplicates and leave with KErrAlreadyExists?
+        * @param aCommands Commands to add
+        * @param aIgnoreErrors If ETrue, even if some commands fail to be trained,
+        *        handler adds all that are trainable
+        */
+        IMPORT_C virtual void AddCommandsL( const RVCommandArray& aCommands, 
+                                            TBool aIgnoreErrors = EFalse );
+        
+        /**
+        * Synchronous. Removes the command from the system
+        * @param aCommand Reference to the command to be removed. Existing commands are
+        *		 compared against aCommand. All the matches are removed from VAS
+        * @leave KErrNotFound No such command
+        */
+        IMPORT_C virtual void RemoveCommandL( const CVCommand& aCommand );
+
+        /**
+        * Synchronous. 
+        * @param aCommands Reference to the list of commands to be removed. Existing commands are
+        *		 compared against aCommands items. All the matches are removed from VAS
+        * @param aIgnoreErrors If ETrue, even if some commands fail to be removed,
+        *        handler will remove as many as possible
+        */
+        IMPORT_C virtual void RemoveCommandsL( const RVCommandArray& aCommands, 
+				      TBool aIgnoreErrors = EFalse );
+
+        
+        /**
+        * Synchronous
+        * @return an array of the commands in the system
+        *         Ownership of the array is transfered to the client
+        *         The returned CVCommandArray contains copies of all the 
+        *         commands currently stored in this handler
+        */
+        IMPORT_C virtual CVCommandArray* ListCommandsL();
+        
+        /**
+        * Not intented to be called directly.
+        * @see CVCommand::PlaySpokenTextL
+        */
+        virtual void PlaySpokenTextL( const CStoredVCommand& aCommand, 
+                                   MNssPlayEventHandler& aPlayEventHandler ) const;
+        
+        /**
+        * Not intented to be called directly.
+        * @see CVCommand::PlayAlternativeSpokenTextL
+        */                                   
+        virtual void PlayAlternativeSpokenTextL( const CStoredVCommand& aCommand, 
+                                   MNssPlayEventHandler& aPlayEventHandler ) const;
+                                   
+        /**
+        * Not intented to be called directly.
+        * @see CVCommand::CancelPlaybackL
+        */                                   
+        virtual void CancelPlaybackL( const CStoredVCommand& aCommand ) const;
+        
+    private:
+    	void ConstructL( MVCommandHandlerObserver* aObserver );
+    	// Implementation of the VCommand API
+    	MVCService* iImpl;
+    };
+    
+#endif // VCOMMANDAPI_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vas_vcommand_api/vas_vcommand_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="3fb9c731996e081e959f6d738559b03e" dataversion="2.0">
+  <name>VAS VCommand API</name>
+  <description>High level interface for adding, removing, playing, and reading voice tags for voice commands.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="vcommandhandler.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vcommand_settings_cenrep_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                VCommand settings CenRep API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/vcommanddomaincrkeys.h     APP_LAYER_PLATFORM_EXPORT_PATH(vcommanddomaincrkeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vcommand_settings_cenrep_api/inc/vcommanddomaincrkeys.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice Command Settings API CenRep definitions.
+*
+*/
+
+
+#ifndef VCOMMANDDOMAINCRKEYS_H
+#define VCOMMANDDOMAINCRKEYS_H
+
+// Voice Command settings API
+
+const TUid KCRUidVCommandSettings = {0x10207267};
+
+const TUint32 KVCSynthesizer       = 0x00000001;
+const TUint32 KVCVerification      = 0x00000002;
+const TUint32 KVuiDemoFirstTime    = 0x00000003;
+const TUint32 KVuiDemoMode         = 0x00000004;
+
+#endif // VCOMMANDDOMAINCRKEYS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vcommand_settings_cenrep_api/vcommand_settings_cenrep_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="3ab5b72c452b59a1c4db472e0a46b48b" dataversion="2.0">
+  <name>VCommand settings CenRep API</name>
+  <description>CenRep keys for storing VCommand settings</description>
+  <type>c++</type>
+  <collection>voiceui</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vocman_hw_device_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                VocMan HW Device API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/asrsvocmanhwdevice.h     APP_LAYER_PLATFORM_EXPORT_PATH(asrsvocmanhwdevice.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vocman_hw_device_api/inc/asrsvocmanhwdevice.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,187 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Vocabulary pruning functions for speech recognition
+*
+*/
+
+
+
+
+
+
+#ifndef ASRSVOCMANHWDEVICE_H
+#define ASRSVOCMANHWDEVICE_H
+
+//  INCLUDES
+#include <asrshwdevice.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+
+// FORWARD DECLARATIONS
+class CVocManAlgorithm;
+
+// CLASS DECLARATION
+
+/**
+*  Class for pruning
+*  When the grammar starts to get big, this class can prune
+*  least used rule variants away before adding new rules.
+*
+*  @lib AsrsVocmanHwDevice.dll
+*  @since ?Series60_version
+*/
+class CASRSVocManHwDevice : public CASRSHwDevice
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CASRSVocManHwDevice* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CASRSVocManHwDevice();
+
+    public: // Functions from base classes
+
+        /**
+        * From CASRHwDevice
+        * Gets a custom interface
+        * @since 2.8
+        * @param aInterfaceUid Uid of the interface.
+        * @return Pointer to the interface. Ownership depends on UID.
+        */
+        TAny* CustomInterface(TUid aInterfaceUid);
+
+        /**
+        * From CASRHwDevice
+        * Initializes the HW Device
+        * @since 2.8
+        * @return None
+        */
+        void InitializeL();
+
+        /**
+        * From CASRHwDevice
+        * Clear HW Device's allocated memory
+        * @since 2.8
+        * @return None
+        */
+        void Clear();
+
+    public: // New functions
+        
+        /**
+        * Use to adapt rule after recognition
+        * @since 2.6
+        * @param aCorrectRuleVariantID Correctly recognized rule variant
+		* @param aRule Rule including correct variant
+        */
+        IMPORT_C void AdaptL( const TSIRuleVariantID aCorrectRuleVariantID, 
+								    CSIRule& aRule );
+
+        /**
+        * Use to prune grammar.
+        * @since 2.6
+        * @param aGrammar Grammar to be pruned
+		* @param aMinNumber Minimum number of items to be pruned
+		* @param aPrunedItems Information which items can be removed
+		* @return ETrue pruning successful, EFalse cannot be pruned
+        */
+		IMPORT_C TBool Prune( const CSIGrammar& aGrammar, 
+							  TUint32 aMinNumber,
+							  RArray<TSIRuleVariantInfo>& aPrunedItems);
+
+        /**
+        * Use to determine number of new rule variants
+        * @since 2.6
+        * @param aGrammar Grammar where new variants should be added to
+		* @param aTargetNRuleVariants Target number of rule variants in the grammar
+		* @param aMaxNRuleVariants Maximum number of rule variants in the grammar
+		* @param aNewRuleScores Score for each new rule
+		* @param aNNRuleVariants Number of rule variants for each rule. 
+		*        Array must be initialized as maximum number of rule variants per a rule.
+		* @return None
+        */
+		IMPORT_C void ComputeNRuleVariantsL( const CSIGrammar& aGrammar, 
+											 const TUint32 aTargetNRuleVariants, 
+											 const TUint32 aMaxNRuleVariants, 
+											 const RArray<TUint>& aNewRuleScores, 
+											 RArray<TUint>& aNNewRuleVariants, 
+											 TUint32& aNPrune );
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CASRSVocManHwDevice();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CASRVocManHwDevice( const CASRVocManHwDevice& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CASRVocManHwDevice& operator=( const CASRVocManHwDevice& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        CVocManAlgorithm* iVMAlgorithm;
+         
+        // Reserved pointer for future extension
+        TAny* iReserved;
+
+    };
+
+#endif      // ASRSVOCMANHWDEVICE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/vocman_hw_device_api/vocman_hw_device_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="918950c5e10a287ed749a5fb80ad3dfd" dataversion="2.0">
+  <name>VocMan HW Device API</name>
+  <description>Interface for vocabulary management algorithm</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+    <lib name="asrsvocmanhwdevice.lib" />
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_commands_resource_header_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Voice Commands resource header API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/voicecommands.rh     APP_LAYER_PLATFORM_EXPORT_PATH(voicecommands.rh)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_commands_resource_header_api/inc/voicecommands.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource header of Voice Commands localization info
+*
+*/
+
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// VCOMMANDITEM
+// One Voice Command text item
+// -----------------------------------------------------------------------------
+//
+STRUCT VCOMMANDITEM
+    {
+    WORD key;
+    LTEXT txt; // variable length
+    }
+
+// -----------------------------------------------------------------------------
+// VCOMMANDS
+// Array of Voice Command text items
+// -----------------------------------------------------------------------------
+//
+STRUCT VCOMMANDS
+    {
+    STRUCT items[];
+    }
+
+// -----------------------------------------------------------------------------
+// VCOMMANDITEM
+// One Voice Command integer item
+// -----------------------------------------------------------------------------
+//
+STRUCT VCOMMANDINTEGERITEM
+    {
+    WORD key;
+    WORD value;
+    }
+
+// -----------------------------------------------------------------------------
+// VCOMMANDS
+// Array of Voice Command text items
+// -----------------------------------------------------------------------------
+//
+STRUCT VCOMMANDINTEGERS
+    {
+    STRUCT intitems[];
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_commands_resource_header_api/voice_commands_resource_header_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="bd2c11e373e9f124f7b3c6d57d6f5475" dataversion="2.0">
+  <name>Voice Commands resource header API</name>
+  <description>Defines a resource structure which client should use for localized strings if adding new voice command XMLs.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_accessory_button_handling_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Voice UI accessory button handling API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/voiceuidomainpskeys.h     APP_LAYER_PLATFORM_EXPORT_PATH(voiceuidomainpskeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_accessory_button_handling_api/inc/voiceuidomainpskeys.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice UI Accessory Monitor API
+*
+*/
+
+
+
+#ifndef VOICEUIDOMAINPSKEYS_H
+#define VOICEUIDOMAINPSKEYS_H
+
+// Voice UI Accessory Monitor API
+// VCommandmanager uses this API for notifying
+// Voice UI about certain Symbian Remote Control events.
+
+const TUid KPSUidVoiceUiAccMonitor = {0x101F8543};
+
+// Value: Accessory event id
+const TUint32 KVoiceUiAccessoryEvent = 0x00000001;
+
+const TInt KVoiceUiNoEvent = 0;
+const TInt KVoiceUiShortPressEvent = 1;
+const TInt KVoiceUiLongPressEvent = 2;
+
+const TUint32 KVoiceUiOpenKey = 0x00000002;
+
+const TInt KVoiceUiIsClose = 0;
+const TInt KVoiceUiIsOpen = 1;
+
+#endif // VOICEUIDOMAINPSKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_accessory_button_handling_api/voice_ui_accessory_button_handling_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="393cf43a5845e36306050bd8098a985d" dataversion="2.0">
+  <name>Voice UI accessory button handling API</name>
+  <description>P&amp;S keys for handling accessory button presses from Phone to VoiceUI</description>
+  <type>c++</type>
+  <collection>voiceui</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_plugin_api/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                Voice Ui Plug-in API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/nssvuipf.hrh     APP_LAYER_PLATFORM_EXPORT_PATH(nssvuipf.hrh)
+../inc/nssvoiceevent.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvoiceevent.h)
+../inc/nssvoiceuiplugin.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvoiceuiplugin.h)
+../inc/nssvoicestatus.h     APP_LAYER_PLATFORM_EXPORT_PATH(nssvoicestatus.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_plugin_api/inc/nssvoiceevent.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of voice event interfaces
+*
+*/
+
+
+#ifndef NSSVOICEEVENT_H
+#define NSSVOICEEVENT_H
+
+
+// CLASS DECLARATION
+
+/**
+*  MVoiceEventExecutor for notifies VoiceUI Plug-in Handler about voice event
+*
+*  @since 3.1
+*/
+class MVoiceEventExecutor
+    {
+  
+    public: 
+        
+        /**
+        * Notifies observer that a voice event needs to be handled.
+        * @since 3.1
+        * @param aEventUID UID of voice event
+        * @return One of the system wide error codes, KErrNone if successful.
+        */
+        virtual TInt VoiceEvent( TUid aEventUid ) = 0;
+    };
+
+/**
+*  MVoiceEventObserverPlugin determines VoiceUI Plug-in interface.
+*
+*  @since 3.1
+*/
+class CVoiceEventObserverPluginBase : public CBase
+    {
+  
+    public: 
+
+        /**
+        * Initializes a plug-in
+        * @since 3.1
+        * @param aEventHandler reference to a voice event handler.
+        * @return none
+        */
+        virtual void InitializeL( MVoiceEventExecutor& aEventHandler ) = 0;
+        
+    };
+
+#endif // NSSVOICEEVENT_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_plugin_api/inc/nssvoicestatus.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Status values for VUIPF
+*
+*/
+
+
+#ifndef NSSVOICESTATUS_H
+#define NSSVOICESTATUS_H
+
+// Status values which extend standard error values. They are used 
+// in execution and event plug-ins. 
+
+// Status used when an event was not used e.g. captured key can be forwarded
+const TInt KErrNoneEventNotConsumed = 1;
+
+// Status used when an event has been consumed and the a plug-in allows another
+// plug-in to handle the event also. Used in VUIP Handler and execution plug-ins.
+const TInt KErrNoneForwardEvent = 2;
+
+
+#endif // NSSVOICESTATUS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_plugin_api/inc/nssvoiceuiplugin.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Generic interface for VUI plug-in
+*
+*/
+
+
+#ifndef NSSVOICEUIPLUGIN_H
+#define NSSVOICEUIPLUGIN_H
+
+// TYPE DEFINITIONS
+
+enum TVuipPriority
+    {
+    EVuipPriorityExtraLow = 0,
+    EVuipPriorityLow = 25,
+    EVuipPriorityNormal = 50,
+    EVuipPriorityHigh = 75,
+    EVuipPriorityExtraHigh = 100
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  MVoiceUiPlugin defines an interface for VUI plug-ins
+*
+*  @since 3.1
+*/
+class CVoiceUiPluginBase : public CBase
+    {
+     
+    public:
+    
+        /**
+        * Returns a reference to the array of Uids of events, which are handled by the plug-in.
+        * @since 3.1
+        * @param None
+        * @return Event Uids
+        */
+        virtual RArray<TUid>& EventUids() = 0;
+
+        /**
+        * Runs a task of plug-in
+        * @since 3.1
+        * @param aEvent Event which has happened
+        * @return status of execution: standard error or VUIPF status values
+        * @see nssvoicestatus.h
+        */
+        virtual TInt Execute( TUid aEvent ) = 0;
+
+        /**
+        * Initializes a plug-in
+        * @since 3.1
+        * @param None
+        * @return None.
+        */
+        virtual void InitializeL() = 0;
+
+        /**
+        * Retirieves a current priority value
+        * @since 3.1
+        * @param None
+        * @return Priority value. 0 is idle, 100 is highest priority.
+        * @see TVuipPriority
+        */
+        inline virtual TVuipPriority Priority() = 0;
+
+    };
+
+#endif // NSSVOICEUIPLUGIN_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_plugin_api/inc/nssvuipf.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constants global to the VUIPF plugins
+*
+*/
+
+
+#ifndef NSSVUIPF_HRH
+#define NSSVUIPF_HRH
+
+// Interface UID for the events interface
+#define KVuipfEventInterfaceUid		0x10201AF8
+
+// Interface UID for the execution plugins interface
+#define KVuipfExecutionInterfaceUid	0x10201AF9
+
+enum TVuipfEventId
+        {
+        // 0xAACF0000 is just an arbitary value
+        // Uids 0x00000000- 0x0000FFFF should be used for testing purposes
+	    EVuipfEventVoiceKeyShortPress = 0xAACF0000,
+	    EVuipfEventVoiceKeyLongPress,
+	    EVuipfEventLSKLongPress
+        };
+
+
+#endif // NSSVUIPF_HRH   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/speechsrv_plat/voice_ui_plugin_api/voice_ui_plugin_api.metaxml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="26ee5bce4e913480609e35be8ef33766" dataversion="2.0">
+  <name>Voice Ui Plug-in API</name>
+  <description>Defines a voice event plug-in inferface, which clients can implement.</description>
+  <type>c++</type>
+  <collection>srsf</collection>
+  <libs>
+  </libs>
+  <release category="platform"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
Binary file srsf/cenrep/keys_srsf.xls has changed
Binary file srsf/conf/srsf.confml has changed
Binary file srsf/conf/srsf_10281c7d.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/bwins/nssdevasru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,35 @@
+EXPORTS
+	??1CDevASR@@UAE@XZ @ 1 NONAME ; CDevASR::~CDevASR(void)
+	?ActivateGrammarL@CDevASR@@QAEXG@Z @ 2 NONAME ; void CDevASR::ActivateGrammarL(unsigned short)
+	?AdaptL@CDevASR@@QAEXABVCSIResultSet@@H@Z @ 3 NONAME ; void CDevASR::AdaptL(class CSIResultSet const &, int)
+	?Cancel@CDevASR@@QAEXXZ @ 4 NONAME ; void CDevASR::Cancel(void)
+	?CompileGrammarL@CDevASR@@QAEXAAVCSICompiledGrammar@@@Z @ 5 NONAME ; void CDevASR::CompileGrammarL(class CSICompiledGrammar &)
+	?ComputeNewGrammarSizeL@CDevASR@@QAEXABVCSIGrammar@@KKABV?$RArray@I@@AAV3@AAK@Z @ 6 NONAME ; void CDevASR::ComputeNewGrammarSizeL(class CSIGrammar const &, unsigned long, unsigned long, class RArray<unsigned int> const &, class RArray<unsigned int> &, unsigned long &)
+	?CustomInterface@CDevASR@@QAEPAXVTUid@@@Z @ 7 NONAME ; void * CDevASR::CustomInterface(class TUid)
+	?DeactivateGrammarL@CDevASR@@QAEXG@Z @ 8 NONAME ; void CDevASR::DeactivateGrammarL(unsigned short)
+	?EndRecSession@CDevASR@@QAEXXZ @ 9 NONAME ; void CDevASR::EndRecSession(void)
+	?EndRecord@CDevASR@@QAEXXZ @ 10 NONAME ; void CDevASR::EndRecord(void)
+	?GetEnginePropertiesL@CDevASR@@QAEXABV?$RArray@H@@AAV2@@Z @ 11 NONAME ; void CDevASR::GetEnginePropertiesL(class RArray<int> const &, class RArray<int> &)
+	?GetUtteranceData@CDevASR@@QAEXPAVTDes8@@AAVTTimeIntervalMicroSeconds32@@@Z @ 12 NONAME ; void CDevASR::GetUtteranceData(class TDes8 *, class TTimeIntervalMicroSeconds32 &)
+	?InitFrontEnd@CDevASR@@QAEXW4TRecognizerMode@@@Z @ 13 NONAME ; void CDevASR::InitFrontEnd(enum TRecognizerMode)
+	?InitRecognizerBE@CDevASR@@QAEXAAVCSIResultSet@@@Z @ 14 NONAME ; void CDevASR::InitRecognizerBE(class CSIResultSet &)
+	?IsGrammarActive@CDevASR@@QAEHG@Z @ 15 NONAME ; int CDevASR::IsGrammarActive(unsigned short)
+	?IsGrammarLoaded@CDevASR@@QAEHG@Z @ 16 NONAME ; int CDevASR::IsGrammarLoaded(unsigned short)
+	?LoadEngineParametersL@CDevASR@@QAEXABV?$RArray@H@@0@Z @ 17 NONAME ; void CDevASR::LoadEngineParametersL(class RArray<int> const &, class RArray<int> const &)
+	?LoadGrammar@CDevASR@@QAEXABVCSICompiledGrammar@@@Z @ 18 NONAME ; void CDevASR::LoadGrammar(class CSICompiledGrammar const &)
+	?LoadGrammar@CDevASR@@QAEXABVCSIGrammar@@@Z @ 19 NONAME ; void CDevASR::LoadGrammar(class CSIGrammar const &)
+	?LoadLexicon@CDevASR@@QAEXABVCSILexicon@@@Z @ 20 NONAME ; void CDevASR::LoadLexicon(class CSILexicon const &)
+	?LoadModels@CDevASR@@QAEXABVCSIModelBank@@@Z @ 21 NONAME ; void CDevASR::LoadModels(class CSIModelBank const &)
+	?NewL@CDevASR@@SAPAV1@AAVMDevASRObserver@@@Z @ 22 NONAME ; class CDevASR * CDevASR::NewL(class MDevASRObserver &)
+	?NewLC@CDevASR@@SAPAV1@AAVMDevASRObserver@@@Z @ 23 NONAME ; class CDevASR * CDevASR::NewLC(class MDevASRObserver &)
+	?PruneGrammar@CDevASR@@QAEHABVCSIGrammar@@KAAV?$RArray@VTSIRuleVariantInfo@@@@@Z @ 24 NONAME ; int CDevASR::PruneGrammar(class CSIGrammar const &, unsigned long, class RArray<class TSIRuleVariantInfo> &)
+	?Record@CDevASR@@QAEXVTTimeIntervalMicroSeconds32@@@Z @ 25 NONAME ; void CDevASR::Record(class TTimeIntervalMicroSeconds32)
+	?SendSpeechData@CDevASR@@QAEXAAVTPtrC8@@H@Z @ 26 NONAME ; void CDevASR::SendSpeechData(class TPtrC8 &, int)
+	?SetPrioritySettings@CDevASR@@QAEXABVTMMFPrioritySettings@@@Z @ 27 NONAME ; void CDevASR::SetPrioritySettings(class TMMFPrioritySettings const &)
+	?StartRecSession@CDevASR@@QAEHW4TRecognizerMode@@@Z @ 28 NONAME ; int CDevASR::StartRecSession(enum TRecognizerMode)
+	?StartTrainingFromTextL@CDevASR@@QAEXAAVCSITtpWordList@@ABV?$RArray@W4TLanguage@@@@ABV?$RArray@K@@@Z @ 29 NONAME ; void CDevASR::StartTrainingFromTextL(class CSITtpWordList &, class RArray<enum TLanguage> const &, class RArray<unsigned long> const &)
+	?UnloadGrammar@CDevASR@@QAEXABVCSICompiledGrammar@@@Z @ 30 NONAME ; void CDevASR::UnloadGrammar(class CSICompiledGrammar const &)
+	?UnloadGrammar@CDevASR@@QAEXABVCSIGrammar@@@Z @ 31 NONAME ; void CDevASR::UnloadGrammar(class CSIGrammar const &)
+	?UnloadRule@CDevASR@@QAEXGK@Z @ 32 NONAME ; void CDevASR::UnloadRule(unsigned short, unsigned long)
+	?PreStartSamplingL@CDevASR@@QAEXXZ @ 33 NONAME ; void CDevASR::PreStartSamplingL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/eabi/nssdevasru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+EXPORTS
+	_ZN7CDevASR10LoadModelsERK12CSIModelBank @ 1 NONAME
+	_ZN7CDevASR10UnloadRuleEtm @ 2 NONAME
+	_ZN7CDevASR11LoadGrammarERK10CSIGrammar @ 3 NONAME
+	_ZN7CDevASR11LoadGrammarERK18CSICompiledGrammar @ 4 NONAME
+	_ZN7CDevASR11LoadLexiconERK10CSILexicon @ 5 NONAME
+	_ZN7CDevASR12InitFrontEndE15TRecognizerMode @ 6 NONAME
+	_ZN7CDevASR12PruneGrammarERK10CSIGrammarmR6RArrayI18TSIRuleVariantInfoE @ 7 NONAME
+	_ZN7CDevASR13EndRecSessionEv @ 8 NONAME
+	_ZN7CDevASR13UnloadGrammarERK10CSIGrammar @ 9 NONAME
+	_ZN7CDevASR13UnloadGrammarERK18CSICompiledGrammar @ 10 NONAME
+	_ZN7CDevASR14SendSpeechDataER6TPtrC8i @ 11 NONAME
+	_ZN7CDevASR15CompileGrammarLER18CSICompiledGrammar @ 12 NONAME
+	_ZN7CDevASR15CustomInterfaceE4TUid @ 13 NONAME
+	_ZN7CDevASR15IsGrammarActiveEt @ 14 NONAME
+	_ZN7CDevASR15IsGrammarLoadedEt @ 15 NONAME
+	_ZN7CDevASR15StartRecSessionE15TRecognizerMode @ 16 NONAME
+	_ZN7CDevASR16ActivateGrammarLEt @ 17 NONAME
+	_ZN7CDevASR16GetUtteranceDataEP5TDes8R27TTimeIntervalMicroSeconds32 @ 18 NONAME
+	_ZN7CDevASR16InitRecognizerBEER12CSIResultSet @ 19 NONAME
+	_ZN7CDevASR18DeactivateGrammarLEt @ 20 NONAME
+	_ZN7CDevASR19SetPrioritySettingsERK20TMMFPrioritySettings @ 21 NONAME
+	_ZN7CDevASR20GetEnginePropertiesLERK6RArrayIiERS1_ @ 22 NONAME
+	_ZN7CDevASR21LoadEngineParametersLERK6RArrayIiES3_ @ 23 NONAME
+	_ZN7CDevASR22ComputeNewGrammarSizeLERK10CSIGrammarmmRK6RArrayIjERS4_Rm @ 24 NONAME
+	_ZN7CDevASR22StartTrainingFromTextLER14CSITtpWordListRK6RArrayI9TLanguageERKS2_ImE @ 25 NONAME
+	_ZN7CDevASR4NewLER15MDevASRObserver @ 26 NONAME
+	_ZN7CDevASR5NewLCER15MDevASRObserver @ 27 NONAME
+	_ZN7CDevASR6AdaptLERK12CSIResultSeti @ 28 NONAME
+	_ZN7CDevASR6CancelEv @ 29 NONAME
+	_ZN7CDevASR6RecordE27TTimeIntervalMicroSeconds32 @ 30 NONAME
+	_ZN7CDevASR9EndRecordEv @ 31 NONAME
+	_ZN7CDevASRD0Ev @ 32 NONAME
+	_ZN7CDevASRD1Ev @ 33 NONAME
+	_ZN7CDevASRD2Ev @ 34 NONAME
+	_ZTI18CRecognitionAlgMgr @ 35 NONAME ; #<TI>#
+	_ZTI19CVMAlgorithmManager @ 36 NONAME ; #<TI>#
+	_ZTI20CSRSAlgorithmManager @ 37 NONAME ; #<TI>#
+	_ZTI22CDevASRResourceHandler @ 38 NONAME ; #<TI>#
+	_ZTI7CDevASR @ 39 NONAME ; #<TI>#
+	_ZTI8CQueItem @ 40 NONAME ; #<TI>#
+	_ZTV18CRecognitionAlgMgr @ 41 NONAME ; #<VT>#
+	_ZTV19CVMAlgorithmManager @ 42 NONAME ; #<VT>#
+	_ZTV20CSRSAlgorithmManager @ 43 NONAME ; #<VT>#
+	_ZTV22CDevASRResourceHandler @ 44 NONAME ; #<VT>#
+	_ZTV7CDevASR @ 45 NONAME ; #<VT>#
+	_ZTV8CQueItem @ 46 NONAME ; #<VT>#
+	_ZN7CDevASR17PreStartSamplingLEv @ 47 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for DevASR.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nssdevasr.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/group/nssdevasr.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project specification for DevASR API.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          nssdevasr.dll
+TARGETTYPE      DLL
+
+UID             0x1000008d 0x101FF937 // UID: 270530871
+
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src 
+
+SOURCE          devasr.cpp
+SOURCE          devasrsrsalgorithmmanager.cpp
+SOURCE          devasrvmalgorithmmanager.cpp
+SOURCE          devasrrecognitionalgmgr.cpp
+SOURCE          devasrutil.cpp
+SOURCE          devasrresourcehandler.cpp
+SOURCE          devasrcenrep.cpp
+
+START RESOURCE  nssdevasr.rss
+HEADER
+#include "data_caging_paths.hrh"
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/kernel
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/mmf/server
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+USERINCLUDE     ../src ../inc 
+USERINCLUDE     ../../rubydebug  
+USERINCLUDE     ../../inc
+USERINCLUDE     ../../group
+
+LIBRARY         efsrv.lib
+LIBRARY         euser.lib 
+LIBRARY         mmfdevsound.lib 
+LIBRARY         asrsgrcompilerhwdevice.lib
+LIBRARY         asrsadaptationhwdevice.lib
+LIBRARY         asrsvocmanhwdevice.lib
+LIBRARY         asrsrecognitionhwdevice.lib
+LIBRARY         asrsttphwdevice.lib
+LIBRARY         nsssispeechrecognitiondata.lib
+LIBRARY         bafl.lib
+LIBRARY         centralrepository.lib
+
+CAPABILITY      CAP_GENERAL_DLL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasr.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,474 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the implementation of DevASR.
+*
+*/
+
+
+// INCLUDE FILES
+#include <nssdevasr.h>
+#include "devasrsrsalgorithmmanager.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::CDevASR
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDevASR::CDevASR() : iSRSAlgorithmManager( NULL ),
+                     iReserved1( NULL ),
+                     iReserved2( NULL )
+    {
+    // Nothing
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDevASR::ConstructL( MDevASRObserver& aObserver )
+    {
+    iSRSAlgorithmManager = CSRSAlgorithmManager::NewL( aObserver );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDevASR* CDevASR::NewL( MDevASRObserver& aObserver )
+    {
+    CDevASR* self = NewLC( aObserver );
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDevASR* CDevASR::NewLC( MDevASRObserver& aObserver )
+    {
+    CDevASR* self = new ( ELeave ) CDevASR;
+    CleanupStack::PushL( self );
+    self->ConstructL( aObserver );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::~CDevASR
+// The destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDevASR::~CDevASR()
+    {
+    delete iSRSAlgorithmManager;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::ActivateGrammarL
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::ActivateGrammarL( TSIGrammarID aGrammarID )
+    {
+    iSRSAlgorithmManager->ActivateGrammarL( aGrammarID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::AdaptL
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::AdaptL( const CSIResultSet& aResultSet, TInt aResultIndex )
+    {
+    // Adaptation
+    iSRSAlgorithmManager->AdaptL( aResultSet, aResultIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::Cancel
+// Cancels the current and any on going requests/tasks. Forwards call to
+// CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::Cancel()
+    {
+    iSRSAlgorithmManager->Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::Cancel
+// Compiles SI grammar. Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::CompileGrammarL( CSICompiledGrammar& aGrammar/*, 
+                                        CSIModelBank& aModelBank*/ )
+    {
+    iSRSAlgorithmManager->CompileGrammarL( aGrammar/*, aModelBank*/ );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::ComputeNewGrammarSizeL
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::ComputeNewGrammarSizeL( const CSIGrammar& aGrammar, 
+                                               const TUint32 aTargetNRuleVariants, 
+                                               const TUint32 aMaxNRuleVariants, 
+                                               const RArray<TUint>& aNewRuleScores, 
+                                               RArray<TUint>& aNewRuleVariants, 
+                                               TUint32& aNPrune )
+    {
+    iSRSAlgorithmManager->ComputeNewGrammarSizeL( aGrammar, 
+                                                  aTargetNRuleVariants, 
+                                                  aMaxNRuleVariants, 
+                                                  aNewRuleScores, 
+                                                  aNewRuleVariants, 
+                                                  aNPrune );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::CustomInterface
+// Send a command to the implementation that the DevASR API doesn't currently
+// supports. Now returns NULL every time, no custom operations.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TAny* CDevASR::CustomInterface( TUid /*aCustomInterfaceId*/ )
+    {
+    return NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::DeactivateGrammarL
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::DeactivateGrammarL( TSIGrammarID aGrammarID )
+    {
+    iSRSAlgorithmManager->DeactivateGrammarL( aGrammarID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::EndRecord
+// Requests to end recording and a result will be resolved. Passes the function 
+// call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::EndRecord()
+    {
+    iSRSAlgorithmManager->StopRecognition();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::EndRecSession
+// Signal the end of a recognition session. Passes the function call to 
+// CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::EndRecSession()
+    {
+    iSRSAlgorithmManager->EndRecSession();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::GetEnginePropertiesL
+// Retreive the properties of the underlying speech recognition engine.
+// An array of values corresponding to the querried identifiers will be populated.
+// The function may leave with KErrArgument. Passes the function call to 
+// CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::GetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+                                             RArray<TInt>& aPropertyValue)
+    {
+    iSRSAlgorithmManager->GetEnginePropertiesL( aPropertyId, aPropertyValue );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::GetUtteranceData
+// Get the recorded audio data accumulated during training. Passes the function 
+// call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::GetUtteranceData( TDes8* aBuffer,
+                                         TTimeIntervalMicroSeconds32& aDuration )
+    {
+    iSRSAlgorithmManager->GetUtteranceData( aBuffer, aDuration );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::InitFrontEnd
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::InitFrontEnd( TRecognizerMode aMode )
+    {
+    iSRSAlgorithmManager->InitFrontEnd( aMode );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::InitRecognizerBE
+// Initializes the recognition back-end. The module responsible for recognition
+// function is started as a result. Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::InitRecognizerBE( CSIResultSet& aResult )
+    {
+    iSRSAlgorithmManager->InitRecognizerBE( aResult );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::LoadEngineParametersL
+// Load the specified recognizer parameter(s).
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::LoadEngineParametersL( const RArray<TInt>& aParameterId,
+                                              const RArray<TInt>& aParameterValue )
+    {
+    iSRSAlgorithmManager->LoadEnginePropertiesL( aParameterId, aParameterValue );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::LoadGrammar
+// Load the specified SI grammar into the recognizer.
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::LoadGrammar( const CSIGrammar& aGrammar )
+    {
+    TRAPD( error, iSRSAlgorithmManager->LoadGrammarL( aGrammar ) );
+    // No way to process or send the error upwards.
+    error = error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::LoadGrammar
+// Load the specified compiled SI grammar into the recognizer.
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::LoadGrammar( const CSICompiledGrammar& aGrammar )
+    {	
+    TRAPD( error, iSRSAlgorithmManager->LoadGrammarL( aGrammar ) );
+    // No way to process or send the error upwards.
+    error = error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::UnloadGrammar
+// Unloads the specified SI grammar from the recognizer.
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::UnloadGrammar( const CSIGrammar& aGrammar )
+    {
+    TRAPD( error, iSRSAlgorithmManager->UnloadGrammarL( aGrammar ) );
+    // No way to process or send the error upwards.
+    error = error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::LoadGrammar
+// Unloads the specified compiled SI grammar from the recognizer.
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::UnloadGrammar( const CSICompiledGrammar& aGrammar )
+    {	
+    TRAPD( error, iSRSAlgorithmManager->UnloadGrammarL( aGrammar ) );
+    // No way to process or send the error upwards.
+    error = error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::LoadLexicon
+// Load the specified SI lexicion into the recognizer.
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::LoadLexicon( const CSILexicon& aLexicon )
+    {
+    TRAPD( error, iSRSAlgorithmManager->LoadLexiconL( aLexicon ) );
+    // No way to process or send the error upwards.
+    error = error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::LoadModels
+// Load the specified SI models into the recognizer.
+// Forwards call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::LoadModels( const CSIModelBank& aModels )
+    {
+    TRAPD( error, iSRSAlgorithmManager->LoadModelsL( aModels ) );
+    // No way to process or send the error upwards.
+    error = error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::PruneGrammar
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDevASR::PruneGrammar( const CSIGrammar& aGrammar, 
+                                      const TUint32 aMinNumber, 
+                                      RArray<TSIRuleVariantInfo>& aPrunedRuleVariants )
+    {
+    return iSRSAlgorithmManager->PruneGrammar( aGrammar, 
+                                               aMinNumber, 
+                                               aPrunedRuleVariants );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::Record
+// Request to begin recording. Passes the function call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::Record( TTimeIntervalMicroSeconds32 aRecordDuration )
+    {
+    iSRSAlgorithmManager->StartRecognition( aRecordDuration );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::PreStartSamplingL
+// Begins sampling before Record() call
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::PreStartSamplingL()
+    {
+    iSRSAlgorithmManager->PreStartSamplingL();
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CDevASR::SendSpeechData
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::SendSpeechData( TPtrC8& aBuffer, TBool aEnd )
+    {
+    iSRSAlgorithmManager->SendSpeechData( aBuffer, aEnd );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::SetPrioritySettings
+// Set the priority of the sound device
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings )
+    {
+    iSRSAlgorithmManager->SetPrioritySettings( aPrioritySettings );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::StartRecSession
+// Signal the start of a recognition session.
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDevASR::StartRecSession( TRecognizerMode aMode )
+    {
+    return iSRSAlgorithmManager->StartRecSession( aMode );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::StartTrainFromText
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::StartTrainingFromTextL( CSITtpWordList& aWordList, 
+                                               const RArray<TLanguage>& aDefaultLanguage, 
+                                               const RArray<TUint32>& aMaxNPronunsForWord )
+
+    {
+    iSRSAlgorithmManager->StartTrainingFromTextL( aWordList, aDefaultLanguage, 
+                                                  aMaxNPronunsForWord );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::UnloadRule
+// Unload the specified rule from the grammar.
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevASR::UnloadRule( TSIGrammarID aGrammarID,
+                                   TSIRuleID aRuleID )
+    {
+    iSRSAlgorithmManager->UnloadRule( aGrammarID, aRuleID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::IsGrammarLoaded
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDevASR::IsGrammarLoaded( TSIGrammarID aGrammarID )
+    {
+    return iSRSAlgorithmManager->IsGrammarLoaded( aGrammarID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevASR::IsGrammarActive
+// Passes the function call to CSRSAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDevASR::IsGrammarActive( TSIGrammarID aGrammarID )
+    {
+    return iSRSAlgorithmManager->IsGrammarActive( aGrammarID );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrcenrep.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CenRep handling for DevASR
+*
+*/
+
+
+// INCLUDE FILES
+#include "devasrcenrep.h"
+#include "rubydebug.h"
+#include "srsfinternalcrkeys.h"
+
+// CONSTANTS
+
+// Maximum value of the rejection setting in Central Repository
+const TInt KMaxRepositoryRejection = 10;
+
+// Maximum value of the rejection setting in the engine
+const TInt KMaxEngineRejection = 1024;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDevAsrCenRep::CDevAsrCenRep
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDevAsrCenRep::CDevAsrCenRep() 
+    {
+    // Nothing
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevAsrCenRep::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDevAsrCenRep::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+	iRepository = CRepository::NewL( KCRUidSRSFSettings );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevAsrCenRep::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDevAsrCenRep* CDevAsrCenRep::NewL()
+    {
+    CDevAsrCenRep* self = new( ELeave ) CDevAsrCenRep();
+ 
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevAsrCenRep::~CDevAsrCenRep
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDevAsrCenRep::~CDevAsrCenRep()
+    {
+    delete iRepository;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevAsrCenRep::RejectionValue
+// Returns the rejection setting from CenRep
+// -----------------------------------------------------------------------------
+//
+TInt CDevAsrCenRep::RejectionValue() 
+    {
+    RUBY_DEBUG0( "" );
+    TInt rejection( KMaxEngineRejection );
+    // Get from CenRep
+    TInt error = iRepository->Get( KSRSFRejection, rejection );
+    if ( error == KErrNone )
+        {
+        RUBY_DEBUG1( "Rejection repository value:[%d]", rejection );
+        // Scale value
+        rejection = ( rejection * KMaxEngineRejection ) / KMaxRepositoryRejection;
+        RUBY_DEBUG1( "Scaled rejection value:[%d]", rejection );
+        }
+    return rejection;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrcenrep.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CenRep handling for DevASR
+*
+*/
+
+
+#ifndef DEVASRCENREP_H
+#define DEVASRCENREP_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <centralrepository.h>
+
+// CLASS DECLARATION
+
+/**
+* Playback volume CenRep handler for DevAsr
+*/
+NONSHARABLE_CLASS( CDevAsrCenRep ) : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDevAsrCenRep* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDevAsrCenRep();
+        
+    public: // New functions
+
+        /**
+        * Returns the current rejection setting from CenRep.
+        * If nothing is found (or error occurs), maximum volume will be returned.
+        * Volume setting is scaled to 0..aMaxVolume
+        *
+        * @param "TInt aMaxVolume" Maximum volume
+        * @return Volume setting read from CenRep
+        */    
+        TInt RejectionValue();
+
+    public: // Functions from base classes
+       
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CDevAsrCenRep();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor
+        CDevAsrCenRep( const CDevAsrCenRep& );
+        // Prohibit assigment operator
+        CDevAsrCenRep& operator=( const CDevAsrCenRep& );
+        
+    private: // Data
+
+        // Central Repository
+        CRepository* iRepository;
+
+    };
+    
+#endif // DEVASRCENREP_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrrecognitionalgmgr.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1571 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains the implementation of Recognition Algorithm
+*               Manager, a submodule of DevASR.
+*
+*/
+
+
+// INCLUDE FILES
+#ifdef _DEBUG
+#include <e32svr.h>
+#endif
+#include "devasrrecognitionalgmgr.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+const TInt KInitFrontEnd        = 1;
+//const TInt KInitTrainBE         = 2;
+const TInt KInitRecognizerBE    = 3;
+const TInt KLoadGrammar         = 4;
+const TInt KLoadLexicon         = 5;
+const TInt KLoadModels          = 6;
+//const TInt KUtteranceDataRcvd   = 7;
+const TInt KActivateGrammar     = 8;
+const TInt KDeActivateGrammar   = 9;
+const TInt KUnloadRule          = 10;
+const TInt KUnloadGrammar       = 11;
+
+//_LIT( KPanicDescriptor, "CRecognitionAlgMgr Panic" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::CRecognitionAlgMgr
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRecognitionAlgMgr::CRecognitionAlgMgr( MRecAlgMgrObserver& aObserver )
+                    : CActive( CActive::EPriorityStandard ),
+                      iRecAlgMgrObserver( &aObserver ),
+                      iCombinedGrammar( NULL ),
+                      iCombineNeeded( ETrue ),
+                      iInitialized( EFalse ),
+                      iRecoHw( NULL ),
+                      iAdaptHw( NULL ),
+                      iSDModelBank( NULL ),
+                      iSIModelBank( NULL ),
+                      iSDGrammar( NULL ),
+                      iSIGrammar( NULL ),
+                      iSICompGrammar( NULL ),
+                      iSDCompGrammar( NULL ),
+                      iSDLexicon( NULL ),
+                      iSILexicon( NULL ),
+                      iFEState( EIdle ),
+                      iBEState( EIdle ),
+                      iFeatures( EFalse ),
+                      iAdaptation( ETrue ),
+                      iAdaptationData( NULL )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::CRecognitionAlgMgr()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::ConstructL()" );
+
+    iRecoHw = CASRSRecognitionHwDevice::NewL( *this );
+    iRecoHw->InitializeL();
+
+    iAdaptHw = CASRSAdaptHwDevice::NewL( *this );
+    iAdaptHw->InitializeL();
+
+    CActiveScheduler::Add(this);
+    
+    RUBY_DEBUG1( "CRecognitionAlgMgr::ConstructL(): RecoHwDevice instance [%x]", iRecoHw );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRecognitionAlgMgr* CRecognitionAlgMgr::NewL( MRecAlgMgrObserver& aObserver )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::ConstructL()" );
+    
+    CRecognitionAlgMgr* self = new ( ELeave ) CRecognitionAlgMgr( aObserver );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::~CRecognitionAlgMgr
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CRecognitionAlgMgr::~CRecognitionAlgMgr()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::~CRecognitionAlgMgr()" );
+    
+    iSIActiveGrammars.Reset();
+    iSIDeActivatedGrammars.Reset();
+    iNBestList.Reset();
+    iScores.Reset();
+
+    if ( iRecoHw != NULL )
+        {
+        iRecoHw->Clear();
+        delete iRecoHw;
+        }
+
+    if ( iAdaptHw != NULL )
+        {
+        iAdaptHw->Clear();
+        delete iAdaptHw;
+        }
+
+    delete iCombinedGrammar;
+
+    iBlackList.ResetAndDestroy();
+    iBlackList.Close();
+
+    delete iAdaptationData;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::AdaptModelsL
+// Adapts models.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::AdaptModelsL( const CSIResultSet& aResultSet, 
+                                       TInt aResultIndex,
+                                       TLanguage aLanguage )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::AdaptModelsL()" );
+
+    RUBY_DEBUG1( "CRecognitionAlgMgr::AdaptModelsL aResultIndex: %x", aResultIndex );
+
+    // TODO: Not too nice to remove consts like this
+    CSIResult& iCorrectResult = ( CSIResult& ) aResultSet.AtL( aResultIndex );
+
+    // Check that we have a modelbank to adapt
+    if ( iSIModelBank == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    CSIResultSet& iResultSet = ( CSIResultSet& ) aResultSet;
+    iAdaptHw->StartAdaptationL( iResultSet.AdaptationData(), 
+                                *iSIModelBank, 
+                                iCorrectResult.Pronunciation(),
+                                aLanguage );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::InitFrontEnd
+// Receives the initialize frontend request and starts an asynchronous handler
+// for the request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::InitFrontEnd( TRecognizerMode aMode )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::InitFrontEnd()" );
+
+    // Save arguments and set code
+    iMode = aMode;
+    iRequestFunction = KInitFrontEnd;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleInitFrontEnd
+// Asynchronously handles the initialize frontend request. The front-end module
+// is started as a result.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleInitFrontEnd()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleInitFrontEnd()" );
+    
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->InitFEComplete( KErrNotReady );
+        return;
+        }
+
+    if ( iFEState != EIdle )
+        {
+        iRecAlgMgrObserver->InitFEComplete( KErrInUse );
+        return;
+        }
+    
+    if ( iMode != ESiRecognition && iMode != ESiRecognitionSpeechInput )
+        {
+        iRecAlgMgrObserver->InitFEComplete( KErrNotSupported );
+        return;
+        }
+
+    TInt error = KErrNone;
+
+    if ( iFeatures || iAdaptation )
+        {
+        TRAP( error, iRecoHw->InitRecognizerFEL( ETrue ) );
+        }
+    else
+        {
+        TRAP( error, iRecoHw->InitRecognizerFEL( EFalse ) );
+        }
+
+    iRecAlgMgrObserver->InitFEComplete( error );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::InitRecognizerBE
+// Receives the initialize recognition backend request and starts an asynchronous
+// handler for the request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::InitRecognizerBE( CSIResultSet& aResult )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::InitRecognizerBE()" );
+    
+    // Save arguments and set code
+    iSDResult = NULL;
+    iSIResult = &aResult;
+    iRequestFunction = KInitRecognizerBE;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleInitRecognizerBE
+// Asynchronously handles the initialize recognition backend request. The backend
+// module for recognition function is started as a result.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleInitRecognizerBE()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleInitRecognizerBE()" );
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->InitRecognizerBEComplete( KErrNotReady );
+        return;
+        }
+
+    if ( iBEState != EIdle )
+        {
+        iRecAlgMgrObserver->InitRecognizerBEComplete( KErrInUse );
+        return;
+        }
+    TInt error( KErrNone );
+    if ( iSDResult )
+        {
+        iRecAlgMgrObserver->InitRecognizerBEComplete( KErrNotSupported );
+        return;
+        }
+    else if ( iSIResult )
+        {
+        // Call RecoHwDevice
+        if ( ( iSIActiveGrammars.Count() == 0 )  || ( iSIModelBank == NULL ) )
+            {
+            // Guess it is ok to leave with KErrNotReady if all necessary 
+            iRecAlgMgrObserver->InitRecognizerBEComplete( KErrNotReady );
+            return;
+            }
+        else
+            {
+            if ( iCombineNeeded )
+                {
+                delete iCombinedGrammar;
+                iCombinedGrammar = NULL;
+
+                TRAPD( error, iRecAlgMgrObserver->CombineGrammarL( iSIActiveGrammars, iBlackList ) );  
+                if ( error != KErrNone )
+                    {
+                    iRecAlgMgrObserver->InitRecognizerBEComplete( error );
+                    }
+                // Wait for the callback from grammar compilation!
+                return;
+                }
+            // Call reco HW device
+            TRAP( error, iRecoHw->InitRecognizerBEL( iCombinedGrammar->Des(), *iSIModelBank ) );
+            if ( error != KErrNone )
+                {
+                iRecAlgMgrObserver->InitRecognizerBEComplete( error );
+                }
+            }
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    
+    if ( error == KErrNone )
+        {
+        iBEState = EProcessing;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::LoadGrammarL
+// Receives the load grammar request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::LoadGrammarL( const CSIGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::LoadGrammarL()" );
+
+    if ( IsActive() )
+        {
+        // Callback before the request function returns
+        User::Leave( KErrServerBusy );
+        return;
+        }
+    
+    // Save arguments and set code
+    iSIGrammar = &aGrammar;
+    iRequestFunction = KLoadGrammar;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::LoadGrammarL
+// Receives the load grammar request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::LoadGrammarL( const CSICompiledGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::LoadGrammarL()" );
+    
+    if ( IsActive() )
+        {
+        // Callback before the request function returns
+        User::Leave( KErrServerBusy );
+        return;
+        }
+    
+    // Save arguments and set code
+    iSICompGrammar = &aGrammar; 
+/*    __ASSERT_DEBUG( iSDGrammar == NULL, User::Panic( KPanicDescriptor, KErrCorrupt ) );
+    __ASSERT_DEBUG( iSIGrammar == NULL, User::Panic( KPanicDescriptor, KErrCorrupt ) );*/
+    iRequestFunction = KLoadGrammar;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleLoadGrammar
+// Asynchronous handler for Load Grammar request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleLoadGrammar()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleLoadGrammar()" );
+
+    TInt error( KErrNone );
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->LoadGrammarComplete( KErrNotReady );
+        return;
+        }
+
+    if ( iSICompGrammar )
+        {
+
+        if ( iSICompGrammar->Count() < 1 )
+            {
+            iRecAlgMgrObserver->LoadGrammarComplete( KErrArgument );
+            return;
+            }
+
+        error = iSIActiveGrammars.Append( iSICompGrammar );
+
+        iSICompGrammar = NULL;
+
+        // Mark that there is need to recombine grammars
+        iCombineNeeded = ETrue;
+
+        iRecAlgMgrObserver->LoadGrammarComplete( error );
+ 
+        }
+    else
+        {
+        iRecAlgMgrObserver->LoadGrammarComplete( KErrNotSupported );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::UnloadGrammarL
+// Receives the unload grammar request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::UnloadGrammarL( const CSIGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::UnloadGrammarL()" );
+
+    if ( IsActive() )
+        {
+        // Callback before the request function returns
+        User::Leave( KErrServerBusy );
+        return;
+        }
+    
+    // Save arguments and set code
+    iSIGrammar = &aGrammar;
+    iRequestFunction = KUnloadGrammar;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::UnloadGrammarL
+// Receives the unload grammar request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::UnloadGrammarL( const CSICompiledGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::UnloadGrammarL()" );
+    
+    if ( IsActive() )
+        {
+        // Callback before the request function returns
+        User::Leave( KErrServerBusy );
+        return;
+        }
+    
+    // Save arguments and set code
+    iSICompGrammar = &aGrammar; 
+    iRequestFunction = KUnloadGrammar;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleUnloadGrammar
+// Asynchronous handler for Load Grammar request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleUnloadGrammar()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleUnloadGrammar()" );
+
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->UnloadGrammarComplete( KErrNotReady );
+        return;
+        }
+
+    if ( iSICompGrammar )
+        {
+        
+        TRAPD( error, GetGrammarL( iSICompGrammar->GrammarID(), &siActiveGrammar, &siNonActiveGrammar ) ); // Leaves if not found
+        if ( error != KErrNone )
+            {
+            iRecAlgMgrObserver->UnloadGrammarComplete( error ); 
+            return;
+            }
+        
+        if ( siActiveGrammar )
+            {
+            // Remove grammar from active grammars
+            iSIActiveGrammars.Remove( iSIActiveGrammars.Find( siActiveGrammar ) );
+            // Mark that there is need to recombine grammars
+            iCombineNeeded = ETrue;
+            }
+        else if ( siNonActiveGrammar )
+            {
+            // Remove grammar from deactive
+            iSIActiveGrammars.Remove( iSIActiveGrammars.Find( siActiveGrammar ) );
+            // No need to set recombination flag
+            }
+        else
+            {
+            iRecAlgMgrObserver->UnloadGrammarComplete( KErrNotFound ); 
+            return;
+            }
+        }
+    else
+        {
+        iRecAlgMgrObserver->UnloadGrammarComplete( KErrNotSupported );
+        return;
+        }
+
+    iRecAlgMgrObserver->UnloadGrammarComplete( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::GetGrammarL
+// Find grammar based on identifier
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::GetGrammarL( const TSIGrammarID aGrammarID, 
+                                      CSICompiledGrammar** aSIActiveGrammar,
+                                      CSICompiledGrammar** aSIDeActivatedGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::GetGrammarL()" );
+
+    // Find the grammar.
+    // One of the arrays should contain the specified grammar and
+    // others are empty.
+    TInt i( 0 );
+    
+    // SI active grammars.
+    for ( i = 0; i < iSIActiveGrammars.Count(); i++ )
+        {
+        if ( aGrammarID == iSIActiveGrammars[i]->GrammarID() )
+            {
+            // Grammar found.
+            *aSIActiveGrammar = iSIActiveGrammars[i];
+            *aSIDeActivatedGrammar = NULL;
+            return;
+            }
+        }
+    
+    // SI deactived grammars.
+    for ( i = 0; i < iSIDeActivatedGrammars.Count(); i++ )
+        {
+        if ( aGrammarID == iSIDeActivatedGrammars[i]->GrammarID() )
+            {
+            // Grammar found.
+            *aSIDeActivatedGrammar = iSIDeActivatedGrammars[i];
+            *aSIActiveGrammar = NULL;
+            return;
+            }
+        }
+
+    User::Leave( KErrNotFound );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::ActivateGrammarL
+// Receives the load grammar request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::ActivateGrammarL( const TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::ActivateGrammarL()" );
+
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    
+    iRequestFunction = KActivateGrammar;
+    iGrammarID = aGrammarID;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleActivateGrammar
+// Asynchronous handler for activate grammar request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleActivateGrammar()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleActivateGrammar()" );
+
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->ActivateGrammarComplete( KErrNotReady );
+        }
+
+    // Find the grammar
+    TRAPD( error, GetGrammarL( iGrammarID, &siActiveGrammar, &siNonActiveGrammar ) ); // Leaves if not found
+    if ( error != KErrNone )
+        {
+        iRecAlgMgrObserver->ActivateGrammarComplete( error ); 
+        }
+
+    if ( siActiveGrammar )
+        {
+        // Do nothing since grammar is already active
+        }
+    else if ( siNonActiveGrammar )
+        {
+        // Move item from non-active grammar list to active list
+        iSIActiveGrammars.Append( siNonActiveGrammar );
+        iSIDeActivatedGrammars.Remove( iSIDeActivatedGrammars.Find( siNonActiveGrammar ) );
+        // Mark that there is need to recombine grammars
+        iCombineNeeded = ETrue;
+        }
+    else
+        {
+        iRecAlgMgrObserver->ActivateGrammarComplete( KErrNotFound );
+        return;
+        }
+
+    iRecAlgMgrObserver->ActivateGrammarComplete( KErrNone ); 
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::DeactivateGrammarL
+// Receives the load grammar request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::DeactivateGrammarL( const TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::DeactivateGrammarL()" );
+
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    
+    iRequestFunction = KDeActivateGrammar;
+    iGrammarID = aGrammarID;
+    Ready( KErrNone );    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleDeActivateGrammar
+// Asynchronous handler for deactivate grammar request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleDeActivateGrammar()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleDeActivateGrammar()" );
+
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->DeActivateGrammarComplete( KErrNotReady );
+        }
+
+    // Find the grammar
+    TRAPD( error, GetGrammarL( iGrammarID, &siActiveGrammar, &siNonActiveGrammar ) ); // Leaves if not found
+    if ( error != KErrNone )
+        {
+        iRecAlgMgrObserver->DeActivateGrammarComplete( error ); 
+        }
+
+    if ( siActiveGrammar )
+        {
+        // Move item from active grammar list to non-active list
+        iSIDeActivatedGrammars.Append( siActiveGrammar );
+        iSIActiveGrammars.Remove( iSIActiveGrammars.Find( siActiveGrammar ) );
+        // Mark that there is need to recombine grammars
+        iCombineNeeded = ETrue;
+        }
+    else if ( siNonActiveGrammar )
+        {
+        // Do nothing since grammar is already inactive
+        }
+    else
+        {
+        iRecAlgMgrObserver->DeActivateGrammarComplete( KErrNotFound ); 
+        return;
+        }
+
+    iRecAlgMgrObserver->DeActivateGrammarComplete( KErrNone ); 
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::LoadLexiconL
+// Receives the load lexicon request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::LoadLexiconL( const CSILexicon& aLexicon )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::LoadLexiconL()" );
+    
+    // Save arguments and set code
+    if ( IsActive() )
+        {
+        // Callback before the request function returns
+        User::Leave( KErrServerBusy );
+        return;
+        }
+    
+    iSILexicon = &aLexicon;
+    
+    iRequestFunction = KLoadLexicon;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleLoadLexicon
+// Asynchronous handler for Load Lexicon request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleLoadLexicon()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleLoadLexicon()" );
+
+    TInt error( KErrNone );
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->LoadLexiconComplete( KErrNotReady );
+        return;
+        }
+
+    if ( iSDLexicon )
+        {
+        iSDLexicon = NULL;
+        iRecAlgMgrObserver->LoadLexiconComplete( KErrNotSupported );
+        return;
+        }
+    else if ( iSILexicon )
+        {
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    
+    // Do not load empty lexicon
+    if ( iSILexicon && iSILexicon->Count() == 0 )
+        {
+        iSILexicon = NULL;
+        iRecAlgMgrObserver->LoadLexiconComplete( KErrArgument );
+        return;
+        }
+
+/*    __ASSERT_DEBUG( iSDLexicon == NULL, User::Panic( KPanicDescriptor, KErrCorrupt ) );
+    __ASSERT_DEBUG( iSILexicon == NULL, User::Panic( KPanicDescriptor, KErrCorrupt ) );*/
+    
+    iRecAlgMgrObserver->LoadLexiconComplete( error );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::LoadModelsL
+// Receives the load models request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::LoadModelsL( const CSDModelBank& aModels )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::LoadModelsL()" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        return;
+        }
+
+    // Save arguments and set code
+    iSDModelBank = ( CSDModelBank* ) &aModels;
+    iRequestFunction = KLoadModels;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::LoadModelsL
+// Receives the load models request and start the asynchronous handler.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::LoadModelsL( const CSIModelBank& aModels )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::LoadModelsL()" );
+
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+
+    // Save arguments and set code
+    iSIModelBank = ( CSIModelBank* ) &aModels;
+    iRequestFunction = KLoadModels;
+    Ready( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleLoadModels
+// Asynchronous handler for Load Models request.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleLoadModels()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleLoadModels()" );
+
+    TInt error( KErrNone );
+
+    if ( !iInitialized )
+        {
+        iSDModelBank = NULL;
+        iSIModelBank = NULL;
+        iRecAlgMgrObserver->LoadModelsComplete( KErrNotReady );
+        return;
+        }
+
+    if ( iSDModelBank )
+        {
+        // SD modelbank not supported
+        iSDModelBank = NULL;
+        iRecAlgMgrObserver->LoadModelsComplete( KErrNotSupported );
+        return;
+        }
+    else if ( iSIModelBank )
+        {
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+
+    if ( iSIModelBank && iSIModelBank->Count() < 1 )
+        {
+        iSIModelBank = NULL;
+        iRecAlgMgrObserver->LoadModelsComplete( KErrArgument );
+        return;
+        }
+
+/*    __ASSERT_DEBUG( iSDModelBank == NULL, User::Panic( KPanicDescriptor, KErrCorrupt ) );
+    __ASSERT_DEBUG( iSIModelBank == NULL, User::Panic( KPanicDescriptor, KErrCorrupt ) );*/
+    
+    iRecAlgMgrObserver->LoadModelsComplete( error );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::GetEnginePropertiesL
+// Retreive the properties of the underlying speech recognition engine.
+// An array of values corresponding to the querried identifiers will be populated.
+// The function may leave with KErrArgument.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::GetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+                                              RArray<TInt>& aPropertyValue )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::GetEnginePropertiesL()" );
+    
+    for ( TInt index = 0; index < aPropertyId.Count(); index++ )
+        {
+        switch( aPropertyId[index] )
+            {
+            case KDevASRSendFeatures:
+                if ( iFeatures )
+                    {
+                    aPropertyValue[index] = 1;
+                    }
+                else
+                    {
+                    aPropertyValue[index] = 0;
+                    }
+                break;
+                
+            case KDevASRAdaptation:
+                if ( iAdaptation )
+                    {
+                    aPropertyValue[index] = 1;
+                    }
+                else
+                    {
+                    aPropertyValue[index] = 0;
+                    }
+                break;
+                
+            default:
+                break;
+                
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::LoadEnginePropertiesL
+// Loads properties to engine, invalid IDs are neglected.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::LoadEnginePropertiesL( const RArray<TInt>& aParameterId,
+                                               const RArray<TInt>& aParameterValue )
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::LoadEnginePropertiesL()" );
+    
+    for ( TInt index = 0; index < aParameterId.Count(); index++ )
+        {
+        switch( aParameterId[index] )
+            {
+            case KDevASRSendFeatures:
+                if ( aParameterValue[index] == 0 )
+                    {
+                    iFeatures = EFalse;
+                    }
+                else
+                    {
+                    iFeatures = ETrue;
+                    }
+                break;
+                
+            case KDevASRAdaptation:
+                if ( aParameterValue[index] == 0 )
+                    {
+                    iAdaptation = EFalse;
+                    }
+                else
+                    {
+                    iAdaptation = ETrue;
+                    }
+                break;
+                
+            default:
+                break;
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::SendSpeechData
+// Sends utterance data to recognizer.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::SendSpeechData( TPtrC8& aBuffer, TBool aEnd )
+    {
+    iRecoHw->SendSpeechData( aBuffer, aEnd );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::StartRecSession
+// Signal the start of a recognition sesion.
+// -----------------------------------------------------------------------------
+//
+TInt CRecognitionAlgMgr::StartRecSession( TRecognizerMode aMode )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::StartRecSession()" );
+
+    TInt error( KErrNone );
+
+    if ( !iInitialized )
+        {
+        return KErrNotReady; 
+        }
+
+    if ( aMode == ESiRecognition )
+        {
+        iMode = aMode;
+        }
+    else if ( aMode == ESiRecognitionSpeechInput )
+        {
+        iMode = aMode;
+        }
+    else
+        {
+        return KErrNotSupported;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::StartRecognitionL
+// Start recognition.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::StartRecognitionL()
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::StartRecognitionL()" );
+
+    if ( !iInitialized )
+        {
+        return;
+        }
+
+    // Reset the result IDs
+    iNBestList.Reset();
+    iScores.Reset();
+
+    iRecoHw->StartRecognitionL( iNBestList, iScores );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::EndRecSession
+// Signal the end of a recognition sesion.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::EndRecSession()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::EndRecSession()" );
+  
+    // Reset grammars etc.
+    iSIActiveGrammars.Reset();
+	iSIDeActivatedGrammars.Reset();
+    iNBestList.Reset();
+    iScores.Reset();
+    iBlackList.ResetAndDestroy();
+
+    delete iCombinedGrammar;
+    iCombinedGrammar = NULL;
+
+    iCombineNeeded = ETrue;
+    iSDModelBank = NULL;
+    iSIModelBank = NULL;
+    iSDGrammar = NULL;
+    iSIGrammar = NULL;
+    iSICompGrammar = NULL;
+    iSDCompGrammar = NULL;
+    iSDLexicon = NULL;
+    iSILexicon = NULL;
+    iFEState = EIdle;
+    iBEState = EIdle;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::Cancel
+// Cancels the current and any on going requests/tasks.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::Cancel()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::Cancel()" );
+
+    iRecoHw->StopRecognition();
+
+    iFEState = EIdle;
+    iBEState = EIdle;
+
+    iAdaptHw->CancelAdaptation();
+    
+    CActive::Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::DoCancel
+// Cancels the current and any on going requests/tasks.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::DoCancel()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::DoCancel()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::GetUtteranceDuration
+// Get start and end point of utterance.
+// -----------------------------------------------------------------------------
+//
+TBool CRecognitionAlgMgr::GetUtteranceDuration( TUint32& /*aStartFrame*/,
+                                                TUint32& /*aEndFrame*/,
+                                                TReal& /*aFrameLength*/ )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::GetUtteranceDuration()" );
+
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::UnloadRule
+// Unloads one rule from specified grammar.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::UnloadRule()" );
+
+    if ( !IsActive() )
+        {
+        iGrammarID = aGrammarID;
+        iRuleID = aRuleID;
+        iRequestFunction = KUnloadRule;
+        Ready( KErrNone );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::HandleUnloadRule
+// Asynchrounous handler for rule unload.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::HandleUnloadRule()
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::HandleUnloadRule()" );
+
+    TInt error = KErrNone;
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+    CSICompiledGrammar* siGrammar = NULL;
+
+    if ( !iInitialized )
+        {
+        iRecAlgMgrObserver->UnloadRuleComplete( KErrNotReady );
+        }
+    
+    TRAP( error, GetGrammarL( iGrammarID, &siActiveGrammar, &siNonActiveGrammar ) );
+    if ( error != KErrNone )
+        {
+        iRecAlgMgrObserver->UnloadRuleComplete( error );
+        return;
+        }
+
+    if ( siActiveGrammar != NULL )
+        {
+        siGrammar = siActiveGrammar;
+        }
+    else if ( siNonActiveGrammar != NULL )
+        {
+        siGrammar = siNonActiveGrammar;
+        }
+    else
+        {
+        iRecAlgMgrObserver->UnloadRuleComplete( KErrNotFound );
+        return;
+        }
+
+    // Check that given rule id can be found from the given grammar
+    if ( siGrammar->Find( iRuleID ) < 0 )
+        {
+        iRecAlgMgrObserver->UnloadRuleComplete( KErrNotFound );
+        return;
+        }
+
+    // Fetch the actual rule object based on rule id
+    TRAP_IGNORE( 
+    
+        CSIRule& blackRule = siGrammar->AtL( siGrammar->Find( iRuleID ) );
+     
+        // Loop through the rule variants in blacklisted rule
+        for ( TInt i = 0; i < blackRule.Count(); i++ )
+            {
+            // AtL should not leave in any case since i is every time
+            // within range 0..Count()-1
+            CSIRuleVariant& blackVariant = blackRule.AtL( i );
+    
+            // Create rule variant info
+            TSIRuleVariantInfo* info = new TSIRuleVariantInfo( iGrammarID, iRuleID, blackVariant.RuleVariantID() );
+            if ( !info )
+                {
+                iRecAlgMgrObserver->UnloadRuleComplete( KErrNoMemory );
+                return;
+                }
+    
+            iBlackList.Append( info );
+            }
+        ); // TRAP_IGNORE
+
+    // Mark that new combination is needed
+    // iCombineNeeded = ETrue;
+
+    iRecAlgMgrObserver->UnloadRuleComplete( error );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::CombineComplete
+// Notifies that grammar combination has been done.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::CombineComplete( HBufC8* aResult, TInt aError )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::CombineComplete()" );
+
+    if ( aError != KErrNone )
+        {
+        iRecAlgMgrObserver->InitRecognizerBEComplete( aError );
+        return;
+        }
+
+    delete iCombinedGrammar;
+    iCombinedGrammar = NULL;
+    iCombinedGrammar = aResult;
+
+    // Do the rest of BE initialization
+    TRAPD( error, iRecoHw->InitRecognizerBEL( iCombinedGrammar->Des(), *iSIModelBank ) );
+    if ( error != KErrNone )
+        {
+        iRecAlgMgrObserver->InitRecognizerBEComplete( error );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// MASRAdaptationHwDeviceObserver MIXIN impl begins
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MaahdAdaptationComplete
+// Model adaptation has been completed.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MaahdAdaptationComplete( TInt aError )
+    {
+//    iAdaptHw->ClearAdaptation();
+    iRecAlgMgrObserver->AdaptComplete( aError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// MASRAdaptationHwDeviceObserver MIXIN impl begins
+// -----------------------------------------------------------------------------
+
+
+
+// -----------------------------------------------------------------------------
+// MASRSRecogHwDeviceObserver MIXIN impl begins
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoRequestSpeechData
+// Forwards request to upper layers.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoRequestSpeechData()
+    {
+    iRecAlgMgrObserver->RequestSpeechData();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoInitializationComplete
+// Initialization of Hw Device has been completed.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoInitializationComplete( TInt aError )
+    {
+    if ( aError == KErrNone )
+        {
+        iInitialized = ETrue;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoRecognizerFEComplete
+// FE has been initialized.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoInitRecognizerFEComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "CRecognitionAlgMgr::MarhdoInitRecognizerFEComplete(), Status: %d", aError );
+
+    if ( aError == KErrNone )
+        {
+        iFEState = EIdle;
+        }
+    iRecAlgMgrObserver->InitFEComplete( aError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoRecognizerBEComplete
+// BE has been initialized.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoInitRecognizerBEComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "CRecognitionAlgMgr::MarhdoInitRecognizerBEComplete(), Status: %d", aError );
+
+    if ( aError == KErrNone )
+        {
+        iBEState = EIdle;
+        }
+    iRecAlgMgrObserver->InitRecognizerBEComplete( aError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoRecognitionComplete
+// Recognition has been completed
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoRecognitionComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "CRecognitionAlgMgr::MarhdoRecognitionComplete, Status: %d", aError );
+
+    if ( iCombinedGrammar == NULL )
+        {
+        RUBY_DEBUG0( "CRecognitionAlgMgr::HandleMarhdoRecognitionComplete, Cancelled" );
+        delete iAdaptationData;
+        iAdaptationData = NULL;
+        iRecAlgMgrObserver->RecognitionComplete( KErrCancel );
+        return;
+        }
+
+     // Resolve result
+    iRecAlgMgrObserver->ResolveResult( iNBestList, *iSIResult, iSIActiveGrammars, 
+                                       iCombinedGrammar->Des()/*, *iSIModelBank*/ );
+
+
+    RUBY_DEBUG1( "CRecognitionAlgMgr::MarhdoRecognitionComplete, result resolved, result count: %d", iSIResult->Count() );
+
+    TRAP_IGNORE(
+
+        // Put scores in place
+        for ( TInt i = 0; i < iSIResult->Count(); i++ )
+            {
+            // Should not leave since we are every time within range
+            CSIResult& result = iSIResult->AtL( i );
+
+            if ( i < iScores.Count() )
+                {
+                result.SetScore( iScores[i] );
+                }
+            else
+                {
+                result.SetScore( 0 );
+                }
+            }
+            
+        ); // TRAP_IGNORE
+    
+    iScores.Reset();
+
+    RUBY_DEBUG0( "CRecognitionAlgMgr::MarhdoRecognitionComplete, scores in place" );
+
+    // Put adaptation data in place if needed
+    if ( iAdaptation )
+        {
+        iSIResult->SetAdaptationData( iAdaptationData );
+        // Result set gains ownership, no need to delete
+        iAdaptationData = NULL;
+        RUBY_DEBUG0( "CRecognitionAlgMgr::MarhdoRecognitionComplete, adaptation data in place" );
+        }
+
+    iBEState = EIdle;
+    iFEState = EIdle;
+    iRecAlgMgrObserver->RecognitionComplete( aError );
+
+    RUBY_DEBUG0( "CRecognitionAlgMgr::MarhdoRecognitionComplete, ok, event sent" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoEouDetected
+// Called when EOU has been detected, no need to send samples anymore.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoEouDetected( TInt aError )
+    {
+    RUBY_DEBUG1( "CRecognitionAlgMgr::MarhdoEouDetected(), Status: %d", aError );
+
+    iRecAlgMgrObserver->EouDetected( aError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::MarhdoFeatureVector
+// Feature vector sent by AsrRecognitionHwDevice
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::MarhdoFeatureVector( const TDesC8& aFV, 
+                                              TInt32 aSNR, 
+                                              TInt32 aPosition )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::FeatureVectorDataRcvd()" );
+
+    // Collect data to one buffer
+    if ( iAdaptation )
+        {
+        if ( aPosition == 0 )
+            {
+            // Clear previous data if exists
+            if ( iAdaptationData )
+                {
+                delete iAdaptationData;
+                iAdaptationData = NULL;
+                }
+            // Copy data to new buffer
+            iAdaptationData = HBufC8::New( aFV.Length() );
+            if ( !iAdaptationData )
+                {
+                return;
+                }
+            TPtr8 bufferPtr( iAdaptationData->Des() );
+            bufferPtr.Copy( aFV.Ptr(), aFV.Length() );
+            }
+        else if ( aPosition > 0 )
+            {
+            if ( iAdaptationData != NULL )
+                {
+                // Append data to existing buffer
+                iAdaptationData = iAdaptationData->ReAlloc( iAdaptationData->Length() + aFV.Length() );
+                // Check that we got enough memory for new buffer
+                if ( iAdaptationData == NULL )
+                    {
+                    return;
+                    }
+                TPtr8 bufferPtr( iAdaptationData->Des() );
+                bufferPtr.Append( aFV );
+                }
+            else
+                {
+                // Do a new buffer since there is no existing one
+                iAdaptationData = HBufC8::New( aFV.Length() );
+                if ( !iAdaptationData )
+                    {
+                    return;
+                    }
+                TPtr8 bufferPtr( iAdaptationData->Des() );
+                bufferPtr.Copy( aFV.Ptr(), aFV.Length() );
+                }
+            }
+        }
+    // Same callback to client if needed
+    if ( iFeatures )
+        {
+        iRecAlgMgrObserver->FeatureVectorDataRcvd( aFV, aSNR, aPosition );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// MASRSRecogHwDeviceObserver MIXIN impl ends
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// Active object implementation begins
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::RunL
+// Invoke by the active scheduler when a request completes.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CRecognitionAlgMgr::RunL()" );
+
+    switch(iRequestFunction)
+        {
+        case KInitFrontEnd:
+            HandleInitFrontEnd();
+            break;
+            
+        case KInitRecognizerBE:
+            HandleInitRecognizerBE();
+            break;
+            
+        case KLoadGrammar:
+            HandleLoadGrammar();
+            break;
+            
+        case KLoadLexicon:
+            HandleLoadLexicon();
+            break;
+            
+        case KLoadModels:
+            HandleLoadModels();
+            break;
+            
+        case KActivateGrammar:
+            HandleActivateGrammar();
+            break;
+
+        case KDeActivateGrammar:
+            HandleDeActivateGrammar();
+            break;
+
+        case KUnloadRule:
+            HandleUnloadRule();
+            break;
+
+        case KUnloadGrammar:
+            HandleUnloadGrammar();
+            break;
+        
+        default:
+            break;
+        };
+    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::Ready
+// Utility function to post a request complete
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::Ready( const TInt aStatus )
+    {
+    TRequestStatus* stat = &iStatus;
+    User::RequestComplete( stat, aStatus );
+    SetActive();
+    }
+
+
+// -----------------------------------------------------------------------------
+// Active object impl ends
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::AlgorithmState
+// Utility function to print out the state of the algorithms.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::AlgorithmState()
+    {
+#ifdef _DEBUG
+    switch ( iFEState )
+        {
+        case EIdle:
+            RUBY_DEBUG1( "Recognition algorithm is: [%d] - EIdle", iFEState );
+            break;
+            
+        case EProcessing:
+            RUBY_DEBUG1( "Recognition algorithm is: [%d] - EProcessing", iFEState );
+            break;
+            
+        case ECancel:
+            RUBY_DEBUG1( "Recognition algorithm is: [%d] - ECancel", iFEState );
+            break;
+            
+        default:
+            break;
+        };
+#endif
+    }
+    
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::SetRejection
+// Set rejection threshold.
+// -----------------------------------------------------------------------------
+//
+void CRecognitionAlgMgr::SetRejection( TUint32 aRejection )
+    {
+    RUBY_DEBUG0( "CRecognitionAlgMgr::SetRejection()" );
+
+    iRecoHw->SetRejection( aRejection );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrrecognitionalgmgr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,611 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the recognition algorithm manager.
+*
+*/
+
+
+#ifndef DEVASRRECOGNITIONALGMGR_H
+#define DEVASRRECOGNITIONALGMGR_H
+
+//  INCLUDES
+#include <nsssispeechrecognitiondatadevasr.h>
+#include <asrsrecognitionhwdevice.h>
+#include <nssdevasrcommon.h>
+#include <nssdevasr.h>
+#include <asrsadaptationhwdevice.h>
+
+// CLASS DECLARATION
+
+/**
+*  Interface class to be implemented by observer of the recognition algorithm manager.
+*
+*  @since 2.0
+*/
+class MRecAlgMgrObserver
+    {
+    public:
+
+        /**
+        * Invoked by the adaptation hw device when model adaptation has
+        * finished its processing.
+        *
+        * @since 2.8
+        * @param "TInt aResultCode" Error code of operation.
+        */
+        virtual void AdaptComplete( TInt aResultCode ) = 0;
+
+
+        /**
+        * Feature vector received event from the front-end algorithm.
+        *
+        * @since 2.0
+        * @param "TDesC8& aFV" Buffer containing a feature vector.
+        * @param "TInt32 aSNR" Signal-to-noise ratio.
+        * @param "TInt32 aPosition" Indicates whether this is the first, 
+        *        subsequent or last feature vector.
+        */
+        virtual void FeatureVectorDataRcvd( const TDesC8& aFV, 
+                                            TInt32 aSNR, 
+                                            TInt32 aPosition ) = 0;
+
+        /**
+        * Invoked by the front-end when EOU has been detected
+        *
+        * @since 2.8
+        * @param "TInt aResultCode" Result of front-end processing.
+        */
+        virtual void EouDetected( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the front-end when initialization has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of front-end initialization.
+        */
+        virtual void InitFEComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the recognizer back-end when initialization has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of recognizer back-end initialization.
+        */
+        virtual void InitRecognizerBEComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the recognizer back-end when grammar loading has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of grammar loading
+        */
+        virtual void LoadGrammarComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked when grammar has been unloaded.
+        *
+        * @since 2.8
+        * @param "TInt aResultCode" Result of grammar loading
+        */
+        virtual void UnloadGrammarComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked when grammar has been activated.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of grammar activation
+        */
+        virtual void ActivateGrammarComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked when grammar has been deactivated.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of grammar deactivation
+        */
+        virtual void DeActivateGrammarComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the recognizer back-end when lexicon loading has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of lexicon loading.
+        */
+        virtual void LoadLexiconComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the recognizer back-end when model loading has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of model loading.
+        */
+        virtual void LoadModelsComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the recognizer when recognition process has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of the recognition process.
+        */
+        virtual void RecognitionComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked by the training module when the training process has completed.
+        *
+        * @since 2.0
+        * @param "TInt aResultCode" Result of training process.
+        */
+        virtual void TrainComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked when rule unloading has been done.
+        *
+        * @since 2.8
+        * @param "TInt aResultCode" Result of training process.
+        */
+        virtual void UnloadRuleComplete( TInt aResultCode ) = 0;
+
+        /**
+        * Invoked when speech data is needed.
+        *
+        * @since 2.8
+        */
+        virtual void RequestSpeechData() = 0;
+
+        /**
+        * Invoked when result resolving is needed.
+        *
+        * @since 2.8
+        * @param "RArray<TUint>& aNBestIDs"
+        * @param "CSIResultSet& aSIResultSet"
+        * @param "RPointerArray<CSICompiledGrammar>& aSICompiledGrammar"
+        * @param "TDesC8& aCombinedData"
+        */
+        virtual void ResolveResult( const RArray<TUint>& aNBestIDs,
+                                    CSIResultSet& aSIResultSet,
+                                    const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar,
+                                    const TDesC8& aCombinedData/*,
+                                    CSIModelBank& iSIModelBank*/ ) = 0;
+
+        /**
+        * Invoked when grammar combining is needed
+        *
+        * @since 2.8
+        * @param "RPointerArray<CSICompiledGrammar>& aCompiledGrammars" 
+        *        Array of previously compiled grammar
+        * @param "const RPointerArray<TSIRuleVariantInfo>& aExcludedRules" 
+        *        Rules to be blacklisted.
+        */
+        virtual void CombineGrammarL( const RPointerArray<CSICompiledGrammar>& aCompiledGrammars,
+                                      const RPointerArray<TSIRuleVariantInfo>& aExcludedRules ) = 0;
+
+    };
+
+
+/**
+*  This class is an aggregation of all related algorithms. It manages the algorithms
+*  and coordinate transfer of data.
+*
+*  @lib NssDevASR.lib
+*  @since 2.0
+*/
+class CRecognitionAlgMgr : public CActive,
+                           public MASRSRecognitionHwDeviceObserver,
+                           public MASRAdaptationHwDeviceObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CRecognitionAlgMgr* NewL( MRecAlgMgrObserver& aObserver );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CRecognitionAlgMgr();
+
+    public: // New functions
+
+        /**
+        * Adapts models
+        *
+        * @sinxe 2.8
+        * @param "CSIResultSet& aResultSet" Result set reference.
+        * @param "TInt aResultIndex" Index of correct result.
+        * @param "TLanguage aLanguage" Language of correct result.
+        */
+        void AdaptModelsL( const CSIResultSet& aResultSet, TInt aResultIndex,
+                           TLanguage aLanguage );
+
+        /**
+        * Cancels the current or started tasks.
+        *
+        * @since 2.0
+        */
+        void Cancel();
+
+        /**
+        * This method is used to indicate the end of a recognition session.
+        * The EndRecSession() method should be used to end the session.
+        *
+        * @since 2.0
+        */
+        void EndRecSession();
+
+        /**
+        * Grammar combination has been completed.
+        */
+        void CombineComplete( HBufC8* aResult, TInt aError );
+
+		/**
+        * Retreive the properties of the underlying speech recognition engine.
+        *
+        * @since 2.0
+        * @param "RArray<TInt>& aPropertyId" An array of identifiers being querried.
+        * @param "RArray<TInt>& aPropertyValue" An array of values corresponding
+        *        to the querried identifiers.
+        */
+        void GetEnginePropertiesL( const RArray<TInt>& aPropertyId, 
+                                   RArray<TInt>& aPropertyValue );
+
+        /**
+        * Load the specified parameter(s) to the engines. 
+        *
+        * @param "RArray<TInt>& aParameterId" An array of parameter identifiers.
+        * @param "RArray<TInt>& aParameterValue" An array of parameter values.
+        */
+        void LoadEnginePropertiesL( const RArray<TInt>& aParameterId,
+                                    const RArray<TInt>& aParameterValue );
+
+        /**
+        * Retreive the duration of the utterance detected by the algorithm.
+        *
+        * @since 2.0
+        * @param "TUint32& aStartFrame" Indicates the start frame of feature vector.
+        * @param "TUint32& aEndFrame" Indicates the end frame of the feature vector.
+        * @param "TReal& aFrameLength" The length of each frame
+        * @return ETrue if successful
+        */
+        TBool GetUtteranceDuration( TUint32& aStartFrame, TUint32& aEndFrame, 
+                                    TReal& aFrameLength );
+
+        /**
+        * Initializes the front-end module in the speech recognition engine.
+        * The frontend module used during training/recognition functions is started
+        * as a result. This method is intended to be used in conjunction with InitTrainBE().
+        *
+        * @since 2.0
+        * @param "TRecognizerMode aFeMode" Mode of the recognizer.
+        */
+        void InitFrontEnd( TRecognizerMode aFeMode );
+
+        /**
+        * Initialize the recognition engine back-end. The module responsible for recognition
+        * function is started as a result. This method must be used before any recognition
+        * operations and intended to be used in conjunction with InitFrontEnd().
+        *
+        * @since 2.0
+        * @param "aResult" A reference to an object where the recognition
+        *        result will be written.
+        */
+		void InitRecognizerBE( CSIResultSet& aResult );
+
+        /**
+        * Load the specified grammar into the recognizer.
+        *
+        * @since 2.8
+        * @param "aGrammar" A reference to a grammar in an internal format.
+        */
+		void LoadGrammarL( const CSIGrammar& aGrammar );
+		void LoadGrammarL( const CSICompiledGrammar& aGrammar );
+
+        /**
+        * Unloads the specified grammar from the recognizer.
+        *
+        * @since 2.8
+        * @param "aGrammar" A reference to a grammar.
+        */
+		void UnloadGrammarL( const CSIGrammar& aGrammar );
+		void UnloadGrammarL( const CSICompiledGrammar& aGrammar );
+
+        /**
+        * Get the specified grammar.
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" Identifier of grammar to be found.
+		* @param "CSDGrammar** aSDGrammar" Pointer to found SD grammar, 
+        *         NULL if not found.
+		* @param "CSICompiledGrammar** aSIActiveGrammar" Pointer to found SI 
+        *        active grammar, NULL if not found.
+		* @param "CSICompiledGrammar** aSIDeActivatedGrammar" Pointer to found SI 
+        *        non-active grammar, NULL if not found
+        */
+		void GetGrammarL( const TSIGrammarID aGrammarID, 
+                          CSICompiledGrammar** aSIActiveGrammar,
+                          CSICompiledGrammar** aSIDeActivatedGrammar );
+
+		/**
+		* Activates a grammar.
+        *
+		* @since 2.8
+		* @param "TSIGrammarID aGrammarID" A grammar identifier.
+		*/
+		void ActivateGrammarL( const TSIGrammarID aGrammarID );
+
+		/**
+		* Deactivates a grammar
+        *
+		* @since 2.8
+		* @param "TSIGrammarID aGrammarID" A grammar identifier
+		*/
+		void DeactivateGrammarL( const TSIGrammarID aGrammarID );
+
+        /**
+        * Load the specified lexicon into the recognizer.
+        *
+        * @since 2.0
+        * @param "aLexicon" A reference to a lexicon in an internal format.
+        */
+		void LoadLexiconL( const CSILexicon& aLexicon );
+
+        /**
+        * Load the specified model bank into the recognizer.
+        *
+        * @since 2.0
+        * @param "aModels" A reference to a model bank.
+        */
+        void LoadModelsL( const CSDModelBank& aModels );
+		void LoadModelsL( const CSIModelBank& aModels );
+
+        /**
+        * Use to send the utterance data as a response to the RequestSpeechData().
+        *
+        * @since 2.8
+        * @param "TDesC8& aBuffer" Buffer containing utterance data.
+        * @param "TBool aEnd" Flag to tell if given buffer is the last one.
+        */
+        void SendSpeechData( TPtrC8& aBuffer, TBool aEnd );
+
+        /**
+        * Request to start a recognition session.
+        *
+        * @since 2.0
+        * @param "TRecognizerMode aMode" Mode of recognizer.
+        * @return result code of request.
+        */
+        TInt StartRecSession( TRecognizerMode aMode );
+
+        /**
+        * Starts recognition.
+        */
+        void StartRecognitionL();
+
+        /**
+        * Request to unload the specified rule in the grammar from recognizer.
+        *
+        * @param "TSIGrammarID aGrammarID" Identifer of the grammar to operate on.
+        * @param "TSIRuleID aRuleID" Identifier of the rule to remove.
+        */
+        void UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+        /**
+        * Used during unit testing to print the state of the algorithm
+        */
+        void AlgorithmState();
+        
+        /**
+        * Sets rejection value
+        *
+        * @param "TUint32 aRejection" Rejection threshold value.
+        */
+        void SetRejection( TUint32 aRejection );
+
+    public: // MASRAdaptationHwDeviceObserver
+        /**
+        * Called when adaptation has been done
+        */
+        void MaahdAdaptationComplete( TInt aError );
+
+    public: // From MASRSRecognitionHwDeviceObserver
+
+        /**
+        * Called by the hardware device when the InitializeL() method has completed.
+        * @since Series60 2.8
+        * @param aError Initialization result code. 
+        *               KErrNone if successful otherwise a system-wide error code.
+        * @return none
+        */
+        void MarhdoInitializationComplete( TInt aError );
+
+        /**
+        * Called by the hardware device when the  InitializeL() method has completed.
+        * @since Series60 2.8
+        * @param aError Initialization result code. 
+        *               KErrNone if successful otherwise a system-wide error code.
+        * @return none
+        */
+        void MarhdoInitRecognizerFEComplete( TInt aError );
+
+        /**
+        * Called by the hardware device when backend initialization is completed.
+        * @since Series60 2.8
+        * @param aError Initialization result code. 
+        *               KErrNone if successful otherwise a system-wide error code.
+        * @return none
+        */
+        void MarhdoInitRecognizerBEComplete( TInt aError );
+
+        /**
+        * Called by the hardware device when recognition result is available.
+        * @since Series60 2.8
+        * @param aError Recognition result code. KErrNone if successful.  
+        *               KErrRejected if the recognition result is rejected, 
+        *               otherwise a system-wide error code
+        * @return none
+        */ 
+        void MarhdoRecognitionComplete( TInt aError );
+
+        /**
+        * Called by the hardware device when end-of-utterance is detected by the 
+        * acoustic frontend. This method must be called before MarhdoRecognitionComplete().
+        * @since Series60 2.8
+        * @param aError Recognition result code. KErrNone if successful, otherwise KErrTooLong, 
+        *               KErrTooShort, KErrAsrSpeechTooEarly, KErrNoSpeech
+        * @return none
+        */
+        void MarhdoEouDetected( TInt aError );
+
+        /**
+        * Called by the hardware device when a feature vector is extracted by acoustic frontend.
+        * @since Series60 2.8
+        * @param aFV A buffer containing a feature vector.
+        * @param aSNR Signal-to-noise ratio.
+        * @param aPosition Indicates whether this is the first, subsequent or last feature vector in a series.
+        * @return none
+        */
+        void MarhdoFeatureVector( const TDesC8& aFV, TInt32 aSNR, TInt32 aPosition );
+
+        /**
+        * Called by the hardware device to request for utterance data. 
+        * The response to the request is sent in SendSpeechData().
+        * @since Series60 2.8
+        * @param none
+        * @return none
+        */
+        void MarhdoRequestSpeechData();
+
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRecognitionAlgMgr(MRecAlgMgrObserver& aObserver);
+
+        /**
+        * Symbian 2nd phase constructor
+        */
+        void ConstructL();
+
+        void RunL();
+        void DoCancel();
+
+        /**
+        * The following methods are asynchronous handlers for the corresponding
+        * synchronous calls.
+        */
+        void HandleInitFrontEnd();
+        void HandleInitTrainBE();
+        void HandleInitRecognizerBE();
+        void HandleLoadGrammar();
+        void HandleLoadLexicon();
+        void HandleLoadModels();
+        void HandleUtteranceDataRcvd();
+        void HandleActivateGrammar();
+        void HandleDeActivateGrammar();
+        void HandleUnloadRule();
+        void HandleUnloadGrammar();
+
+        /**
+        * Used to complete a request
+        */
+        void Ready(const TInt aStatus);
+
+
+    private: // Data
+
+        /**
+        * Current working state of the recognizer
+        */
+        enum TAlgState
+            {
+            EIdle=0,
+            EProcessing,
+            ECancel
+        };
+
+        // Pointer to Algorithm Manager Observer
+        MRecAlgMgrObserver* iRecAlgMgrObserver;
+
+		// Grammar handling
+		RPointerArray<CSICompiledGrammar> iSIActiveGrammars;
+		RPointerArray<CSICompiledGrammar> iSIDeActivatedGrammars;
+
+        // Blacklisted rules
+        RPointerArray<TSIRuleVariantInfo> iBlackList;
+
+        // Result IDs
+        RArray<TUint> iNBestList;
+
+        // Result scores
+        RArray<TInt> iScores;
+
+        //CSICompiledGrammar* iCombinedGrammar;
+        HBufC8* iCombinedGrammar;
+
+        // Flag to tell if combining is needed for active grammars.
+        TBool iCombineNeeded;
+
+        // Flag to inform if recognition hw device has been successfully 
+        // initialized.
+        TBool iInitialized;
+
+        // Pointer to Algorithms
+        CASRSRecognitionHwDevice* iRecoHw;
+        CASRSAdaptHwDevice* iAdaptHw;
+
+        // Begin: data used in async handling of requests
+        TRecognizerMode iMode;
+        void* iModel;
+
+        CSDModelBank* iSDModelBank;
+		CSIModelBank* iSIModelBank;
+        void* iSDResult;
+
+		CSIResultSet* iSIResult;
+        const void* iSDGrammar;
+        const CSIGrammar* iSIGrammar;
+		const CSICompiledGrammar* iSICompGrammar;
+        const void* iSDCompGrammar;
+        const void* iSDLexicon;
+
+        const CSILexicon* iSILexicon;
+        TSIGrammarID iGrammarID;
+        TSIRuleID iRuleID;
+        TUint32 iStartFrame;
+        TUint32 iEndFrame;
+        TReal   iFrameLength;
+		TPtrC8 iBuffer;
+        TBool iEnd;
+        TInt iRequestFunction;
+        // End: data used in async handling of requests
+
+		// Algorithm states for front-end, back-end, and train back-end.
+        TAlgState iFEState;
+        TAlgState iBEState;
+
+        // Should we send feature vectors to upper layers or not
+        TBool iFeatures;
+
+        // Should we include adaptation data to result set or not
+        TBool iAdaptation;
+
+        // Adaptation data
+        HBufC8* iAdaptationData;
+    };
+
+#endif // DEVASRRECOGNITIONALGMGR_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrresourcehandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads the resource file and provides access to the
+*               information read from the resource file.
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <barsread.h>
+#include "devasrresourcehandler.h"
+#include <nssdevasr.rsg>
+#include "rubydebug.h"
+#include <data_caging_path_literals.hrh>
+
+// LOCAL CONSTANTS AND MACROS
+_LIT( KResourceFileName, "nssdevasr.rsc" );
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDevASRResourceHandler::CDevASRResourceHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDevASRResourceHandler::CDevASRResourceHandler()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevASRResourceHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDevASRResourceHandler::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CDevASRResourceHandler::ConstructL()" );
+
+    ReadResourceFileL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevASRResourceHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDevASRResourceHandler* CDevASRResourceHandler::NewL()
+    {
+    CDevASRResourceHandler* self = new ( ELeave ) CDevASRResourceHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // Self
+    return self;
+    }
+
+// Destructor
+CDevASRResourceHandler::~CDevASRResourceHandler()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevASRResourceHandler::ReadResourceFileL
+// Reads the data from the resource file.
+// -----------------------------------------------------------------------------
+//
+void CDevASRResourceHandler::ReadResourceFileL()
+    {
+    RUBY_DEBUG_BLOCK( "CDevASRResourceHandler::ReadResourceFileL()" );
+
+    // letters for drives in search order
+    const TBuf<2> KResourceDrives = _L("cz"); 
+
+    // load resources
+    RResourceFile resourceFile;
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    
+    TFileName name;
+    TInt i( 0 );
+    // try to find from the first driver
+    name.Append( KResourceDrives[i] );
+    name.Append( ':' );
+    name.Append( KDC_RESOURCE_FILES_DIR );
+    name.Append( KResourceFileName );
+
+    TBool found( EFalse );
+    
+    while ( !found && i < KResourceDrives.Length() )
+        {
+        name[0] = KResourceDrives[i++];
+       
+        if ( BaflUtils::FileExists(fs, name) )
+            {
+            // open resource
+            resourceFile.OpenL( fs, name );
+            CleanupClosePushL( resourceFile );
+            found = ETrue;
+            }
+        }
+            
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    
+    HBufC8* res = resourceFile.AllocReadLC( DEVASRINFO );
+
+    TResourceReader theReader;
+    theReader.SetBuffer( res );
+
+    iSamplingRate = theReader.ReadInt16();
+    iBitsPerSample = theReader.ReadInt16();
+    iMicrophoneGain = theReader.ReadInt16();
+    iSpeakerVolume = theReader.ReadInt16();
+    iSilenceFrames = theReader.ReadInt16();
+    iPadEndFrames = theReader.ReadInt16();
+    iPadStartFrames = theReader.ReadInt16();
+    iBufferSize = theReader.ReadInt16();
+    iBuffersInWins = theReader.ReadInt16();
+    iBuffersInThumb = theReader.ReadInt16();
+
+    // Cleanup res, fs, resourceFile
+    CleanupStack::PopAndDestroy( 3 );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrresourcehandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads the resource file and provides access to the
+*               information read from the resource file.
+*
+*/
+
+
+#ifndef CDEVASRRESOURCEHANDLER_H
+#define CDEVASRRESOURCEHANDLER_H
+
+// CLASS DECLARATION
+
+/**
+*  This class encapsulates resource file handling functions
+*
+*  @lib DevASR.lib
+*  @since 2.0
+*/
+class CDevASRResourceHandler : public CBase
+	{
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDevASRResourceHandler* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDevASRResourceHandler();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDevASRResourceHandler();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Reads the data from the resource file.
+        * @since 2.0
+        * @param	-
+        * @return	-
+        */
+		void ReadResourceFileL();
+
+	public: // Data
+
+		// Recording sampling rate
+		TInt iSamplingRate;
+		// Number of bits per sample
+		TInt iBitsPerSample;
+		// Number of channels
+		TInt iMicrophoneGain;
+		// percentage of max speaker volume
+		TInt iSpeakerVolume;
+		// Number of frames to silence
+		TInt iSilenceFrames;
+		// Number of frames to pad at the end of end-pointed buffer
+		TInt iPadEndFrames;
+		// Number of frames to pad at the start of end-pointed buffer
+		TInt iPadStartFrames;
+        // Size of playback/record buffer in bytes
+        TInt iBufferSize;
+        // Number of buffers gathered in WINS
+        TInt iBuffersInWins;
+        // Number of buffers gathered in THUMB
+        TInt iBuffersInThumb;
+	};
+
+
+#endif // CDevASRResourceHandler_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrsrsalgorithmmanager.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,2150 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains the implementation of Algorithm Manager,
+*               a submodule of DevASR.
+*
+*/
+
+
+// INCLUDE FILES
+#include <mmfdatabuffer.h>
+#include <AudioPreference.h>
+#include <nssdevasr.h>
+#include "devasrsrsalgorithmmanager.h"
+#include "devasrvmalgorithmmanager.h"
+#include "rubydebug.h"
+#include "devasrcenrep.h"
+#include "srsfbldvariant.hrh"
+
+// CONSTANTS
+const TInt KPlay = 1;
+const TInt KRecord = KPlay + 1;
+
+// Extra error values
+const TInt KErrTooEarly = -100; // if speech was started too early
+const TInt KErrNoSpeech = -101; // if it was silent 
+const TInt KErrTooLong  = -102; // if speech did not stop before timeout
+const TInt KErrTooShort = -103; // if speech was too short
+
+// Default priority for recording
+const TInt KDefaultPriority = KAudioPriorityVoiceDial;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::CSRSAlgorithmManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSRSAlgorithmManager::CSRSAlgorithmManager( MDevASRObserver& aObserver )
+                                           : CActive( CActive::EPriorityStandard ),
+                                             iDevASRObserver( &aObserver ),
+                                             iDevSound( NULL ),
+                                             iCurrentVolume( 0 ),
+                                             iCurrentGain( 0 ),
+                                             iRecognitionAlgMgr( NULL ),
+                                             iVMAlgorithmManager( NULL ),
+                                             iStartRecognition( EFalse ),
+                                             iPendingRequestSpeechData( EFalse ),
+                                             iStartPoint( 0 ),
+                                             iStopPoint( 0 ),
+                                             iAudioBuffer( NULL ),
+                                             iPtr( NULL, 0, 0 ),
+                                             iOverallLength( 0 ),
+                                             iOverallSampled( 0 ),
+                                             iProcessingUtterance( EFalse ),
+                                             iEndFlag( 0 ),
+                                             iStartFrame( 0 ),
+                                             iEndFrame( 0 ),
+                                             iFrameLength( 0 ),
+                                             iBufferStartPoint( 0 ),
+                                             iBufferEndPoint( 0 ),
+                                             iDevASRState( EDASRIdle ),
+                                             iDevSoundState( ESoundDeviceNotInitialized ),
+                                             iRequestFunction( 0 ),
+                                             iBufferUnderConstruction( NULL ),
+                                             iConstructionPoint( 0 ),
+                                             iPreSamplingStarted( EFalse )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::CSRSAlgorithmManager()" );
+#ifdef AUDIOBUFFER_TO_FILE
+    iFileCreated = EFalse;
+#endif
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::ConstructL()" );
+
+    // Resource handler reads the DevASR resource file
+    iResourceHandler = CDevASRResourceHandler::NewL();
+
+    iRecognitionAlgMgr = CRecognitionAlgMgr::NewL( *this );
+    iVMAlgorithmManager = CVMAlgorithmManager::NewL( *iDevASRObserver, *this );
+
+    // Queue containing audio buffers
+    iAudioBufferQue = new ( ELeave ) TSglQue<CQueItem>( _FOFF( CQueItem, iLink ) );
+
+    // Set default priority settings
+    iPrioritySettings.iState = EMMFStateRecording;
+    iPrioritySettings.iPriority = KDefaultPriority;
+    iPrioritySettings.iPref = ( TMdaPriorityPreference ) KAudioPrefVocosRecog;
+
+    // CenRep utility class
+    CDevAsrCenRep* cenRep = CDevAsrCenRep::NewL();
+    CleanupStack::PushL( cenRep );
+    
+    iRecognitionAlgMgr->SetRejection( cenRep->RejectionValue() );
+    
+    CleanupStack::PopAndDestroy( cenRep );
+
+    CActiveScheduler::Add( this );
+
+    RUBY_DEBUG1( "associated DevSound instance [%x]", iDevSound );
+    RUBY_DEBUG1( "associated Recognition AlgMgr instance [%x]", iRecognitionAlgMgr );
+    RUBY_DEBUG1( "associated Vocabulary AlgMgr instance [%x]", iRecognitionAlgMgr );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSRSAlgorithmManager* CSRSAlgorithmManager::NewL( MDevASRObserver& aObserver )
+    {
+    CSRSAlgorithmManager* self = new( ELeave ) CSRSAlgorithmManager( aObserver );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::~CSRSAlgorithmManager
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CSRSAlgorithmManager::~CSRSAlgorithmManager()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::~CSRSAlgorithmManager()" );
+
+    //delete iAudioBuffer;
+    delete iQueItem;
+
+    // Empty audio queue if there happens to be something
+    if ( iAudioBufferQue )
+        {
+        while ( !iAudioBufferQue->IsEmpty() )
+            {
+            iQueItem = iAudioBufferQue->First();
+            iAudioBufferQue->Remove( *iQueItem );
+            delete iQueItem;
+            }
+
+        delete iAudioBufferQue;
+        }
+
+    delete iBufferUnderConstruction;
+    iBufferUnderConstruction = NULL;
+    iConstructionPoint = 0;
+
+    delete iDevSound;
+    delete iRecognitionAlgMgr;
+    delete iVMAlgorithmManager;
+    delete iResourceHandler;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::AdaptL
+// Adapts vocabulary and models based on correct result.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::AdaptL( const CSIResultSet& aResultSet, 
+                                   TInt aResultIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::AdaptL()" );
+
+    // Adapt vocab
+    iVMAlgorithmManager->AdaptVocabL( aResultSet, aResultIndex );
+
+    // Find language of correct result
+    const CSIResult& iCorrectResult = aResultSet.AtL( aResultIndex );
+    TSIGrammarID grammarID = iCorrectResult.GrammarID();
+    TSIRuleID ruleID = iCorrectResult.RuleID();
+    TSIRuleVariantID ruleVariantID = iCorrectResult.RuleVariantID();
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+    CSICompiledGrammar* siGrammar = NULL;
+  
+    TRAPD( error, GetGrammarL( grammarID, &siActiveGrammar, &siNonActiveGrammar ) );
+    User::LeaveIfError( error );
+
+    TInt index = 0;
+
+    if ( siActiveGrammar != NULL )
+        {
+        siGrammar = siActiveGrammar;
+        }
+    else if ( siNonActiveGrammar != NULL )
+        {
+        siGrammar = siNonActiveGrammar;
+        }
+    else
+        {
+        User::Leave( KErrNotFound );	
+        }
+    
+    index = siGrammar->Find( ruleID );
+    User::LeaveIfError( index );
+    CSIRule& rule = siGrammar->AtL( index );
+
+    index = rule.Find( ruleVariantID );
+    User::LeaveIfError( index );
+    CSIRuleVariant& ruleVariant = rule.AtL( index );
+
+    // Adapt models
+    iRecognitionAlgMgr->AdaptModelsL( aResultSet, aResultIndex, ruleVariant.Language() );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::CompileGrammarL
+// Forward call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::CompileGrammarL( CSICompiledGrammar& aGrammar/*,
+                                            CSIModelBank& aModelBank*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::CompileGrammarL()" );
+
+    iVMAlgorithmManager->CompileGrammarL( aGrammar/*, aModelBank*/ );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ComputeNewGrammarSizeL
+// Forward call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ComputeNewGrammarSizeL( const CSIGrammar& aGrammar, 
+                                                   const TUint32 aTargetNRuleVariants, 
+                                                   const TUint32 aMaxNRuleVariants, 
+                                                   const RArray<TUint>& aNewRuleScores, 
+                                                   RArray<TUint>& aNNeNRuleVariants, 
+                                                   TUint32& aNPrune )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::ComputeNewGrammarSizeL()" );
+
+    iVMAlgorithmManager->ComputeNewGrammarSizeL( aGrammar,
+                                                 aTargetNRuleVariants,
+                                                 aMaxNRuleVariants,
+                                                 aNewRuleScores,
+                                                 aNNeNRuleVariants,
+                                                 aNPrune );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::PruneGrammar
+// Forward call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+//
+TBool CSRSAlgorithmManager::PruneGrammar( const CSIGrammar& aGrammar, 
+                                          const TUint32 aMinNumber, 
+                                          RArray<TSIRuleVariantInfo>& aPrunedRuleVariants )
+    {
+    return iVMAlgorithmManager->PruneGrammar( aGrammar, aMinNumber, aPrunedRuleVariants );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::StartTrainingFromTextL
+// Forward call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+// 
+void CSRSAlgorithmManager::StartTrainingFromTextL( CSITtpWordList& aWordList, 
+                                                   const RArray<TLanguage>& aDefaultLanguage, 
+                                                   const RArray<TUint32>& aMaxNPronunsForWord )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::StartTrainingFromTextL()" );
+
+    iVMAlgorithmManager->TrainFromTextL( aWordList, aDefaultLanguage, aMaxNPronunsForWord );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ResolveResult
+// Forward call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+// 
+void CSRSAlgorithmManager::ResolveResult( const RArray<TUint>& aNBestIDs,
+                                          CSIResultSet& aSIResultSet,
+                                          const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar,
+                                          const TDesC8& aCombinedData/*,
+                                          CSIModelBank& iSIModelBank*/ )
+    {
+    iVMAlgorithmManager->ResolveResult( aNBestIDs, aSIResultSet, 
+                                        aSICompiledGrammar, aCombinedData/*,
+                                        iSIModelBank*/ );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::CombineGrammarL
+// Forward call to CVMAlgorithmManager.
+// -----------------------------------------------------------------------------
+// 
+void CSRSAlgorithmManager::CombineGrammarL( const RPointerArray<CSICompiledGrammar>& aCompiledGrammars,
+                                            const RPointerArray<TSIRuleVariantInfo>& aExcludedRules )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::CombineGrammarL()" );
+
+    iVMAlgorithmManager->CombineGrammarL( aCompiledGrammars, aExcludedRules );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ConfigureSoundDeviceL
+// Configure sound device according to resource file parameters
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ConfigureSoundDeviceL()
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::ConfigureSoundDeviceL()" );
+
+	// Fetch the default configuration from DevSound
+    iDevSoundCapabilities = iDevSound->Config();
+
+	// Now, configure it according to resource file parameters
+    switch ( iResourceHandler->iSamplingRate )
+		{
+		case 8000:
+			iDevSoundCapabilities.iRate = EMMFSampleRate8000Hz;
+			break;
+		case 11025:
+			iDevSoundCapabilities.iRate = EMMFSampleRate11025Hz;
+			break;
+		case 16000:
+			iDevSoundCapabilities.iRate = EMMFSampleRate16000Hz;
+			break;
+		case 22050:
+			iDevSoundCapabilities.iRate = EMMFSampleRate22050Hz;
+			break;
+		case 32000:
+			iDevSoundCapabilities.iRate = EMMFSampleRate32000Hz;
+			break;
+		case 44100:
+			iDevSoundCapabilities.iRate = EMMFSampleRate44100Hz;
+			break;
+		case 48000:
+			iDevSoundCapabilities.iRate = EMMFSampleRate48000Hz;
+			break;
+		case 88200:
+			iDevSoundCapabilities.iRate = EMMFSampleRate88200Hz;
+			break;
+		case 96000:
+			iDevSoundCapabilities.iRate = EMMFSampleRate96000Hz;
+			break;
+		default:
+			iDevSoundCapabilities.iRate = EMMFSampleRate8000Hz;
+			break;
+		}
+
+    iDevSoundCapabilities.iBufferSize = iResourceHandler->iBufferSize;
+
+    if ( iResourceHandler->iBitsPerSample == 8 )
+        {
+        iDevSoundCapabilities.iEncoding = EMMFSoundEncoding8BitPCM;
+        }
+    else
+        {
+        iDevSoundCapabilities.iEncoding = EMMFSoundEncoding16BitPCM;
+        }
+
+	// Now, configure DevSound according to new parameters.
+    iDevSound->SetConfigL( iDevSoundCapabilities );
+
+    RUBY_DEBUG1( "DevSound Max Volume = %d", iDevSound->MaxVolume() );
+    RUBY_DEBUG1( "DevSound Max Gain = %d", iDevSound->MaxGain() );
+
+    // In order to avoid truncation, computation must be done this way.
+    iCurrentVolume = ( ( iDevSound->MaxVolume() * iResourceHandler->iSpeakerVolume ) + 50 ) / 100;
+    iCurrentGain = ( ( iDevSound->MaxGain() * iResourceHandler->iMicrophoneGain ) + 50 ) / 100;
+
+    // The speaker volume is set to the percentage of max volume supported.
+    iDevSound->SetVolume( iCurrentVolume );
+    // The gain is set to the percentage of max gain supported.
+    iDevSound->SetGain( iCurrentGain );
+
+    iDevSoundCapabilities = iDevSound->Config();
+
+    RUBY_DEBUG1( "DevSound Set Volume = %d", iCurrentVolume );
+    RUBY_DEBUG1( "DevSound Set Gain = %d", iCurrentGain );
+    RUBY_DEBUG1( "DevSound Buffer Size = %d", iDevSoundCapabilities.iBufferSize );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::GetEnginePropertiesL
+// Retreive the properties of the underlying speech recognition engine.
+// An array of values corresponding to the querried identifiers will be populated.
+// The function may leave with KErrArgument.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::GetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+                                                 RArray<TInt>& aPropertyValue )
+    {
+    RUBY_DEBUG_BLOCK( "SRSAlgorithmManager::EnginePropertiesL()" );
+
+    // Check that arrays are ok
+    if ( aPropertyId.Count() != aPropertyValue.Count() )
+        {
+        User::Leave( KErrArgument );
+        }
+
+	// Run through the engine properties and fill in known values
+    for ( TInt index = 0; index < aPropertyId.Count(); index++)
+        {
+        switch( aPropertyId[index] )
+            {
+            case KSamplingRate:
+                aPropertyValue[index] = iResourceHandler->iSamplingRate;
+                break;
+
+            case KBitsPerSample:
+                aPropertyValue[index] = iResourceHandler->iBitsPerSample;
+                break;
+
+            default:
+                break;
+
+            }
+        }
+	// Get engine properties from other sources.
+    iRecognitionAlgMgr->GetEnginePropertiesL( aPropertyId, aPropertyValue );
+    iVMAlgorithmManager->GetEnginePropertiesL( aPropertyId, aPropertyValue );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::InitFrontEnd
+// Initializes the recognition front end.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::InitFrontEnd( TRecognizerMode aMode )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::InitFrontEnd()" );
+
+	iProcessingUtterance = EFalse;
+
+    if ( iMode != aMode )
+        {
+        return;
+        }
+
+    StateTransition( EDASRInitRecognition );
+
+    iRecognitionAlgMgr->InitFrontEnd( aMode );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::InitRecognizerBE
+// Initializes the recognition back-end. The module responsible for recognition
+// function is started as a result.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::InitRecognizerBE( CSIResultSet& aResult )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::InitRecognizerBE()" );
+
+    iRecognitionAlgMgr->InitRecognizerBE( aResult );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::IsGrammarLoaded
+// Checks if grammar has been loaded.
+// -----------------------------------------------------------------------------
+//
+TBool CSRSAlgorithmManager::IsGrammarLoaded( TSIGrammarID aGrammarID )
+    {
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+  
+    TRAPD( error, GetGrammarL( aGrammarID, &siActiveGrammar, &siNonActiveGrammar ) );
+    if ( error != KErrNone )
+        {
+        return EFalse;
+        }
+
+    if ( siActiveGrammar != NULL )
+        {
+        return ETrue;
+        }
+    else if ( siNonActiveGrammar != NULL )
+        {
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::IsGrammarActive
+// Checks if grammar is currently active.
+// -----------------------------------------------------------------------------
+//
+TBool CSRSAlgorithmManager::IsGrammarActive( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::IsGrammarActive()" );
+
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+  
+    TRAPD( error, GetGrammarL( aGrammarID, &siActiveGrammar, &siNonActiveGrammar ) );
+    if ( error != KErrNone )
+        {
+        return EFalse;
+        }
+
+    if ( siActiveGrammar != NULL )
+        {
+        return ETrue;
+        }
+    else if ( siNonActiveGrammar != NULL )
+        {
+        return EFalse;
+        }
+
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadGrammarL
+// Load the specified grammar into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadGrammarL( const CSIGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::LoadGrammarL(si non-compiled)" );
+
+    iRecognitionAlgMgr->LoadGrammarL( aGrammar );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadGrammarL
+// Load the specified grammar into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadGrammarL( const CSICompiledGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::LoadGrammarL(si compiled)" );
+
+    iRecognitionAlgMgr->LoadGrammarL( aGrammar );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadGrammarL
+// Unloads the specified grammar from the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::UnloadGrammarL( const CSIGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::UnloadGrammarL(si non-compiled)" );
+
+    iRecognitionAlgMgr->UnloadGrammarL( aGrammar );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::UnloadGrammarL
+// Unloads the specified grammar from the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::UnloadGrammarL( const CSICompiledGrammar& aGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::UnloadGrammarL(si compiled)" );
+
+    iRecognitionAlgMgr->UnloadGrammarL( aGrammar );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ActivateGrammarL
+// Unload the specified grammar from the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ActivateGrammarL( const TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::ActivateGrammarL()" );
+
+    iRecognitionAlgMgr->ActivateGrammarL( aGrammarID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::DeactivateGrammarL
+// Unload the specified grammar from the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::DeactivateGrammarL( const TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::DeactivateGrammarL()" );
+
+    iRecognitionAlgMgr->DeactivateGrammarL( aGrammarID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSRecognitionAlgMgr::GetGrammar
+// Find grammar based on identifier
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::GetGrammarL( const TSIGrammarID aGrammarID, 
+                                        CSICompiledGrammar** aSIActiveGrammar,
+                                        CSICompiledGrammar** aSIDeActivatedGrammar )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::GetGrammarL()" );
+
+    iRecognitionAlgMgr->GetGrammarL( aGrammarID, 
+                                     aSIActiveGrammar,
+                                     aSIDeActivatedGrammar );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::UnloadRule
+// Request to unload rule.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::UnloadRule( TSIGrammarID aGrammarID,
+                                       TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::UnloadRule()" );
+
+    iRecognitionAlgMgr->UnloadRule( aGrammarID, aRuleID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadEngineParametersL
+// Load the specified recognizer parameter(s).
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadEnginePropertiesL( const RArray<TInt>& aParameterId,
+                                                  const RArray<TInt>& aParameterValue )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::LoadEnginePropertiesL()" );
+
+    // Check that parameter ids are valid, settable values
+    for ( TInt i = 0; i < aParameterId.Count(); i++ )
+        {
+        if ( ( aParameterId[i] != KDevASRSendFeatures ) && 
+             ( aParameterId[i] != KDevASRAdaptation ) )
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }
+    iRecognitionAlgMgr->LoadEnginePropertiesL( aParameterId, aParameterValue );
+    iVMAlgorithmManager->LoadEnginePropertiesL( aParameterId, aParameterValue );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadLexiconL
+// Load the specified lexicion into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadLexiconL( const CSILexicon& aLexicon )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::LoadLexiconL()" );
+
+    iSILexicon = &aLexicon;
+
+    iRecognitionAlgMgr->LoadLexiconL( aLexicon );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadModelsL
+// Load the specified models into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadModelsL( const CSIModelBank& aModels )
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::LoadModelsL()" );
+
+    iSIModelBank = &aModels;
+
+    iRecognitionAlgMgr->LoadModelsL( aModels );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::UtteranceData
+// Get the recorded audio data accumulated during training.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::GetUtteranceData( TDes8* /*aBuffer*/, 
+                                             TTimeIntervalMicroSeconds32& /*aDuration*/ )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::GetUtteranceData()" );
+    // Not supported
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::HandlePlay
+// Asynchronously handles the play request.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::HandlePlayL()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::HandlePlayL()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::StartRecognition
+// Request to begin recording.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::StartRecognition( TTimeIntervalMicroSeconds32 aRecordDuration )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::StartRecognition()" );
+
+    iEndFlag = EFalse;
+    iRecordDuration = aRecordDuration;
+    iRequestFunction = KRecord;
+    Ready( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::PreStartSamplingL
+// Pre-starts sampling
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::PreStartSamplingL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+#ifdef __FULLDUPLEX_CHANGE
+    InitializeDevSoundL();
+    StartDevSoundL();
+    iPreSamplingStarted = ETrue;
+#endif // __FULLDUPLEX_CHANGE
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::StopRecognition
+// Request to stop recording.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::StopRecognition()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::StopRecognition()" );
+
+    iEndFlag = ETrue;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::HandleRecord
+// Asynchronously handles the recording request.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::HandleRecordL()
+    {
+    RUBY_DEBUG_BLOCK( "CSRSAlgorithmManager::HandleRecordL()" );
+
+    if ( StateTransition( EDASRSampling ) ) // Attempt to change state
+        {
+        // Allocate a buffer big enough for recording.
+
+        if ( iRecordDuration.Int() == 0 )
+            {
+            iOverallLength = 0;
+            }
+        else
+            {
+            TInt bytesPerSecond = ( TInt ) ( iResourceHandler->iSamplingRate * ( iResourceHandler->iBitsPerSample / 8 ) );
+            iOverallLength = ( TInt) ( iRecordDuration.Int() * 0.000001 * bytesPerSecond );
+            }
+
+        iOverallSampled = 0;
+
+        TInt err = KErrNone;
+
+
+        // Start the devSound only if client does not provide utterance data.
+        if ( iMode == ESiRecognition )
+            {
+#ifdef __FULLDUPLEX_CHANGE
+            if ( !iPreSamplingStarted )
+                {
+                TRAP( err, StartDevSoundL() );
+                }
+#else            
+            iDevSound->SetPrioritySettings( iPrioritySettings );
+            TRAP( err, iDevSound->RecordInitL() );
+#endif // __FULLDUPLEX_CHANGE
+
+            // Mark that recognition should be started when first buffer arrives
+            iStartRecognition = ETrue;
+            }
+        else
+            {
+            TRAPD ( error, iRecognitionAlgMgr->StartRecognitionL() );
+            if ( error != KErrNone )
+                {
+                iRecognitionAlgMgr->Cancel();
+                StateTransition( EDASRIdle );
+                iDevASRObserver->DevASREvent( EDevASRRecord, error );
+                }
+            }
+
+        if ( err == KErrNone )
+            {
+            iDevSoundState = ESoundDeviceRecord;
+            iDevASRObserver->DevASREvent( EDevASRRecordStarted, KErrNone );
+            
+            // Empty audio buffer queue if there happens to be some garbage 
+            // from previous recognition.
+            while ( !iAudioBufferQue->IsEmpty() )
+                {
+                iQueItem = iAudioBufferQue->First();
+                iAudioBufferQue->Remove( *iQueItem );
+                delete iQueItem;
+                iQueItem = NULL;
+                }
+            delete iBufferUnderConstruction;
+            iBufferUnderConstruction = NULL;
+            iConstructionPoint = 0;
+            iPendingRequestSpeechData = EFalse;
+            }
+        else
+            {
+            RUBY_DEBUG1( "RecordInitL() Error: %d", err );
+            iRecognitionAlgMgr->Cancel();
+            StateTransition( EDASRIdle );
+            iDevASRObserver->DevASREvent( EDevASRRecord, err );
+            }
+        }
+    else // Wrong state to handle this request
+        {
+        iDevASRObserver->DevASREvent( EDevASRRecord, KErrAsrInvalidState );
+        
+        RUBY_DEBUG1( "HandleRecord in wrong state: %d", iDevASRState );
+        }
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::StartRecSession
+// Signal the start of a recognition sesion.
+// -----------------------------------------------------------------------------
+//
+TInt CSRSAlgorithmManager::StartRecSession( TRecognizerMode aMode )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::StartRecSession()" );
+
+    TInt err( KErrNone );
+
+#ifdef __FULLDUPLEX_CHANGE
+    if ( !iPreSamplingStarted )
+        {
+        TRAP( err, InitializeDevSoundL() );
+        }
+#else
+    TRAP( err, InitializeDevSoundL() );
+#endif // __FULLDUPLEX_CHANGE
+
+    if ( err == KErrNone )
+        {
+        iMode = aMode;
+
+        err = iRecognitionAlgMgr->StartRecSession( aMode );
+        if ( err == KErrNone )
+            {
+            StateTransition( EDASRPreRecognition );
+            }
+        }
+
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::EndRecSession
+// Signal the end of a recognition sesion.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::EndRecSession()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::EndRecSession()" );
+
+    iRecognitionAlgMgr->EndRecSession();
+    StateTransition( EDASRIdle );
+    if ( iDevASRState == EDASRIdle )
+        {
+	    iSIModelBank = NULL;
+		iSILexicon = NULL;
+        }
+    
+    delete iDevSound;
+    iDevSound = NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::SendSpeechData
+// Gives data buffer to recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::SendSpeechData( TPtrC8& aBuffer, TBool aEnd )
+    {
+    if ( iMode == ESiRecognitionSpeechInput )
+        {
+        iRecognitionAlgMgr->SendSpeechData( aBuffer, aEnd );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::Cancel
+// Cancels the current and any on going requests/tasks.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::Cancel()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::Cancel()" );
+
+    iVMAlgorithmManager->Cancel();
+
+    iRecognitionAlgMgr->Cancel();
+
+    if( iDevASRState != EDASRIdle )
+    	{
+        //StateTransition( EDASRPreRecognition );
+        // Force to pre recognition state
+        iDevASRState = EDASRPreRecognition;
+    	}
+
+    if ( iDevSoundState != ESoundDeviceNotInitialized )
+    	{
+        RUBY_DEBUG0( "CSRSAlgorithmManager::Cancel(), Stopping DevSound..." );
+
+        if ( iMode == ESiRecognition )
+            {
+            if ( iDevSound )
+                {
+                iDevSound->Stop();
+                }
+            }
+		iDevSoundState = ESoundDeviceStopped;
+    	}
+
+    CActive::Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRecognitionAlgMgr::DoCancel
+// Cancels the current and any on going CActive requests/tasks.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::DoCancel()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::DoCancel()" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::EmptyBuffer
+// Copies the contents of the received buffer to the holding buffer. Subsequent
+// call to EmptyBuffer will append to existing buffer.
+// -----------------------------------------------------------------------------
+//
+TInt CSRSAlgorithmManager::EmptyBuffer( CMMFDataBuffer& aBuffer,
+                                        TInt aBufferLength )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::EmptyBuffer(): Len=%d bytes", aBufferLength );
+
+    TInt i = 0;
+    TInt status = KErrNone;
+    TBool iBufferCreated = EFalse;
+#ifdef __WINS__
+    TInt KNumberOfBuffers = iResourceHandler->iBuffersInWins;
+#else
+    TInt KNumberOfBuffers = iResourceHandler->iBuffersInThumb;
+#endif
+
+    TDes8& ReceivedData = aBuffer.Data();
+    TInt iSize = ReceivedData.Length();
+
+#ifdef __FULLDUPLEX_CHANGE
+    // If state is not EDASRSampling, then end immediately
+    // Samples will be negelected until real recognition starts
+    if ( iDevASRState != EDASRRecognitionSampling )
+        {
+        iDevSound->RecordData();
+        return status;
+        }
+    else
+        {
+        // Reset pre-sampling flag
+        iPreSamplingStarted = EFalse; 
+        }
+#endif // __FULLDUPLEX_CHANGE
+
+    // If DevSound has not filled the whole buffer, something 
+    // is wrong in the sampling
+    if( aBufferLength < ReceivedData.MaxLength() )
+        {
+        status = KErrEof;
+        }
+
+    // iOverallLength checks how much is sampled during all the callbacks
+    if ( iOverallLength != 0 )
+        {
+        if ( iOverallSampled >= iOverallLength )
+            {
+            status = KErrOverflow;
+            }
+        }
+
+    TInt silentFrames = iResourceHandler->iSilenceFrames;
+
+    // Create new buffer if previous one has been queued
+    if ( iBufferUnderConstruction == NULL )
+        {
+        iBufferUnderConstruction = new TUint8[ iSize * KNumberOfBuffers ];
+        if ( !iBufferUnderConstruction )
+            {
+            return KErrNoMemory;
+            }
+        iConstructionPoint = 0;
+        }
+
+    // Copy data, put silence into the beginning of buffer if needed
+    for ( i = 0; i < iSize; i++ )
+        {
+        if ( ( iOverallSampled + i ) < silentFrames )
+            {
+            // Do not copy zeros
+            //iBufferUnderConstruction[ iConstructionPoint ] = 0;
+            }
+        else
+            {
+            iBufferUnderConstruction[ iConstructionPoint ] = ReceivedData[ i ];
+            iConstructionPoint++;
+            }
+        }
+
+    // Count the number of sampled bytes
+    iOverallSampled = iOverallSampled + iSize;
+
+    // If internal buffer overflowed or EOF, mark this the final block of data
+    // Mark as the final block also if EndRecord() has been explicitly called
+    if ( ( status == KErrOverflow ) || ( status == KErrEof ) || iEndFlag )
+        {
+        CQueItem* qItem( NULL );
+        TRAPD( err, qItem = CQueItem::NewL( &iBufferUnderConstruction[0], iConstructionPoint ) );
+        if ( err != KErrNone )
+            {
+            return err;
+            }
+        qItem->iFinalBlock = ETrue;
+        iEndFlag = EFalse;
+        iAudioBufferQue->AddLast( *qItem );
+        iBufferUnderConstruction = NULL;
+        iConstructionPoint = 0;
+        iBufferCreated = ETrue;
+
+        RUBY_DEBUG0( "CSRSAlgorithmManager::EmptyBuffer(): Sampling ended due to timeout!!" );
+        }
+    else
+        {
+        // Notify devsound
+        iDevSound->RecordData();
+
+        // If next buffer does not fit to the buffer under construction
+        // put it to queue and start new when next callback arrives
+        if ( iConstructionPoint + iSize > iSize * KNumberOfBuffers )
+            {
+            // Put data to queue
+            CQueItem* qItem( NULL );
+            TRAPD( err, qItem = CQueItem::NewL( &iBufferUnderConstruction[0], iConstructionPoint ) );
+            if ( err != KErrNone )
+                {
+                return err;
+                }
+            qItem->iFinalBlock = EFalse;
+            iAudioBufferQue->AddLast( *qItem );
+            iBufferCreated = ETrue;
+            }
+        }
+
+    if ( iBufferCreated )
+        {
+
+#ifdef AUDIOBUFFER_TO_FILE
+        TInt connectError = iFs.Connect();
+        if ( connectError != KErrNone )
+            {
+            return connectError;
+            }
+        _LIT( KBufferFileName, "C:\\documents\\devasraudiobuffer.raw" );
+        if ( !iFileCreated )
+            {
+            iBufferDataFile.Replace( iFs, KBufferFileName, EFileWrite );
+            iFileCreated = ETrue;
+            }
+        else
+            {
+            TInt openError = iBufferDataFile.Open( iFs, KBufferFileName, EFileWrite );
+            if ( openError != KErrNone )
+                {
+                return openError;
+                }
+            }
+        
+        TPtr8 ptr( &iBufferUnderConstruction[0], iConstructionPoint, iConstructionPoint );
+        TInt pos = 0;
+        iBufferDataFile.Seek( ESeekEnd, pos );
+        iBufferDataFile.Write( pos, ptr );
+        iBufferDataFile.Close();
+        iFs.Close();
+#endif
+
+        iBufferUnderConstruction = NULL;
+        iConstructionPoint = 0;
+        
+        // Start recognition if it has not been already started
+        if ( iStartRecognition )
+            {
+            TRAP( status, iRecognitionAlgMgr->StartRecognitionL() );
+            iStartRecognition = EFalse;
+            }
+        
+        // If RequestSpeechData() gets called when there is no data in queue, we
+        // should call it again to deliver the new data to recognizer
+        if ( iPendingRequestSpeechData )
+            {
+            iPendingRequestSpeechData = EFalse;
+            RequestSpeechData();
+            }
+        }
+    
+    return status;
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::FillBuffer
+// Copies a portion of the holding buffer to the received buffer.
+// -----------------------------------------------------------------------------
+//
+TInt CSRSAlgorithmManager::FillBuffer( CMMFDataBuffer& /*aBuffer*/, 
+                                       TInt /*aBufferLength*/ )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::FillBuffer()" );
+
+    return KErrNotSupported;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::SetPrioritySettings
+// Store the priority setting for the sound device.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings )
+    {
+    iPrioritySettings = aPrioritySettings;
+    // Always use preference meant for recognition
+    iPrioritySettings.iPref = ( TMdaPriorityPreference ) KAudioPrefVocosRecog;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::InitializeDevSoundL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::InitializeDevSoundL()
+    {
+    if ( !iDevSound )
+        {
+        // Instance
+        iDevSound = CMMFDevSound::NewL();
+        }
+    
+    // Initialization        
+    iDevSound->InitializeL( *this, EMMFStateRecording );
+    
+    // Wait for initialization callback
+    if ( !iAudioWait.IsStarted() )
+        {
+        iAudioWait.Start();
+        }    
+
+    // Configuration
+    ConfigureSoundDeviceL();
+    }
+        
+        
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::StartDevSoundL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::StartDevSoundL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    iDevSound->SetPrioritySettings( iPrioritySettings );
+    iDevSound->RecordInitL();
+    iDevSoundState = ESoundDeviceRecord;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::StateTransition
+// Change to the specified state if possible. If state change is invalid,
+// EFalse is returned, otherwise, ETrue.
+// -----------------------------------------------------------------------------
+//
+TBool CSRSAlgorithmManager::StateTransition( TDevASRState aTargetState )
+    {
+
+    TBool result = ETrue;
+
+#ifdef _DEBUG
+    DevASRState();
+#endif
+
+    switch ( aTargetState )
+        {
+        case EDASRIdle:
+            iDevASRState = aTargetState;
+            break;
+
+        case EDASRInitTrain:
+            if ( iDevASRState == EDASRIdle )
+                {
+                iDevASRState = aTargetState;
+                }
+            else
+                {
+                result = EFalse;
+                }
+            break;
+
+        case EDASRTrain:
+            if ( ( iDevASRState == EDASRTrain ) ||
+                ( iDevASRState == EDASRInitTrain ) ||
+                ( iDevASRState == EDASRTrainSampling ) )
+                {
+                iDevASRState = aTargetState;
+                }
+            else
+                {
+                result = EFalse;
+                }
+            break;
+
+        case EDASRSampling:
+            if ( iDevASRState == EDASRTrain )
+                {
+                iDevASRState = EDASRTrainSampling;
+                }
+            else if ( iDevASRState == EDASRRecognition )
+                {
+                iDevASRState = EDASRRecognitionSampling;
+                }
+            else
+                {
+                result = EFalse;
+                }
+            break;
+
+        case EDASRPlayback:
+            if ( iDevASRState == EDASRIdle )
+                {
+                iDevASRState = EDASRPlayback;
+                }
+            else if ( iDevASRState == EDASRPreRecognition )
+                {
+                iDevASRState = EDASRRecognitionPlayback;
+                }
+            else
+                {
+                result = EFalse;
+                }
+            break;
+
+        case EDASRPreRecognition:
+            if ( ( iDevASRState == EDASRIdle ) ||
+                ( iDevASRState == EDASRRecognition ) ||
+                ( iDevASRState == EDASRRecognitionPlayback ) )
+                {
+                iDevASRState = aTargetState;
+                }
+            else
+                {
+                result = EFalse;
+                }
+            break;
+
+        case EDASRRecognitionPlayback:
+            if (iDevASRState == EDASRPreRecognition)
+                {
+                iDevASRState = aTargetState;
+                }
+            else
+                {
+                result=EFalse;
+                }
+            break;
+
+        case EDASRInitRecognition:
+            if ((iDevASRState == EDASRInitRecognition) ||
+                (iDevASRState == EDASRPreRecognition))
+                {
+                iDevASRState = aTargetState;
+                }
+            else
+                {
+                result=EFalse;
+                }
+            break;
+
+        case EDASRRecognition:
+            if ( ( iDevASRState == EDASRInitRecognition ) ||
+                ( iDevASRState == EDASRRecognitionSampling ) )
+                {
+                iDevASRState = aTargetState;
+                }
+            else
+                {
+                result = EFalse;
+                }
+            break;
+
+        case EDASRCancel:
+            break;
+
+        default:
+            RUBY_DEBUG1( "Invalid state: %d", aTargetState );
+            break;
+        };
+
+#ifdef _DEBUG
+    DevASRState();
+    iRecognitionAlgMgr->AlgorithmState();
+#endif
+    return result;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::TranslateError
+// Translate internal errors to system errors
+// -----------------------------------------------------------------------------
+//
+TInt CSRSAlgorithmManager::TranslateError( TInt aError )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::TranslateError(%d)", aError );
+
+    TInt error = aError;
+
+     switch ( aError )
+        {
+        case KErrTooEarly:
+            error = KErrAsrSpeechTooEarly;
+            break;
+        case KErrNoSpeech:
+            error = KErrAsrNoSpeech;
+            break;
+        case KErrTooLong:
+            error = KErrAsrSpeechTooLong;
+            break;
+        case KErrTooShort:
+            error = KErrAsrSpeechTooShort;
+            break;
+        default:
+            RUBY_DEBUG1( "Unmapped Error: %d", aError );
+            break;
+        };
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DevSound Observer MIXIN implementation begins
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::InitializeComplete
+// Initialization of DevSound is complete.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::InitializeComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "InitializeComplete[%d]", aError );
+
+    if ( aError == KErrNone  )
+        {
+		iDevSoundState = ESoundDeviceInitialized;
+		}
+		
+    // Free wait loop
+    if ( iAudioWait.IsStarted() )
+        {
+        iAudioWait.AsyncStop();
+        }                       
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ToneFinished
+// Finished playing tones
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ToneFinished( TInt /*aError*/ )
+    {
+    // Should never be called because no tone services is required.
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::BufferToBeFilled
+// Buffer from DevSound to be filled with audio data.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::BufferToBeFilled( CMMFBuffer* aBuffer )
+    {
+    CMMFDataBuffer* buffer = STATIC_CAST( CMMFDataBuffer*, aBuffer );
+
+    if ( FillBuffer( *buffer, aBuffer->RequestSize() ) == KErrNone )
+        {
+        iDevSound->PlayData();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::PlayError
+// Playing of an audio sample has completed successfully or otherwise.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::PlayError( TInt aError )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::PlayError[%d]", aError );
+
+    if ( iDevASRState != EDASRIdle )
+		{
+
+		if ( iDevASRState == EDASRRecognitionPlayback )
+			{
+			StateTransition( EDASRPreRecognition );
+			}
+		else
+			{
+			StateTransition( EDASRIdle );
+			}
+
+		if ( aError == KErrUnderflow )
+			{
+			iDevASRObserver->DevASREvent( EDevASRPlay, KErrNone );
+			}
+		else
+			{
+			iDevASRObserver->DevASREvent( EDevASRPlay, aError );
+			}
+
+		}
+
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::BufferToBeEmptied
+// An audio buffer is ready to be emptied.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::BufferToBeEmptied( CMMFBuffer* aBuffer )
+    {
+    RUBY_DEBUG0( "" );    
+    if ( iDevASRState == EDASRIdle && !iPreSamplingStarted )
+        {
+        RUBY_DEBUG0( "stopping devsound" );
+        iDevSound->Stop();
+		iDevSoundState = ESoundDeviceStopped;
+        return;
+        }
+
+    RUBY_DEBUG0( "processing callback" );
+    CMMFDataBuffer* buffer = STATIC_CAST( CMMFDataBuffer*, aBuffer );
+	EmptyBuffer( *buffer, aBuffer->RequestSize() );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::RecordError
+// Recording has completed successfully or otherwise.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::RecordError( TInt aError )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::RecordError[%d]", aError );
+
+    iPreSamplingStarted = EFalse;
+    iRecognitionAlgMgr->Cancel();
+    StateTransition( EDASRIdle );
+    iDevASRObserver->DevASREvent( EDevASRRecord, aError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ConvertError
+// Conversion has completed successfully or otherwise.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ConvertError( TInt /*aError*/ )
+    {
+    // This method should never be called.
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::RecordError
+// Callback for custom commands
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::DeviceMessage( TUid /*aMessageType*/, 
+                                          const TDesC8& /*aMsg*/ )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::DeviceMessage" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::SendEventToClient
+// Receives and event from DevSound send it to the appropriate handler.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::SendEventToClient( const TMMFEvent& aEvent )
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::SendEventToClient()" );
+
+	if ( aEvent.iErrorCode != KErrNone )
+		{
+		if ( iDevSoundState == ESoundDeviceRecord )
+			{
+			RecordError( aEvent.iErrorCode );
+			}
+		else if ( iDevSoundState == ESoundDevicePlayback )
+			{
+			PlayError( aEvent.iErrorCode );
+			}
+		}
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// DevSound Observer MIXIN impl ends
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// RecognitionAlgMgr Observer MIXIN implementation begins
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::AdaptComplete
+// Model adaptation has finished.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::AdaptComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::AdaptComplete(%d)", aResultCode );
+
+    iDevASRObserver->DevASREvent( EDevASRAdapt, aResultCode );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::InitFEComplete
+// Initialization of frontend algorithm has completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::InitFEComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::InitFEComplete(%d)", aResultCode );
+
+    // Ignore events if we're idle.
+    if ( ( iDevASRState == EDASRInitTrain ) || ( iDevASRState == EDASRInitRecognition ) )
+        {
+        if ( aResultCode == KErrNone )
+            {
+            if ( iDevASRState == EDASRInitTrain )
+                {
+                iDevASRState = EDASRTrain;
+                }
+            else if ( iDevASRState == EDASRInitRecognition )
+                {
+                iDevASRState = EDASRRecognition;
+                }
+            iDevASRObserver->DevASREvent( EDevASRInitFrontend, aResultCode );
+            }
+        else
+            {
+            StateTransition( EDASRIdle );
+            iDevASRObserver->DevASREvent( EDevASRInitFrontend, TranslateError( aResultCode ) );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::InitRecognizerBEComplete
+// Initialization of backend algorithm for recognition has completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::InitRecognizerBEComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::InitRecognizerBEComplete(%d)", aResultCode );
+
+    if ( StateTransition( EDASRInitRecognition ) )
+        {
+        if ( aResultCode == KErrNone )
+            {
+            iDevASRObserver->DevASREvent( EDevASRInitRecognitionBackend, aResultCode );
+            }
+        else
+            {
+            StateTransition( EDASRIdle );
+            iDevASRObserver->DevASREvent( EDevASRInitRecognitionBackend, TranslateError( aResultCode ) );
+            }
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadGrammarComplete
+// Loading of grammar into recognizer has completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadGrammarComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::LoadGrammarComplete(%d)", aResultCode );
+
+	TDevASREvent event = EDevASRLoadGrammar;
+    
+    if ( aResultCode == KErrNone )
+        {
+        iDevASRObserver->DevASREvent( event, aResultCode );
+        }
+    else
+        {
+        //StateTransition( EDASRIdle );
+        iDevASRObserver->DevASREvent( event, TranslateError( aResultCode ) );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::UnloadGrammarComplete
+// Grammar has beed unloaded.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::UnloadGrammarComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::UnloadGrammarComplete(%d)", aResultCode );
+
+	TDevASREvent event = EDevASRUnloadGrammar;
+    
+    if ( aResultCode == KErrNone )
+        {
+        iDevASRObserver->DevASREvent( event, aResultCode );
+        }
+    else
+        {
+        iDevASRObserver->DevASREvent( event, TranslateError( aResultCode ) );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::ActivateGrammarComplete
+// Grammar activation has been completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::ActivateGrammarComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::ActivateGrammarComplete(%d)", aResultCode );
+
+    if ( iDevASRState == EDASRPreRecognition )
+        {
+        iDevASRObserver->DevASREvent( EDevASRActivateGrammar, aResultCode );
+        }  
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::DeActivateGrammarComplete
+// Grammar deactivation has been completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::DeActivateGrammarComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::DeActivateGrammarComplete(%d)", aResultCode );
+
+    if ( iDevASRState == EDASRPreRecognition )
+        {
+        iDevASRObserver->DevASREvent( EDevASRDeactivateGrammar, aResultCode );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadLexiconComplete
+// Loading of lexicon into recognizer has completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadLexiconComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::LoadLexiconComplete(%d)", aResultCode );
+    
+    if ( aResultCode == KErrNone )
+        {
+        iDevASRObserver->DevASREvent( EDevASRLoadLexicon, aResultCode );
+        }
+    else
+        {
+        //StateTransition( EDASRIdle );
+        iDevASRObserver->DevASREvent( EDevASRLoadLexicon, TranslateError( aResultCode ) );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::LoadModelsComplete
+// Loading of models into recognizer has completed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::LoadModelsComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::LoadModelsComplete(%d)", aResultCode );
+    
+    if ( aResultCode == KErrNone )
+        {
+        iDevASRObserver->DevASREvent( EDevASRLoadModels, aResultCode );
+        }
+    else
+        {
+        //StateTransition( EDASRIdle );
+        iDevASRObserver->DevASREvent( EDevASRLoadModels, TranslateError( aResultCode ) );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::RequestSpeechData
+// Speech data is needed.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::RequestSpeechData()
+    {
+    RUBY_DEBUG0( "CSRSAlgorithmManager::RequestSpeechData()" );
+
+    if ( iMode == ESiRecognitionSpeechInput )
+        {
+        iDevASRObserver->RequestSpeechData();
+        }
+    else
+        {
+        // The processed sample descriptor can be deleted
+        delete iQueItem; 
+        iQueItem = NULL;
+        
+        if ( ( iDevASRState == EDASRTrainSampling ) || ( iDevASRState == EDASRRecognitionSampling ) )
+            {
+            // Check if there's more data to send and if so, send the next block of data
+            if ( iAudioBufferQue->IsEmpty() )
+                {
+                iPendingRequestSpeechData = ETrue;
+                iProcessingUtterance = EFalse;
+                }
+            else
+                {
+                iQueItem = iAudioBufferQue->First();
+                iRecognitionAlgMgr->SendSpeechData( iQueItem->iDataBlock, iQueItem->iFinalBlock );
+                iAudioBufferQue->Remove( *iQueItem );
+                }        
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::FeatureVectorDataRcvd
+// Feature vector data received from frontend.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::FeatureVectorDataRcvd( const TDesC8& aFV,
+                                                  TInt32 aSNR,
+                                                  TInt32 aPosition )
+    {
+    iDevASRObserver->FeatureVectorDataRcvd( aFV, aSNR, aPosition );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::EouDetected
+// Frontend finished extracting feature vectors from PCM data.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::EouDetected( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::EouDetected(%d)", aResultCode );
+
+    if ( iDevASRState == EDASRTrainSampling )
+        {
+        
+        if ( aResultCode != KErrNone )
+            {
+            RUBY_DEBUG1( "CSRSAlgorithmManager::EouDetected(): Training ERROR %d", aResultCode );
+
+            StateTransition( EDASRIdle );
+            iDevSound->Stop();
+            iDevSoundState = ESoundDeviceStopped;
+            iDevASRObserver->DevASREvent( EDevASRTrain, TranslateError( aResultCode ) );
+            return;
+            }
+        
+        // If we fail to get the utterance duration, there's probably not enough frames to calculate
+        // utterance duration. We will fail training with "too short".
+        if ( !iRecognitionAlgMgr->GetUtteranceDuration(iStartFrame, iEndFrame, iFrameLength) )
+            {
+            StateTransition(EDASRIdle);
+            iDevSound->Stop();
+            iDevSoundState = ESoundDeviceStopped;
+            iDevASRObserver->DevASREvent( EDevASRTrain, KErrAsrSpeechTooShort );
+            return;
+            }
+        
+        RUBY_DEBUG1( "Start frame: %d", iStartFrame );
+        RUBY_DEBUG1( "End frame: %d", iEndFrame );
+        RUBY_DEBUG1( "Frame Length: %f", iFrameLength );
+
+        // Now, calculate the start and end point in the audio buffer for encoding
+        
+        RUBY_DEBUG1( "Padding start frames: %d", iResourceHandler->iPadStartFrames );
+
+        // Pad additional frame to start and end to prevent clipping during utterance playback.
+        
+        if( (iStartFrame - iResourceHandler->iPadStartFrames) <= 0 )
+            {
+            iStartFrame = 0;
+            }
+        else
+            {
+            iStartFrame = iStartFrame - iResourceHandler->iPadStartFrames;
+            }
+        
+        iBufferStartPoint = (TUint32)(iStartFrame * iFrameLength * iResourceHandler->iSamplingRate * 2);
+        
+        RUBY_DEBUG1( "Padding start frames: %d", iResourceHandler->iPadEndFrames );
+
+        iBufferEndPoint = (TUint32)((iEndFrame + iResourceHandler->iPadEndFrames) * iFrameLength *
+            iResourceHandler->iSamplingRate * 2);
+        
+        if ( iBufferEndPoint >= iStartPoint - 1 ) // Do not pad beyond recorded point
+            {
+            iBufferEndPoint = iStartPoint - 1; // Set to the last byte recorded
+            }
+        
+        if ( iBufferEndPoint > iStopPoint ) // Cannot pad more than buffer size allows
+            {
+            iBufferEndPoint = iStopPoint;
+            }
+        
+        StateTransition(EDASRTrain);
+        iDevSound->Stop();
+        iDevSoundState = ESoundDeviceStopped;
+        }
+    
+    // It is possible that the frontend has completed processing while the audio
+    // buffer is not yet full.
+    // The recording can be stopped as the frontend has detected end of utterance.
+    
+    else if ( iDevASRState == EDASRRecognitionSampling )
+        {
+        
+        if ( ( aResultCode != KErrNone ) && ( aResultCode != KErrTooLong ) )
+            {
+            RUBY_DEBUG1( "CSRSAlgorithmManager::EouDetected(): Recognition ERROR %d", aResultCode );
+
+            StateTransition( EDASRIdle );
+            iRecognitionAlgMgr->Cancel();
+            iDevSound->Stop();
+            iDevASRObserver->DevASREvent( EDevASRRecognize, TranslateError( aResultCode ) );
+            return;
+            }
+        
+        StateTransition( EDASRRecognition );
+      
+        iDevSound->Stop();
+       
+        iDevSoundState = ESoundDeviceStopped;
+        }
+    else // We are in the wrong state to handle this event
+        {
+        RUBY_DEBUG0( "CSRSAlgorithmManager::EouDetected(): WRONG STATE" );
+        return;
+        }
+    
+    iDevASRObserver->DevASREvent( EDevASREouDetected, KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::TrainComplete
+// The training backend has finished processing feature vectors. A Model is
+// created.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::TrainComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::TrainComplete(%d)", aResultCode );
+
+    if ( iDevASRState == EDASRTrain )
+        {
+        // Training is complete, DevASR can return to Idle state.
+        StateTransition( EDASRIdle );
+
+        iDevASRObserver->DevASREvent( EDevASRTrain, TranslateError( aResultCode ) );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::UnloadRuleComplete
+// Rule has been blacklisted successfully or otherwise.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::UnloadRuleComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::UnloadRuleComplete(%d)", aResultCode );
+    
+    iDevASRObserver->DevASREvent( EDevASRUnloadRule, aResultCode );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::RecognitionComplete
+// The recognition backend has finished processing feature vectors. A recognition
+// result is created.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::RecognitionComplete( TInt aResultCode )
+    {
+    RUBY_DEBUG1( "CSRSAlgorithmManager::RecognitionComplete(%d)", aResultCode );
+
+    // Recognition is complete, DevASR can return to pre-recognition state
+    if ( StateTransition( EDASRPreRecognition ) )
+        {
+        // Mark that sampling can be ended if not stopped yet
+        iEndFlag = ETrue;
+		iDevASRObserver->DevASREvent( EDevASRRecognize, TranslateError( aResultCode ) );
+        }
+    else
+        {
+        if ( iDevASRState == EDASRRecognitionSampling )
+            {
+            StateTransition( EDASRRecognition );
+            iDevSound->Stop();
+			iDevSoundState = ESoundDeviceStopped;
+            iDevASRObserver->DevASREvent( EDevASREouDetected, KErrNone );
+            StateTransition( EDASRPreRecognition );
+            iDevASRObserver->DevASREvent( EDevASRRecognize, TranslateError( aResultCode ) );
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// RecAlgMgr Observer MIXIN impl ends
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// MVmAlgMgrObserver MIXIN impl starts
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::CombineComplete
+// Grammar combination is ready.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::CombineComplete( HBufC8* aResult, TInt aError )
+    {
+    // Forward call to reco alg manager
+    iRecognitionAlgMgr->CombineComplete( aResult, aError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// MVmAlgMgrObserver MIXIN impl ends
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// Active object implementation begins
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::RunL
+// Handle the requested function asynchronously.
+// result is created.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::RunL()
+    {
+
+    switch ( iRequestFunction )
+        {
+        case KRecord:
+            TRAPD( err, HandleRecordL() );
+            if ( err )
+                {
+                iRecognitionAlgMgr->Cancel();
+                StateTransition( EDASRIdle );
+                iDevASRObserver->DevASREvent( EDevASRRecord, TranslateError( err ) );
+                }
+            break;
+
+        case KPlay:
+
+            TRAPD( err1, HandlePlayL() );
+            if ( err1 )
+                {
+                StateTransition( EDASRIdle );
+                iDevASRObserver->DevASREvent( EDevASRPlay, TranslateError( err1 ) );
+                }
+            break;
+
+        default:
+            break;
+        };
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::Ready
+// Utility function to post a request complete.
+// result is created.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::Ready( const TInt aStatus )
+    {
+    TRequestStatus* stat = &iStatus;
+    User::RequestComplete( stat, aStatus );
+    SetActive();
+    }
+
+
+// -----------------------------------------------------------------------------
+// Active object impl ends
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// CSRSAlgorithmManager::DevASRState
+// Utility function print out the state of DevASR for unit testing.
+// result is created.
+// -----------------------------------------------------------------------------
+//
+void CSRSAlgorithmManager::DevASRState()
+    {
+
+#ifdef _DEBUG
+    switch ( iDevASRState )
+        {
+        case EDASRIdle:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRIdle", iDevASRState );
+            break;
+
+        case EDASRInitTrain:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRInitTrain", iDevASRState );
+            break;
+
+        case EDASRTrain:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRTrain", iDevASRState );
+            break;
+
+        case EDASRRecognitionSampling:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRRecognitionSampling", iDevASRState );
+            break;
+
+        case EDASRTrainSampling:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRTrainSampling", iDevASRState );
+            break;
+
+        case EDASRPlayback:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRPlayback", iDevASRState );
+            break;
+
+        case EDASRPreRecognition:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRPreRecognition", iDevASRState );
+            break;
+
+        case EDASRRecognitionPlayback:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRRecognitionPlayback", iDevASRState );
+            break;
+
+        case EDASRInitRecognition:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRInitRecognition", iDevASRState );
+            break;
+
+        case EDASRRecognition:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRRecognition", iDevASRState );
+            break;
+
+        case EDASRCancel:
+            RUBY_DEBUG1( "DevASR is: [%d] - EDASRCancel", iDevASRState );
+        default:
+            RUBY_DEBUG1( "DevASR is: [%d] - Unknown", iDevASRState );
+            break;
+        };
+#endif
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrsrsalgorithmmanager.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,773 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definition of the DevASR private interface.
+*
+*/
+
+
+#ifndef DEVASRSRSALGORITHMMANAGER_H
+#define DEVASRSRSALGORITHMMANAGER_H
+
+//#define AUDIOBUFFER_TO_FILE
+
+//  INCLUDES
+#include <sounddevice.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+#include <nssdevasrcommon.h>
+#include "devasrutil.h"
+#include "devasrrecognitionalgmgr.h"
+#include "devasrresourcehandler.h"
+#include "devasrvmalgorithmmanager.h"
+
+
+#ifdef AUDIOBUFFER_TO_FILE
+#include <f32file.h>
+#endif
+
+// DATA TYPES
+
+// Possible DevASR states
+enum TDevASRState
+    {
+    EDASRIdle,
+    EDASRInitTrain,
+    EDASRTrain,
+    EDASRSampling,
+    EDASRTrainSampling,
+    EDASRPlayback,
+    EDASRRecognitionPlayback,
+    EDASRPreRecognition,
+    EDASRInitRecognition,
+    EDASRRecognition,
+    EDASRRecognitionSampling,
+    EDASRCancel
+    };
+
+// Possible DevSound States
+enum TDevSoundState
+    {
+    ESoundDeviceNotInitialized,
+    ESoundDeviceInitialized,
+    ESoundDeviceRecord,
+    ESoundDevicePlayback,
+    ESoundDeviceStopped
+    };
+
+// FORWARD DECLARATIONS
+class MDevASRObserver;
+class CRecognitionAlgMgr;
+
+// CLASS DECLARATION
+
+/**
+*  Interface Class to be used by the DevASR thin client implementation.
+*
+*  @lib NssDevASR.lib
+*/
+class CSRSAlgorithmManager : public CActive, 
+                             public MDevSoundObserver, 
+                             public MRecAlgMgrObserver,
+                             public MVmAlgMgrObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructors.
+        */
+        static CSRSAlgorithmManager* NewL(MDevASRObserver& aObserver);
+        static CSRSAlgorithmManager* NewLC(MDevASRObserver& aObserver);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CSRSAlgorithmManager();
+        
+    public: // New functions
+            
+
+        /**
+        * Does grammar compilation.
+        */
+        void CompileGrammarL( CSICompiledGrammar& aGrammar );
+
+        /**
+        * Computes new grammar size with given number of variants.
+        */
+        void ComputeNewGrammarSizeL( const CSIGrammar& aGrammar, 
+                                     const TUint32 aTargetNRuleVariants, 
+                                     const TUint32 aMaxNRuleVariants, 
+                                     const RArray<TUint>& aNewRuleScores, 
+                                     RArray<TUint>& aNNeNRuleVariants, 
+                                     TUint32& aNPrune );
+
+        /**
+        * Prunes unnecessay rule variants away from grammar.
+        */
+        TBool PruneGrammar( const CSIGrammar& aGrammar, 
+                            const TUint32 aMinNumber, 
+                            RArray<TSIRuleVariantInfo>& aPrunedRuleVariants );
+
+        /**
+        * Starts speaker independent training from text.
+        */  
+        void StartTrainingFromTextL( CSITtpWordList& aWordList, 
+                                     const RArray<TLanguage>& aDefaultLanguage, 
+                                     const RArray<TUint32>& aMaxNPronunsForWord );
+
+
+
+        /**
+        * Adapts recognition models
+        *
+        * @param "CSIResultSet& aResultSet" Result set
+        * @param "TInt aResultIndex" Index of correct result
+        */
+        void AdaptL( const CSIResultSet& aResultSet, TInt aResultIndex );
+
+        /**
+        * Cancels the current or started tasks.
+        */
+        void Cancel();
+        
+        /**
+        * This method is used to indicate the end of a recognition session.
+        */
+        void EndRecSession();
+        
+        /**
+        * Retreive the properties of the underlying speech recognition engine.
+        *
+        * @param "RArray<TInt>& aPropertyId" An array of identifiers being 
+        *         querried.
+        * @param "RArray<TInt>& aPropertyValue" An array of values corresponding 
+        *        to the querried identifiers
+        */
+        void GetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+                                   RArray<TInt>& aPropertyValue );
+        
+        /**
+        * Initializes the front-end module in the speech recognition engine.
+        * The frontend module used during training/recognition functions is started
+        * as a result. This method is intended to be used in conjunction with InitTrainBE().
+        * 
+        * @param "TRecognizerMode aFeMode" Mode of the recognizer.
+        */
+        void InitFrontEnd( TRecognizerMode aFeMode );
+    
+        /**
+        * Initialize the recognition engine back-end. The module responsible for recognition
+        * function is started as a result. This method must be used before any recognition
+        * operations and intended to be used in conjunction with InitFrontEnd().
+        * 
+        * @param "CSIResultSet& aResult" A reference to an object where the 
+        *        recognition result will be written
+        */
+        void InitRecognizerBE( CSIResultSet& aResult );
+        
+        /**
+        * Load the specified recognizer parameter(s). These parameters are used to alter
+        * the recognizer's default parameters. The parameters are specified as attribute-value
+        * pairs.
+        * 
+        * @param "RArray<TInt>& aParameterId" An array of parameter identifiers.
+        * @param "RArray<TInt>& aParameterValue" An array of parameter values.
+        */
+        void LoadEnginePropertiesL( const RArray<TInt>& aParameterId,
+                                    const RArray<TInt>& aParameterValue );
+        
+        /**
+        * Load the specified grammar into the recognizer.
+        * 
+        * @param "aGrammar" A reference to a grammar in an internal format.
+        */
+        void LoadGrammarL( const CSIGrammar& aGrammar );
+        void LoadGrammarL( const CSICompiledGrammar& aGrammar );
+
+        /**
+        * Unloads the specified grammar from the recognizer.
+        * 
+        * @param "aGrammar" A reference to a grammar in an internal format.
+        */
+        void UnloadGrammarL( const CSIGrammar& aGrammar );
+        void UnloadGrammarL( const CSICompiledGrammar& aGrammar );
+
+        /**
+        * Activates a grammar
+        *
+        * @param "TSIGrammarID aGrammarID" A grammar identifier.
+        */
+        void ActivateGrammarL( TSIGrammarID aGrammarID );
+        
+        /**
+        * Deactivates a grammar
+        *
+        * @param "TSIGrammarID aGrammarID" A grammar identifier.
+        */
+        void DeactivateGrammarL( TSIGrammarID aGrammarID );
+        
+        /**
+        * Load the specified lexicon into the recognizer.
+        * 
+        * @param "aLexicon" A reference to a lexicon.
+        */
+        void LoadLexiconL( const CSILexicon& aLexicon );
+        
+        /**
+        * Load the specified models into the recognizer.
+        * 
+        * @param "aModels" A reference to a model bank.
+        */
+        void LoadModelsL( const CSIModelBank& aModels );
+        
+        /**
+        * Request to begin recording.
+        * 
+        * @param "TTimeIntervalMicroSeconds32 aRecordDuration" Length of time 
+        *        to record, expressed in microseconds.
+        */
+        void StartRecognition( TTimeIntervalMicroSeconds32 aRecordDuration );
+        
+        /**
+        * Ends recording process
+        */
+        void StopRecognition();
+
+        /**
+        * Use to set the priority of the sound device
+        *
+        * @param "TMMFPrioritySettings& aPrioritySettings" Priority settings
+        *        structure.
+        */
+        void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings );
+        
+        /**
+        * Request to start a recognition session.
+        * 
+        * @param "TRecognizerMode aMode" Recognizer mode.
+        * @return result code of request
+        */
+        TInt StartRecSession( TRecognizerMode aMode );
+        
+        /**
+        * Call to give speech data to recognizer.
+        *
+        * @param "TDesC8& aBuffer" Filled buffer.
+        * @param "TBool aEnd" Flag to tell if this is the last buffer.
+        */
+        void SendSpeechData( TPtrC8& aBuffer, TBool aEnd );
+
+        /**
+        * Request to unload the specified rule in the grammar from recognizer.
+        *
+        * @param "TSIGrammarID aGrammarID" Identifer of the grammar to operate on.
+        * @param "TSIRuleID aRuleID" Identifier of the rule to remove.
+        */
+        void UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+        
+        /**
+        * Retreive the raw audio data accumulated during recording.
+        *
+        * @param "TDes8* aBuffer" Reference to a buffer containing the data.
+        * @param "TTimeIntervalMicroSeconds32& aDuration" Duration of the 
+        *        utterance.
+        */
+        void GetUtteranceData( TDes8* aBuffer, 
+                               TTimeIntervalMicroSeconds32& aDuration );
+
+        /**
+        * Checks if grammar is loaded or not
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" Grammar ID
+        * @return ETrue if grammar is currently loaded, EFalse otherwise.
+        */
+        TBool IsGrammarLoaded( TSIGrammarID aGrammarID );
+        
+        /**
+        * Checks if grammar is active or not
+        *
+        * @since 2.8
+        * @param "TSIGrammarID aGrammarID" Grammar ID
+        * @return ETrue if grammar is active, EFalse otherwise.
+        */
+        TBool IsGrammarActive( TSIGrammarID aGrammarID );
+
+        /**
+        * Prints DevASR state information for debugging
+        */
+        void DevASRState();
+        
+        /**
+        * Pre-starts recording before StartRecording call.
+        *
+        * @since 3.2
+        */
+        void PreStartSamplingL();
+
+        // ===================================
+        // DevSound Observer MIXIN begins
+        // ===================================
+        
+        /**
+        * Called by DevSound when a buffer is available to be read.
+        *
+        * @param "CMMFBuffer* aBuffer" Buffer containing data to be processed
+        */
+        void BufferToBeEmptied( CMMFBuffer* aBuffer );
+        
+        /**
+        * Called by DevSound when a buffer is available to be written.
+        *
+        * @param "CMMFBuffer* aBuffer" Buffer to which data is written
+        */
+        void BufferToBeFilled( CMMFBuffer* aBuffer );
+        
+        /**
+        * Not used by DevASR
+        */
+        void ConvertError( TInt aError );
+        
+        /**
+        * Handles device event.
+        *
+        * @param "TDesC8& aMsg" A message packed in the descriptor format.
+        */
+        void DeviceMessage( TUid aMessageType, const TDesC8& aMsg );
+        
+        /**
+        * Called by DevSound when initialization is completed.
+        *
+        * @param aError Error code, KErrNone if successful.
+        */
+        void InitializeComplete( TInt aError );
+        
+        /**
+        * Handles record completion or cancel event from DevSound.
+        *
+        * @param aError Error code, KErrNone if successful.
+        */
+        void RecordError( TInt aError );
+        
+        /**
+        * Handles play completion or cancel event from DevSound.
+        *
+        * @param "TInt aError" Error code, KErrNone if successful.
+        */
+        void PlayError( TInt aError );
+        
+        /**
+        * Handles tone play completion or cancel event from DevSound
+        * Tone is not used by DevASR so this event is not expected.
+        *
+        * @param "TInt aError" Error code, KErrNone if successful.
+        */
+        void ToneFinished( TInt aError );
+        
+       	/**
+        * Handles audio policy events from DevSound.
+        *
+        * @param "TMMFEvent&" aEvent An audio policy event.
+        */
+        void SendEventToClient( const TMMFEvent& aEvent );
+        
+        // ===================================
+        // DevSound Observer MIXIN ends
+        // ===================================
+        
+        // ============================================
+        // RecognitionAlgMgr Observer MIXIN begins
+        // ============================================
+         
+        /**
+        * Invoked by the adaptation hw device when model adaptation has
+        * finished its processing.
+        *
+        * @since 2.8
+        * @param "TInt aResultCode" Error code of operation.
+        */
+        void AdaptComplete( TInt aResultCode );
+
+        /**
+        * Invoked by the front-end when EOU has been detected.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void EouDetected( TInt aResultCode );
+        
+        /**
+        * Invoked by the algorithm manager when the frontend initialization
+        * is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void InitFEComplete( TInt aResultCode );
+        
+        /**
+        * Invoked by the algorithm manager when the recognition backend
+        * initialization is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void InitRecognizerBEComplete( TInt aResultCode );
+        
+        /**
+        * Invoked by the algorithm manager when loading grammar
+        * is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void LoadGrammarComplete( TInt aResultCode );
+
+        /**
+        * Invoked when grammar has been unloaded.
+        *
+        * @param "TInt aResultCode" Result of grammar loading
+        */
+        void UnloadGrammarComplete( TInt aResultCode );
+        
+        /**
+        * Invoked when grammar has been activated.
+        *
+        * @param "TInt aResultCode" Result of grammar activation
+        */
+        void ActivateGrammarComplete( TInt aResultCode );
+
+        /**
+        * Invoked when grammar has been deactivated.
+        *
+        * @param "TInt aResultCode" Result of grammar deactivation
+        */
+        void DeActivateGrammarComplete( TInt aResultCode );
+        
+        /**
+        * Invoked by the algorithm manager when loading lexicon
+        * is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void LoadLexiconComplete( TInt aResultCode );
+        
+        /**
+        * Invoked by the algorithm manager when loading models
+        * is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void LoadModelsComplete( TInt aResultCode );
+        
+        /**
+        * Invoked when the recognition process is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void RecognitionComplete( TInt aResultCode );
+        
+        /**
+        * Invoked when the training process is completed.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void TrainComplete( TInt aResultCode );
+
+        /**
+        * Invoked when rule unloading has been done.
+        *
+        * @param "TInt aResultCode" Result code, KErrNone if successful.
+        */
+        void UnloadRuleComplete( TInt aResultCode );
+        
+        /**
+        * Invoked when a feature vector is available.
+        *
+        * @param "TDesC8& aFV" Buffer containing a feature vector.
+        * @param "TInt32 aSNR" Signal-to-noise ratio.
+        * @param "TInt32 aPosition" Indicates whether this is the first,
+        *         subsequent or last feature vector.
+        */
+        void FeatureVectorDataRcvd( const TDesC8& aFV, 
+                                    TInt32 aSNR, 
+                                    TInt32 aPosition );
+        
+        /**
+        * Invoked by the front-end when utterance data is needed.
+        *
+        * @since 2.8
+        */
+        void RequestSpeechData();
+
+     
+        /**
+        * Resolves result.
+        */
+        void ResolveResult( const RArray<TUint>& aNBestIDs,
+                            CSIResultSet& aSIResultSet,
+                            const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar,
+                            const TDesC8& aCombinedData );
+
+        /**
+        * Invoked when grammar combining is needed
+        *
+        * @since 2.8
+        * @param "RPointerArray<CSICompiledGrammar>& aCompiledGrammars" 
+        *        Array of previously compiled grammar
+        * @param "const RPointerArray<TSIRuleVariantInfo>& aExcludedRules" 
+        *        Rules to be blacklisted.
+        */
+        void CombineGrammarL( const RPointerArray<CSICompiledGrammar>& aCompiledGrammars,
+                              const RPointerArray<TSIRuleVariantInfo>& aExcludedRules );
+
+        // ============================================
+        // RecognitionAlgMgr Observer MIXIN ends
+        // ============================================
+        
+        // ============================================
+        // MVmAlgMgrObserver Observer MIXIN begins
+        // ============================================
+
+        /**
+        * Notifies that grammar combination has been done.
+        */
+        void CombineComplete( HBufC8* aResult, TInt aError );
+
+        /**
+        * Get the specified grammar.
+        * 
+        * @param "TSIGrammarID aGrammarID" Identifier of grammar to be found.
+		* @param "CSICompiledGrammar** aSIActiveGrammar" Pointer to found SI 
+        *        active grammar, NULL if not found.
+		* @param "CSICompiledGrammar** aSIDeActivatedGrammar" Pointer to found SI 
+        *        non-active grammar, NULL if not found
+        */
+        void GetGrammarL( const TSIGrammarID aGrammarID, 
+                          CSICompiledGrammar** aSIActiveGrammar,
+                          CSICompiledGrammar** aSIDeActivatedGrammar );
+
+        // ============================================
+        // MVmAlgMgrObserver Observer MIXIN begins
+        // ============================================
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        *
+        * @param "MDevASRObserver& aObserver" Reference to observer.
+        */
+        CSRSAlgorithmManager( MDevASRObserver& aObserver );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * From CActive.
+        */
+        void RunL();
+        void DoCancel();
+        
+        /**
+        * Empties and copies the data to holding buffer.
+        *
+        * @param "CMMFDataBuffer& aBuffer" Buffer containing utterance data
+        * @param "TInt aBufferLength" Length of buffer
+        */
+        TInt EmptyBuffer( CMMFDataBuffer& aBuffer, TInt aBufferLength );
+        
+        /**
+        * Fill the received buffer with utterance data upto the specified length.
+        *
+        * @param "CMMFDataBuffer& aBuffer" Buffer containing utterance data
+        * @param "TInt aBufferLength" Length of buffer
+        */
+        TInt FillBuffer( CMMFDataBuffer& aBuffer, TInt aBufferLength );
+       
+        /**
+        * Transition from current state to target state if possible.
+        *
+        * @param "TDevASRState aState" A target state
+        * @return ETrue if successful.
+        */
+        TBool StateTransition( TDevASRState aState );
+        
+        /**
+        * Translate system error codes to DevASR cause codes.
+        *
+        * @param "TInt aError" System error constant
+        * @return A DevASR error code
+        */
+        TDevASRError TranslateError( TInt aError );
+        
+        /**
+        * Async handler for a play request.
+        */
+        void HandlePlayL();
+        
+        /**
+        * Async handler for a record request.
+        */
+        void HandleRecordL();
+       
+        /**
+        * Async handler for a UtteranceDataProcessed event.
+        */
+        void HandleUtteranceDataProcessed();
+       
+        /**
+        * Completes a request with specified status.
+        *
+        * @param "TInt aStatus" Operation status.
+        */
+        void Ready( const TInt aStatus );
+        
+        /**
+        * Configure the sound device according to parameters in the resource file.
+        */
+        void ConfigureSoundDeviceL();
+        
+        /**
+        * Initializes DevSound for sampling
+        */
+        void InitializeDevSoundL();
+        
+        /**
+        * Starts sampling with DevSound
+        */
+        void StartDevSoundL();
+        
+    private:    // Data
+        
+        // DevASR Observer, the SRS Plugin
+        MDevASRObserver* iDevASRObserver;
+        
+        // ----- DevSound related data -----
+        
+        // Pointer to DevSound
+        CMMFDevSound* iDevSound;
+        
+        // structure of capabilities for DevSound instance
+        TMMFCapabilities iDevSoundCapabilities;
+        
+        // structure of priorities for DevSound instance
+        TMMFPrioritySettings iPrioritySettings;
+        
+        // stores the current volume and gain
+        TInt iCurrentVolume;
+        TInt iCurrentGain;
+        
+        // ----- Algorithm managers ----
+
+        // Pointer to Recognition Algorithm Manager
+        CRecognitionAlgMgr* iRecognitionAlgMgr;
+
+        // Pointer to Vocabulary algorithm manager
+        CVMAlgorithmManager* iVMAlgorithmManager;
+
+        // Flag to tell if recognition should be started when first audio
+        // buffer has been sampled.
+        TBool iStartRecognition;
+
+        // Flag to tell if there is a pending RequestSpeechData() call from 
+        // recognition hw device.
+        TBool iPendingRequestSpeechData;
+        
+        // --- SD Training audio buffer managemet ---
+        // Start and stop points in the audio buffer, used during recording
+        TUint32 iStartPoint;
+        TUint32 iStopPoint;
+        // Audio buffer to hold PCM data coming from DevSound
+        TUint8* iAudioBuffer;
+        TPtr8 iPtr;
+
+
+        // ----- Buffer management -----
+        
+        // Number of ms to record
+        TTimeIntervalMicroSeconds32 iRecordDuration;
+        
+
+        // Overall number of bytes that need to be sampled.
+        // Zero if we should sample until EndRecord() is called.
+        TInt iOverallLength;
+
+        // Number of samples that are recorded.
+        TInt iOverallSampled;
+        
+        // Indicates if utterance processing is currently being done
+        TBool iProcessingUtterance;
+        
+        
+        // Queue of audio buffer descriptors to be processed
+        TSglQue<CQueItem>* iAudioBufferQue;
+
+        // An item in the queue of audio buffer descriptors
+        CQueItem* iQueItem;
+
+        // Flag to tell if recording should be ended
+        TBool iEndFlag;
+
+        // Recognizer mode
+        TRecognizerMode iMode;
+
+        
+        // ----- End-pointing usage -----
+        
+        // Start and end frames in audio buffer
+        TUint32 iStartFrame;
+        TUint32 iEndFrame;
+        TReal iFrameLength;
+        
+        // Start and end point in the audio buffer after end-pointing.
+        TUint32 iBufferStartPoint;
+        TUint32 iBufferEndPoint;
+        
+        // ----- State management -----
+        
+        // State of DevASR
+        TDevASRState iDevASRState;
+        
+        // State of DevSound
+        TDevSoundState iDevSoundState;
+        
+        // ----- Active object handling -----
+        TInt iRequestFunction;
+        
+        // resource file handler
+        CDevASRResourceHandler* iResourceHandler;
+
+        
+        TUint8* iBufferUnderConstruction;
+        TInt iConstructionPoint;
+
+		const CSIModelBank* iSIModelBank;
+		const CSILexicon* iSILexicon;
+        
+        // Flag which tells if pre-sampling has been started
+        TBool iPreSamplingStarted;
+        
+        // Wait loop to wait for audio initialization callback
+        CActiveSchedulerWait iAudioWait;
+        
+        // The following are used when dumping captured audio to file for analysis
+#ifdef AUDIOBUFFER_TO_FILE
+        RFs iFs;
+        RFile iBufferDataFile;
+        TBool iFileCreated;
+#endif
+        
+    };
+    
+#endif // DEVASRSRSALGORITHMMANAGER_H
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrutil.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains the implementation of DevASR Utility.
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "devasrutil.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CQueItem::CQueItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CQueItem::CQueItem() : iDataBlock( NULL, 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CQueItem::~CQueItem
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CQueItem::~CQueItem()
+    {
+    delete iBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// CQueItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CQueItem::ConstructL( TUint8* aBuf, TInt aLength )
+    {
+    RUBY_DEBUG_BLOCK( "CQueItem::ConstructL()" );
+
+    iFinalBlock = EFalse;
+    iDataBlock.Set( aBuf, aLength );
+
+    iBuf = aBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// CQueItem::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CQueItem* CQueItem::NewL( TUint8* aBuf, TInt aLength )
+    {
+    CQueItem* self = new ( ELeave ) CQueItem();
+    CleanupStack::PushL( self );
+    self->ConstructL( aBuf, aLength );
+    CleanupStack::Pop();
+    return self;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrutil.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definitions of utility classes used internally
+*               by DevASR.
+*
+*/
+
+
+#ifndef CDEVASRUTIL_H
+#define CDEVASRUTIL_H
+
+// INCLUDES
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+/**
+*  Class to encapsulate a queue item.
+*
+*  @lib DevASR.lib
+*  @since 2.0
+*/
+class CQueItem : public CBase
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CQueItem* NewL( TUint8* aBuf, TInt aLength );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CQueItem();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CQueItem();
+
+        /**
+        * Construct a queue item object and initialize it with.
+        *
+        * @param "TUint8* aBufBuffer" Containing utterance data, this class 
+        *        gains owenership.
+        * @param "TInt aLength" Length of buffer
+        * @param "TInt aMaxLength" Maximum length of buffer
+        */
+        void ConstructL( TUint8* aBuf, TInt aLength );
+
+    public: // Data
+
+		// Next item
+        TSglQueLink* iLink;
+
+        // Descriptor of data
+		TPtrC8 iDataBlock;
+
+		// Final block of data indicator
+		TBool iFinalBlock;
+
+        // Direct pointer to data buffer
+        TUint8* iBuf;
+    };
+
+#endif // CDEVASRAPI_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrvmalgorithmmanager.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,443 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Algorithm manager for grammar handling algorihtms.
+*
+*/
+
+
+// INCLUDE FILES
+#include "devasrvmalgorithmmanager.h"
+//#include "DevASRSrsAlgorithmManager.h"
+#include <nssdevasr.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+#include "rubydebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::CVMAlgorithmManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVMAlgorithmManager::CVMAlgorithmManager( MDevASRObserver& aObserver,
+                                          MVmAlgMgrObserver& aVmObserver )
+                                        : iGrCompiler( NULL ), 
+                                          iVocMan( NULL ), 
+                                          iTtp( NULL ), 
+                                          iObserver( aObserver ),
+                                          iTtpState( ETtpStateUninitialized ),
+                                          iGrState( EGrStateUninitialized ),
+                                          iVmAlgObserver( aVmObserver )
+    {
+    // Nothing
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::ConstructL()" );
+
+    // TtpHwDevice
+    iTtp = CASRSTtpHwDevice::NewL( *this );
+    iTtp->InitializeL();
+    iTtp->SetPhonemeNotationL( _L("NIPA8" ) );
+    iTtpState = ETtpStateIdle;
+    // Grammar compiler HW device
+    iGrCompiler = CASRSGrCompilerHwDevice::NewL( *this );
+    iGrCompiler->InitializeL();
+    iGrState = EGrStateIdle;
+    // VocManHwDevice
+    iVocMan = CASRSVocManHwDevice::NewL();
+    iVocMan->InitializeL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVMAlgorithmManager* CVMAlgorithmManager::NewL( MDevASRObserver& aObserver, 
+                                                MVmAlgMgrObserver& aVmObserver )
+    {
+    CVMAlgorithmManager* self = new( ELeave ) CVMAlgorithmManager( aObserver, aVmObserver );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::~CVMAlgorithmManager
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CVMAlgorithmManager::~CVMAlgorithmManager()
+    {
+    if ( iGrCompiler != NULL )
+        {
+        iGrCompiler->Clear();
+        }
+    delete iGrCompiler;
+    iGrCompiler = NULL;
+    if ( iVocMan != NULL )
+        {
+        iVocMan->Clear();
+        }
+    delete iVocMan;
+    iVocMan = NULL;
+    if ( iTtp != NULL )
+        {
+        iTtp->Clear();
+        }
+    delete iTtp;
+    iTtp = NULL;
+//    iDataArray.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::AdaptVocabL
+// Use CASRVocManHwDevice to adapt rule.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::AdaptVocabL( const CSIResultSet& aResultSet, 
+                                       TInt aResultIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::AdaptVocabL()" );
+
+    const CSIResult& iCorrectResult = aResultSet.AtL( aResultIndex );
+
+    TSIGrammarID grammarID( iCorrectResult.GrammarID() );
+    TSIRuleID ruleID( iCorrectResult.RuleID() );
+    TSIRuleVariantID ruleVariantID( iCorrectResult.RuleVariantID() );
+    CSICompiledGrammar* siActiveGrammar = NULL;
+    CSICompiledGrammar* siNonActiveGrammar = NULL;
+    CSICompiledGrammar* siGrammar = NULL;
+  
+    TRAPD( error, iVmAlgObserver.GetGrammarL( grammarID, &siActiveGrammar, &siNonActiveGrammar ) );
+    User::LeaveIfError( error );
+
+    TInt index = 0;
+
+    if ( siActiveGrammar != NULL )
+        {
+        siGrammar = siActiveGrammar;
+        }
+    else if ( siNonActiveGrammar != NULL )
+        {
+        siGrammar = siNonActiveGrammar;
+        }
+    else
+        {
+        User::Leave( KErrNotFound );	
+        }
+    
+    index = siGrammar->Find( ruleID );
+    User::LeaveIfError( index );
+    CSIRule& rule = siGrammar->AtL( index );
+    
+    // Do the actual vocabulary adaptation using VocManHwDevice
+    TRAP( error, iVocMan->AdaptL( ruleVariantID, rule ) );
+    // Neglect possible error since it just might be due to the reason
+    // that there are no proper parameters in place within the RuleVariants..
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::ComputeNewGrammarSizeL
+// Use CASRVocManHwDevice to compute size.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::ComputeNewGrammarSizeL( const CSIGrammar& aGrammar, 
+                                                  const TUint32 aTargetNRuleVariants, 
+                                                  const TUint32 aMaxNRuleVariants, 
+                                                  const RArray<TUint>& aNewRuleScores, 
+                                                  RArray<TUint>& aNNeNRuleVariants, 
+                                                  TUint32& aNPrune )
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::ComputeNewGrammarSizeL()" );
+
+    iVocMan->ComputeNRuleVariantsL( aGrammar, aTargetNRuleVariants, 
+                                    aMaxNRuleVariants, aNewRuleScores, 
+                                    aNNeNRuleVariants, aNPrune );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::CompileGrammarL
+// Compiles SI grammar.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::CompileGrammarL( CSICompiledGrammar& aGrammar/*, 
+                                           CSIModelBank& aModelBank*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::CompileGrammarL()" );
+
+    if ( iGrState == EGrStateUninitialized )
+        {
+        User::Leave( KErrNotReady );
+        }
+    if ( iGrState == EGrStateBusyCombining || iGrState == EGrStateBusyCompiling )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    iGrState = EGrStateBusyCompiling;
+
+    iGrCompiler->CompileGrammarL( aGrammar/*, aModelBank*/ );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::CombineGrammarL
+// Combines a list of grammars.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::CombineGrammarL( const RPointerArray<CSICompiledGrammar>& aCompiledGrammars,
+                                           const RPointerArray<TSIRuleVariantInfo>& aExcludedRules )
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::CombineGrammarL()" );
+
+    if ( iGrState == EGrStateUninitialized )
+        {
+        User::Leave( KErrNotReady );
+        }
+    if ( iGrState == EGrStateBusyCombining || iGrState == EGrStateBusyCompiling )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    iGrState = EGrStateBusyCombining;
+
+    iGrCompiler->CombineGrammarL( aCompiledGrammars, aExcludedRules );
+    }
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::PruneGrammar
+// Use CASRVocManHwDevice to prune a grammar.
+// -----------------------------------------------------------------------------
+//
+TBool CVMAlgorithmManager::PruneGrammar( const CSIGrammar& aGrammar, 
+                                         const TUint32 aMinNumber, 
+                                         RArray<TSIRuleVariantInfo>& aPrunedRuleVariants )
+    {
+    return iVocMan->Prune( aGrammar, aMinNumber, aPrunedRuleVariants );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::ResolveResult
+// Use CASRVocManHwDevice to resolve a result.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::ResolveResult( const RArray<TUint>& aNBestIDs,
+                                         CSIResultSet& aSIResultSet,
+                                         const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar,
+                                         const TDesC8& aCombinedData/*,
+                                         CSIModelBank& iSIModelBank*/ )
+    {
+    iGrCompiler->ResolveResult( aNBestIDs, aSIResultSet,
+                                aSICompiledGrammar, aCombinedData );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::TrainFromText
+// Use CVMAlgorithmManager to train from text.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::TrainFromTextL( CSITtpWordList& aWordList, 
+                                          const RArray<TLanguage>& aDefaultLanguage, 
+                                          const RArray<TUint32>& aMaxNPronunsForWord )
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::TrainFromTextL()" );
+
+    if ( iTtpState == ETtpStateUninitialized )
+        {
+        User::Leave( KErrNotReady );
+        }
+    if ( iTtpState == ETtpStateBusy )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    iTtpState = ETtpStateBusy;
+    
+    TRAPD( error, iTtp->ConvertWordListL( aWordList, aDefaultLanguage, aMaxNPronunsForWord ) );
+    if ( error != KErrNone )
+        {
+        iTtpState = ETtpStateIdle;
+        User::Leave( error );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::Cancel
+// Use CVMAlgorithmManager to cancel training.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::Cancel()
+    {
+    if ( iTtpState == ETtpStateBusy )
+        {
+        iTtp->CancelWordListConversion();
+        }
+    if ( iGrState == EGrStateBusyCompiling )
+        {
+        iGrCompiler->CancelCompilation();
+        }
+    if ( iGrState == EGrStateBusyCombining )
+        {
+        iGrCompiler->CancelCombination();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// GetEnginePropertiesL
+// Returns properties of the underlying engines.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::GetEnginePropertiesL( const RArray<TInt>& /*aPropertyId*/, 
+                                                RArray<TInt>& /*aPropertyValue*/ )
+    {
+    // Do nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::LoadEnginePropertiesL
+// Loads properties to engine, invalid IDs are neglected.
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::LoadEnginePropertiesL( const RArray<TInt>& /*aParameterId*/,
+                                                 const RArray<TInt>& /*aParameterValue*/ )
+    {
+    // Do nothing
+    }
+
+// -----------------------------------------------------------------------------
+// MASRTtpHwDeviceObserver mixin begins
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::MathdoConfigurationData
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC8* CVMAlgorithmManager::MathdoConfigurationData( TUint32 aPackageType,
+                                                      TUint32 aPackageID,
+                                                      TUint32 aStartPosition,
+                                                      TUint32 aEndPosition )
+    {
+    // Call DevASR observer
+    return iObserver.ConfigurationData( aPackageType, aPackageID, 
+                                        aStartPosition, aEndPosition );
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::MathdoWordListReady
+// 
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::MathdoWordListReady( const TInt aError )
+    {
+    RUBY_DEBUG0( "CVMAlgorithmManager::MathdoWordListReady()" );
+    
+    iTtpState = ETtpStateIdle;
+
+    // Call DevASR observer
+    iObserver.DevASREvent( EDevASRTrainFromText, aError );
+    }
+    
+
+// -----------------------------------------------------------------------------
+// MASRTtpHwDeviceObserver mixin ends
+// -----------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// MASRGrCompilerObserver mixin begins
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::MghdoGrammarCompilerComplete
+// 
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::MghdoGrammarCompilerComplete( TInt aError )
+    {
+    iGrState = EGrStateIdle;
+    // Forward callback to DevASR observer
+    iObserver.DevASREvent( EDevASRGrammarCompile, aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::MghdoGrammarCombinerComplete
+// 
+// -----------------------------------------------------------------------------
+//
+void CVMAlgorithmManager::MghdoGrammarCombinerComplete( HBufC8* aResult, 
+                                                        TInt aError )
+    {
+    iGrState = EGrStateIdle;
+    iVmAlgObserver.CombineComplete( aResult, aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::MghdoSILexiconL
+// 
+// -----------------------------------------------------------------------------
+//
+CSILexicon* CVMAlgorithmManager::MghdoSILexiconL( TSILexiconID anID )
+    {
+    RUBY_DEBUG_BLOCK( "CVMAlgorithmManager::MghdoSILexiconL()" );
+
+    return iObserver.SILexiconL( anID );
+    }
+
+// -----------------------------------------------------------------------------
+// CVMAlgorithmManager::MghdoConfigurationData
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC8* CVMAlgorithmManager::MghdoConfigurationData( TUint32 aPackageType,
+                                                     TUint32 aPackageID,
+                                                     TUint32 aStartPosition,
+                                                     TUint32 aEndPosition )
+    {
+    // Call DevASR observer
+    return iObserver.ConfigurationData( aPackageType, aPackageID, 
+                                        aStartPosition, aEndPosition );
+    }
+
+
+// -----------------------------------------------------------------------------
+// MASRGrCompilerObserver mixin ends
+// -----------------------------------------------------------------------------
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/devasrvmalgorithmmanager.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,339 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Algorithm manager for grammar handling algorihtms.
+*
+*/
+
+
+#ifndef DEVASRVMALGORITHMMANAGER_H
+#define DEVASRVMALGORITHMMANAGER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+#include <asrsgrcompilerhwdevice.h>
+#include <asrsvocmanhwdevice.h>
+#include <asrsttphwdevice.h>
+
+//#include "DevASRSrsAlgorithmManager.h"
+
+// DATA TYPES
+enum TTtpHwState
+    {
+    ETtpStateUninitialized = 0,
+    ETtpStateIdle,
+    ETtpStateBusy
+    };
+
+enum TGrCompilerState
+    {
+    EGrStateUninitialized = 0,
+    EGrStateIdle,
+    EGrStateBusyCompiling,
+    EGrStateBusyCombining
+    };
+
+
+// FORWARD DECLARATIONS
+class MDevASRObserver;
+class MSDGrammarCompiler;
+//class CASRGrCompilerHwDevice;
+//class CASRSVocManHwDevice;
+//class CASRSTtpHwDevice;
+
+// CLASS DECLARATIONS
+
+/**
+* Observer mixin.
+*
+* @lib NssDevAsr.lib
+* @since 2.8
+*/
+class MVmAlgMgrObserver
+    {
+    public:
+        /**
+        * Called when grammars have been combined.
+        */
+        virtual void CombineComplete( HBufC8* aResult, TInt aError ) = 0;
+
+        /**
+        * Called by CVMAlgorithmManager when it needs a grammar object.
+        * 
+        * @param "TSIGrammarID aGrammarID" Grammar identifier which is needed.
+        * @param "CSICompiledGrammar** aSIActiveGrammar" Output parameter which will
+        *        contain the grammar object pointer if grammar is currently active.
+        * @param "CSICompiledGrammar** aSIDeActivatedGrammar" Output parameter which will
+        *        contain the grammar object pointer if grammar is currently not active.
+        */
+        virtual void GetGrammarL( const TSIGrammarID aGrammarID, 
+                                  CSICompiledGrammar** aSIActiveGrammar,
+                                  CSICompiledGrammar** aSIDeActivatedGrammar ) = 0;
+    };
+
+/**
+* Algorithm manager to handle VocMan, Ttp and Grammar Compiler
+*
+* @lib NssDevAsr.lib
+* @since 2.8
+*/
+class CVMAlgorithmManager : public CBase, public MASRSTtpHwDeviceObserver, public MASRSGrCompilerHwDeviceObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CVMAlgorithmManager* NewL( MDevASRObserver& aObserver, MVmAlgMgrObserver& aVmObserver );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVMAlgorithmManager();
+        
+    public: // New functions
+        
+
+        /**
+        * Use to adapt rule after recognition.
+        *
+        * @since 2.8
+        * @param "CSIResultSet& aResultSet" Result set.
+        * @param "TInt aResultIndex" Index of correct result.
+        */
+        void AdaptVocabL( const CSIResultSet& aResultSet, 
+                          TInt aResultIndex );
+
+        /**
+        * Cancels training.
+        *
+        * @since 2.8
+        */
+        void Cancel();
+        
+        /**
+        * Computes number of rule variants for grammar.
+        *
+        * @since 2.8
+        * @param "CSIGrammar& aGrammar" A grammar where to add new rules.
+        * @param "TUint32 aTargetNRuleVariants" Preferable target number of 
+        *        all rule variants after adding new rule variants
+        * @param "TUint32 aMaxNRuleVariants" Maximum number of all rule variants.
+        * @param "RArray<TUint>& aNewRuleScores" Scores for each new rule. The 
+        *         size of array tells also how many	new rules will be added. 
+        *         Based on the scores some rules can get more rule variants 
+        *         than others. If there is no scores available, the array 
+        *         should initialize with constant values.
+        * @param "RArray<TUint>& aNNeNRuleVariants" Array where to add number 
+        *         of new rule variants for new rules. The order is equivalent 
+        *         to aNewRuleScores.
+        * @param "TUint32& aNPrune" Number of rule variants which should be 
+        *         pruned before adding new rule variants.
+        */
+        void ComputeNewGrammarSizeL( const CSIGrammar& aGrammar, 
+                                     const TUint32 aTargetNRuleVariants, 
+                                     const TUint32 aMaxNRuleVariants, 
+                                     const RArray<TUint>& aNewRuleScores, 
+                                     RArray<TUint>& aNNeNRuleVariants, 
+                                     TUint32& aNPrune );
+        
+
+        /**
+        * Compiles SI or SD grammar to internal format.
+        *
+        * @since 2.8
+        * @param "aGrammar" Reference to grammar object.
+        * @param "aModelBank" Reference to model bank.
+        */
+        void CompileGrammarL( CSICompiledGrammar& aGrammar );
+
+        /**
+        * Invoked when grammar combining is needed
+        *
+        * @since 2.8
+        * @param "RPointerArray<CSICompiledGrammar>& aCompiledGrammars" 
+        *        Array of previously compiled grammar
+        * @param "const RPointerArray<TSIRuleVariantInfo>& aExcludedRules" 
+        *        Rules to be blacklisted.
+        */
+        void CombineGrammarL( const RPointerArray<CSICompiledGrammar>& aCompiledGrammars,
+                              const RPointerArray<TSIRuleVariantInfo>& aExcludedRules );
+
+
+        /**
+        * Determines which rule variants can be removed.
+        *
+        * @since 2.8
+        * @param "CSIGrammar& aGrammar" A grammar to be pruned.
+        * @param "TUint32 aMinNumber" Minimum number of pruned items
+        * @param "RArray<TSIRuleVariantInfo> aPrunedRuleVariants" A array where 
+        *         to put information which variants can be pruned.
+        */
+        TBool PruneGrammar( const CSIGrammar& aGrammar, 
+                            const TUint32 aMinNumber, 
+                            RArray<TSIRuleVariantInfo>& aPrunedRuleVariants );
+        
+        /**
+        * Resolves result using Grammar Compiler.
+        *
+        * @since 2.8
+        * @param "RArray<TUint>& aNBestIDs" List of N-best results
+        * @param "
+        */
+        void ResolveResult( const RArray<TUint>& aNBestIDs,
+                            CSIResultSet& aSIResultSet,
+                            const RPointerArray<CSICompiledGrammar>& aSICompiledGrammar,
+                            const TDesC8& aCombinedData );
+
+        /**
+        * Starts training from text.
+        *
+        * @since 2.8
+        * @param "CSITtpWordList& aWordList" Text for training.
+        * @param "RArray<TLanguage>& aDefaultLanguage" Default language for 
+        *        pronunciations.
+        * @param "RArray<TUint32>& aMaxNPronunsForWord" Maximum number of 
+        *        pronunciation per word.
+        */
+        void TrainFromTextL( CSITtpWordList& aWordList, 
+                             const RArray<TLanguage>& aDefaultLanguage, 
+                             const RArray<TUint32>& aMaxNPronunsForWord );
+
+		/**
+        * Retreive the properties of the engines.
+        *
+        * @since 2.0
+        * @param "RArray<TInt>& aPropertyId" An array of identifiers being querried.
+        * @param "RArray<TInt>& aPropertyValue" An array of values corresponding
+        *        to the querried identifiers.
+        */
+        void GetEnginePropertiesL( const RArray<TInt>& aPropertyId, 
+                                   RArray<TInt>& aPropertyValue );
+
+        /**
+        * Load the specified parameter(s) to the engines. 
+        *
+        * @param "RArray<TInt>& aParameterId" An array of parameter identifiers.
+        * @param "RArray<TInt>& aParameterValue" An array of parameter values.
+        */
+        void LoadEnginePropertiesL( const RArray<TInt>& aParameterId,
+                                    const RArray<TInt>& aParameterValue );
+
+        
+    public: // From MASRTtpHwDeviceObserver
+        
+        /**
+        * Callback function to load configuration data.
+        *
+        * @param "TUint32 aPackageType" Type identifier.
+        * @param "TUint32 aPackageID" Package identifier.
+        * @param "TUint32 aStartPosition" First byte.
+        * @param "TUint32 aEndPosition" Last byte. If greater than the size of 
+        *                               the data, rest of the data is given.
+        * @return Pointer to the data buffer, TTP HW Device takes ownership.
+        */	
+        HBufC8* MathdoConfigurationData( TUint32 aPackageType, TUint32 aPackageID,
+                                         TUint32 aStartPosition = 0,
+                                         TUint32 aEndPosition = KMaxTUint32 );
+
+		/**
+        * Callback function to notify that word list is converted.
+        *
+        * @param "TInt aError" Error code, KErrNone if successful.
+        */	
+		void MathdoWordListReady( const TInt aError );
+
+    public: // From MASRSGrCompilerObserver
+
+        /**
+        * Grammar has been compiled.
+        *
+        * @param "TInt aError" An error code.
+        */
+        void MghdoGrammarCompilerComplete( TInt aError );
+
+        /**
+        * Grammars have been combined.
+        *
+        * @param "HBufC8* aResult" Contains the compiled grammar, NULL if error
+        *         happened.
+        * @param "TInt aError" KErrNone if successful.
+        */
+        void MghdoGrammarCombinerComplete( HBufC8* aResult, TInt aError );
+
+        /**
+        * Called when GrCompilerHwDevice needs an SI lexicon.
+        *
+        * @param "TSILexiconID anID" Requested lexicon id.
+        * @return Pointer to created lexicon.
+        */
+        CSILexicon* MghdoSILexiconL( TSILexiconID anID );
+
+        /**
+        * Called when GrCompiler needs configuration data package
+        */
+        HBufC8* MghdoConfigurationData( TUint32 aPackageType,
+                                        TUint32 aPackageID,
+                                        TUint32 aStartPosition = 0,
+                                        TUint32 aEndPosition = KMaxTUint32 );
+             
+    private:
+        
+/*        void DeleteData( TPtrC8& aData );*/
+        
+        /**
+        * C++ default constructor.
+        */
+        CVMAlgorithmManager( MDevASRObserver& aObserver, MVmAlgMgrObserver& aVmObserver );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor
+        CVMAlgorithmManager( const CVMAlgorithmManager& );
+        // Prohibit assigment operator
+        CVMAlgorithmManager& operator=( const CVMAlgorithmManager& );
+        
+    private: // Data
+        // Grammar compiler HW device
+        CASRSGrCompilerHwDevice* iGrCompiler;
+        
+        // Vocabulary management HW device
+        CASRSVocManHwDevice* iVocMan;
+        
+        // TTP HW device
+        CASRSTtpHwDevice* iTtp;
+        
+        // Observer
+        MDevASRObserver& iObserver;
+        
+        // Array for data pointers
+//        RPointerArray<HBufC8> iDataArray;
+        
+        // TtpHwDevice state
+        TTtpHwState iTtpState;
+
+        // GrCompilerHwDeviceState
+        TGrCompilerState iGrState;
+
+        // Our own observer
+        MVmAlgMgrObserver& iVmAlgObserver;
+       
+    };
+    
+#endif // DEVASRVMALGORITHMMANAGER_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/nssdevasr.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Structure definition for resource file.
+*
+*/
+
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// DevASR_INFO
+// Structure definition for DevASR resource file.
+// -----------------------------------------------------------------------------
+//
+STRUCT DEVASR_INFO
+    {
+    WORD    sampling_rate;
+    WORD    bits_per_sample;
+    WORD    microphone_gain;
+    WORD    speaker_volume;
+    WORD    frames_to_silence;
+    WORD    frames_to_pad_end;
+    WORD    frames_to_pad_start;
+    WORD    buffer_size;
+    WORD    gather_buffers_wins;
+    WORD    gather_buffers_thumb;
+    WORD    parameter1;               // user-defined parameter
+    WORD    parameter2;               // user-defined parameter
+    WORD    parameter3;               // user-defined parameter
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devasr/src/nssdevasr.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DevASR resource file.
+*
+*/
+
+
+// INCLUDES
+#include "nssdevasr.rh"
+
+
+// RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// devASRInfo
+// DevASR resouce file.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DEVASR_INFO devASRInfo
+    {
+    sampling_rate = 8000;    // Specify in Hz
+    bits_per_sample = 16;    // Specify 8, 16, 32 bit
+    microphone_gain = 100;   // Specify in percentage of maximum supported gain
+    speaker_volume = 60;     // Specify in percentage of maximum supported volume
+    frames_to_silence = 0;   // Specify number of BYTES to write silence from the beginning of audio stream
+    frames_to_pad_end = 80;  // Specify number of frames to pad at the end of end-pointed buffer
+    frames_to_pad_start = 0; // Specify number of frames to add to the front of end-pointed buffer
+    buffer_size = 2048;      // Specify playback/recording buffer size in bytes
+    gather_buffers_wins = 1; // Specify number of buffers gathered in DevASR before sending them to RecoHwDevice
+    gather_buffers_thumb = 1;// Specify number of buffers gathered in THUMB build
+    }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/bwins/nssdevttsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,32 @@
+EXPORTS
+	??1CDevTTS@@UAE@XZ @ 1 NONAME ; CDevTTS::~CDevTTS(void)
+	?AddStyleL@CDevTTS@@QAEKABVTTtsStyle@@@Z @ 2 NONAME ; unsigned long CDevTTS::AddStyleL(class TTtsStyle const &)
+	?Balance@CDevTTS@@QAEHXZ @ 3 NONAME ; int CDevTTS::Balance(void)
+	?BufferProcessed@CDevTTS@@QAEXABVTDesC8@@@Z @ 4 NONAME ; void CDevTTS::BufferProcessed(class TDesC8 const &)
+	?CustomInterface@CDevTTS@@QAEPAXVTUid@@@Z @ 5 NONAME ; void * CDevTTS::CustomInterface(class TUid)
+	?DeleteStyleL@CDevTTS@@QAEXK@Z @ 6 NONAME ; void CDevTTS::DeleteStyleL(unsigned long)
+	?GetPositionL@CDevTTS@@QBEXAAVTTimeIntervalMicroSeconds@@@Z @ 7 NONAME ; void CDevTTS::GetPositionL(class TTimeIntervalMicroSeconds &) const
+	?GetPositionL@CDevTTS@@QBEXAAVTTtsSegment@@AAH@Z @ 8 NONAME ; void CDevTTS::GetPositionL(class TTtsSegment &, int &) const
+	?IsLanguageSupported@CDevTTS@@QBEHW4TLanguage@@@Z @ 9 NONAME ; int CDevTTS::IsLanguageSupported(enum TLanguage) const
+	?MaxVolume@CDevTTS@@QAEHXZ @ 10 NONAME ; int CDevTTS::MaxVolume(void)
+	?NewL@CDevTTS@@SAPAV1@AAVMDevTTSObserver@@@Z @ 11 NONAME ; class CDevTTS * CDevTTS::NewL(class MDevTTSObserver &)
+	?NumberOfStyles@CDevTTS@@QBEGXZ @ 12 NONAME ; unsigned short CDevTTS::NumberOfStyles(void) const
+	?Pause@CDevTTS@@QAEXXZ @ 13 NONAME ; void CDevTTS::Pause(void)
+	?PrimeSynthesisL@CDevTTS@@QAEXAAVCTtsParsedText@@@Z @ 14 NONAME ; void CDevTTS::PrimeSynthesisL(class CTtsParsedText &)
+	?PrimeSynthesisL@CDevTTS@@QAEXAAVMTtsSegmentStream@@@Z @ 15 NONAME ; void CDevTTS::PrimeSynthesisL(class MTtsSegmentStream &)
+	?SetAudioPriority@CDevTTS@@QAEXHW4TDevTTSAudioPreference@@@Z @ 16 NONAME ; void CDevTTS::SetAudioPriority(int, enum TDevTTSAudioPreference)
+	?SetBalance@CDevTTS@@QAEXH@Z @ 17 NONAME ; void CDevTTS::SetBalance(int)
+	?SetPositionL@CDevTTS@@QAEXABVTTimeIntervalMicroSeconds@@@Z @ 18 NONAME ; void CDevTTS::SetPositionL(class TTimeIntervalMicroSeconds const &)
+	?SetPositionL@CDevTTS@@QAEXABVTTtsSegment@@H@Z @ 19 NONAME ; void CDevTTS::SetPositionL(class TTtsSegment const &, int)
+	?SetVolume@CDevTTS@@QAEXH@Z @ 20 NONAME ; void CDevTTS::SetVolume(int)
+	?SetVolumeRamp@CDevTTS@@QAEXABVTTimeIntervalMicroSeconds@@@Z @ 21 NONAME ; void CDevTTS::SetVolumeRamp(class TTimeIntervalMicroSeconds const &)
+	?Stop@CDevTTS@@QAEXXZ @ 22 NONAME ; void CDevTTS::Stop(void)
+	?StyleL@CDevTTS@@QBEAAVTTtsStyle@@G@Z @ 23 NONAME ; class TTtsStyle & CDevTTS::StyleL(unsigned short) const
+	?StyleL@CDevTTS@@QBEAAVTTtsStyle@@K@Z @ 24 NONAME ; class TTtsStyle & CDevTTS::StyleL(unsigned long) const
+	?SynthesizeL@CDevTTS@@QAEXW4TDevTTSOutputMode@@@Z @ 25 NONAME ; void CDevTTS::SynthesizeL(enum TDevTTSOutputMode)
+	?Volume@CDevTTS@@QAEHXZ @ 26 NONAME ; int CDevTTS::Volume(void)
+	?LanguageIdentificationL@CDevTTS@@QAEXAAVCTtsParsedText@@HAAV?$RArray@W4TLanguage@@@@AAV?$RArray@H@@@Z @ 27 NONAME ; void CDevTTS::LanguageIdentificationL(class CTtsParsedText &, int, class RArray<enum TLanguage> &, class RArray<int> &)
+	?NormalizeAndSegmentTextL@CDevTTS@@QAEXAAVCTtsParsedText@@@Z @ 28 NONAME ; void CDevTTS::NormalizeAndSegmentTextL(class CTtsParsedText &)
+	?NormalizeTextL@CDevTTS@@QAEXAAVCTtsParsedText@@@Z @ 29 NONAME ; void CDevTTS::NormalizeTextL(class CTtsParsedText &)
+	?SetAudioOutputL@CDevTTS@@QAEXH@Z @ 30 NONAME ; void CDevTTS::SetAudioOutputL(int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/eabi/nssdevttsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+EXPORTS
+	_ZN7CDevTTS10SetBalanceEi @ 1 NONAME
+	_ZN7CDevTTS11SynthesizeLE17TDevTTSOutputMode @ 2 NONAME
+	_ZN7CDevTTS12DeleteStyleLEm @ 3 NONAME
+	_ZN7CDevTTS12SetPositionLERK11TTtsSegmenti @ 4 NONAME
+	_ZN7CDevTTS12SetPositionLERK25TTimeIntervalMicroSeconds @ 5 NONAME
+	_ZN7CDevTTS13SetVolumeRampERK25TTimeIntervalMicroSeconds @ 6 NONAME
+	_ZN7CDevTTS15BufferProcessedERK6TDesC8 @ 7 NONAME
+	_ZN7CDevTTS15CustomInterfaceE4TUid @ 8 NONAME
+	_ZN7CDevTTS15PrimeSynthesisLER14CTtsParsedText @ 9 NONAME
+	_ZN7CDevTTS15PrimeSynthesisLER17MTtsSegmentStream @ 10 NONAME
+	_ZN7CDevTTS16SetAudioPriorityEi22TDevTTSAudioPreference @ 11 NONAME
+	_ZN7CDevTTS4NewLER15MDevTTSObserver @ 12 NONAME
+	_ZN7CDevTTS4StopEv @ 13 NONAME
+	_ZN7CDevTTS5PauseEv @ 14 NONAME
+	_ZN7CDevTTS6VolumeEv @ 15 NONAME
+	_ZN7CDevTTS7BalanceEv @ 16 NONAME
+	_ZN7CDevTTS9AddStyleLERK9TTtsStyle @ 17 NONAME
+	_ZN7CDevTTS9MaxVolumeEv @ 18 NONAME
+	_ZN7CDevTTS9SetVolumeEi @ 19 NONAME
+	_ZN7CDevTTSD0Ev @ 20 NONAME
+	_ZN7CDevTTSD1Ev @ 21 NONAME
+	_ZN7CDevTTSD2Ev @ 22 NONAME
+	_ZNK7CDevTTS12GetPositionLER11TTtsSegmentRi @ 23 NONAME
+	_ZNK7CDevTTS12GetPositionLER25TTimeIntervalMicroSeconds @ 24 NONAME
+	_ZNK7CDevTTS14NumberOfStylesEv @ 25 NONAME
+	_ZNK7CDevTTS19IsLanguageSupportedE9TLanguage @ 26 NONAME
+	_ZNK7CDevTTS6StyleLEm @ 27 NONAME
+	_ZNK7CDevTTS6StyleLEt @ 28 NONAME
+	_ZTI12CDevTTSAudio @ 29 NONAME ; #<TI>#
+	_ZTI20CTTSAlgorithmManager @ 30 NONAME ; #<TI>#
+	_ZTI7CDevTTS @ 31 NONAME ; #<TI>#
+	_ZTV12CDevTTSAudio @ 32 NONAME ; #<VT>#
+	_ZTV20CTTSAlgorithmManager @ 33 NONAME ; #<VT>#
+	_ZTV7CDevTTS @ 34 NONAME ; #<VT>#
+	_ZN7CDevTTS14NormalizeTextLER14CTtsParsedText @ 35 NONAME
+	_ZN7CDevTTS23LanguageIdentificationLER14CTtsParsedTextiR6RArrayI9TLanguageERS2_IiE @ 36 NONAME
+	_ZN7CDevTTS24NormalizeAndSegmentTextLER14CTtsParsedText @ 37 NONAME
+	_ZN7CDevTTS15SetAudioOutputLEi @ 38 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for DevTTS.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nssdevtts.mmp
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/group/nssdevtts.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for DevTTS
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+TARGET          nssdevtts.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101FF928 // UID: 270530865
+
+VENDORID        VID_DEFAULT
+
+// Define this if no TtpHwDevice is available
+//MACRO         DEVTTS_NO_TTP
+
+// Define this if audio buffer should be written to a file
+//MACRO         DEVTTS_AUDIOBUFFER_TO_FILE
+
+SOURCEPATH      ../src
+SOURCE          nssdevtts.cpp
+SOURCE          devttsalgorithmmanager.cpp
+SOURCE          devttsaudio.cpp
+SOURCE          devttscenrep.cpp
+
+START RESOURCE  nssdevtts.rss
+HEADER
+#include "data_caging_paths.hrh"
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../src
+USERINCLUDE     ../../group
+USERINCLUDE     ../../inc
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/mmf
+SYSTEMINCLUDE   /epoc32/include/mmf/server
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+// For RUBY_DEBUG
+USERINCLUDE     ../../rubydebug
+
+
+LIBRARY         audiooutputrouting.lib
+LIBRARY         euser.lib
+LIBRARY         mmfdevsound.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         nssttscommon.lib
+LIBRARY         centralrepository.lib
+LIBRARY         asrsttshwdevice.lib
+#ifndef DEVTTS_NO_TPP
+LIBRARY         asrsttphwdevice.lib
+#endif
+LIBRARY         asrsnlphwdevice.lib
+
+LANG            SC
+
+CAPABILITY      CAP_GENERAL_DLL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/devttsalgorithmmanager.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1235 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementations for CTTSAlgorithmManager methods.
+*
+*/
+
+
+// INCLUDE FILES
+#include <barsc.h>
+#include <bautils.h>
+#include <barsread.h>
+#include <nssdevtts.rsg>
+#include <AudioPreference.h>
+#include <data_caging_path_literals.hrh>
+#include "devttsalgorithmmanager.h"
+#include "rubydebug.h"
+
+#ifdef _DEBUG
+#include <e32svr.h>
+#endif
+
+// CONSTANTS
+_LIT( KResourceFileName, "nssdevtts.rsc" );
+
+// Default audio priority
+const TInt KDefaultPriority = KAudioPriorityVoiceDial;
+
+#ifdef DEVTTS_AUDIOBUFFER_TO_FILE
+const TFileName KAudioBufferFileName( _L( "c:\\documents\\devttsaudio" ) );
+const TFileName KAudioBufferFileNameExtension( _L( ".raw" ) );
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::CTTSAlgorithmManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTTSAlgorithmManager::CTTSAlgorithmManager( MDevTTSObserver& aObserver ):
+        iPaused( EFalse ),
+        iObserver( aObserver ),
+        iAudio( NULL ),
+        iAudioState( ETTSAudioPlayerNotInitialized ),
+        iHw( NULL ),
+        iError( KErrNone ),
+        iState( EDevTTSNotInitialized ),
+        iMode( EDevTTSSoundDeviceMode ),
+        iLastBufferFromTts( EFalse ),
+        iTtpHw( NULL ), 
+#ifdef DEVTTS_3DB_HACK
+		iApplyGain( ETrue ),
+#endif
+        iNlp( NULL ),
+        iNlpInitialized( EFalse )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::ConstructL(/*CConsoleBase* console*/)
+    {
+    RUBY_DEBUG_BLOCK( "CTTSAlgorithmManager::ConstructL" );
+    
+    TBool boolStereo( EFalse );
+    TUint intStereo( 0 );
+    TUint bitsPerSample( 16 );
+    TUint samplingRate( 16000 );
+    TUint bufferSize( 4096 );
+    TInt defaultPriority( 0 );
+    
+    // Try to find resource file first from MMC, then from C-drive and only 
+    // after that from flash
+    // letters for drives in search order
+    const TBuf<2> KResourceDrives = _L("cz"); 
+    
+    // load resources
+    RResourceFile resourceFile;
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    
+    TFileName name;
+    TInt i( 0 );
+    // try to find from the first driver
+    name.Append( KResourceDrives[i] );
+    name.Append( ':' );
+    name.Append( KDC_RESOURCE_FILES_DIR );
+    name.Append( KResourceFileName );
+
+    TBool found( EFalse );
+    
+    while ( !found && i < KResourceDrives.Length() )
+        {
+        name[0] = KResourceDrives[i++];
+       
+        if ( BaflUtils::FileExists(fs, name) )
+            {
+            // open resource
+            resourceFile.OpenL( fs, name );
+            CleanupClosePushL( resourceFile );
+            found = ETrue;
+            }
+        }
+            
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    HBufC8* configurations = resourceFile.AllocReadLC( R_DEVTTS_CONFIGURATIONS );
+    
+    TResourceReader resReader;
+    resReader.SetBuffer( configurations );
+    
+    // Sampling rate
+    samplingRate = resReader.ReadUint32();
+
+    // Bits per sample
+    bitsPerSample = resReader.ReadUint32();
+    
+    // Mono / Stereo
+    intStereo = resReader.ReadUint32();
+
+    // Buffer size
+    bufferSize = resReader.ReadUint32();
+
+#ifdef __WINS__
+    // CMMFDevSound uses currently buffer size of 16384 in emulator. 
+    RUBY_DEBUG0( "CTTSAlgorithmManager::ConstructL - Hard coded buffer size in use!" );
+    bufferSize = 16384;
+#endif
+
+    // Priority
+    defaultPriority = KDefaultPriority;
+    
+    if ( intStereo == 0 )
+        {
+        boolStereo = EFalse;
+        }
+    else
+        {
+        boolStereo = ETrue;
+        }
+        
+    // Cleanup configurations, resourceFile, fs
+    CleanupStack::PopAndDestroy( configurations );    
+    CleanupStack::PopAndDestroy( &resourceFile );
+    CleanupStack::PopAndDestroy( &fs );
+
+    // Create new TtsHwDevice instance
+    iHw = CTtsHwDevice::NewL( *this, samplingRate, bufferSize );
+    
+    // Create audio playback instance
+    iAudio = CDevTTSAudio::NewL( *this, defaultPriority );
+    
+    iState = EDevTTSStopped;
+    
+    // Start audio device initialization process
+    iAudio->InitializeL();
+
+    // Wait for callback only if it is asynchronous
+    // (state will be something else if it is synchronous)
+    if ( iAudioState == ETTSAudioPlayerNotInitialized )
+        {
+        if ( !iAudioWait.IsStarted() )
+            {
+            RUBY_DEBUG0( "CTTSAlgorithmManager::ConstructL iAudioWait.Start()" );
+            iAudioWait.Start();
+            }
+        }
+        
+    iAudio->ConfigL( samplingRate, bitsPerSample, boolStereo, bufferSize);
+
+    // Create & initialize TtpHwDevice
+    iTtpHw = CASRSTtpHwDevice::NewL( *this );
+    iTtpHw->InitializeL();
+    iTtpHw->SetPhonemeNotationL( _L( "NIPA8" ) );
+    
+    // Create NlpHwDevice
+    TRAPD( error, iNlp = CNlpHwDevice::NewL( *this ) );
+    if ( error == KErrNone )
+        {
+        iNlp->InitializeL();
+        iNlpInitialized = ETrue;
+        }
+    else
+        {
+        iNlpInitialized = EFalse;
+        }
+
+#ifdef DEVTTS_AUDIOBUFFER_TO_FILE
+    User::LeaveIfError( iSession.Connect() );
+    iFileOpen = EFalse;
+    iFileCounter = 0;
+#endif
+
+    RUBY_DEBUG1( "CTTSAlgorithmManager config, sampling rate: %d", samplingRate );
+    RUBY_DEBUG1( "CTTSAlgorithmManager config, bits per sample: %d", bitsPerSample);
+    RUBY_DEBUG1( "CTTSAlgorithmManager config, mono/stereo: %d", intStereo);
+    RUBY_DEBUG1( "CTTSAlgorithmManager config, buffer size: %d", bufferSize);
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTTSAlgorithmManager* CTTSAlgorithmManager::NewL( MDevTTSObserver& aObserver/*, CConsoleBase* console*/ )
+    {
+    CTTSAlgorithmManager* self = new( ELeave ) CTTSAlgorithmManager(aObserver);
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( /*console*/ );
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::~CTTSAlgorithmManager
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTTSAlgorithmManager::~CTTSAlgorithmManager()
+    {
+    if ( iAudio )
+        {
+        iAudio->Clear();
+        delete iAudio;
+        iAudio = NULL;
+        }
+    if ( iHw )
+        {
+        delete iHw;
+        iHw = NULL;
+        }
+    if ( iTtpHw )
+        {
+        iTtpHw->Clear();
+        delete iTtpHw;
+        iTtpHw = NULL;
+        }
+    if ( iNlp )
+        {
+        iNlp->Clear();
+        delete iNlp;
+        iNlp = NULL;
+        }
+#ifdef DEVTTS_AUDIOBUFFER_TO_FILE
+    iSession.Close();
+#endif
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::AddStyleL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+TTtsStyleID CTTSAlgorithmManager::AddStyleL( const TTtsStyle& aStyle )
+    {
+    return iHw->AddStyleL( aStyle );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::Balance
+// Forwards call to the CDevTTSAudio.
+// -----------------------------------------------------------------------------
+//
+TInt CTTSAlgorithmManager::Balance()
+    {
+    return iAudio->Balance();
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::BufferProcessed
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::BufferProcessed( const TDesC8& aBuffer )
+    {
+    // Client should call this only when buffers are provided to client
+    if ( iMode == EDevTTSClientMode )
+        {
+        iHw->BufferProcessed( aBuffer );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::CustomInterface
+// Not in use currently. Now returns NULL.
+// -----------------------------------------------------------------------------
+//
+TAny* CTTSAlgorithmManager::CustomInterface( TUid /*aInterfaceID*/ )
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::DeleteStyleL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::DeleteStyleL( TTtsStyleID aStyleID )
+    {
+    iHw->DeleteStyleL( aStyleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::GetPositionL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::GetPositionL( TTimeIntervalMicroSeconds& aTime ) const
+    {
+    iHw->GetPositionL( aTime );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::GetPositionL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::GetPositionL( TTtsSegment& aSegment, TInt& aWordIndex ) const
+    {
+    iHw->GetPositionL( aSegment, aWordIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::IsLanguageSupported
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+TBool CTTSAlgorithmManager::IsLanguageSupported( TLanguage aLanguage ) const
+    {
+    return iHw->IsLanguageSupported( aLanguage );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MaxVolume
+// Forwards call to the CDevTTSAudio.
+// -----------------------------------------------------------------------------
+//
+TInt CTTSAlgorithmManager::MaxVolume()
+    {
+    return iAudio->MaxVolume();
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::NumberOfStyles
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+TUint16 CTTSAlgorithmManager::NumberOfStyles() const
+    {
+    return iHw->NumberOfStyles();
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::Pause
+// Pauses synthesis process in TtsHwDevice and also audio playback if needed.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::Pause()
+    {
+    // Do nothing if not synthesizing currently
+    if ( iState != EDevTTSSynthesizing )
+        {
+        return;
+        }
+    
+    // Stop synthesis and playback
+    iHw->Pause();
+
+    if( iMode == EDevTTSSoundDeviceMode )
+        {
+        // Do a complete stop to the audio player instead of pause.
+        // Pausing and resuming after that leads to the situation where all of
+        // the data won't be played...
+        iAudio->Stop();
+        iAudioState = ETTSAudioPlayerPaused;
+        }
+    
+    iState = EDevTTSPrimed;
+    iPaused = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::PrimeSynthesisL
+// Prepares a synthesizing process, data will be read from client using a 
+// stream.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::PrimeSynthesisL( MTtsSegmentStream& aStream ) 
+    {
+    // Not yet in use, leave every time
+    // @todo: Remove this when functionality is available
+    User::Leave( KErrNotSupported );
+    
+    // Do the state check    
+    if ( iState == EDevTTSNotInitialized )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    if ( iState != EDevTTSStopped )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    iHw->PrimeSynthesisL( aStream );
+    
+    iState = EDevTTSPrimed;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::PrimeSynthesisL
+// Prepares a synthesizing process.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::PrimeSynthesisL( CTtsParsedText& aText )
+    {
+    RUBY_DEBUG_BLOCK( "CTTSAlgorithmManager::PrimeSynthesisL" );
+
+    // Do the state check
+    
+    if ( iState == EDevTTSNotInitialized )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    if (iState != EDevTTSStopped)
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    // 1. Analyze structure if no segments in the parsed text object
+    if ( aText.NumberOfSegments() == 0 )
+        {
+        iHw->AnalyzeStructureL( aText );
+        }
+
+    // 2. Call NLP if there is written text
+    if ( ( aText.Text() != KNullDesC16 ) && iNlpInitialized )
+        {
+        
+        TBool useNlp( ETrue );
+        TInt counter( 0 );
+        
+        // Loop through content types of segments to find out if NLP should be used
+        for ( counter = 0; counter < aText.NumberOfSegments(); counter++ )
+            {
+            TTtsSegment segment = aText.SegmentL( counter );
+            TTtsStyleID styleID = segment.StyleID();
+            TTtsStyle& style = StyleL( styleID );
+            
+            if ( !style.iNlp )
+                {
+                useNlp = EFalse;                
+                }
+            }
+        
+        if ( useNlp )
+            {
+            // If language is not specified, run LID before NLP
+            for ( counter = 0; counter < aText.NumberOfSegments(); counter++ )
+                {
+                TTtsSegment segment = aText.SegmentL( counter );
+                TTtsStyleID styleID = segment.StyleID();
+                TTtsStyle& style = StyleL( styleID );
+
+                if ( style.iLanguage == ELangOther )
+                    {
+                    RArray<TLanguage> languages;
+                    RArray<TInt> scores;
+                
+                    // Only one result is needed
+                    iTtpHw->LanguageIdentificationL( segment.TextPtr(), 1, languages, scores );
+
+                    if ( languages.Count() == 0 )
+                        {
+                        languages.Close();
+                        scores.Close();
+                        User::Leave( KErrGeneral );
+                        }
+
+                    style.iLanguage = languages[0];
+
+                    RUBY_DEBUG1( "CTTSAlgorithmManager::PrimeSynthesisL called LID [lang id: %d] before NLP", style.iLanguage );
+
+                    languages.Close();
+                    scores.Close();
+                    }
+                }
+            }
+            
+        if ( useNlp )
+            {
+            iNlp->NormalizeTextL( aText );
+            }
+        }
+
+    // Set the phoneme notation which is given within parsed text into TTP
+    // Do this only if no phonemesequence is given and if notation is something
+    // else than the default
+    if ( ( aText.PhonemeNotation() != KNullDesC16 ) && ( aText.PhonemeSequence() == KNullDesC8 ) )
+        {
+        iTtpHw->SetPhonemeNotationL( aText.PhonemeNotation() );
+        }
+
+    // 3. Do the TTP if phoneme sequence not available
+    if ( aText.PhonemeSequence() == KNullDesC8 )
+        {
+        // If also text is NULL, argument is not ok
+        if ( aText.Text() == KNullDesC16 )
+            {
+            User::Leave( KErrArgument );
+            }
+        
+#ifdef __SIND_MULTIPLE_SEGMENTS
+        RArray<TInt> segmentPhonemeLengths;
+        CleanupClosePushL(segmentPhonemeLengths);
+#endif // __SIND_MULTIPLE_SEGMENTS
+        // Find the style attached to each segment
+        for ( TInt i = 0; i < aText.NumberOfSegments(); i++ )
+            {
+            TTtsSegment segment = aText.SegmentL( i );
+            TTtsStyleID styleID = segment.StyleID();
+            TTtsStyle& style = StyleL( styleID );
+            
+            RUBY_DEBUG1( "CTTSAlgorithmManager::PrimeSynthesisL calling TTP with lang id [%d]", style.iLanguage );
+
+            HBufC8* phonemeBuffer = iTtpHw->ConvertTextL( segment.TextPtr(), style.iLanguage );
+            
+            if ( phonemeBuffer == NULL )
+                {
+                RUBY_DEBUG0( "CTTSAlgorithmManager::PrimeSynthesisL TTP returned NULL, calling again with ELangOther" );
+
+                // Try with another approach, use ELangOther as language and let
+                // the LID to do the job
+                if ( style.iLanguage != ELangOther )
+                    {
+                    style.iLanguage = ELangOther;
+                    phonemeBuffer = iTtpHw->ConvertTextL( segment.TextPtr(), style.iLanguage );
+                    RUBY_DEBUG1( "CTTSAlgorithmManager::PrimeSynthesisL LID returned lang id [%d]", style.iLanguage );
+                    if ( phonemeBuffer == NULL )
+                        {
+                        User::Leave( KErrGeneral );
+                        }
+                    }
+                else
+                    {
+                    User::Leave( KErrGeneral );
+                    }
+                }
+
+            CleanupStack::PushL( phonemeBuffer );
+
+#ifdef __SIND_MULTIPLE_SEGMENTS
+            // Append segment's phone sequence to CTtsparsedText's phoneme sequence
+            HBufC8*  phonemeSeq = HBufC8::NewLC( aText.PhonemeSequence().Length() + phonemeBuffer->Des().Length() );
+            phonemeSeq->Des().Append( aText.PhonemeSequence() );
+            phonemeSeq->Des().Append( phonemeBuffer->Des() );
+            // Set new phoneme sequence
+            aText.SetPhonemeSequenceL( *phonemeSeq );
+            CleanupStack::PopAndDestroy( phonemeSeq );
+            
+            // Save the length of segment's phoneme sequence
+            segmentPhonemeLengths.AppendL( phonemeBuffer->Des().Length() );
+
+#else
+            aText.SetPhonemeSequenceL( phonemeBuffer->Des() );
+            
+            segment.SetPhonemeSequencePtr( aText.PhonemeSequence() );
+            // Add modified segment to parsed text
+            aText.DeleteSegmentL( i );
+            aText.AddSegmentL( segment, i );
+#endif // __SIND_MULTIPLE_SEGMENTS
+            
+            // phonemeBuffer
+            CleanupStack::PopAndDestroy( phonemeBuffer );
+            }
+        
+#ifdef __SIND_MULTIPLE_SEGMENTS
+        // Put pointers of the whole phone sequence in CTtsParsedText
+        // to their respective segments 
+        TInt position( 0 );
+        for ( TInt i = 0; i < aText.NumberOfSegments(); i++ )
+            {
+            TTtsSegment segment = aText.SegmentL( i );
+            segment.SetPhonemeSequencePtr( aText.PhonemeSequence().Mid( position, segmentPhonemeLengths[i] ) );
+            // Add modified segment to parsed text
+            aText.DeleteSegmentL( i );
+            aText.AddSegmentL( segment, i );
+            // Move the position to next segments starting position
+            position += segmentPhonemeLengths[i];
+            }
+        
+        // Release resources allocated by RArray    
+        CleanupStack::PopAndDestroy( &segmentPhonemeLengths );
+#endif // __SIND_MULTIPLE_SEGMENTS
+        
+        }
+
+#ifdef DEVTTS_3DB_HACK
+	iApplyGain = ETrue;
+#endif
+
+
+    // 4. Analyze prosody
+    iHw->AnalyzeProsodyL( aText );    
+    
+    // 5. Prime TtsHwDevice
+    iHw->PrimeSynthesisL( aText );
+    
+    iState = EDevTTSPrimed;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetAudioPriority
+// Forwards call to the CDevTTSAudio
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetAudioPriority( TInt aPriority, TDevTTSAudioPreference aPref )
+    {
+    iAudio->SetAudioPriority( aPriority, aPref );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetAudioOutputL
+// Forwards call to the CDevTTSAudio
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetAudioOutputL( TInt aAudioOutput )
+    {
+    iAudio->SetAudioOutputL( aAudioOutput );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetBalance
+// Forwards call to the CDevTTSAudio
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetBalance( TInt aBalance )
+    {
+    iAudio->SetBalance( aBalance );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetPositionL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetPositionL( const TTimeIntervalMicroSeconds& aTime )
+    {
+    iHw->SetPositionL( aTime );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetPositionL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetPositionL( const TTtsSegment& aSegment, 
+                                         TInt aWordIndex )
+    {
+    iHw->SetPositionL( aSegment, aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetVolume
+// Forwards call to the CDevTTSAudio
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetVolume( TInt aVolume )
+    {
+    iAudio->SetVolume( aVolume );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SetVolumeRamp
+// Forwards call to the CDevTTSAudio
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration )
+    {
+    iAudio->SetVolumeRamp( aRampDuration );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::Stop
+// Stop synthesis process as well as audio playback if running.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::Stop()
+    {
+    if ( iState == EDevTTSNotInitialized )
+        {
+        // Just to play it safe, do nothing if not initialized
+        return;
+        }
+    
+    if ( iAudioState == ETTSAudioPlayerPlaying )
+        {
+        iAudio->Stop();
+        iAudioState = ETTSAudioPlayerIdle;
+        }
+    if ( iState == EDevTTSSynthesizing || iState == EDevTTSPrimed )
+        {
+        iHw->Stop();
+        }
+    
+    iState = EDevTTSStopped;
+    
+    // Clear paused flag. might be that we are stopping after pausing
+    iPaused = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::StyleL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTTSAlgorithmManager::StyleL( TTtsStyleID aStyleID ) const
+    {
+    return iHw->StyleL( aStyleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::StyleL
+// Forwards call to TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTTSAlgorithmManager::StyleL( TUint16 aIndex ) const
+    {
+    return iHw->StyleL(  aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::SynthesizeL
+// Starts or resumes synthesis process. 
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::SynthesizeL( TDevTTSOutputMode aOutputMode ) 
+    {
+    
+    if ( (iState == EDevTTSNotInitialized) || (iState == EDevTTSStopped) )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    if ( iState != EDevTTSPrimed )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    // If iPaused flag is set, we know that there is an
+    // ongoing synthesis process and we should resume that instead of starting
+    // a new one.
+    if ( iPaused )
+        {
+        // Resume synthesis by calling hwdevice
+        iHw->SynthesizeL();
+        
+        if ( iMode == EDevTTSSoundDeviceMode )
+            {
+            iAudio->PlayInitL();
+            
+            iAudioState = ETTSAudioPlayerPlaying;
+            }
+        iState = EDevTTSSynthesizing;
+        iPaused = EFalse;
+        return;
+        }
+    
+    iMode = aOutputMode;
+    
+    // Start synthesizing by calling hwdevice
+    iHw->SynthesizeL();
+    iLastBufferFromTts = EFalse;
+    
+    if ( iMode == EDevTTSSoundDeviceMode )
+        {
+        // Check the audio player state
+        if ( iAudioState == ETTSAudioPlayerNotInitialized || 
+            iAudioState == ETTSAudioPlayerError )
+            {
+            User::Leave( KErrNotReady );
+            }
+        
+        if ( iAudioState == ETTSAudioPlayerPlaying )
+            {
+            User::Leave( KErrInUse );
+            }
+        
+        // Initialize audio device so that it is ready for playback
+        iAudio->PlayInitL();
+        
+        iAudioState = ETTSAudioPlayerPlaying;
+        }
+    
+    iState = EDevTTSSynthesizing;
+
+    RUBY_DEBUG0( "CTTSAlgorithmManager::SynthesizeL started" );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::Volume
+// Forwards call to the CDevTTSAudio.
+// -----------------------------------------------------------------------------
+//
+TInt CTTSAlgorithmManager::Volume()
+    {
+    return iAudio->Volume();
+    }
+
+
+// ========================== CALLBACKS FROM DEVTTSAUDIO =======================
+
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::InitializeComplete
+// Audio has been initialized.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MdtaoInitializeComplete(TInt aError) 
+    {
+    if ( aError == KErrNone )
+        {
+        iAudioState = ETTSAudioPlayerIdle;
+        RUBY_DEBUG0( "CTTSAlgorithmManager::InitializeComplete ok" );
+        }
+    else
+        {
+        iAudioState = ETTSAudioPlayerError;
+        RUBY_DEBUG0( "CTTSAlgorithmManager::InitializeComplete ERROR" );
+        }
+        
+    if ( iAudioWait.IsStarted() )
+        {
+        RUBY_DEBUG0( "DEVTTS iAudioWait.AsyncStop()" );                	
+        iAudioWait.AsyncStop();
+        }                   
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MdtaoBufferToBeFilled
+// Audio player wants a new buffer so that it can be played.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MdtaoBufferToBeFilled( TDes8& aBuffer, 
+                                                  TInt aSizeRequested )
+    {
+    RUBY_DEBUG1( "CTTSAlgorithmManager::MdtaoBufferToBeFilled size of wanted audio buffer: %d bytes", aSizeRequested );
+    
+    // Sometimes it might happen that we get still one callback even though
+    // DevSound is not anymore playing
+    if ( iAudioState != ETTSAudioPlayerPlaying )
+        {
+        RUBY_DEBUG0( "CTTSAlgorithmManager::MdtaoBufferToBeFilled called even though iAudioState != ETTSAudioPlayerPlaying" );
+        return;
+        }
+
+    const TUint8* buffer = iPlaybackBuffer.Ptr();
+    
+    if ( iStartPoint >= iStopPoint )
+        {
+        // Underflow, nothing to be sent to audio out
+        aBuffer.FillZ( aSizeRequested );
+        aBuffer.SetLength( aSizeRequested );
+        
+        iAudio->PlayData( iLastBufferFromTts );
+        return;
+        }
+    
+    TInt copyLength = 0;
+    // Tells if the whole buffer given by TtsHwDevice has been played
+    TBool last = EFalse;
+    
+    if ( ( iStartPoint + aSizeRequested ) >= iStopPoint )
+        {
+        // We get to the end of the data that needs to be played
+        last = ETrue;
+        copyLength = iStopPoint - iStartPoint + 1;
+        
+        // Empty buffer
+        aBuffer.FillZ();
+        }
+    else
+        {
+        // Fill the whole requested size
+        copyLength = aSizeRequested;
+        }
+    
+    // Copy data to audio out buffer
+    aBuffer.Copy( &buffer[iStartPoint], copyLength);
+
+#ifdef DEVTTS_3DB_HACK
+	if( iApplyGain ) 
+	{
+		const TInt32 KSqrt2FXP = 0x00002d41L;
+		const TInt32 KSqrt2Shift = 13;
+		TPtr16 audioData((TUint16*)(aBuffer.Ptr()), copyLength/2, copyLength/2);
+		for( int i=0; i<copyLength/2; ++i )
+		{
+			TInt16 sample = audioData[i];
+			TInt32 newvalue = (sample * KSqrt2FXP) >> KSqrt2Shift; 
+			if(newvalue > 0x7fffL | newvalue < -0x8000L) 
+			{
+				
+				iApplyGain = EFalse;
+				break;
+			}
+			audioData[i] = newvalue;
+		}
+	}
+#endif
+    
+    // Notify TtsHwDevice
+    if ( last )
+        {
+        iHw->BufferProcessed( iPlaybackBuffer );
+        }
+    
+    RUBY_DEBUG1( "CTTSAlgorithmManager::MdtaoBufferToBeFilled Audio buffer size filled: %d bytes\n", aBuffer.Length() );
+    
+    iStartPoint = iStartPoint + copyLength;
+    
+    iAudio->PlayData( iLastBufferFromTts );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::PlayFinished
+// Checks the incoming error code and sets the audio state accordingly.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MdtaoPlayFinished( TInt aError )
+    {
+    iAudioState = ETTSAudioPlayerIdle;
+    
+    if ( aError == KErrNone ) 
+        {
+        // Don't put error code to aError since MthdTtsCompleted can
+        // be called with error code before this function is called
+        RUBY_DEBUG0( "CTTSAlgorithmManager::MdtaoPlayFinished ok" );
+        }
+    else
+        {
+        // Audio is interrupted by something with higher priority.
+        // Keep idle state for audio player since application might
+        // try again with better luck. (When there is no other apps trying
+        // to access audio out.)
+        iError = aError;
+        
+        // Stop TTS Hw device too
+        iHw->Stop();
+        
+        RUBY_DEBUG0( "CTTSAlgorithmManager::MdtaoPlayFinished audio interrupted" );
+        }
+ 
+    // Move automatically to stopped state
+    iState = EDevTTSStopped;
+    
+    // Call the client
+    iObserver.MdtoEvent( EDevTTSEventComplete, iError );
+    }
+
+
+
+// ========================== CALLBACKS FROM TtsHwDevice =======================
+
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MthdTtsCompleted
+// Called by TtsHwDevice when synthesis has completed
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MthdTtsCompleted( TInt aStatus )
+    {
+    iState = EDevTTSStopped;
+    
+    // Mark that previous received buffer is the last one
+    iLastBufferFromTts = ETrue;
+    
+    iError = aStatus;
+    
+    // Do the callback to client, handled by MdtaoPlayFinished if in sound device mode
+    if ( iMode == EDevTTSClientMode )
+        {
+        iObserver.MdtoEvent( EDevTTSEventComplete, aStatus );
+        }
+
+#ifdef DEVTTS_AUDIOBUFFER_TO_FILE
+    iFile.Close();
+    iFileOpen = EFalse;
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MthdCustomEvent
+// Custom event from TtsHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MthdCustomEvent( TInt /*aEvent*/, TInt /*aStatus*/, 
+                                           const TDesC8& /*aParameter*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MthdProcessBuffer
+// Prepares buffer for playback or forwards callback to client, depends on the
+// operation mode.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MthdProcessBuffer( const TDesC8& aBuffer )
+    {
+    RUBY_DEBUG0( "CTTSAlgorithmManager::MthdProcessBuffer" );
+    
+#ifdef DEVTTS_AUDIOBUFFER_TO_FILE
+    if ( iFileOpen == EFalse )
+        {
+        TFileName filename;
+        filename.Append( KAudioBufferFileName );
+        filename.AppendNum( iFileCounter );
+        filename.Append( KAudioBufferFileNameExtension );
+
+        iFile.Replace( iSession, filename, EFileWrite );
+        iFileOpen = ETrue;
+        iFileCounter++;
+        }
+    TInt size( 0 );
+    iFile.Size( size );
+    iFile.Seek( ESeekEnd, size );
+    iFile.Write( aBuffer );
+#endif
+
+    // Handle buffer internally if in sound device mode, otherwise just 
+    // forward the callback to client
+    if ( iMode == EDevTTSSoundDeviceMode )
+        {
+        // Store pointer to buffer
+        iPlaybackBuffer.Set( aBuffer );
+        // Mark start and stop points for the audio playback
+        iStartPoint = 0;
+        iStopPoint = aBuffer.Size() - 1;
+        }
+    else
+        {
+        iObserver.MdtoProcessBuffer( aBuffer );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MthdoConfigurationData
+// Forwards callback to client.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CTTSAlgorithmManager::MthdoConfigurationData( TUint32 aPackageType, 
+                                                      TUint32 aPackageID,
+                                                      TUint32 aStartPosition,
+                                                      TUint32 aEndPosition )
+    {
+    return iObserver.MdtoConfigurationData( aPackageType, aPackageID, 
+                                            aStartPosition, aEndPosition );
+    }
+
+
+// ====================== CALLBACKS FROM MASRSTtpHwDeviceObserver ==============
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MathdoConfigurationData
+// Forwards callback to client.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CTTSAlgorithmManager::MathdoConfigurationData( TUint32 aPackageType, 
+                                                       TUint32 aPackageID,
+                                                       TUint32 aStartPosition,
+                                                       TUint32 aEndPosition )
+    {
+    return iObserver.MdtoConfigurationData( aPackageType, aPackageID, 
+                                            aStartPosition, aEndPosition );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MathdoWordListReady
+// Should not be called since we always use synchrnous TTP.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MathdoWordListReady( const TInt /*aError*/ )
+    {
+    // Do nothing
+    }
+
+
+
+// ====================== CALLBACKS FROM MNlpHwDeviceObserver ==================
+
+
+// -----------------------------------------------------------------------------
+// MNlpHwDeviceObserver::MnhdNlpCompleted
+// Called when asynchronous NLP processing has been completed
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::MnhdoNlpCompleted( TInt /*aStatus*/ )
+    {
+    // Should not be called currently since NLP is handled synchronously
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MnhdoConfigurationData
+// NLP calls when it needs its configuration data to be loaded
+// -----------------------------------------------------------------------------
+//
+HBufC8* CTTSAlgorithmManager::MnhdoConfigurationData( TUint32 aPackageType, 
+                                                      TUint32 aPackageID, 
+                                                      TUint32 aStartPosition, 
+                                                      TUint32 aEndPosition )
+    {
+    return iObserver.MdtoConfigurationData( aPackageType, aPackageID, 
+                                            aStartPosition, aEndPosition );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::MnhdoStyleL
+// Called when NLP needs style information
+// -----------------------------------------------------------------------------
+//
+const TTtsStyle& CTTSAlgorithmManager::MnhdoStyleL( TTtsStyleID styleID )
+    {
+    // Call TtsHwDevice to get the wanted style
+    return iHw->StyleL( styleID );
+    }
+
+
+// ====================== New additions for SIND inc3 ==========================
+
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::LanguageIdentificationL
+// Does language identification.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::LanguageIdentificationL( CTtsParsedText& aText, 
+                                                    TInt aNumberOfGuesses, 
+                                                    RArray<TLanguage>& aLanguages,
+                                                    RArray<TInt>& aScores )
+    {
+    CheckStateL();
+
+    // Check that at least some text is given
+    if ( aText.Text() == KNullDesC16 )
+        {
+        User::Leave( KErrArgument);
+        }
+ 
+    // Call TtpHwDevice
+    iTtpHw->LanguageIdentificationL( aText.Text(), aNumberOfGuesses, aLanguages, aScores );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::NormalizeTextL
+// Normalizes text using NLPHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::NormalizeTextL( CTtsParsedText& aText )
+    {
+    if ( iNlp == NULL || !iNlpInitialized )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    CheckStateL();
+
+    iNlp->NormalizeTextL( aText );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::NormalizeAndSegmentTextL
+// Normalizes and segments the text using NLPHwDevice
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::NormalizeAndSegmentTextL( CTtsParsedText& aText )
+    {
+    if ( iNlp == NULL || !iNlpInitialized )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    CheckStateL();
+
+    iNlp->NormalizeAndSegmentTextL( aText );
+    }
+
+
+// ========================== PRIVATE FUNCTIONS ================================
+
+
+// -----------------------------------------------------------------------------
+// CTTSAlgorithmManager::CheckStateL
+// Checks that state of DevTTS is idle.
+// -----------------------------------------------------------------------------
+//
+void CTTSAlgorithmManager::CheckStateL()
+    {
+    if ( iState == EDevTTSNotInitialized )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    if ( iState != EDevTTSStopped )
+        {
+        User::Leave( KErrInUse );
+        }
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/devttsalgorithmmanager.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,601 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementations behind DevTTS interface
+*
+*/
+
+
+#ifndef DEVTTSALGORITHMMANAGER_H
+#define DEVTTSALGORITHMMANAGER_H
+
+// INCLUDES
+#include "srsfbldvariant.hrh"
+#include "nssdevtts.h"
+#include "devttsaudio.h"
+
+#include <asrsttshwdevice.h>
+#include <asrsttphwdevice.h>
+#include <asrsnlphwdevice.h>
+
+// CLASS DECLARATION
+
+/**
+* CTTSAlgorithmManager contains implementations behind DevTTS interface.
+* Observer callbacks from TtsHwDevice and DevTTSAudio
+*
+*  @lib NssDevTts.lib
+*/
+class CTTSAlgorithmManager : public CBase, public MDevTTSAudioObserver,
+                             public MTtsHwDeviceObserver,
+                             public MASRSTtpHwDeviceObserver,
+                             public MNlpHwDeviceObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param "MDevTTSObserver& aObserver"
+        *        Reference to the callback observer.
+        */ 
+        static CTTSAlgorithmManager* NewL( MDevTTSObserver& aObserver/*, CConsoleBase* console*/ );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTTSAlgorithmManager();
+        
+    public: // New functions
+        
+        /**
+        * Adds a new style to the collection. If equal style exists already,
+        * new style is not added.
+        * Will leave if an error occurs. Likely errors are: KErrNoMemory,
+        * not enough memory to add new style. KErrNotSupported, the style 
+        * is not supported. KErrArgument, the style contains an imposible 
+        * value.
+        *
+        * @param "TTtsStyle& aStyle"
+        *        Reference to the style which will be added to the style 
+        *        collection.
+        *
+        * @return Identifier of added style.
+        */
+        TTtsStyleID AddStyleL( const TTtsStyle& aStyle );
+
+        /**
+        * Returns the current balance setting.
+        *
+        * @return Balance value.
+        */
+        TInt Balance();
+        
+        /**
+        * Notifies that the buffer has been processed. The 
+        * method is used if output mode of synthesizing is 
+        * EDevTTSClientMode.
+        *
+        * @param "TDesC8& aBuffer"
+        *        The buffer which has been processed.
+        */
+        void BufferProcessed( const TDesC8& aBuffer );
+        
+        /**
+        * Request a pointer to the custom interface. Currently not in use.
+        * 
+        * @param "TUid aInterfaceID"
+        *        Custom interface identifier.
+        *
+        * @return Pointer to custom interface. NULL if interface is not 
+        *         found or initiation failures.
+        */
+        TAny* CustomInterface( TUid aInterfaceID );
+
+        /**
+        * Deletes style.
+        * 
+        * @param "TTtsStyleID aStyleID" Identifier of style to be deleted.
+        */
+        void DeleteStyleL( TTtsStyleID aStyleID );
+        
+        /**
+        * Gives current position of synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing.
+        * 
+        * @param "TTimeIntervalMicroSeconds& aTime"
+        *        Time of the synthesizing position
+        */
+        void GetPositionL( TTimeIntervalMicroSeconds& aTime ) const;
+        
+        /**
+        * Gives current position of synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing.
+        * 
+        * @param "TTtsSegment& aSegment"
+        *        Current segment which is synthesized, out parameter
+        * @param "TInt& aWordIndex"
+        *        Index of the current word, starting from the begining of 
+        *        current segment
+        */
+        void GetPositionL( TTtsSegment& aSegment, TInt& aWordIndex ) const;
+        
+        /**
+        * Tells if language is supported by the TTS engine or not.
+        * 
+        * @param "TLanguage aLanguage"
+        *        Language code
+        *
+        * @return ETrue if supported, EFalse otherwise
+        */
+        TBool IsLanguageSupported( TLanguage aLanguage ) const;
+
+        /**
+        * Returns maximum volume value.
+        * 
+        * @return Maximum volume.
+        */
+        TInt MaxVolume();
+        
+        /**
+        * Gives number of styles.
+        * 
+        * @return Number of styles.
+        */
+        TUint16 NumberOfStyles() const;
+        
+        /**
+        * Pauses synthesizing.
+        */
+        void Pause();
+        
+        /**
+        * Prepares for synthesis. The method will leave if an 
+        * error occurs. Likely errors are: KErrInUse, synthesizing is 
+        * currently ongoing. KErrNoMemory, not enough memory to start 
+        * synthesis. KErrNotSupport, requested function is not supported.
+        * 
+        * @param "MTtsSegmentStream& aStream"
+        *        Stream to be synthesized.
+        */
+        void PrimeSynthesisL( MTtsSegmentStream& aStream );
+        
+        /**
+        * Prepares for synthesis. The method will leave if an 
+        * error occurs. Likely errors are: KErrInUse, synthesizing is 
+        * currently ongoing. KErrNoMemory, not enough memory to start 
+        * synthesis. KErrNotSupport, requested function is not supported.
+        * 
+        * @param "CTtsParsedText& aText"
+        *        Text containing multiple segments to be synthesized.
+        */
+        void PrimeSynthesisL( CTtsParsedText& aText );
+        
+        /**
+        * Sets the priority for audio playback if in EDevTTSSoundDeviceMode.
+        * 
+        * @param "TInt iPriority"
+        *        Priority value.
+        * @param "TDevTTSAudioPreference iPref"'
+        *        Preference setting. Quality, time or both.
+        */
+        void SetAudioPriority( TInt aPriority, TDevTTSAudioPreference aPref );
+
+        /**
+        * Sets the audio output routing
+        * 
+        * @param TInt aAudioOutput
+        *        New output.
+        */
+        void SetAudioOutputL( TInt aAudioOutput );
+
+        /**
+        * Sets the playback device balance. Affects only when DevTTS is in 
+        * EDevTTSSoundDeviceMode. Illegal values are neglected.
+        * 
+        * @param "TInt aBalance" Balance to be set. 
+        */
+        void SetBalance( TInt aBalance );
+               
+        /**
+        * Sets new position for synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing. KErrArgument, position cannot be set.
+        * 
+        * @param "TTimeIntervalMicroSeconds& aTime"
+        *        Time of the synthesizing postion.
+        */
+        void SetPositionL( const TTimeIntervalMicroSeconds& aTime );
+        
+        /**
+        * Sets new position for synthesizing. The method will leave if an 
+        * error occurs. Likely errors are: KErrNotReady, no synthesizing is 
+        * ongoing. KErrArgument, position cannot be set.
+        * 
+        * @param "TTTtsSegment& aSegment"
+        *        The segment being synthesized.
+        * @param "TInt aWordIndex"
+        *        The index of word being synthesized.
+        */
+        void SetPositionL( const TTtsSegment& aSegment, TInt aWordIndex );
+        
+        /**
+        * Sets the playback device volume. Affects only when DevTTS is in 
+        * EDevTTSSoundDeviceMode. Range is from 0..MaxVolume(). Illegal values 
+        * are neglected.
+        * 
+        * @param "TInt aVolume" Volume setting.
+        */
+        void SetVolume( TInt aVolume );
+
+        /**
+        * Sets the volume ramp duration. Start and end volumes must be set with
+        * SetVolume() function.
+        * 
+        * @param "TTimeIntervalMicroSeconds& aRampDuration" 
+        *        Ramp duration in microseconds.
+        */
+        void SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration );
+
+        /**
+        * Stops synthesizing and releases resources of synthesizing. 
+        * The method does nothing if already stopped.
+        */
+        void Stop();
+        
+        /**
+        * Receives style information. The method will leave if an error 
+        * occurs. Likely errors are: KErrNotFound, style identifier not 
+        * found. 
+        * 
+        * @param "TTtsStyleID aStyleID"
+        *        Style identifier.
+        *
+        * @return Reference to style
+        */
+        TTtsStyle& StyleL( TTtsStyleID aStyleID ) const;
+        
+        /**
+        * Receives style information. The method will leave if an error 
+        * occurs. Likely errors are: KErrArgument, index is out of bounds.
+        * 
+        * @param "TUint16 aIndex"
+        *        Index to style: 0..NumberOfStyles().
+        *
+        * @return Reference to style
+        */ 
+        TTtsStyle& StyleL( TUint16 aIndex ) const;
+        
+        /**
+        * Starts synthesizing the text. The method is asynchronous, as soon
+        * as the request has been placed, function call will return. 
+        * MDevTTSObserver::MdtoEvent will be called when synthesizing finishes.
+        * The method will leave if an error occurs. Likely errors are: 
+        * KErrNoMemory, not enough memory. 
+        * KErrInUse, synthesizing is currently ongoing
+        * 
+        * @param "TDevTTSOutputMode aOutputMode"
+        *        Either use a sound device (EDevTTSSoundDeviceMode) or client 
+        *        using callback (EDevTTSClientMode)
+        */
+        void SynthesizeL( TDevTTSOutputMode aOutputMode );
+
+        /**
+        * Returns current playback volume.
+        * 
+        * @return Volume setting.
+        */       
+        TInt Volume();
+
+        /** 
+        * Calls language identification for a given text.
+        *
+        * @since 3.0M
+        * @param "CTtsParsedText& aText" Text
+        * @param "TInt aNumberOfGuesses" Maximum number of guesses that will be provided
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which will contain the languages
+        * @param "RArray<TInt>& aScores" Scores
+        */
+        void LanguageIdentificationL( CTtsParsedText& aText, 
+                                      TInt aNumberOfGuesses, 
+                                      RArray<TLanguage>& aLanguages,
+                                      RArray<TInt>& aScores );
+
+        /**
+        * Calls Natural Language Processing (NLP) to normalize text.
+        *
+        * @since 3.0M
+        * @param "CTtsParsedText& aText" Text which will be normalized
+        */
+        void NormalizeTextL( CTtsParsedText& aText );
+
+        /**
+        * Calls Natural Language Processing (NLP) to normalize and segment text.
+        *
+        * @since 3.0M
+        * @param "CTtsParsedText& aText" Text which will be normalized
+        */
+        void NormalizeAndSegmentTextL( CTtsParsedText& aText );
+        
+    public: // Functions from base classes
+        
+        /**
+        * From MDevTTSAudioObserver::InitializeComplete
+        *
+        * @param "TInt aError"
+        *        KErrNone if everything is ok, system wide error code otherwise
+        */
+        void MdtaoInitializeComplete( TInt aError );
+        
+        /**
+        * From MDevTTSAudioObserver::BufferToBeFilled
+        *
+        * @param "TDes8& aBuffer"
+        *        Descriptor which should be filled
+        * @param "TInt aSizeRequested"
+        *        Number of bytes requested
+        */
+        void MdtaoBufferToBeFilled( TDes8& aBuffer, TInt aSizeRequested );
+        
+        /**
+        * From MDevTTSAudioObserver::PlayFinished
+        *
+        * @param "TInt aError"
+        *        KErrNone if everything is ok, system wide error code otherwise
+        */
+        void MdtaoPlayFinished( TInt aError );
+        
+        
+        
+        
+        /**
+        * From MTtsHwDeviceObserver::MthdTtsCompleted
+        *
+        * Called by the HW device when the synthesis has been completed.
+        *
+        * @param "TInt aStatus" Error code, KErrNone if success
+        */
+        void MthdTtsCompleted( TInt aStatus );
+        
+        /**
+        * From MTtsHwDeviceObserver::MthdCustomEvent
+        *
+        * Called by the HW device when custom command implementation wants 
+        * to notify a client.
+        *
+        * @param "TInt aEvent" Event code 
+        * @param "TInt aStatus" Error code, KErrNone if success.
+        * @param "TDesC8& aParameter" Optional parameter 
+        */
+        void MthdCustomEvent( TInt aEvent, TInt aStatus, 
+                              const TDesC8& aParameter = KNullDesC8 );
+        
+        /**
+        * From MTtsHwDeviceObserver::MthdProcessBuffer
+        *
+        * Called by the HW device when the HW device has synthesized a new audio buffer.
+        *
+        * @param "TDesC8& aBuffer"
+        *         Synthesized audio buffer.
+        */
+        void MthdProcessBuffer( const TDesC8& aBuffer );
+        
+        /**
+        * From MTtsHwDeviceObserver::MthdoConfigurationData
+        *
+        * Invoked by TTS HW Device when it needs a configuration data package.
+        *
+        * @param "TUint32 aPackageType" Type identifier. 
+        * @param "TUint32 aPackageID" Identifier of package
+        * @param "TUint32 aStartPosition" Start index in bytes
+        * @param "TUint32 aEndPosition" End index in bytes. If the position is bigger 
+        *         than the size of data package, the end part will be returned.
+        * @return Pointer to buffer containing data.
+        */
+        HBufC8* MthdoConfigurationData( TUint32 aPackageType, 
+                                        TUint32 aPackageID, 
+                                        TUint32 aStartPosition, 
+                                        TUint32 aEndPosition );
+
+        
+        
+
+        /**
+        * From MASRSTtpHwDeviceObserver::MathdoConfigurationData
+        *
+        * Callback function to load configuration data.
+        * Client provides an implementation.
+        *
+        * @param "TUint32 aPackageType" Type identifier.
+        * @param "TUint32 aPackageID" Package identifier.
+        * @param "TUint32 aStartPosition" First byte.
+        * @param "TUint32 aEndPosition" Last byte. If greater than the size of 
+        *                               the data, rest of the data is given.
+        * @return Pointer to the data buffer, TTP HW Device takes ownership.
+        */	
+        HBufC8* MathdoConfigurationData( TUint32 aPackageType, TUint32 aPackageID,
+                                         TUint32 aStartPosition,
+                                         TUint32 aEndPosition );
+
+		/**
+        * From MASRSTtpHwDeviceObserver::MathdoWordListReady
+        *
+        * Callback function to notify that word list is converted.
+        * Client provides an implementation.
+        *
+        * @param "TInt aError" Error code, KErrNone if successful.
+        */	
+		void MathdoWordListReady( const TInt aError );
+        
+
+        /**
+        * From MNlpHwDeviceObserver::MnhdNlpCompleted
+        *
+        * Called by the HW device when the synthesis has been completed.
+        * @param aStatus Error code, KErrNone if success
+        * @return none
+        */
+        void MnhdoNlpCompleted( TInt aStatus );
+        
+        /**
+        * From MNlpHwDeviceObserver::MnhdoConfigurationData
+        *
+        * Invoked by TTS HW Device when it needs a configuration data package.
+        * @param aPackageType Type identifier. 
+        * @param aPackageID Identifier of package
+        * @param aStartPosition Start index in bytes
+        * @param aEndPosition End index in bytes. If the position is bigger 
+        *         than the size of data package, the end part will be returned.
+        * @return Data package in a buffer
+        */
+        HBufC8* MnhdoConfigurationData( TUint32 aPackageType, 
+                                        TUint32 aPackageID, 
+                                        TUint32 aStartPosition, 
+                                        TUint32 aEndPosition );
+
+        /**
+        * From MNlpHwDeviceObserver::MnhdCustomEvent
+        *
+        * Returns style given the style id.
+        */		
+	   	const TTtsStyle& MnhdoStyleL( TTtsStyleID styleID );
+
+       
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CTTSAlgorithmManager( MDevTTSObserver& aObserver );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( /*CConsoleBase* console*/ );
+        
+        /**
+        * Checks if state is idle and leaves in case of error.
+        */
+        void CheckStateL();
+ 
+        // Prohibit copy constructor
+        CTTSAlgorithmManager( const CTTSAlgorithmManager& );
+        // Prohibit assigment operator
+        CTTSAlgorithmManager& operator=( const CTTSAlgorithmManager& );
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        
+        //State enumeration
+        enum TDevTTSState
+            {
+            EDevTTSNotInitialized = 0,
+            EDevTTSStopped,
+            EDevTTSPrimed,
+            EDevTTSSynthesizing
+            };
+        
+        enum TTTSAudioPlayerState
+            {
+            ETTSAudioPlayerNotInitialized = 0,
+            ETTSAudioPlayerInitializing,
+            ETTSAudioPlayerIdle,
+            ETTSAudioPlayerPlaying,
+            ETTSAudioPlayerRecording, // Reserved for future
+            ETTSAudioPlayerPaused,
+            ETTSAudioPlayerError
+            };
+        
+        
+        // Flag which will be set if there is an ongoing synthesis when we are 
+        // in paused state.
+        TBool iPaused;
+        
+        // Reference to the registered oberserver
+        MDevTTSObserver& iObserver;
+        
+        // For audio playback
+        CDevTTSAudio* iAudio;
+        
+        // Audio device state
+        TTTSAudioPlayerState iAudioState;
+        
+        // Pointer to the tts hw device
+        CTtsHwDevice* iHw;
+        
+        // Stored error value, either from audio device or from TtsHwDevice
+        TInt iError;
+        
+        // Current state of the object
+        TDevTTSState iState;
+        
+        // Current mode of operation, buffers to audio device or to client
+        TDevTTSOutputMode iMode;
+        
+        // Flag which is set when last buffer from TtsHwDevice has arrived
+        TBool iLastBufferFromTts;
+        
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+       
+        // TtpHwDevice
+        CASRSTtpHwDevice* iTtpHw;
+        
+        // Pointer to the beginning of playback data
+        TPtrC8 iPlaybackBuffer;
+        
+        // Start point for the next playback and length of the buffer
+        // These are used to index iPlaybackBuffer
+        TInt iStartPoint;
+        TInt iStopPoint;
+        
+#ifdef  DEVTTS_3DB_HACK
+		TBool iApplyGain;
+#endif
+
+#ifdef DEVTTS_AUDIOBUFFER_TO_FILE
+        RFs iSession;
+        RFile iFile;
+        TBool iFileOpen;
+        TInt iFileCounter;
+#endif
+
+        // NlpHwDevice pointer
+        CNlpHwDevice* iNlp;
+
+        // ETrue if NLP has been successfully initialized
+        TBool iNlpInitialized;
+
+        // Wait loop for audio initialization
+        CActiveSchedulerWait iAudioWait;
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+    };
+    
+#endif    // DEVTTSALGORITHMMANAGER_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/devttsaudio.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,523 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Audio playback wrapper for DevTTS.
+*
+*/
+
+
+// INCLUDE FILES
+#include "devttsaudio.h"
+#include "devttscenrep.h"
+#include <AudioPreference.h>
+#include <AudioOutput.h>
+#include <mmfbase.h>
+#include "rubydebug.h"
+
+// CONSTANTS
+// Sample rates
+const TUint KSampleRate8k = 8000;
+const TUint KSampleRate11k = 11025;
+const TUint KSampleRate16k = 16000;
+const TUint KSampleRate22k = 22050;
+const TUint KSampleRate32k = 32000;
+const TUint KSampleRate44k = 44100;
+const TUint KSampleRate48k = 48000;
+const TUint KSampleRate88k = 88200;
+const TUint KSampleRate96k = 96000;
+
+// Bits per sample
+const TUint KBitsPerSample8 = 8;
+const TUint KBitsPerSample16 = 16;
+
+// Volume min
+const TUint KMinVolume = 0;
+
+const TUint KBalanceMiddle = 100;
+
+// Default audio priority
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::CDevTTSAudio
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDevTTSAudio::CDevTTSAudio( MDevTTSAudioObserver& aObserver, TInt aPriority ) : 
+        iObserver( aObserver ), 
+        iDevsound( NULL ),
+        iBuffer( NULL ),
+        iPriority( aPriority ),
+        iBalance( KDevTTSBalanceMiddle ),
+        iVolume( KMinVolume )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CDevTTSAudio::ConstructL" );
+
+    // Construct DevSound object
+    iDevsound = CMMFDevSound::NewL();
+    
+#ifndef __WINS__// This is not supported in emulator
+    iAudioOutput = CAudioOutput::NewL( *iDevsound );
+#endif
+
+    // Handler for the CenRep settings
+    CDevTtsCenRep* cenrep = CDevTtsCenRep::NewL();
+    CleanupStack::PushL( cenrep ); 
+    
+    // Set volume to default
+    RUBY_DEBUG0( "CDevTTSAudio::ConstructL Set volume" );
+    SetVolume( cenrep->Volume( MaxVolume() ) );
+    
+    CleanupStack::PopAndDestroy( cenrep );
+
+    // Set default playback priority
+    SetAudioPriority( KAudioPriorityVoiceDial, 
+                      (TDevTTSAudioPreference) KAudioPrefVocosPlayback );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDevTTSAudio* CDevTTSAudio::NewL( MDevTTSAudioObserver& aObserver, 
+                                  TInt aPriority )
+    {
+    CDevTTSAudio* self = new( ELeave ) CDevTTSAudio( aObserver, aPriority );
+ 
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::~CDevTTSAudio
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDevTTSAudio::~CDevTTSAudio()
+    {
+    delete iAudioOutput; 
+    delete iDevsound; 
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::InitializeL
+// Initializes audio playback device.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::InitializeL() 
+    {
+    iDevsound->InitializeL(*(this), EMMFStatePlaying );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::ConfigL
+// Configures audio playback device.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::ConfigL( TUint aSamplingRate, TUint aBitsPerSample, 
+                            TBool aStereo, TUint aBufferSize )
+    {
+    // Resolve configuration
+    iDevCap = iDevsound->Config();
+    
+    // Set the preferred buffer size
+    iDevCap.iBufferSize = aBufferSize;
+   
+    // Resolve sampling rate
+    switch ( aSamplingRate )
+        {
+        case KSampleRate8k:
+            iDevCap.iRate = EMMFSampleRate8000Hz;
+            break;
+            
+        case KSampleRate11k:
+            iDevCap.iRate = EMMFSampleRate11025Hz;
+            break;
+            
+        case KSampleRate16k:
+            iDevCap.iRate = EMMFSampleRate16000Hz;
+            break;
+            
+        case KSampleRate22k:
+            iDevCap.iRate = EMMFSampleRate22050Hz;
+            break;
+            
+        case KSampleRate32k:
+            iDevCap.iRate = EMMFSampleRate32000Hz;
+            break;
+            
+        case KSampleRate44k:
+            iDevCap.iRate = EMMFSampleRate44100Hz;
+            break;
+            
+        case KSampleRate48k:
+            iDevCap.iRate = EMMFSampleRate48000Hz;
+            break;
+            
+        case KSampleRate88k:
+            iDevCap.iRate = EMMFSampleRate88200Hz;
+            break;
+            
+        case KSampleRate96k:
+            iDevCap.iRate = EMMFSampleRate96000Hz;
+            break;
+            
+        default:
+            User::Leave(KErrNotSupported);
+            break;
+        }
+    
+    // Resolve bits per sample
+    switch ( aBitsPerSample )
+        {
+        case KBitsPerSample8:
+            iDevCap.iEncoding = EMMFSoundEncoding8BitPCM;
+            break;
+            
+        case KBitsPerSample16:
+            iDevCap.iEncoding = EMMFSoundEncoding16BitPCM;
+            break;
+            
+        default:
+            User::Leave(KErrNotSupported);
+            break;
+        }
+    
+    // Resolve mono/stereo
+    if ( aStereo )
+        {
+        iDevCap.iChannels = EMMFStereo;
+        }
+    else
+        {
+        iDevCap.iChannels = EMMFMono;
+        }
+    
+    // Set DevSound configuration in place
+    iDevsound->SetConfigL( iDevCap );
+    
+    // Set the audio priority settings to default
+    iAudioPriority.iPriority = KAudioPriorityVoiceDial;
+    iAudioPriority.iPref = ( TMdaPriorityPreference ) KAudioPrefVocosPlayback;
+    iAudioPriority.iState = EMMFStatePlaying;
+    
+    iDevsound->SetPrioritySettings( iAudioPriority );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::Clear
+// No counter part for initialize in DevSound. Function is in this class just
+// for future convenience.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::Clear()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::PlayInitL
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::PlayInitL()
+    {
+    iDevsound->PlayInitL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::PlayData
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::PlayData( TBool aLastBuffer ) 
+    {
+    iBuffer->SetLastBuffer( aLastBuffer );
+    iDevsound->PlayData();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::SetAudioPriority
+// Resolves arguments and forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::SetAudioPriority( TInt aPriority, TDevTTSAudioPreference aPref )
+    {
+    // Set the priority settings
+    iPriority = aPriority;
+    iAudioPriority.iPriority = aPriority;
+    iAudioPriority.iState = EMMFStatePlaying;
+    iAudioPriority.iPref = ( TMdaPriorityPreference ) aPref;
+  
+    iDevsound->SetPrioritySettings( iAudioPriority );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::SetAudioOutputL
+// 
+// -----------------------------------------------------------------------------
+// 
+void CDevTTSAudio::SetAudioOutputL( TInt aAudioOutput )
+    {
+    RUBY_DEBUG1( "Setting output to %d", aAudioOutput );
+    
+    if ( iAudioOutput )
+        {
+        iAudioOutput->SetAudioOutputL( 
+            (CAudioOutput::TAudioOutputPreference)aAudioOutput );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::Balance
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+TInt CDevTTSAudio::Balance()
+    {
+    return iBalance;
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::SetBalance
+// Checks parameter validity and forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::SetBalance( TInt aBalance )
+    {
+    TInt right( 0 );
+    TInt left( 0 );
+
+    if ( ( aBalance > KDevTTSBalanceRight ) || ( aBalance < KDevTTSBalanceLeft ) )
+        {
+        return;
+        }
+    iBalance = aBalance;
+
+    if ( aBalance < 0 )
+        {
+        left = KBalanceMiddle;
+        right = KBalanceMiddle + aBalance;
+        }
+    else if ( aBalance > 0 )
+        {
+        left = KBalanceMiddle - aBalance;
+        right = KBalanceMiddle;
+        }
+    else
+        {
+        left = KBalanceMiddle;
+        right = KBalanceMiddle;
+        }
+
+    RUBY_DEBUG2( "CDevTTSAudio::SetBalance Balance setting left: %d, right: %d", left, right );
+
+    TRAPD( error, iDevsound->SetPlayBalanceL( left, right ) );
+    if ( error == KErrNone )
+        {
+        RUBY_DEBUG0( "CDevTTSAudio::SetBalance Balance set" );
+        }
+    else
+        {
+        RUBY_DEBUG1( "CDevTTSAudio::SetBalance Balance set error: %d", error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::SetVolume
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::SetVolume( TInt aVolume )
+    {
+    if ( ( aVolume > iDevsound->MaxVolume() ) || ( aVolume < KMinVolume ) )
+        {
+        return;
+        }
+    
+    iVolume = aVolume;
+    RUBY_DEBUG1( "CDevTTSAudio::SetVolume %i", aVolume ); 
+
+    iDevsound->SetVolume( aVolume );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::SetVolumeRamp
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration )
+    {
+    iDevsound->SetVolumeRamp( aRampDuration );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::MaxVolume
+// Returns DevSound maximum volume.
+// -----------------------------------------------------------------------------
+//
+TInt CDevTTSAudio::MaxVolume()
+    {
+    return iDevsound->MaxVolume();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::Volume
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+TInt CDevTTSAudio::Volume()
+    {
+    return iVolume;
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::Stop
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::Stop()
+    {
+    iDevsound->Stop();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::Pause
+// Forwards call to DevSound.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::Pause()
+    {
+    iDevsound->Pause();
+    }
+
+
+// ========================== MDevSoundObserver CALLBACKS ======================
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::InitializeComplete
+// Forwards callback
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::InitializeComplete( TInt aError ) 
+    {
+    iObserver.MdtaoInitializeComplete( aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::ToneFinished
+// Not needed when using only waveform playback
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::ToneFinished(TInt /*aError*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::BufferToBeFilled
+// Forwards callback
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::BufferToBeFilled( CMMFBuffer* aBuffer )
+    {
+    iBuffer = aBuffer;
+    CMMFDataBuffer* buffer = STATIC_CAST( CMMFDataBuffer*, aBuffer );
+    
+    iObserver.MdtaoBufferToBeFilled( buffer->Data(), aBuffer->RequestSize() );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::PlayError
+// Forwards callback.
+// Spec says that KErrNone is used when audio playback is ok. In practise it
+// seems that KErrUnderflow means the same thing.
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::PlayError( TInt aError )
+    {
+    if ( aError == KErrNone || aError == KErrUnderflow ) 
+        {
+        iObserver.MdtaoPlayFinished( KErrNone );
+        }
+    else
+        {
+        iObserver.MdtaoPlayFinished( aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::BufferToBeEmptied
+// Not needed when using only waveform playback
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::BufferToBeEmptied( CMMFBuffer* /*aBuffer*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::RecordError
+// Not needed when using only waveform playback
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::RecordError( TInt /*aError*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::ConvertError
+// Not needed when using only waveform playback
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::ConvertError( TInt /*aError*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::DeviceMessage
+// Not needed, no custom commands issued to audio hw device
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::DeviceMessage( TUid /*aMessageType*/, const TDesC8& /*aMsg*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTSAudio::SendEventToClient
+// Called when an attempt to acquire a sound device is rejected by audio policy 
+// server
+// -----------------------------------------------------------------------------
+//
+void CDevTTSAudio::SendEventToClient( const TMMFEvent& /*aEvent*/ )
+    {
+    // Inform our own observer
+    iObserver.MdtaoPlayFinished( KErrCancel );
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/devttsaudio.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,365 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Audio interface for DevTts
+*
+*/
+
+
+#ifndef DEVTTSAUDIO_H
+#define DEVTTSAUDIO_H
+
+//  INCLUDES
+
+#include <e32base.h>
+#include <sounddevice.h>    // DevSound
+#include <nssdevtts.h>      // DevTTS public header
+
+
+// FORWARD DECLARATION
+
+class CAudioOutput;
+
+
+// CLASS DECLARATIONS
+
+class MDevTTSAudioObserver
+    {
+    public:
+        
+        /**
+        * Notifies the observer that initialization has been completed.
+        *
+        * @param "TInt aError"
+        *        KErrNone if successful, otherwise one of the system level 
+        *        error codes.
+        */
+        virtual void MdtaoInitializeComplete( TInt aError ) = 0;
+        
+        /**
+        * Audio device wants the buffer to be filled. Client should provide
+        * data to the descriptor given as parameter and call PlayData when
+        * data is ready to be played.
+        *
+        * @param "TDes8& aBuffer"
+        *        Descriptor which should be filled
+        * @param "TInt aSizeRequested"
+        *        Number of bytes requested
+        */
+        virtual void MdtaoBufferToBeFilled( TDes8& aBuffer,
+                                            TInt aSizeRequested ) = 0;
+        
+        /**
+        * Called when playback process is finished, successfully or otherwise.
+        *
+        * @param "TInt aError"
+        *        KErrNone if everything succeeded, one of the system level error
+        *        codes otherwise.
+        */
+        virtual void MdtaoPlayFinished( TInt aError ) = 0;
+        
+    };
+
+/**
+* Audio playback functionality for DevTTS.
+*/
+class CDevTTSAudio : public CBase, 
+                     public MDevSoundObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDevTTSAudio* NewL( MDevTTSAudioObserver& aObserver, 
+                                   TInt aPriority );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDevTTSAudio();
+        
+    public: // New functions
+        
+        /**
+        * Initializes the audio device. Method is asynchronous.
+        * MDevTTSAudioObserver::InitializeComplete() called when initialization
+        * is ready.
+        */
+        void InitializeL();
+        
+         /**
+        * Configures the audio device. Method is synchronous.
+        */
+        void ConfigL( TUint aSamplingRate, TUint aBitsPerSample, 
+                      TBool aStereo, TUint aBufferSize );
+        
+        /**
+        * Clears the audio device resources. Counter part of InitializeL.
+        */
+        void Clear();
+        
+        /**
+        * Returns the current balance setting.
+        *
+        * @return Balance.
+        */
+        TInt Balance();
+
+        /**
+        * Returns maximum volume.
+        *
+        * @return Max volume.
+        */
+        TInt MaxVolume();
+
+        /**
+        * Initialises the audio playback process.
+        */
+        void PlayInitL();
+        
+        /**
+        * Plays the filled buffer, Should be called when BufferToBeFilled 
+        * callback has filled the requested buffer.
+        *
+        * @param "TBool aLastBuffer"
+        *        Flag to tell if this is the last buffer
+        */
+        void PlayData( TBool aLastBuffer );
+        
+        /**
+        * Sets the priority for audio playback.
+        * 
+        * @param "TInt aPriority"
+        *        Priority value.
+        * @param "TDevTTSAudioPreference aPref"'
+        *        Preference setting. Quality, time or both.
+        */
+        void SetAudioPriority( TInt aPriority, TDevTTSAudioPreference aPref );
+
+        /**
+        * Sets the audio output routing
+        * 
+        * @param TInt aAudioOutput
+        *        New output.
+        */
+        void SetAudioOutputL( TInt aAudioOutput );
+
+        /**
+        * Sets the playback balance.
+        *
+        * @param "TInt aBalance"
+        *        Balance value to be set.
+        */
+        void SetBalance( TInt aVolume );
+        
+        /**
+        * Sets the playback volume. Range is from 0 (minumum) to MaxVolume().
+        * Out of range values will be discarded.
+        *
+        * @param "TInt aVolume"
+        *        Volume value to be set, from 0 to MaxVolume.
+        */
+        void SetVolume( TInt aVolume );
+
+        /**
+        * Sets the volume ramp duration
+        *
+        * @param "TTimeIntervalMicroSeconds& aRampDuration"
+        *        Ramp duration.
+        */
+        void SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration );
+        
+        /**
+        * Stops the ongoing playback operation.
+        */
+        void Stop();
+        
+        /**
+        * Pauses the ongoing playback operation
+        */
+        void Pause();
+        
+        /**
+        * Returns the current volume setting.
+        *
+        * @return Volume
+        */
+        TInt Volume();
+
+    public: // Functions from base classes
+        
+        /**
+        * From MDevSoundObserver::InitializeComplete
+        * Handles initialization completion event from DevSound.
+        * Called InitializeL() function completes.
+        *
+        * @param "TInt aError"
+        *        Error code. KErrNone if successful. Other values are possible
+        *        indicating a problem initializing CMMFDevSound object.
+        */
+        void InitializeComplete( TInt aError );
+        
+        /**
+        * From MDevSoundObserver::ToneFinished
+        * Handles tone play completion event.
+        * Called when an attempt to play tone has
+        * completed, successfully or otherwise.
+        *
+        * @param "TInt aError"
+        *        Error code. The status of tone playback. KErrUnderflow playing of
+        *        the tone is complete. KErrAccessDenied the sound device is in use by
+        *        another higher priority client. KErrCancel playing of the audio
+        *        sample is stopped by DevSound client another higher priority client.
+        */
+        void ToneFinished( TInt aError ); 
+        
+        /**
+        * From MDevSoundObserver::BufferToBeFilled
+        * Handles CMMFDevSound object's data request event.
+        * CMMFDevSound object calls this method when and where it needs data for
+        * playing or converting. The observer should notify CMMFDevSound object as
+        * quickly as possible after the data is read into buffer, aBuffer by calling
+        * PlayData(), otherwise the implementation might callback method PlayError()
+        * on derived class object with error code KErrUnderflow.
+        *
+        * @param "CMMFBuffer* aBuffer"
+        *         Buffer into which data should be read. The amount of data that is
+        *         needed is specified in CMMFBuffer::RequestSize().
+        */
+        void BufferToBeFilled( CMMFBuffer* aBuffer );
+        
+        /**
+        * From MDevSoundObserver::PlayError
+        * Handles play completion or cancel event.
+        * Called when an attempt to play audio sample
+        * has completed, successfully or otherwise.
+        *
+        * @param "TInt aError"
+        *        Error code. The status of playback. KErrUnderflow playing of the
+        *        audio sample is complete. KErrAccessDenied the sound device is in
+        *        use by another higher priority client.
+        */
+        void PlayError( TInt aError ); 
+        
+        /**
+        * From MDevSoundObserver::BufferToBeEmptied
+        * Handles CMMFDevSound object's data request event.
+        * Called when the buffer, aBuffer gets filled
+        * while recording or converting. The observer should notify CMMFDevSound
+        * object as quickly as possible after data in the buffer is processed by
+        * calling RecordData(), otherwise the implementation might callback
+        * method RecordError() on derived class object with error code KErrOverflow.
+        *
+        * @param "CMMFBuffer* aBuffer"
+        *        Buffer containing processed (recorded or converted) data. The amount
+        *        of data that is available is specified in CMMFBuffer::RequestSize().
+        */
+        void BufferToBeEmptied( CMMFBuffer* aBuffer ); 
+        
+        /**
+        * From MDevSoundObserver::RecordError
+        * Handles record completion or cancel event.
+        * Called when an attempt to record audio sample
+        * has completed, successfully or otherwise.
+        *
+        * @param "TInt aError"
+        *        Error code. The status of recording. KErrOverflow audio devices
+        *        runs out of internal buffer. KErrAccessDenied the sound device is
+        *        in use by another higher priority client.
+        */
+        void RecordError( TInt aError ); 
+        
+        /**
+        * From MDevSoundObserver::ConvertError
+        * Handles conversion completion or cancel event.
+        * Called when an attempt to convert data from
+        * source format to destination format has completed, 
+        * successfully or otherwise.
+        *
+        * @param	"TInt aError"
+        *           Error code. KErrCancel conversion operation is cancelled. KErrNone
+        *           conversion is complete. Other values are possible indicating a
+        *           problem converting data.
+        */
+        void ConvertError( TInt aError );
+        
+        /**
+        * From MDevSoundObserver::DeviceMessage
+        * Handles device event.
+        * Called when a message is received from the
+        * audio hardware device.
+        *
+        * @param "aMessageType" 
+        *         Defines the type of message. Used to determine how to 
+        *         interpret the contents of aMsg.
+        * @param "aMsg"
+        *         Message that is packed in the Descriptor format.
+        */
+        void DeviceMessage( TUid aMessageType, const TDesC8& aMsg );
+        
+        /**
+        * From MDevSoundObserver::SendEventToClient
+        * Handles policy request completion event.
+        * Called when an attempt to acquire sound
+        * device is rejected by audio policy server.
+        *
+        * @param "const TMMFEvent& aEvent"
+        */
+        void SendEventToClient( const TMMFEvent& aEvent );  
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CDevTTSAudio( MDevTTSAudioObserver& aObserver, TInt aPriority );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+    private:    // Data
+    
+        // Observer
+        MDevTTSAudioObserver& iObserver;
+        
+        // DevSound
+        CMMFDevSound* iDevsound;
+        
+        // Used for setting audio routing
+        CAudioOutput* iAudioOutput;
+        
+        // DevSound capabilities
+        TMMFCapabilities iDevCap;
+        
+        // Buffer which is being filled
+        CMMFBuffer* iBuffer;
+
+        // Numerical value of the priority setting
+        TInt iPriority;
+        
+        // DevSound priority settings
+        TMMFPrioritySettings iAudioPriority;
+
+        // Current balance
+        TInt iBalance;
+
+        // Current volume
+        TInt iVolume;
+    };
+    
+#endif // DEVTTSAUDIO_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/devttscenrep.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CenRep handling for DevTTS.
+*
+*/
+
+
+// INCLUDE FILES
+#include "devttscenrep.h"
+#include "rubydebug.h"
+#include "srsfinternalcrkeys.h"
+
+// CONSTANTS
+
+// Maximum value of the volume setting in Central Repository
+const TInt KMaxRepositoryVolume = 10;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDevTtsCenRep::CDevTtsCenRep
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDevTtsCenRep::CDevTtsCenRep() 
+    {
+    // Nothing
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevTtsCenRep::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDevTtsCenRep::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+	iRepository = CRepository::NewL( KCRUidSRSFSettings );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevTtsCenRep::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDevTtsCenRep* CDevTtsCenRep::NewL()
+    {
+    CDevTtsCenRep* self = new( ELeave ) CDevTtsCenRep();
+ 
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevTtsCenRep::~CDevTtsCenRep
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDevTtsCenRep::~CDevTtsCenRep()
+    {
+    delete iRepository;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevTtsCenRep::Volume
+// Returns the volume setting from CenRep
+// -----------------------------------------------------------------------------
+//
+TInt CDevTtsCenRep::Volume( TInt aMaxVolume ) 
+    {
+    RUBY_DEBUG0( "" );
+    TInt volume( aMaxVolume );
+    // Get from CenRep
+    TInt error = iRepository->Get( KSRSFPlaybackVolume, volume );
+    if ( error == KErrNone )
+        {
+        RUBY_DEBUG2( "Volume repository value:[%d], maxvolume:[%d]", volume, aMaxVolume );
+        // Scale value
+        volume = ( volume * aMaxVolume ) / KMaxRepositoryVolume;
+        RUBY_DEBUG1( "Scaled volume value:[%d]", volume );
+        
+        return volume;
+        }
+    // Return max volume by default
+    return aMaxVolume;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/devttscenrep.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CenRep handling for DevTts
+*
+*/
+
+
+#ifndef DEVTTSCENREP_H
+#define DEVTTSCENREP_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <nssdevtts.h>
+#include <centralrepository.h>
+
+// CLASS DECLARATION
+
+/**
+* Playback volume CenRep handler for DevTTS
+*/
+NONSHARABLE_CLASS( CDevTtsCenRep ) : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDevTtsCenRep* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDevTtsCenRep();
+        
+    public: // New functions
+
+        /**
+        * Returns the current volume setting from CenRep.
+        * If nothing is found (or error occurs), maximum volume will be returned.
+        * Volume setting is scaled to 0..aMaxVolume
+        *
+        * @param "TInt aMaxVolume" Maximum volume
+        * @return Volume setting read from CenRep
+        */    
+        TInt Volume( TInt aMaxVolume );
+
+    public: // Functions from base classes
+       
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CDevTtsCenRep();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor
+        CDevTtsCenRep( const CDevTtsCenRep& );
+        // Prohibit assigment operator
+        CDevTtsCenRep& operator=( const CDevTtsCenRep& );
+        
+    private: // Data
+
+        // Central Repository
+        CRepository* iRepository;
+
+    };
+    
+#endif // DEVTTSCENREP_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/nssdevtts.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,363 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CDevTTS method implementations.
+*
+*/
+
+
+// INCLUDE FILES
+#include "srsfbldvariant.hrh"
+#include "nssdevtts.h"
+#include "devttsalgorithmmanager.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDevTTS::CDevTTS
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDevTTS::CDevTTS() : iImpl(NULL)
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDevTTS::ConstructL( MDevTTSObserver& aObserver/*, CConsoleBase* console*/ )
+    {
+    iImpl = CTTSAlgorithmManager::NewL( aObserver/*, console*/ );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDevTTS* CDevTTS::NewL( MDevTTSObserver& aObserver/*, CConsoleBase* console*/ )
+    {
+    CDevTTS* self = new( ELeave ) CDevTTS;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aObserver/*, console*/ );
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::~CDevTTS
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDevTTS::~CDevTTS()
+    {
+    if (iImpl != NULL) 
+        {
+        delete iImpl;
+        iImpl = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::AddStyleL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyleID CDevTTS::AddStyleL( const TTtsStyle& aStyle )
+    {
+    return iImpl->AddStyleL( aStyle );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::Balance
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDevTTS::Balance()
+    {
+    return iImpl->Balance();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::BufferProcessed
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::BufferProcessed( const TDesC8& aBuffer )
+    {
+    iImpl->BufferProcessed( aBuffer );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::CustomInterface
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TAny* CDevTTS::CustomInterface( TUid aInterfaceID )
+    {
+    return iImpl->CustomInterface( aInterfaceID );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::DeleteStyleL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::DeleteStyleL( TTtsStyleID aStyleID )
+    {
+    iImpl->DeleteStyleL( aStyleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::GetPositionL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::GetPositionL( TTimeIntervalMicroSeconds& aTime ) const
+    {
+    iImpl->GetPositionL( aTime );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::GetPositionL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::GetPositionL( TTtsSegment& aSegment, TInt& aWordIndex ) const
+    {
+    iImpl->GetPositionL( aSegment, aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::IsLanguageSupported
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDevTTS::IsLanguageSupported( TLanguage aLanguage ) const
+    {
+    return iImpl->IsLanguageSupported( aLanguage );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::MaxVolume
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDevTTS::MaxVolume()
+    {
+    return iImpl->MaxVolume();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::StyleL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle& CDevTTS::StyleL( TTtsStyleID aStyleID ) const
+    {
+    return iImpl->StyleL( aStyleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::StyleL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle& CDevTTS::StyleL( TUint16 aIndex ) const
+    {
+    return iImpl->StyleL( aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::NumberOfStyles
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint16 CDevTTS::NumberOfStyles() const
+    {
+    return iImpl->NumberOfStyles();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::Pause
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::Pause()
+    {
+    iImpl->Pause();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::PrimeSynthesisL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::PrimeSynthesisL( MTtsSegmentStream& aStream ) 
+    {
+    iImpl->PrimeSynthesisL( aStream );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::PrimeSynthesisL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::PrimeSynthesisL( CTtsParsedText& aText )
+    {
+    iImpl->PrimeSynthesisL( aText );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SetAudioPriority
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetAudioPriority( TInt aPriority, TDevTTSAudioPreference aPref )
+    {
+    iImpl->SetAudioPriority( aPriority, aPref );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SetAudioOutputL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetAudioOutputL( TInt aAudioOutput )
+    {
+    iImpl->SetAudioOutputL( aAudioOutput );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDevTTS::SetBalance
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetBalance( TInt aBalance )
+    {
+    iImpl->SetBalance( aBalance );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SetPositionL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetPositionL( const TTimeIntervalMicroSeconds& aTime )
+    {
+    iImpl->SetPositionL( aTime );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SetPositionL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetPositionL( const TTtsSegment& aSegment, TInt aWordIndex )
+    {
+    iImpl->SetPositionL( aSegment, aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SetVolume
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetVolume( TInt aVolume )
+    {
+    iImpl->SetVolume( aVolume );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SetVolumeRamp
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration )
+    {
+    iImpl->SetVolumeRamp( aRampDuration );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::Stop
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::Stop()
+    {
+    iImpl->Stop();
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::SynthesizeL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::SynthesizeL( TDevTTSOutputMode aOutputMode ) 
+    {
+    iImpl->SynthesizeL( aOutputMode );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::Volume
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDevTTS::Volume()
+    {
+    return iImpl->Volume();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDevTTS::LanguageIdentificationL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::LanguageIdentificationL( CTtsParsedText& aText, 
+                                                TInt aNumberOfGuesses, 
+                                                RArray<TLanguage>& aLanguages,
+                                                RArray<TInt>& aScores )
+    {
+    iImpl->LanguageIdentificationL( aText, aNumberOfGuesses, aLanguages, aScores );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::NormalizeTextL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::NormalizeTextL( CTtsParsedText& aText )
+    {
+    iImpl->NormalizeTextL( aText );
+    }
+
+// -----------------------------------------------------------------------------
+// CDevTTS::NormalizeAndSegmentTextL
+// Forwards call to the actual implementation object.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDevTTS::NormalizeAndSegmentTextL( CTtsParsedText& aText )
+    {
+    iImpl->NormalizeAndSegmentTextL( aText );
+    }
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/nssdevtts.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configruration data for DevTTS algorithm manager
+*
+*/
+
+
+//  INCLUDES
+#include <badef.rh>
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// DEVTTSCONFIGURATIONS
+// Configurations for DevTTS algorithm manager
+// -----------------------------------------------------------------------------
+//
+STRUCT DEVTTSCONFIGURATIONS
+    {
+    // Sampling rate
+    LONG samplingRate;
+    
+    // Bits per sample
+    LONG bitsPerSample;
+    
+    // Non zero if stereo, mono equals to 0
+    LONG isStereo;
+    
+    // Playback buffer size
+    LONG bufferSize;
+    
+    // Reserves
+    LONG reserve1;
+    LONG reserve2;
+    LONG reserve3;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/devtts/src/nssdevtts.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configruration data for DevTTS algorithm manager
+*
+*/
+
+
+//  INCLUDES
+#include "nssdevtts.rh"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// DEVTTSCONFIGURATIONS
+// Configurations for DevTTS algorithm manager
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DEVTTSCONFIGURATIONS r_devtts_configurations
+    {
+    // Sampling rate
+    samplingRate = 16000;
+    
+    // Bits per sample
+    bitsPerSample = 16;
+    
+    // Non zero if stereo, mono equals to 0
+    isStereo = 0;
+    
+    // Playback buffer size
+    bufferSize = 4096;
+
+    // Reserves
+    reserve1 = 0;
+    reserve2 = 0;
+    reserve3 = 0;
+    }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/group/10201aee.txt	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+SRSF
+%full_filespec: 10201aee.txt-18:ascii:tr1nss#1 %
+%date_modified: Mon Apr 10 11:57:24 2006 %
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/group/backup_registration.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,6 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+   <dbms_backup policy="10201AFE"/>
+
+   <proxy_data_manager sid="0x10202BE9" /> 
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/group/backup_registration_plugin.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,4 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+   <dbms_backup policy="10201AFF"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for all SRSF modules.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "srsfbldvariant.hrh"
+
+PRJ_PLATFORMS
+DEFAULT
+
+#include "../sispeechrecognitiondata/group/bld.inf"
+#include "../ttscommon/group/bld.inf"
+#include "../devtts/group/bld.inf"
+#include "../ttscustomcommands/group/bld.inf"
+#include "../ttscontrollerplugin/group/bld.inf"
+#include "../ttsutility/group/bld.inf"
+#include "../speechsynthesis/client/group/bld.inf"
+#include "../speechsynthesis/server/group/bld.inf"
+#include "../devasr/group/bld.inf"
+#include "../sicc/group/bld.inf"
+#include "../sisrscontrollerplugin/group/bld.inf"
+#include "../siutility/group/bld.inf"
+#include "../nssvasapi/group/bld.inf"
+#include "../nssvascontacthdlr/group/bld.inf"
+#include "../vcommandhandler/group/bld.inf"
+#include "../vuiphandler/group/bld.inf"
+#include "../vcommandexecutor/group/bld.inf"
+#include "../vcommandexecutorbearer/group/bld.inf"
+#include "../vcommandmanager/group/bld.inf"
+#include "../vcexecutorapp/group/bld.inf"
+#include "../profileobserverplugin/group/bld.inf"
+
+PRJ_EXPORTS
+
+#include "../rom/exports.inc"
+#include "exports.inc"
+
+// VAS database backup
+backup_registration.xml  /epoc32/data/z/private/10201afe/backup_registration.xml
+backup_registration.xml  /epoc32/release/winscw/udeb/z/private/10201afe/backup_registration.xml
+backup_registration.xml  /epoc32/release/winscw/urel/z/private/10201afe/backup_registration.xml
+
+// Plugin database backup
+backup_registration_plugin.xml  /epoc32/data/z/private/10201aff/backup_registration.xml
+backup_registration_plugin.xml  /epoc32/release/winscw/udeb/z/private/10201aff/backup_registration.xml
+backup_registration_plugin.xml  /epoc32/release/winscw/urel/z/private/10201aff/backup_registration.xml
+
+
+// Generic configuration interface for component cenrep settings  
+../conf/srsf.confml                  APP_LAYER_CONFML(srsf.confml)
+../conf/srsf_10281c7d.crml           APP_LAYER_CRML(srsf_10281c7d.crml)
+// SI custom commands
+
+// version information
+./10201aee.txt                        /epoc32/data/z/private/10208acc/10201aee.txt
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,22 @@
+/*
+* ==============================================================================
+*        %name: exports.inc %
+*     %version: 2 %
+*      Part of: srsf
+*  Description: voice commands exports
+*
+*  Copyright © 2006-2007 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+* ==============================================================================
+*/
+
+#include <platform_paths.hrh>
+../loc/defaultvoicecommands.loc APP_LAYER_LOC_EXPORT_PATH(defaultvoicecommands.loc)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/group/srsfbldvariant.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Flags for SRSF build
+*
+*/
+
+
+#ifndef SRSFBLDVARIANT_HRH
+#define SRSFBLDVARIANT_HRH
+
+// Define these flags in ProductVariant.hrh if non-default configuration is needed
+
+// Define this if SIND supports more than one segment in CTtsParsedText
+#define __SIND_MULTIPLE_SEGMENTS
+
+// Define this if SINDE feature is supported
+#define __SIND_EXTENSIONS
+
+// Define this if enhanced SINDE training is supported
+#define __SINDE_TRAINING
+
+// Define this for auto-configurable LID
+#define __SIND_AUTOCONF_LID
+
+// Define this for PreStartSampling() implementation
+#define __FULLDUPLEX_CHANGE
+
+#endif // SRSFBLDVARIANT
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/inc/srsfinternalcrkeys.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Internal CR keys for SRSF
+*
+*/
+
+
+#ifndef SRSFINTERNALCRKEYS_H
+#define SRSFINTERNALCRKEYS_H
+
+// Domain CR keys
+#include <srsfdomaincrkeys.h>
+
+#endif // SRSFINTERNALCRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/inc/srsfprivatecrkeys.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Internal CR keys for SRSF
+*
+*/
+
+
+#ifndef SRSFPRIVATECRKEYS_H
+#define SRSFPRIVATECRKEYS_H
+
+// Internal CR keys
+#include "srsfinternalcrkeys.h"
+
+// If value equals to one, indicates a full resync is needed on the next boot.
+// If value equals to KImmediateResync, indicates an immediate full resync
+const TUint32 KSRSFFullResyncNeeded = 0x00000000;
+
+const TInt KImmediateResync = 2;
+
+// Language which was used in VCommandManager training
+const TUint32 KSRSFUiLanguage = 0x00000001;
+
+#endif // SRSFPRIVATECRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/loc/defaultvoicecommands.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1011 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Default (implementation English) resource localisation file for 
+*               voice commands.
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+
+// Popup texts START
+// ============================================================================
+
+// d:Tooltip text shown when a profile changing command is highlighted.
+// d:%U is the profile name (either default or user edited)
+// l:popup_preview_text_window/opt5
+// r:3.2
+//
+#define qtn_vc_info_popup_text_prof                 "Say %U to activate the profile"
+
+// d:Tooltip text shown when an application launch voice command is highlighted.
+// d:%U is the application name (either default or user edited)
+// l:popup_preview_text_window/opt5
+// r:3.2
+//
+#define qtn_vc_info_popup_text_gen                  "Say %U to open application"
+
+// d:Tooltip text shown when a toggling voice command is highlighted
+// d:%U is the application name (either default or user edited)
+// l:popup_preview_text_window/opt5
+// r:3.2
+// 
+#define qtn_vc_info_popup_text_binary               "Say %U to switch feature on or off"
+
+// d:Tooltip text shown when a messaging related voice command is highlighted
+// d:%U is the application name (either default or user edited)
+// l:popup_preview_text_window/opt5
+// r:3.2
+// 
+#define qtn_vc_info_popup_text_msg                  "Say %U to create a new message"
+
+// d:Tooltip text shown when a mail related voice command is highlighted
+// d:%U is the application name (either default or user edited)
+// l:popup_preview_text_window/opt5
+// r:3.2
+// 
+#define qtn_vc_info_popup_text_mail                  "Say %U to create a new mail" 
+
+// d:Tooltip text shown when qtn_vc_main_time is highlighted.
+// d:%U is qan_vc_main_time or user edited voice command
+// l:popup_preview_text_window/opt5
+// r:3.2
+//
+#define qtn_vc_info_popup_text_time       "Say %U to hear the current time"
+
+// ============================================================================
+// Popup texts END
+
+// Profiles command START
+// ============================================================================
+
+// d:Command said by user, opens the profiles application
+// d:This is a default command
+// d:Related UI string: qtn_vc_command_profiles
+// l:None
+// r:3.2
+//
+#define qan_vc_command_profiles                     "Profiles"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_command_profiles
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_command_profiles                     "Profiles"
+
+// ============================================================================
+// Profiles command END
+
+// Voice mailbox command START
+// ============================================================================
+
+// d:Command said by user, opens the voice mailbox application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_mail
+// l:None
+// r:3.2
+//
+#define qan_vc_main_mail                   "Voice mail"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_mail
+// d:In 3.1 logical string qtn_vc_main_mail was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_mail                   "Voice mail"
+
+// ============================================================================
+// Voice mailbox command END
+
+// Bluetooth command START
+// ============================================================================
+
+// d:Command said by user, opens the bluetooth application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_bt
+// l:None
+// r:3.2
+//
+#define qan_vc_main_bt                       "Bluetooth"
+
+// d:Displayed within the list of voice commands.
+// d:In 3.1 logical string qtn_vc_main_bt was in vcommand.loc
+// d:Related spoken prompt: qan_vc_main_bt 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_bt                       "Bluetooth"
+
+// ============================================================================
+// Bluetooth command END
+
+// Voice recorder command START
+// ============================================================================
+
+// d:Command said by user, opens the voice recorder application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_recorder
+// l:None
+// r:3.2
+//
+#define qan_vc_main_recorder                  "Voice recorder"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_recorder 
+// d:In 3.1 logical string qtn_vc_main_recorder was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_recorder                  "Voice recorder"
+
+// ============================================================================
+// Voice recorder command END
+
+// Phonebook command START
+// ============================================================================
+
+// d:Command said by user, opens the Phonebook application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_phonebook
+// l:None
+// r:3.2
+//
+#define qan_vc_main_phonebook                        "Phonebook"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_phonebook 
+// d:In 3.1 logical string qtn_vc_main_phonebook was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_phonebook                        "Phonebook"
+
+// ============================================================================
+// Phonebook command END
+
+// Calendar command START
+// ============================================================================
+
+// d:Command said by user, opens the calendar application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_calendar
+// l:None
+// r:3.2
+//
+#define qan_vc_main_calendar                        "Calendar"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_calendar
+// d:In 3.1 logical string qtn_vc_main_calendar was in vcommand.loc 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_calendar                        "Calendar"
+
+// ============================================================================
+// Calendar command END
+
+// Messaging command START
+// ============================================================================
+
+// d:Command said by user, opens the messaging application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_messaging
+// l:None
+// r:3.2
+//
+#define qan_vc_main_messaging                       "Messaging"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_messaging 
+// d:In 3.1 logical string qtn_vc_main_messaging was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_messaging                       "Messaging"
+
+// ============================================================================
+// Messaging command END
+
+// New message command START
+// ============================================================================
+
+// d:Command said by user, opens the new message application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_message_editor
+// l:None
+// r:3.2
+//
+#define qan_vc_main_message_editor                  "New message"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_message_editor 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_message_editor                     "New message"
+
+// ============================================================================
+// New message command END
+
+// New e-mail command START
+// ============================================================================
+
+// d:Command said by user, opens the new e-mail application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_email_editor
+// l:None
+// r:3.2
+//
+#define qan_vc_main_email_editor                       "New e-mail"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_email_editor
+// d:In 3.1 logical string qtn_vc_main_email_editor was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_email_editor                       "New e-mail"
+
+// ============================================================================
+// New e-mail command END
+
+// New MMS postcard command START
+// ============================================================================
+
+// d:Command said by user, opens the MMS postcard editor.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_postcard 
+// l:None
+// r:3.2
+//
+#define qan_vc_main_postcard                       "New MMS postcard"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_postcard
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_postcard                       "New MMS postcard"
+
+// ============================================================================
+// New MMS postcard command END
+
+// Gallery command START
+// ============================================================================
+
+// d:Command said by user, opens the gallery application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_mg
+// l:None
+// r:3.2
+//
+#define qan_vc_main_mg                         "Gallery"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_mg 
+// d:In 3.1 logical string qtn_vc_main_mg was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_mg                         "Gallery"
+
+// ============================================================================
+// Gallery command END
+
+// Photos command START
+// ============================================================================
+
+// d:Command said by user, opens the Photos application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_photos
+// l:None
+// r:5.0
+//
+#define qan_vc_main_photos                         "Photos"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_photos
+// l:list_double_large_graphic_pane_t1_cp2
+// r:5.0
+//
+#define qtn_vc_main_photos                         "Photos"
+
+// ============================================================================
+// Photos command END
+
+// Browser command START
+// ============================================================================
+
+// d:Command said by user, opens the services application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_services
+// l:None
+// r:3.2
+//
+#define qan_vc_main_services                        "Browser"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_services 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_services                        "Browser"
+
+// ============================================================================
+// Browser command END
+
+// Personalization command START
+// ============================================================================
+
+// d:Command said by user, opens the personalization application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_skins
+// l:None
+// r:3.2
+//
+#define qan_vc_main_skins                 "Personalisation"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_skins 
+// d:In 3.1 logical string qtn_vc_main_skins was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_skins                 "Personalisation"
+
+// ============================================================================
+// Personalization command END
+
+// Help command START
+// ============================================================================
+
+// d:Command said by user, opens the help application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_help
+// l:None
+// r:3.2
+//
+#define qan_vc_main_help                            "Help"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_help 
+// d:In 3.1 logical string qtn_vc_main_help was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_help                            "Help"
+
+// ============================================================================
+// Help command END
+
+// Connection manager command START
+// ============================================================================
+
+// d:Command said by user, opens the connection manager application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_cmon
+// l:None
+// r:3.2
+//
+#define qan_vc_main_cmon                    "Connection manager"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_cmon 
+// d:In 3.1 logical string qtn_vc_main_cmon was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_cmon                    "Conn. manager"
+
+// ============================================================================
+// Connection manager command END
+
+// Notepad command START
+// ============================================================================
+
+// d:Command said by user, opens the Notepad application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_notepad
+// l:None
+// r:3.2
+//
+#define qan_vc_main_notepad                           "Notepad"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_notepad 
+// d:In 3.1 logical string qtn_vc_main_notepad was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_notepad                           "Notepad"
+
+// ============================================================================
+// Notepad command END
+
+// Calculator command START
+// ============================================================================
+
+// d:Command said by user, opens the calculator application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_calculator
+// l:None
+// r:3.2
+//
+#define qan_vc_main_calculator                      "Calculator"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_calculator 
+// d:In 3.1 logical string qtn_vc_main_calculator was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_calculator                      "Calculator"
+
+// ============================================================================
+// Calculator command END
+
+// Converter command START
+// ============================================================================
+
+// d:Command said by user, opens the converter application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_converter
+// l:None
+// r:3.2
+//
+#define qan_vc_main_converter                       "Converter"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qtn_vc_main_converter 
+// d:In 3.1 logical string qtn_vc_main_converter was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_converter                       "Converter"
+
+// ============================================================================
+// Converter command END
+
+// Voice commands command START
+// ============================================================================
+
+// d:Command said by user, opens the voice commands application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_vc 
+// l:None
+// r:3.2
+//
+#define qan_vc_main_vc                  "Voice commands"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_vc
+// d:In 3.1 logical string qtn_vc_main_vc was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_vc                  "Voice commands"
+
+// ============================================================================
+// Voice commands command END
+
+// Clock command START
+// ============================================================================
+
+// d:Command said by user, opens the clock application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_clock
+// l:None
+// r:3.2
+//
+#define qan_vc_main_clock                           "Clock"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_clock  
+// d:In 3.1 logical string qtn_vc_main_clock was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_clock                           "Clock"
+
+// ============================================================================
+// Clock command END
+
+// Logs command START
+// ============================================================================
+
+// d:Command said by user, opens the logs application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_logs
+// l:None
+// r:3.2
+//
+#define qan_vc_main_logs                             "Logs"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_logs 
+// d:In 3.1 logical string qtn_vc_main_logs was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_logs                             "Logs"
+
+// ============================================================================
+// Logs command END
+
+// Settings command START
+// ============================================================================
+
+// d:Command said by user, opens the settings application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_settings
+// l:None
+// r:3.2
+//
+#define qan_vc_main_settings                        "Settings"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_settings
+// d:In 3.1 logical string qtn_vc_main_settings was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_settings                       "Settings"
+
+// ============================================================================
+// Settings command END
+
+// Application manager command START
+// ============================================================================
+
+// d:Command said by user, opens the application manager application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_am
+// l:None
+// r:3.2
+//
+#define qan_vc_main_am                     "Application manager"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_am 
+// d:In 3.1 logical string qtn_vc_main_am was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_am                     "App. manager"
+
+// ============================================================================
+// Application manager command END
+
+// Speed dialing command START
+// ============================================================================
+
+// d:Command said by user, opens the speed dial application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_sd
+// l:None
+// r:3.2
+//
+#define qan_vc_main_sd                      "Speed dialing"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_sd
+// d:In 3.1 logical string qtn_vc_main_sd was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_sd                      "Speed dialing"
+
+// ============================================================================
+// Speed dialing command END
+
+// File manager command START
+// ============================================================================
+
+// d:Command said by user, opens the file manager application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_fmgr
+// l:None
+// r:3.2
+//
+#define qan_vc_main_fmgr                    "File manager"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_fmgr 
+// d:In 3.1 logical string qtn_vc_main_fmgr  was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_fmgr                    "File manager"
+
+// ============================================================================
+// File manager command END
+
+// Instant messaging command START
+// ============================================================================
+
+// d:Command said by user, opens the Instant messaging application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_instant
+// l:None
+// r:3.2
+//
+#define qan_vc_main_instant                              "Instant messaging"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_instant 
+// d:In 3.1 logical string qtn_vc_main_instant was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_instant                             "Instant messaging"
+
+// ============================================================================
+// Instant messaging command END
+
+// Device manager command START
+// ============================================================================
+
+// d:Command said by user, opens the device manager application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_dm
+// l:None
+// r:3.2
+//
+#define qan_vc_main_dm                  "Device manager"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_dm 
+// d:In 3.1 logical string qtn_vc_main_dm was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_dm                  "Device manager"
+
+// ============================================================================
+// Device manager command END
+
+// Radio command START
+// ============================================================================
+
+// d:Command said by user, opens the radio application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_radio
+// l:None
+// r:3.2
+//
+#define qan_vc_main_radio                           "Radio"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_radio 
+// d:In 3.1 logical string qtn_vc_main_radio was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_radio                           "Radio"
+
+// ============================================================================
+// Radio command END
+
+// Camcorder command START
+// ============================================================================
+
+// d:Command said by user, opens the camcorder application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_camcorder
+// l:None
+// r:3.2
+//
+#define qan_vc_main_camcorder                       "Cameras"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_camcorder 
+// d:In 3.1 logical string qtn_vc_main_camcorder was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_camcorder                       "Cameras"
+
+// ============================================================================
+// Camcorder command END
+
+// Chinese dictionary command START
+// ============================================================================
+
+// d:Command said by user, opens the chinese dictionary application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_dict
+// l:None
+// r:3.2
+//
+#define qan_vc_main_dict              "Chinese dictionary"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_dict 
+// d:In 3.1 logical string qtn_vc_main_dict was in vcommand.loc
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_dict              "Chinese dictionary"
+
+// ============================================================================
+// Chinese dictionary command END
+
+// MediaPlayer commands START
+// ============================================================================
+
+// d:Command said by user, opens the Media Player application.
+// d:This is alternative to qan_vc_main_mp_nonbranded
+// d:Related UI string: qtn_vc_main_mp
+// l:None
+// r:3.2
+//
+#define qan_vc_main_mp                      "Real Player"
+
+// d:Displayed within the list of voice commands.
+// d:This is alternative to qtn_vc_main_mp_nonbranded
+// d:Related spoken prompt: qan_vc_main_mp 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_mp                     "Real Player"
+
+// d:Command said by user, opens the Media Player application.
+// d:This is alternative to qan_vc_main_mp
+// d:Related UI string: qtn_vc_main_mp_nonbranded
+// l:None
+// r:3.2
+//
+#define qan_vc_main_mp_nonbranded          "Media Player"
+
+// d:Displayed within the list of voice commands.
+// d:This is alternative to qtn_vc_main_mp
+// d:Related spoken prompt: qan_vc_main_mp_nonbranded 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_mp_nonbranded          "Media Player"
+
+// ============================================================================
+// MediaPlayer commands END
+
+// Music Player command START
+// ============================================================================
+
+// d:Command said by user, opens the Music Player application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_music
+// l:None
+// r:3.2
+//
+#define qan_vc_main_music                      "Music Player"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_music 
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_music                     "Music Player"
+
+// ============================================================================
+// Music Player command END
+
+// Landmarks command START
+// ============================================================================
+
+// d:Command said by user, opens the Landmarks application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_lm 
+// l:None
+// r:3.2
+//
+#define qan_vc_main_lm              "Landmarks"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_lm
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_lm              "Landmarks"
+
+// ============================================================================
+// Landmarks command END
+
+// Navigator command START
+// ============================================================================
+
+// d:Command said by user, opens the Navigator application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_blid 
+// l:None
+// r:3.2
+//
+#define qan_vc_main_blid              "Navigator"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_blid
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_blid              "Navigator"
+
+// ============================================================================
+// Navigator command END
+
+// Data synchronisation command START
+// ============================================================================
+
+// d:Command said by user, opens the Data synchronisation application.
+// d:This is a default command
+// d:Related UI string: qtn_vc_main_datasync  
+// l:None
+// r:3.2
+//
+#define qan_vc_main_datasync              "Data synchronisation"
+
+// d:Displayed within the list of voice commands.
+// d:Related spoken prompt: qan_vc_main_datasync
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_datasync              "Data synchronisation"
+
+// ============================================================================
+// Data synchronisation command END
+
+
+// Spoken status info commands START
+// ============================================================================
+
+// d:Command said by user, time information will be played via text-to-speech
+// d:as an answer to the question.
+// d:Related UI string: qtn_vc_main_time
+// l:None
+// r:3.2
+//
+#define qan_vc_main_time                  "What time is it"
+
+// d:Displayed in the list of Spoken status info related voice commands.
+// d:Related spoken prompt: qan_vc_main_time
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_time                  "What time is it"
+
+// ============================================================================
+// Spoken status info commands END
+
+
+// Spoken time info START
+// ============================================================================
+
+// Should be defined as a compromise between natural speech and ease of
+// implementation. 
+
+// d:Spoken time information, used as input to text-to-speech engine.
+// d:%0N is the numeric value of hours, %1N is the numeric value of minutes.
+// d:Time expression e.g. 14:35 will be expanded to the spoken form by the NLP module.
+// d:Localization of actual time expression (%0N:%1N) is NOT handled here. 
+// d:Modify ONLY "It is", "AM" and "PM" parts of the strings.
+// d:"%0N:%1N" is also a valid localization if it is not suitable for
+// d:certain language to have "Time is" before the time expression.
+// d:For example: "It is 10:51"
+// l:None
+// r:3.2
+//
+#define qan_vc_prompt_time24                  "It is %0N:%1N"
+
+// d:Twelwe hour formatted time, am.
+// d:Numeric values same as above, acronyms should be written in capital letters.
+// l:None
+// r:3.2
+//
+#define qan_vc_prompt_time12am                "It is %0N:%1N AM"
+
+// d:Twelwe hour formatted time, pm.
+// d:Numeric values same as above, acronyms should be written in capital letters.
+// l:None
+// r:3.2
+//
+#define qan_vc_prompt_time12pm                "It is %0N:%1N PM"
+
+// ============================================================================
+// Spoken time info END
+
+
+// Folder texts START
+// ============================================================================
+
+// d:String which is shown within the list of voice commands in Voice Commands 
+// d:application as a folder name. Folder which contains profiles related commands.
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_profiles                          "Profiles"
+
+// d:String which is shown in title pane when Voice Commands application
+// d:is showing the profiles commands.
+// l:title_pane_t1
+// r:3.2
+//
+#define qtn_vc_title_profiles                         "Profiles"
+
+
+// d:String which is shown within the list of voice commands in Voice Commands 
+// d:application as a folder name. Folder which contains tools related commands.
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_tools                             "Tools"
+
+// d:String which is shown in title pane when Voice Commands application
+// d:is showing the tools commands.
+// l:title_pane_t1
+// r:3.2
+//
+#define qtn_vc_title_tools                            "Tools"
+
+
+// d:String which is shown within the list of voice commands in Voice Commands 
+// d:application as a folder name. Folder which contains messaging related commands.
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_messaging_folder                  "Messaging"
+
+// d:String which is shown in title pane when Voice Commands application
+// d:is showing the messaging commands.
+// l:title_pane_t1
+// r:3.2
+//
+#define qtn_vc_title_messaging                        "Messaging"
+
+
+// d:String which is shown within the list of voice commands in Voice Commands 
+// d:application as a folder name. Folder which contains organizer related commands.
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_organizer                         "Organizer"
+
+// d:String which is shown in title pane when Voice Commands application
+// d:is showing the organizer commands.
+// l:title_pane_t1
+// r:3.2
+//
+#define qtn_vc_title_organizer                        "Organizer"
+
+
+// d:String which is shown within the list of voice commands in Voice Commands 
+// d:application as a folder name. Folder which contains media related commands.
+// l:list_double_large_graphic_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_main_media                             "Media"
+
+// d:String which is shown in title pane when Voice Commands application
+// d:is showing the media commands.
+// l:title_pane_t1
+// r:3.2
+//
+#define qtn_vc_title_media                            "Media"
+
+// ============================================================================
+// Folder texts END
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/bwins/nssvasapiu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+EXPORTS
+	??1CNssAdaptationItem@@UAE@XZ @ 1 NONAME ; CNssAdaptationItem::~CNssAdaptationItem(void)
+	??1CNssTrainingParameters@@UAE@XZ @ 2 NONAME ; CNssTrainingParameters::~CNssTrainingParameters(void)
+	??1CVasVPbkHandler@@UAE@XZ @ 3 NONAME ; CVasVPbkHandler::~CVasVPbkHandler(void)
+	?AdaptL@CNssAdaptationItem@@UAEXPAVMNssAdaptationEventHandler@@AAVMNssTag@@@Z @ 4 NONAME ; void CNssAdaptationItem::AdaptL(class MNssAdaptationEventHandler *, class MNssTag &)
+	?AdaptL@CNssAdaptationItem@@UAEXPAVMNssAdaptationEventHandler@@H@Z @ 5 NONAME ; void CNssAdaptationItem::AdaptL(class MNssAdaptationEventHandler *, int)
+	?ChangeVoiceTagFieldL@CVasVPbkHandler@@UAEXH@Z @ 6 NONAME ; void CVasVPbkHandler::ChangeVoiceTagFieldL(int)
+	?CloseContactL@CVasVPbkHandler@@UAEXH@Z @ 7 NONAME ; void CVasVPbkHandler::CloseContactL(int)
+	?CompressL@CVasVPbkHandler@@UAEXXZ @ 8 NONAME ; void CVasVPbkHandler::CompressL(void)
+	?ContactIdArrayLC@CVasVPbkHandler@@UAEPAVCContactIdArray@@XZ @ 9 NONAME ; class CContactIdArray * CVasVPbkHandler::ContactIdArrayLC(void)
+	?CreateContactObserverL@CVasVPbkHandler@@UAEXPAVMVasContactObserver@@@Z @ 10 NONAME ; void CVasVPbkHandler::CreateContactObserverL(class MVasContactObserver *)
+	?Disable@CNssAdaptationItem@@QAEXXZ @ 11 NONAME ; void CNssAdaptationItem::Disable(void)
+	?FieldIdL@CVasVPbkHandler@@UAEHXZ @ 12 NONAME ; int CVasVPbkHandler::FieldIdL(void)
+	?FieldTypeL@CVasVPbkHandler@@UAE?AVTUid@@XZ @ 13 NONAME ; class TUid CVasVPbkHandler::FieldTypeL(void)
+	?FindContactFieldL@CVasVPbkHandler@@UAEXPAVMNssTag@@@Z @ 14 NONAME ; void CVasVPbkHandler::FindContactFieldL(class MNssTag *)
+	?FindContactL@CVasVPbkHandler@@UAEXJH@Z @ 15 NONAME ; void CVasVPbkHandler::FindContactL(long, int)
+	?FindContactL@CVasVPbkHandler@@UAEXPAVMNssTag@@@Z @ 16 NONAME ; void CVasVPbkHandler::FindContactL(class MNssTag *)
+	?FindDefaultContactFieldL@CVasVPbkHandler@@UAEXH@Z @ 17 NONAME ; void CVasVPbkHandler::FindDefaultContactFieldL(int)
+	?FindFieldL@CVasVPbkHandler@@UAEXH@Z @ 18 NONAME ; void CVasVPbkHandler::FindFieldL(int)
+	?FindFieldL@CVasVPbkHandler@@UAEXPAVMNssTag@@@Z @ 19 NONAME ; void CVasVPbkHandler::FindFieldL(class MNssTag *)
+	?GetContextMgr@CNssVASDBMgr@@QAEPAVMNssContextMgr@@XZ @ 20 NONAME ; class MNssContextMgr * CNssVASDBMgr::GetContextMgr(void)
+	?GetRecognitionHandler@CNssRecognitionHandlerBuilder@@QAEPAVMNssRecognitionHandler@@XZ @ 21 NONAME ; class MNssRecognitionHandler * CNssRecognitionHandlerBuilder::GetRecognitionHandler(void)
+	?GetTagMgr@CNssVASDBMgr@@QAEPAVMNssTagMgr@@XZ @ 22 NONAME ; class MNssTagMgr * CNssVASDBMgr::GetTagMgr(void)
+	?GetTagSelectNotification@CNssSelectNotificationBuilder@@QAEPAVMNssTagSelectNotification@@XZ @ 23 NONAME ; class MNssTagSelectNotification * CNssSelectNotificationBuilder::GetTagSelectNotification(void)
+	?GetTagSelectNotifier@CNssVASDBMgr@@QAEPAVCNssDBTagSelectNotifier@@XZ @ 24 NONAME ; class CNssDBTagSelectNotifier * CNssVASDBMgr::GetTagSelectNotifier(void)
+	?GetVASDBEventNotifier@CNssVASDBMgr@@QAEPAVMNssVASDBEventNotifier@@XZ @ 25 NONAME ; class MNssVASDBEventNotifier * CNssVASDBMgr::GetVASDBEventNotifier(void)
+	?InitializeL@CNssRecognitionHandlerBuilder@@QAEXXZ @ 26 NONAME ; void CNssRecognitionHandlerBuilder::InitializeL(void)
+	?InitializeL@CNssSelectNotificationBuilder@@QAEXXZ @ 27 NONAME ; void CNssSelectNotificationBuilder::InitializeL(void)
+	?InitializeL@CNssVASDBMgr@@QAEHXZ @ 28 NONAME ; int CNssVASDBMgr::InitializeL(void)
+	?InitializeL@CVasVPbkHandler@@UAEXXZ @ 29 NONAME ; void CVasVPbkHandler::InitializeL(void)
+	?IsFieldEmptyL@CVasVPbkHandler@@UAEHXZ @ 30 NONAME ; int CVasVPbkHandler::IsFieldEmptyL(void)
+	?LabelL@CVasVPbkHandler@@UAE?AVTPtrC16@@XZ @ 31 NONAME ; class TPtrC16 CVasVPbkHandler::LabelL(void)
+	?Languages@CNssTrainingParameters@@QBEABV?$RArray@W4TLanguage@@@@XZ @ 32 NONAME ; class RArray<enum TLanguage> const & CNssTrainingParameters::Languages(void) const
+	?NewL@CNssAdaptationItem@@SAPAV1@PAVCNssRecognitionHandler@@PAVCSIClientResultSet@@@Z @ 33 NONAME ; class CNssAdaptationItem * CNssAdaptationItem::NewL(class CNssRecognitionHandler *, class CSIClientResultSet *)
+	?NewL@CNssRecognitionHandlerBuilder@@SAPAV1@XZ @ 34 NONAME ; class CNssRecognitionHandlerBuilder * CNssRecognitionHandlerBuilder::NewL(void)
+	?NewL@CNssSelectNotificationBuilder@@SAPAV1@XZ @ 35 NONAME ; class CNssSelectNotificationBuilder * CNssSelectNotificationBuilder::NewL(void)
+	?NewL@CNssTrainingParameters@@SAPAV1@XZ @ 36 NONAME ; class CNssTrainingParameters * CNssTrainingParameters::NewL(void)
+	?NewL@CNssVASDBMgr@@SAPAV1@XZ @ 37 NONAME ; class CNssVASDBMgr * CNssVASDBMgr::NewL(void)
+	?NewL@CVasVPbkHandler@@SAPAV1@XZ @ 38 NONAME ; class CVasVPbkHandler * CVasVPbkHandler::NewL(void)
+	?NewLC@CNssRecognitionHandlerBuilder@@SAPAV1@XZ @ 39 NONAME ; class CNssRecognitionHandlerBuilder * CNssRecognitionHandlerBuilder::NewLC(void)
+	?NewLC@CNssSelectNotificationBuilder@@SAPAV1@XZ @ 40 NONAME ; class CNssSelectNotificationBuilder * CNssSelectNotificationBuilder::NewLC(void)
+	?NewLC@CNssTrainingParameters@@SAPAV1@XZ @ 41 NONAME ; class CNssTrainingParameters * CNssTrainingParameters::NewLC(void)
+	?NewLC@CNssVASDBMgr@@SAPAV1@XZ @ 42 NONAME ; class CNssVASDBMgr * CNssVASDBMgr::NewLC(void)
+	?ResetFactoryModelsL@CNssVASDBMgr@@QAEXPAVMNssResetFactoryModelsClient@@@Z @ 43 NONAME ; void CNssVASDBMgr::ResetFactoryModelsL(class MNssResetFactoryModelsClient *)
+	?Separator@CNssTrainingParameters@@QBE?AVTChar@@XZ @ 44 NONAME ; class TChar CNssTrainingParameters::Separator(void) const
+	?SetLanguages@CNssTrainingParameters@@QAEXPAV?$RArray@W4TLanguage@@@@@Z @ 45 NONAME ; void CNssTrainingParameters::SetLanguages(class RArray<enum TLanguage> *)
+	?SetSeparator@CNssTrainingParameters@@QAEXVTChar@@@Z @ 46 NONAME ; void CNssTrainingParameters::SetSeparator(class TChar)
+	?SetSindeLanguages@CNssTrainingParameters@@QAEXABV?$RArray@V?$RArray@W4TLanguage@@@@@@@Z @ 47 NONAME ; void CNssTrainingParameters::SetSindeLanguages(class RArray<class RArray<enum TLanguage> > const &)
+	?SindeLanguagesL@CNssTrainingParameters@@QBEABV?$RArray@V?$RArray@W4TLanguage@@@@@@XZ @ 48 NONAME ; class RArray<class RArray<enum TLanguage> > const & CNssTrainingParameters::SindeLanguagesL(void) const
+	?Tag@CNssVASDBEvent@@QAEPAVMNssTag@@XZ @ 49 NONAME ; class MNssTag * CNssVASDBEvent::Tag(void)
+	?TextL@CVasVPbkHandler@@UAE?AVTPtrC16@@XZ @ 50 NONAME ; class TPtrC16 CVasVPbkHandler::TextL(void)
+	?Type@CNssVASDBEvent@@QAE?AW4TVASDBEventType@1@XZ @ 51 NONAME ; enum CNssVASDBEvent::TVASDBEventType CNssVASDBEvent::Type(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/eabi/nssvasapiu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,146 @@
+EXPORTS
+	_ZN12CNssVASDBMgr11InitializeLEv @ 1 NONAME
+	_ZN12CNssVASDBMgr13GetContextMgrEv @ 2 NONAME
+	_ZN12CNssVASDBMgr19ResetFactoryModelsLEP28MNssResetFactoryModelsClient @ 3 NONAME
+	_ZN12CNssVASDBMgr20GetTagSelectNotifierEv @ 4 NONAME
+	_ZN12CNssVASDBMgr21GetVASDBEventNotifierEv @ 5 NONAME
+	_ZN12CNssVASDBMgr4NewLEv @ 6 NONAME
+	_ZN12CNssVASDBMgr5NewLCEv @ 7 NONAME
+	_ZN12CNssVASDBMgr9GetTagMgrEv @ 8 NONAME
+	_ZN14CNssVASDBEvent3TagEv @ 9 NONAME
+	_ZN14CNssVASDBEvent4TypeEv @ 10 NONAME
+	_ZN15CVasVPbkHandler10FieldTypeLEv @ 11 NONAME
+	_ZN15CVasVPbkHandler10FindFieldLEP7MNssTag @ 12 NONAME
+	_ZN15CVasVPbkHandler10FindFieldLEi @ 13 NONAME
+	_ZN15CVasVPbkHandler11InitializeLEv @ 14 NONAME
+	_ZN15CVasVPbkHandler12FindContactLEP7MNssTag @ 15 NONAME
+	_ZN15CVasVPbkHandler12FindContactLEli @ 16 NONAME
+	_ZN15CVasVPbkHandler13CloseContactLEi @ 17 NONAME
+	_ZN15CVasVPbkHandler13IsFieldEmptyLEv @ 18 NONAME
+	_ZN15CVasVPbkHandler16ContactIdArrayLCEv @ 19 NONAME
+	_ZN15CVasVPbkHandler17FindContactFieldLEP7MNssTag @ 20 NONAME
+	_ZN15CVasVPbkHandler20ChangeVoiceTagFieldLEi @ 21 NONAME
+	_ZN15CVasVPbkHandler22CreateContactObserverLEP19MVasContactObserver @ 22 NONAME
+	_ZN15CVasVPbkHandler24FindDefaultContactFieldLEi @ 23 NONAME
+	_ZN15CVasVPbkHandler4NewLEv @ 24 NONAME
+	_ZN15CVasVPbkHandler5TextLEv @ 25 NONAME
+	_ZN15CVasVPbkHandler6LabelLEv @ 26 NONAME
+	_ZN15CVasVPbkHandler8FieldIdLEv @ 27 NONAME
+	_ZN15CVasVPbkHandler9CompressLEv @ 28 NONAME
+	_ZN15CVasVPbkHandlerD0Ev @ 29 NONAME
+	_ZN15CVasVPbkHandlerD1Ev @ 30 NONAME
+	_ZN15CVasVPbkHandlerD2Ev @ 31 NONAME
+	_ZN18CNssAdaptationItem4NewLEP22CNssRecognitionHandlerP18CSIClientResultSet @ 32 NONAME
+	_ZN18CNssAdaptationItem6AdaptLEP26MNssAdaptationEventHandlerR7MNssTag @ 33 NONAME
+	_ZN18CNssAdaptationItem6AdaptLEP26MNssAdaptationEventHandleri @ 34 NONAME
+	_ZN18CNssAdaptationItem7DisableEv @ 35 NONAME
+	_ZN18CNssAdaptationItemD0Ev @ 36 NONAME
+	_ZN18CNssAdaptationItemD1Ev @ 37 NONAME
+	_ZN18CNssAdaptationItemD2Ev @ 38 NONAME
+	_ZN22CNssTrainingParameters12SetLanguagesEP6RArrayI9TLanguageE @ 39 NONAME
+	_ZN22CNssTrainingParameters12SetSeparatorE5TChar @ 40 NONAME
+	_ZN22CNssTrainingParameters17SetSindeLanguagesERK6RArrayIS0_I9TLanguageEE @ 41 NONAME
+	_ZN22CNssTrainingParameters4NewLEv @ 42 NONAME
+	_ZN22CNssTrainingParameters5NewLCEv @ 43 NONAME
+	_ZN22CNssTrainingParametersD0Ev @ 44 NONAME
+	_ZN22CNssTrainingParametersD1Ev @ 45 NONAME
+	_ZN22CNssTrainingParametersD2Ev @ 46 NONAME
+	_ZN29CNssRecognitionHandlerBuilder11InitializeLEv @ 47 NONAME
+	_ZN29CNssRecognitionHandlerBuilder21GetRecognitionHandlerEv @ 48 NONAME
+	_ZN29CNssRecognitionHandlerBuilder4NewLEv @ 49 NONAME
+	_ZN29CNssRecognitionHandlerBuilder5NewLCEv @ 50 NONAME
+	_ZN29CNssSelectNotificationBuilder11InitializeLEv @ 51 NONAME
+	_ZN29CNssSelectNotificationBuilder24GetTagSelectNotificationEv @ 52 NONAME
+	_ZN29CNssSelectNotificationBuilder4NewLEv @ 53 NONAME
+	_ZN29CNssSelectNotificationBuilder5NewLCEv @ 54 NONAME
+	_ZNK22CNssTrainingParameters15SindeLanguagesLEv @ 55 NONAME
+	_ZNK22CNssTrainingParameters9LanguagesEv @ 56 NONAME
+	_ZNK22CNssTrainingParameters9SeparatorEv @ 57 NONAME
+	_ZTI10CNssTagMgr @ 58 NONAME ; #<TI>#
+	_ZTI11CNssContext @ 59 NONAME ; #<TI>#
+	_ZTI12CNssVASDBMgr @ 60 NONAME ; #<TI>#
+	_ZTI14CNssContextMgr @ 61 NONAME ; #<TI>#
+	_ZTI14CNssSpeechItem @ 62 NONAME ; #<TI>#
+	_ZTI14CNssVASDBEvent @ 63 NONAME ; #<TI>#
+	_ZTI15CNssVASDatabase @ 64 NONAME ; #<TI>#
+	_ZTI15CVasVPbkHandler @ 65 NONAME ; #<TI>#
+	_ZTI16CNssTagReference @ 66 NONAME ; #<TI>#
+	_ZTI16CNssVASDBBuilder @ 67 NONAME ; #<TI>#
+	_ZTI17CNssTagSelectData @ 68 NONAME ; #<TI>#
+	_ZTI18CNssAdaptationItem @ 69 NONAME ; #<TI>#
+	_ZTI18CNssContextBuilder @ 70 NONAME ; #<TI>#
+	_ZTI20CNssContextSrsPortal @ 71 NONAME ; #<TI>#
+	_ZTI21CNssSpeechItemBuilder @ 72 NONAME ; #<TI>#
+	_ZTI21CNssSpeechItemTrainer @ 73 NONAME ; #<TI>#
+	_ZTI21CNssVASDBEventMonitor @ 74 NONAME ; #<TI>#
+	_ZTI22CNssRecognitionHandler @ 75 NONAME ; #<TI>#
+	_ZTI22CNssTrainingParameters @ 76 NONAME ; #<TI>#
+	_ZTI22CNssVASDBEventNotifier @ 77 NONAME ; #<TI>#
+	_ZTI23CNssDBTagSelectNotifier @ 78 NONAME ; #<TI>#
+	_ZTI23CNssSpeechItemSrsPortal @ 79 NONAME ; #<TI>#
+	_ZTI25CNssTagSelectNotification @ 80 NONAME ; #<TI>#
+	_ZTI29CNssRecognitionHandlerBuilder @ 81 NONAME ; #<TI>#
+	_ZTI29CNssSelectNotificationBuilder @ 82 NONAME ; #<TI>#
+	_ZTI7CNssRRD @ 83 NONAME ; #<TI>#
+	_ZTI7CNssTag @ 84 NONAME ; #<TI>#
+	_ZTV10CNssTagMgr @ 85 NONAME ; #<VT>#
+	_ZTV11CNssContext @ 86 NONAME ; #<VT>#
+	_ZTV12CNssVASDBMgr @ 87 NONAME ; #<VT>#
+	_ZTV14CNssContextMgr @ 88 NONAME ; #<VT>#
+	_ZTV14CNssSpeechItem @ 89 NONAME ; #<VT>#
+	_ZTV14CNssVASDBEvent @ 90 NONAME ; #<VT>#
+	_ZTV15CNssVASDatabase @ 91 NONAME ; #<VT>#
+	_ZTV15CVasVPbkHandler @ 92 NONAME ; #<VT>#
+	_ZTV16CNssTagReference @ 93 NONAME ; #<VT>#
+	_ZTV16CNssVASDBBuilder @ 94 NONAME ; #<VT>#
+	_ZTV17CNssTagSelectData @ 95 NONAME ; #<VT>#
+	_ZTV18CNssAdaptationItem @ 96 NONAME ; #<VT>#
+	_ZTV18CNssContextBuilder @ 97 NONAME ; #<VT>#
+	_ZTV20CNssContextSrsPortal @ 98 NONAME ; #<VT>#
+	_ZTV21CNssSpeechItemBuilder @ 99 NONAME ; #<VT>#
+	_ZTV21CNssSpeechItemTrainer @ 100 NONAME ; #<VT>#
+	_ZTV21CNssVASDBEventMonitor @ 101 NONAME ; #<VT>#
+	_ZTV22CNssRecognitionHandler @ 102 NONAME ; #<VT>#
+	_ZTV22CNssTrainingParameters @ 103 NONAME ; #<VT>#
+	_ZTV22CNssVASDBEventNotifier @ 104 NONAME ; #<VT>#
+	_ZTV23CNssDBTagSelectNotifier @ 105 NONAME ; #<VT>#
+	_ZTV23CNssSpeechItemSrsPortal @ 106 NONAME ; #<VT>#
+	_ZTV25CNssTagSelectNotification @ 107 NONAME ; #<VT>#
+	_ZTV29CNssRecognitionHandlerBuilder @ 108 NONAME ; #<VT>#
+	_ZTV29CNssSelectNotificationBuilder @ 109 NONAME ; #<VT>#
+	_ZTV7CNssRRD @ 110 NONAME ; #<VT>#
+	_ZTV7CNssTag @ 111 NONAME ; #<VT>#
+	_ZThn12_N15CVasVPbkHandlerD0Ev @ 112 NONAME ; #<thunk>#
+	_ZThn12_N15CVasVPbkHandlerD1Ev @ 113 NONAME ; #<thunk>#
+	_ZThn16_N15CVasVPbkHandlerD0Ev @ 114 NONAME ; #<thunk>#
+	_ZThn16_N15CVasVPbkHandlerD1Ev @ 115 NONAME ; #<thunk>#
+	_ZThn24_N15CVasVPbkHandlerD0Ev @ 116 NONAME ; #<thunk>#
+	_ZThn24_N15CVasVPbkHandlerD1Ev @ 117 NONAME ; #<thunk>#
+	_ZThn28_N15CVasVPbkHandlerD0Ev @ 118 NONAME ; #<thunk>#
+	_ZThn28_N15CVasVPbkHandlerD1Ev @ 119 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler10FieldTypeLEv @ 120 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler10FindFieldLEP7MNssTag @ 121 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler10FindFieldLEi @ 122 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler11InitializeLEv @ 123 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler12FindContactLEP7MNssTag @ 124 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler12FindContactLEli @ 125 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler13CloseContactLEi @ 126 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler13IsFieldEmptyLEv @ 127 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler16ContactIdArrayLCEv @ 128 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler17FindContactFieldLEP7MNssTag @ 129 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler20ChangeVoiceTagFieldLEi @ 130 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler22CreateContactObserverLEP19MVasContactObserver @ 131 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler24FindDefaultContactFieldLEi @ 132 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler5TextLEv @ 133 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler6LabelLEv @ 134 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler8FieldIdLEv @ 135 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandler9CompressLEv @ 136 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandlerD0Ev @ 137 NONAME ; #<thunk>#
+	_ZThn4_N15CVasVPbkHandlerD1Ev @ 138 NONAME ; #<thunk>#
+	_ZThn4_N18CNssAdaptationItem6AdaptLEP26MNssAdaptationEventHandlerR7MNssTag @ 139 NONAME ; #<thunk>#
+	_ZThn4_N18CNssAdaptationItem6AdaptLEP26MNssAdaptationEventHandleri @ 140 NONAME ; #<thunk>#
+	_ZThn4_N18CNssAdaptationItemD0Ev @ 141 NONAME ; #<thunk>#
+	_ZThn4_N18CNssAdaptationItemD1Ev @ 142 NONAME ; #<thunk>#
+	_ZThn8_N15CVasVPbkHandlerD0Ev @ 143 NONAME ; #<thunk>#
+	_ZThn8_N15CVasVPbkHandlerD1Ev @ 144 NONAME ; #<thunk>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for Voice Application Services (NssVAS)
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+// specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+
+#include "exports.inc"
+
+PRJ_MMPFILES
+// specify the .mmp files required for building the important component releasables
+// note that you should specify any .mmp files for test programs further down the file.
+//
+// It's best if the .MMP files are specified in the order in which the components are
+// built, but that eventually shouldn't matter
+//
+// Use C++ style #defines to denote that a component is only built for a particular platform
+//
+// specify "tidy" if the component you need to build doesn't need to be released to
+// the rest of the company
+// specify "ignore" if the MMP file exists but should be ignored - William wants this!
+
+
+nssvasapi.mmp
+
+
+
+PRJ_TESTMMPFILES
+// specify the .mmp files required for building any test programs here
+//
+// you can specify "manual" to denote that a test should be listed in a generated
+// batch file for running a group of tests which require user input during testing.
+// you can specify "support" to denote that a file is a test support file and shouldn't
+// be listed in a batch file for running a group of tests
+// By default, each test will be listed in a batch file for running a group of tests
+// which can be left to run without requiring watching over by the person running the tests,
+// i.e. tests where no user input is required.  The default will apply if neither "manual"
+// or "support" is specified.
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* ==============================================================================
+*        %name: exports.inc %
+*     %version: 13 %
+*         Name: NssVasCRRD.h
+*      Part of: NssVAS / NssVASApi
+*  Description: VAS Exports for external clients
+*
+*  Copyright © 2004-2006 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+* ==============================================================================
+*/
+
+#include <platform_paths.hrh>
+
+../nssvasdb/inc/10201afe.spd                                       /epoc32/release/winscw/udeb/z/private/100012a5/policy/10201afe.spd
+../nssvasdb/inc/10201afe.spd                                       /epoc32/release/winscw/urel/z/private/100012a5/policy/10201afe.spd
+../nssvasdb/inc/10201afe.spd                                       /epoc32/data/z/private/100012a5/policy/10201afe.spd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/group/nssvasapi.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file NssVAS Api
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET            nssvasapi.dll
+TARGETTYPE        dll
+UID               0x1000008d 0x10201aee // UID: 270539502
+
+VENDORID          VID_DEFAULT
+
+// This is a SYSTEMINCLUDE macro containing the application
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE     /epoc32/include/connect
+SYSTEMINCLUDE     /epoc32/include/mmf/common
+
+USERINCLUDE       ../../group  // for srsfbldvariant.hrh
+USERINCLUDE       ../nssvascore/inc ../nssvasrecognition/inc 
+USERINCLUDE       ../nssvasdb/inc ../nssvasdb/nssvasdbeventnotifier/inc
+USERINCLUDE       ../../inc
+
+SOURCEPATH        ../nssvascore/src
+SOURCE            nssvasapimain.cpp
+SOURCE            nssvasccontext.cpp nssvascrrd.cpp nssvasctag.cpp nssvascspeechitem.cpp
+SOURCE            nssvasccontextbuilder.cpp nssvasccontextsrsportal.cpp
+SOURCE            nssvascspeechitembuilder.cpp nssvascspeechitemtrainer.cpp
+SOURCE            nssvasctrainingactiontracker.cpp
+SOURCE            nssvasctrainingparams.cpp
+SOURCE            nssvascspeechitemsrsportal.cpp nssvasctagreference.cpp
+SOURCE            nssvassiutilitywrapper.cpp nssvasttsutilitywrapper.cpp
+
+SOURCE            vascvpbkhandler.cpp
+
+SOURCEPATH        ../nssvasdb/src
+SOURCE            nssvasccontextmgr.cpp nssvascdbtagselectnotifier.cpp
+SOURCE            nssvasctagmgr.cpp nssvascvasdbbuilder.cpp nssvascvasdbmgr.cpp
+SOURCE            nssvascvasdatabase.cpp nssvasrvasdbsession.cpp 
+SOURCE            nssvasbackupobserver.cpp
+
+SOURCE            nssvascvasdb.cpp nssvastvasdbcreator.cpp
+
+SOURCEPATH        ../nssvasdb/nssvasdbeventnotifier/src
+SOURCE            nssvascvasdbeventmonitor.cpp nssvascvasdbeventnotifier.cpp nssvascvasdbevent.cpp
+
+SOURCEPATH        ../nssvasrecognition/src
+SOURCE            nssvascrecognitionhandler.cpp nssvascrecognitionhandlerbuilder.cpp 
+SOURCE            nssvascselectnotificationbuilder.cpp nssvasctagselectnotification.cpp
+SOURCE            nssvasctagselectdata.cpp
+SOURCE            nssvascadaptationitem.cpp
+
+USERINCLUDE       ../../rubydebug  
+
+// Database file name is read from a resource file.
+
+SOURCEPATH        .
+
+START RESOURCE    nssvasresource.rss
+HEADER
+#include "data_caging_paths.hrh"
+TARGETPATH        RESOURCE_FILES_DIR
+END
+
+LIBRARY           euser.lib efsrv.lib edbms.lib 
+LIBRARY           nsssispeechrecognitiondata.lib
+LIBRARY           bafl.lib 
+LIBRARY           nssttscommon.lib
+LIBRARY           sysutil.lib
+LIBRARY           commonengine.lib // for shared data client
+
+LIBRARY           cone.lib
+LIBRARY           cntmodel.lib
+LIBRARY           pbkeng.lib
+LIBRARY           vpbkeng.lib
+LIBRARY           ecom.lib
+LIBRARY           featmgr.lib
+LIBRARY           centralrepository.lib
+
+CAPABILITY        CAP_GENERAL_DLL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/group/nssvasresource.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SD Controller Plugin resource file.
+*
+*/
+
+
+//  INCLUDES
+#include "nssvasresource.rh"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// vasInfo
+// VAS resouce file.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE VAS_INFO vasInfo
+    {
+    // Location of the VAS database
+    directory_name = "c:\\system\\data\\vasdb\\";
+    // Name of the database file
+    database_name = "nssvasdatabase.db";
+    }
+            
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasccontext.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,322 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CContext class provides context processing. It implements 
+*               MNssContext interface.
+*
+*/
+
+
+#ifndef NSSVASCCONTEXT_H
+#define NSSVASCCONTEXT_H
+
+//  INCLUDES
+#include <nsssispeechrecognitiondatacommon.h>
+#include "nssvascoreconstant.h"
+#include "nssvasmcontext.h"
+#include "nssvasccontextsrsportal.h"
+#include "nssvasmcoresrsdbeventhandler.h"
+#include "nssvascoreconstant.h"
+
+
+class CNssContextSrsPortal;
+
+// CLASS DECLARATION
+
+/**
+*  CContext is the implementation class for MNssContext. 
+*  It encapsulates context data. A context cannot be directly created by a 
+*  client. A client has to own an instance of Context Manager which has methods 
+*  for creating context objects. The CContext class also provides additional 
+*  members for internal use by NssVAS.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class CNssContext: public CBase, public MNssContext
+{
+public:
+    /**
+    * C++ constructor.
+    */
+	CNssContext(CNssContextSrsPortal* aContextSrsPortal);
+
+    /**
+    * Destructor.
+    */
+	~CNssContext();
+
+public: // functions for internal VAS use
+
+    /**
+    * Get the context id
+	* for internal use
+	* @since 2.0
+    * @param 
+    * @return context id
+    */
+	TInt ContextId() const;
+
+    /**
+    * Get the grammar id
+	* for internal use
+	* @since 2.0
+    * @param 
+    * @return grammar id
+    */
+	TUint32 GrammarId() const;
+
+	/**
+    * Get the lexicon id
+	* for internal use
+	* @since 2.0
+    * @param 
+    * @return lexicon id
+    */
+	TUint32 LexiconId() const;
+
+	/**
+    * Get the model bank id
+	* for internal use
+	* @since 2.0
+    * @param 
+    * @return model bank id
+    */
+	TUint32 ModelBankId() const;
+
+	/**
+    * Get the recognition mode
+	* for internal use
+	* @since 2.8
+    * @param none
+    * @return recognition technology (SI / SD)
+    */
+	TNSSRecognitionMode RecognitionMode() const;
+
+    /**
+    * Set the context id 
+	* for internal use
+	* @since 2.0
+    * @param aContextId - the context id 
+    * @return 
+    */
+	void SetContextId(TInt aContextId);
+
+	/**
+    * Set the grammar id 
+	* for internal use
+	* @since 2.0
+    * @param aGrammarId - the grammar id
+    * @return 
+    */
+	void SetGrammarId(TUint32 aGrammarId);
+
+	/**
+    * Set the lexicon id
+	* for internal use
+	* @since 2.0
+    * @param aLexiconId - the lexicon id
+    * @return id
+    */
+	void SetLexiconId(TUint32 aLexiconId);
+
+	/**
+    * Set the model bank id
+	* for internal use
+	* @since 2.0
+    * @param aModelBankId - the model bank id
+    * @return id
+    */
+	void SetModelBankId(TUint32 aModelBankId);
+
+    /**
+    * Set the speech technology (Speaker independent or dependent)
+    * for internal use
+    * @since 2.0
+    * @param aRecognitionMode - the recognition mode
+    * @return none
+    */
+    void SetRecognitionMode(TNSSRecognitionMode aRecognitionMode);
+
+	/**
+    * Save the context to the SRS. 
+	* for internal use
+	* This method is used to save the context to the SRS.
+	* This creates the model bank, 
+	* lexicon, and grammar for a context. Model bank, and lexicon 
+	* are created only for the first time, and are thus, fixed.
+	* For every context, there is one grammar id. After, model bank,
+	* lexicon, and grammar are created, the corresponding Ids are 
+	* set in the context object.
+	* @since 2.0
+    * @param
+    * @return none
+    */
+	void BeginSaveToSrsL(MNssCoreSrsDBEventHandler* aSrsDBEventHandler);
+
+	/**
+    * Delete the context from the SRS. 
+	* for internal use
+	* deletes grammar from SRS
+	* @since 2.0
+    * @param 
+    * @return none
+    */
+	void BeginDeleteFromSrsL(MNssCoreSrsDBEventHandler* aSrsDBEventHandler);
+
+	/**
+    * Commit the context from the SRS. 
+	* for internal use
+	* Commit the changes from SRS
+	* @since 2.0
+    * @param 
+    * @return 
+    */
+	TInt CommitSrsChanges();
+
+	/**
+    * Don't commit the context from the SRS. 
+	* for internal use
+	* Doesn't commit the changes from SRS
+	* @since 2.8
+    * @param 
+    * @return 
+    */
+	TInt RollbackSrsChanges();
+
+    /**
+    * Set/Reset the iModelBankAndLexiconExist flag.
+	* for internal use
+	* @since 2.0
+    * @param aVal, ETrue to set, EFalse to reset
+    * @return 
+    */
+	void SetModelBankAndLexiconExist(TBool aVal);
+
+	/**
+    * Get the iModelBankAndLexiconExist flag
+	* for internal use
+	* @since 2.0
+    * @param 
+    * @return ETrue if set, else EFalse
+    */
+	TBool ModelBankAndLexiconExist();
+
+	/**
+    * overloaded assignment operator
+	* for internal use
+	* @since 2.0
+    * @param reference to context
+    * @return reference to the context
+    */
+	CNssContext& operator=(const CNssContext& aContext);
+
+	/**
+    * Create a copy of the context. 
+	* for internal use
+	* This function creates a new context by allocating memory for
+	* a new context, and deep copying the members of the context on which
+	* this fucntion is called. Old context and new context exist. Client need
+	* to deallocate memory.
+	* @since 2.0
+    * @param 
+    * @return pointer the newly created context.
+    */
+	CNssContext* CopyL();
+
+    /**
+    * Sets/Resets the client data. The data must be saved with
+    * MNssContextMgr::SaveClientData after this call.
+    * @since 2.8
+    * @param aData At most 100 bytes of serialized client data.
+    */
+    void SetClientData(const TDesC8& aData);
+
+    /**
+    * Gets the client data.
+    * @since 2.8
+    * @return At most 100 bytes of data.
+    */
+    const TDesC8& ClientData();
+
+public: // functions derived from MNssContext
+
+   /**
+   * Get the name of the context
+   * @since 2.0
+   * @param 
+   * @return reference to name of context
+   */  
+   TDesC& ContextName();
+
+	/**
+   * Is the context global
+   * @since 2.0
+   * @param 
+   * @return ETrue if context is global, EFalse otherwise
+   */  
+   TBool IsGlobal();
+
+	/**
+    * Sets the name of the context
+	* @since 2.0
+    * @param aName name of the context as a descriptor
+    * @return 
+    */  
+    void SetNameL(const TDesC& aName);
+
+   /**
+   * Sets/Resets the global flag for the context
+   * @since 2.0
+   * @param aGlobal ETrue to set the context as global, EFalse as not global 
+   * @return 
+   */  
+   void SetGlobal(TBool aGlobal);
+
+private: // data
+
+	// name of the context
+	HBufC*				iName;
+
+	// context id, used by the VAS DB
+	TInt				iContextId;
+
+	// global flag
+	TBool				iGlobal;
+
+	// grammar id
+	TUint32		        iGrammarId;
+
+	// lexicon id
+	TUint32             iLexiconId;
+
+	// model bank id
+	TUint32             iModelBankId;
+
+	// association to context srs portal 
+	CNssContextSrsPortal*	iContextSrsPortal;
+	
+	// flag to denote if Model Bank and Lexicon already created
+	TBool				iModelBankAndLexiconExist;
+
+    // differentiates between SI and SD contexts
+    TNSSRecognitionMode iRecognitionMode;
+
+    // client payload data
+    TBuf8<100>          iClientData;
+};
+
+
+#endif // NSSVASCCONTEXT  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasccontextbuilder.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssContextBuilder is the builder for context objects. It is owned 
+*               by the context manager. A client builds contexts by requesting the
+*               context manager which in turn forwards the request to context builder.
+*
+*/
+
+
+#ifndef NSSVASCCONTEXTBUILDER_H
+#define NSSVASCCONTEXTBUILDER_H
+
+//  INCLUDES
+#include "nssvasccontext.h"
+#include "nssvasccontextsrsportal.h" 
+
+// CLASS DECLARATION
+
+/**
+*  CNssContextBuilder is a builder class for creating context objects. 
+*  It has overloaded variants for the CreateContext(). A client will not create 
+*  a context object directly but will request it through the context manager, 
+*  which in turn calls the CreateContext() in context builder. 
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssContextBuilder: public CBase
+{
+public:
+
+     /**
+    * destructor
+    * @param 
+    * @return 
+    */
+	~CNssContextBuilder();
+
+    /**
+    * 2 phase construction
+    * @param 
+    * @return pointer to context builder
+    */
+	static CNssContextBuilder* NewL();
+
+    /**
+    * 2 phase construction
+    * @param 
+    * @return pointer to context builder 
+    */
+	static CNssContextBuilder* NewLC();
+
+public: 
+
+    /**
+    * create a context given the name, context id, global flag, grammar id, 
+	* lexicon id, and modelbank id. Used by VAS internal components
+	* @since 2.0
+    * @param aName Name for the context
+	* @param aContextId Context Id for the context
+	* @param aGlobal Context is global or not
+	* @param aGrammarId Grammar id for the context
+	* @param aLexiconId Lexicon id for the context 
+	* @param aModelBankId Model bank id for the context
+    * @return 
+    */
+	CNssContext* CreateContextL(const TDesC& aName, TInt aContextId, TBool aGlobal, 
+	                TUint32 aGrammarId, TUint32 aLexiconId, TUint32 aModelBankId, 
+	                TUint32 iTrainType, const TDesC8& aClientData );
+
+    /**
+    * create a context given the lexicon id and modelbank id, other members of the 
+	* context are initialized to 0. Used by VAS internal components
+	* @since 2.0
+    * @param aLexiconId lexicon id
+	* @param aModelBankId model bank id
+    * @return 
+    */
+	CNssContext* CreateContextL(TUint32 aLexiconId, TUint32 aModelBankId);
+
+    /**
+    * create an empty context
+	* @since 2.0
+    * @param 
+    * @return context id
+    */
+	CNssContext* CreateContextL();
+
+    /**
+    * get context SRS portal
+    * @since 2.8
+    * @param
+    * @return CNssContextSrsPortal
+    */
+    CNssContextSrsPortal* GetContextPortal();
+
+private:
+
+	/**
+    * constructor
+    * @param 
+    * @return 
+    */
+	CNssContextBuilder();
+
+    /**
+    * 2 phase construction
+    * @param 
+    * @return context id
+    */
+	void ConstructL();
+
+private:
+	
+	// a srs utility portal
+	CNssContextSrsPortal* iContextSrsPortal;
+};
+
+
+#endif // NSSVASCCONTEXTBUILDER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasccontextsrsportal.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,229 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssContextSrsPortal provides SRS related functionalities for 
+*               context processing. A context is saved in the SRS DB by creating 
+*               model bank, lexicon, and grammar into the SRS.
+*
+*/
+
+
+#ifndef NSSVASCCONTEXTSRSPORTAL_H
+#define NSSVASCCONTEXTSRSPORTAL_H
+
+//  INCLUDES
+#include "nssvassiutilitywrapper.h"
+#include <nsssispeechrecognitionutilityobserver.h>
+#include "nssvasccontext.h"
+#include "nssvasmcoresrsdbeventhandler.h"
+
+// FORWARD DECLARATIONS
+class CNssContext;
+ 
+//FORWARD DECLARATION  
+class MNssSpeechRecognitionEvent;
+
+// CLASS DECLARATION
+
+/**
+*  CNssContextSrsPortal is the interface to SRS.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssContextSrsPortal: public CBase, public MSISpeechRecognitionUtilityObserver
+{
+
+public:
+
+	// ENUMERATIONS
+	enum TNssTerminationState
+	{
+		EVASTERMINATION_PENDING,
+		EVASTERMINATION_NOT_PENDING
+	};
+
+public:
+
+	/**
+    * C++ constructor
+    */
+	CNssContextSrsPortal();
+
+	/**
+    * C++ destructor
+    */
+	~CNssContextSrsPortal();
+
+public: // from MSpeechRecognitionEvent
+
+	/**
+    * overriding interface from MSpeechRecognitionUtilityObserver
+	* @since 2.0
+    */
+	void MsruoEvent(TUid aEvent, TInt aResult);
+
+
+public: // for inter component use
+
+	/**
+    * Save a context to SRS. Asyncronous function.
+	* @since 2.0
+    * @param aContext - context to be saved
+	* @param aSrsDBEventHandler - call back address
+    * @return none
+    */
+	void BeginSaveContextL(CNssContext* aContext, MNssCoreSrsDBEventHandler* aSrsDBEventHandler);
+
+	/**
+    * Delete a context from SRS. Asyncronous function
+	* @since 2.0
+    * @param aContext - context to be deleted
+	* @param aSrsDBEventHandler - call back address
+    * @return none
+    */
+	void BeginDeleteContextL(CNssContext* aContext, MNssCoreSrsDBEventHandler* aSrsDBEventHandler);
+
+    /**
+    * Reset speaker adapted models: Remove a model bank and create a new one.
+    * @since 2.8
+    * @param 
+    * @return none
+    */
+    void BeginResetModelsL( TSIModelBankID aAdaptedModels, 
+            TSIModelBankID& aNewModels, MNssCoreSrsDBEventHandler* aSrsDBEventHandler );
+
+	/**
+    * Commit a context from SRS. Syncronous function
+	* @since 2.0
+    * @param 
+    * @return error code
+    */
+	TInt CommitSaveContext();
+
+	/**
+    * Don't commit a context from SRS. Syncronous function
+	* @since 2.8
+    * @param 
+    * @return error code
+    */
+	TInt RollbackSaveContext();
+
+	/**
+    * Register context to the portal
+	* @since 2.0
+    * @param 
+    * @return
+    */
+	void Register();
+
+	/**Deregister context from portal 
+	* @since 2.0
+    * @param 
+    * @return 
+    */
+	void Deregister();
+
+	/**
+    * Set portal state to termination pending, or not pending
+	* @since 2.0
+    * @param aState - termination pending, or not.
+    * @return 
+    */
+	void SetTerminationState(TNssTerminationState aState);
+
+	/**
+    * Returns context count, number of contexts registered with the portal
+	* @since 2.0
+    * @param 
+    * @return count
+    */
+	TInt ContextCount();
+
+	/**
+    * Clean up the SRS after the SRS operation fail
+	* @since 2.0
+    * @param 
+    * @return
+    */
+	void CleanUp(TInt aResult);
+
+	/**
+    * Delete the SRS 
+	* @since 2.0
+    * @param 
+    * @return
+    */
+	void DeleteSRS();
+
+    /**
+    * Method to process the SRS DB error 
+    * @since 2.0
+    * @param aResult - the result value from SRS to indicate an error
+    * @return - an error code to identify the DB error
+    */   
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult DoSrsDBResult(TInt aResult);
+
+
+
+private:
+	
+	// a count of the number of contexts registered to the portal
+	TInt					    iContextCount; 
+
+	// state denoting if the builder is destroyed or not
+	TNssTerminationState			iTerminationState;
+
+	// instance of the SRS utility class
+	CNssSiUtilityWrapper*	iSpeechRecognitionUtility;
+
+	// Pointer to SRS DB Event Handler object.
+    MNssCoreSrsDBEventHandler* iSrsDBEventHandler; 
+	
+	// model bank id, used internally for error handling
+	TSIModelBankID iModelBankId;
+
+	// lexicon id, used internally for error handling
+	TSILexiconID iLexiconId;
+
+	// grammar id, used internally for error handling
+	TSIGrammarID iGrammarId;
+
+	// local pointer to context, used internally for error handling
+	CNssContext *iContext;
+
+	// flag for recovery during error cases
+	TBool iRecovery;
+
+    // when resetting speaker adaptation, the new model bank ID is stored here.
+    TSIModelBankID* iResetModelBankId;
+
+	// states required for EDiskFull errors from SRS
+	enum TState
+	{
+		EVASNone,
+		EVASCreateModelBank,
+		EVASCreateLexicon,
+		EVASCreateGrammar,
+		EVASRemoveModelBank,
+		EVASRemoveLexicon,
+		EVASRemoveGrammar,
+        EVASResetRemoveModelBank,
+        EVASResetCreateModelBank,
+        EVasWaitForCommitChanges
+	} iState;
+};
+
+
+#endif // NSSVASCCONTEXTSRSPORTAL_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvascrrd.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssRRD class encapsulated a RRD. It implements MNssRRD.
+*
+*/
+
+
+#ifndef NSSVASCRRD_H
+#define NSSVASCRRD_H
+
+//  INCLUDES
+#include "nssvasmrrd.h"
+#include "nssvascoreconstant.h"
+
+// CLASS DECLARATION
+
+/**
+*  CNssRRD encapsulates result recognition data. 
+*  It is the implementation class for MNssRRD. In addition to methods in MNssRRD, 
+*  it also provides methods for internal use by VAS components.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssRRD: public  CBase, public MNssRRD
+{
+public:
+
+    /**
+    * C++ destructor.
+    */
+	~CNssRRD();
+
+    /**
+    * 2 phase construction
+    */
+	static CNssRRD* NewL(); 
+
+    /**
+    * 2 phase construction
+    */
+	static CNssRRD* NewLC();
+
+    /**
+    * Set the tag id for this context
+	* @param aTagId tag id for the context
+    * @return 
+    */
+	void SetTagId(TInt aTagId);
+
+	 /**
+    * Get the tag id for this context
+    * @since 2.0
+    * @param 
+    * @return tag id
+    */  
+	TInt TagId();
+
+	/**
+    * Creates a deep copy of the RRD object and returns a pointer
+	* to the newly created RRD. A client calling calling
+	* this method takes the responsibility of deleting the new RRD object.
+	* For internal use by by VAS components.
+	* @since 2.0
+    * @param 
+    * @return pointer to newly created rrd
+    */
+	CNssRRD *CopyL();
+
+public: // from MNssRRD
+
+	/**
+    * Get the text array for this RRD
+	* @since 2.0
+    * @param 
+    * @return pointer to text array
+    */  
+	 CArrayFixFlat<NssRRDText>* TextArray();
+
+	/**
+    * Get the integer array this RRD
+	* @since 2.0
+    * @param 
+    * @return pointer to integer array
+    */  
+	 CArrayFixFlat<TInt>* IntArray();
+
+	/**
+    * Set the text array for this RRD
+	* @since 2.0
+    * @param pointer to text array
+    * @return 
+    */  
+	 void SetTextArrayL(CArrayFixFlat<NssRRDText>* aTextArray);
+
+	/**
+    * Set the integer array this RRD
+	* @since 2.0
+    * @param pointer to integer array
+    * @return 
+    */  
+	 void SetIntArrayL(CArrayFixFlat<TInt>* aIntArray);
+
+private:
+
+	/**
+    * C++ constructor.
+    */
+	CNssRRD();
+
+	/**
+    * EPOC constructor.
+    */
+	void ConstructL();
+
+private:
+
+	// text array
+	CArrayFixFlat<NssRRDText>* iTextArray;
+
+	// integer array
+	CArrayFixFlat<TInt>*	iIntArray;
+
+	// tag id, for internal use by VAS DB
+	TInt					iTagId; 
+};
+
+
+#endif // NSSVASCRRD_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvascspeechitem.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,634 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CSeechItem provides speech mechanism to request services from SRS.
+*
+*/
+
+
+#ifndef NSSVASCSPEECHITEM_H
+#define NSSVASCSPEECHITEM_H
+
+// INCLUDE FILES
+#include <nsssispeechrecognitiondatacommon.h>
+#include <nsssispeechrecognitionutilityobserver.h>
+#include <nssttscommon.h>
+
+#include "srsfbldvariant.hrh"
+#include "nssvascoreconstant.h"
+#include "nssvasmspeechitem.h"
+#include "nssvasmtrainvoiceeventhandler.h"
+#include "nssvasmtraintexteventhandler.h"
+#include "nssvasmplayeventhandler.h"
+#include "nssvasmcoresrsdbeventhandler.h"
+#include "nssvasmsavetagclient.h"
+#include "nssvasmdeletetagclient.h"
+#include "nssvasccontext.h"
+#include "nssvascspeechitemsrsportal.h"
+#include "nssvastspeechitemconstant.h"
+#include "nssvasttsutilitywrapper.h"
+
+// FORWARD DECLARATIONS
+class CNssSpeechItemTrainer;
+class CNssTag;
+
+/**
+* The CNssSpeechItem class provides a realization of the MNssSpeechItem client
+* interface. The CNssSpeechItem methods use the CSpeechRecognitionUtility Api 
+* to implement client speech requests.
+*
+* @lib nssvasapi.lib
+* @since 2.8
+*/
+class CNssSpeechItem : public CBase, 
+                       public MNssSpeechItem, 
+                       public MSISpeechRecognitionUtilityObserver,
+                       public MTtsClientUtilityObserver
+{
+
+  public:   // Constructors and destructor
+
+    /**
+    * Destructor.
+    */ 
+    ~CNssSpeechItem();
+
+    /**
+    * Two-phased CNssSpeechItem constructor
+    *
+    * @since 2.0
+    * @param aContext A reference to Context object
+    * @param aPortal A reference to SpeechItem Portal object
+    * @return a pointer to the new SpeechItem object
+    */   
+    static CNssSpeechItem* NewL( CNssContext& aContext, 
+                                 CNssSpeechItemSrsPortal& aPortal, 
+                                 CNssSpeechItemTrainer& aTrainer );
+
+
+    /**
+    * Two-phased CNssSpeechItem constructor
+    *
+    * @since 2.0
+    * @param aContext A reference to Context object
+    * @param aPortal A reference to SpeechItem Portal object
+    * @param aRuleID A rule ID value
+    * @param aText A reference to the TDesc text 
+    * @return a pointer to the new SpeechItem object
+    */   
+    static CNssSpeechItem* NewL( CNssContext& aContext,
+                                 CNssSpeechItemSrsPortal& aPortal,
+                                 CNssSpeechItemTrainer& aTrainer,
+                                 TUint32 aRuleID,
+                                 const TDesC& aText );
+
+    /**
+    * Two-phased CNssSpeechItem constructor
+    *
+    * @since 2.0
+    * @param aContext A reference to Context object
+    * @param aPortal A reference to SpeechItem Portal object
+    * @param aRuleID A rule ID value
+    * @param aText A reference to the TDesc text 
+    * @return a pointer to the new SpeechItem object
+    */   
+    static CNssSpeechItem* NewLC( CNssContext& aContext,
+                                  CNssSpeechItemSrsPortal& aPortal, 
+                                  CNssSpeechItemTrainer& aTrainer,
+                                  TUint32 aRuleID,
+                                  const TDesC& aText );
+
+
+  public: // New functions
+
+    /**
+    * Method to return the rule ID
+    *
+    * @since 2.0
+    * @param 
+    * @return the rule ID.
+    */   
+    TUint32 RuleID();
+
+    /**
+    * Method to set the rule ID
+    *
+    * @since 2.0
+    * @param aRuleID Rule ID 
+    */   
+    void SetRuleID( TUint32 aRuleID );
+
+    /**
+    * Method to set the Training Type
+    *
+    * @since 2.0
+    * @param aTrainType Training Type
+    */   
+    void SetTrainedType( TNssVasCoreConstant::TNssTrainedType aTrainType );
+
+	/**
+    * Create a copy of the SpeechItem object. 
+	* This cunction creates a new SpeechItem by allocating memory for
+	* a new SpeechItem, and deep copying the members of the SpeechItem 
+	* on which this fucntion is called. Old SpeechItem and new SpeechItem
+    * exist. Client need to deallocate memory for both.
+    *
+    * @param aContext a pointer to a Context
+    * @return pointer the newly created SpeechItem.
+    */
+	CNssSpeechItem* CopyL( CNssContext* aContext );
+
+
+
+  public: // Functions from base classes
+
+
+    /**
+    * Function inherited from MSISpeechRecognitionUtilityObserver to
+    * handle the events from SRS Utility object
+    *
+    * @since 2.0
+    * @param aEvent an event from the SRS utility object
+    * @param aResult the result from aEvent operation
+    */   
+    void MsruoEvent( TUid aEvent, TInt aResult );
+
+ 
+    /**
+    * The Record method is used by the client in the train voice sequence
+    * for SRS to record input speech.
+    *
+    * @since 2.0
+    * @param aTrainVoiceEventHandler a reference to TrainVoiceEventHandler
+    * @return a fail or success result from processing this method.
+    */   
+    TNssSpeechItemResult RecordL( MNssTrainVoiceEventHandler* aTrainVoiceEventHandler );
+
+
+    /**
+    * Method called by the client to indicate to SRS that a playback is
+    * needed.
+    *
+    * @since 2.0
+    * @param aPlayEventHandler a reference to PlayEventHandler
+    * @return a fail or success result from processing this method.
+    */   
+    TNssSpeechItemResult PlayL( MNssPlayEventHandler* aPlayEventHandler );
+
+    /**
+    * Method called by the client to indicate to SRS that a playback is
+    * needed with a certain language.
+    *
+    * @since 2.8
+    * @param aPlayEventHandler a call back object to handle the play events
+    * @param aLanguage language which will be used in playback
+    * @return TNssSpeechItemResult synchronous return value to identify whether the
+    *         synchronous process is success or fail
+    */    
+    TNssSpeechItemResult PlayL( MNssPlayEventHandler* aPlayEventHandler,
+                                TLanguage aLanguage );
+
+    /**
+    * Method called by the client to indicate to SRS that training is
+    * needed.
+    *
+    * @since 2.0
+    * @param aTrainVoiceEventHandler a reference to TrainVoiceEventHandler
+    * @return a fail or success result from processing this method.
+    */   
+    TNssSpeechItemResult TrainVoiceL(MNssTrainVoiceEventHandler* aTrainVoiceEventHandler);
+
+    /**
+    * Method called by the client to  cancel the previous operation.
+    *
+    * @since 2.0
+    * @return a fail or success result from processing this method.
+    */   
+    TNssSpeechItemResult CancelL();
+ 
+    /**
+    * The TrainingCapabilities member fucntion is used by the client 
+    * to get training capabilities to beused in Speaker Independent voice 
+    * recognition.
+    *
+    * @since 2.0
+    * @return a pointer to the Training Capability array object
+    */   
+    CArrayFixFlat<TNssVasCoreConstant::TNssTrainingCapability>* TrainingCapabilities();
+ 
+    /**
+    * Method to return the Training Type
+    *
+    * @since 2.0
+    * @return the Training Type
+    */   
+    TNssVasCoreConstant::TNssTrainedType TrainedType();
+
+    /**
+    * Method to return the Text
+    *
+    * @since 2.0
+    * @return the Text
+    */   
+    TDesC& Text();
+
+    /**
+    * Returns the raw training text from where escape characters are not removed.
+    * Should not be used by clients who want to display the string.
+    *
+    * @since 3.2
+    * @return Reference to the text buffer
+    */    
+    TDesC& RawText();
+    
+    /**
+    * Returns the part of text which identified with the given id.
+    * If RawText() is for example "_1Amy_1Harris_2mobile" then 
+    * PartialTextL( _L( "1" ) ) call will return "Amy Harris".
+    *
+    * @since 3.2
+    * @param aIdentifier ID of the text part to return
+    * @reuturn Text or KNullDesC if identifier is not found
+    */
+    HBufC* PartialTextL( const TDesC& aIdentifier );
+    
+    /**
+    * Method to set the training text
+    *
+    * @since 2.0
+    * @param aText Text which will be trained
+    * @return
+    */   
+    void SetTextL( const TDesC& aText );
+
+    /**
+    * Method to query playing support.
+    *
+    * @since 2.8
+    * @return TBool True if playing is supported.
+    */
+    TBool IsPlayingSupported();
+
+    /**
+    * Method to train a speech model from text.
+    *
+    * @since 2.8
+    * @param aEventHandler Event handler
+    * @param aTrainingParams Training options, NULL uses default ones.
+    * @return TNssSpeechItemResult Success status
+    */
+    TNssSpeechItemResult TrainTextL( MNssTrainTextEventHandler* aEventHandler,
+                                     CNssTrainingParameters* aTrainingParams );
+
+    /**
+    * Unused method for future extensions of MTtsClientUtilityObserver.
+    *
+    * @from MTtsClientUtilityObserver
+    * @since 2.8
+    * @param aEvent event ID
+    * @param aError result
+    */
+	void MapcCustomCommandEvent( TInt aEvent, TInt aError );
+
+    /**
+    * Method to signal that playing has been initialized.
+    *
+    * @from MTtsClientUtilityObserver
+    * @since 2.8
+    * @param aError Successful or not
+    * @param aDuration Length of the TTS waveform
+    */
+	void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration);
+
+    /**
+    * Method to signal that playing has been completed.
+    *
+    * @from MTtsClientUtilityObserver
+    * @since 2.8
+    * @param aError Successful or not
+    */
+	void MapcPlayComplete( TInt aError );
+
+  public: // New Functions 
+
+    /**
+    * Method to start transaction for saving the data into the SRS.
+    *
+    * @since 2.0
+    * @param aSaveTagClient Callback after we made it or died trying
+    * @param aTag Tag to be deleted
+    * @return a fail or success result from processing this method.
+    */   
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult 
+        NSSBeginSaveToSrs( MNssSaveTagClient* aSaveTagClient, CNssTag* aTag );
+
+    /**
+    * Method to start transaction for deleting tags from SRS and VAS DB.
+    *
+    * @since 2.0
+    * @param aDeleteTagClient Callback after we made it or died trying
+    * @param aTag Tag to be deleted
+    * @return a fail or success result from processing this method.
+    */   
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult 
+        NSSBeginDeleteFromSrs( MNssDeleteTagClient* aDeleteTagClient, CNssTag* aTag );
+
+    /**
+    * Method to commit the transaction to the SRS.
+    * This is a SYNCHRONOUS method.
+    * @since 2.0
+    * @return a fail or success result from processing this method.
+    */   
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult CommitSrsChanges();
+
+
+    /**
+    * Method to end the transaction without committing..
+    * This is a SYNCHRONOUS method.
+    * @since 2.8
+    * @return a fail or success result from processing this method.
+    */   
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult RollbackSrsChanges();
+
+    /**
+    * Method to set the Tag ID
+    * @since 2.0
+    * @param aTagId a Tag ID 
+    */   
+	void SetTagId( TInt aTagId );
+
+    /**
+    * Method to return the Tag ID
+    *
+    * @since 2.0
+    * @return the Tag ID.
+    */   
+    TInt TagId();
+
+    /**
+    * Method to return the Grammar ID from the context of the speech item.
+    *
+    * @since 2.8
+    * @return the Grammar ID.
+    */
+    TUint32 GrammarId();
+
+    /**
+    * Method to set the Trained flag for True or False
+    *
+    * @since 2.0
+    * @param aTrained Trained flag
+    */   
+	void SetTrained( TBool aTrained );
+
+    /**
+    * Method to return the Trained flag
+    *
+    * @since 2.0
+    * @return the Trained flag
+    */   
+    TBool Trained();
+
+    /**
+    * Updates the speech item after training.
+    *
+    * @since 2.8
+    * @param aRuleID Rule ID.
+    */
+    void DelayedTrainingComplete( TUint32 aRuleID );
+
+
+  private: //function
+
+    /**
+    * C++ constructor
+    *
+    * @param aContext reference to Context object
+    * @param aPortal reference to SpeechItem Portal object
+    * @param aTrainer reference to speech item trainer
+    */   
+    CNssSpeechItem( CNssContext& aContext, 
+                    CNssSpeechItemSrsPortal& aPortal, 
+                    CNssSpeechItemTrainer& aTrainer );
+
+    /**
+    * Symbian 2nd phase constructor 
+    *
+    * @param aRuleID Rule ID value
+    * @param aText Reference to the TDesc text 
+    */   
+    void ConstructL( TUint32 aRuleID, const TDesC& aText );
+
+    /**
+    * Method to copy utterance data from current to transient values
+    */   
+    void CopyUtteranceData();
+
+    /**
+    * Method to handle the "GetUtteranceDurationEvent" complete from SRS
+    */   
+    void DoGetUtteranceDurationCompleteEvent();
+
+    /**
+    * Method to handle the "PlayEvent" complete from SRS
+    */   
+    void DoPlayCompleteEvent();
+
+    /**
+    * Method to handle the "PlayEvent" fail from SRS
+    *
+    * @param aResult - a Result value from the Play operation
+    */   
+    void DoPlayFailEvent( TInt aResult );
+
+    /**
+    * Method to process the SRS play error 
+    *
+    * @param aResult the result value from SRS which indicates an error
+    * @return a converted error code to identify the VAS play error
+    */   
+    MNssPlayEventHandler::TNssPlayResult DoPlayResult( TInt aResult );
+    
+    /**
+    * Method to handle the "GetAvailableStorageEvent" complete from SRS
+    */   
+    void DoGetAvailableStorageCompleteEvent();
+
+    /**
+    * Method to handle the "TrainEvent" complete from SRS
+    */   
+    void DoTrainCompleteEvent();
+
+    /**
+    * Method to process the various train failed events from SRS'
+    *
+    * @param aResult the result value to indicate an error
+    */   
+    void DoTrainFailEvent( TInt aResult );
+
+    /**
+    * Method to process the SRS train error
+    *
+    * @param aResult the result value from SRS which indicates an error
+    * @return a converted error code to identify the VAS train error
+    */   
+    MNssTrainVoiceEventHandler::TNssTrainResult DoTrainResult( TInt aResult );
+    
+    /**
+    * Method to handle the "AddPronunciation" complete from SRS
+    */   
+    void DoAddPronunciationCompleteEvent();
+
+    /**
+    * Method to handle the "AddPronunciation" fail from SRS
+    *
+    * @param aResult a Result value from the event
+    */   
+    void DoAddPronounciationFailEvent( TInt aResult );
+    
+    /**
+    * Method to handle the "RemoveModel" complete from SRS
+    */   
+    void DoRemoveModelCompleteEvent();
+
+    /**
+    * Method to handle the "RemoveModel" fail from SRS
+    *
+    * @param aResult a Result value from the event
+    */   
+    void DoRemoveModelFailEvent( TInt aResult );
+
+    /**
+    * Method to process the SRS DB error 
+    *
+    * @param aResult the result value from SRS to indicate an error
+    * @return an error code to identify the DB error
+    */   
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult DoSrsDBResult( TInt aResult );
+
+    /**
+    * Method to notify the event handler for receiving the Unexpected Event
+    */  
+    void NotifyHandlerForUnexpectedEvent();
+
+    /**
+    * Method to do clean up
+    */   
+    void CleanUp();
+    
+    /**
+    * Method to verify whether it is ok to retry
+    *
+    * @return ETrue is ok to retry, EFalse stops retry 
+    */   
+    TBool DoRetry();
+ 
+    /**
+    * This method starts playback with CTtsUtility.
+    */
+    void DoPlayL();
+
+    /**
+    * This method releases resources, which were reserved for playing,
+    * and updated the state from PlayingStrated to Idle.
+    */
+    void CleanPlayback();
+
+    /**
+    * Makes the callback after playing has completed or failed.
+    *
+    * @param Symbian standard error code
+    */
+    void MakePlayCallback( TInt aResult );
+
+  private: //data
+
+    // The rule ID.
+    TUint32 iRuleID;
+
+    // The transient rule ID.
+    TUint32 iTransientRuleID;
+
+    // The text data.
+    HBufC* iText;
+
+    // The trained type.
+    TNssVasCoreConstant::TNssTrainedType iTrainedType;
+
+    // Need to keep track the training state.
+    TNssSpeechItemConstant::TNssState iState;
+    TNssSpeechItemConstant::TNssState iOldState;
+
+    // Reference to Context object
+    CNssContext& iContext;
+
+    // Reference to SRS Portal object.
+    CNssSpeechItemSrsPortal& iPortal;
+
+    // Reference to SRS Trainer object. Used for delayed text training.
+    CNssSpeechItemTrainer& iTrainer;
+
+    // Pointer to Play Event Handler object.
+    MNssPlayEventHandler* iPlayEventHandler; 
+
+    // Pointer to Train Event Handler object
+	MNssTrainVoiceEventHandler* iTrainVoiceEventHandler;
+
+    // The Tag ID for internal use by Vas Database,
+	TInt iTagId; 
+
+    // The Trained flag for re-training operation
+    TBool iTrained;
+
+    // The duration for the play utterance
+    TTimeIntervalMicroSeconds32 iPlayDuration;
+
+    // The flag to identify recovery is in progress
+    TBool iRecover;
+
+    // Retry counter
+    TInt iRetry;
+
+    // Memory is allocated for TTS data only when plaing the tag.
+    // This is because CNssSpeechItem may have thousands of copies.
+    struct TTtsData
+        {
+        // TTS speech style
+        TTtsStyle iStyle;
+
+        // TTS speech style handle
+        TTtsStyleID iStyleID;
+
+        // TTS speech segment
+        TTtsSegment iSegment;
+
+        // TTS player
+        CNssTtsUtilityWrapper* iTts;
+
+        // Parsed text
+        CTtsParsedText* iParsedText;
+
+        // Initializes everyting to zero.
+        TTtsData();
+        };
+
+    // TTS Data
+    TTtsData* iTtsData;
+    
+    // Cleaned text data where escape characters have been removed
+    HBufC* iTrimmedText;
+};
+
+#endif // NSSVASCSPEECHITEM_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvascspeechitembuilder.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSpeechItemBuilder provides methods to create SpeechItem object.
+*
+*/
+
+
+#ifndef NSSVASCSPEECHITEMBUILDER_H
+#define NSSVASCSPEECHITEMBUILDER_H
+
+#include "nssvasccontext.h"
+#include "nssvascspeechitem.h"
+#include "nssvascspeechitemtrainer.h"
+#include "nssvasmcoresyncrecoveryhandler.h"
+
+// FORWARD DECLARATIONS
+class CNssVASDatabase;
+
+/**
+* The CNssSpeechItemBuilder class builds SpeechItem instances when requested.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssSpeechItemBuilder : public CBase
+{
+  public:
+
+    /**
+    * Destructor.
+    * The CNssSpeechItemBuilder destructor
+    * Destroys the speech item builder. In addition, this must set the
+    * state of the speech item portal termination state to termination pending.
+    */   
+    ~CNssSpeechItemBuilder();
+
+    /**
+    * Creates SpeechItemBuilder.  In addition, this must also create the
+    * Speech Item Portal and Speech Item Trainer.
+    * @since 2.0
+    * @param aDatabase - interface to database
+    * @return 
+    */       
+    static CNssSpeechItemBuilder* NewL( CNssVASDatabase* aDatabase );
+
+    /**
+    * 2 phase construction
+    * @since 2.0
+    * @param aDatabase - interface to database
+    * @return 
+    */      
+    static CNssSpeechItemBuilder* NewLC( CNssVASDatabase* aDatabase );
+    
+    /**
+    * Create SpeechItem object given a Context
+    * @since 2.0
+    * @param aContext - reference of Contaxt object  
+    * @return *CNssSpeechItem - a pointer to a SpeechItem object
+    */      
+    CNssSpeechItem* CreateEmptySpeechItemL(CNssContext& aContext);
+
+    /**
+    * Create SpeechItem object given most of its data members.
+    * @since 2.0
+    * @param aContext - reference of Contaxt object  
+    * @param aText - a text description
+    * @param aTagID - a TagID 
+    * @return *CNssSpeechItem - a pointer to a SpeechItem object
+    */   
+    CNssSpeechItem* CreateSpeechItemL(CNssContext& aContext,
+        TUint32 aRuleID,const TDesC& aText, TInt aTagID,
+        TNssVasCoreConstant::TNssTrainedType aTrainedType );
+
+
+  private: //function
+
+
+   /**
+    * C++ constructor
+    */ 
+    CNssSpeechItemBuilder();
+
+
+    /**
+    * Symbian 2nd phase constructor 
+    */      
+    void ConstructL( CNssVASDatabase* aDatabase );
+
+
+  private: //data
+
+    // Pointer to SRS Portal object.
+    // The SpeechItemBuilder own the SpeechItemPortal
+    CNssSpeechItemSrsPortal* iPortal; 
+    CNssSpeechItemTrainer*  iTrainer;
+};
+
+
+
+#endif // NSSVASCSPEECHITEMBUILDER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvascspeechitemsrsportal.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The VasCSpeechItemSrsPortal provides the portal to the 
+*               SpeechRecognitionUtility object.
+*
+*/
+
+
+
+#ifndef NSSVASCSPEECHITEMSRSPORTAL_H
+#define NSSVASCSPEECHITEMSRSPORTAL_H
+
+#include <nsssispeechrecognitionutilityobserver.h>
+#include "nssvassiutilitywrapper.h"
+
+#include "nssvascoreconstant.h" 
+#include "nssvastspeechitemconstant.h"     
+
+
+/**
+* This class handles accessing the SpeechRecognitionUtility services. 
+* It allows only one transaction for each SpeechItem object to be in 
+* progress at any given time. 
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssSpeechItemSrsPortal:public CBase
+{
+  public:
+        
+    /**
+    * Destructor.
+    */
+    ~CNssSpeechItemSrsPortal();
+
+    /**
+    * Creates CNssSpeechItemSrsPortal.
+    * Get the SpeechRecognitionUtility's engine status ?????
+    * @since 2.0
+    * @param 
+    * @return 
+    */      
+    static CNssSpeechItemSrsPortal* NewL();
+
+    /**
+    * Creates CNssSpeechItemSrsPortal.
+    * 2 phase construction
+    * @since 2.0
+    * @param 
+    * @return 
+    */      
+    static CNssSpeechItemSrsPortal* NewLC();
+ 
+    /**
+    * Requests that the value of the state be changed to Termination state. 
+    * If the counter is zero, the SpeechItemPortal will delete itself.
+    * @since 2.0
+    * @param 
+    * @return 
+    */ 
+    void SetTerminationState();
+
+    /**
+    * Get training capabilities from SpeechRecognitionUtility object.
+    * @since 2.0
+    * @param 
+    * @return 
+    */      
+    CArrayFixFlat<TNssVasCoreConstant::TNssTrainingCapability>* 
+        GetTrainingCapability();
+
+    /**
+    * Increment the counter to count the number of created SpeechItem objects.
+    * @since 2.0
+    * @param 
+    * @return 
+    */      
+    void Register();
+
+    /**
+    * Decrement the counter when SpeechItem objects is destroy.
+    * If the counter is zero and the state is in termination state, 
+    * the portal will destroy the SpeechRecognitionUtility object if exist, 
+    * and it destroys itself.
+    * @since 2.0
+    * @param 
+    * @return 
+    */      
+    void Deregister();
+
+
+
+	/**
+    * overloaded assignment operator
+    * @param 
+    * @return reference to the CNssSpeechItemSrsPortal
+    */
+    CNssSpeechItemSrsPortal& 
+        operator=(const CNssSpeechItemSrsPortal& aCNssSpeechItemSrsPortal);
+
+
+    /**
+    * Return the status of whether the Engine Property Set flag
+    * @param 
+    * @return the status of Engine Property Set flag
+    */
+    TBool IsEnginePropertySet();
+
+    /**
+    * Return the Maximum Loadable Models from the SRS 
+    * @param - the Model Storage capacity
+    * @param - the Maximum Loadable Models
+    * @return 
+    */
+    void SetEngineProperty(TInt aModelStorageCapacity, TInt aMaxLoadableModels);
+
+    /**
+    * Return the Model Storage Capacity from the SRS
+    * @param 
+    * @return the Model Storage capacity
+    */
+    TInt ModelStorageCapacity();
+
+    /**
+    * Return the Maximum Loadable Models from the SRS 
+    * @param 
+    * @return the Maximum Loadable Models
+    */
+    TInt MaxLoadableModels();
+
+
+
+
+  private: //function
+
+
+    /**
+    * C++ constructor.
+    */   
+    CNssSpeechItemSrsPortal();
+
+
+  
+  private: //data
+
+
+    // The Portal's state
+    TNssSpeechItemConstant::TNssState iState;
+
+    // Counter to count the total of registered SpeechItem objects 
+    TInt iSpeechItemCounter; 
+
+    // The SRS's Engine Property has been set flag
+    TBool iEnginePropertySet;
+    
+    // The SRS's ModelStorageCapacity 
+    TInt iModelStorageCapacity;
+
+    // The SRS's MaxLoadableModels  
+    TInt iMaxLoadableModels;
+
+
+};
+
+#endif // NSSVASCSPEECHITEMSRSPORTAL_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvascspeechitemtrainer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,500 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSpeechItemTrainer trains SpeechItem objects and later
+*               saves them to the database. Both in training and saving,
+*               SpeechItemTrainrt allows grouping several requests together
+*               and executing them in one run. This is crucial if we want
+*               training and saving to scale up.
+*
+*/
+
+
+
+#ifndef NSSVASCSPEECHITEMTRAINER_H
+#define NSSVASCSPEECHITEMTRAINER_H
+
+#include "nssvasccontext.h"
+#include "nssvascspeechitem.h"
+
+#include "nssvasmcoresyncrecoveryhandler.h"
+#include "nsssispeechrecognitionutilityobserver.h"
+#include "nssvasctrainingactiontracker.h"
+
+#include <badesca.h>
+
+// FORWARD DECLARATIONS
+class CNssSpeechItem;
+class MNssSaveTagClient;
+class MNssDeleteTagClient;
+class CNssVASDatabase;
+
+
+typedef enum
+    {
+    EStateIdle,
+    ETrainStateWaiting,
+
+    // Training states
+    ETrainStateSaveContext,
+    ETrainStateTraining,
+
+    // Saving states
+    ESaveStateWaiting,
+    ESaveStateSaving,
+
+    // Deleting states
+    EDeleteStateWaiting,
+    EDeleteStateDeleting,
+
+    // Retraining states
+    ERetrainStateWaiting,
+    ERetrainStateRetraining
+
+    } TTrainState;
+
+/**
+* The CNssSpeechItemTrainer class builds SpeechItem instances when requested.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssSpeechItemTrainer
+: public CBase,
+  public MSISpeechRecognitionUtilityObserver,
+  private MDelayedNotifiable
+{
+    public:
+
+    /**
+    * Destructor.
+    * The CNssSpeechItemTrainer destructor
+    * Destroys the speech item trainer.
+    */   
+    ~CNssSpeechItemTrainer();
+
+    /**
+    * Creates CNssSpeechItemTrainer.
+    * @since 2.8
+    * @param aDatabase VAS database object
+    * @return Speech item trainer
+    */       
+    static CNssSpeechItemTrainer* NewL( CNssVASDatabase* aDatabase );
+
+    /**
+    * Creates CNssSpeechItemTrainer. Pushes it to the cleanup stack.
+    * @since 2.8
+    * @param aDatabase VAS database object
+    * @return Speech item trainer
+    */       
+    static CNssSpeechItemTrainer* NewLC( CNssVASDatabase* aDatabase );
+    
+    /**
+    * Adds a names to the queue of names to be trained. These names are
+    * actually trained after a delay. Calling this function resets
+    * the delay timer.
+    * @since 2.8
+    * @param aEventHandler Callback after the names have been trained
+    * @param aTrainingParams Parameters for training
+    * @param aSpeechItem Speech item to be trained
+    * @param aContext Context, to which the speech item belongs.
+    * @return Success status
+    */       
+    MNssSpeechItem::TNssSpeechItemResult TrainTextDelayed(
+        MNssTrainTextEventHandler* aEventHandler,
+	    CNssTrainingParameters*    aTrainingParams,
+        CNssSpeechItem& aSpeechItem,
+        CNssContext& aContext
+        );
+
+    /**
+    * Adds a names to the queue of names to be trained. These names are
+    * actually trained after a delay. Calling this function resets
+    * the delay timer.
+    * @since 2.8
+    * @param aEventHandler Callback after the names have been trained
+    * @param aTrainingParams Parameters for training
+    * @param aSpeechItem Speech item to be trained
+    * @param aContext Context, to which the speech item belongs.
+    * @return Success status
+    */       
+    MNssSpeechItem::TNssSpeechItemResult RetrainTextDelayed(
+        MNssTrainTextEventHandler* aEventHandler,
+	    CNssTrainingParameters*    aTrainingParams,
+        CNssSpeechItem& aSpeechItem,
+        CNssContext& aContext
+        );
+
+    /**
+    * Queue a tag for saving.
+    * @since 2.8
+    * @param aSaveTagClient callback to call after saving / failing to save.
+    * @param aTag           tag to be saved
+    * @return Symbian-wide error codes
+    */
+    TInt SaveTagDelayed(
+        MNssSaveTagClient* aSaveTagClient,
+        CNssTag& aTag
+        );
+
+    /*
+    * Saves the tags, which the client has piled up
+    * by calling SaveTagDelayed() repeatedly
+    * @since 2.8
+    */
+    void DoSaveTags();
+
+    /**
+    * Queue a tag for removal.
+    * @param aDeleteTagClient callback to call after deleting / failing to delete.
+    * @param aTag           tag to be removed
+    * @return Symbian-wide error codes
+    */
+    TInt DeleteTagDelayed(
+        MNssDeleteTagClient* aDeleteTagClient,
+        CNssTag& aTag
+        );
+
+    /*
+    * Deprecated, to be removed, when no usage for this method is confirmed
+    * This method is substituted with DoDeleteGroupedTags
+    *
+    * Deletes the tags, which the client has piled up
+    * by calling DeleteTagDelayed() repeatedly
+    * @since 2.8
+    */
+    void DoDeleteTags();
+    
+    /*
+    * Deletes the tags, which the client has piled up
+    * by calling DeleteTagDelayed() repeatedly
+    * @since 2.8
+    */
+    void DoDeleteGroupedTags();
+
+    /*
+    * Sends the next RemoveRule call to SRS
+    * @since 2.8
+    */
+    void DeleteNextTag();
+
+    /*
+    * Handles successful KAsrEventRemoveRule event after RemoveRule call to SRS.
+    *
+    * Can be obsolete method.
+    * @todo Check if it used in retraining tags. If not, remove it
+    *
+    * @since 2.8
+    */
+    void HandleRemoveTagComplete();
+    
+    /*
+    * Handles successful KAsrEventRemoveRules event after RemoveRule call to SRS.
+    * @since 2.8
+    */
+    void HandleRemoveTagsComplete();
+
+    /*
+    * Handles failed KAsrEventRemoveRule event after RemoveRule call to SRS.
+    * @since 2.8
+    * @param aError Symbian-wide error code
+    */
+    void HandleRemoveTagFailed( TInt aError );
+
+    /*
+    * Removes tags from VAS and commits SRS removals if successful.
+    * @since 2.8
+    */
+    void RemoveTagsFromVAS();
+
+    /*
+    * Sends callbacks related to deleting tags. Also works as an error handler.
+    * @since 2.8
+    */
+    void FinishDeleteTags( TInt aSuccess );
+
+    // Functions from base classes
+
+    /*
+    * This function is called after the action tracker decides that it is the time for
+    * executing the buffered actions
+    * @from MDelayedNotifiable
+    */
+    void RunBufferedActionsL();
+
+    /*
+    * Starts the timer if it isn't running, and resets the time if it is running.
+    * @since 2.8
+    */
+    void RestartTimer();
+
+    /*
+    * Trains names after timeout has happened.
+    * @since 2.8
+    */
+    void DoTrainTextDelayed();
+
+    /*
+    * Checks whether training parameters are equal to previous ones.
+    * In queued training, all names must have the same training parameters.
+    * @since 2.8
+    * @param aParams Training parameters
+    * @return ETrue, if the training parameters are the same as with other tags.
+    */
+    TBool CheckTrainingParametersL( const CNssTrainingParameters *aParams );
+
+    /*
+    * Checks whether the context is equal to the previous one.
+    * In queued training, all names must belong to the same context.
+    * @since 2.8
+    * @param aContext Context of the tag
+    * @return ETrue, if the context is the same as for the other tags.
+    */
+    TBool CheckContext(CNssContext& aContext);
+
+    /*
+    * Cleans up, if an error happens during training.
+    * @since 2.8
+    * @param anItemArray Array of speech items
+    */
+    void HandleTrainError( RPointerArray<CNssSpeechItem>*& anItemArray );
+
+    /*
+    * Splits a descriptor into an array of descriptors.
+    * @since 2.8
+    * @param aPhrase Phrase to be split.
+    * @param aSeparator Separator character between the parts of the string.
+    * @return Array, where the descriptor has been split.
+    */
+    CDesC16ArrayFlat* SplitPhraseL( const TDesC& aPhrase, TChar aSeparator );
+
+    /*
+    * Callback to mediate speech recognition events
+    * @since 2.8
+    * @from MSpeechRecognitionUtilityObserver
+    * @param aEvent ID of the speech event
+    * @param aResult Success status
+    */
+    virtual void MsruoEvent( TUid aEvent, TInt aResult );
+
+    /*
+    * Cleans memory allocated for training.
+    * @since 2.8
+    */
+    void CleanUpTraining();
+
+    /*
+    * Called when training is complete.
+    * @since 2.8
+    * @param aResult Success status
+    */
+    void HandleTrainComplete( TInt aResult );
+
+    /*
+    * Called when lexicon has been created.
+    * @since 2.8
+    * @param aError Success status
+    */
+    void HandleLexiconCreated( TInt aError );
+
+    /*
+    * Called when grammar has been created.
+    * @since 2.8
+    * @param aError Success status
+    */
+    void HandleGrammarCreated( TInt aError );
+
+    /**
+    * Initializes iSrsApi or returns an error.
+    * @since 2.8
+    * @return KErrNone or some symbian-wide error code.
+    */
+    TInt CreateSrsApi();
+
+    /*
+    * Commits training to SRS database..
+    * @since 2.8
+    * @return success status
+    */
+    TInt CommitSIUpdate();
+
+    /*
+    * Commits training to SRS database..
+    * @since 2.8
+    * @return success status
+    */
+    TInt UncommitSIUpdate();
+
+    /*
+    * Trys to allocate a speech item buffer
+    * @since 2.8
+    * @retutn ETrue if success, EFalse if failure
+    */
+    TBool SpeechItemBufferNeeded();
+
+    /*
+    * Trys to allocate a grammar id buffer
+    * @since 2.8
+    * @retutn ETrue if success, EFalse if failure
+    */
+    TBool GrammarIdBufferNeeded();
+
+    /*
+    * Phase 1 of retraining: Removes old rules
+    * @since 2.8
+    */
+    void DoRetrainTextDelayed();
+
+    /*
+    * Phase 2 of retraining: Adds new rules
+    * @since 2.8
+    */
+    void DoRetrainAddVoiceTags();
+
+    /*
+    * Phase 3 of retraining: Updates VAS DB and makes the callbacks.
+    * @since 2.8
+    * @param aResult Success status of the AddVoiceTags call
+    */
+    void HandleRetrainComplete( TInt aResult );
+
+    /*
+    * Converts an array of Speech Items to a format,
+    * where they can be sent to Utility for training.
+    * @since 2.8
+    * @param aSpeechItems List of speech items
+    * @param aPhrases Storage array for splitted phrases
+    * @return Success status
+    */
+    TInt SpeechItems2Phrases(
+        RPointerArray<CNssSpeechItem>& aSpeechItems,
+        RPointerArray<MDesCArray>& aPhrases );
+
+    /**
+    * Cleans up training/retraining and sends the callbacks to the client.
+    * @since 2.8
+    * @param aResult Was training successful or not.
+    */
+    void SendTrainingCallbacks( TInt aResult );
+
+    /**
+    * Cleanup/error handler function for Delayed Remove operation.
+    * @since 2.8
+    * @param aSuccess Success status of remove tags
+    */
+    void RemoveTagsFinished( TInt aSuccess );
+
+  private: //function
+
+
+   /**
+    * C++ constructor
+    */ 
+    CNssSpeechItemTrainer( CNssVASDatabase* aDatabase );
+
+
+    /**
+    * Symbian 2nd phase constructor 
+    */      
+    void ConstructL();
+    
+    /**
+    * Set the train state.
+    * This is the place to check any state-related invariants and/or
+    * print state switching related info in UDEB
+    */
+    void SetState(TTrainState aState);
+
+    /*
+    * Splits a descriptor into an array of descriptors.
+    * @since 3.1
+    * @param aPhrase Phrase to be split. (for example "_1Adam_1Russell_2mobile")
+    * @param aSeparator Separator character between the parts of the string.
+    * @return Array, where the descriptor has been split.
+    */
+    CDesC16ArrayFlat* SplitPhraseSindeL( const TDesC& aPhrase, TChar aSeparator );
+
+  private: //data
+
+    // Pointer to SRS Portal object.
+    // The SpeechItemTrainer own the SpeechItemPortal
+    CNssVASDatabase* iDatabase;
+
+    // Buffer for grouping the MNssSpeechItems for efficient training.
+    RPointerArray<CNssSpeechItem>* iSpeechItemBuffer;
+
+    // Names, which are being trained by CSpeechRecognitionUtility.
+    RPointerArray<CNssSpeechItem>* iSpeechItemTrainingBuffer;
+
+    // Stores grammar IDs, so we don't need to store the whole tag when deleting.
+    RArray<TUint32>* iGrammarIdBuffer;
+
+    // The grammar IDs for speech items, which we are currently deleting.
+    RArray<TUint32>* iGrammarIdDeletingBuffer;
+
+    // This buffer is sent to SRS Utility. Contains: The recognition phrase split into subwords.
+    RPointerArray<MDesCArray> iPhraseArray;
+
+    // State: Idle, waiting or training.
+    TTrainState iState;
+
+    // Training parameters
+    CNssTrainingParameters* iTrainingParams;
+
+    // Context
+    CNssContext* iContext;
+
+    // Rule ID array. Return values from AddVoiceTags() are placed here.
+    RArray<TUint32>* iRuleIDArray;
+    
+    // Rule ID array. Rule IDs for tags scheduled for deletion are placed here
+    RArray<TUint32>* iDeleteRuleIDArray;
+
+    // Handle to speech services
+    CNssSiUtilityWrapper *iSrsApi;
+
+    MNssTrainTextEventHandler *iTrainEventHandler;
+
+    // Lexicon ID for training
+    TUint32 iLexiconId;
+
+    // Grammar ID for training
+    TUint32 iGrammarId;
+
+    /*************** Saving variables ****************/
+    // The tags to be saved
+    RPointerArray<CNssTag> *iTagBuffer;
+
+    // Callback function after saving
+    MNssSaveTagClient* iSaveEventHandler;
+
+    /*************** Deleting variables **************/
+    // Tags, which are currently being deleted
+    RPointerArray<CNssTag> *iTagDeleteBuffer;
+
+    // Callback function after removal
+    MNssDeleteTagClient* iDeleteEventHandler;
+
+    // Counter for asynchronous delete calls
+    TInt iTagDeleteCounter;
+    
+    // decides when to execute the buffered (delayed) actions
+    CNssTrainingActionTracker* iActionTracker;
+
+};
+
+
+
+#endif // NSSVASCSPEECHITEMTRAINER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasctag.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,159 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssTag implements MNssTag. In addition, it provides members for use
+*               by VAS internal components.
+*
+*/
+
+
+#ifndef NSSVASCTAG_H
+#define NSSVASCTAG_H
+
+// includes
+#include "nssvasmtag.h"
+#include "nssvasccontext.h"
+#include "nssvascrrd.h"
+#include "nssvascspeechitem.h"
+#include "nssvascoreconstant.h"
+
+// CLASS DECLARATION
+
+/**
+*  CNssTag is the implementation class for MNssTag interface. 
+*  It encapsulates tag data. A tag cannot be directly created by a client. 
+*  A client has to own an instance of Tag Manager which has methods for creating 
+*  tag objects. The CNssTag class also provides additional members for internal 
+*  use by VAS.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssTag: public CBase, public MNssTag
+{
+
+public: // functions for internal VAS use
+	
+    /**
+    * Two-phased constructor. Creates an empty tag object
+    * for internal use.
+    */
+    static CNssTag* NewLC();
+    
+    /**
+    * Two-phased constructor. Creates an empty tag object
+    * for internal use.
+    */
+    static CNssTag* NewL();
+
+public:   
+
+    /**
+    * C++ constructor.
+	* @param aContext - pointer to a previously created context
+	* @param aRRD - pointer to a previously created rrd
+	* @param aSpeechItem - pointer to a previously created speech item
+    * @return 
+    */
+	CNssTag(CNssContext* aContext, CNssRRD* aRRD, CNssSpeechItem* aSpeechItem);
+
+    /**
+    * Destructor.
+	* @param 
+    * @return 
+    */
+	 ~CNssTag();
+
+    /**
+    * Get the context for this tag.
+	* @since 2.0
+	* @param 
+    * @return pointer to the context for this tag
+    */
+     MNssContext* Context();
+
+    /**
+    * Get the RRD for this tag.
+	* @since 2.0
+	* @param 
+    * @return pointer to the RRD for this tag
+    */
+	 MNssRRD* RRD();
+
+    /**
+    * Get the Speech Item for this tag.
+	* @since 2.0
+	* @param 
+    * @return pointer to the RRD for this tag
+    */
+	 MNssSpeechItem* SpeechItem();
+
+	/**
+    * Get the Tag Id for this tag.
+	* @since 2.0
+	* @param 
+    * @return id for this tag
+    */
+	 TInt TagId();
+
+	/**
+    * Set the Tag Id for this tag.
+	* @since 2.0
+	* @param aId - id for this tag
+    * @return 
+    */
+	 void SetTagId(TInt aId);
+
+	/**
+    * Creates a copy of the tag object and returns a pointer
+	* to the newly created tag. CopyL creates a new rrd object and 
+	* a new speech item for the new tag. CopyL uses the same context 
+	* object from the source tag into the new tag. A client calling calling
+	* this method takes the responsibility of deleting the new tag object.
+	* For internal use by by VAS components.
+	* @since 2.0
+	* @param 
+    * @return pointer to the tag object newly created 
+    */
+	 CNssTag *CopyL();
+	 
+private:
+    /**
+    * Constructor used in two-phased construction
+    */
+    CNssTag();
+    
+    /**
+    * Two-phase construction
+    */
+	void ConstructL();
+
+private:
+
+	// context object
+	CNssContext* iContext;
+	
+	// RRD object
+	CNssRRD* iRRD;
+
+	// speech item object
+	CNssSpeechItem* iSpeechItem;
+
+	// tag id, for internal use
+	TInt iTagId;
+
+};
+
+#endif // NSSVASCTAG_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasctagreference.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssTagMgr implements the MNssTagMgr interface. In addition, it 
+*               also provides methods for internal use by VAS components.
+*
+*/
+
+
+#ifndef NSSVASCTAGREFERENCE_H
+#define NSSVASCTAGREFERENCE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include "nssvasmtagreference.h"
+
+// CLASS DECLARATIONS
+/**
+*  CNssTagReference is a tag object, which only contains the name and the ID.
+*  What has been dropped is RRD data and data required for speech actions.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssTagReference: public CBase, public MNssTagReference
+{
+public:
+   CNssTagReference();
+
+   ~CNssTagReference();
+
+   TDesC& TagName();
+   void   SetTagNameL(const TDesC& aTagName);
+   TInt   TagId();
+   void   SetTagId(TInt aTagId);
+   
+private:
+   HBufC* iTagName;
+   TInt   iTagId;
+};
+
+#endif // NSSVASCTAGREFERENCE_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasctrainingactiontracker.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implements the buffer timeout logic specific to the speech item 
+*               trainer. Is notified about the speech item trainer action requests,
+*               and decides when to actually fire the buffered actions
+*
+*/
+
+
+#ifndef NSSVASCTRAININGACTIONTRACKER_H
+#define NSSVASCTRAININGACTIONTRACKER_H
+
+#include <e32base.h>
+
+/**
+ * An interface for the objects to be notifiable by the CNssTrainingActionTracker
+ */
+class MDelayedNotifiable
+    {
+    public:
+        virtual void RunBufferedActionsL() = 0;
+    };
+
+/**
+ * Implements the buffer timeout logic specific to the speech item 
+ * trainer. Is notified about the speech item trainer action requests,
+ * and decides when to actually fire the buffered actions
+ */
+NONSHARABLE_CLASS( CNssTrainingActionTracker ) : public CTimer
+    {
+    public:
+        static CNssTrainingActionTracker* NewL( MDelayedNotifiable& aNotifiable );
+        
+        /**
+         * Is called by the client to notify tracker about the request to
+         * perform a potentially bufferable action. It is up to tracker
+         * when to stop recording the action requests and fire the 
+         * delayed actions via MDelayedNotifiable::DoBufferedActionsL
+         * 
+         * DoBufferedActionsL is always called asynchronously. Even if tracker
+         * decides to fire the delayable actions immediately
+         */
+        void ActionRequestedL();
+        
+        ~CNssTrainingActionTracker();
+    
+    protected:
+        
+        // Fired when timer is expired
+        void RunL();
+    
+    private:
+        CNssTrainingActionTracker( MDelayedNotifiable& aNotifiable );
+    
+        void ConstructL();
+        
+        /**
+         * static callback required by CAsyncCallBack* iAsyncCallback
+         * @param pX A pointer to this object
+         */        
+        static TInt FireActionsImmediately( TAny* pX );
+        
+        /**
+         * Call back the host
+         */
+        void DoFireActionsL();
+        
+        /**
+         * Another action requested. Start waiting [again]
+         */
+        void RestartTimer();
+        
+    private:
+        // Observer
+        MDelayedNotifiable& iHost;
+        
+        // Utility for firing the action immediately, but asynchronously
+        CAsyncCallBack* iAsyncCallback;
+        
+        // ETrue when tracker has some actions to fire in the queue
+        TBool iUnfiredActions;
+    };
+
+#endif // NSSVASCTRAININGACTIONTRACKER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvassiutilitywrapper.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,335 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef NSSVASSIUTILITYWRAPPER_H
+#define NSSVASSIUTILITYWRAPPER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitionutilityobserver.h>
+#include <nsssiutilitybase.h>
+
+// CLASS DECLARATION
+
+/**
+* CNssSiUtilityWrapper
+* @since 3.1
+* @see nsssispeechrecognitionutility.h
+* @see nsssispeechrecognitionutilityobserver.h
+* @see nsssiutilitybase.h
+*/
+NONSHARABLE_CLASS ( CNssSiUtilityWrapper ) : public CActive, 
+                                             public MSISpeechRecognitionUtilityObserver
+    {
+    public: // Constructors & destructor
+     
+        /**
+        * Two-phased constructor
+        * 
+        * @since 3.1
+        */
+        static CNssSiUtilityWrapper* NewL( MSISpeechRecognitionUtilityObserver& aObserver,
+                                           TUid aClientUid );
+
+        /**
+        * Destructor.
+        */
+	    virtual ~CNssSiUtilityWrapper();
+
+    public: // New functions
+    
+        /**
+        *
+        *    Adapts the speaker independent models to a specific speaker's voice.
+        *
+        * @since  2.8
+        * @param  aResultSet     Recognition result N-Best
+        * @param  aCorrect       Index to N-Best pointing the correct result.
+        * @return system wide error code
+        */
+        TInt Adapt( const CSIClientResultSet& aResultSet,
+                             TInt aCorrect );    
+    
+        /**
+        * Adds a new rules for the given phrases into the 
+        * specified grammar.
+        *
+        * @param    aTextArrayArray     Array of text arrays. The phrase k is the concatenation
+        *                               of texts in array k.
+        * @param    aLanguageArray      pronunciations will be generated for these languages
+        * @param    aLexiconID          lexicon, where to add pronunciations
+        * @param    aGrammarID          grammar, where to add rules
+        * @param    aRuleID             the ID of the rule will be placed on this variable.
+        *                               If some of the names fail while others succeed,
+        *                               KInvalidRuleID will be placed to the array.
+        * @return    system wide error code
+        */
+        TInt AddVoiceTags( const RPointerArray<MDesCArray> &aTextArrayArray,
+                                    const RArray<TLanguage> &aLanguageArray,
+                                    TSILexiconID aLexiconID,
+                                    TSIGrammarID aGrammarID, 
+                                    RArray<TSIRuleID>& aRuleIDArray );
+
+        /**
+        * Adds a new rules for the given phrases into the 
+        * specified grammar.
+        *
+        * @param aTextArrayArray     Array of text arrays. The phrase k is the concatenation
+        *                            of texts in array k.
+        * @param aLanguageArray      pronunciations will be generated for these languages
+        * @param aLexiconID          lexicon, where to add pronunciations
+        * @param aGrammarID          grammar, where to add rules
+        * @param aRuleID             the ID of the rule will be placed on this variable.
+        *                            If some of the names fail while others succeed,
+        *                            KInvalidRuleID will be placed to the array.
+        * @return System wide error code
+        */
+        TInt AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                    const RArray<RLanguageArray>& aLanguageArray,
+                                    TSILexiconID aLexiconID,
+                                    TSIGrammarID aGrammarID, 
+                                    RArray<TSIRuleID>& aRuleIDArray );  
+
+        /**
+        * Cancels the current operation
+        */
+        void CancelUtility();
+
+        /**
+        * Saves the changes into a permanent storage.
+        *
+        * @return    System-wide errors
+        */
+        TInt CommitChanges();
+    
+        /**
+        * Creates a new grammar.
+        */
+        TInt CreateGrammar( TSIGrammarID& aGrammarID );
+
+        /**
+        * Creates a new lexicon.
+        */
+        TInt CreateLexicon( TSILexiconID& aLexiconID );
+        
+        /**
+        *    Creates a new model bank.
+        * @param    aModelBankID        reference where a new model 
+        *                                bank Id is assigned to
+        * @return    system wide error codes
+        */
+        TInt CreateModelBank( TSIModelBankID& aModelBankID );
+
+        /**
+        *    Ends the current recognition session. Resources allocated 
+        *    for recognition are freed.
+        * @param    aModelBankID        reference where a new model bank Id is 
+        *                                assigned to
+        * @return    system wide error codes
+        */
+        TInt EndRecSession();
+
+        /**
+        * 
+        *    Loads the specified grammar into the recognizer;
+        *    done prior to recognition.
+        * @param     aGrammarID            grammar ID
+        * @return    system wide error codes
+        */
+        TInt LoadGrammar( TSIGrammarID aGrammarID );
+        
+        /**
+        * 
+        *    Loads the specified model bank into the recognizer;
+        *    done prior to recognition..
+        * @param     ModelBankID            model bank Id
+        * @return    system wide error codes
+        */
+        TInt LoadModels( TSIModelBankID aModelBankID );
+
+
+        /**
+        *    Records uder utterance for training and recognition.
+        * @param    aRecordTime            recording time in microseconds
+        * @return    system wide error codes
+        */
+        TInt Record( TTimeIntervalMicroSeconds32 aRecordTime );
+
+        /**
+        * Pre-starts samping before Record call.
+        * 
+        * @since 3.2
+        * @return System wide error code
+        */
+        TInt PreStartSampling();
+
+        /**
+        *    Initiates speaker independent recognition; performed
+        *   following loading of model bank, lexicon, and grammar.
+        *
+        * @param    aResultSet            reference where the recognition
+        *                                result is set
+        * @return    system wide error codes
+        */
+        TInt Recognize( CSIClientResultSet& aResultSet );
+
+        /**
+        *    Removes the specified grammar from the permanent storage.
+        *    Removing a grammar will remove all rules within the grammar.
+        *
+        * @param    aGrammarID            grammar Id
+        * @return    system wide error codes
+        */
+        TInt RemoveGrammar( TSIGrammarID aGrammarID );
+
+        /**
+        *    Removes the specified lexicon from the permanent storage.
+        *    Removing a lexicon will remove all pronunciations within the 
+        *    lexicon.
+        * 
+        * @param    aLexiconID            lexicon Id
+        * @return    system wide error codes
+        */
+        TInt RemoveLexicon( TSILexiconID aLexiconID );
+
+
+        /**
+        *    Removes the specified model bank from the permanent storage.
+        *    Removing a model bank will remove all models within the model bank.
+        * 
+        * @param    aModelBankID        model bank Id
+        * @return    system wide error codes
+        */
+        TInt RemoveModelBank( TSIModelBankID aModelBankID );
+
+        /**
+        *    Removes the specified rule from the specified grammar permanently.
+        * 
+        * @param    aGrammarID            grammar Id
+        * @param    aRuleID                rule Id
+        * @return    system wide error codes
+        */
+        TInt RemoveRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+        /**
+        *    Removes multiple rules from the specified grammar permanently.
+        * 
+        * @param    aGrammarID            grammar Id
+        * @param    aRuleID                rule Id
+        * @return    system wide error codes
+        */
+        TInt RemoveRules( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+
+        /**
+        *    Set the audio priority and preference for train, playback 
+        *    and recognition
+        * 
+        * @param    aPriority                priority for voice recognition
+        * @param    aTrainPreference        preference for training
+        * @param    aPlaybackPreference        preference for playback
+        * @param    aRecognitionPreference    preference for recognition
+        * @return    system wide error codes
+        */
+        TInt SetAudioPriority( TInt aPriority, TInt aTrainPreference, 
+                        TInt aPlaybackPreference, TInt aRecognitionPreference );
+        
+        /**
+        *    Set the event handler for asynchronous events
+        * 
+        * @param    aSpeechRecognitionUtilityObserver        pointer to observer
+        */
+        void SetEventHandler( MSISpeechRecognitionUtilityObserver*
+                        aSpeechRecognitionUtilityObserver );
+
+
+        /**
+        *    Starts a new recognition session.
+        * 
+        * @param    aMode                recognition mode
+        * @return    system wide error codes
+        */
+        TInt StartRecSession( TNSSRecognitionMode aMode );
+
+
+        /**
+        *    Unloads the specified rule from the specified grammar
+        *    in temporary memory, previously loaded with LoadGrammarL.  
+        *    The rule in the permanent storage remains intact.
+        * 
+        * @param    aGrammarID            grammar Id
+        * @param    aRuleID               rule Id
+        * @return   system wide error codes
+        */
+        TInt UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+
+    private: // Functions
+
+	    /**
+        * C++ constructor.
+        */
+	    CNssSiUtilityWrapper( MSISpeechRecognitionUtilityObserver& iObserver, TUid aClientUid );
+
+	    /**
+        * EPOC constructor.
+        */
+	    void ConstructL();
+	    
+	    /**
+	    * From CActive
+	    */
+	    void RunL();
+	    
+	    /**
+	    * From CActive
+	    */
+	    void DoCancel();
+	    
+	    /**
+	    * Sets the active object ready to be run
+	    */
+	    void Ready();
+	    
+	    /**
+	    * From MSISpeechRecognitionUtilityObserver
+	    */
+	    void MsruoEvent( TUid aEvent, TInt aResult );
+	    
+	private: // Member variables
+	
+	    // Handle to library loader
+	    RLibrary iLib;
+	    
+	    // UID of the client
+	    TUid iClientUid;
+	    
+	    // Utility API
+	    MSISpeechRecognitionUtilityBase* iUtility;
+	    
+	    // Reference to callback handler
+	    MSISpeechRecognitionUtilityObserver& iObserver;
+	    
+	    // Stored callback parameters
+	    TUid iEvent;
+	    TInt iResult;
+    };
+
+#endif // NSSVASSIUTILITYWRAPPER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvastspeechitemconstant.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The TNssSpeechItemConstant provides constant values used by internal
+*               VASAPI methods.
+*
+*/
+
+
+#ifndef NSSVASTSPEECHITEMCONSTANT_H
+#define NSSVASTSPEECHITEMCONSTANT_H
+
+/**
+* The TNssSpeechItemConstant provides constant values used by internal VASAPI 
+* methods.
+*
+*  @lib NssVasApi.lib
+*  @since 2.0
+*/
+class TNssSpeechItemConstant
+{
+public:
+   
+    // The states for SpeechItem object 
+    enum TNssState
+    {
+        EIdle,
+        EBusy,
+        EPlayMemoryStart,
+        EPlayMemoryComplete,
+        EPlayStart,
+        EPlayComplete,
+        ETrainStart,
+        ETrainComplete,
+        ESaveToSrsStart,
+        ESaveToSrsComplete,
+        EDeleteToSrsStart,
+        EDeleteToSrsComplete,
+        ETerminate,
+        ECommitComplete,
+        EAddPronounciationComplete,
+        EAddRuleComplete,
+        ERemoveRuleComplete,
+        ERemovePronounciationComplete,
+        ERemoveModelCompelete,
+        EWaitForCommitChanges
+    };
+
+    // The results for the SpeechItem operations
+    enum TNssResult
+    {
+        EErrorNone,
+        EInvalidState,
+        EInvalidEventHandler
+    };
+
+};
+
+#endif // NSSVASTSPEECHITEMCONSTANT
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/inc/nssvasttsutilitywrapper.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Wrapper class which forwards calls to TTS Utility
+*
+*/
+
+
+#ifndef NSSVASTTSUTILITYWRAPPER_H
+#define NSSVASTTSUTILITYWRAPPER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <nssttsutilityobserver.h>
+#include <nssttscommon.h>
+
+// FORWARD DECLARATIONS
+class MTtsUtilityBase;
+
+// CLASS DECLARATION
+
+/**
+* CNssTtsUtilityWrapper
+* @since 3.1
+* @see nssttsutility.h
+* @see nssttsutilitybase.h
+* @see nssttsutilityobserver.h
+*/
+NONSHARABLE_CLASS ( CNssTtsUtilityWrapper ) : public CActive, public MTtsClientUtilityObserver
+    {
+    public: // Constructors & destructor
+
+        /**
+        * Two-phased constructor
+        * 
+        * @since 3.1
+        */
+        static CNssTtsUtilityWrapper* NewL( MTtsClientUtilityObserver& aObserver,
+                TInt aPriority = EMdaPriorityNormal,
+                TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality );
+
+        /**
+        * Destructor.
+        */
+	    virtual ~CNssTtsUtilityWrapper();
+
+    public: // New functions
+    
+        /**
+        * Adds new style to style collection.
+        *
+        * @since 3.1
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Assigned style ID.
+        */
+        TTtsStyleID AddStyleL( const TTtsStyle& aStyle );
+        
+       /**
+        * Opens a parsed text source and plays it.
+        *
+        * @since 3.1
+        * @param "CTtsParsedText& aText" Parsed text object to play.
+        * @param "TInt aPriority" Playback priority.
+        * @param "TMdaPriorityPreference aPref" Playback priority preference.
+        */
+        void OpenAndPlayParsedTextL( CTtsParsedText& aText, 
+                TInt aPriority = EMdaPriorityNormal, 
+                TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality );
+                                     
+        /**
+        * Stops playback of the audio sample as soon as possible.
+        *
+        * If the audio sample is playing, playback is stopped as soon as
+        * possible. If playback is already complete, nothing further happens as
+        * a result of calling this function. The callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is not
+        * called.
+        *
+        * @since 3.1
+        */
+        void Stop();                                     
+        
+        /**
+        * Begins playback of the initialised audio sample at the current volume
+        * and priority levels.
+        *
+        * When playing of the audio sample is complete, successfully or
+        * otherwise, the callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is
+        * called.
+        *
+        * @since 3.1
+        */
+        void Play();
+        
+        /**
+        * Closes the current audio clip (allowing another clip to be opened)
+        *
+        * @since 3.1
+        */
+        void Close();
+ 
+    private: // Functions
+
+	    /**
+        * C++ constructor.
+        */
+	    CNssTtsUtilityWrapper( MTtsClientUtilityObserver& aObserver,
+                               TInt aPriority,
+                               TMdaPriorityPreference aPref );
+
+	    /**
+        * EPOC constructor.
+        */
+	    void ConstructL();
+	    
+	    /*
+	    * From MTtsClientUtilityObserver
+	    */
+	    void MapcCustomCommandEvent( TInt aEvent, TInt aError );
+	    
+	    /*
+	    * From MTtsClientUtilityObserver
+	    */
+        void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration );
+
+	    /*
+	    * From MTtsClientUtilityObserver
+	    */
+	    void MapcPlayComplete( TInt aError );
+	    
+	    /**
+	    * From CActive
+	    */
+	    void RunL();
+	    
+	    /**
+	    * From CActive
+	    */
+	    void DoCancel();
+	    
+	    /**
+	    * Sets the active object ready to be run
+	    */
+	    void Ready();
+	        
+	private: // Member variables
+	
+	    // Handle to library loader
+	    RLibrary iLib;
+	    
+	    // UID of the utility client
+	    TUid iClientUid;
+	    
+	    // Pointer to the utility base class
+	    MTtsUtilityBase* iUtility;
+	    
+	    // Reference to the observer
+	    MTtsClientUtilityObserver& iObserver;
+	    
+	    // Audio priority and preference
+        TInt iPriority;
+        TMdaPriorityPreference iPref;
+        
+        // Stored callback parameters
+        TInt iError;
+        TTimeIntervalMicroSeconds iDuration;   
+	    
+	    // Callback function
+	    enum TTtsUtilityVasCallback
+	        {
+            EInitComplete,
+            EPlayComplete
+            };
+        
+        TTtsUtilityVasCallback iState;
+    };
+
+#endif // NSSVASSIUTILITYWRAPPER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasapimain.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Entry point for VAsApi.dll
+*
+*/
+
+
+
+#include <e32def.h>
+#include <e32std.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasccontext.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,369 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssContext class does all context processing. It implements 
+*               MNssContext interface.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasccontext.h"
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================  
+
+// ---------------------------------------------------------
+// CNssContext::CNssContext
+// C++ default constructor can NOT contain any code that
+// might leave.
+// ---------------------------------------------------------
+//
+CNssContext::CNssContext( CNssContextSrsPortal* aContextSrsPortal )
+    {
+    // These take forever in strain test
+    RUBY_DEBUG0( "CNssContext::CNssContext" );
+    
+    iContextSrsPortal = aContextSrsPortal;
+    iGlobal = EFalse;
+    iContextId = KNssVASDbDefaultValue; 
+    iContextSrsPortal->Register();
+    iRecognitionMode = ENSSSdSiMode;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::~CNssContext
+// Destructor
+// ---------------------------------------------------------
+//
+CNssContext::~CNssContext()
+    {
+    // These take forever in strain test:
+    // RUBY_DEBUG0( "CNssContext::~CNssContext" );
+    
+    if ( iContextSrsPortal )
+        {
+        iContextSrsPortal->Deregister();
+        }
+    if ( iName )
+        {
+        delete iName;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContext::ContextName
+// returns the name of the context as a reference
+// ---------------------------------------------------------
+//
+TDesC& CNssContext::ContextName()
+    {
+    return *iName;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::IsGlobal
+// returns the global flag
+// ---------------------------------------------------------
+//
+TBool CNssContext::IsGlobal()
+    {
+    return iGlobal;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::SetNameL
+// sets the name of the context to aName, 
+// old name, if any is deleted.
+// ---------------------------------------------------------
+//
+void CNssContext::SetNameL( const TDesC& aName )
+    {
+    if ( iName )
+        {
+        delete iName;
+        iName = NULL;
+        }
+    iName = aName.AllocL(); 
+    }
+
+// ---------------------------------------------------------
+// CNssContext::SetGlobal
+// sets the global flag to ETrue or EFalse
+// ---------------------------------------------------------
+//
+void CNssContext::SetGlobal( TBool aGlobal )
+    {
+	iGlobal = aGlobal;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::ContextId
+// return the context id
+// for internal use
+// ---------------------------------------------------------
+//
+TInt CNssContext::ContextId() const
+    {
+	return iContextId;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::GrammarId
+// returns the grammar id
+// for internal use
+// ---------------------------------------------------------
+//
+TUint32 CNssContext::GrammarId() const
+	{
+	return iGrammarId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::LexiconId
+// returns the lexicon id
+// for internal use
+// ---------------------------------------------------------
+//
+TUint32 CNssContext::LexiconId() const
+	{
+	return iLexiconId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::ModelBankId
+// returns the model bank id
+// for internal use
+// ---------------------------------------------------------
+//
+TUint32 CNssContext::ModelBankId() const
+	{
+    return iModelBankId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::RecognitionMode
+// returns the recognition technology
+// for internal use
+// ---------------------------------------------------------
+//
+TNSSRecognitionMode CNssContext::RecognitionMode() const
+	{
+    return iRecognitionMode;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SetContextId
+// sets the context id to the given value
+// for internal use
+// ---------------------------------------------------------
+//
+void CNssContext::SetContextId( TInt aContextId )
+	{
+	iContextId = aContextId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SetGrammarId
+// sets the grammar id to the given value
+// for internal use
+// ---------------------------------------------------------
+//
+void CNssContext::SetGrammarId( TUint32 aGrammarId )
+	{
+	iGrammarId = aGrammarId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SetLexiconId
+// sets the lexicon id to the given value
+// for internal use
+// ---------------------------------------------------------
+//
+void CNssContext::SetLexiconId( TUint32 aLexiconId )
+	{
+	iLexiconId = aLexiconId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SetModelBankId
+// sets the model bank id to the given value
+// for internal use
+// ---------------------------------------------------------
+//
+void CNssContext::SetModelBankId( TUint32 aModelBankId )
+	{
+	iModelBankId = aModelBankId;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SetRecognitionMode
+// sets the model bank id to the given value
+// for internal use
+// ---------------------------------------------------------
+//
+void CNssContext::SetRecognitionMode( TNSSRecognitionMode aRecogMode )
+	{
+	iRecognitionMode = aRecogMode;
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SaveToSrsL
+// for internal use
+// This method is used to save the context to the SRS.
+// This creates the model bank, 
+// lexicon, and grammar for a context. Model bank, and lexicon 
+// are created only for the first time, and are thus, fixed.
+// For every context, there is one grammar id. After, model bank,
+// lexicon, and grammar are created, the corresponding Ids are 
+// set in the context object.
+// ---------------------------------------------------------
+//
+void CNssContext::BeginSaveToSrsL( MNssCoreSrsDBEventHandler* aSrsDBEventHandler )
+	{
+	iContextSrsPortal->BeginSaveContextL( this, aSrsDBEventHandler );
+	}
+
+// ---------------------------------------------------------
+// CNssContext::DeleteFromSrsL
+// for internal use
+// This method is used to delete a context from the SRS.
+// This deletes the grammar from the SRS. 
+// ---------------------------------------------------------
+//
+void CNssContext::BeginDeleteFromSrsL( MNssCoreSrsDBEventHandler* aSrsDBEventHandler )
+	{
+	iContextSrsPortal->BeginDeleteContextL( this, aSrsDBEventHandler );
+	}
+
+// ---------------------------------------------------------
+// CNssContext::CommitSrsChanges
+// for internal use
+// This method is used to commit a context change from the SRS.
+// ---------------------------------------------------------
+//
+TInt CNssContext::CommitSrsChanges()
+	{
+	return iContextSrsPortal->CommitSaveContext();
+	}
+
+// ---------------------------------------------------------
+// CNssContext::RollbackSrsChanges
+// for internal use
+// This method is used to commit a context change from the SRS.
+// ---------------------------------------------------------
+//
+TInt CNssContext::RollbackSrsChanges()
+	{
+	return iContextSrsPortal->RollbackSaveContext();
+	}
+
+// ---------------------------------------------------------
+// CNssContext::SetModelBankAndLexiconExist
+// for internal use
+// sets the iModelBankAndLexiconExist flag to ETrue or EFalse
+// ---------------------------------------------------------
+//
+void CNssContext::SetModelBankAndLexiconExist( TBool aVal )
+    {
+	iModelBankAndLexiconExist = aVal;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::ModelBankAndLexiconExist
+// for internal use
+// gets the value of the iModelBankAndLexiconExist flag
+// ---------------------------------------------------------
+//
+TBool CNssContext::ModelBankAndLexiconExist()
+    {
+	return iModelBankAndLexiconExist;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::operator=
+// for internal use
+// overloaded assignment operator
+// ---------------------------------------------------------
+//
+CNssContext& CNssContext::operator=( const CNssContext& aContext )
+    {
+    RUBY_DEBUG0( "CNssContext::operator=" );
+    
+    if ( this != &aContext )
+        {
+        if ( iName )
+            {
+            delete iName;
+            }
+        iName = (aContext.iName)->Alloc();
+        iContextId = aContext.iContextId;
+        iGlobal = aContext.iGlobal;
+        iGrammarId = aContext.iGrammarId;
+        iLexiconId = aContext.iLexiconId;
+        iModelBankId = aContext.iModelBankId;
+        iContextSrsPortal = aContext.iContextSrsPortal;
+        iModelBankAndLexiconExist = aContext.iModelBankAndLexiconExist;
+        iRecognitionMode = aContext.iRecognitionMode;
+        }
+    return *this;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::CopyL
+// for internal use
+// creates a copy of this context
+// ---------------------------------------------------------
+//
+CNssContext* CNssContext::CopyL()
+    {
+    // Takes ages in strain test
+    RUBY_DEBUG0( "CNssContext::CopyL" );
+    
+    CNssContext* copy = new (ELeave) CNssContext( iContextSrsPortal );
+    copy->iName = iName->Alloc();
+    copy->iContextId = iContextId;
+    copy->iGlobal = iGlobal;
+    copy->iGrammarId = iGrammarId;
+    copy->iLexiconId = iLexiconId;
+    copy->iModelBankId = iModelBankId;
+    copy->iContextSrsPortal = iContextSrsPortal;
+    copy->iModelBankAndLexiconExist = iModelBankAndLexiconExist;
+    copy->iClientData.Copy( iClientData );
+    
+    return copy;
+    }
+
+// ---------------------------------------------------------
+// CNssContext::SetClientData
+// Sets/Resets the client data. The data must be saved
+// to VAS DBwith CNssContextMgr::SaveClientData.
+// ---------------------------------------------------------
+//
+void CNssContext::SetClientData(const TDesC8& aData)
+    {
+    iClientData.Copy( aData );
+    }
+
+// ---------------------------------------------------------
+// CNssContext::ClientData
+// Gets the client data.
+// ---------------------------------------------------------
+//
+const TDesC8& CNssContext::ClientData(void)
+    {
+    return iClientData;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasccontextbuilder.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssContextBuilder is the builder for context objects. It is owned 
+*               by the context manager. A client builds contexts by requesting the
+*               context manager which in turn forwards the request to context builder.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasccontextbuilder.h"
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssContextBuilder::CNssContextBuilder
+// C++ constructor can NOT contain any code that
+// might leave.
+// ---------------------------------------------------------
+// 
+CNssContextBuilder::CNssContextBuilder()
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+// 
+CNssContextBuilder* CNssContextBuilder::NewL()
+    {
+    // Takes ages in strain test
+    // RUBY_DEBUG0( "CNssContextBuilder::NewL" );
+
+    CNssContextBuilder* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::NewLC
+// Two-phased constructor.
+// ---------------------------------------------------------
+// 
+CNssContextBuilder* CNssContextBuilder::NewLC()
+    {
+    CNssContextBuilder* self = new (ELeave) CNssContextBuilder;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::~CNssContextBuilder
+// Destructor
+// ---------------------------------------------------------
+//    
+CNssContextBuilder::~CNssContextBuilder()
+    {
+    RUBY_DEBUG0( "CNssContextBuilder::~CNssContextBuilder" );
+
+	// do not delete the portal if ContextCount() > 0 
+	if ( iContextSrsPortal )
+	    {
+    	iContextSrsPortal->SetTerminationState( CNssContextSrsPortal::EVASTERMINATION_PENDING );
+    	if ( iContextSrsPortal->ContextCount() == 0 )
+	    	{
+			delete iContextSrsPortal;
+		    }    	
+	    }
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::ConstructL
+// creates a context srs portal
+// ---------------------------------------------------------
+//
+void CNssContextBuilder::ConstructL()
+    {
+    iContextSrsPortal = new (ELeave) CNssContextSrsPortal();
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::CreateContextL
+// creates a context given all data member values.
+// ---------------------------------------------------------
+//
+CNssContext* CNssContextBuilder::CreateContextL( const TDesC& aName, 
+                                                 TInt aContextId, 
+                                                 TBool aGlobal, 
+                                                 TUint32 aGrammarId, 
+                                                 TUint32 aLexiconId, 
+                                                 TUint32 aModelBankId, 
+                                                 TUint32 /*iTrainType*/, 
+                                                 const TDesC8& aClientData )
+    {
+    // Takes ages in strain test
+    // RUBY_DEBUG_BLOCK( "CNssContextBuilder::CreateContextL" );
+
+	CNssContext *context = new (ELeave) CNssContext( iContextSrsPortal );
+	CleanupStack::PushL(context);
+	context->SetNameL( aName );
+	context->SetContextId( aContextId );
+	context->SetGlobal( aGlobal );
+	context->SetGrammarId( aGrammarId );
+	context->SetLexiconId( aLexiconId );
+	context->SetModelBankId( aModelBankId );
+    context->SetClientData( aClientData );
+	CleanupStack::Pop(context);
+	return context;
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::CreateContextL
+// creates a context given lexicon id and model bank id
+// ---------------------------------------------------------
+//
+CNssContext* CNssContextBuilder::CreateContextL( TUint32 aLexiconId, 
+                                                 TUint32 aModelBankId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssContextBuilder::CreateContextL() - w/ lex id & model bank id" );
+
+	CNssContext *context = new (ELeave) CNssContext( iContextSrsPortal );
+	context->SetLexiconId( aLexiconId );
+	context->SetModelBankId( aModelBankId );
+	return context;
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::CreateContextL
+// creates an empty context object
+// ---------------------------------------------------------
+//
+CNssContext* CNssContextBuilder::CreateContextL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssContextBuilder::CreateContextL() - empty" );
+
+    CNssContext *context = new (ELeave) CNssContext( iContextSrsPortal );
+	return context;
+    }
+
+// ---------------------------------------------------------
+// CNssContextBuilder::GetContextPortal
+// returns the context SRS portal
+// ---------------------------------------------------------
+//
+CNssContextSrsPortal* CNssContextBuilder::GetContextPortal()
+    {
+	return iContextSrsPortal;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasccontextsrsportal.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,545 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssContextSrsPortal provides SRS related functionalities for 
+*               context processing. A context is saved in the SRS DB by creating 
+*               model bank, lexicon, and grammar into the SRS.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasccontextsrsportal.h"
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::CNssContextSrsPortal
+// C++ default constructor can NOT contain any code that
+// might leave.
+// ---------------------------------------------------------
+//
+CNssContextSrsPortal::CNssContextSrsPortal()
+    {
+    RUBY_DEBUG0( "CNssContextSrsPortal::CNssContextSrsPortal" );
+    
+    iTerminationState = CNssContextSrsPortal::EVASTERMINATION_NOT_PENDING;
+    iState = EVASNone;
+    iRecovery = EFalse;
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::~CNssContextSrsPortal
+// Destructor
+// ---------------------------------------------------------
+//
+CNssContextSrsPortal::~CNssContextSrsPortal()
+    {
+    RUBY_DEBUG0( "CNssContextSrsPortal::~CNssContextSrsPortal" );
+    
+    DeleteSRS();
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::MsruoEvent
+// interface implementation from MSpeechRecognitionUtilityObserver
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::MsruoEvent( TUid aEvent, TInt aResult )
+    {
+    RUBY_DEBUG2( "CNssContextSrsPortal::MsruoEvent - Event=0x%x, Result=%d", aEvent.iUid, aResult );
+    
+    TInt err = KErrNone;
+    switch ( aEvent.iUid )
+        {
+        case KUidAsrEventCreateGrammarVal:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - CreateGrammar" );
+
+            if ( aResult == KErrNone )
+                {
+                iContext->SetGrammarId( iGrammarId );
+                iState = EVasWaitForCommitChanges;  // wait for commit
+                iSrsDBEventHandler->HandleSaveSrsDBCompleted();
+                }
+            else
+                {   
+                CleanUp( aResult );
+                }
+            break;
+            
+            
+        case KUidAsrEventCreateLexiconVal:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - CreateLexicon" );
+                 
+            if (aResult == KErrNone)
+                {
+                iContext->SetLexiconId(iLexiconId);
+                iState = EVASCreateGrammar;
+                err = iSpeechRecognitionUtility->CreateGrammar(iGrammarId);
+                if(err != KErrNone)
+                    {
+                    CleanUp(aResult);
+                    }
+                }
+            else
+                {
+                CleanUp(aResult);
+                }
+            break;
+            
+            
+        case KUidAsrEventCreateModelBankVal:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - CreateModelBank" );
+
+            // Two states may trigger this message:
+            //  * When creating the first context
+            //  * When resetting to factory settings
+            
+            // "Reset factory settings"
+            if ( iState == EVASResetCreateModelBank )
+                {
+                if ( aResult == KErrNone )
+                    {
+                    iState = EVasWaitForCommitChanges;      // wait for commit
+                    iSrsDBEventHandler->HandleResetSrsDBCompleted();
+                    }
+                else
+                    {
+                    CleanUp( aResult );
+                    }
+                }
+            else
+                {
+                
+                if ( aResult == KErrNone )
+                    {
+                    iContext->SetModelBankId(iModelBankId);
+                    iState = EVASCreateLexicon;
+                    err = iSpeechRecognitionUtility->CreateLexicon(iLexiconId);
+                    if ( err != KErrNone )
+                        {
+                        CleanUp( aResult );
+                        }
+                    }
+                else
+                    {
+                    CleanUp( aResult );
+                    }
+                }
+            break;
+            
+            
+        case KUidAsrEventRemoveGrammarVal:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - RemoveGrammar" );
+            
+            if ( aResult == KErrNone || aResult == KErrNotFound )
+                {
+                iState = EVASRemoveLexicon;
+                err = iSpeechRecognitionUtility->RemoveLexicon( 
+                                (TSILexiconID) iContext->LexiconId() );
+                if ( err != KErrNone )
+                    {
+                    CleanUp( aResult );
+                    }
+                }
+            else
+                {
+                CleanUp( aResult );
+                }
+            break;
+            
+            // This case may never being called.
+        case KUidAsrEventRemoveLexiconVal:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - RemoveLexicon" );
+             
+            if ( aResult == KErrNone || aResult == KErrNotFound )
+                {
+                iState = EVasWaitForCommitChanges;      // wait for commit
+                iSrsDBEventHandler->HandleDeleteSrsDBCompleted();
+                }
+            else
+                {
+                CleanUp( aResult );
+                }
+            break;
+            
+            
+            // This case may never being called.
+        case KUidAsrEventRemoveModelBankVal:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - RemoveModelBank" );
+             
+            // "Reset factory settings": Remove speaker adapted model bank
+            //                           and create a new one.
+            if ( iState == EVASResetRemoveModelBank )
+                {
+                TInt createErr = KErrNone;
+                
+                if ( aResult == KErrNone )
+                    {
+                    iState = EVASResetCreateModelBank;
+                    
+                    createErr = iSpeechRecognitionUtility->CreateModelBank( *iResetModelBankId );
+                    }
+                
+                // If RemoveModelBank failed, or CreateModelBank 5 lines age failed.
+                if ( aResult != KErrNone || createErr != KErrNone )
+                    {
+                    DeleteSRS();
+                    iSrsDBEventHandler->HandleSrsDBError( 
+                            MNssCoreSrsDBEventHandler::EVasRemoveModelBankFailed );
+                    }
+                }
+            else
+                {
+                // Legacy code from SDND - I don't know when this is invoked
+                if ( aResult == KErrNone || aResult == KErrNotFound )
+                    {
+                    iState = EVasWaitForCommitChanges;      // wait for commit
+                    
+                    DeleteSRS();
+                    iSrsDBEventHandler->HandleDeleteSrsDBCompleted();	
+                    }
+                else
+                    {
+                    CleanUp( aResult );
+                    }
+                }
+            break;
+            
+            
+            
+        default:
+            RUBY_DEBUG0( "CNssContextSrsPortal::MsruoEvent - default" );
+            CleanUp( aResult );
+            break;
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CNssContextSrsPortal::DoSrsDBResult
+// Method to process the SRS DB result.
+// -----------------------------------------------------------------------------
+//
+MNssCoreSrsDBEventHandler::TNssSrsDBResult 
+CNssContextSrsPortal::DoSrsDBResult(TInt aResult)
+    {
+    RUBY_DEBUG1( "CNssContextSrsPortal::DoSrsDBResult() aResult = %d", aResult );
+    
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult errorCode;
+    
+    switch (aResult)
+        {
+        case KErrDiskFull:
+            RUBY_DEBUG0( "CNssContextSrsPortal::DoSrsDBResult - KErrDiskFull" );
+            
+            errorCode = MNssCoreSrsDBEventHandler::EVasDiskFull;
+            break;
+        case KErrNoMemory:
+            RUBY_DEBUG0( "CNssContextSrsPortal::DoSrsDBResult - KErrNoMemory" );
+            
+            errorCode = MNssCoreSrsDBEventHandler::EVasNoMemory;
+            break;
+        default:
+            {
+            RUBY_DEBUG1( "CNssContextSrsPortal::DoSrsDBResult - default, state = %d", iState );
+            
+            switch ( iState )
+                {
+                case EVASCreateModelBank:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasCreateModelBankFailed;
+                    break;
+                case EVASCreateLexicon:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasCreateLexiconFailed;
+                    break;
+                case EVASCreateGrammar:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasCreateGrammarFailed;
+                    break;
+                case EVASRemoveModelBank:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasRemoveModelBankFailed;
+                    break;
+                case EVASRemoveLexicon:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasRemoveLexiconFailed;
+                    break;
+                case EVASRemoveGrammar:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasRemoveGrammarFailed;
+                    break;
+                default:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasDBOperationError;
+                    break;
+                }
+            }
+        }
+    
+    return errorCode;
+    }
+
+
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::BeginSaveContextL
+// save context to srs database
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::BeginSaveContextL( CNssContext* aContext, 
+                                              MNssCoreSrsDBEventHandler* aSrsDBEventHandler )
+    {
+    RUBY_DEBUG_BLOCK( "CNssContextSrsPortal::BeginSaveContextL" );
+    
+    iSrsDBEventHandler = aSrsDBEventHandler;
+    iContext = aContext;
+    
+    // verify the SRS is NULL, if not return failure
+    if ( iSpeechRecognitionUtility )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    RUBY_DEBUG0( "CNssContextSrsPortal::CREATE SRS" );
+    
+    iSpeechRecognitionUtility = CNssSiUtilityWrapper::NewL( *this, KNssVASApiUid );
+    
+    TInt error;
+    iRecovery = EFalse;
+    
+    // if creating context first time, create model bank and lexicon
+    if ( !aContext->ModelBankAndLexiconExist() ) 
+        {
+        iState = EVASCreateModelBank;
+        error = iSpeechRecognitionUtility->CreateModelBank(iModelBankId);
+        if ( error != KErrNone )
+            {
+            DeleteSRS();
+            User::Leave( error );
+            }
+        }
+    else // Create grammar and lexicon
+        {
+        iState = EVASCreateLexicon;
+        error = iSpeechRecognitionUtility->CreateLexicon(iLexiconId);
+        if ( error != KErrNone )
+            {
+            DeleteSRS();
+            User::Leave( error );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::BeginDeleteContextL
+// deletes context from SRS. 
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::BeginDeleteContextL(CNssContext* aContext, 
+                                MNssCoreSrsDBEventHandler* aSrsDBEventHandler)
+    {
+    RUBY_DEBUG_BLOCK( "CNssContextSrsPortal::BeginDeleteContextL" );
+    
+    iSrsDBEventHandler = aSrsDBEventHandler;
+    iContext = aContext;
+    iRecovery = EFalse;
+    
+    // verify the SRS is NULL, if not return failure
+    if ( iSpeechRecognitionUtility )
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    RUBY_DEBUG0( "CNssContextSrsPortal::CREATE SRS" );
+     
+    iSpeechRecognitionUtility = CNssSiUtilityWrapper::NewL( *this, KNssVASApiUid );
+    iState = EVASRemoveGrammar;
+    
+    TInt error = iSpeechRecognitionUtility->RemoveGrammar( (TSIGrammarID)aContext->GrammarId() );
+    if ( error != KErrNone )
+        {
+        DeleteSRS();
+        User::Leave( error );
+        }
+    
+    // Lexicon will be deleted when grammar deletion callback arrives
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::CommitSaveContext
+// commit context changes from SRS. 
+// ---------------------------------------------------------
+//
+TInt CNssContextSrsPortal::CommitSaveContext()
+    {
+    RUBY_DEBUG0( "CNssContextSrsPortal::CommitSaveContext" );
+    
+    TInt ret( KErrNone );
+    
+    if ( iState == EVasWaitForCommitChanges )
+        {
+        TInt error = iSpeechRecognitionUtility->CommitChanges();
+        
+        if ( error != KErrNone )
+            {
+            DeleteSRS();
+            ret = error;
+            }
+        }
+    else
+        {
+        DeleteSRS();
+        ret = KErrGeneral;
+        }
+    
+    DeleteSRS();
+    iState = EVASNone;      // reset the state
+    
+    return ret;	
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::RollbackSaveContext
+// commit context changes from SRS. 
+// ---------------------------------------------------------
+//
+TInt CNssContextSrsPortal::RollbackSaveContext()
+    {
+    RUBY_DEBUG0( "CNssContextSrsPortal::RollbackSaveContext" );
+
+    if (iState != EVasWaitForCommitChanges)
+        {
+        DeleteSRS();
+        return KErrGeneral;
+        }
+    
+    DeleteSRS();
+    iState = EVASNone;      // reset the state
+    return KErrNone;	
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::DeleteSRS
+// Delete the SRS, and set it to NULL
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::DeleteSRS()
+    {
+    RUBY_DEBUG0( "CNssContextSrsPortal::DeleteSRS" );
+    
+    if ( iSpeechRecognitionUtility )
+        {
+        RUBY_DEBUG0( "CNssContextSrsPortal::deleted SRS........" );        
+        
+        delete iSpeechRecognitionUtility; 
+        iSpeechRecognitionUtility = NULL;
+        
+        RUBY_DEBUG0( "CNssContextSrsPortal::.....SRS just deleted" );
+        }      
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::CleanUp
+// Clean up after SRS operation fail
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::CleanUp( TInt aResult )
+    {
+    RUBY_DEBUG0( "CNssContextSrsPortal::CleanUp" );
+
+    DeleteSRS();
+    
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult errorCode = DoSrsDBResult( aResult );
+    iSrsDBEventHandler->HandleSrsDBError( errorCode );            
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::Register
+// context portal keeps a count of number of contexts created
+// increment count
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::Register()
+    {
+    iContextCount++;
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::Deregister
+// decrement count
+// id count is zero, and context builder is deleted, delete itself (portal),
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::Deregister()
+    {
+    iContextCount--;
+    if ( iContextCount == 0 && iTerminationState == EVASTERMINATION_PENDING )
+        {
+        delete this;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::ContextCount
+// returns context count
+// ---------------------------------------------------------
+//
+TInt CNssContextSrsPortal::ContextCount()
+    {
+    return iContextCount;
+    }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::SetTerminationState
+// sets termination state
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::SetTerminationState( TNssTerminationState aState )
+   {
+	iTerminationState = aState;
+   }
+
+// ---------------------------------------------------------
+// CNssContextSrsPortal::BeginResetModelsL
+// sets termination state
+// ---------------------------------------------------------
+//
+void CNssContextSrsPortal::BeginResetModelsL( TSIModelBankID aAdaptedModels,
+                                              TSIModelBankID& aNewModels,
+                                              MNssCoreSrsDBEventHandler* aSrsDBEventHandler )
+    {
+    RUBY_DEBUG_BLOCK( "CNssContextSrsPortal::BeginSaveContextL" );
+    
+    iSrsDBEventHandler = aSrsDBEventHandler;
+    
+    // verify the SRS is NULL, if not return failure
+    if ( iSpeechRecognitionUtility )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    RUBY_DEBUG0( "CNssContextSrsPortal::CREATE SRS" );
+    
+    iSpeechRecognitionUtility = CNssSiUtilityWrapper::NewL( *this, KNssVASApiUid );
+    TInt error = KErrNone;
+    iRecovery = EFalse;
+    
+    iState = EVASResetRemoveModelBank;
+    error = iSpeechRecognitionUtility->RemoveModelBank( aAdaptedModels );
+    
+    if ( error != KErrNone )
+        {
+        DeleteSRS();
+        User::Leave( error );
+        }
+    
+    iResetModelBankId = &aNewModels;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvascrrd.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,189 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssRRD class encapsulated a RRD. It implements MNssRRD.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+
+#include "rubydebug.h"
+#include "nssvascrrd.h"
+#include "nssvascvasdbdataexchanger.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssRRD::CNssRRD
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CNssRRD::CNssRRD()
+    {
+    iTagId = KNssVASDbDefaultValue;
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::ConstructL
+// EPOC constructor can leave.
+// ---------------------------------------------------------
+//
+void CNssRRD::ConstructL()
+    {
+    iTextArray = new (ELeave) CArrayFixFlat<NssRRDText>(1);
+    iIntArray = new (ELeave) CArrayFixFlat<TInt>(1);
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CNssRRD* CNssRRD::NewL()
+    {
+    CNssRRD* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::NewLC
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CNssRRD* CNssRRD::NewLC()
+    {
+    CNssRRD* self = new (ELeave) CNssRRD;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::~CNssRRD
+// Destructor
+// ---------------------------------------------------------
+//
+CNssRRD::~CNssRRD()
+    {
+    if ( iTextArray )
+        {
+        iTextArray->Reset(); 
+        delete iTextArray;
+        }
+    if ( iIntArray )
+        {
+        iIntArray->Reset();
+        delete iIntArray;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::TextArray
+// returns the text array with this RRD
+// ---------------------------------------------------------
+//
+CArrayFixFlat<NssRRDText>* CNssRRD::TextArray()
+    {
+	return iTextArray; 
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::IntArray
+// returns the int array with this rrd
+// ---------------------------------------------------------
+//
+CArrayFixFlat<TInt>* CNssRRD::IntArray()
+    {
+    return iIntArray;
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::SetTextArrayL
+// sets text array for this RRD
+// ---------------------------------------------------------
+//
+void CNssRRD::SetTextArrayL(CArrayFixFlat<NssRRDText>* aTextArray)
+    {
+    iTextArray->Reset();
+    TInt count = aTextArray->Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( (*aTextArray)[i].MaxLength() > KNssVASMAXRRDTextLength )
+            {
+            RUBY_DEBUG2("CNssRRD::SetTextArrayL text too long %i, max %i",
+                 (*aTextArray)[i].MaxLength(), KNssVASMAXRRDTextLength );
+            User::Leave( KErrOverflow );
+            }
+         
+        iTextArray->AppendL( (*aTextArray) [i] );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssRRD::SetIntArrayL
+// sets int array for this rrd
+// ---------------------------------------------------------
+//
+ void CNssRRD::SetIntArrayL(CArrayFixFlat<TInt>* aIntArray)
+     {
+     iIntArray->Reset();
+     TInt count = aIntArray->Count();
+     for ( TInt i = 0; i < count; i++ )
+         {
+         iIntArray->AppendL( (*aIntArray) [i] );
+         }
+     }
+
+// ---------------------------------------------------------
+// CNssRRD::SetTagId
+// sets the tag id associated with a RRD
+// for use by the VAS Database
+// ---------------------------------------------------------
+//
+void CNssRRD::SetTagId( TInt aTagId )
+    {
+    iTagId = aTagId;
+    }		
+
+// ---------------------------------------------------------
+// CNssRRD::TagId
+// gets the tag id associated with the RRD
+// for use by the VAS Database
+// ---------------------------------------------------------
+//
+TInt CNssRRD::TagId()
+    {
+    return iTagId;
+    }		
+
+// ---------------------------------------------------------
+// CNssRRD::CopyL
+// Make a deep copy of RRD
+// ---------------------------------------------------------
+//
+CNssRRD* CNssRRD::CopyL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssRRD::CopyL" );
+    
+    CNssRRD *copy = CNssRRD::NewL();
+    copy->SetTextArrayL( iTextArray );
+    copy->SetIntArrayL( iIntArray );
+    copy->iTagId = iTagId;
+    return copy;
+    }
+	
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvascspeechitem.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1310 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSpeechItem provides speech mechanism to request services 
+*               from SRS.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+
+#include "srsfbldvariant.hrh"
+#include <nssvascoreconstant.h>
+#include "nssvascspeechitem.h"
+#include "nssvascspeechitemtrainer.h"
+#include "nssvasctag.h"
+#include "nssvasctrainingparameters.h"
+#include "nssvasdbkonsts.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+// This value is used for maximum retry times
+const TInt KVASSpeechItemMaxRetry = 2;   
+// This value is used to reset the retry number 
+const TInt KVASSpeechItemResetRetry = 0;
+
+// Character which is used instead of separator marker
+_LIT( KEmptySpace, " " );
+
+// Panic category
+_LIT( KSpeechItemPanic, "CNssSpeechItem" );
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::CNssSpeechItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem::CNssSpeechItem( CNssContext& aContext, 
+                                CNssSpeechItemSrsPortal& aPortal, 
+                                CNssSpeechItemTrainer& aTrainer )
+                              : iRuleID( KInvalidRuleID ),
+                                iTrainedType( TNssVasCoreConstant::EVasNotTrained ),
+                                iState( TNssSpeechItemConstant::EIdle ),
+                                iContext( aContext ),
+                                iPortal( aPortal ),
+                                iTrainer( aTrainer ),
+                                iTagId( KNssVASDbDefaultValue ),
+                                iTrained( EFalse ),
+                                iRecover( EFalse )
+    {
+    //Register to Portal
+    iPortal.Register();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::~CNssSpeechItem
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem::~CNssSpeechItem()
+    {
+    delete iText;
+    delete iTrimmedText;
+    
+    if ( iTtsData )
+        {
+        CleanPlayback();
+        }
+    
+    iPortal.Deregister(); // Deregister to Portal
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::NewL
+// Two-phased constructor.
+// This is for new SpeechItem
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem* CNssSpeechItem::NewL( CNssContext& aContext, 
+                                      CNssSpeechItemSrsPortal& aPortal, 
+                                      CNssSpeechItemTrainer& aTrainer )
+    {
+    CNssSpeechItem* self = new (ELeave) CNssSpeechItem( aContext, aPortal, aTrainer );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// This is overloaded function for SpeechItem from database
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::ConstructL( TUint32 aRuleID, const TDesC& aText )
+    {
+    SetTextL( aText );
+    iRuleID = aRuleID;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::NewLC
+// Two-phased constructor.
+// This is overloaded function for SpeechItem from database
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem* CNssSpeechItem::NewLC( CNssContext& aContext,
+                                       CNssSpeechItemSrsPortal& aPortal,
+                                       CNssSpeechItemTrainer& aTrainer,
+                                       TUint32 aRuleID, const TDesC& aText )
+    {
+    CNssSpeechItem* self = new (ELeave) CNssSpeechItem( aContext, aPortal, aTrainer );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRuleID, aText );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::NewL
+// Two-phased constructor.
+// This is overloaded function for SpeechItem from database
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem* CNssSpeechItem::NewL( CNssContext& aContext,
+                                      CNssSpeechItemSrsPortal& aPortal,
+                                      CNssSpeechItemTrainer& aTrainer,
+                                      TUint32 aRuleID, 
+                                      const TDesC& aText )
+    {
+    CNssSpeechItem* self = NewLC( aContext, aPortal, aTrainer, aRuleID, 
+                                  aText );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::PlayL
+// Method to do play operation. In SI, this means synthesizing the name.
+// -----------------------------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult
+CNssSpeechItem::PlayL( MNssPlayEventHandler* aPlayEventHandler, TLanguage aLanguage )
+    {
+    if ( !iTtsData )
+        {
+        iTtsData = new (ELeave) TTtsData;
+        }
+    
+    iTtsData->iStyle.iLanguage = aLanguage;
+    
+    RUBY_DEBUG1( "CNssSpeechItem::PlayL lang id: %d", iTtsData->iStyle.iLanguage );
+    
+    // Verify for valid state
+    if (!(iState == TNssSpeechItemConstant::EIdle ||
+        iState == TNssSpeechItemConstant::ETrainComplete))
+        {
+        RUBY_DEBUG0( "CNssSpeechItem::PlayL - wrong state" );
+
+        return MNssSpeechItem::EVasUnexpectedRequest;
+        }
+    
+    // Verify for valid event handler
+    if ( aPlayEventHandler )
+        {
+        iPlayEventHandler = aPlayEventHandler;
+        }
+    else
+        {
+        return MNssSpeechItem::EVasInvalidParameter;
+        }
+    
+    TRAPD( err, DoPlayL() );
+    if ( err != KErrNone )
+        {
+        CleanPlayback();
+        return MNssSpeechItem::EVasPlayFailed;
+        }
+    
+    return MNssSpeechItem::EVasErrorNone;
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::PlayL
+// Method to do play operation. In SI, this means synthesizing the name.
+// -----------------------------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult 
+CNssSpeechItem::PlayL( MNssPlayEventHandler* aPlayEventHandler )
+    {
+    // Use UI language by default
+    // If synthesis engine does not support UI language for some reason,
+    // then language identification will be used instead
+    return PlayL( aPlayEventHandler, User::Language() );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DoPlayL
+// Starts playing. Assumes that all checks have been done earlier.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::DoPlayL()
+    {
+    TTtsData* d = iTtsData;
+
+    d->iTts = CNssTtsUtilityWrapper::NewL( *this );
+    d->iStyleID = d->iTts->AddStyleL( d->iStyle );
+
+    d->iParsedText = CTtsParsedText::NewL();
+    d->iParsedText->SetTextL( Text() );
+
+    d->iSegment.SetTextPtr( d->iParsedText->Text() );
+    d->iSegment.SetStyleID( d->iStyleID );
+
+    d->iParsedText->AddSegmentL( d->iSegment );
+
+    d->iTts->OpenAndPlayParsedTextL( *d->iParsedText );
+
+    iOldState = iState;
+    iState = TNssSpeechItemConstant::EPlayStart;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::CleanPlayback
+// Cleans playback and releases all memory.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::CleanPlayback()
+    {
+    TTtsData* d = iTtsData;
+
+    if ( d->iTts )
+        {
+        d->iTts->Stop();
+        d->iTts->Close();
+        }
+
+    delete d->iParsedText;
+    d->iParsedText = NULL;
+
+    delete d->iTts;
+    d->iTts = NULL;
+
+    delete iTtsData;
+    iTtsData = NULL;
+
+    iState = iOldState;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::MakePlayCallback
+// Makes callback to VAS client. Uses error status from TTS Utility to decide
+// callback and parameters.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::MakePlayCallback( TInt aResult )
+    {
+    MNssPlayEventHandler::TNssPlayResult res;
+
+    if ( aResult == KErrNone )
+        {
+        iPlayEventHandler->HandlePlayComplete( MNssPlayEventHandler::EVasErrorNone );
+        }
+    else{
+        switch( aResult )
+            {
+            case KErrNoMemory:
+                res = MNssPlayEventHandler::EVasPlayNoMemory;
+                break;
+
+            case KErrAccessDenied:
+                res = MNssPlayEventHandler::EVasPlayAccessDeny;
+                break;
+
+            default:
+                res = MNssPlayEventHandler::EVasPlayFailed;
+                break;
+            }
+        iPlayEventHandler->HandlePlayComplete( res );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::MapcCustomCommandEvent
+// TTS may call this method if we had used custom interfaces,
+// But we don't use custom interfaces.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::MapcCustomCommandEvent( TInt /*aEvent*/, TInt /*aError*/ )
+    {
+    // We don't expect to arrive here
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::MapcInitComplete
+// TTS calls this method to announce that it has initialized playing.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration )
+    {
+    if ( aError != KErrNone )
+        {
+        CleanPlayback();
+        MakePlayCallback( aError );
+        }
+    else
+        {
+        if ((iState == TNssSpeechItemConstant::EPlayStart) || 
+            (iState == TNssSpeechItemConstant::EPlayMemoryStart)
+            )
+            {
+            iPlayDuration = I64LOW( aDuration.Int64() );
+            iPlayEventHandler->HandlePlayStarted(iPlayDuration);
+            }
+        else
+            {
+            NotifyHandlerForUnexpectedEvent();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::MapcPlayComplete
+// TTS calls this method to announce that playing has finished.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::MapcPlayComplete( TInt aError )
+    {
+    CleanPlayback();
+    MakePlayCallback( aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::RecordL
+// Method to do record operation
+// -----------------------------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult 
+CNssSpeechItem::RecordL( MNssTrainVoiceEventHandler* aTrainVoiceEventHandler )
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::RecordL tagid [%d]", iTagId );
+    
+    // Verify for valid state
+    if (iState == TNssSpeechItemConstant::EIdle)
+        {
+        RUBY_DEBUG0( "CNssSpeechItem::RecordL - wrong state" );
+
+        return MNssSpeechItem::EVasUnexpectedRequest;
+        }
+    
+    // Verify for valid event handler
+    if (aTrainVoiceEventHandler)
+        {
+        iTrainVoiceEventHandler = aTrainVoiceEventHandler;
+        }
+    else
+        {
+        return MNssSpeechItem::EVasInvalidParameter;
+        }
+    
+    return MNssSpeechItem::EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::TrainVoiceL
+// Method to do train operation
+// For retraining, the previous utterance data need to be preserved for the 
+// delete operation later.
+// -----------------------------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult 
+CNssSpeechItem::TrainVoiceL(MNssTrainVoiceEventHandler* /*aTrainVoiceEventHandler*/)
+    {
+    // This is SI, don't even try to train by voice.
+    return MNssSpeechItem::EVasUnexpectedRequest;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::CancelL
+// Method to do cancel operation by calling the SpeechRecognitionUtility Cancel
+// method, and cleanup the SRS from the current transaction.
+// -----------------------------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult CNssSpeechItem::CancelL()
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::CancelL tagid [%d]", iTagId );
+
+    //Verify a transaction is in progress
+    if (iState == TNssSpeechItemConstant::EIdle)
+        {   
+        return MNssSpeechItem::EVasUnexpectedRequest;
+        }
+    
+    // Do the Clean up
+    CleanUp();
+    
+    return MNssSpeechItem::EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::TrainingCapabilities
+// Method to get the Training capabilities
+// -----------------------------------------------------------------------------
+//
+CArrayFixFlat<TNssVasCoreConstant::TNssTrainingCapability>* 
+CNssSpeechItem::TrainingCapabilities()
+    { 
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::RuleID
+// Method to get the rule ID
+// -----------------------------------------------------------------------------
+//
+TUint32 CNssSpeechItem::RuleID()
+    {
+    return iRuleID;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::SetRuleID
+// Method to set the rule ID
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::SetRuleID(TUint32 aRuleID)
+    {
+    iRuleID = aRuleID;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::TrainedType
+// Method to get the Trained Type
+// -----------------------------------------------------------------------------
+//
+TNssVasCoreConstant::TNssTrainedType CNssSpeechItem::TrainedType()
+    {
+    return iTrainedType;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::SetTrainedType
+// Method to set the Trained Type
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::SetTrainedType( TNssVasCoreConstant::TNssTrainedType aTrainType )
+    {
+    iTrainedType = aTrainType;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::Text
+// Method to get the Text
+// -----------------------------------------------------------------------------
+//
+TDesC& CNssSpeechItem::Text()
+    {
+    if ( iTrimmedText )
+        {
+        return *iTrimmedText;
+        }
+
+    if ( iText )
+        {
+        return *iText;
+        }
+    else
+        {
+        return (TDesC&)KNullDesC;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::RawText
+// Method to get the raw text
+// -----------------------------------------------------------------------------
+//
+TDesC& CNssSpeechItem::RawText()
+    {
+    if ( !iText )
+        {
+        return (TDesC&)KNullDesC;
+        }
+    
+    return *iText;
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::PartialTextL
+// Returns the part of the text which is indentified with the given ID
+// -----------------------------------------------------------------------------
+//
+HBufC* CNssSpeechItem::PartialTextL( const TDesC& aIdentifier )
+    {
+    if ( !iText )
+        {
+        User::Leave( KErrNotFound  );
+        }
+        
+    // Copy text for manipulation
+    HBufC* partialText = HBufC::NewL( iText->Length() );
+    CleanupStack::PushL( partialText );
+    *partialText = *iText;
+    TPtr partialTextPtr = partialText->Des();
+
+    // Find all separator characters from text
+    TInt markerIndex = partialTextPtr.Find( KNameSeparator );
+    TBool found( EFalse );
+    
+    while ( markerIndex != KErrNotFound )
+        {
+        // Separator marker should never be the last character of string
+        __ASSERT_ALWAYS( markerIndex <= partialTextPtr.Length(), User::Leave( KErrCorrupt ) );
+        
+        TBool removeThisPart( ETrue );
+        
+        if ( partialTextPtr.Mid( markerIndex + 1, 1 ) == aIdentifier )
+            {
+            found = ETrue;
+            removeThisPart = EFalse;
+            }
+        
+        if ( markerIndex == 0 )
+            {
+            // Remove separator marker & the next char (which is the identifier)
+            partialTextPtr.Delete( markerIndex, KTrainingIndexSize );
+            }
+        else
+            {
+            // Replace separator marker & the next char
+            partialTextPtr.Replace( markerIndex, KTrainingIndexSize, KEmptySpace );
+            }         
+        
+        if ( removeThisPart )
+            {
+            // Find next separator
+            TInt tempIndex = partialTextPtr.Find( KNameSeparator );
+            if ( tempIndex != KErrNotFound )
+                {
+                partialTextPtr.Delete( markerIndex, tempIndex - markerIndex );
+                }
+            else
+                {
+                partialTextPtr.Delete( markerIndex, partialTextPtr.Length() );
+                }
+            }
+        
+        // Find the next marker
+        markerIndex = partialTextPtr.Find( KNameSeparator );
+        }
+    
+    if ( found )
+        {
+        CleanupStack::Pop( partialText );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( partialText );
+        User::Leave( KErrNotFound );
+        }
+    
+    // Ownership transferred to client 
+    return partialText;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::SetTextL
+// Method to set the Text
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::SetTextL( const TDesC& aText )
+    {
+    if ( iText )
+        {
+        delete iText;
+        iText = NULL;
+        }
+    iText = aText.Left( KNssVasDbTagName ).AllocL();
+    
+    if ( iTrimmedText )
+        {
+        delete iTrimmedText;
+        iTrimmedText = NULL;
+        }
+    iTrimmedText = iText->AllocL();
+    
+    // Remove escape characters
+    for ( TInt iCounter = 0; iCounter < iTrimmedText->Length(); iCounter ++ )
+        {
+        if ( (*iTrimmedText)[iCounter] == KNameSeparator()[0] )
+            {
+            TPtr ptr( iTrimmedText->Des() );
+            if ( iCounter == iTrimmedText->Length() - 1 )
+                {
+                // Special handling for last char
+                ptr.Delete( iCounter, 1 );
+                }
+            else
+                {
+                ptr.Replace( iCounter, KTrainingIndexSize, KEmptySpace );
+                }
+            }
+        
+        }
+    TPtr ptr( iTrimmedText->Des() );
+    ptr.Trim();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::IsPlayingSupported
+// Method to query playing support
+// -----------------------------------------------------------------------------
+//
+TBool CNssSpeechItem::IsPlayingSupported()
+    {
+    if ( Text().Length() == 0 )
+        {
+        return EFalse;
+        }
+
+    return( ETrue );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::TrainTextL
+// Method to train a speech model from text
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem::TNssSpeechItemResult CNssSpeechItem::TrainTextL(
+                           MNssTrainTextEventHandler *aEventHandler,
+                           CNssTrainingParameters    *aTrainingParams )
+    {
+    
+    if ( /*aEventHandler == 0 ||*/ Text().Length() == 0 )
+        {
+        return CNssSpeechItem::EVasInvalidParameter;
+        }
+    
+    RUBY_DEBUG1( "CNssSpeechItem::TrainTextL tagig [%d]", iTagId );
+    
+    // Verify for the valid state
+    if (iState != TNssSpeechItemConstant::EIdle && 
+        iState != TNssSpeechItemConstant::ETrainComplete )
+        {
+        RUBY_DEBUG0( "CNssSpeechItem::TrainTextL - wrong state" );
+       
+        return MNssSpeechItem::EVasUnexpectedRequest;
+        }
+    
+    // Verify for the valid event handler
+    if ( !aEventHandler )
+        {
+        return MNssSpeechItem::EVasInvalidParameter;
+        }
+    
+    
+    iState = TNssSpeechItemConstant::ETrainStart;
+    
+    // To diffrentiate from voice trained tags
+    iTrainedType = TNssVasCoreConstant::EVasTrainText;
+    
+    // Training assigns rule ID from KInvalidRuleID to some correct value.
+    if ( iRuleID == KInvalidRuleID )
+        {
+        return( iTrainer.TrainTextDelayed( aEventHandler, aTrainingParams, *this, iContext ));
+        }
+    else
+        {
+        return( iTrainer.RetrainTextDelayed( aEventHandler, aTrainingParams, *this, iContext ));
+        }
+    
+    // Use delayed training to train the new phrase.
+    //return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::NSSBeginSaveToSrsL
+// Method to begin the transaction for saving the utterance data to SRS 
+// -----------------------------------------------------------------------------
+//
+MNssCoreSrsDBEventHandler::TNssSrsDBResult 
+CNssSpeechItem::NSSBeginSaveToSrs( MNssSaveTagClient* aSaveTagClient, CNssTag* aTag )
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::BeginSaveToSrsL tagid: [%d]", aTag->TagId() );
+    
+    // The state should be in the Training Complete
+    if (iState != TNssSpeechItemConstant::ETrainComplete)
+        {
+        RUBY_DEBUG0( "CNssSpeechItem::BeginSaveToSrsL - wrong state" );
+
+        return MNssCoreSrsDBEventHandler::EVasUnexpectedRequest;
+        }
+    
+    TInt ret = iTrainer.SaveTagDelayed( aSaveTagClient, *aTag );
+    
+    if ( ret != KErrNone )
+        {
+        return MNssCoreSrsDBEventHandler::EVasUnexpectedRequest;
+        }
+    
+    return MNssCoreSrsDBEventHandler::EVasSuccess;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::NSSBeginDeleteFromSrsL
+// Method to begin the transaction for saving the utterance data to SRS 
+// -----------------------------------------------------------------------------
+//
+MNssCoreSrsDBEventHandler::TNssSrsDBResult 
+CNssSpeechItem::NSSBeginDeleteFromSrs( MNssDeleteTagClient* aDeleteTagClient, CNssTag* aTag )
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::BeginDeleteFromSrsL tagid: [%d]", aTag->TagId() );
+    
+    // The state should be in the Training Complete
+    if (iState != TNssSpeechItemConstant::ETrainComplete &&
+        iState != TNssSpeechItemConstant::EIdle )
+        {
+        RUBY_DEBUG0( "CNssSpeechItem::BeginSaveToSrsL - wrong state" );
+        
+        return MNssCoreSrsDBEventHandler::EVasUnexpectedRequest;
+        }
+    
+    TInt ret = iTrainer.DeleteTagDelayed( aDeleteTagClient, *aTag );
+    
+    if ( ret != KErrNone )
+        {
+        return MNssCoreSrsDBEventHandler::EVasUnexpectedRequest;
+        }
+    
+    return MNssCoreSrsDBEventHandler::EVasSuccess;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::CommitSrsChanges
+// Method to to commit the transaction to the SRS.
+// This is a SYNCHRONOUS method
+// -----------------------------------------------------------------------------
+//
+MNssCoreSrsDBEventHandler::TNssSrsDBResult CNssSpeechItem::CommitSrsChanges()
+    {
+    // Not used
+    User::Panic( KSpeechItemPanic, __LINE__ );
+    return MNssCoreSrsDBEventHandler::EVasSuccess;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::CommitSrsChanges
+// Method to to roll back the transaction to the SRS.
+// This is a SYNCHRONOUS method
+// -----------------------------------------------------------------------------
+//
+MNssCoreSrsDBEventHandler::TNssSrsDBResult CNssSpeechItem::RollbackSrsChanges()
+    {
+    // Not used
+    User::Panic( KSpeechItemPanic, __LINE__ );
+    return MNssCoreSrsDBEventHandler::EVasSuccess;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::CopyUtteranceData
+// Method to copy utterance data from current data to transient data
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::CopyUtteranceData()
+    {
+    iTransientRuleID = iRuleID;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::MsruoEvent
+// Method to process the events from SRS utility object
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::MsruoEvent( TUid aEvent, TInt aResult )
+    {
+    RUBY_DEBUG2( "CNssSpeechItem::MsruoEvent, Event=0x%x, Result=%d", aEvent.iUid, aResult  );
+    
+    switch (aEvent.iUid)
+        {
+        
+        
+        //----------------------------------------------------------------------
+        //  Pre-Train Events 
+        //----------------------------------------------------------------------
+        
+        
+        case KUidAsrEventGetModelCountVal:
+            RUBY_ERROR0( "CNssSpeechItem::MsruoEvent KUidAsrEventAddRuleVal not expected" );
+            break;
+                        
+        case KUidAsrEventGetAvailableStorageVal:
+            if (aResult == KErrNone)
+                {
+                DoGetAvailableStorageCompleteEvent();
+                }
+            else
+                {
+                DoTrainFailEvent(aResult);
+                }
+            break;
+            
+            
+            //----------------------------------------------------------------------
+            //  Train Events 
+            //----------------------------------------------------------------------
+            
+        case KUidAsrEventTrainReadyVal:
+            RUBY_DEBUG0( "CNssSpeechItem::MsruoEvent - TrainReadyEvent" );
+            
+            // Always success, no need to verify aResult
+            if (iState == TNssSpeechItemConstant::ETrainStart)
+                {
+                iTrainVoiceEventHandler->HandleReadyToRecord();
+                }
+            else
+                {
+                NotifyHandlerForUnexpectedEvent();
+                }
+            break;
+            
+        case KUidAsrEventRecordStartedVal:
+            RUBY_DEBUG0( "CNssSpeechItem::MsruoEvent - RecordStartedEvent" );
+            
+            // Always success, no need to verify aResult
+            if (iState == TNssSpeechItemConstant::ETrainStart)
+                {
+                iTrainVoiceEventHandler->HandleRecordStarted();
+                }
+            else
+                {
+                NotifyHandlerForUnexpectedEvent();
+                }
+            break;
+        case KUidAsrEventEouDetectedVal:
+            RUBY_DEBUG0( "CNssSpeechItem::MsruoEvent - EouDetectedEvent" );
+            
+            // Always success, no need to verify aResult
+            if (iState == TNssSpeechItemConstant::ETrainStart)
+                {
+                iTrainVoiceEventHandler->HandleEouDetected();
+                }
+            else
+                {
+                NotifyHandlerForUnexpectedEvent();
+                }
+            break;
+            
+        case KUidAsrEventTrainVal:
+            if (aResult == KErrNone)
+                {
+                DoTrainCompleteEvent();
+                }
+            else
+                {
+                DoTrainFailEvent(aResult);
+                }
+            break;
+            
+            // currently this is only for fail cases
+        case KUidAsrEventRecordVal: 
+            RUBY_DEBUG0( "CNssSpeechItem::MsruoEvent - ERecordFailed" );
+
+            // If the result is success, do nothing
+            if (aResult != KErrNone)
+                {
+                DoTrainFailEvent(aResult);
+                }
+            break;
+            
+            
+            // End of Train Events 
+            
+            
+            //----------------------------------------------------------------------
+            //  Save Events 
+            //----------------------------------------------------------------------
+            
+        case KUidAsrEventAddRuleVal:
+            RUBY_ERROR0( "CNssSpeechItem::MsruoEvent KUidAsrEventAddRuleVal not expected" );
+            break;
+            
+            // End of Save to Srs Events  
+            
+            
+            //----------------------------------------------------------------------
+            //  Delete Events 
+            //----------------------------------------------------------------------
+            
+            
+        case KUidAsrEventRemoveRuleVal:
+            RUBY_ERROR0( "CNssSpeechItem::MsruoEvent KUidAsrEventRemoveRuleVal not expected" );
+            break;
+            
+            // End of Deleting from Srs Events  
+            
+            
+        default:
+            RUBY_DEBUG0( "CNssSpeechItem::MsruoEvent ERROR:default in switch" );
+            
+            NotifyHandlerForUnexpectedEvent();
+            break;
+    }
+}
+
+
+
+//  -------------------------       Play       -----------------------------  //
+
+//  -------------------------       Train       ----------------------------  //
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DoGetAvailableStorageCompleteEvent
+// Method to handle the "GetAvailableStorage" Event.
+// Verify the size of available storage, if it is not zero, continue with
+// the next operation to train.
+// If the size is zero, send the error message.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::DoGetAvailableStorageCompleteEvent()
+    {
+    // Obsolete
+    User::Panic( KSpeechItemPanic, __LINE__ );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DoTrainCompleteEvent
+// Method to process the Train event.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::DoTrainCompleteEvent()
+    {
+    RUBY_DEBUG0( "CNssSpeechItem::DoTrainCompleteEvent" );
+
+    if (iState == TNssSpeechItemConstant::ETrainStart)
+        {
+        iState = TNssSpeechItemConstant::ETrainComplete;
+        //iTrainVoiceEventHandler->HandleTrainComplete();
+        iTrainVoiceEventHandler->HandleTrainComplete( KErrNone );
+        }
+    else
+        {
+        NotifyHandlerForUnexpectedEvent();
+        }
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DoTrainFailEvent
+// Method to process the train failed events
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::DoTrainFailEvent( TInt aResult )
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::DoTrainFailEvent [%d]", aResult );
+    
+    if (iState != TNssSpeechItemConstant::ETrainStart)
+        {
+        NotifyHandlerForUnexpectedEvent();
+        return;
+        }
+    
+    CleanUp();
+    MNssTrainVoiceEventHandler::TNssTrainResult errorCode = DoTrainResult( aResult );
+    
+    iTrainVoiceEventHandler->HandleTrainComplete( errorCode );
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DoTrainResult
+// Method to process the Train result.
+// -----------------------------------------------------------------------------
+//
+MNssTrainVoiceEventHandler::TNssTrainResult 
+CNssSpeechItem::DoTrainResult( TInt aResult )
+    {
+    
+    MNssTrainVoiceEventHandler::TNssTrainResult errorCode;
+    
+    switch (aResult)
+        {
+        case KErrAsrNoSpeech:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - EVasTrainFailedNoSpeech" );
+           
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainFailedNoSpeech;
+            break;
+        case KErrAsrSpeechTooEarly:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - EVasTrainFailedTooEarly" );
+
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainFailedTooEarly;
+            break;
+        case KErrAsrSpeechTooLong:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - EVasTrainFailedTooLong" );
+            
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainFailedTooLong;
+            break;
+        case KErrAsrSpeechTooShort:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - KErrAsrSpeechTooShort" );
+
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainFailedTooShort;
+            break;
+        case KErrAccessDenied:      // this is temporary .....
+        case KErrDied:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - EVasTrainAccessDeny" );
+
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainAccessDeny;
+            break;
+        case KErrNoMemory:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - EVasTrainNoMemory" );
+
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainNoMemory;
+            break;
+        default:
+            RUBY_DEBUG0( "CNssSpeechItem::DoTrainResult - default" );
+
+            errorCode = MNssTrainVoiceEventHandler::EVasTrainFailed;
+            break;
+        }
+    
+    return errorCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DoSrsDBResult
+// Method to process the SRS DB result.
+// -----------------------------------------------------------------------------
+//
+MNssCoreSrsDBEventHandler::TNssSrsDBResult 
+CNssSpeechItem::DoSrsDBResult( TInt aResult )
+    {
+    
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult errorCode;
+    
+    switch (aResult)
+        {
+        case KErrDiskFull:
+            RUBY_DEBUG0( "CNssSpeechItem::DoSrsDBResult - KErrDiskFull" );
+            
+            errorCode = MNssCoreSrsDBEventHandler::EVasDiskFull;
+            break;
+        case KErrNoMemory:
+            RUBY_DEBUG0( "CNssSpeechItem::DoSrsDBResult - EVasNoMemory" );
+            
+            errorCode = MNssCoreSrsDBEventHandler::EVasNoMemory;
+            break;
+        default:
+            {
+            RUBY_DEBUG0( "CNssSpeechItem::DoSrsDBResult - default" );
+
+            switch ( iState )
+                {
+                case TNssSpeechItemConstant::ESaveToSrsStart:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasAddPronunciationFailed;
+                    break;
+                case TNssSpeechItemConstant::EAddPronounciationComplete:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasAddRuleFailed;
+                    break;
+                case TNssSpeechItemConstant::EDeleteToSrsStart:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasRemoveRuleFailed;
+                    break;
+                case TNssSpeechItemConstant::ERemoveRuleComplete:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasRemovePronunciationFailed;
+                    break;
+                case TNssSpeechItemConstant::ERemovePronounciationComplete:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasRemoveModelFailed;
+                    break;
+                default:
+                    errorCode = MNssCoreSrsDBEventHandler::EVasDBOperationError;
+                    break;
+                }
+            }
+        }
+    
+    return errorCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::NotifyHandlerForUnexpectedEvent
+// Method to notify the event handler for receiving the Unexpected Event
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::NotifyHandlerForUnexpectedEvent()
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::NotifyHandlerForUnexpectedEvent tagid: %d", iTagId );
+    
+    switch( iState )
+        {
+        case TNssSpeechItemConstant::EAddPronounciationComplete:
+        case TNssSpeechItemConstant::EAddRuleComplete:
+        case TNssSpeechItemConstant::ERemoveRuleComplete:
+        case TNssSpeechItemConstant::ERemovePronounciationComplete:
+        case TNssSpeechItemConstant::ERemoveModelCompelete:
+        case TNssSpeechItemConstant::EWaitForCommitChanges:
+            // Shouldn't happen, since all calls to SRS
+            // are done at CNssSpeechItemTrainer.
+            User::Panic( KSpeechItemPanic, __LINE__ );
+            
+            break;
+            
+        case TNssSpeechItemConstant::EPlayMemoryStart:
+        case TNssSpeechItemConstant::EPlayStart:
+            if (iPlayEventHandler)
+                {
+                CleanUp();
+                iPlayEventHandler->HandlePlayComplete(
+                    MNssPlayEventHandler::EVasPlayFailed);
+                }
+            break;
+            
+        case TNssSpeechItemConstant::ETrainStart:
+            if (iTrainVoiceEventHandler)
+                {
+                CleanUp();
+                iTrainVoiceEventHandler->HandleTrainComplete(
+                    MNssTrainVoiceEventHandler::EVasTrainFailed);
+                }
+            break;
+            
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::SetTagId
+// Method to set the Tag ID
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::SetTagId( TInt aTagId )
+    {
+    iTagId = aTagId;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::TagId
+// Method to return the Tag ID
+// -----------------------------------------------------------------------------
+//
+TInt CNssSpeechItem::TagId()
+    {
+    return iTagId;
+    }		
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::GrammarId
+// Method to return the Grammar ID
+// -----------------------------------------------------------------------------
+//
+TUint32 CNssSpeechItem::GrammarId()
+    {
+    return iContext.GrammarId();
+    }		
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::SetTrained
+// Method to set the Trained flag
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::SetTrained( TBool aTrained )
+    {
+    iTrained = aTrained;
+    }		
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::Trained
+// Method to return the Trained flag
+// -----------------------------------------------------------------------------
+//
+TBool CNssSpeechItem::Trained()
+    {
+    return iTrained;
+    }		
+
+// ---------------------------------------------------------
+// CNssSpeechItem::CopyL
+// creates a copy of this SpeechItem
+// ---------------------------------------------------------
+//
+CNssSpeechItem* CNssSpeechItem::CopyL( CNssContext* aContext )
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::CopyL tagid: %d", iTagId );
+    
+    CNssSpeechItem* copy = new (ELeave) CNssSpeechItem(*aContext, iPortal, iTrainer);
+    
+    if ( iText )
+        {
+        copy->iText = iText->Alloc();
+        }
+    if ( iTrimmedText )
+        {
+        copy->iTrimmedText = iTrimmedText->Alloc();
+        }
+    copy->iRuleID = iRuleID;
+    copy->iTransientRuleID = iTransientRuleID;
+    
+    copy->iTrainedType = iTrainedType;
+    copy->iState = iState;
+    copy->iContext = iContext;
+    copy->iPortal = iPortal;
+    copy->iPlayEventHandler = iPlayEventHandler;
+    //copy->iSrsDBEventHandler = iSrsDBEventHandler;
+    copy->iTrainVoiceEventHandler = iTrainVoiceEventHandler;
+    
+    copy->iTagId = iTagId;
+    copy->iTrained = iTrained;
+    copy->iPlayDuration = iPlayDuration;
+    
+    
+    // set the iSrsApi to NULL
+    // set the iRetry to NULL
+    
+    // set the state to Idle
+    copy->iState = TNssSpeechItemConstant::EIdle;
+    // set iRecover to False
+    copy->iRecover = EFalse;
+    
+    return copy;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItem::CleanUp
+// Method to do the clean up
+// ---------------------------------------------------------
+//
+void CNssSpeechItem::CleanUp()
+    {
+    RUBY_DEBUG1( "CNssSpeechItem::CleanUp tagid: %d", iTagId );
+
+    if ( iTtsData )
+        {
+        CleanPlayback();
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItem::DoRetry
+// Method to verify whether retry is already max out,
+// if not return ETrue, else return EFalse
+// ---------------------------------------------------------
+//
+TBool CNssSpeechItem::DoRetry()
+    {
+    if ( iRetry < KVASSpeechItemMaxRetry )
+        {
+        iRetry++;
+        return ETrue;
+        }
+    else
+        {
+        // Reset the retry count
+        iRetry = KVASSpeechItemResetRetry;
+        return EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItem::DelayedTrainingComplete
+// Updates the speech item, after SI training has been carried out.
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItem::DelayedTrainingComplete( TUint32 aRuleID )
+    {
+    SetRuleID( aRuleID );
+    
+    if ( aRuleID != KInvalidRuleID )
+        {
+        this->iTrainedType = TNssVasCoreConstant::EVasTrainText;
+        }
+    else
+        {
+        // Training failed; mark all invalid
+        SetRuleID( KInvalidRuleID );
+        
+        this->iTrainedType = TNssVasCoreConstant::EVasNotTrained;
+        }
+    
+    this->iTrained = ETrue;
+    this->iState = TNssSpeechItemConstant::ETrainComplete;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsData::TTtsData
+// Initializes everything to zero.
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItem::TTtsData::TTtsData() : iStyle(),
+                                       iStyleID( 0 ),
+                                       iSegment( 0 ),
+                                       iTts( NULL ),
+                                       iParsedText( NULL )
+    {
+    // Nothing
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvascspeechitembuilder.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSpeechItemBuilder provides methods to create SpeechItem object.
+*
+*/
+
+
+#include "nssvascspeechitembuilder.h"
+#include "rubydebug.h"
+
+// ---------------------------------------------------------
+// CNssSpeechItemBuilder::CNssSpeechItemBuilder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CNssSpeechItemBuilder::CNssSpeechItemBuilder()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemBuilder::ConstructL
+// Symbian 2nd phase constructor can leave.
+// This is overloaded function for SpeechItemBuilder from database
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItemBuilder::ConstructL( CNssVASDatabase *aDatabase )
+    {
+    // create the Srs Potal object
+    iPortal  = CNssSpeechItemSrsPortal::NewL();
+    iTrainer = CNssSpeechItemTrainer::NewL( aDatabase );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemBuilder::NewL
+// Two-phased constructor.
+// This is for new SpeechItemBuilder
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemBuilder* CNssSpeechItemBuilder::NewL( CNssVASDatabase *aDatabase )
+    {
+    RUBY_DEBUG_BLOCK( "CNssSpeechItemBuilder::NewL" );
+    
+    CNssSpeechItemBuilder* self = NewLC( aDatabase );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemBuilder::NewLC
+// Two-phased constructor.
+// This is overloaded function for SpeechItemBuilder from database
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemBuilder* CNssSpeechItemBuilder::NewLC( CNssVASDatabase *aDatabase )
+    {
+    CNssSpeechItemBuilder* self = new (ELeave) CNssSpeechItemBuilder();
+    CleanupStack::PushL( self );
+    self->ConstructL( aDatabase );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemBuilder::CreateEmptySpeechItem
+// Creates a SpeechItem given a Context and a Portal
+// ---------------------------------------------------------
+//
+CNssSpeechItem* CNssSpeechItemBuilder::CreateEmptySpeechItemL( CNssContext& aContext )
+    {
+    CNssSpeechItem *speechItem = CNssSpeechItem::NewL( aContext, *iPortal, *iTrainer );
+    speechItem->SetTagId( KNssVASDbDefaultValue );   //Identify as a new item
+    return speechItem;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemBuilder::CreateSpeechItem
+// Creates a SpeechItem given all data member values.
+// ---------------------------------------------------------
+//
+CNssSpeechItem* CNssSpeechItemBuilder::CreateSpeechItemL( CNssContext& aContext, 
+                                                          TUint32 aRuleID, 
+                                                          const TDesC& aText, 
+                                                          TInt aTagID,
+                               TNssVasCoreConstant::TNssTrainedType aTrainedType )
+    {
+    CNssSpeechItem *speechItem = CNssSpeechItem::NewL( aContext, *iPortal,
+                                                       *iTrainer, aRuleID, aText );
+    speechItem->SetTrainedType( aTrainedType );
+    speechItem->SetTagId( aTagID );   
+    return speechItem;
+    }
+
+
+// ---------------------------------------------------------
+// CNssSpeechItemBuilder::~CNssSpeechItemBuilder
+// Delete the SpeechItemBuilder object and set the Portal's 
+// state to Terminate.
+// The Builder does not delete the Portal, the Portal  
+// deletes itself.
+// ---------------------------------------------------------
+//
+CNssSpeechItemBuilder::~CNssSpeechItemBuilder()
+    {
+    RUBY_DEBUG0( "CNssSpeechItemBuilder::~CNssSpeechItemBuilder" );
+
+    if ( iPortal )
+        {
+        //set the SRS Portal's state to termination 
+        iPortal->SetTerminationState();
+        }
+    delete iTrainer;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvascspeechitemsrsportal.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSpeechItemSrsPortal provides the portal to the 
+*               SpeechRecognitionUtility object.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvascspeechitemsrsportal.h"
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::CNssSpeechItemSrsPortal
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemSrsPortal::CNssSpeechItemSrsPortal()
+    {
+    //Initialize data members
+    iState = TNssSpeechItemConstant::EIdle;
+    
+    iEnginePropertySet = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::~CNssSpeechItemSrsPortal
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemSrsPortal::~CNssSpeechItemSrsPortal()
+    {
+    RUBY_DEBUG0( "CNssSpeechItemSrsPortal::~CNssSpeechItemSrsPortal" );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemSrsPortal* CNssSpeechItemSrsPortal::NewL()
+    {
+    RUBY_DEBUG0( "CNssSpeechItemSrsPortal::NewL" );
+
+    CNssSpeechItemSrsPortal* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemSrsPortal* CNssSpeechItemSrsPortal::NewLC()
+    {
+    CNssSpeechItemSrsPortal* self = new (ELeave) CNssSpeechItemSrsPortal();
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::SetTerminationState
+// If there is no registered SpeechItem object, then delete myself,
+// else set the state to Termination State
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItemSrsPortal::SetTerminationState()
+    {
+    RUBY_DEBUG0( "CNssSpeechItemSrsPortal::SetTerminationState" );
+    
+    if ( !iSpeechItemCounter )
+        {
+        // delete myself
+        delete this;
+        }
+    else
+        {
+        iState = TNssSpeechItemConstant::ETerminate;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::Register
+// Increment the counter for SpeechItem object
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItemSrsPortal::Register()
+    {
+    //increment the counter
+    iSpeechItemCounter++;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::Deregister
+// Decrement the counter for SpeechItem, and check for Termination state
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItemSrsPortal::Deregister()
+    {
+    //decrement the counter
+    iSpeechItemCounter--;
+    
+    if (iState == TNssSpeechItemConstant::ETerminate)
+        {
+        SetTerminationState();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::GetTrainingCapability
+// Return the Training Capabilities
+// -----------------------------------------------------------------------------
+//
+CArrayFixFlat<TNssVasCoreConstant::TNssTrainingCapability>*  
+CNssSpeechItemSrsPortal::GetTrainingCapability()
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::IsEnginePropertySet
+// Return ETrue or EFalse
+// -----------------------------------------------------------------------------
+//
+TBool CNssSpeechItemSrsPortal::IsEnginePropertySet()
+    {
+    return iEnginePropertySet;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::SetEngineProperty
+// Set the Engine Property data members
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItemSrsPortal::SetEngineProperty( TInt aModelStorageCapacity, 
+                                                 TInt aMaxLoadableModels )
+    {
+    iModelStorageCapacity = aModelStorageCapacity;
+    iMaxLoadableModels = aMaxLoadableModels;
+    
+    // Set the EnginePropertySet flag
+    iEnginePropertySet = ETrue;     
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::ModelStorageCapacity
+// Return the Model Storage capacity 
+// -----------------------------------------------------------------------------
+//
+TInt CNssSpeechItemSrsPortal::ModelStorageCapacity()
+    {
+    return iModelStorageCapacity;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::MaxLoadableModels
+// Return the Maximum Loadable Models 
+// -----------------------------------------------------------------------------
+//
+TInt CNssSpeechItemSrsPortal::MaxLoadableModels()
+    {
+    return iMaxLoadableModels;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemSrsPortal::operator=
+// Overloaded operator =
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemSrsPortal& CNssSpeechItemSrsPortal::operator=( 
+                            const CNssSpeechItemSrsPortal& aPortal )
+    {
+    if ( this != &aPortal )
+        {
+        iState = aPortal.iState;
+        iSpeechItemCounter = aPortal.iSpeechItemCounter;
+        iEnginePropertySet = aPortal.iEnginePropertySet;
+        iModelStorageCapacity = aPortal.iModelStorageCapacity;
+        iMaxLoadableModels = aPortal.iMaxLoadableModels;
+        }
+    
+    return *this;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvascspeechitemtrainer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1965 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSpeechItemTrainer provides methods to train, save
+*               and delete CNssSpeechItem objects in large quantities.
+*
+*/
+
+
+/* Here is a state machine for training:
+*
+* Summary:
+*
+* Idle state
+*     |
+* Waiting state     <-------------------
+*     |                                | (loop back to waiting state)
+* ###################################  |
+* # IF NEEDED: Create lexicon state #  |
+* #            |                    #  |
+* # IF NEEDED: Create grammar state #---
+* #            |                    #
+* #       Training state            #
+* ###################################
+*     |
+* Idle state
+*
+*
+*
+* State: Idle state
+* Event: A client calls TrainTextL, 
+* Action:This induces a call to CNssSpeechItemTrainer::TrainTextDealyed().
+*
+*        The basic idea of _delayed_training_ is that several training calls
+*        are piled up before taking action. When a large number of names is
+*        trained at a time, the economies of scale are considerable.
+*
+*        So, TrainTextDelayed() adds the name to the to-be-trained list,
+*        and starts a _delay_timer_. When this delay timer has finished, the
+*        actual training starts.
+* Transition: Idle state -> Waiting state
+*
+*
+* State: Waiting state
+* Event: A client calls TrainTextL.
+* Action:The function adds the name to the to-be-trained list, and
+*        resets the timer
+*        (background: In contact synchronization via PC Suite, names are added
+*         every 1/2 seconds. We want to keep piling the names  as long as
+*         new names keep coming. Since we can't wait 50 seconds
+*         before training, the only reasonable solution is to reset the timer
+*         every time a new name arrives)
+* Transition: Waiting state -> Waiting state
+*
+*
+* State: Waiting state
+* Event: Timer finishes doing time.
+* Action:Check the preparations for training:
+*         * Has the grammar for the context been created?
+*         * Has the lexicon for the context been created?
+* CASE: Preconditions OK
+*       Action    : Send async AddVoiceTags call
+*       Transition: Waiting state -> Training state
+*
+* State: Training state
+* Event: Training finished
+* Action: Save the newly created Rule IDs to the speech items.
+*         Commit the database.
+*         Make the callbacks (success or failure) to the client.
+*
+* Transition: Check if new names were piled during traning.
+*         YES: Training state -> Waiting state
+*         NO : Training state -> Idle state
+*
+*/
+
+#include "srsfbldvariant.hrh"
+#include "nssvascspeechitemtrainer.h"
+#include "nssvasctrainingparameters.h"
+#include "nssvascvasdatabase.h"
+#include "nssvasmsavetagclient.h"
+#include "nssvasmdeletetagclient.h"
+
+#include "rubydebug.h"
+
+#include <badesca.h>
+
+#ifdef _DEBUG
+    // Used in UDEB only
+    _LIT( KSpeechItemTrainerPanic, "VasCSpeechItemTrainer" );
+#endif  // _DEBUG
+
+#define DEBUGPANIC User::Panic( KSpeechItemTrainerPanic, __LINE__ )
+#define REACT( a, b ) if ( a != KErrNone ) { b; }
+#define CHECK_NOT_NULL( a ) \
+    if ( !(a) ) \
+        { \
+        return MNssSpeechItem::EVasTrainFailed; \
+        }
+#define ALLOWED_STATES( a, b, c ) \
+    if ( iState != a && iState != b && iState != c ) \
+        { \
+        return MNssSpeechItem::EVasTrainFailed; \
+        } 
+
+// tags are buffered in the buffer that grows with this granularity
+const TInt KTagBufferGranularity = 100;
+
+// rule ids are buffered in the buffer that grows with this granularity
+const TInt KRuleIdBufferGranularity = 50;
+
+// tag ids are buffered in the buffer that grows with this granularity
+const TInt KRemoveTagIdBufferGranularity = 50;
+
+// Granularity for the array of words per sinde phrase
+const TInt KSindeWordArrayGranularity = 2;
+
+
+// Local function declarations
+TInt EnforceRuleIdCountInvariant( RArray<TUint32>& aArray, TInt aCount );
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::CNssSpeechItemTrainer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CNssSpeechItemTrainer::CNssSpeechItemTrainer( CNssVASDatabase* aDatabase )
+: iDatabase( aDatabase ),
+  iSpeechItemBuffer       ( NULL ),
+  iSpeechItemTrainingBuffer( NULL ),
+  iGrammarIdBuffer        ( NULL ),
+  iGrammarIdDeletingBuffer( NULL ),
+  iTagBuffer(NULL)
+    {
+    // empty
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemTrainer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// This is overloaded function for SpeechItemTrainer from database
+// -----------------------------------------------------------------------------
+//
+void CNssSpeechItemTrainer::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK("CNssSpeechItemTrainer::ConstructL");
+    iActionTracker = CNssTrainingActionTracker::NewL( *this );
+
+    // Create buffer for grouping phrases in training
+    iSpeechItemBuffer = new(ELeave)RPointerArray<CNssSpeechItem>;
+    iSpeechItemTrainingBuffer = 0; // No name being currently trained.
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemTrainer::NewL
+// Two-phased constructor.
+// This is for new SpeechItemTrainer
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemTrainer* CNssSpeechItemTrainer::NewL( CNssVASDatabase* aDatabase )
+    {
+    RUBY_DEBUG_BLOCK( "CNssSpeechItemTrainer::NewL" );
+
+    CNssSpeechItemTrainer* self = NewLC( aDatabase );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssSpeechItemTrainer::NewLC
+// Two-phased constructor.
+// This is overloaded function for SpeechItemTrainer from database
+// -----------------------------------------------------------------------------
+//
+CNssSpeechItemTrainer* CNssSpeechItemTrainer::NewLC( CNssVASDatabase* aDatabase )
+    {
+    CNssSpeechItemTrainer* self
+        = new (ELeave) CNssSpeechItemTrainer( aDatabase );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::~CNssSpeechItemTrainer
+// Delete the SpeechItemTrainer object and set the Portal's 
+// state to Terminate.
+// The Trainer does not delete the Portal, the Portal  
+// deletes itself.
+// ---------------------------------------------------------
+//
+CNssSpeechItemTrainer::~CNssSpeechItemTrainer()
+    {
+    RUBY_DEBUG0( "CNssSpeechItemTrainer::~CNssSpeechItemTrainer" );
+
+    delete iActionTracker;
+
+
+    // Buffer for grouping the MNssSpeechItems for efficient training.
+    if ( iSpeechItemBuffer )
+        {
+        iSpeechItemBuffer->Reset();
+        delete iSpeechItemBuffer;
+        }
+
+    // Names, which are being trained by CSISpeechRecognitionUtility.
+    if ( iSpeechItemTrainingBuffer )
+        {
+        iSpeechItemTrainingBuffer->Reset();
+        delete iSpeechItemTrainingBuffer;
+        }
+
+    // This buffer is sent to SRS Utility. Contains: The recognition phrase split into subwords.
+    iPhraseArray.ResetAndDestroy();
+
+    // Training parameters
+    delete iTrainingParams;
+
+    // Context
+    delete iContext;
+
+    // Rule ID array. Return values from AddVoiceTags() are placed here.
+    if ( iRuleIDArray )
+        {
+        iRuleIDArray->Close();
+        delete iRuleIDArray;
+        }
+      
+    if ( iDeleteRuleIDArray )
+    	{
+        RUBY_DEBUG0( "CNssSpeechItemTrainer::~CNssSpeechItemTrainer Deleting iDeleteRuleIDArray" );
+    	iDeleteRuleIDArray->Close();
+    	delete iDeleteRuleIDArray;
+    	}
+
+    // Handle to speech services
+    if ( iSrsApi )
+        {
+        iSrsApi->CancelUtility();
+        delete iSrsApi;
+        iSrsApi = NULL;
+        }
+
+    // The tags to be saved: Owned by client
+    // RPointerArray<CNssTag> *iTagBuffer;
+    if ( iTagBuffer )
+        {
+        iTagBuffer->Reset();
+        delete iTagBuffer;
+        iTagBuffer = 0;
+        }
+
+    if ( iGrammarIdBuffer )
+        {
+        iGrammarIdBuffer->Reset();
+        delete iGrammarIdBuffer;
+        iGrammarIdBuffer = 0;
+        }
+
+    if ( iGrammarIdDeletingBuffer )
+        {
+        iGrammarIdDeletingBuffer->Reset();
+        delete iGrammarIdDeletingBuffer;
+        iGrammarIdDeletingBuffer = 0;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::RetrainTextDelayed
+// Does delayed retraining.
+// ---------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult CNssSpeechItemTrainer::RetrainTextDelayed(
+    MNssTrainTextEventHandler* aEventHandler,
+	CNssTrainingParameters*    aTrainingParams,
+    CNssSpeechItem&            aSpeechItem,
+    CNssContext&               aContext)
+    {
+    RUBY_DEBUG0( "CNssSpeechItemTrainer::RetrainTextDelayed" );
+
+    // Check parameters: 
+    // callback 
+    CHECK_NOT_NULL( aEventHandler );
+
+    // phrase to be trained
+    CHECK_NOT_NULL( aSpeechItem.Text().Length() );
+
+    // Check state
+    ALLOWED_STATES( EStateIdle, ERetrainStateWaiting, ERetrainStateRetraining );
+
+    // Check event handler
+    if ( !iTrainEventHandler )
+        {
+        iTrainEventHandler = aEventHandler;
+        }
+    else if ( iTrainEventHandler != aEventHandler )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // The training parameters and the context 
+    // must be the same for all in the buffer.
+    TRAPD( error,
+        if ( !CheckTrainingParametersL( aTrainingParams ) ||
+             !CheckContext( aContext ) )
+            {
+            return( MNssSpeechItem::EVasTrainFailed );
+            }
+         );
+    if ( error != KErrNone )
+        {
+        return MNssSpeechItem::EVasTrainFailed;
+        }
+
+    // Buffer the training request
+
+    // Allocate buffer, if not done earlier
+    if ( !SpeechItemBufferNeeded() )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // If this is the first tag, save Lexicon ID and Grammar ID.
+    if ( iSpeechItemBuffer->Count() == 0 )
+        {
+        iLexiconId = aContext.LexiconId();
+        iGrammarId = aContext.GrammarId();
+        }
+    else
+        {
+        // The tags after the first one must have the same Gramamr ID & Lexicon ID.
+        if ( iLexiconId != aContext.LexiconId() ||
+            iGrammarId != aContext.GrammarId() )
+            {
+            return( MNssSpeechItem::EVasTrainFailed );
+            }
+        }
+
+    // Add request to buffer
+    TInt ret = iSpeechItemBuffer->Append( &aSpeechItem );
+
+    if ( ret != KErrNone )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // Restart timer. When the timer has waited for a defined period, the names
+    // get retrained. Timer is reseted every time RetrainTextDelayed is called.
+    //
+    // Retraining in groups is more efficient. The delay ensures this grouping.
+    switch( iState )
+        {
+        case ERetrainStateRetraining:
+            // Wait for the retraining to finish before acting.
+            break;
+
+        case EStateIdle:
+            SetState( ERetrainStateWaiting );
+            RestartTimer();
+            break;
+
+        case ERetrainStateWaiting:
+            RestartTimer();
+            break;
+
+        default:
+            return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    return( MNssSpeechItem::EVasErrorNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SaveTagDelayed
+// Does delayed saving.
+// ---------------------------------------------------------
+//
+TInt CNssSpeechItemTrainer::SaveTagDelayed(
+    MNssSaveTagClient* aSaveTagClient,
+    CNssTag& aTag )
+    {
+    RUBY_DEBUG0( "CNssSpeechItemTrainer::SaveTagDelayed" );
+
+    // Check internal state: Must not be training
+    if ( this->iState != EStateIdle &&
+         this->iState != ESaveStateWaiting &&
+         this->iState != ESaveStateSaving )
+        {
+        return( KErrNotReady );
+        }
+
+    // Check arguments
+    if ( aSaveTagClient == 0  )
+        {
+        return KErrArgument;
+        }
+
+    if ( !((CNssSpeechItem*)aTag.SpeechItem())->Trained() )
+        {
+        return KErrNotReady;
+        }
+
+    // The event handler must be the same for all group-saved tags
+    if ( !iSaveEventHandler )
+        {
+        iSaveEventHandler = aSaveTagClient;
+        }
+    else if ( aSaveTagClient != iSaveEventHandler )
+        {
+        return KErrArgument;
+        }
+
+    // Buffer the saving request
+
+    // Allocate buffer, if not done earlier
+    if ( !iTagBuffer )
+        {
+        iTagBuffer = new RPointerArray<CNssTag>( KTagBufferGranularity );
+
+        if ( !iTagBuffer )
+            {
+            return KErrNoMemory;
+            }
+        }
+
+    // Add request to buffer
+    TInt ret = iTagBuffer->Append( &aTag );
+
+    if ( ret != KErrNone )
+        {
+        return( ret );
+        }
+
+    // Restart timer. When the timer has waited for a defined period, the names
+    // get saved. Timer is reseted every time SaveTagDelayed is called.
+    //
+    // Saving in groups is more efficient. The delay ensures this grouping.
+    switch( iState )
+        {
+        case ESaveStateSaving:
+            // Wait for the training to finish before acting.
+            break;
+
+        case EStateIdle:
+            SetState( ESaveStateWaiting );
+            RestartTimer();
+            break;
+
+        case ESaveStateWaiting:
+            RestartTimer();
+            break;
+
+        default:
+            return( KErrCorrupt );
+        }
+
+    return( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DeleteTagDelayed
+// Does delayed deleting.
+// (other items were commented in a header)
+// ---------------------------------------------------------
+//
+TInt CNssSpeechItemTrainer::DeleteTagDelayed(
+    MNssDeleteTagClient* aDeleteTagClient,
+    CNssTag& aTag )
+    {
+    RUBY_DEBUG0( "CNssSpeechItemTrainer::DeleteTagDelayed" );
+
+    // Check internal state: Must not be doing something else
+    ALLOWED_STATES( EStateIdle, EDeleteStateWaiting, EDeleteStateDeleting );
+
+    // Check arguments
+    CHECK_NOT_NULL( aDeleteTagClient );
+
+    // The event handler must be the same for all group-deleted tags
+    if ( !iDeleteEventHandler )
+        {
+        iDeleteEventHandler = aDeleteTagClient;
+        }
+    else if ( aDeleteTagClient != iDeleteEventHandler )
+        {
+        return KErrArgument;
+        }
+
+    // Buffer the deleting request
+
+    // Allocate buffer, if not done earlier
+    if ( !SpeechItemBufferNeeded() ||
+         !GrammarIdBufferNeeded()  )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // If this is the first tag, save the grammar id.
+    if ( iSpeechItemBuffer->Count() == 0 )
+        {
+        iGrammarId = ((CNssContext*)aTag.Context())->GrammarId();
+        if ( !iDeleteRuleIDArray ) 
+        	{
+        	iDeleteRuleIDArray = new RArray<TUint32>;
+        	if( !iDeleteRuleIDArray ) 
+        		{
+        		return KErrNoMemory;
+	        	}
+        	// no deletion. iDeleteRuleIDArray might still be used
+        	}
+//        delete iDeleteRuleIDArray; // if any
+//        iDeleteRuleIDArray = new RArray<TUint32>;
+        }
+    else
+        {
+        // subsequent tags must have the same grammar id.
+        if ( iGrammarId != ((CNssContext*)aTag.Context())->GrammarId() )
+            {
+            return( MNssSpeechItem::EVasTrainFailed );
+            }
+        }
+
+    // Add request to buffer
+    // iSpeechItemBuffer will be copied into iSpeechItemTrainingBuffer later and
+    // iSpeechItemTrainingBuffer will be used to delete tags from the VAS DB
+    TInt ret = iSpeechItemBuffer->Append( (CNssSpeechItem*)aTag.SpeechItem() );
+    if ( ret != KErrNone )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    RUBY_DEBUG1( "CNssSpeechItemTrainer::DeleteTagDelayed Adding [%d] to iDeleteRuleIDArray", 
+        ( ( CNssSpeechItem* )aTag.SpeechItem() )->RuleID() );
+
+    ret = iDeleteRuleIDArray->Append( ( ( CNssSpeechItem* )aTag.SpeechItem() )->RuleID() );
+
+    if ( ret != KErrNone )
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::DeleteTagDelayed Adding to iDeleteRuleIDArray failed with error [%d]", ret );
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // Restart timer. When the timer has waited for a defined period, the names
+    // get deleted. Timer is reseted every time DeleteDagDelayed is called.
+    //
+    // Deleting in groups is more efficient. The delay ensures this grouping.
+    switch( iState )
+        {
+        case EDeleteStateDeleting:
+            // Wait for the training to finish before acting.
+            break;
+
+        case EStateIdle:
+            SetState( EDeleteStateWaiting );
+            RestartTimer();
+            break;
+
+        case EDeleteStateWaiting:
+            RestartTimer();
+            break;
+
+        default:
+            return( KErrCorrupt );
+        }
+
+    return( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::TrainTextDelayed
+// Does delayed training.
+// ---------------------------------------------------------
+//
+MNssSpeechItem::TNssSpeechItemResult CNssSpeechItemTrainer::TrainTextDelayed(
+    MNssTrainTextEventHandler* aEventHandler,
+	CNssTrainingParameters*    aTrainingParams,
+    CNssSpeechItem&            aSpeechItem,
+    CNssContext&               aContext)
+    {
+    RUBY_DEBUG0( "CNssSpeechItemTrainer::TrainTextDelayed" );
+
+    // Check parameters: 
+    // callback
+    CHECK_NOT_NULL( aEventHandler );
+
+    // Text is not null
+    CHECK_NOT_NULL( aSpeechItem.Text().Length() );
+
+    // Check state
+    ALLOWED_STATES( EStateIdle, ETrainStateWaiting, ETrainStateTraining );
+
+    // Check event handler
+    if ( !iTrainEventHandler )
+        {
+        iTrainEventHandler = aEventHandler;
+        }
+    else if ( iTrainEventHandler != aEventHandler )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // The training parameters and the context 
+    // must be the same for all in the buffer.
+    TRAPD( error,
+        if ( !CheckTrainingParametersL( aTrainingParams ) ||
+             !CheckContext( aContext ) )
+            {
+            return( MNssSpeechItem::EVasTrainFailed );
+            }
+        );
+    if ( error != KErrNone )
+        {
+        return MNssSpeechItem::EVasTrainFailed;
+        }
+
+    // Buffer the training request
+    if ( !SpeechItemBufferNeeded() )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    TInt ret = iSpeechItemBuffer->Append( &aSpeechItem );
+
+    if ( ret == KErrNoMemory )
+        {
+        return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    // Restart timer. When the timer has waited for a defined period, the names
+    // get trained. Timer is reseted every time TrainTextDelayed is called.
+    //
+    // Training in groups is more efficient. The delay ensures this grouping.
+    switch( iState )
+        {
+        case ETrainStateTraining:
+            // Wait for the training to finish before acting.
+            break;
+
+        case EStateIdle:
+            SetState( ETrainStateWaiting );
+            RestartTimer();
+            break;
+
+        case ETrainStateWaiting:
+            RestartTimer();
+            break;
+
+        default:
+            return( MNssSpeechItem::EVasTrainFailed );
+        }
+
+    return( MNssSpeechItem::EVasErrorNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::HandleTrainError
+// Called if AddVoiceTags() call failed.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::HandleTrainError( RPointerArray<CNssSpeechItem>*& anItemArray )
+    {
+    RUBY_DEBUG0( "CNssSpeechItemTrainer::HandleTrainError" );
+
+    TInt count = anItemArray->Count();
+
+    CleanUpTraining();
+
+    // Announce the error to the client
+    for( TInt k=0; k<count; k++ )
+        {
+        iTrainEventHandler->HandleTrainComplete( KErrGeneral );
+        
+        }
+    iTrainEventHandler = NULL;
+    // All the errors reported, everything was rolled back
+    // Back tothe idle state
+    SetState( EStateIdle );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::CleanUpTrianing
+// Cleans memory allocated by training.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::CleanUpTraining(void)
+    {
+    // Delete buffered names
+    if ( iSpeechItemTrainingBuffer )
+        {
+        iSpeechItemTrainingBuffer->Close();
+        }
+    delete iSpeechItemTrainingBuffer;
+    iSpeechItemTrainingBuffer = 0;
+
+    // Delete parameters common to all names
+    delete iTrainingParams;
+    iTrainingParams = 0;
+
+    delete iContext;
+    iContext = 0;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoTrainTextDelayed
+// Starts training tags. Sends the AddVoiceTags() call.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DoTrainTextDelayed()
+    {
+    SetState( ETrainStateTraining );
+
+    // Move from speech item buffers from filling state to processing state.
+
+    // names to be trained + names to be retrained
+    iSpeechItemTrainingBuffer = iSpeechItemBuffer;
+    iSpeechItemBuffer = 0;
+
+    // Initialize iSrsApi (speech recognition utility)
+    TInt error = CreateSrsApi();
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::DoTrainTextDelayed Creating SrsApi failed. Error [%d]", error );
+        HandleTrainError( iSpeechItemTrainingBuffer );
+        }
+    else 
+       	{
+        	
+	    __ASSERT_DEBUG( iContext->LexiconId() != KInvalidLexiconID, 
+	                    User::Panic( KSpeechItemTrainerPanic, KErrCorrupt ) );
+	    __ASSERT_DEBUG( iContext->GrammarId() != KInvalidGrammarID, 
+	                    User::Panic( KSpeechItemTrainerPanic, KErrCorrupt ) );
+
+	    // Extract texts from speech items to phrase array.
+
+	    // iPhraseArray is an array of arrays: 
+	    // 
+	    //        |-- firstname1
+	    //  tag1 -|-- lastname1
+	    //
+	    //  tag2 -|-- firstname2
+	    //        |-- lastname2
+	    iPhraseArray.ResetAndDestroy();
+
+	    // Convert speech item array to the format understood by the Utility.
+	    TInt ret = SpeechItems2Phrases( *iSpeechItemTrainingBuffer, iPhraseArray );
+	    if ( ret != KErrNone )
+	        {
+	        SendTrainingCallbacks( ret );
+	        /** @todo reengineer into signle return path
+	            @todo check that everything is cleaned up before the return */
+	        return;
+	        }
+
+	    // Initialize Rule ID array. The Utility puts the IDs
+	    // of newly created rules here.
+	    // Not using (ELeave) since this is non-leaving function (trapping of (ELeave) is not allowed).
+	    iRuleIDArray = new RArray<TUint32>;
+
+	    if ( iRuleIDArray == 0 )
+	        {
+            RUBY_DEBUG0( "CNssSpeechItemTrainer::DoTrainTextDelayed iRuleIDArray == 0" );
+
+	        HandleTrainError( iSpeechItemTrainingBuffer );
+	        }
+	    else
+	       	{
+            RUBY_DEBUG1( "CNssSpeechItemTrainer::Calling AddVoiceTags (%d names)", 
+                         iPhraseArray.Count() ); 
+	       	// allocation succeeded
+
+            TRAPD( errSinde, const RArray<RTrainingLanguageArray>& languages = 
+                                        iTrainingParams->SindeLanguagesL() );
+            
+            if ( errSinde == KErrNone )
+                {
+#ifdef __SINDE_TRAINING
+                TRAP_IGNORE(
+                    const RArray<RTrainingLanguageArray>& languages = 
+                                        iTrainingParams->SindeLanguagesL();
+    		        ret = iSrsApi->AddVoiceTags( iPhraseArray,
+                                                 languages,
+                                                 (TSILexiconID)iContext->LexiconId(),
+                                                 (TSIGrammarID)iContext->GrammarId(),
+                                                 *iRuleIDArray );
+                ); // TRAP_IGNORE
+#endif // __SINDE_TRAINING
+                }
+            else
+                {
+                // Use the old style of training if SINDE languages are not available
+		        ret = iSrsApi->AddVoiceTags( iPhraseArray,
+                                             iTrainingParams->Languages(),
+                                             (TSILexiconID)iContext->LexiconId(),
+                                             (TSIGrammarID)iContext->GrammarId(),
+                                             *iRuleIDArray );
+                }
+
+		    // error -> cleanup
+		    if ( ret != KErrNone )
+		        {
+                RUBY_DEBUG1( "CNssSpeechItemTrainer::AddVoiceTags failed(%d)", ret );
+
+		        HandleTrainComplete( ret );
+		        }  // if ret is not KErrNone
+	       	}  // if iRuleIDArray allocation succeeded
+       	}  // if SRS API was created successfully
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoRetrainTextDelayed
+// Starts the 1st phase of retraining,
+// which is removing old rules.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DoRetrainTextDelayed()
+    {
+    __ASSERT_DEBUG( iSpeechItemBuffer != 0, DEBUGPANIC );
+
+    SetState( ERetrainStateRetraining );
+
+    // Move speech item buffer from filling state to processing state.
+    iSpeechItemTrainingBuffer = iSpeechItemBuffer;
+    iSpeechItemBuffer = 0;
+
+    // Initialize iSrsApi (speech recognition utility)
+    TInt error = CreateSrsApi();
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::DoRetrainTextDelayed Creating SrsApi failed. Error [%d]", error );
+        HandleTrainError( iSpeechItemTrainingBuffer );
+        return;
+        }
+
+    // Start deleting tags
+    iTagDeleteCounter = 0;
+    DeleteNextTag();
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoRetrainAddVoiceTags
+// Phase 2 of retraining: Add voice tags
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DoRetrainAddVoiceTags()
+    {
+    SetState( ERetrainStateRetraining );
+
+    // Move from speech item buffers from filling state to processing state.
+
+    __ASSERT_DEBUG( iContext->LexiconId() != KInvalidLexiconID, 
+                    User::Panic( KSpeechItemTrainerPanic, KErrCorrupt ) );
+    __ASSERT_DEBUG( iContext->GrammarId() != KInvalidGrammarID, 
+                    User::Panic( KSpeechItemTrainerPanic, KErrCorrupt ) );
+
+    // Extract texts from speech items to phrase array.
+
+    iPhraseArray.ResetAndDestroy();
+
+    // Convert speech item array to the format understood by the Utility.
+    TInt ret = SpeechItems2Phrases( *iSpeechItemTrainingBuffer, iPhraseArray );
+    if ( ret != KErrNone )
+        {
+        SendTrainingCallbacks( ret );
+        return;
+        }
+
+    // Allocate Rule ID array. The Utility fills this array.
+    // When the utility trans a name, it attaches a Rule ID to the name.
+    iRuleIDArray = new RArray<TUint32>;
+    if ( iRuleIDArray == 0 )
+        {
+        SendTrainingCallbacks( KErrNoMemory );
+        return;
+        }
+
+    RUBY_DEBUG1( "CNssSpeechItemTrainer::Retrain Calling AddVoiceTags (%d names)", 
+                 iPhraseArray.Count() );
+
+    TRAPD( errSinde, const RArray<RTrainingLanguageArray>& languages = 
+                                        iTrainingParams->SindeLanguagesL() );
+            
+    if ( errSinde == KErrNone )
+        {
+#ifdef __SINDE_TRAINING        	
+        TRAP_IGNORE(
+            const RArray<RTrainingLanguageArray>& languages = 
+                                iTrainingParams->SindeLanguagesL();
+	        ret = iSrsApi->AddVoiceTags( iPhraseArray,
+                                         languages,
+                                         (TSILexiconID)iContext->LexiconId(),
+                                         (TSIGrammarID)iContext->GrammarId(),
+                                         *iRuleIDArray );
+        ); // TRAP_IGNORE
+#endif // __SINDE_TRAINING
+        }
+    else
+        {
+        // Use the old style of training if SINDE languages are not available
+        ret = iSrsApi->AddVoiceTags( iPhraseArray,
+                                     iTrainingParams->Languages(),
+                                     (TSILexiconID)iLexiconId,
+                                     (TSIGrammarID)iGrammarId,
+                                     *iRuleIDArray );
+        }
+
+    // error -> cleanup
+    if ( ret != KErrNone )
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::Retrain ERROR: AddVoiceTags(%d)", ret );
+
+        SendTrainingCallbacks( ret );
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoRetrainAddVoiceTags
+// After the new tags have been trained:
+// Announce the new rule IDs for speech items,
+// and update the rule IDs to the VAS database.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::HandleRetrainComplete( TInt aResult )
+    {
+    RUBY_DEBUG1( "CNssSpeechItemTrainer::HandleTrainComplete(%d)", aResult );
+
+    // iRuleIdArray contains the rule IDs of the newly trained tags.
+    // The following call makes sure that
+    // iRuleIdArray.Count() == iSpeechItemTrainingBuffer.Count().
+    if ( EnforceRuleIdCountInvariant( *iRuleIDArray, 
+                        iSpeechItemTrainingBuffer->Count() ) != KErrNone )
+        {
+        SendTrainingCallbacks( KErrNoMemory );
+        }
+    else
+        {
+        TInt count = iSpeechItemTrainingBuffer->Count();
+        RArray<TNssSpeechItem> ruleIdUpdateArray( KRuleIdBufferGranularity );
+
+        for( TInt itemIdx = 0; itemIdx < count; itemIdx++ )
+            {
+            CNssSpeechItem* item = (*iSpeechItemTrainingBuffer)[itemIdx];
+            TUint32    ruleID = (*iRuleIDArray)[itemIdx];
+            if ( ruleID != KInvalidRuleID )
+                {
+                // tag was trained successfully
+
+                item->DelayedTrainingComplete( ruleID );
+                
+                TNssSpeechItem flatItem;
+
+                flatItem.iRuleId = item->RuleID();
+                flatItem.iTagId  = item->TagId();
+
+                TInt ret = ruleIdUpdateArray.Append( flatItem );
+
+                if ( ret != KErrNone )
+                    {
+                    ruleIdUpdateArray.Close();
+                    SendTrainingCallbacks( KErrNoMemory );
+                    return;
+                    }
+                }
+            else
+                {
+                // training failed -> remove tag
+                iDatabase->DeleteTag( item->TagId() );
+                }   
+            }
+
+        aResult = iDatabase->UpdateTagRuleIDs( ruleIdUpdateArray );
+        ruleIdUpdateArray.Close();
+        SendTrainingCallbacks( aResult );
+        }
+
+    
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoSaveTags
+// Saves tags.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DoSaveTags()
+    {
+
+    __ASSERT_DEBUG( iState == ESaveStateWaiting, DEBUGPANIC );
+
+    // Save the tags en masse
+    TInt ret = iDatabase->SaveTags( iTagBuffer );
+
+    // Next, we're going to make callbacks to the client.
+    // Before that, we have to return the object to idle state,
+    // This way, the last callback can trigger new train/save action.
+
+    // Destroy buffered tags
+    TInt count = iTagBuffer->Count();
+    iTagBuffer->Close();
+    delete iTagBuffer;
+    iTagBuffer = 0;
+
+    // Detach save tag client
+    MNssSaveTagClient* client = iSaveEventHandler;
+    iSaveEventHandler = 0;
+
+    // Make SpeechItemTrainer ready for new challenges
+    SetState( EStateIdle );
+
+    // Make callbacks
+    for ( TInt k = 0; k < count; k++ )
+        {
+        if ( ret == KErrNone )
+            {
+#ifdef _DEBUG
+            TRAPD( err, client->SaveTagCompleted( KErrNone ) );
+            __ASSERT_DEBUG( err == KErrNone, DEBUGPANIC );
+#else
+            client->SaveTagCompleted( KErrNone );
+#endif // _DEBUG
+            }
+        else
+            {
+#ifdef _DEBUG
+            TRAPD( err, client->SaveTagCompleted( KErrGeneral ) );
+            __ASSERT_DEBUG( err == KErrNone, DEBUGPANIC );
+#else
+            client->SaveTagCompleted( KErrGeneral );
+#endif // _DEBUG
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoDeleteTags
+// Starts tag removal.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DoDeleteTags()
+    {
+    // NOTE: This method is never called from anywhere!
+    
+    SetState( EDeleteStateDeleting );
+
+    TInt err = CreateSrsApi();
+    if ( err != KErrNone )
+        {
+        RemoveTagsFinished( err );
+        return;
+        }
+
+    // Move Tag Buffer from filling state to processing state.
+    iSpeechItemTrainingBuffer = iSpeechItemBuffer;
+    iSpeechItemBuffer = 0;
+    iSpeechItemBuffer = new RPointerArray<CNssSpeechItem>; // New filling buffer
+    if( !iSpeechItemBuffer )
+        {
+        SendTrainingCallbacks( KErrNoMemory );
+        return;
+        }
+
+    iTagDeleteCounter = 0;
+    DeleteNextTag();
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DoDeleteGroupedTags
+// Starts grouped tag removal.
+// Used when deleting tags without retraining.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DoDeleteGroupedTags()
+    {
+  	RUBY_DEBUG1("CNssSpeechItemTrainer::DoDeleteGroupedTags iDeleteRuleIDArray->Count() = [%d]", iDeleteRuleIDArray->Count() );
+	SetState( EDeleteStateDeleting );
+
+    // Move Tag Buffer from filling state to processing state.
+    // We want to have this buffer != NULL so that we are able to do callbacks (with appropriate error code )
+    // in RemoveTagsFinished method even if e.g. CreateSrsApi fails. 
+    iSpeechItemTrainingBuffer = iSpeechItemBuffer;
+    iSpeechItemBuffer = 0;
+
+    TInt err = CreateSrsApi();
+    if ( err != KErrNone )
+        {
+        RemoveTagsFinished( err );
+        return;
+        }
+
+    iSpeechItemBuffer = new RPointerArray<CNssSpeechItem>; // New filling buffer
+    
+    if( !iSpeechItemBuffer )
+        {
+        // As this method is not used when retraining, no need 
+        // to send other callbacks than those related to deleting tags.
+        RemoveTagsFinished( KErrNoMemory );
+        return;
+        }
+
+	TInt ret = iSrsApi->RemoveRules( ( TSIGrammarID )iGrammarId,
+                                     *iDeleteRuleIDArray );
+
+    if ( ret != KErrNone && ret != KErrNotFound )
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::DoDeleteGroupedTags RemoveRules failed. \
+                      Error [%d]", ret );
+        RemoveTagsFinished( ret );
+        return;
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::DeleteNextTag
+// Sends a RemoveRule() call for the next rule in the removal queue.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::DeleteNextTag()
+    {
+    RUBY_DEBUG2( "CNssSpeechItemTrainer::DeleteNextTag iTagDeleteCounter [%d], iSpeechItemTrainingBuffer->Count() [%d]", iTagDeleteCounter, iSpeechItemTrainingBuffer->Count() );
+
+    __ASSERT_DEBUG( iTagDeleteCounter <= iSpeechItemTrainingBuffer->Count(), 
+                    User::Panic( KSpeechItemTrainerPanic, __LINE__ ) );
+
+    CNssSpeechItem* speechItem = (*iSpeechItemTrainingBuffer)[iTagDeleteCounter];
+
+    TInt ret = iSrsApi->RemoveRule(
+        (TSIGrammarID)speechItem->GrammarId(),
+        (TSIRuleID)speechItem->RuleID()
+        );
+
+    if ( ret != KErrNone && ret != KErrNotFound )
+        {
+        RemoveTagsFinished( ret );
+        return;
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::HandleRemoveTagComplete
+// Called after SRS has successfully removed a tag.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::HandleRemoveTagComplete()
+    {
+    iTagDeleteCounter++;
+
+    if ( iTagDeleteCounter < iSpeechItemTrainingBuffer->Count() )
+        {
+        DeleteNextTag();
+        }
+    else
+        {
+        RemoveTagsFinished( KErrNone );
+        return;
+        }
+    }
+    
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::HandleRemoveTagsComplete
+// Called after SRS has successfully removed a group of tags.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::HandleRemoveTagsComplete()
+    {
+    RemoveTagsFinished( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::HandleRemoveTagFailed
+// Called if SRS fails to remove a tag.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::HandleRemoveTagFailed( TInt aError )
+    {
+    RemoveTagsFinished( aError );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::RemoveTagsFinished
+// All required tags have been removed.
+// Go to next phase.
+//    functions a bit defferently depending on whether we were retraining or
+//    deleting tags
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::RemoveTagsFinished( TInt aSuccess )
+    {
+    // The continuation depends on what we are doing:
+
+    // If we are deleting tags
+    if ( iState == EDeleteStateDeleting )
+        {
+        if ( aSuccess == KErrNone )
+            {
+            RemoveTagsFromVAS();
+            }
+        else{
+            FinishDeleteTags( aSuccess );
+            }
+        }
+
+    // If we are retraining 
+    // (removing the old rules before adding the new ones)
+    else if ( iState == ERetrainStateRetraining )
+        {
+        if  ( aSuccess == KErrNone )
+            {
+            DoRetrainAddVoiceTags();
+            }
+        else{
+            SendTrainingCallbacks( aSuccess );
+            }
+        }
+    else
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::RemoveTagsFinished - ERROR: Wrong state(%d)", iState );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::RemoveTagsFromVAS
+// Deletes tags from VAS.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::RemoveTagsFromVAS()
+    {
+    RArray<TUint32> tagIdArray( KRemoveTagIdBufferGranularity );
+    TInt ret = KErrNone;
+
+    ////////////// Remove tags from VAS DB ///////////////////
+
+    // Take the Tag IDs to an array.
+    for ( TInt k( 0 ); k < iSpeechItemTrainingBuffer->Count(); k++ )
+        {
+        ret |= tagIdArray.Append( (*iSpeechItemTrainingBuffer)[k]->TagId() );
+        }
+
+    // Delete tags from VAS DB
+    if ( ret == KErrNone )
+        {
+        ret = iDatabase->DeleteTags( tagIdArray );
+        }
+
+    // Close tag ID array.
+    tagIdArray.Close();
+
+    ////////////// Remove tags from VAS DB done //////////////
+
+    FinishDeleteTags( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::FinishDeleteTags
+// Cleans up and sends calbacks after
+// deleting has finished or completed.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::FinishDeleteTags( TInt aSuccess )
+    {
+    RUBY_DEBUG1("CNssSpeechItemTrainer::FinishDeleteTags aSuccess [%d]", aSuccess);
+    // Commit or uncommit according to success
+    if ( iSrsApi )
+        {
+        if ( aSuccess == KErrNone )
+            {
+            CommitSIUpdate();
+            }
+        else{
+            UncommitSIUpdate();
+            }
+        }
+	
+    // Free memory
+    TInt count( 0 );
+    if ( iSpeechItemTrainingBuffer )
+        {        
+        count = iSpeechItemTrainingBuffer->Count();
+        RUBY_DEBUG1("CNssSpeechItemTrainer::FinishDeleteTags aSuccess Freeing [%d] items from the training buffer", count);
+        iSpeechItemTrainingBuffer->Close();
+        }
+    delete iSpeechItemTrainingBuffer;
+    iSpeechItemTrainingBuffer = 0;
+
+    // Send callbacks
+    MNssDeleteTagClient* client = iDeleteEventHandler;
+    iDeleteEventHandler = 0;
+    iTagDeleteCounter = 0;
+
+    
+    for ( TInt k( 0 ); k < count; k++ )
+        {
+        RUBY_DEBUG1("CNssSpeechItemTrainer::FinishDeleteTags sending callback for item [%d]", k);
+        // Failed or succeedeed, one rule is processed
+        iDeleteRuleIDArray->Remove(0);
+       
+        client->DeleteTagCompleted( aSuccess );
+        }
+    RUBY_DEBUG2("CNssSpeechItemTrainer::FinishDeleteTags Reported [%d] deletions. [%d] remaining. Setting idle state", count, iDeleteRuleIDArray->Count());
+    SetState( EStateIdle );
+
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::RunBufferedActionsL
+// Called when it is time to execute the buffered actions
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::RunBufferedActionsL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssSpeechItemTrainer::RunL" );
+    
+    if ( iState == ETrainStateWaiting )
+        {
+        DoTrainTextDelayed();
+        }
+    else if ( iState == ESaveStateWaiting )
+        {
+        DoSaveTags();
+        }
+    else if ( iState == EDeleteStateWaiting )
+        {
+        DoDeleteGroupedTags();
+        }
+    else if ( iState == ERetrainStateWaiting )
+        {
+        DoRetrainTextDelayed();
+        }
+    else
+        {
+        RUBY_DEBUG1( "CNssSpeechItemTrainer::RunL - ERROR: Wrong state (%d)", iState );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::RestartTimer
+// Restarts the timer.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::RestartTimer()
+    {
+    TRAP_IGNORE( iActionTracker->ActionRequestedL() );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::CheckTrainingParametersL
+// All tags in the queue should have the same training parameters. This
+// function check that a new context has similar training parameters
+// as the previous ones.
+// ---------------------------------------------------------
+//
+TBool CNssSpeechItemTrainer::CheckTrainingParametersL( const CNssTrainingParameters* aParams )
+    {
+    if ( aParams )
+        {
+        if ( !iTrainingParams )
+            {
+            // Make a local copy of training parameters
+            iTrainingParams = CNssTrainingParameters::NewL();
+
+            const RArray<TLanguage>& paramLangArray = aParams->Languages();
+
+            RArray<TLanguage>* langArray = new ( ELeave ) RArray<TLanguage>;
+            CleanupStack::PushL( langArray );
+                
+            for ( TInt k = 0; k < paramLangArray.Count(); k++ )
+                {
+                TInt ret = langArray->Append( paramLangArray[ k ] );
+                if ( ret != KErrNone )
+                    {
+                    langArray->Close();
+                    delete langArray;
+                    return EFalse;
+                    }
+                }
+                
+            // Copy training languages
+            iTrainingParams->SetLanguages( langArray );
+            CleanupStack::Pop( langArray );
+
+            // Copy SINDE languages
+            TRAP_IGNORE( iTrainingParams->SetSindeLanguages( aParams->SindeLanguagesL() ) );
+            
+            // Copy separator
+            iTrainingParams->SetSeparator( aParams->Separator() );
+            }
+        else
+            {
+            // Compare with previous training parameters
+            
+            // Separator
+            if ( aParams->Separator() != iTrainingParams->Separator() )
+                {
+                return EFalse;
+                }
+
+            // Training languages
+            for ( TInt k = 0; k < aParams->Languages().Count(); k++ )
+                {
+                if ( aParams->Languages()[ k ] != iTrainingParams->Languages()[ k ] )
+                    {
+                    return EFalse;
+                    }
+                }
+            
+            // @todo SINDE languages should be checked also!            
+            }
+       }
+       
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::CheckContext
+// All tags in the queue should have the same contexts. This
+// function check that a new context is similar to that of previous tags.
+// ---------------------------------------------------------
+//
+TBool CNssSpeechItemTrainer::CheckContext(CNssContext& aContext)
+    {
+    if ( &aContext == 0 ) // Default settings - anything goes.
+        {
+        return( EFalse );
+        }
+
+    if ( aContext.RecognitionMode() != ENSSSdSiMode &&
+         aContext.RecognitionMode() != ENSSSiMode )
+        {
+        return( EFalse );
+        }
+
+    if ( iContext )
+        {
+        // Check that identifiers (name & ID) are identical.
+        if ( aContext.ContextId() != iContext->ContextId() )
+            {
+            return( EFalse );
+            }
+
+        if ( aContext.ContextName().Compare( iContext->ContextName() ) != 0 )
+            {
+            return( EFalse );
+            }
+        }
+    else
+        {
+        if ( aContext.RecognitionMode()  == ENSSSdSiMode )
+            {
+            aContext.SetRecognitionMode( ENSSSiMode );
+            }
+
+        TRAPD( error, iContext = aContext.CopyL() );
+        if ( error != KErrNone )
+            {
+            return EFalse;
+            }
+        }
+
+    return( ETrue );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::HandleTrainComplete
+// Called after speech recognition utility has trained all tags.
+// Announces the newly assigned Rule IDs for the speech items.
+// Signals the VAS client that training has been finished.
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::HandleTrainComplete( TInt aResult )
+    {
+    RUBY_DEBUG1( "CNssSpeechItemTrainer::HandleTrainComplete(%d)", aResult );
+
+    // iRuleIdArray contains the rule IDs of the newly trained tags.
+    // The following call makes sure that
+    // iRuleIdArray.Count() == iSpeechItemTrainingBuffer.Count().
+    if ( EnforceRuleIdCountInvariant( *iRuleIDArray, 
+              iSpeechItemTrainingBuffer->Count() ) != KErrNone )
+        {
+        SendTrainingCallbacks( KErrNoMemory );
+        }
+
+    // Save rule IDs. Some rule IDs may have "KInvalidRuleID". This is a sign
+    // that training failed. It's good to save also that info to speech items.
+    for( TInt itemIdx = 0; itemIdx < iSpeechItemTrainingBuffer->Count(); itemIdx++ )
+        {
+        CNssSpeechItem* item = (*iSpeechItemTrainingBuffer)[ itemIdx ];
+        TUint32    ruleID = (*iRuleIDArray)[ itemIdx ];
+
+        item->DelayedTrainingComplete( ruleID );
+        }
+
+    SendTrainingCallbacks( aResult );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SendTrainingCallbacks
+// 
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::SendTrainingCallbacks( TInt aResult )
+    {
+    // If the changes were successful, commit them.
+    // If they werent, roll back the changes.
+    if ( aResult == KErrNone )
+        {
+        CommitSIUpdate();
+        }
+    else{
+        UncommitSIUpdate();
+        }
+
+    // Save count (callback count)...
+    TInt count = iSpeechItemTrainingBuffer->Count();
+    MNssTrainTextEventHandler* callback = iTrainEventHandler;
+    RArray<TUint32>* ruleIdArray = iRuleIDArray;
+    iRuleIDArray = 0;
+
+    // Delete buffered names that were just trained
+    if ( iSpeechItemTrainingBuffer )
+        {
+        iSpeechItemTrainingBuffer->Close();
+        }
+    delete iSpeechItemTrainingBuffer;
+    iSpeechItemTrainingBuffer = 0;
+
+
+    // If there are names on the training queue,
+    // restart the waiting of delayed training.
+    if ( iSpeechItemBuffer && iSpeechItemBuffer->Count() > 0 )
+        {
+        // don't delete context etc as training will be continued
+        SetState( ETrainStateWaiting );
+        RestartTimer();
+        }
+    else
+        {
+        SetState( EStateIdle );
+            
+        // Cleanup
+        delete iTrainingParams;
+        iTrainingParams = 0;
+
+        delete iContext;
+        iContext = 0;
+        
+        iTrainEventHandler = 0;        
+        }
+
+    // Make the callbacks to the client according to the recognition result.
+    for( TInt k( 0 ); k < count; k++ )
+        {
+        if ( ruleIdArray->Count() <= k )
+            {
+            RUBY_DEBUG2( "CNssSpeechItemTrainer::SendTrainingCallbacks ruleIdArray->Count() [%d] <= k [%d]", ruleIdArray->Count(), k );
+            callback->HandleTrainComplete( KErrNoMemory );
+            }
+        if ( (*ruleIdArray)[ k ] == KInvalidRuleID )
+            {
+            RUBY_DEBUG0( "CNssSpeechItemTrainer::SendTrainingCallbacks (*ruleIdArray)[ k ] == KInvalidRuleID" );
+            if ( aResult == KErrNone )
+                {
+                callback->HandleTrainComplete( KErrGeneral );
+                }
+            else
+                {
+                callback->HandleTrainComplete( aResult );
+                }
+            
+            }
+        else
+            {
+            callback->HandleTrainComplete( KErrNone );
+            }
+        }
+
+    ruleIdArray->Close();
+    delete ruleIdArray;
+    ruleIdArray = 0;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::MsruoEvent
+// SRS Utility callback function 
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::MsruoEvent( TUid aEvent, TInt aResult )
+    {
+    switch( aEvent.iUid )
+        {
+        case KUidAsrEventAddVoiceTagsVal:
+            RUBY_DEBUG0( "CNssSpeechItemTrainer::MsruoEvent - state is KUidAsrEventAddVoiceTagsVal" );
+
+            if ( iState == ETrainStateTraining )
+                {
+                HandleTrainComplete( aResult );
+                }
+            else if ( iState == ERetrainStateRetraining )
+                {
+                HandleRetrainComplete( aResult );
+                }
+            break;
+
+        case KUidAsrEventRemoveRuleVal:
+            RUBY_DEBUG0( "CNssSpeechItemTrainer::MsruoEvent - state is KUidAsrEventRemoveRuleVal" );
+
+            if ( aResult == KErrNone || aResult == KErrNotFound )
+                {
+                HandleRemoveTagComplete();
+                }
+            else{
+                HandleRemoveTagFailed( aResult );
+                }
+            break;
+            
+        case KUidAsrEventRemoveRulesVal:
+            RUBY_DEBUG0( "CNssSpeechItemTrainer::MsruoEvent - state is KUidAsrEventRemoveRulesVal" );
+
+        	if( aResult == KErrNone || aResult == KErrNotFound )
+        		{
+        		HandleRemoveTagsComplete();
+        		}
+        	else 
+        		{
+        		HandleRemoveTagFailed( aResult );
+        		}
+        	break;
+
+        default:
+            RUBY_DEBUG2( "CNssSpeechItemTrainer::MsruoEvent - ERROR: Uknown state (%d,%d)", aEvent.iUid, aResult );
+            break;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SplitPhraseSindeL
+// Splits a phrase to parts. Returns the parts in array.
+// ---------------------------------------------------------
+//
+CDesC16ArrayFlat* CNssSpeechItemTrainer::SplitPhraseSindeL( const TDesC& aPhrase, 
+                                                            TChar aSeparator )
+    {
+    CDesC16ArrayFlat* wordArray = new ( ELeave ) CDesC16ArrayFlat( KSindeWordArrayGranularity );
+    CleanupStack::PushL( wordArray );
+
+    // Separate the words in the phrase.
+    TPtrC text = aPhrase; // Cursor to the phrase
+
+    do
+        {
+        TInt index = text.Locate( aSeparator );
+
+        if ( index != 0 )
+            {
+            // no more separators -> this is the last word -> end of word == end of string
+            if ( index == KErrNotFound ) 
+                {
+                index = text.Length();
+                }
+
+                // Add word to array
+                wordArray->AppendL( text.Left( index ) );
+                }
+
+        // Discard the processed word
+        TInt charactersLeft = text.Length() - index; 
+        // Forget the separator
+        if ( charactersLeft > 0 )                    
+            {
+            charactersLeft--;                        
+            }
+
+        // Update text cursor
+        text.Set( text.Right( charactersLeft ) );
+
+        } 
+    while( text.Length() > 0 );
+
+    CleanupStack::Pop( wordArray );
+    return wordArray;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SplitPhrase
+// Splits a phrase to parts. Returns the parts in array.
+// ---------------------------------------------------------
+//
+CDesC16ArrayFlat* CNssSpeechItemTrainer::SplitPhraseL( const TDesC& aPhrase, TChar aSeparator )
+    {
+    CDesC16ArrayFlat *wordArray = new (ELeave) CDesC16ArrayFlat( KSindeWordArrayGranularity );
+
+    // Separate the words in the phrase. Especially firstname / lastname.
+    TPtrC text = aPhrase; // Cursor to the phrase
+
+    do
+        {
+        TInt index = text.Locate( aSeparator );
+
+        // no more separators -> this is the last word -> end of word == end of string
+        if ( index == -1 ) 
+            {
+            index = text.Length();
+            }
+
+        // Add word to array
+        wordArray->AppendL( text.Left( index ) );
+
+        // Discard the processed word
+        TInt charactersLeft = text.Length() - index; 
+        // Forget the separator
+        // (the last word doesn't have one)
+        if ( charactersLeft > 0 )                    
+            {
+            charactersLeft--;                        
+            }
+
+        // Update text cursor
+        text.Set( text.Right( charactersLeft ) );
+
+        } 
+    while( text.Length() > 0 );
+
+    return wordArray;
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::CommitSIUpdate
+// Commits changes to SRS and destroys SRS utility.
+// ---------------------------------------------------------
+//
+TInt CNssSpeechItemTrainer::CommitSIUpdate()
+    {
+    if ( !iSrsApi )
+        {
+        return( KErrNotReady );
+        }
+
+    iSrsApi->CommitChanges();
+
+    delete iSrsApi;
+    iSrsApi = NULL;
+
+    return( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::UncommitSIUpdate
+// Destroys SRS utility without committing.
+// ---------------------------------------------------------
+//
+TInt CNssSpeechItemTrainer::UncommitSIUpdate()
+    {
+    if ( !iSrsApi )
+        {
+        return( KErrNotReady );
+        }
+
+    delete iSrsApi;
+    iSrsApi = NULL;
+
+    return( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SpeechItemBufferNeeded
+// Trys to allocate a speech item buffer
+// ---------------------------------------------------------
+//
+TBool CNssSpeechItemTrainer::SpeechItemBufferNeeded()
+    {
+    if ( !iSpeechItemBuffer )
+        {
+        iSpeechItemBuffer = new RPointerArray<CNssSpeechItem>;
+        if ( !iSpeechItemBuffer )
+            {
+            return( EFalse );
+            }
+        }
+
+    return( ETrue );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SpeechItemBufferNeeded
+// Trys to allocate a grammar id buffer
+// ---------------------------------------------------------
+//
+TBool CNssSpeechItemTrainer::GrammarIdBufferNeeded()
+    {
+    if ( !iGrammarIdBuffer )
+        {
+        iGrammarIdBuffer = new RArray<TUint32>;
+        if ( !iGrammarIdBuffer )
+            {
+            return( EFalse );
+            }
+        }
+
+    return( ETrue );
+    }
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SpeechItemBufferNeeded
+// Trys to create SRS api. Returns success status.
+// ---------------------------------------------------------
+//
+TInt CNssSpeechItemTrainer::CreateSrsApi()
+    {
+    if ( !iSrsApi )
+        {
+        TRAPD( err, iSrsApi = CNssSiUtilityWrapper::NewL( *this, KNssVASApiUid ) );
+        REACT( err, return( err ) );
+
+        iSrsApi->SetEventHandler( this );
+        }
+
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SpeechItems2Phrases
+// Converts an array of speech items
+// into Utility's AddVoiceTags array format.
+// ---------------------------------------------------------
+//
+TInt CNssSpeechItemTrainer::SpeechItems2Phrases(
+    RPointerArray<CNssSpeechItem>& aSpeechItems,
+    RPointerArray<MDesCArray>& aPhrases )
+    {
+    // iPhraseArray is an array of arrays: 
+    // 
+    //        |-- firstname1
+    //  tag1 -|-- lastname1
+    //
+    //  tag2 -|-- firstname2
+    //        |-- lastname2
+
+    // Create training parameters, if none were given
+    if ( iTrainingParams == 0 )
+        {
+        RArray<TLanguage>* languages = new RArray<TLanguage>();
+
+        if ( !languages )
+            {
+            return( KErrNoMemory );
+            }
+
+        // Use UI language + 1 other as default if languages are not given
+        // in training parameters
+        TInt err = languages->Append( User::Language() );
+
+        if ( err == KErrNone )
+            {
+            err = languages->Append( ELangOther );
+            }
+
+        if ( err != KErrNone )
+            {
+            languages->Close();
+            delete languages;
+            return( err );
+            }
+
+        TRAP( err, iTrainingParams = CNssTrainingParameters::NewL() ); 
+        if ( err != KErrNone )
+            {
+            languages->Close();
+            delete languages;
+            return( err );
+            }
+
+        iTrainingParams->SetLanguages( languages );
+        }
+
+    // Split the phrases to subwords (names -> first name + last name)
+    for ( TInt k( 0 ); k < aSpeechItems.Count(); k++ )
+        {
+        // Split names into the first name and the last name
+        CDesC16ArrayFlat *wordArray = 0;
+
+        // Check if SINDE type of training should be used
+        TRAPD( errSinde, const RArray<RTrainingLanguageArray>& temp = 
+                                        iTrainingParams->SindeLanguagesL() );
+        if ( errSinde == KErrNone )
+            {
+            TRAP_IGNORE( wordArray = SplitPhraseSindeL( aSpeechItems[ k ]->RawText(),
+                                                        iTrainingParams->Separator() ) );
+            }
+        else
+            {
+            TRAP_IGNORE( wordArray = SplitPhraseL( aSpeechItems[ k ]->Text(),
+                                                   iTrainingParams->Separator() ) );
+            }
+
+        if ( wordArray == 0 )
+            {
+            return KErrNoMemory;
+            }
+
+        TInt ret = aPhrases.Append( wordArray );
+
+        if ( ret != KErrNone )
+            {
+            return ret;
+            }
+        }
+
+    return( KErrNone );
+    }
+    
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::SetState
+// Changes state of the trainer
+// ---------------------------------------------------------
+//
+void CNssSpeechItemTrainer::SetState(TTrainState aState) 
+	{
+	RUBY_DEBUG2("CNssSpeechItemTrainer::SetState Switching state from [%d] to [%d]", iState, aState);
+#ifdef _DEBUG
+	if( iState == EDeleteStateWaiting ) 
+		{
+		RUBY_DEBUG0("CNssSpeechItemTrainer::SetState From EDeleteStateWaiting");
+		}
+	if( aState == EDeleteStateWaiting ) 
+		{
+		RUBY_DEBUG0("CNssSpeechItemTrainer::SetState To EDeleteStateWaiting");
+		}
+		
+#endif	
+	iState = aState;
+	}
+
+// ---------------------------------------------------------
+// CNssSpeechItemTrainer::EnforceRuleIdCountInvariant
+// Adds KInvalidRuleId to the Rule ID Array, until
+// the number of rules is equal to count.
+// ---------------------------------------------------------
+//
+TInt EnforceRuleIdCountInvariant( RArray<TUint32>& aArray, TInt aCount )
+    {
+    while( aArray.Count() < aCount )
+        {
+        TInt err = aArray.Append( KInvalidRuleID );
+        if ( err != KErrNone )
+            {
+            return( err );
+            }
+        }
+
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasctag.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssTag implements MNssTag. In addition, it provides members for use
+*               by VAS internal components.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasctag.h"
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssTag::CNssTag
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+CNssTag::CNssTag( CNssContext* aContext, CNssRRD* aRRD, 
+                  CNssSpeechItem* aSpeechItem )
+    {
+    iContext = aContext;
+    iRRD = aRRD;
+    iSpeechItem = aSpeechItem;
+    iTagId = KNssVASDbDefaultValue;
+    }
+
+// ---------------------------------------------------------
+// CNssTag::~CNssTag
+// Destructor
+// ---------------------------------------------------------
+//
+CNssTag::~CNssTag()
+    {
+    delete iContext;
+    iContext = NULL;
+    
+    delete iRRD;
+    iRRD = NULL;
+    
+    delete iSpeechItem;
+    iSpeechItem = NULL;
+    }
+
+// ---------------------------------------------------------
+// CNssTag::Context
+// get the context object for this tag
+// ---------------------------------------------------------
+//
+MNssContext* CNssTag::Context()
+    {
+    return  iContext;
+    }
+
+// ---------------------------------------------------------
+// CNssTag::RRD
+// get the RRD object for this tag
+// ---------------------------------------------------------
+//
+MNssRRD* CNssTag::RRD()
+    {
+    return  iRRD;
+    }
+
+// ---------------------------------------------------------
+// CNssTag::SpeechItem
+// get the speech item for this tag
+// ---------------------------------------------------------
+//
+MNssSpeechItem* CNssTag::SpeechItem()
+    {
+    return iSpeechItem;
+    }
+
+// ---------------------------------------------------------
+// CNssTag::TagId
+// get the tag id for this tag
+// ---------------------------------------------------------
+//
+TInt CNssTag::TagId()
+    {
+    return iTagId;
+    }
+
+// ---------------------------------------------------------
+// CNssTag::SetTagId
+// Set the tag id for this tag
+// ---------------------------------------------------------
+//
+void CNssTag::SetTagId(TInt aId)
+    {
+    iTagId = aId;
+    
+    if ( iSpeechItem )
+        {
+        iSpeechItem->SetTagId( aId );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssTag::CopyL
+// Make a deep copy of the tag
+// ---------------------------------------------------------
+//
+CNssTag* CNssTag::CopyL()
+    {
+    CNssContext *context = iContext->CopyL();
+    CleanupStack::PushL( context );
+    CNssRRD *rrd = iRRD->CopyL();
+    CleanupStack::PushL( rrd );
+    CNssSpeechItem *speechItem = iSpeechItem->CopyL( context );
+    CleanupStack::PushL( speechItem );
+    CNssTag* copy = new (ELeave) CNssTag( context, rrd, speechItem );
+    CleanupStack::Pop( speechItem );
+    CleanupStack::Pop( rrd );
+    CleanupStack::Pop( context );
+    copy->iTagId = iTagId;
+    return copy;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasctagreference.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "nssvasctagreference.h"
+#include "nssvasctagmgr.h"
+
+CNssTagReference::CNssTagReference()
+{
+   iTagName = NULL;
+}
+
+CNssTagReference::~CNssTagReference()
+{
+   delete iTagName;
+}
+
+void CNssTagReference::SetTagNameL(const TDesC& aTagName)
+{
+   if(iTagName)
+   {
+      delete iTagName;
+      iTagName = NULL;
+   }
+   iTagName = aTagName.AllocL(); 
+}
+TDesC& CNssTagReference::TagName()
+{
+   return *iTagName;
+}
+
+void CNssTagReference::SetTagId(TInt aTagId)
+{
+   iTagId = aTagId;
+}
+
+TInt CNssTagReference::TagId()
+{
+   return iTagId;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasctrainingactiontracker.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implements the buffer timeout logic specific to the speech item 
+*               trainer. Is notified about the speech item trainer action requests,
+*               and decides when to actually fire the buffered actions
+*
+*/
+
+
+#include "nssvasctrainingactiontracker.h"
+#include "rubydebug.h"
+
+const TInt KDelayInMicroseconds = 500000;
+
+
+CNssTrainingActionTracker* CNssTrainingActionTracker::NewL( MDelayedNotifiable& aNotifiable )
+    {
+    CNssTrainingActionTracker* self = new (ELeave) CNssTrainingActionTracker( aNotifiable );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+CNssTrainingActionTracker::CNssTrainingActionTracker( MDelayedNotifiable& aNotifiable ) :
+    CTimer( EPriorityStandard ), iHost( aNotifiable )
+    {
+    // empty
+    }
+    
+CNssTrainingActionTracker::~CNssTrainingActionTracker()
+    {
+    delete iAsyncCallback;
+    }    
+        
+/**
+ * Is called by the client to notify tracker about the request to
+ * perform a potentially bufferable action. It is up to tracker
+ * when to stop recording the action requests and fire the 
+ * delayed actions via MDelayedNotifiable::DoBufferedActionsL
+ * 
+ * DoBufferedActionsL is always called asynchronously. Even if tracker
+ * decides to fire the delayable actions immediately
+ */
+void CNssTrainingActionTracker::ActionRequestedL()
+    {
+    RUBY_DEBUG_BLOCK("");
+    iUnfiredActions = ETrue;
+    if ( !IsActive() )
+        {
+        RUBY_DEBUG0( "The first event in a sequence" );
+        iAsyncCallback->CallBack();
+        }
+    RestartTimer();
+    }
+    
+void CNssTrainingActionTracker::RestartTimer()
+    {
+    if( IsActive() )
+        {
+        Cancel();
+        }
+    After( TTimeIntervalMicroSeconds32( KDelayInMicroseconds ) );
+    }
+    
+    
+void CNssTrainingActionTracker::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    iAsyncCallback = new (ELeave) CAsyncCallBack( TCallBack(FireActionsImmediately, this ), 
+                                                  CActive::EPriorityStandard );
+    }
+
+void CNssTrainingActionTracker::RunL()
+    {
+    // timeout happened
+    if( iUnfiredActions )
+        {
+        RUBY_DEBUG0("Unfired actions in the buffeer");
+        DoFireActionsL();
+        }
+    }
+    
+TInt CNssTrainingActionTracker::FireActionsImmediately( TAny* pX )
+    {
+    TRAPD( err, static_cast<CNssTrainingActionTracker*>(pX)->DoFireActionsL() );
+    return err;
+    }
+    
+    
+void CNssTrainingActionTracker::DoFireActionsL()
+    {
+    RUBY_DEBUG_BLOCK("");
+    // Whatever is requested after RunBufferedActionsL or *during* RunBufferedActionsL
+    // has to be fired later
+    iUnfiredActions = EFalse;
+    iHost.RunBufferedActionsL();
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasctrainingparams.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Saves training parameters, which include pronunciation language
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasctrainingparameters.h"
+#include "nssvasdbkonsts.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::NewL
+// Two-phased constructor
+// ---------------------------------------------------------
+//
+EXPORT_C CNssTrainingParameters* CNssTrainingParameters::NewL()
+    {
+    CNssTrainingParameters *me = CNssTrainingParameters::NewLC();
+    CleanupStack::Pop( me );
+    return( me );
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::NewLC
+// Two-phased constructor
+// ---------------------------------------------------------
+//
+EXPORT_C CNssTrainingParameters* CNssTrainingParameters::NewLC()
+    {
+    CNssTrainingParameters *me = new (ELeave) CNssTrainingParameters();
+    CleanupStack::PushL( me );
+
+    me->ConstructL();
+
+    return( me );
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::CNssTrainingParameters
+// C++ constructor
+// ---------------------------------------------------------
+//
+CNssTrainingParameters::CNssTrainingParameters()
+ : iSeparator(' ')
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::ConstructL
+// Second-phase constructor
+// ---------------------------------------------------------
+//
+void CNssTrainingParameters::ConstructL()
+    {
+    iLanguages = new (ELeave) RArray<TLanguage>;
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::~CNssTrainingParameters
+// Destructor
+// ---------------------------------------------------------
+//
+EXPORT_C CNssTrainingParameters::~CNssTrainingParameters()
+    {
+    if ( iLanguages )
+        {
+        iLanguages->Close();
+        delete iLanguages;
+        }
+    ResetSindeLanguageArray();
+    
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::SetLanguages
+// Sets the language list
+// ---------------------------------------------------------
+//
+EXPORT_C void CNssTrainingParameters::SetLanguages( RArray<TLanguage>* aLanguageArray )
+    {
+    if ( iLanguages )
+        {
+        iLanguages->Close();
+        delete iLanguages;
+        }
+    iLanguages = aLanguageArray;
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::Languages
+// Returns the language list
+// ---------------------------------------------------------
+//
+EXPORT_C const RArray<TLanguage>& CNssTrainingParameters::Languages() const
+    {
+    return( *iLanguages );
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::SetSeparator
+// Sets the separator char
+// ---------------------------------------------------------
+//
+EXPORT_C void CNssTrainingParameters::SetSeparator( TChar aSeparator )
+    {
+    iSeparator = aSeparator;
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::Separator
+// Returns the separator char
+// ---------------------------------------------------------
+//
+EXPORT_C TChar CNssTrainingParameters::Separator() const
+    {
+    return( iSeparator );
+    }
+
+// ---------------------------------------------------------
+// CNssTrainingParameters::SetLanguages
+// Sets the SINDE language list
+// ---------------------------------------------------------
+//
+EXPORT_C void CNssTrainingParameters::SetSindeLanguages( 
+                const RArray<RTrainingLanguageArray>& aLanguageArray )
+    {
+    ResetSindeLanguageArray();
+    
+    for ( TInt i = 0; i < aLanguageArray.Count(); i++ )
+        {
+        const RTrainingLanguageArray& array = aLanguageArray[i];
+        RTrainingLanguageArray copiedArray;
+        for ( TInt j = 0; j < array.Count(); j++ )
+            {
+            copiedArray.Append( array[j] );
+            }
+        iSindeLanguages.Append( copiedArray );
+        }
+    
+    }
+    
+// ---------------------------------------------------------
+// CNssTrainingParameters::Languages
+// Returns the SINDE language list
+// ---------------------------------------------------------
+//
+EXPORT_C const RArray<RTrainingLanguageArray>& CNssTrainingParameters::SindeLanguagesL() const
+    {
+    if ( iSindeLanguages.Count() == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    return iSindeLanguages;
+    }
+    
+// ---------------------------------------------------------
+// CNssTrainingParameters::ResetSindeLanguageArray
+// Resets SINDE language array
+// ---------------------------------------------------------
+//    
+void CNssTrainingParameters::ResetSindeLanguageArray()
+    {
+    for ( TInt i = 0; i < iSindeLanguages.Count(); i++ )
+        {
+        RTrainingLanguageArray& array = iSindeLanguages[i];
+        array.Close();
+        }
+    iSindeLanguages.Reset();
+    iSindeLanguages.Close();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvassiutilitywrapper.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,432 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class which hides the dynamic loading of 
+*               nsssispeechrecognitionutility.dll
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <nsssiutilitybase.h>
+#include "rubydebug.h"
+#include "nssvassiutilitywrapper.h"
+
+// CONSTANTS
+// DLL name
+_LIT( KUtilityFilename, "nsssispeechrecognitionutility.dll" );
+// CreateInstanceL function ordinal number
+const TInt KFunctionOrdinal = 1;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::NewL
+// Two-phased constructor
+// ---------------------------------------------------------
+//
+CNssSiUtilityWrapper* CNssSiUtilityWrapper::NewL( 
+        MSISpeechRecognitionUtilityObserver& aObserver, TUid aClientUid )
+    {
+    CNssSiUtilityWrapper* self = new ( ELeave ) CNssSiUtilityWrapper( aObserver, aClientUid );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::~CNssSiUtilityWrapper
+// Destructor
+// ---------------------------------------------------------
+//
+CNssSiUtilityWrapper::~CNssSiUtilityWrapper()
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::~CNssSiUtilityWrapper" );
+
+    Cancel();
+
+    delete iUtility;
+    // Close RLibrary handle
+    iLib.Close();
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::CNssSiUtilityWrapper
+// C++ constructor
+// ---------------------------------------------------------
+//
+CNssSiUtilityWrapper::CNssSiUtilityWrapper( 
+        MSISpeechRecognitionUtilityObserver& aObserver, TUid aClientUid ) : 
+                                            CActive( EPriorityStandard ), 
+                                            iClientUid( aClientUid ), 
+                                            iObserver( aObserver )
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::ConstructL
+// Second phase constructor
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssSiUtilityWrapper::ConstructL" );
+    
+    // Load a DLL based on name with RLibrary
+    User::LeaveIfError( iLib.Load( KUtilityFilename ) );
+    
+    // Find the TAny* CreateInstanceL() function
+    TLibraryFunction entry = iLib.Lookup( KFunctionOrdinal );
+    if ( !entry )
+        {
+        User::Leave( KErrNotFound );
+        }    
+  
+    // Call CreateInstanceL  
+    // Cannot use static_cast since entry() call returns TInt    
+    iUtility = ( MSISpeechRecognitionUtilityBase* ) entry();
+     
+    // Do the 2nd phase construction
+    iUtility->CreateInstanceSecondPhaseL( iClientUid, KNullUid, *this );
+    
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::Adapt
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::Adapt( const CSIClientResultSet& aResultSet,
+                                  TInt aCorrect )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::Adapt" );
+    return iUtility->Adapt( aResultSet, aCorrect );
+    }
+    
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::AddVoiceTags
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                         const RArray<TLanguage>& aLanguageArray,
+                                         TSILexiconID aLexiconID,
+                                         TSIGrammarID aGrammarID, 
+                                         RArray<TSIRuleID>& aRuleIDArray )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::AddVoiceTags" );
+    return iUtility->AddVoiceTags( aTextArrayArray, aLanguageArray, 
+                                   aLexiconID, aGrammarID, aRuleIDArray );
+    }
+    
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::AddVoiceTags
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                         const RArray<RLanguageArray>& aLanguageArray,
+                                         TSILexiconID aLexiconID,
+                                         TSIGrammarID aGrammarID, 
+                                         RArray<TSIRuleID>& aRuleIDArray )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::AddVoiceTags" );
+    return iUtility->AddVoiceTags( aTextArrayArray, aLanguageArray, 
+                                   aLexiconID, aGrammarID, aRuleIDArray );
+    }
+    
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::CancelUtility
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::CancelUtility()
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::Cancel" );
+    return iUtility->Cancel();
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::CommitChanges
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::CommitChanges()
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::CommitChanges" );
+    return iUtility->CommitChanges();
+    }
+
+    
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::CreateGrammar
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::CreateGrammar( TSIGrammarID& aGrammarID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::CreateGrammar" );
+    return iUtility->CreateGrammar( aGrammarID );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::CreateLexicon
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::CreateLexicon( TSILexiconID& aLexiconID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::CreateLexicon" );
+    return iUtility->CreateLexicon( aLexiconID );
+    }
+        
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::CreateModelBank
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::CreateModelBank( TSIModelBankID& aModelBankID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::CreateModelBank" );
+    return iUtility->CreateModelBank( aModelBankID );
+    }
+        
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::EndRecSession
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::EndRecSession()
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::EndRecSession" );
+    return iUtility->EndRecSession();
+    }
+
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::LoadGrammar
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::LoadGrammar( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::LoadGrammar" );
+    return iUtility->LoadGrammar( aGrammarID );
+    }
+        
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::LoadModels
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::LoadModels( TSIModelBankID aModelBankID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::LoadModels" );
+    return iUtility->LoadModels( aModelBankID );
+    }
+
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::Record
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::Record( TTimeIntervalMicroSeconds32 aRecordTime )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::Record" );
+    return iUtility->Record( aRecordTime );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::PreStartSampling
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::PreStartSampling()
+    {
+    RUBY_DEBUG0( "" );
+    return iUtility->PreStartSampling();
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::Recognize
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::Recognize( CSIClientResultSet& aResultSet )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::Recognize" );    
+    return iUtility->Recognize( aResultSet ); 
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::RemoveGrammar
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::RemoveGrammar( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::RemoveGrammar" );   
+    return iUtility->RemoveGrammar( aGrammarID );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::RemoveLexicon
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::RemoveLexicon( TSILexiconID aLexiconID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::RemoveLexicon" );  
+    return iUtility->RemoveLexicon( aLexiconID );
+    }
+
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::RemoveModelBank
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::RemoveModelBank( TSIModelBankID aModelBankID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::RemoveModelBank" );      
+    return iUtility->RemoveModelBank( aModelBankID );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::RemoveRule
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::RemoveRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::RemoveRule" );  
+    return iUtility->RemoveRule( aGrammarID, aRuleID );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::RemoveRules
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::RemoveRules( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::RemoveRules" );
+    return iUtility->RemoveRules( aGrammarID, aRuleIDs );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::SetAudioPriority
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::SetAudioPriority( TInt aPriority, TInt aTrainPreference, 
+                        TInt aPlaybackPreference, TInt aRecognitionPreference )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::SetAudioPriority" );
+    return iUtility->SetAudioPriority( aPriority, aTrainPreference, 
+                                aPlaybackPreference, aRecognitionPreference );
+    }
+        
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::SetEventHandler
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::SetEventHandler( MSISpeechRecognitionUtilityObserver*
+                                            aSpeechRecognitionUtilityObserver )
+    {
+    iObserver = *aSpeechRecognitionUtilityObserver;
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::StartRecSession
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::StartRecSession( TNSSRecognitionMode aMode )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::StartRecSession" );
+    return iUtility->StartRecSession( aMode );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::UnloadRule
+// Forwards the call to Recognition Utility
+// ---------------------------------------------------------
+//
+TInt CNssSiUtilityWrapper::UnloadRule( TSIGrammarID aGrammarID, TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::UnloadRule" );
+    return iUtility->UnloadRule( aGrammarID, aRuleID );
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::MsruoEvent
+// Callback from SI Utility
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::MsruoEvent( TUid aEvent, TInt aResult )
+    {
+    RUBY_DEBUG2( "CNssSiUtilityWrapper::MsruoEvent, event[%d], result[%d]", aEvent, aResult );
+    iEvent = aEvent;
+    iResult = aResult;
+    Ready();
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::Ready
+// Sets active object ready to be run
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::Ready()
+    {
+    if ( !IsActive() )
+        {
+        SetActive();
+        TRequestStatus* stat = &iStatus;
+        User::RequestComplete( stat, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::RunL
+// From CActive
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::RunL()
+    {
+    // Forwards callback to other parts of VAS
+    RUBY_DEBUG2( "CNssSiUtilityWrapper::RunL calling callback function, event[%d], result[%d]", iEvent, iResult );
+    iObserver.MsruoEvent( iEvent, iResult );
+    RUBY_DEBUG0( "CNssSiUtilityWrapper::RunL callback called" );
+    }
+	    
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::DoCancel
+// From CActive
+// ---------------------------------------------------------
+//
+void CNssSiUtilityWrapper::DoCancel()
+    {
+    // Nothing
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/nssvasttsutilitywrapper.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class which hides the dynamic loading of nssttsutility.dll
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <nssttsutilitybase.h>
+#include "rubydebug.h"
+#include "nssvasttsutilitywrapper.h"
+
+// CONSTANTS
+// DLL name
+_LIT( KUtilityFilename, "nssttsutility.dll" );
+// CreateInstanceL function ordinal number
+const TInt KFunctionOrdinal = 1;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::NewL
+// Two-phased constructor
+// ---------------------------------------------------------
+//
+CNssTtsUtilityWrapper* CNssTtsUtilityWrapper::NewL( MTtsClientUtilityObserver& aObserver,
+                                                    TInt aPriority,
+                                                    TMdaPriorityPreference aPref )
+    {
+    CNssTtsUtilityWrapper* self = new ( ELeave ) CNssTtsUtilityWrapper( 
+                                                 aObserver, aPriority, aPref );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::~CNssTtsUtilityWrapper
+// Destructor
+// ---------------------------------------------------------
+//
+CNssTtsUtilityWrapper::~CNssTtsUtilityWrapper()
+    {
+    RUBY_DEBUG0( "CNssTtsUtilityWrapper::~CNssTtsUtilityWrapper" );
+    if ( IsActive() )
+        {
+        Cancel();
+        }
+    delete iUtility;
+    // Close RLibrary handle    
+    iLib.Close();
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::CNssTtsUtilityWrapper
+// C++ constructor
+// ---------------------------------------------------------
+//
+CNssTtsUtilityWrapper::CNssTtsUtilityWrapper( MTtsClientUtilityObserver& aObserver,
+                                              TInt aPriority,
+                                              TMdaPriorityPreference aPref ) :
+                                              CActive( EPriorityStandard ),
+                                              iObserver( aObserver ),
+                                              iPriority( aPriority ),
+                                              iPref( aPref )
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::ConstructL
+// Second phase constructor
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssTtsUtilityWrapper::ConstructL" );
+    
+    // Load a DLL based on name with RLibrary    
+    User::LeaveIfError( iLib.Load( KUtilityFilename ) );
+    
+    // Find the TAny* CreateInstanceL() function    
+    TLibraryFunction entry = iLib.Lookup( KFunctionOrdinal );
+    if ( !entry )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    // Call CreateInstanceL
+    // Cannot use static_cast since entry() call returns TInt
+    iUtility = ( MTtsUtilityBase* ) entry();
+    
+    // Do the 2nd phase construction
+    iUtility->CreateInstanceSecondPhaseL( *this );
+    
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::AddStyleL
+// Forwards call to TTS Utility
+// ---------------------------------------------------------
+//
+TTtsStyleID CNssTtsUtilityWrapper::AddStyleL( const TTtsStyle& aStyle )
+    {
+    return iUtility->AddStyleL( aStyle );
+    }
+        
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::OpenAndPlayParsedTextL
+// Forwards call to TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::OpenAndPlayParsedTextL( CTtsParsedText& aText, 
+                                                    TInt /*aPriority*/, 
+                                                    TMdaPriorityPreference /*aPref*/ )
+    {
+    iUtility->OpenAndPlayParsedTextL( aText );
+    }
+                                     
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::Stop
+// Forwards call to TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::Stop()
+    {
+    iUtility->Stop();
+    }
+        
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::Play
+// Forwards call to TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::Play()
+    {
+    iUtility->Play();
+    }
+        
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::Close
+// Forwards call to TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::Close()
+    {
+    iUtility->Close();
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::MapcCustomCommandEvent
+// Callback from TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::MapcCustomCommandEvent( TInt /*aEvent*/, 
+                                                    TInt /*aError*/ )
+    {
+    // Nothing
+    }
+	    
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::MapcInitComplete
+// Callback from TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::MapcInitComplete( TInt aError, 
+                                              const TTimeIntervalMicroSeconds& aDuration )
+    {
+    RUBY_DEBUG1( "CNssTtsUtilityWrapper::MapcInitComplete, aError[%d]", aError );    
+    iError = aError;
+    iDuration = aDuration;
+    iState = EInitComplete;
+    Ready();
+    }
+    
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::MapcPlayComplete
+// Callback from TTS Utility
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::MapcPlayComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "CNssTtsUtilityWrapper::MapcPlayComplete, aError[%d]", aError );       
+    iError = aError;
+    iState = EPlayComplete;
+    Ready();
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::Ready
+// Sets active object ready to be run
+// ---------------------------------------------------------
+//    
+void CNssTtsUtilityWrapper::Ready()
+    {
+    if ( !IsActive() )
+        {
+        SetActive();
+        TRequestStatus* stat = &iStatus;
+        User::RequestComplete( stat, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssTtsUtilityWrapper::RunL
+// From CActive
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::RunL()
+    {
+    // Forwards callback to other parts of VAS    
+    RUBY_DEBUG_BLOCK( "CNssTtsUtilityWrapper::RunL" );    
+    switch ( iState )
+        {
+        case EInitComplete:
+            iObserver.MapcInitComplete( iError, iDuration );
+            break;
+            
+        case EPlayComplete:
+            iObserver.MapcPlayComplete( iError );
+            break;
+            
+        default:
+            RUBY_ERROR1( "CNssTtsUtilityWrapper::RunL unexpected state %d", iState );
+            break;
+        }
+    }
+	    
+// ---------------------------------------------------------
+// CNssSiUtilityWrapper::DoCancel
+// From CActive
+// ---------------------------------------------------------
+//
+void CNssTtsUtilityWrapper::DoCancel()
+    {
+    // Nothing
+    }    
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvascore/src/vascvpbkhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1338 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <coemain.h> 
+#include <centralrepository.h>
+#include <featmgr.h>
+
+#include <PbkFields.hrh>
+
+#include <VPbkEng.rsg>
+
+#include <CVPbkContactManager.h> 
+#include <CVPbkContactStoreUriArray.h> 
+#include <VPbkContactStoreUris.h>
+#include <TVPbkContactStoreUriPtr.h> 
+#include <MVPbkContactStoreList.h> 
+#include <CVPbkContactIdConverter.h> 
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkFieldType.h>
+#include <CVPbkDefaultAttribute.h>
+#include <MVPbkContactAttributeManager.h>
+#include <MVPbkContactFieldTextData.h> 
+#include <MVPbkContactFieldUriData.h>
+#include <MVPbkContactViewBase.h> 
+#include <CVPbkContactViewDefinition.h>
+
+#include <nssvasmtag.h>
+#include <nssvascoreconstant.h>
+
+#include "vascvpbkhandler.h"
+#include "vasmcontactobserver.h"
+
+#include "srsfprivatecrkeys.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+
+// Priority list of virtual phonebook fields
+const TInt KFieldPriority[] = 
+    { 
+    R_VPBK_FIELD_TYPE_LANDPHONEGEN, 
+    R_VPBK_FIELD_TYPE_LANDPHONEHOME,
+    R_VPBK_FIELD_TYPE_LANDPHONEWORK, 
+    R_VPBK_FIELD_TYPE_MOBILEPHONEGEN,
+    R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, 
+    R_VPBK_FIELD_TYPE_MOBILEPHONEWORK,
+    R_VPBK_FIELD_TYPE_VIDEONUMBERGEN,
+    R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, 
+    R_VPBK_FIELD_TYPE_VIDEONUMBERWORK,
+    R_VPBK_FIELD_TYPE_FAXNUMBERGEN,
+    R_VPBK_FIELD_TYPE_FAXNUMBERHOME, 
+    R_VPBK_FIELD_TYPE_FAXNUMBERWORK,
+    R_VPBK_FIELD_TYPE_VOIPGEN,
+    R_VPBK_FIELD_TYPE_VOIPHOME, 
+    R_VPBK_FIELD_TYPE_VOIPWORK,
+    R_VPBK_FIELD_TYPE_IMPP,
+    R_VPBK_FIELD_TYPE_EMAILGEN,
+    R_VPBK_FIELD_TYPE_EMAILHOME, 
+    R_VPBK_FIELD_TYPE_EMAILWORK,
+    R_VPBK_FIELD_TYPE_FIRSTNAMEREADING,
+    R_VPBK_FIELD_TYPE_FIRSTNAME,
+    R_VPBK_FIELD_TYPE_LASTNAMEREADING,
+    R_VPBK_FIELD_TYPE_LASTNAME,
+    R_VPBK_FIELD_TYPE_COMPANYNAME,
+    R_VPBK_FIELD_TYPE_SECONDNAME
+    };
+const TInt KFieldPriorityCount = sizeof( KFieldPriority ) / sizeof ( TInt );
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CVasVPbkHandler* CVasVPbkHandler::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+EXPORT_C CVasVPbkHandler* CVasVPbkHandler::NewL()
+    {
+    CVasVPbkHandler* self = new (ELeave) CVasVPbkHandler;    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// Destructor
+EXPORT_C CVasVPbkHandler::~CVasVPbkHandler()
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::~CVasVPbkHandler START" );
+    
+    iObserver = NULL;
+    
+    delete iField;
+    
+    delete iContact;
+    
+    delete iOperation;
+    
+    delete iConverter;
+    
+    if ( iContactManager )
+        {
+        TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) );
+        }
+    delete iContactManager;
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::~CVasVPbkHandler EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::InitializeL
+// Initializes phonebook handles
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CVasVPbkHandler::InitializeL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::InitializeL" );
+    
+    __ASSERT_ALWAYS( !iContactManager, User::Leave( KErrAlreadyExists ) );
+    __ASSERT_ALWAYS( !iConverter, User::Leave( KErrAlreadyExists ) );
+    
+    FeatureManager::InitializeLibL();
+
+    iMMSSupported = FeatureManager::FeatureSupported( KFeatureIdMMS );
+
+    FeatureManager::UnInitializeLib();
+
+    CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+    uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) );
+    
+    iContactManager = CVPbkContactManager::NewL( *uriArray, NULL );
+    CleanupStack::PopAndDestroy( uriArray );
+
+    MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
+    storeList.OpenAllL( *this );
+    
+    // Synchronize the OpenAllL call
+    iWait.Start();
+    
+    User::LeaveIfError( iError );
+    
+    iConverter = CVPbkContactIdConverter::NewL( iContactManager->ContactStoresL().At( 0 ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::CreateContactObserverL
+// Creates the contact change notifier and sets observer as a listener
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CVasVPbkHandler::CreateContactObserverL( MVasContactObserver* aObserver )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::CreateContactObserverL" );
+    iObserver = aObserver;
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::CompressL
+// Compresses database
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CVasVPbkHandler::CompressL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::CompressL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    iOperation = iContactManager->CompressStoresL( *this );
+    
+    iWait.Start();
+    
+    User::LeaveIfError( iError );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::CompressL
+// Returns all contact ids from database
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CContactIdArray* CVasVPbkHandler::ContactIdArrayLC()
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactIdArrayLC START" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    CContactIdArray* array = CContactIdArray::NewLC();
+    
+    CVPbkContactViewDefinition* definition = CVPbkContactViewDefinition::NewL();
+    CleanupStack::PushL( definition );
+    
+    definition->SetType( EVPbkContactsView );
+    definition->SetUriL( VPbkContactStoreUris::DefaultCntDbUri() );
+    
+    MVPbkContactViewBase* view =
+        iContactManager->CreateContactViewLC( *this, *definition, iContactManager->FieldTypes() );
+
+    iWait.Start();
+    
+    User::LeaveIfError( iError );
+
+    for( int i = 0; i < view->ContactCountL(); ++i )
+        {
+        MVPbkContactLink* link = view->CreateLinkLC( i );        
+        
+        if ( link )
+            {
+            array->AddL( iConverter->LinkToIdentifier( *link ) );
+        
+            CleanupStack::PopAndDestroy(); // Destroy link
+            }
+        }
+        
+    CleanupStack::PopAndDestroy(); // Destroy view
+    CleanupStack::PopAndDestroy( definition );
+        
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactIdArrayLC EXIT" );
+    
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FindContactL
+// Finds a contact from the phonebook that matches given tag
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void CVasVPbkHandler::FindContactL( MNssTag* aTag )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindContactL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    delete iField;
+    iField = NULL;
+    
+    delete iContact;
+    iContact = NULL;
+        
+    MVPbkContactLink* link =
+        iConverter->IdentifierToLinkLC( aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) );
+       
+    iOperation = iContactManager->RetrieveContactL( *link, *this );
+    
+    iWait.Start();
+    
+    // If contact was not found, then request for immediate contact db resync
+    if ( iError == KErrNotFound )
+        {
+        CRepository* repository = CRepository::NewLC( KCRUidSRSFSettings );
+        
+        repository->Set( KSRSFFullResyncNeeded, KImmediateResync );
+        
+        CleanupStack::PopAndDestroy( repository );
+        }
+    
+    User::LeaveIfError( iError );
+    
+    CleanupStack::PopAndDestroy();  // Destroys the link
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FindContactL
+// Finds a contact from the phonebook that matches given contact id
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void CVasVPbkHandler::FindContactL( TInt32 aContactId, TBool aReadOnly )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindContactL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    delete iField;
+    iField = NULL;
+    
+    delete iContact;
+    iContact = NULL;
+        
+    MVPbkContactLink* link = iConverter->IdentifierToLinkLC( aContactId );
+       
+    iOperation = iContactManager->RetrieveContactL( *link, *this );
+    
+    iWait.Start();
+    
+    User::LeaveIfError( iError );
+    
+    if ( !aReadOnly )
+        {
+        iContact->LockL( *this );
+        
+        iWait.Start();
+        
+        User::LeaveIfError( iError );
+        }
+    
+    CleanupStack::PopAndDestroy();  // Destroys the link
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::CloseContactL
+// Closes contact with or without saving changes
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C void CVasVPbkHandler::CloseContactL( TBool aSaveChanges )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::CloseContactL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    if ( aSaveChanges )
+        {
+        iContact->CommitL( *this );
+        
+        iWait.Start();
+    
+        User::LeaveIfError( iError );
+        }
+    
+    delete iContact;
+    iContact = NULL;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FindFieldL
+// Finds a contact field that matches given tag
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void CVasVPbkHandler::FindFieldL( MNssTag* aTag )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindFieldL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    delete iField;
+    iField = NULL;
+    
+    TRAPD( error,
+        FindDefaultContactFieldL( aTag->RRD()->IntArray()->At( KVasExtensionCommandRrdLocation ) ) );
+    if ( error == KErrNotFound )
+        {
+        FindFieldL( aTag->RRD()->IntArray()->At( KVasFieldIdRrdLocation ) );
+        }
+        
+    if ( !iField )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FindFieldL
+// Finds a contact field that matches given field id
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void CVasVPbkHandler::FindFieldL( TInt aFieldId )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindFieldL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    delete iField;
+    iField = NULL;
+    
+    MVPbkStoreContactFieldCollection& fields = iContact->Fields();
+
+    TInt priority = KFieldPriorityCount;
+    for ( TInt index = 0; index < fields.FieldCount(); ++index )
+        {
+        if ( ConvertFieldId( fields.FieldAt( index ) ) == aFieldId &&
+             FieldPriority( fields.FieldAt( index ) ) < priority )
+            {
+            priority = FieldPriority( fields.FieldAt( index ) );
+            
+            delete iField;
+            iField = NULL;
+                            
+            iField = fields.FieldAtLC( index );
+            CleanupStack::Pop(); // Pops iField
+            }
+        }
+        
+    if ( !iField )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FindContactFieldL
+// Finds a contact and a field that mathes given tag
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void CVasVPbkHandler::FindContactFieldL( MNssTag* aTag )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindContactFieldL" );
+    
+    FindContactL( aTag );
+    FindFieldL( aTag );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FindDefaultContactFieldL
+// Tries to find a default field of given type from found contact
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CVasVPbkHandler::FindDefaultContactFieldL( TInt aCommandType )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindDefaultContactFieldL" );
+    
+    __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    TInt found = KErrNotFound;
+    
+    TVPbkDefaultType type = SelectDefaultType( aCommandType );
+    
+    if ( type != EVPbkDefaultTypeUndefined )
+        {
+        MVPbkContactAttributeManager& attributeManager = iContactManager->ContactAttributeManagerL();
+    
+        CVPbkDefaultAttribute* attribute = CVPbkDefaultAttribute::NewL( type );
+        CleanupStack::PushL( attribute );
+        
+        MVPbkStoreContactField* field =
+            attributeManager.FindFieldWithAttributeL( *attribute, *iContact );
+
+        if ( field && AcceptDefaultField( *field, aCommandType ) )
+            {
+            iField = field->CloneLC();
+            CleanupStack::Pop(); // Pops iField
+            found = KErrNone;
+            }
+        
+        CleanupStack::PopAndDestroy( attribute );
+        }
+    
+    User::LeaveIfError( found );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ChangeVoiceTagFieldL
+// Changes current field's voice tag field status
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CVasVPbkHandler::ChangeVoiceTagFieldL( TBool /*aSet*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::ChangeVoiceTagFieldL" );
+    
+    User::Leave( KErrNotSupported );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::LabelL
+// Returns the field label
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TPtrC CVasVPbkHandler::LabelL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::LabelL" );
+    
+    __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    if ( iField->BestMatchingFieldType()->FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP && 
+         iField->FieldData().DataType() == EVPbkFieldStorageTypeUri )
+        {
+        return MVPbkContactFieldUriData::Cast( iField->FieldData()).Scheme();
+        }
+
+    return iField->FieldLabel();
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::TextL
+// Returns the field text
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TPtrC CVasVPbkHandler::TextL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::TextL" );
+    
+    __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    if ( iField->FieldData().DataType() == EVPbkFieldStorageTypeText )
+        {
+        return MVPbkContactFieldTextData::Cast( iField->FieldData() ).Text();
+        }
+    else if ( iField->FieldData().DataType() == EVPbkFieldStorageTypeUri )
+        {
+        return MVPbkContactFieldUriData::Cast( iField->FieldData() ).Text();
+        }
+    else
+        {
+        return KNullDesC();
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FieldTypeL
+// Returns field type as an UID
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TFieldType CVasVPbkHandler::FieldTypeL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FieldTypeL" );
+    
+    __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    TFieldType uid = KNullUid;
+    
+    switch( iField->BestMatchingFieldType()->FieldTypeResId() )
+        {
+        case R_VPBK_FIELD_TYPE_LANDPHONEHOME:
+        case R_VPBK_FIELD_TYPE_LANDPHONEWORK:
+        case R_VPBK_FIELD_TYPE_LANDPHONEGEN:
+            {
+            uid = KUidContactFieldVCardMapVOICE;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME:
+        case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK:
+        case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN:
+            {
+            uid = KUidContactFieldVCardMapCELL;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_VIDEONUMBERHOME:
+        case R_VPBK_FIELD_TYPE_VIDEONUMBERWORK:
+        case R_VPBK_FIELD_TYPE_VIDEONUMBERGEN:
+            {
+            uid = KUidContactFieldVCardMapVIDEO;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_FAXNUMBERHOME:
+        case R_VPBK_FIELD_TYPE_FAXNUMBERWORK:
+        case R_VPBK_FIELD_TYPE_FAXNUMBERGEN:
+            {
+            uid = KUidContactFieldVCardMapFAX;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_VOIPHOME:
+        case R_VPBK_FIELD_TYPE_VOIPWORK:
+        case R_VPBK_FIELD_TYPE_VOIPGEN:
+        case R_VPBK_FIELD_TYPE_IMPP:
+            {
+            uid = KUidContactFieldVCardMapVOIP;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_EMAILHOME:
+        case R_VPBK_FIELD_TYPE_EMAILWORK:
+        case R_VPBK_FIELD_TYPE_EMAILGEN:
+            {
+            uid = KUidContactFieldVCardMapEMAILINTERNET;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_FIRSTNAME:
+            {
+            uid = KUidContactFieldGivenName;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_FIRSTNAMEREADING:
+            {
+            uid = KUidContactFieldGivenNamePronunciation;
+            break;
+            } 
+            
+        case R_VPBK_FIELD_TYPE_LASTNAME:
+            {
+            uid = KUidContactFieldFamilyName;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_LASTNAMEREADING:
+            {
+            uid = KUidContactFieldFamilyNamePronunciation;
+            break;
+            }
+            
+        case R_VPBK_FIELD_TYPE_COMPANYNAME:
+            {
+            uid = KUidContactFieldCompanyName;
+            break;
+            }            
+            
+        case R_VPBK_FIELD_TYPE_SECONDNAME:
+            {
+            uid = KUidContactFieldSecondName;
+            break;
+            }
+        }
+    
+    return uid;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FieldIdL
+// Returns field id as a phonebook id
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TInt CVasVPbkHandler::FieldIdL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FieldIdL" );
+    
+    __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    return ConvertFieldId( *iField );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::IsFieldEmptyL
+// Returns information if current field is empty
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TBool CVasVPbkHandler::IsFieldEmptyL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::IsFieldEmptyL" );
+    
+    __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) );
+    
+    return iField->FieldData().IsEmpty();
+    }    
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::StoreReady
+// -----------------------------------------------------------------------------
+//
+void CVasVPbkHandler::StoreReady( MVPbkContactStore& /*aContactStore*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::StoreReady START" );
+
+    iError = KErrNone;
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::StoreReady EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::StoreUnavailable
+// -----------------------------------------------------------------------------
+//
+void CVasVPbkHandler::StoreUnavailable( MVPbkContactStore& /*aContactStore*/, TInt aReason )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::StoreUnavailable START" );
+
+    iError = aReason;
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::StoreUnavailable EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::HandleStoreEventL
+// -----------------------------------------------------------------------------
+//
+void CVasVPbkHandler::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/,
+                                         TVPbkContactStoreEvent aStoreEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::HandleStoreEventL" );
+    
+    if ( iObserver )
+        {
+        TPhonebookEvent event;
+        event.iType = ConvertEvent( aStoreEvent );
+        
+        if ( aStoreEvent.iContactLink )
+            {
+            event.iContactId = iConverter->LinkToIdentifier( *aStoreEvent.iContactLink );
+            }
+        
+        iObserver->HandleEventL( event );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::OpenComplete
+// -----------------------------------------------------------------------------
+//
+void CVasVPbkHandler::OpenComplete()
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::OpenComplete START" );
+
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::OpenComplete EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::VPbkSingleContactOperationComplete
+// -----------------------------------------------------------------------------
+//
+void CVasVPbkHandler::VPbkSingleContactOperationComplete( MVPbkContactOperationBase& /*aOperation*/,
+                                                          MVPbkStoreContact* aContact )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationComplete START" );
+
+    iError = KErrNone;
+    
+    delete iOperation;
+    iOperation = NULL;
+    
+    iContact = aContact;
+
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationComplete EXIT" );
+    }
+                                                 
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::VPbkSingleContactOperationFailed
+// -----------------------------------------------------------------------------
+//                                       
+ void CVasVPbkHandler::VPbkSingleContactOperationFailed( MVPbkContactOperationBase& /*aOperation*/,
+                                                         TInt aError )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationFailed START" );
+
+    iError = aError;
+    
+    delete iOperation;
+    iOperation = NULL;
+    
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationFailed EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactOperationCompleted
+// -----------------------------------------------------------------------------
+//                                         
+void CVasVPbkHandler::ContactOperationCompleted( TContactOpResult /*aResult*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationCompleted START" );
+
+    iError = KErrNone;
+    
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationCompleted EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactOperationFailed
+// -----------------------------------------------------------------------------
+//   
+void CVasVPbkHandler::ContactOperationFailed( TContactOp /*aOpCode*/, TInt aErrorCode,
+                                              TBool /*aErrorNotified*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationFailed START" );
+
+    iError = aErrorCode;
+        
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationFailed EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::AttributeOperationComplete
+// -----------------------------------------------------------------------------
+//                                        
+void CVasVPbkHandler::AttributeOperationComplete( MVPbkContactOperationBase& /*aOperation*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationComplete START" );
+
+    iError = KErrNone;
+    
+    delete iOperation;
+    iOperation = NULL;
+
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationComplete EXIT" );
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::AttributeOperationFailed
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::AttributeOperationFailed( MVPbkContactOperationBase& /*aOperation*/,
+                                                TInt aError )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationFailed START" );
+
+    iError = aError;
+    
+    delete iOperation;
+    iOperation = NULL;
+    
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationFailed EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::StepComplete
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::StepComplete( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::StepComplete START" );
+
+    // Do nothing
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::StepComplete EXIT" );
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::StepFailed
+// -----------------------------------------------------------------------------
+//  
+TBool CVasVPbkHandler::StepFailed( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/,
+                                   TInt /*aError*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::StepFailed START" );   
+    RUBY_DEBUG0( "CVasVPbkHandler::StepFailed EXIT" );
+    
+    return EFalse;
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::OperationComplete
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::OperationComplete( MVPbkContactOperationBase& /*aOperation*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::OperationComplete START" );
+    
+    iError = KErrNone;
+    
+    delete iOperation;
+    iOperation = NULL;
+    
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::OperationComplete EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactViewReady
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::ContactViewReady( MVPbkContactViewBase& /*aView*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady START" );
+    
+    iError = KErrNone;
+    
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady EXIT" );
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactViewUnavailable
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::ContactViewUnavailable( MVPbkContactViewBase& /*aView*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewUnavailable" );
+    // Do nothing
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactAddedToView
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::ContactAddedToView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
+                                          const MVPbkContactLink& /*aContactLink*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewUnavailable" );
+    // Do nothing
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactRemovedFromView
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::ContactRemovedFromView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
+                                              const MVPbkContactLink& /*aContactLink*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewUnavailable" );
+    // Do nothing
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ContactViewError
+// -----------------------------------------------------------------------------
+//  
+void CVasVPbkHandler::ContactViewError( MVPbkContactViewBase& /*aView*/, TInt aError,
+                                        TBool /*aErrorNotified*/ )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady START" );
+    
+    iError = aError;
+    
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    
+    RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::CVasVPbkHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVasVPbkHandler::CVasVPbkHandler()
+ : iError( KErrNone )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVasVPbkHandler::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasVPbkHandler::ConstructL" );
+
+    }
+        
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::SelectDefaultType
+// Returns default field type for given tag
+// -----------------------------------------------------------------------------
+//
+TVPbkDefaultType CVasVPbkHandler::SelectDefaultType( TInt aCommandType )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::SelectDefaultType START" );
+    
+    TVPbkDefaultType type = EVPbkDefaultTypeUndefined;
+    
+    switch( aCommandType )
+        {
+        case EDefaultCommand:
+        case EMobileCommand:
+        case EGeneralCommand:
+        case EWorkCommand:
+        case EHomeCommand:       
+            {
+            type = EVPbkDefaultTypePhoneNumber;
+            break;
+            }
+    
+        case EEmailCommand:
+            {
+            type = EVPbkDefaultTypeEmail;
+            break;
+            }
+            
+        case EVideoCommand:
+            {
+            type = EVPbkDefaultTypeVideoNumber;
+            break;
+            }
+            
+        case EVoipCommand:
+            {
+            type = EVPbkDefaultTypeVoIP;
+            break;
+            }
+            
+        case EMessageCommand:
+            {
+            if ( iMMSSupported )
+                {
+                type = EVPbkDefaultTypeMms;
+                }
+            else
+                {
+                type = EVPbkDefaultTypeSms;
+                }
+            break;
+            }
+            
+        }
+        
+    RUBY_DEBUG0( "CVasVPbkHandler::SelectDefaultType EXIT" );
+        
+    return type;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::AcceptDefaultField
+// Accepts or rejects given field based on the given tag
+// -----------------------------------------------------------------------------
+//
+TBool CVasVPbkHandler::AcceptDefaultField( MVPbkStoreContactField& aField, TInt aCommandType )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::AcceptDefaultField START" );
+    
+    TBool accept = ETrue;
+    
+    if ( aCommandType == EMobileCommand &&
+         aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEHOME &&
+         aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEWORK &&
+         aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEGEN )
+        {
+        accept = EFalse;
+        }
+    else if ( aCommandType == EGeneralCommand &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEHOME &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEWORK &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEGEN )
+        {
+        accept = EFalse;
+        }
+    else if ( aCommandType == EWorkCommand &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEWORK )
+        {
+        accept = EFalse;
+        }
+    else if ( aCommandType == EHomeCommand &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEHOME )
+        {
+        accept = EFalse;
+        }
+    else if ( aCommandType == EVoipCommand &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEGEN &&
+              aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEGEN )
+        {
+        accept = EFalse;
+        }
+        
+    RUBY_DEBUG0( "CVasVPbkHandler::AcceptDefaultField EXIT" );
+        
+    return accept;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ConvertFieldId
+// Converts field id to old phonebook id
+// -----------------------------------------------------------------------------
+//
+TInt CVasVPbkHandler::ConvertFieldId( MVPbkStoreContactField& aField )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ConvertFieldId START" );
+    
+    TInt id = KErrNone;
+    
+    if ( aField.BestMatchingFieldType() )
+        {
+        switch( aField.BestMatchingFieldType()->FieldTypeResId() )
+            {
+            case R_VPBK_FIELD_TYPE_LANDPHONEGEN:
+                {
+                id = EPbkFieldIdPhoneNumberGeneral;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_LANDPHONEHOME:
+                {
+                id = EPbkFieldIdPhoneNumberHome;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_LANDPHONEWORK:
+                {
+                id = EPbkFieldIdPhoneNumberWork;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME:
+            case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK:
+            case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN:
+                {
+                id = EPbkFieldIdPhoneNumberMobile;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_VIDEONUMBERHOME:
+            case R_VPBK_FIELD_TYPE_VIDEONUMBERWORK:
+            case R_VPBK_FIELD_TYPE_VIDEONUMBERGEN:
+                {
+                id = EPbkFieldIdPhoneNumberVideo;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_FAXNUMBERHOME:
+            case R_VPBK_FIELD_TYPE_FAXNUMBERWORK:
+            case R_VPBK_FIELD_TYPE_FAXNUMBERGEN:
+                {
+                id = EPbkFieldIdFaxNumber;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_VOIPHOME:
+            case R_VPBK_FIELD_TYPE_VOIPWORK:
+            case R_VPBK_FIELD_TYPE_VOIPGEN:
+                {
+                id = EPbkFieldIdVOIP;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_IMPP:
+                {
+                id = EPbkFieldIdXsp;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_EMAILHOME:
+            case R_VPBK_FIELD_TYPE_EMAILWORK:
+            case R_VPBK_FIELD_TYPE_EMAILGEN:
+                {
+                id = EPbkFieldIdEmailAddress;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_FIRSTNAMEREADING:
+                {
+                id = EPbkFieldIdFirstNameReading;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_FIRSTNAME:
+                {
+                id = EPbkFieldIdFirstName;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_LASTNAMEREADING:
+                {
+                id = EPbkFieldIdLastNameReading;
+                break;
+                }
+                            
+            case R_VPBK_FIELD_TYPE_LASTNAME:
+                {
+                id = EPbkFieldIdLastName;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_COMPANYNAME:
+                {
+                id = EPbkFieldIdCompanyName;
+                break;
+                }
+                
+            case R_VPBK_FIELD_TYPE_SECONDNAME:
+                {
+                id = EPbkFieldIdSecondName;
+                break;
+                }
+            }
+        }
+    else
+        {
+        RUBY_DEBUG0( "aField.BestMatchingFieldType() returned NULL" );
+        }
+        
+    RUBY_DEBUG0( "CVasVPbkHandler::ConvertFieldId EXIT" );
+        
+    return id;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::ConvertEvent
+// Converts contact event type
+// -----------------------------------------------------------------------------
+//
+TVasContactEvent CVasVPbkHandler::ConvertEvent( const TVPbkContactStoreEvent& aEvent )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::ConvertEvent START" );
+   
+    TVasContactEvent event;
+    
+    switch( aEvent.iEventType )
+        {
+        case ENullEvent:       
+            {
+            event = ENullEvent;
+            break;
+            }
+    
+        case EContactChanged:
+            {
+            event = EContactChanged;
+            break;
+            }
+            
+        case EContactDeleted:
+            {
+            event = EContactDeleted;
+            break;
+            }
+            
+        case EContactAdded:
+            {
+            event = EContactAdded;
+            break;
+            }
+            
+        case EUnknownChanges:
+            {
+            event = EUnknownChanges;
+            break;
+            }
+            
+        case EGroupAdded:       
+            {
+            event = EGroupAdded;
+            break;
+            }
+    
+        case EGroupChanged:
+            {
+            event = EGroupChanged;
+            break;
+            }
+            
+        case EGroupDeleted:
+            {
+            event = EGroupDeleted;
+            break;
+            }
+            
+        case EStoreBackupBeginning:
+            {
+            event = EStoreBackupBeginning;
+            break;
+            }
+            
+        case EStoreRestoreBeginning:
+            {
+            event = EStoreRestoreBeginning;
+            break;
+            }
+            
+        case EStoreBackupRestoreCompleted:
+            {
+            event = EStoreBackupRestoreCompleted;
+            break;
+            }
+        
+        default:
+            {
+            event = ENotSupported;
+            break;
+            }
+        }
+    RUBY_DEBUG0( "CVasVPbkHandler::ConvertEvent EXIT" );
+        
+    return event;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVasVPbkHandler::FieldPriority
+// Gets the priority of the given field
+// -----------------------------------------------------------------------------
+//
+TInt CVasVPbkHandler::FieldPriority( MVPbkStoreContactField& aField )
+    {
+    RUBY_DEBUG0( "CVasVPbkHandler::FieldPriority START" );
+    
+    TInt priority = KFieldPriorityCount;
+    
+    for ( int i = 0; i < KFieldPriorityCount; ++i )
+        {
+        if ( aField.BestMatchingFieldType()->FieldTypeResId() == KFieldPriority[ i ] )
+            {
+            priority = i;
+            break;
+            }
+        }
+    RUBY_DEBUG0( "CVasVPbkHandler::FieldPriority EXIT" );
+    
+    return priority;
+    }
+
+//  End of File
+
Binary file srsf/nssvasapi/nssvasdb/inc/10201afe.spd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasccontextmgr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,358 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CContextManager provides context processing for the client. CContextManager
+*               implements the MNssContextMgr interface, and also provides additional methods for
+*               use by internal VAS components. 
+*
+*/
+
+
+#ifndef NSSVASCCONTEXTMGR_H
+#define NSSVASCCONTEXTMGR_H
+
+// INCLUDES
+//
+#include <e32std.h>
+#include <e32base.h>
+
+#include "nssvasmcontextmgr.h"
+#include "nssvasmcontext.h"
+#include "nssvasmgetcontextclient.h"
+#include "nssvasmdeletecontextclient.h"
+#include "nssvasmsavecontextclient.h"
+#include "nssvasmintercompcontextmgrclient.h"
+#include "nssvasmvasdatabaseclient.h"
+#include "nssvasmcoresrsdbeventhandler.h"
+#include "nssvascoreconstant.h"
+
+// FORWARD DECLARATIONS
+class CNssContextBuilder;
+class CNssVASDatabase;
+class MNssResetFactoryModelsClient;
+
+// CLASS DECLARATIONS
+/**
+*  CContextMgr is the implementation class for MNssContextMgr interface.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssContextMgr :
+    public CActive,
+    public MNssContextMgr,
+    public MNssVASDatabaseClient,
+    public MNssCoreSrsDBEventHandler
+    {
+public:
+
+    enum TNssCallBackState
+        {
+	    ENone,
+	    EGetContextClientGetContext,
+	    EGetContextClientGetContextList,
+	    EDeleteContextClient,
+	    ESaveContextClient,
+        ESaveClientDataClient,
+	    EInterCompContextMgrClientGetContext,
+	    EInterCompContextMgrClientGetContextList,
+	    EInterCompContextMgrClientGetGlobalContexts
+	    };
+
+   /**
+   * 
+   * Destructor.
+   */
+   ~CNssContextMgr();
+
+   /**
+   * 2 Phase construction
+   * @param aVASDatabase - Reference to the database.
+   * @return void
+   */
+   static CNssContextMgr* NewL(CNssVASDatabase* aVASDatabase);
+
+   /**
+   * 2 Phase construction
+   * @param aVASDatabase - Reference to the database.
+   * @return void
+   */
+   static CNssContextMgr* NewLC(CNssVASDatabase* aVASDatabase);
+
+
+   /**
+   * Creates an empty context object
+   * @since 2.8
+   * @param void
+   * @return A reference to the context object
+   */
+   MNssContext* CreateContextL();
+
+
+   /**
+   * GetContext is called to retrieve a context from the VAS DB. 
+   * This method is asynchronous. A call back will be made to 
+   * either GetContextCompleted() or GetContextFailed() as
+   * defined in the MNssGetContextClient interface. It also returns an
+   * error code validating success of call to VAS DB.
+   * @since 2.8
+   *
+   * @param aContextClient - call back address
+   * @param aName          - name of context to retreive
+   * @return - syncronous error code from function return
+   */    
+   TInt GetContext(MNssGetContextClient* aContextClient,const TDesC& aName);
+
+   /**
+   * GetContextList is called to retrieve a context list from the VAS DB. 
+   * This method is asynchronous. A call back will be made to 
+   * either GetContextListCompleted() or GetContextFailed() as
+   * defined in the MNssGetContextClient interface. It also returns an
+   * error code validating success of call to VAS DB.
+   * @since 2.8
+   *
+   * @param aContextClient - call back address 
+   * @param  
+   * @return - syncronous error code from function return
+   */    
+   TInt GetContextList(MNssGetContextClient* aContextClient);
+   
+   /**
+   * DeleteContext is called to remove a context from the VAS DB. 
+   * This method is asynchronous. A call back will be made to 
+   * either DeleteContextCompleted() or DeleteContextFailed() as
+   * defined in the MNssDeleteContextClient interface. It also returns an
+   * error code validating success of call to VAS DB.
+   * @since 2.8
+   *
+   * @param aContextClient - call back address
+   * @param aContext       - context object to delete
+   * @return syncronous error code from function return
+   */     
+   TInt DeleteContext(MNssDeleteContextClient* aContextClient, MNssContext* aContext);
+   
+   /**
+   * SaveContext is called to store a context to the VAS DB. 
+   * This method is asynchronous. A call back will be made to 
+   * either SaveContextCompleted() or SaveContextFailed() as
+   * defined in the MNssSaveContextClient interface. It also returns an
+   * error code validating success of call to VAS DB.
+   * @since 2.8
+   *
+   * @param aContextClient - call back address
+   * @param aContext       - context object to save
+   * @return - syncronous error code from function return
+   */ 
+   TInt SaveContext( MNssSaveContextClient* aContextClient, MNssContext* aContext);
+
+   /**
+   * SaveClientData is called to save client-specific data about the context.
+   * This method is asynchronous. A call back will be made to either
+   * SaveContextCompleted or SaveContextFailed() as defined in the
+   * MNssSaveContextClient interface. It also returns an error code validating
+   * success of call to VAS DB.
+   *
+   * @from VasMNssContextMgr
+   * @since 2.8
+   * @param aContext       - the client data of this context will be updated.
+   */
+   TInt SaveClientData( MNssContext* aContext );
+
+   /**
+   * GetGlobalContexts is called to get the list of global contexts in VAS DB. 
+   * This method is synchronous (It used to be asynchronous before 2.8. A call
+   * back was made to  either GetGlobalContextsCompleted() or GetContextFailed()
+   * as defined in the MNssInterCompContextMgrClient interface. It also returned an
+   * error code validating success of call to VAS DB). This method is for use by
+   * internal VAS components.
+   * @since 2.8
+   *
+   * @param aContextClient - call back address
+   * @return - syncronous error code from function return
+   */
+   TMNssContextList* GetGlobalContexts();
+
+   /**
+   * Call back function from CVASDatabase, through interface MNssVASDatabaseClient
+   * @since 2.8
+   * @param aContextList - list of contexts
+   * @param aTagList - list of tags (not used by context manager)
+   * @param aTagRefList - list of tag references
+   * @param aCode - success status
+   * @return 
+   */     
+   void VASDatabaseComplete( CArrayPtrFlat<CNssContext>* aContextList, 
+                             CArrayPtrFlat<CNssTag>* aTagList,
+	                         CArrayPtrFlat<CNssTagReference>* aTagRefList,
+	                         TNssVASDBClientReturnCode aCode);
+
+
+   /**
+   * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler
+   * Called after saving to SRS DB is successful
+   * @since 2.8
+   * @param
+   * @return 
+   */     
+   void HandleSaveSrsDBCompleted();
+
+   /**
+   * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler
+   * Called after deleting from SRS DB is successful
+   * @since 2.8
+   * @param
+   * @return 
+   */     
+   void HandleDeleteSrsDBCompleted();
+
+   /**
+   * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler
+   * Called after deleting from SRS DB is successful
+   * @since 2.8
+   * @param
+   * @return 
+   */     
+   void HandleResetSrsDBCompleted();
+
+   /**
+   * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler
+   * Called after saving or deleting to SRS DB is unsuccessful
+   * @since 2.8
+   * @param aResult result code 
+   * @return 
+   */     
+   void HandleSrsDBError(MNssCoreSrsDBEventHandler::TNssSrsDBResult aResult);
+
+   /**
+   * Determine if tag exists in the VAS Database for a context
+   * @since 2.8
+   * @param context pointer
+   * @return ETrue if a context exists, EFalse otherwise.
+   */     
+   TBool TagExist(CNssContext* aContext);
+
+   /**
+   * Cancel get context / get context list / get global contexts 
+   * @since 2.8
+   * @param none
+   * @return none
+   */     
+   void CancelGetContext();
+
+   /**
+   * Deletes the speaker adapted models and creates new,
+   * speaker independent ones. Asynchronous.
+   * @since 2.8
+   * @param aClient Callback to signal success or failure
+   * @return symbian-wide error code
+   */
+   TInt ResetFactoryModels( MNssResetFactoryModelsClient* aClient );
+
+   /**
+   * Error handler if RunL leaves.
+   * @from CActive
+   * @since 2.8
+   * @param aClient Callback to signal success or failure
+   * @return none
+   */
+   TInt RunError(TInt aError);
+
+   /**
+   * Look at CActive documentation for exaplanation.
+   * @from CActive
+   * @since 2.8
+   * @param aClient Callback to signal success or failure
+   * @return none
+   */
+   void RunL();
+
+   /**
+   * Look at CActive documentation for exaplanation.
+   * @from CActive
+   * @since 2.8
+   * @param none
+   * @return none
+   */
+   void DoCancel();
+
+private:
+	
+   /**
+   * C++ Constructor.
+   */
+   CNssContextMgr();
+
+   /**
+   * C++ overloaded Constructor.
+   */
+   CNssContextMgr(CNssVASDatabase* aVASDatabase);
+
+   /**
+   * Symbian constructor
+   */     
+   void ConstructL();
+
+   /**
+   * Utility function for CContext to MNssContext List conversion, and call back to client
+   * @param aSourceList a CContext list
+   * @return 
+   */  
+   void CNssContextListToMNssContextListConvertorL(CArrayPtrFlat<CNssContext>* aSourceList);
+
+private:
+    // VAS Database
+    CNssVASDatabase* iVasDatabase;
+
+    // context builder
+    CNssContextBuilder* iContextBuilder;
+
+    // internal state
+    TNssCallBackState iState;
+
+    // external get context client
+    MNssGetContextClient* iGetContextClient;
+
+    // external delete context client
+    MNssDeleteContextClient* iDeleteContextClient;
+
+    // external save context client
+    MNssSaveContextClient* iSaveContextClient;
+
+    // internal inter-component client
+    MNssInterCompContextMgrClient* iInterCompContextMgrClient;
+
+    // flag to denote if model bank and lexicon exist or not for
+    // VAS has a single model bank and lexicon
+    TBool iModelBankAndLexiconExist;
+
+    // model bank id, if model bank exists; else its not a valid id
+    TSIModelBankID iModelBankId;
+
+    // lexicon id, if lexicon exists; else its not a valid id
+    TUint32 iLexiconId;
+
+    // local pointer to context, used to handle error conditions
+    CNssContext* iLocalContext; 
+
+    // flag used to handle error conditions
+    TBool iRecovery; 
+
+    // For GetContext: Stores the context list
+    CArrayPtrFlat<CNssContext> *iContextList;
+
+    // Callback for ResetFactoryModels
+    MNssResetFactoryModelsClient* iResetClient;
+    };
+
+#endif // NSSVASCCONTEXTMGR_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascdbtagselectnotifier.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssDBTagSelectNotifier provides tag select notification to 
+*               its clients (observers). It itslef receives tag select notification
+*               from Recognition Handler.
+*
+*/
+
+
+#ifndef NSSVASCDBTAGSELECTNOTIFIER_H
+#define NSSVASCDBTAGSELECTNOTIFIER_H
+
+#include <e32base.h>
+#include "nssvascvasdatabase.h"
+#include "nssvasmdbtagselectnotifierclient.h"
+
+
+// CLASS DECLARATIONS
+/**
+*  CNssDBTagSelectNotifier provides tag select notification to its clients.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssDBTagSelectNotifier : public CActive
+{
+public:
+
+   /**
+   * 2 Phase construction
+   * @param aVasDatabase - a pointer to the datatbase
+   * @return a pointer to CNssDBTagSelectNotifier
+   */
+	static CNssDBTagSelectNotifier* NewL( CNssVASDatabase* aVasDatabase );
+   
+   /**
+   * 2 Phase construction
+   * @param aVasDatabase - a pointer to the datatbase
+   * @return a pointer to CNssDBTagSelectNotifier
+   */
+	static CNssDBTagSelectNotifier* NewLC( CNssVASDatabase* aVasDatabase );
+   
+	/**
+   * Destructor.
+   */	
+	~CNssDBTagSelectNotifier();
+   
+   /**
+   * Register a client (observer) for tag select notification
+   * @since 2.0
+   * @param aObserver - MNssDBTagSelectNotifierClient 
+   * @return error code
+   */
+   TInt RegisterForNotification( MNssDBTagSelectNotifierClient* aObserver );
+
+   /**
+   * Deregister a client (observer) from tag select notification
+   * @since 2.0
+   * @param aObserver - MNssDBTagSelectNotifierClient 
+   * @return error code
+   */
+   TInt Deregister( MNssDBTagSelectNotifierClient* aObserver );
+
+   /**
+   * Handle selection, called by regconition when tag is selected
+   * @since 2.0
+   * @param None
+   * @return None
+   */
+	void HandleSelection( CNssTag* aTag );
+
+private:
+
+    /**
+    * C++ constructor
+    */
+    CNssDBTagSelectNotifier();
+
+    /**
+    * Overloaded C++constructor
+    */
+    CNssDBTagSelectNotifier( CNssVASDatabase* aVasDatabase );
+
+    /**
+    * Symbian construtor
+    */
+    void ConstructL ();
+
+    /**
+    * Handles selection of a tag based on tag and context ids
+    *
+    * @param "TInt aTagId" Tag identifier
+    * @param "TInt aContextId" Context identifier
+    */
+    void DoHandleSelectionCallback( TInt aTagId, TInt aContextId );
+
+private: // From CActive
+
+    void RunL();
+    void DoCancel();
+
+private: 
+	// pointer to the VAS datatbase
+	CNssVASDatabase* iVasDatabase;
+
+	// list of observers (clients)
+	CArrayPtrFlat<MNssDBTagSelectNotifierClient> *iObserverList;
+	
+	// P&S handle
+	RProperty iProperty;
+	
+	// Values read from P&S
+	TInt iTagId;
+	TInt iContextId;
+};
+
+#endif // NSSVASCDBTAGSELECTNOTIFIER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascresourcehandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Reads the VAS resource file and keeps the information in
+*               member variables for later use.
+*
+*/
+
+
+#ifndef NSSVASCRESOURCEHANDLER_H
+#define NSSVASCRESOURCEHANDLER_H
+
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+/**
+*  This class encapsulates resource file handling functions
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+NONSHARABLE_CLASS( CNssVasResourceHandler ) : public CBase
+	{
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CNssVasResourceHandler* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CNssVasResourceHandler();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CNssVasResourceHandler();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Reads the data from the resource file.
+        */
+		void ReadResourceFileL();
+
+	public: // Data
+
+        // Path of the database
+        HBufC* iDatabasePath;
+
+        // Database filename
+        HBufC* iDatabaseName;
+	};
+
+#endif // NSSVASCRESOURCEHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasctagmgr.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,338 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssTagMgr implements the MNssTagMgr interface. In addition, it also provides
+*               methods for internal use by VAS components.
+*
+*/
+
+
+#ifndef NSSVASCTAGMGR_H
+#define NSSVASCTAGMGR_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include "nssvasmtagmgr.h"
+#include "nssvasmgettagclient.h"
+#include "nssvasmdeletetagclient.h"
+#include "nssvasmsavetagclient.h"
+#include "nssvasmintercomptagmgrclient.h"
+#include "nssvasmcoresrsdbeventhandler.h"
+#include "nssvasmvasdatabaseclient.h"
+#include "nssvascoreconstant.h"
+#include "nssvasmtagreference.h"
+#include "nssvasmgettagreferenceclient.h"
+#include "nssvasmcoresyncrecoveryhandler.h"
+#include "nssvascvasdbdataexchanger.h"
+
+// FORWARD DECLARATION
+class CNssSpeechItemBuilder; 
+class CNssContextMgr;
+class CNssTag;
+class CNssVASDatabase;
+
+// CLASS DECLARATIONS
+/**
+*  CNssTagMgr implements the MNssTagMgr interface for tag management services.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssTagMgr:
+    public CActive,
+    public MNssTagMgr, 
+    public MNssCoreSrsDBEventHandler, 
+    public MNssVASDatabaseClient
+{
+public:
+
+   /**
+   * destructor
+   */     
+   ~CNssTagMgr();
+ 
+   /**
+   * 2 phase constructor
+   * @param aVasDatabase - pointer to the VAS Database
+   * @param aContextManager - pointer to the context manager
+   * @return pointer the created tag manager
+   */     
+   static CNssTagMgr* NewL(CNssVASDatabase* aVasDatabase, CNssContextMgr *aContextManager);
+
+   /**
+   * 2 phase constructor
+   * @param aVasDatabase - pointer to the VAS Database
+   * @param aContextManager - pointer to the context manager
+   * @return pointer the created tag manager
+   */     
+   static CNssTagMgr* NewLC(CNssVASDatabase* aVasDatabase, CNssContextMgr *aContextManager);
+
+   /**
+   * Creates a new tag
+   * @since 2.0
+   * @param aContext - pointer to context 
+   * @return newly created tag
+   */   
+   MNssTag* CreateTagL(MNssContext* aContext);
+   
+   /**
+   * gets tag list, implementation of interface MNssTagMgr
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aContext - context for which to get tags
+   * @return synchronous error codes
+   */   
+   TInt GetTagList(MNssGetTagClient* aTagClient,MNssContext* aContext);
+   
+   /**
+   * gets tag list, implementation of interface MNssTagMgr
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aName - name for which to get tags
+   * @return synchronous error codes
+   */   
+   TInt GetTagList(MNssGetTagClient* aTagClient, MNssContext* aContext, const TDesC& aName);
+   
+  
+   /**
+   * delete tag, implementation of interface MNssTagMgr
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTag - tag to delete
+   * @return synchronous error codes
+   */   
+   TInt DeleteTag(MNssDeleteTagClient* aTagClient,MNssTag* aTag);
+
+   /**
+   * save tag, implementation of interface MNssTagMgr
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTag - tag to save
+   * @return synchronous error codes
+   */   
+   TInt SaveTag(MNssSaveTagClient* aTagClient,MNssTag* aTag);
+   
+   /**
+   * get a tag based on grammar id and rule id.
+   * for use by VAS components, call back returns a list with one element.
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aGrammarId - grammar id
+   * @param aRuleId - rule id
+   * @return synchronous error codes
+   */ 
+   CNssTag* GetTag( TUint32 aGrammarId, TUint32 aRuleId );
+   
+   /**
+   * get tags based on their grammar id and rule id.
+   * for use by VAS components, call back returns a list with one element.
+   * @param aGrammarIdRuleIds array of grammarid-ruleid pairs
+   * return array list. It is to be destroyed by the client
+   */ 
+   MNssTagListArray* GetTags( TNssGrammarIdRuleIdListArray&  aGrammarIdRuleIds);
+   
+
+   /**
+   * call back implementation from MNssVASDatabaseClient
+   * @since 2.0
+   * @param aContextList - list of contexts (not used in tag manager)
+   * @param aTagList - list of tags
+   * @param aCode - error code if failed
+   * @return
+   */     
+   void VASDatabaseComplete( CArrayPtrFlat<CNssContext>* aContextList, 
+                             CArrayPtrFlat<CNssTag>* aTagList,
+	                         CArrayPtrFlat<CNssTagReference>* aTagRefList,
+	                         MNssVASDatabaseClient::TNssVASDBClientReturnCode aCode);
+
+
+   /**
+   * call back implementation from MNssCoreSrsDBEventHandler
+   * @since 2.0
+   * @param
+   * @return
+   */     
+   void HandleSaveSrsDBCompleted();
+
+   /**
+   * call back implementation from MNssCoreSrsDBEventHandler
+   * @since 2.0
+   * @param 
+   * @return
+   */     
+   void HandleDeleteSrsDBCompleted();
+
+   /**
+   * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler
+   * Called after deleting from SRS DB is successful
+   * @since 2.8
+   * @param
+   * @return 
+   */     
+   void HandleResetSrsDBCompleted();
+
+   /**
+   * call back implementation from MNssCoreSrsDBEventHandler
+   * @since 2.0
+   * @param 
+   * @return
+   */     
+   void HandleSrsDBError(MNssCoreSrsDBEventHandler::TNssSrsDBResult aResult);
+
+   /**
+   * utility function for CNssTag List to MNssTag List conversion, and call back to client
+   * @since 2.0
+   * @param aSourceList - CNssTag List
+   * @return
+   */     
+   void CNssTagListToMNssTagListConvertorL(CArrayPtrFlat<CNssTag>* aSourceList);
+
+   /**
+   * Cancel get tag, for use by inter component clients only, not provided for 
+   * external clients.
+   * @since 2.0
+   * @param none
+   * @return none
+   */     
+   void CancelGetTag();
+
+   /**
+   * gets a tagCount, implementation of interface MNssTagMgr
+   * @since 2.0
+   * @param aContext - context for which to get tag count.
+   * @return synchronous error codes or tagCount
+   */   
+   TInt TagCount(MNssContext* aContext);
+
+   /**
+   * get the tag(s) based on partial rrd int data and position
+   * @since 2.0
+   * @param aTInt - the rrd int value.
+   * @param aPosition - the position of the int value in rrd int array
+   * @return synchronous error codes or tagCount
+   */ 
+   
+   TInt GetTagList(MNssGetTagClient* aTagClient,MNssContext* aContext,TInt aNum,TInt aPosition);
+   /**
+   * get the tag(s) based on partial rrd text data and position
+   * @since 2.0
+   * @param aTInt - the rrd text value.
+   * @param aPosition - the position of the int value in rrd int array
+   * @return synchronous error codes or tagCount
+   */      
+   
+   TInt GetTagList(MNssGetTagClient* aTagClient,MNssContext* aContext,TDesC& aText,TInt aPosition);
+   /**
+   * Get a list of tag references based on context. 
+   * @since 2.0
+   * @param aTagReferenceClient - call back address
+   * @param aContext - a context
+   * @return asynchronous return error code
+   */
+   TInt GetTagReferenceList(MNssGetTagReferenceClient* aTagRefClient,MNssContext* aContext);
+   /**
+   * Get a tag based on tagreference. 
+   * @since 2.0
+   * @param aTagClient - call back address
+   * @param aTagReference - a tagreferenc
+   * @return asynchronous return error code
+   */
+   TInt GetTag(MNssGetTagClient* aTagClient,MNssTagReference* aTagReference);
+
+   void CNssTagRefListToMNssTagRefListConvertorL(CArrayPtrFlat<CNssTagReference>* aSourceList);
+
+   /********************** ACTIVE OBJECT *******************/
+    TInt RunError( TInt aError );
+    void RunL();
+    void DoCancel();
+
+private:
+
+   enum TCallBackState
+   {
+	   ENone,
+	   EGetTagClient,
+	   EDeleteTagClient,
+	   ESaveTagClient,
+	   EInterCompTagMgrClient,
+	   EGetTagReferenceClient
+	};
+
+   /**
+   * C++ constructor
+   * @param 
+   * @return 
+   */  
+   CNssTagMgr();
+   
+   /**
+   * C++ constructor
+   * @param aVasDatabase - pointer to the VAS Database
+   * @param aContextManager - pointer to the context manager
+   * @return 
+   */  
+   CNssTagMgr(CNssVASDatabase* aVasDatabase, CNssContextMgr *aContextManager);
+
+   /**
+   * EPOC constructor
+   */     
+   void ConstructL();
+
+
+private:
+
+	// pointer to the VAS Database
+	CNssVASDatabase*  iVasDatabase;
+
+	// pointer to the speech item builder, tag manager owns this builder
+	CNssSpeechItemBuilder* iSpeechItemBuilder;
+
+	// pointer to a context manager, association
+	CNssContextMgr*	iContextManager;
+
+	// state of the tag manager
+	TCallBackState iState;
+
+	// get tag client call back address
+	MNssGetTagClient* iGetTagClient;
+
+	// delete tag client call back address
+	MNssDeleteTagClient* iDeleteTagClient;
+
+	// save tag clienat call back address
+	MNssSaveTagClient* iSaveTagClient;
+
+	// internal VAS components as clients, call back address
+	MNssInterCompTagMgrClient* iInterCompTagMgrClient;
+	
+	// local pointer to tag, for error handling
+	CNssTag*			iLocalTag; 
+
+	// local pointer to speech item, for error handling
+	CNssSpeechItem*	iLocalSpeechItem;
+	
+	// for error handling
+	TBool			iRecovery;
+    
+	// get tag reference client call back address
+	MNssGetTagReferenceClient*  iGetTagReferenceClient;
+
+    // Tag array for GetTag[List]
+    CArrayPtrFlat<MNssTag>* iTagList;
+
+    // Tag array for GetTagReferenceList
+    CArrayPtrFlat<MNssTagReference>* iTagRefList;
+};
+
+#endif // NSSVASCTAGMGR_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascvasdatabase.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,412 @@
+/*
+* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVasDatabase is responsible for the issuing of requests  to
+*               to the VasDb server and returning the results to the VasDb Managers.
+*
+*/
+
+
+#ifndef CNSSVASDATABASE_H
+#define CNSSVASDATABASE_H
+
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <s32file.h>
+#include <d32dbms.h>
+#include "nssvasrvasdbsession.h" 
+#include "nssvasmgetcontextclient.h"
+#include "nssvasmgettagclient.h"
+#include "nssvasccontext.h"
+#include "nssvasctag.h"
+#include "nssvascrrd.h"
+#include "nssvascvasdbdataexchanger.h"
+#include "nssvasmvasdatabaseclient.h"
+#include "nssvascspeechitembuilder.h"
+#include "nssvasccontextbuilder.h"
+#include "nssvascvasdbeventmonitor.h"
+#include "nssvasctagreference.h"
+#include "nssvasmcoresyncrecoveryhandler.h"
+
+// CLASS DECLARATIONS
+/**
+*
+*  The CNssVasDatabase class definition. 
+* 
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssVASDatabase: public CBase 
+    {
+public:
+
+     /**
+     * Two-phased constructor.
+    */
+   	static CNssVASDatabase* NewL(TInt aPriority);
+    /**
+    * Two-phased constructor.
+    */
+	static CNssVASDatabase* NewLC(TInt aPriority);
+	/**
+	* Destructor
+	*/
+	~CNssVASDatabase();
+	// VAS Db
+	/**
+    * Method to create vas database
+    * @since 2.0
+    * @param 
+    * @return TInt a success or failure code.
+    */
+	TInt CreateDb();
+	/**
+    * Method to open vas database
+    * @since 2.0
+    * @param 
+    * @return TInt a success or failure code.
+    */
+	TInt OpenDatabase();
+	/**
+    * Method to close vas database.
+    * @since 2.0
+    * @param 
+    * @return void
+    */
+    void CloseDatabase();
+
+    // ContextMgr Requests
+	/**
+    * Method to determine if modelbank and lexicon ids exist.
+    * @since 2.0
+    * @param aModelBankId- The modelbank id
+	* @param aLexiconId - The lexicon id
+    * @return TBool ETrue or EFalse.
+    */
+	TBool ModelBankAndLexiconExist(TUint32 &aModelBankId, TUint32 &aLexiconId);
+	/**
+    * Method to save context.
+    * @since 2.0
+    * @param aContext - .
+    * @return TInt success or failure code.
+    */
+    TInt SaveContext( CNssContext* aContext, TInt& aNewContextId );
+
+	/**
+    * Updates the client data of the context
+    * @since 2.8
+    * @param aContext - .
+    * @return TInt success or failure code.
+    */
+    TInt SaveContextClientData(CNssContext* aContext);
+
+	/**
+    * Method to get context by name
+    * @since 2.0
+    * @param aName -  The name of the context.
+    * @return CArrayPtrFlat<CNssContext>* List of contexts.
+    */
+	CArrayPtrFlat<CNssContext>* GetContext(const TDesC& aName);
+
+	/**
+    * Method to get all global contexts.
+    * @since 2.0
+    * @return CArrayPtrFlat<CNssContext>* List of contexts.
+    */
+	CArrayPtrFlat<CNssContext>* GetGlobalContexts();
+
+	/**
+    * Method to get all contexts.
+    * @since 2.0
+    * @return CArrayPtrFlat<CNssContext>* List of contexts.
+    */
+	CArrayPtrFlat<CNssContext>* GetAllContexts();
+
+	/**
+    * Method to transfer context list to client side.
+    * @since 2.0
+    * @param 
+    * @return TInt success or failure code.
+    */
+	TInt TransferContextList();
+
+	/**
+    * Method to delete context by name.
+    * @since 2.0
+    * @param aName- The name of the context to delete.
+    * @return TInt success or failure code.
+    */
+	TInt DeleteContext( const TDesC& aName );
+
+    /**
+    * Method to delete context.
+    * @since 2.0
+    * @param aContext-  The context to delete.
+    * @return TInt success or failure code.
+    */
+	TInt DeleteContext( CNssContext* aContext );
+
+	// TagMgr Requests	
+	/**
+    * Method to save a tag.
+    * @since 2.0
+    * @param aTag The voice tag to save.
+    * @return TInt sucess of failure code.
+    */
+	TInt SaveTag( CNssTag* aTag, TInt& aNewId );
+
+    /**
+    * Method to save several tags.
+    * @since 2.8
+    * @param aTagArray The voice tags to save.
+    * @return TInt success or failure code.
+    */
+    TInt SaveTags( RPointerArray<CNssTag>* aTagArray );
+
+    /**
+    * Method to delete several tags.
+    * @since 2.8
+    * @param aTagArray The voice tags to delete.
+    * @return TInt success or failure code.
+    */
+    TInt DeleteTags( const RArray<TUint32>& aTagIdArray );
+
+    /**
+    * Method to get a tag by name.
+    * @since 2.0
+    * @param aName- The name of the voice tag.
+    * @return TInt success or failure code.
+    */
+	MNssTagListArray* GetTag( const TDesC& aName );
+
+    /**
+    * Initiate the Select Tag event.
+    * @since 2.0
+    * @param aTag The voice tag which was selected.
+    * @return TNssRecognitionResult Return indicating request is valid.
+    */
+	MNssTagListArray* GetTag( CNssContext* aContext );
+    /**
+    * Method to get tag by grammar id and rule id.
+    * @since 2.0
+    * @param aGrammarId - The grammar id of the voice tag.
+	* @param aRuleId - The rule id of the voice tag.
+    * @return TInt success or failure code.
+    */	
+	MNssTagListArray* GetTag( const TInt aGrammarID, const TInt aRuleID );
+	
+	/**
+    * Method to tags by theirgrammar id and rule id.
+    * @param aGrammarId - The grammar id of the voice tag.
+	* @param aRuleId - The rule id of the voice tag.
+    * @return TInt success or failure code.
+    */	
+	MNssTagListArray* GetTags( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds);
+	
+    /**
+    * Method to get a tag by context and name.
+    * @since 2.0
+    * @param aContext - The context of the tag.
+	* @param aName - The name of the tag.
+    * @return TInt success or failure code.
+    */	
+	MNssTagListArray* GetTag( CNssContext* aContext, const TDesC& aName );
+
+    /**
+    * Method to get a tag by tagid.
+    * @since 2.0
+    * @param aTagId - The tagid of the voice tag.
+    * @return TInt success or failure code.
+    */
+	MNssTagListArray* GetTag( const TUint32 aTagId );
+
+   	/**
+    * Method to transfer tag list to client side.
+    * @since 2.0
+    * @param 
+    * @return TInt success or failure code.
+    */
+	TInt TransferTagList();
+
+    /**
+    * Method to delete tag by name.
+    * @since 2.0
+    * @param aName- The name of the voice tag to delete.
+    * @return TInt success or failure code.
+    */
+	TInt DeleteTag( const TDesC& aName );
+        /**
+    * Initiate the Select Tag event.
+    * @since 2.0
+    * @param aTag The voice tag which was selected.
+     * @return TInt success or failure code.
+    */
+	TInt DeleteTag( CNssTag *aTag );
+	/**
+    * Method to delete a tag by id
+    * @since 2.0
+    * @param aTagId- the tagid.
+    * @return TInt success or failure code.
+    */
+	TInt DeleteTag( const TUint32 aTagId );
+
+	// Event Monitoring methods
+    /**
+    * Method use to start monitoring vas database.
+    * @since 2.0
+    * @param 
+    * @return void
+    */
+	void StartMonitoringDatabaseL();
+	/**
+    * Method use to add observers to vas database. 
+    * @since 2.0
+    * @param aObserver- An observer of vas database.
+    * @return none
+    */
+	void AddObserverL( MNssVASDatabaseObserver* aObserver );
+	/**
+    * Method used to stop observering vas database.
+    * @since 2.0
+    * @param aObserver- The observer to remove.
+    * @return TInt success or failure code.
+    */
+	TInt RemoveObserver( MNssVASDatabaseObserver* aObserver );
+
+	/**
+	* Method to determine if tags exist for a context
+	* @since 2.0
+	* @param aContext - The context to check tags for.
+	* @return TBool ETrue or EFalse
+	*/
+    TBool TagExist( CNssContext* aContext );
+
+    /**
+	* Method to get the number of tags for a context
+	* @since 2.0
+	* @param aContext - The context to check tags for.
+	* @return TInt
+	*/
+    TInt TagCount( CNssContext* aContext );
+
+    /**
+	* Method to get tags based on a rrd int value and position
+	* @since 2.0
+	* @param aNum - The rrd int value
+	* @param aPosition - The int value position in the rrd intarray
+	*/
+	MNssTagListArray* GetTagList( CNssContext* aContext, TInt aNum, TInt aPosition );
+
+	/**
+	* Method to get tags based on a rrd text value and position
+	* @since 2.0
+	* @param aText - The rrd text value
+	* @param aPosition - The text value position in the rrd textarray
+	*/
+    MNssTagListArray* GetTagList( CNssContext* aContext, TDesC& aText, TInt aPosition );
+
+	CArrayPtrFlat<MNssTagReference>* GetTagReferenceList( CNssContext* aContext );
+
+	TInt TransferTagReferenceList();
+
+    /**
+    * Method to get the default model bank id
+    * @since 2.8
+    * @param aId reference where to put the model bank Id
+    * @return symbian-wide error code
+    */
+    TInt GetDefaultModelBankId( TUint32& aId );
+
+    /**
+    * Modifies the context table so that all contexts start using
+    * the new id as their model bank id.
+    * @since 2.8
+    * @param aNewId new model bank id
+    * @return symbian-wide error code
+    */
+    TInt ResetModelBank( TUint32 aNewId );
+
+    /**
+    * Changes the Rule ID of some tags.
+    * When an already trained tag is retrained, the Rule ID changes.
+    * This function updates the change to VAS DB.
+    * @since 2.8
+    * @param aNewId new model bank id
+    * @return symbian-wide error code
+    */
+    TInt UpdateTagRuleIDs( const RArray<TNssSpeechItem>& aRetrainedTags );
+
+private:
+
+	// C++ constructor
+    CNssVASDatabase(TInt aPriority);
+    // 2nd phase construction.
+    void ConstructL ();
+    
+    void ConvertTNssTagRefToMNssTagRefL( TNssTagReferenceListArray* aTNssTagRef,
+                                         CArrayPtrFlat<MNssTagReference>* aCNssTagRef);
+    MNssVASDatabaseClient::TNssVASDBClientReturnCode  ConvertDBError(TInt aError);
+
+
+    // Pointer to the object, which makes the actual operations on database.
+    CNssVasDb* iVasDb;
+
+    // How many VAS instances in this thread have connected.
+    TInt iConnected;
+
+    //Current state
+    TInt				         iState;
+    //Grammar and rule data passed to server
+    TNssGrammarIdRuleId          iTNssGrammarIdRuleId;
+    //Package for grammar and rule data
+    TPckgCTNssGrammarIdRuleId*   iGrammarIdRuleIdPackage;
+    //Taglist returned to client
+    CArrayPtrFlat<CNssTag>*      iCNssTagList;
+    //Contextlist returned to client
+    CArrayPtrFlat<CNssContext>*  iCNssContextList;
+    //Tag id
+    TUint32                   iTagId;
+    //Contextbuilder used to create contexts
+    CNssContextBuilder*          iContextBuilder;
+    //SpeechItembuilder used to create speechitems
+    CNssSpeechItemBuilder*       iSpeechItemBuilder;
+    //RRD int array data
+    //TNssRRDIntArray*             iRRDIntArray;
+    //RRD text array data
+    //TNssRRDTextArray*            iRRDTextArray;
+    //EventMonitor for vas db
+    CNssVASDBEventMonitor*		 iVASDBEventMonitor;
+
+    TNssTagReferenceListArray*       iTNssTagRefList;
+    CArrayPtrFlat<CNssTagReference>* iCNssTagRefList;
+
+    enum TState  //events
+        {
+        EStateGetContext = 0,
+	    EStateTransferContext,
+	    EStateGetTag,
+	    EStateTransferTag,
+	    EStateDeleteContext,
+	    EStateDeleteTag,
+	    EStateSaveContext,
+	    EStateSaveTag,
+	    EStateGetTagReference,
+	    EStateTransferTagReference
+        };
+
+    // Flag: Is the database locked
+    TBool iIsLocked;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascvasdb.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,566 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef CNSSVASDB_H
+#define CNSSVASDB_H
+
+#include <d32dbms.h>
+#include <e32def.h>
+#include "nssvascvasdbsrvdef.h"
+#include "nssvasdbkonsts.h"
+#include "nssvascvasdbdataexchanger.h"
+#include "nssvastvasdbcreator.h"
+#include "nssvascspeechitembuilder.h"
+#include "nssvasccontextbuilder.h"
+
+#include "nssvasctag.h"
+
+
+class CNssVasBackupObserver;
+
+
+// CLASS DECLARATION
+
+/**
+*
+*  The CNssVasDb class definition. 
+* 
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+NONSHARABLE_CLASS( CNssVasDb ) : public CBase
+    {
+public:
+	
+    /**
+    * Two-phased constructor.
+	* @since 2.0
+	* @param aClient - client thread
+	* @param aServer - vasdb server
+    */
+	static CNssVasDb* NewL( CNssContextBuilder& aContextBuilder,
+	                        CNssSpeechItemBuilder& aSpeechItemBuilder );
+
+	/**
+    * Destructor.  
+    * @since 2.0
+    * @param 
+    * @return void
+    */
+	~CNssVasDb();	
+
+public:
+
+    /**
+    * Read a context from the database. If context with this name is not present,
+    * leave with KErrNotFound.
+    * @since 2.8
+    * @param aName the name of the context
+    * @return CArrayFixFlat<CNssContext> A List of contexts.
+    */
+    CArrayPtrFlat<CNssContext>* GetContextByNameL( const TDesC& aName );
+
+    /**
+    * Read all global contexts from the database. Contexts have a flag, which
+    * tells if they are global or not.
+    * Global context = "Context, which is recognized when the user presses
+    *                   the voice key"
+    * Currently, SIND names and command words are global.
+    * @since 2.8
+    * @return CArrayFixFlat<CNssContext> A List of contexts.
+    */
+    CArrayPtrFlat<CNssContext>* GetGlobalContexts();
+
+    /**
+    * Read all global contexts from the database. 
+    * @since 2.8
+    * @return CArrayFixFlat<CNssContext> A List of contexts.
+    */
+    CArrayPtrFlat<CNssContext>* GetAllContexts();
+
+    /**
+    * Create a new database.
+    * @since 2.8
+    * @return none
+    */
+	void CreateDatabaseL();
+
+    /**
+    * Open database.
+    * @since 2.8
+    * @return none
+    */
+	void OpenDatabaseL();
+
+    /**
+    * Close database.
+    * @since 2.8
+    * @return Symbian-wide error codes
+    */
+	TInt  CloseDatabase();
+
+    /**
+    * Get model bank id and lexicon id from some context. All contexts
+    * have the same model bank id.
+    * @since 2.8
+    * @param aModelBankId Place to store model bank ID.
+    * @param aLexiconId   Place to store lexicon ID.
+    * @return ETrue if successful (leaves, if not successful)
+    */
+	TBool GetModelBankIdLexiconIdL( TUint32& aModelBankId, TUint32& aLexiconId );
+
+    /**
+    * Check if a context has tags or not.
+    * @since 2.8
+    * @param aContextId context id
+    * @return ETrue if there are tags, EFalse if not.
+    */
+    TBool TagExistL( TInt aContextId );
+
+    /**
+    * How many tags there are in this context?
+    * @since 2.8
+    * @param aContextId context id
+    * @return The number of tags
+    */
+	TInt  TagCountL( TInt aContextId );
+
+    /**
+    * Saves a context. When a context is save, a unique Context ID
+    * is assigned to it. This ID is returned in aNewContextId reference variable.
+    * @since 2.8
+    * @param aContext The context
+    * @param aNewContextId Place to store the newly assigned context ID.
+    * @return none
+    */
+    void SaveContextL( CNssContext& aContext, TInt& aNewContextId );
+
+    /**
+    * Updates the information of an existing context.
+    * @since 2.8
+    * @param aContext The context
+    * @return none
+    */
+	void UpdateContextL( CNssContext& aContext );
+
+    /**
+    * Updates the client data of an existing context.
+    * @since 2.8
+    * @param aContext The context
+    * @return none
+    */
+	void UpdateContextClientDataL( CNssContext& aContext );
+
+    /**
+    * Saves a tag. When a tag is saved, a unique ID is assigned to it
+    * @since 2.8
+    * @param aContext The context
+    * @return none
+    */
+    void SaveTagL( CNssTag& aTag, TInt& aNewId );
+
+    /**
+    * Get tag reference list. A tag reference contains only the name and the ID.
+    * @since 2.8
+    * @param aContextId  The context
+    * @return Tag references for all tags in the context.
+    */
+	TNssTagReferenceListArray* GetTagReferenceListL( TInt aContextId );
+
+    /**
+    * Get a tag, given the grammar ID and rule ID of the tag.
+    * Used when resolving recognition result.
+    * @since 2.8
+    * @param aGrammarIdRuleId Dedicated struct to pass gramamr ID and rule ID.
+    * @return Tag with the given rule ID.
+    */
+	CArrayPtrFlat<CNssTag>* GetTagL( TNssGrammarIdRuleId aGrammarIdRuleId );
+
+    /**
+    * Get a list of tags tag, given the list of grammar IDs and rule IDs of 
+    * the tags.
+    * Used when resolving recognition result.
+    * @since 2.8
+    * @param aGrammarIdRuleIds Array of gramamr ID and rule ID pairs
+    * @return List of tags with the given rule ID and grammar ID.
+    */
+	CArrayPtrFlat<CNssTag>* GetTagsL( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds );
+	
+	/**
+    * Get a tag, given the recognition phrase.
+    * @since 2.8
+    * @param aName Recognition phrase of the tag
+    * @return Tag with the given rule ID.
+    */
+	CArrayPtrFlat<CNssTag>* GetTagL( const TDesC& aName );
+
+    /**
+    * Get a list of tags based on RRD integer data.
+    * The client can save 5 integer for each tag. This function gets those tags,
+    * which have value aNum in position aPosition.
+    * @since 2.8
+    * @param aContextId Context ID
+    * @param aNum The number we search for.
+    * @param aPosition RRD integer position. There are 5 slots, numbered 0-4.
+    * @return List of tags
+    */
+	CArrayPtrFlat<CNssTag>* GetTagL( TInt aContextId, TInt aNum, TInt aPosition );
+
+    /**
+    * Get a list of tags based on RRD text data.
+    * The client can save 5 strings for each tag. This function gets those tags,
+    * for which the text data at slot aPosition matches to aText.
+    * @since 2.8
+    * @param aContextId Context ID
+    * @param aText The text we search for.
+    * @param aPosition RRD text position. There are 5 slots, numbered 0-4.
+    * @return List of tags
+    */
+	CArrayPtrFlat<CNssTag>* GetTagL( TInt aContextId, const TDesC& aText, TInt aPosition );
+
+    /**
+    * Gets all tags from this context.
+    * @since 2.8
+    * @param aContext A context
+    * @return List of tags
+    */
+	CArrayPtrFlat<CNssTag>* GetTagL( const CNssContext& aContext );
+
+    /**
+    * Get a tag, given a tag ID.
+    * @since 2.8
+    * @param aTagId tag id
+    * @return List of tags
+    */    
+	CArrayPtrFlat<CNssTag>* GetTagL( TUint32 aTagId );
+
+    /**
+    * Method to get the default model bank id
+    * @since 2.8
+    * @param aId reference where to put the model bank Id
+    * @return symbian-wide error code
+    */
+    void GetDefaultModelBankIdL( TUint32& aId );
+
+    /**
+    * Modifies the context table so that all contexts start using
+    * the new id as their model bank id.
+    * @since 2.8
+    * @param aNewId new model bank id
+    * @return symbian-wide error code
+    */
+    void ResetModelBankL( TUint32 aNewId );
+
+    /**
+    * Deletes a context.
+    * @since 2.8
+    * @param aName Name of the context to be deleted.
+    * @return none
+    */
+	void DeleteContextL( const TDesC& aName );
+
+    /**
+    * Deletes a tag.
+    * @since 2.8
+    * @param aName Name of the tag to be deleted.
+    * @return none
+    */
+	void DeleteTagL( const TDesC& aName );
+
+    /**
+    * Deletes a tag.
+    * @since 2.8
+    * @param aTagId The unique ID of the tag.
+    * @return none
+    */
+	void DeleteTagL( TUint32 aTagId );
+
+    /**
+    * Deletes a tag without starting a transaction.
+    * @since 2.8
+    * @param aTagId Tag id
+    * @return none
+    */
+    void DeleteTagInsideTransactionL( TUint32 aTagId );
+
+    /**
+    * Deletes a list of tags.
+    * @since 2.8
+    * @param aTagArray A list of tags
+    */
+    void DeleteTagsL( const RArray<TUint32>& aTagIdArray );
+
+    /**
+    * Updates the rule ids of some tags.
+    * The rule ID changes, if an already trained tag is retrained.
+    * @since 2.8
+    * @param aRetrainedTags Tags which need an update for rule ID.
+    * @return TInt Success status.
+    */
+    void UpdateTagRuleIDsL( const RArray<TNssSpeechItem>& aRetrainedTags );
+
+    /**
+    * Saves a list of tags.
+    * @since 2.8
+    * @param aTagArray A list of trained tags
+    * @param aTagIdArray The newly assigned Tag IDs are placed here.
+    */
+    void SaveTagsL( CArrayPtrFlat<CNssTag>* aTagArray, RArray<TInt>& aTagIdArray );
+
+	/**
+	* Permit transactions. Used when e.g. backup or restore begins 
+	* @since 3.1
+	*/
+	void LockTransactionsL();
+
+	/**
+	* Allow transactions. Used when e.g. backup or restore ends 
+	* @since 3.1
+	*/
+	void UnlockTransactionsL();
+	
+private:
+
+    /*
+    * First phase constructor.
+    */
+    CNssVasDb( CNssContextBuilder& contextBuilder,
+	           CNssSpeechItemBuilder& speechItemBuilder );
+
+    /*
+    * Second phase constructor.
+    */
+	void ConstructL();
+
+    /*
+    * Get a list of contexts.
+    * The pipeline for the public GetContextL variants is:
+    * (1) Turn parameters into an SQL query
+    * (2) Call this function
+    */
+    CArrayPtrFlat<CNssContext>* GetContextL( const TDesC& aSqlStatement );
+
+    /*
+    * "workhorse" function for the the previous one. The previous function
+    * takes care of locking and unlocking the database.
+    */
+    CArrayPtrFlat<CNssContext>* GetContextInsideTransactionL( const TDesC& aSqlQuery );
+
+    /*
+    * Reads a list of contexts after query. RDbView object is created
+    * as a result of a query.
+    */
+	void FillContextListArrayL( RDbView& aView, CArrayPtrFlat<CNssContext>& aContextList );
+
+    /*
+    * Get the RRD data for a tag. The RRD table is separate from tag table.
+    */
+	void FillRRDL( TUint32 aTagId, CNssRRD& aRRD );
+
+    /*
+    * Get a speech item after a query (which created the RDbView object).
+    * In addition to core tags data, it fetces the context and the RRD data
+    * form separate arrays.
+    */
+	void FillSpeechItemL( RDbView& aView, CNssSpeechItem& aSpeechItem, TInt& aContextId );
+
+    /*
+    * Get a context after query.
+    */
+	void FillContextL( RDbView& aView, CNssContext &aContext );
+
+    /*
+    * (1) Makes a tag out of context, speech item and RRD data.
+    * (2) Adds the tag to aTagList.
+    */
+	void FillTagListArrayL( CArrayPtrFlat<CNssTag>& aTagList, 
+	                        CNssContext* aContext,
+	                        CNssSpeechItem* aSpeechItem,
+	                        CNssRRD* aRRD );
+
+    /*
+    * Saves a context.
+    */
+    void SaveContextL( CNssContext* aContext, TInt& aNewContextId );
+
+    /*
+    * Saves RRD data.
+    */
+	void SaveRRDL(CNssRRD* aRRD);	
+
+    /*
+    * Saves a tags. When a tag is saved for the first time, an ID is assigned
+    * to it. This ID is stored to aTagId.
+    */
+	void SaveTagL( CNssTag* aTag, TInt& aTagId);
+
+    /*
+    * The public GetTagL / GetTagListL variants make an SQL query from their
+    * parameters and call this function to do the rest.
+    */
+    CArrayPtrFlat<CNssTag>* GetTagListByQueryL(const TDesC& aSqlQuery);
+
+    /*
+    * Deletes RRD data
+    */
+	void DeleteRRDL( TUint32 aTagId );
+
+    /*
+    * Update an existing tag. Locks database.
+    */
+	void UpdateTagL( CNssTag& aTag );
+
+    /*
+    * Update an existing tag.
+    */
+	void UpdateTagInTransactionL( CNssTag& aTag );
+
+    /*
+    * Updates an existing context. Does not lock database.
+    */
+	void DoUpdateContextL( CNssContext& aContext );
+
+    /*
+    * Updates the client data of an existing context. Does not lock database.
+    */
+    void DoUpdateContextClientDataL( CNssContext& aContext );
+
+    /*
+    * Updates RRD data. Does not lock database.
+    */
+	void UpdateRRDL( CNssRRD& aRRD );
+
+    /*
+    * Updates speech item. Does not lock database.
+    */
+	void UpdateSpeechItemL( CNssSpeechItem& aSpeechItem );
+
+    /*
+    * Gets a tag list from view. A mid-phase between GetTagListByQuery and
+    * the lower functions (those which get RRD and speech item).
+    */
+    void GetTagListFromViewL( RDbView& aView, 
+                              CArrayPtrFlat<CNssTag>* aTagList,
+                              CNssContext* aContext );
+
+    /*
+    * Locks the database with Begin().
+    */
+    TInt StartTransaction();
+
+    /*
+    * Commits a transaction.
+    * If the client has locked the database (Lock()), keeps the database locked
+    * by calling Begin() immediately again.
+    * @param "TBool aCompact" ETrue if compact should be called
+    */
+    TInt CommitTransaction( TBool aCompact );
+
+    /*
+    * Rolls back a transaction.
+    * If the client has locked the database (Lock()), keeps the database locked
+    * by calling Begin() immediately again.
+    */
+    TInt RollbackTransaction();
+		
+    /*
+    * Commits or rolls back according to success status, which is one of the
+    * symbian-wide error codes.
+    * @param aCompactIfSuccess If ETrue and commit is going to happen, compacts 
+    *        the DB after the Commit
+    */
+    void CommitIfSuccess( RDbDatabase aDatabase, TInt aSuccess, TBool aCompactIfCommit = EFalse );
+
+    /*
+    * This method is used to create a TCleanupOperation, which rolls back
+    * transaction. This way, rollback can be pushed to the cleanup stack.
+    */
+    static void RollbackCleanupFunction( TAny* aArg );
+
+    /*
+    * Reserves disk space. Leaves (KErrDiskFull), if not
+    * enough space.
+    */
+    void ReserveDiskSpaceL( TInt aRequestSize );
+
+    /*
+    * Release the previously reserved disk space
+    */
+    void ReleaseDiskSpace();
+    
+    /**
+    * Updates the information of an existing context inside already opened transaction.
+    * @since 3.0
+    * @param aContext The context
+    * @return none
+    */
+	void UpdateContextInsideTransactionL( CNssContext& aContext );
+	
+	/**
+	* Creates a cleanup item and pushes it to the cleanup stack. In case of a 
+	* leave, PopAndDestroying this item will call RollbackCleanupFunction
+	*/
+	void CreatePushRollbackItemLC();
+	
+private:
+	// Data
+
+    // DB session
+	RDbs					iDbSession;
+
+    // DB
+	RDbNamedDatabase		iDatabase;
+
+    // Have we yet opened the DB file
+	TBool					iClientHasOpenedDatabase;
+
+    // Used to check drive space
+    TInt iDrive;
+
+    // Used to store an SQL query.
+	TBuf<KNssMaxSQLLength>		iSQLStatement;
+
+    // Used to create the database
+	TNssVasDbCreator           iDbcreator;
+
+    // Is the databas locked to us
+    TBool                   iLocked;
+
+    // Should the database be relocked after commit
+    // to ensure it stays locked for us
+    TBool                   iShouldBeLocked;
+
+    // Mutex which makes sure that multiple processes don't get the exclusive
+    // write lock at the same time
+    RMutex iMutex;
+    
+    // Critical section is used in locking transactions inside one object
+    RCriticalSection iCriticalSection;
+    
+    // backup and restore observer
+    CNssVasBackupObserver* iBackupObserver;
+    
+    // For creating empty CNssContext-objects
+    CNssContextBuilder&          iContextBuilder;
+    
+    // For creating empty CNssSpeechItem-objects
+    CNssSpeechItemBuilder&       iSpeechItemBuilder;
+    };
+
+#endif // __CVASDB_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascvasdbbuilder.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,180 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVasDbBuilder is owned by CNssVASDBMgr. It is responsible for creating
+*               the context manaher, tag manager, vas db event notifier, and tag select 
+*               notifier. This class is a singleton, and is created using the InstanceL(),
+*               and deleted using the RemoveInstance() methods. 
+*
+*/
+
+
+#ifndef CNSSVASDBBUILDER_H
+#define CNSSVASDBBUILDER_H
+
+#include "nssvascvasdatabase.h"
+#include "nssvasccontextmgr.h"
+#include "nssvasctagmgr.h"
+#include "nssvascvasdbeventnotifier.h"
+#include "nssvascdbtagselectnotifier.h"
+#include "nssvascvasdbsrvdef.h" 
+
+
+//FORWARD DECLARATIONS
+
+// CLASS DECLARATIONS
+/**
+*  Singleton builder class for creating the VAS DB objects.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssVASDBBuilder : public CBase
+{
+public:
+   /**
+   * This function returns an instance of CNssVASDBBuilder.
+   * Must be called one to one with RemoveInstance(). 
+   * @since 2.0
+   * @param
+   * @return pointer to CNssVASDBBuilder
+   */
+	static CNssVASDBBuilder* InstanceL();
+
+	/**
+   * This method removes one instance of this class by decrementing
+   * the number of instances. When the number of instances hit 0,
+   * the object is deleted. Must be called one to one with InstanceL().
+   * @since 2.0
+   * @param
+   * @return
+   */
+	static void RemoveInstance();
+   
+	/**
+   * Destructor.
+   * @param
+   * @return
+   */	
+	~CNssVASDBBuilder();
+   
+   /**
+   * Initializes VAS DB 
+   * Only one initialization per object lifetime is doing a real job
+   * All the subsequent calls to InitializeL are ignored
+   * @since 2.0
+   * @param 
+   * @return none 
+   */
+   void InitializeL();
+
+   /**
+   * Gets the ContextMgr.
+   * @since 2.0
+   * @param 
+   * @return pointer to CNssContextMgr
+   */	
+   CNssContextMgr* GetContextMgr();
+   
+   /**
+   * Gets the TagMgr.
+   * @since 2.0
+   * @param 
+   * @return pointer to CNssTagMgr
+   */	
+   CNssTagMgr* GetTagMgr();
+   
+   /**
+   * Gets the Vas Db event notifier.
+   * @since 2.0
+   * @param 
+   * @return pointer to CNssVASDBEventNotifier
+   */    
+   CNssVASDBEventNotifier* GetVASDBEventNotifier();
+
+
+   /**
+   * Gets the Vas Db event notifier.
+   * @since 2.0
+   * @param 
+   * @return pointer to CNssVASDBEventNotifier
+   */    
+   CNssDBTagSelectNotifier* GetTagSelectNotifier();
+
+
+private:
+	/**
+   * C++ constructor
+   * @param 
+   * @return 
+   */    
+   CNssVASDBBuilder();
+
+	/**
+   * 2 phase construction
+   * @param
+   * @return
+   */
+	static CNssVASDBBuilder* NewL ();
+
+	/**
+   * 2 phase construction
+   * @param
+   * @return
+   */
+	static CNssVASDBBuilder* NewLC ();
+
+   /**
+   * EPOC constructor
+   * @param 
+   * @return 
+   */    
+   void ConstructL ();
+
+	/**
+   * closes the VAS database
+   * @since 2.0
+   * @param -
+   * @return 
+   */    
+   void Close();
+
+   // owns the VAS Database
+   CNssVASDatabase*			iVasDatabase;
+   
+   // owns the context manager
+   CNssContextMgr*				iContextMgr;
+
+   // owns the tag manager
+   CNssTagMgr*					iTagMgr;
+
+   // owns the tag select notifier
+   CNssDBTagSelectNotifier*	iDBTagSelectNotifier;
+
+   // owns the event notifier
+   CNssVASDBEventNotifier*		iVASDBEventNotifier;
+   
+   // Only one initialization per lifetime is permitted
+   // All the subsequent calls to InitializeL are ignored
+   TBool					iInitialized;
+   
+};
+
+// structure for singleton implementation
+// 
+struct TThreadLocalStorage 
+{
+	CNssVASDBBuilder* iInstance;
+    TInt16 iInstanceCount;
+};
+
+#endif // __CVASDBBUILDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascvasdbdataexchanger.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines serialized data types, which were used to transfer
+*                data between the clinet/server interface of VAS.
+*
+*/
+
+
+#ifndef __CNSSVASDBDATAEXCHANGER_H
+#define __CNSSVASDBDATAEXCHANGER_H
+
+// Data Exchange Interface Definition
+#include "nssvasdbkonsts.h"
+#include "nssvasccontext.h"
+
+//typedef TBuf<KNssVasDbRRDText> NssVasDbRRDText;
+
+class TNssSpeechItem
+    {
+public:
+    TUint32 iRuleId;
+    TUint32 iTagId;
+    TBufC<KNssVasDbTagName> iName;
+    };
+
+class TNssGrammarIdRuleId
+    {
+public:
+    TUint32 iGrammarId;
+    TUint32 iRuleId;
+    };
+    
+typedef CArrayFixFlat<TNssGrammarIdRuleId> TNssGrammarIdRuleIdListArray;    
+
+class TNssTagReference
+    {
+public:
+    TInt      iTagId;
+    TBufC<40> iTagName;
+    };
+
+typedef CArrayFixFlat<TNssTagReference> TNssTagReferenceListArray;
+
+typedef TPckgC<TNssGrammarIdRuleId>     TPckgCTNssGrammarIdRuleId;
+
+#endif // __CNSSVASDBDATAEXCHANGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvascvasdbsrvdef.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef __VASDBSRVDEF_H
+#define __VASDBSRVDEF_H
+
+#include <e32base.h>
+#include <data_caging_path_literals.hrh>
+
+// Resource name & locations
+_LIT( KResourceFileName, "nssvasresource.rsc" );
+
+#endif // #ifndef __SRVDEF_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasdbkonsts.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VAS database constants
+*
+*/
+
+
+#ifndef NSSVASDBKONSTS_H
+#define NSSVASDBKONSTS_H
+
+// CONSTANTS
+
+_LIT( KNameCol, "name" );
+_LIT( KGlobalCol, "global" );
+_LIT( KGrammarIdCol, "grammarid" );
+_LIT( KLexiconIdCol, "lexiconid" );
+_LIT( KModelBankIdCol, "modelbankid" );
+_LIT( KContextIdCol, "contextid" );
+
+_LIT( KRRDTextCol, "rrdtext" );
+_LIT( KRRDIntCol, "rrdint" );
+_LIT( KRRDPositionCol, "rrdposition" );
+
+_LIT( KModelIdCol,"modelid" );
+_LIT( KPronunciationIdCol, "pronunciationid" );
+_LIT( KTrainTypeCol, "traintype" );
+_LIT( KClientDataCol, "clientdata" );
+_LIT( KRuleIdCol, "ruleid" );
+
+_LIT( KTagIdCol, "tagid" );
+
+const TInt KNssVasDbContextName          =50;
+const TInt KNssVasDbRRDText              =64;
+const TInt KNssVasDbSpeechItemName       =128;
+const TInt KNssVasDbTagName              =128;
+const TInt KNssStatementLength           =300; // can be really long, but 300 can be enough
+const TInt KNssMaxSQLLength              =KNssVasDbContextName + KNssStatementLength;
+const TInt KNssMaxNumLength              =10;
+const TInt KNssAppDynamicArrayGranularity=10;
+
+// Vas Db specific error codes
+const TInt KErrDbFailed	         =-1000;
+const TInt KErrDbNotSet          =-1001;
+const TInt KErrDbNoData	         =-1002;
+const TInt KErrDbNoSuchContext   =-1003;
+const TInt KErrDbNoSuchEvent     =-1004;
+const TInt KErrItemAlreadyExist  =-1005;
+const TInt KErrItemRefusedGeneral=-1006;
+const TInt KErrTransferFailed    =-1007;
+const TInt KErrDbAlreadyOpen     =-1008;
+const TInt KErrDbBusy            =-1009;
+const TInt KErrAlreadyConnected  =-1010;
+
+#endif // NSSVASDBKONSTS_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasmcoresrsdbeventhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssCoreSrsDBEventHandler provides interface to handle events
+*                from Save and Delete utterance data into SRS.
+*
+*/
+
+
+#ifndef MNSSCORESRSDBEVENTHANDLER_H
+#define MNSSCORESRSDBEVENTHANDLER_H
+
+
+/**
+* The MNssCoreSrsDBEventHandler provides interface to handle events
+* from Save and Delete utterance data into SRS.
+*
+*  @lib NssVasApi.lib
+*  @since 2.0
+*/
+class MNssCoreSrsDBEventHandler
+{
+public:
+
+   enum TNssSrsDBResult
+   {
+      EVasSuccess,
+	  EVasPending,
+      EVasCommitFailed,
+      EVasAddPronunciationFailed,
+      EVasAddRuleFailed,
+      EVasRemovePronunciationFailed,
+      EVasRemoveRuleFailed,
+      EVasRemoveModelFailed,
+	  EVasInvalidState,
+	  // for Context portal
+	  EVasCreateGrammarFailed,
+	  EVasCreateModelBankFailed,
+	  EVasCreateLexiconFailed,
+	  EVasRemoveGrammarFailed,
+	  EVasRemoveModelBankFailed,
+	  EVasRemoveLexiconFailed,
+      // for generic error
+      EVasUnexpectedRequest,   // Unexpected request from client, when the state is not Idle
+      EVasUnexpectedEvent,
+      EVasInUse,               // VAS resource is currently in use.
+      EVasDiskFull,            // SRF disk is full
+      EVasInvalidParameter,
+      EVasDBOperationError,
+      EVasNoMemory
+   };
+   
+   /**
+   * Callback 
+   * @param None
+   * @return None
+   */
+   virtual void HandleSaveSrsDBCompleted()=0;
+
+   /**
+   * Callback 
+   * @param None
+   * @return None
+   */
+   virtual void HandleDeleteSrsDBCompleted()=0;
+
+   /**
+   * Callback
+   * @param None
+   * @return None
+   */
+   virtual void HandleResetSrsDBCompleted()=0;
+
+   /**
+   * Callback 
+   * @param None
+   * @return None
+   */
+   virtual void HandleSrsDBError(TNssSrsDBResult aResult)=0;
+
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasmcoresyncrecoveryhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MCoreDbSyncRecoveryHandler provides means to restore the database
+*                synchronisation between Speech Recognition DB (SR DB) and VAS DB.
+*
+*                Training a new name saves stuff to SR DB. The SaveTag() call saves
+*                stuff to VAS DB. If the client decides after training not to save, or
+*                battery is removed between training the name and saving it, then the
+*                two databases are out of sync.
+*                These functions add to VAS DB enough information for proper rollback.
+*                If they are called before changing SR DB, the databases will always
+*                stay in sync.
+*
+*
+*/
+
+
+#ifndef MNSSCORERECOVERYHANDLER_H
+#define MNSSCORERECOVERYHANDLER_H
+
+class CNssTag;
+
+/**
+* The MNssCoreSrsDBEventHandler provides interface to handle events
+* from Save and Delete utterance data into SRS.
+*
+*  @lib NssVasApi.lib
+*  @since 2.0
+*/
+class MNssCoreSyncRecoveryHandler
+{
+public:
+
+   /**
+   * Recovery functions.
+   * These are called, before changing the speech recognition database.
+   * They save enough information to clean up and fall back, if:
+   * (a) The client changes SR DB, but doesn't save the tag.
+   * (b) A crash happens during operation.
+   */
+
+   /**
+   * Callback
+   * @return None
+   */
+   virtual void PrepareRecoveryInTraining( const RPointerArray<CNssSpeechItem>& anArray,
+                                           const CNssContext* aContext )=0;
+
+   /**
+   * Callback
+   * @return None
+   */
+   virtual void PrepareRecoveryInChanging(const RPointerArray<CNssSpeechItem>& anArray)=0;
+
+   /**
+   * Callback
+   * @return None
+   */
+   virtual void PrepareRecoveryInDeleting(const RPointerArray<CNssSpeechItem>& anArray)=0;
+
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasmdbtagselectnotifierclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssDBTagSelectNotifierClient is an interface for tag select notification
+*				 and provdies a method for clients to be notified of tag selection.
+*
+*/
+
+
+#ifndef MNSSDBTAGSELECTNOTIFIERCLIENT_H
+#define MNSSDBTAGSELECTNOTIFIERCLIENT_H
+
+// FORWARD DECL
+class CNssTag;
+
+// CLASS DECLARATION
+
+/**
+*  MNssDBTagSelectNotifierClient: A client implements for tag select notification
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssDBTagSelectNotifierClient
+{
+public:
+
+	// HandleSelection is called into the client by CNssDBTagSelectNotifier
+	virtual void HandleSelection(CNssTag* aTag) = 0;
+
+};
+
+
+#endif      // MDBTAGSELECTNOTIFIERCLIENT_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasmintercompcontextmgrclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssInterCompContextMgrClient provides the public callback interfaces 
+*				 for internal VAS clients that want to retrieve contexts from the VAS Db. 
+*				 The client must inherit and override the following methods to 
+*				 handle VAS Db responses for retrieving context(s).
+*
+*/
+
+
+#ifndef MNSSINTERCOMPCONTEXTMGRCLIENT_H
+#define MNSSINTERCOMPCONTEXTMGRCLIENT_H
+
+#include <e32std.h>
+#include <e32base.h>
+
+
+// FORWARD DECLARATION
+class CNssContext;
+
+// TYPEDEFS
+typedef CArrayPtrFlat<CNssContext> TMNssContextList;
+
+// CLASS DECLARATIONS
+/**
+*  MNssInterCompContextMgrClient defines the call back methods used by VAS DB.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssInterCompContextMgrClient
+{
+public:
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to delete the context after using the context.
+   * @since 2.0
+   * @param aContext 
+   * @return None
+   */
+  virtual void GetContextCompleted( CNssContext* aContext,
+                                    TInt aErrorCode ) = 0;
+
+   /**
+   * Callback to indicate GetContext successed.
+   * client has to ResetAndDestroy() after using the list.
+   * @since 2.0
+   * @param aContextList A list of contexts. 
+   * @return None
+   */
+  virtual void GetContextListCompleted( TMNssContextList *aContextList,
+                                        TInt aErrorCode ) = 0;
+
+
+  /**
+   * Callback to indicate GetContext successed.
+   * client has to ResetAndDestroy() after using the list.
+   * @since 2.0
+   * @param aContextList A list of contexts. 
+   * @return None
+   */
+  virtual void GetGlobalContextsCompleted( TMNssContextList *aContextList,
+                                           TInt aErrorCode ) = 0;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasmintercomptagmgrclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MNssInterCompTagMgrClient provides the public callback interfaces 
+*				 for internal VAS clients that want to retrieve tags from the VAS Db. 
+*				 The client must inherit and override the following methods to 
+*				 handle VAS Db responses for retrieving tag(s).
+*
+*/
+
+
+#ifndef MNSSINTERCOMPTAGMGRCLIENT_H
+#define MNSSINTERCOMPTAGMGRCLIENT_H
+
+#include <e32std.h>
+
+
+
+class CNssTag;
+
+// CLASS DECLARATIONS
+/**
+*  MNssInterCompTagMgrClient defines the call back methods used by VAS DB.
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+
+class MNssInterCompTagMgrClient
+{
+public:
+   
+   /**
+   * Callback to indicate GetTag successed.
+   * client has to ResetAndDestroy() after using the list.
+   * @since 2.0
+   * @param aTag tag returned
+   * @param aErrorCode KErrNone if  getting of tag was successfull
+   * @return None
+   */
+   virtual void GetTagCompleted( CNssTag* aTag, TInt aErrorCode ) = 0;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasmvasdatabaseclient.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This interface defines the call back methods used by VAS DB
+*                when replying to an asynchronous DeleteContext() request.
+*
+*/
+
+
+#ifndef MNSSVASDATABASECLIENT_H
+#define MNSSVASDATABASECLIENT_H
+
+#include <e32std.h>
+#include "nssvasccontext.h"
+#include "nssvasctag.h"
+#include "nssvasctagreference.h"
+
+
+// CLASS DECLARATIONS
+/**
+*  MNssVASDatabaseClient defines the call back methods from the VAS DB
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class MNssVASDatabaseClient
+{
+public:
+
+   enum TNssVASDBClientReturnCode
+   {
+      EVASDBSuccess,
+      EVASDBItemNotFound,
+	  EVASDBNoMemory,
+	  EVASDBDiskFull,
+	  EVASDBFailure
+   };
+
+   /**
+   * Callback from VAS DB
+   * @param aEvent 
+   * @return None
+   */
+   virtual void VASDatabaseComplete( CArrayPtrFlat<CNssContext>* aContextList, 
+                                     CArrayPtrFlat<CNssTag>* aTagList, 
+	                                 CArrayPtrFlat<CNssTagReference>* aTagRefList,
+	                                 TNssVASDBClientReturnCode aCode ) = 0;
+   
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasresource.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Structure definition for resource file.
+*
+*/
+
+
+//  INCLUDES
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// VAS_INFO
+// Structure definition for NSSVAS resource file.
+// -----------------------------------------------------------------------------
+//
+STRUCT VAS_INFO
+    {
+    LTEXT directory_name; // Location of the VAS database
+    LTEXT database_name;  // Name of the database file
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvasrvasdbsession.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,342 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RVasDbSession is the client-side(proxy) interface through which 
+*               communication with the vasdb server is channelled.
+*
+*/
+
+#ifndef RNSSVASDBSESSION_H
+#define RNSSVASDBSESSION_H
+
+
+#include "nssvascvasdbsrvdef.h"
+#include "nssvasdbkonsts.h"
+#include "nssvascvasdbdataexchanger.h"
+#include "nssvasccontext.h"
+#include "nssvasccontext.h"
+#include "nssvasctag.h"
+#include "nssvascvasdb.h"
+
+// FORWARD DECLARATIONS
+class CNssVasDb;
+
+// CLASS DECLARATION
+
+/**
+*
+*  The RVasDbSession class definition. 
+* 
+*  @lib NssVASApi.lib
+*  @since 2.0
+*/
+class RNssVasDbSession
+    {
+	// Functions
+public:
+
+    /**
+    * C++ 1st phase constructor
+    */
+	RNssVasDbSession();	
+
+    /**
+    * C++ destructor
+    */
+    ~RNssVasDbSession();
+	
+    /**
+    * A method to create a new database. The name of the database file
+    * is read from a resource file (NssVasResource.rsc).
+    * @since 2.8
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	TInt  CreateDatabase();
+
+    /**
+    * A method to open the database. The name of the database file
+    * is read from a resource file (NssVasResource.rsc).
+    * @since 2.8
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	TInt  OpenDatabase();	
+
+    /**
+    * A method to close the database.
+    * @since 2.8
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	TInt  CloseDatabase ();
+
+    /**
+    * A method to get the model bank id and lexicon id.
+    * @since 2.8
+    * @param aModelBankId Model Bank ID will be returned here.
+    * @param aLexiconId Lexicon ID will be returned here.
+    * @return ETrue if success, otherwise EFalse.
+    */
+    TBool ModelBankIdLexiconId( TUint32 &iModelBankId, TUint32 &iLexiconId );
+
+    /**
+    * A method to check whether a context is empty or not.
+    * @since 2.8
+    * @param aContextId Unique identifier of the context.
+    * @return ETrue if there are tags, EFalse if the context is empty.
+    */
+    TBool TagExist( TInt aContextId );
+
+    /**
+    * Method to return the number of tags in a context.
+    * @since 2.8
+    * @param aContextId Unique identifier of the context.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+    TInt  TagCount( TInt aContextId );
+	
+    /**
+    * Method to save a context. When a context is saved, a context ID is 
+    * assigned to it. The newly assigned ID is returned
+    * in the reference parameter.
+    * @since 2.8
+    * @param aContext Data of the context.
+    * @param aContextId Reference for returning the newly assigned context ID.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+    //TInt SaveContext( TNssContext& aContext, TInt& aContextId );
+	TInt SaveContext( CNssContext& aContext, TInt& aContextId );
+    
+    /**
+    * Method to delete a context from the database.
+    * @since 2.8
+    * @param aName Name of the context to be deleted. 
+    * @return KErrNone or a Symbian-wide error code.
+    */
+    TInt DeleteContext( const TDesC& aName );
+
+    /**
+    * Method to update the data of a context.
+    * @since 2.8
+    * @param aContext the context in serialized form.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	//TInt UpdateContext( TNssContext& aContext );
+	TInt UpdateContext( CNssContext& aContext );
+
+    /**
+    * Method to update the client data of a context.
+    * @since 2.8
+    * @param aContext the context in serialized form.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+    //TInt UpdateContextClientData( TNssContext& aContext );
+    TInt UpdateContextClientData( CNssContext& aContext );
+
+    /**
+    * Method to get a context by name.
+    * @since 2.8
+    * @param aName Name of the context
+    * @return Array containing the context, or NULL if it is not found.
+    */
+    //TNssContextListArray* GetContextByName( const TDesC& aName );
+    CArrayPtrFlat<CNssContext>* GetContextByName( const TDesC& aName );
+
+    /**
+    * Method to list all global contexts.
+    * @since 2.8
+    * @return Array containing all global contexts.
+    */
+    //TNssContextListArray* GetGlobalContexts();
+    CArrayPtrFlat<CNssContext>* GetGlobalContexts();
+
+    /**
+    * Method to list all contexts.
+    * @since 2.8
+    * @return Array containing all contexts.
+    */
+    //TNssContextListArray* GetAllContexts();
+    CArrayPtrFlat<CNssContext>* GetAllContexts();
+
+    /**
+    * Method to save a tag. During saving, a Tag ID is assigned for the tag.
+    * This ID is returned in the refrence parameter.
+    * @since 2.8
+    * @param aTag Tag
+    * @param aNewId This variable is used to return the newly asssigned
+    *               Tag ID for the user.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	//TInt SaveTag( TNssTag& aTag, TInt& aNewId );
+	TInt SaveTag( CNssTag& aTag, TInt& aNewId );
+
+    /**
+    * Method to save a group of tags. During saving, a Tag IDs are assigned
+    * for the tags. These IDs is returned in the aTagIdArray.
+    * @since 2.8
+    * @param aTagArray An array of previously unsaved tags.
+    * @param aTagIdArray Empty array, which will be filled with
+    *                    newly assigned Tag IDs.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	//TInt SaveTags( CArrayFixFlat<TNssTag>* aTagArray, RArray<TInt>& aTagIdArray );
+	TInt SaveTags( CArrayPtrFlat<CNssTag>* aTagArray, RArray<TInt>& aTagIdArray );
+
+    /**
+    * Method to delete a tag by name
+    * @since 2.8
+    * @param aTagName Trained text of the tag ( MNssSpeechItem::SetTextL() )
+    * @return KErrNone or a Symbian-wide error code.
+    */
+    TInt DeleteTag( const TDesC& aTagName );
+
+    /**
+    * Method to delete a tag.
+    * @since 2.8
+    * @param aTagId Tag identifier.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+    TInt DeleteTag( TInt aTagId );
+
+    /**
+    * Method to delete a group of tags.
+    * @since 2.8
+    * @param aTagIdArray Array of tag identifiers.
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	TInt DeleteTags( const RArray<TUint32>& aTagIdArray );
+
+    /**
+    * Method to update the information of an existing tag.
+    * @since 2.8
+    * @param aTag New information about the tag
+    * @return KErrNone or a Symbian-wide error code.
+    */
+	//TInt UpdateTag( const TNssTag& aTag );
+	TInt UpdateTag( const CNssTag& aTag );
+
+    /**
+    * Method to get references to all tags in a context.
+    * @since 2.8
+    * @param aContextId Context identifier.
+    * @return Array containing references to all tags.
+    */
+	TNssTagReferenceListArray* GetTagReferenceList( TInt aContextId );
+
+    /**
+    * Method to get all tags in a context.
+    * @since 2.8
+    * @param aContext The context
+    * @return Array containing all tags in the context
+    */
+    //TNssTagListArray* GetTag( const TNssContext& aContext );
+    CArrayPtrFlat<CNssTag>* GetTag( const CNssContext& aContext );
+
+    /**
+    * Method to get a tag by grammar ID and rule ID.
+    * @since 2.8
+    * @param aGrammarIdRuleId Structure containing the Grammar ID (which
+    *                         specifies a context) and Rule ID (which
+    *                         specifies a tag inside a context).
+    * @return Array containing the matching tag or NULL.
+    */
+    //TNssTagListArray* GetTag( TNssGrammarIdRuleId aGrammarIdRuleId );
+    CArrayPtrFlat<CNssTag>* GetTag( TNssGrammarIdRuleId aGrammarIdRuleId );
+    
+    /**
+    * Method to get tags by their grammar ID and rule ID.
+    * @since 2.8
+    * @param aGrammarIdRuleIds Structure containing the Grammar IDs (that
+    *                          specify a context) and Rule IDs (that
+    *                          specify a tag inside a context).
+    * @return Array containing the matching tags or NULL.
+    */
+    //TNssTagListArray* GetTags( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds );
+    CArrayPtrFlat<CNssTag>* GetTags( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds );
+
+    /**
+    * Method to get a tag by name (CNssSpeechItem::SetText).
+    * @since 2.8
+    * @param aName Tag's trained text.
+    * @return Array containing all matching tags.
+    */
+	//TNssTagListArray* GetTag( const TDesC& aName );
+	CArrayPtrFlat<CNssTag>* GetTag( const TDesC& aName );
+
+    /**
+    * Method to get a tag by RRD data, given RRD integer and the position (0-4)
+    * to which the integer is compared.
+    * @since 2.8
+    * @param aContextId ID of the context, to which the tag belongs.
+    * @param aNum Integer, which should match the RRD integer.
+    * @param aPosition RRD integer array position (0-4).
+    * @return Array containing all matching tags.
+    */
+	//TNssTagListArray* GetTag( TInt aContextId, TInt aNum, TInt aPosition );
+	CArrayPtrFlat<CNssTag>* GetTag( TInt aContextId, TInt aNum, TInt aPosition );
+
+    /**
+    * Method to get a tag by RRD data, given RRD text and the position (0-4)
+    * to which the text is compared.
+    * @since 2.8
+    * @param aContextId ID of the context, to which the tag belongs.
+    * @param aText Text, which should match the RRD text.
+    * @param aPosition RRD text array position (0-4).
+    * @return Array containing all matching tags.
+    */
+	//TNssTagListArray* GetTag( TInt aContextId, TDesC& aText, TInt aPosition );
+	CArrayPtrFlat<CNssTag>* GetTag( TInt aContextId, 
+	                                const TDesC& aText, TInt aPosition );
+
+    /**
+    * Method to get a tag, given the tag ID.
+    * @since 2.8
+    * @param aTagId The ID of the tag.
+    * @return Array containing the tag or NULL.
+    */
+	//TNssTagListArray* GetTag( TUint32 aTagId );
+	CArrayPtrFlat<CNssTag>* GetTag( TUint32 aTagId );
+
+    /**
+    * Method to update the Rule IDs of some tags.
+    * @since 2.8
+    * @param aRetrainedTags Array of tags with changed Rule IDs
+    * @return symbian-wide error code
+    */
+    TInt UpdateTagRuleIDs( const RArray<TNssSpeechItem>& aRetrainedTags );
+
+    /**
+    * Method to get the default model bank id
+    * @since 2.8
+    * @param aId reference where to put the model bank Id
+    * @return symbian-wide error code
+    */
+    TInt GetDefaultModelBankId( TUint32& aId );
+
+    /**
+    * Modifies the context table so that all contexts start using
+    * the new id as their model bank id.
+    * @since 2.8
+    * @param aNewId new model bank id
+    * @return symbian-wide error code
+    */
+    TInt ResetModelBank( TUint32 aNewId );
+
+private:
+
+    // Pointer to the object, which makes the actual operations on database.
+    CNssVasDb* iVasDb;
+
+    // How many VAS instances in this thread have connected.
+    TInt iConnected;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/inc/nssvastvasdbcreator.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  TNssVasDbCreator is responsible for creating VasDatabase.db.
+*
+*/
+
+
+#ifndef TNSSVASDBCREATOR_H
+#define TNSSVASDBCREATOR_H
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>
+#include <s32file.h>
+#include <d32dbms.h>
+
+#include "nssvasdbkonsts.h"
+#include "nssvascvasdbsrvdef.h"
+// CLASS DECLARATION
+
+/**
+*
+*  The TNssVasDbCreator class definition. 
+* 
+*  @lib VASInternal.lib
+*  @since 2.0
+*/
+class TNssVasDbCreator
+{
+public:
+	
+	/**
+    * Constructor 
+    * @since 2.0
+    * @param 
+    * @return 
+    */
+	TNssVasDbCreator();
+
+	/**
+    * Method to create vasdatabase.db and its tables 
+    * @since 2.0
+    * @param "RDbs& iDbSession" Database session handle
+    * @return none
+    */
+	void CreateVasDatabaseL( RDbs& iDbSession );
+
+private:
+    /**
+    * Creates the tables and indices of the database
+    */
+	void CreateTablesAndIndiciesL( RDbNamedDatabase& aDatabase );
+
+    /**
+    * Creates the context table
+    */
+	void CreateContextTableL( RDbNamedDatabase& aDatabase );
+
+    /**
+    * Creates the index of the context table
+    */
+	void CreateContextIndexL( RDbNamedDatabase& aDatabase );
+
+    /**
+    * Creates the tag table
+    */
+    void CreateTagTableL( RDbNamedDatabase& aDatabase );
+
+    /**
+    * Creates the index of the tag table
+    */
+	void CreateTagIndexL( RDbNamedDatabase& aDatabase );
+
+    /**
+    * Creates the RRD table
+    */
+    void CreateRRDTableL( RDbNamedDatabase& aDatabase );
+    
+    /**
+    * Creates indeices for RRD tables
+    */
+    void CreateRRDIndexL( RDbNamedDatabase& aDatabase );
+
+    /**
+    * Creates the write lock table
+    */
+    void CreateWriteLockTableL( RDbNamedDatabase& aDatabase );
+    
+    /**
+    * Creates index for a given table and column. Leaves if creation fails.
+    * Leave codes are the same as error codes in RDbNamedDatabase::CreateIndex + 
+    * general out of memory
+    * @param anIndexName Name of the index to create
+    * @param aColumnName Name of the column to index on
+    * @param aUnique ETrue if index should be unique, EFalse otherwise
+    * @param aTableName Name of the table for which the index should be created
+    */
+    void CreateSingleColumnIndexL( RDbNamedDatabase& aDatabase, const TDesC& anIndexName,
+                 const TDesC& aColumnName, const TBool aUnique, const TDesC& aTableName);
+    
+    /**
+    * Creates index for a given table and columns. Leaves if creation fails.
+    * Leave codes are the same as error codes in RDbNamedDatabase::CreateIndex + 
+    * general out of memory
+    * @param anIndexName Name of the index to create
+    * @param aFirstColumnName Name of the first column to index on
+    * @param aSecondColumnName Name of the second column to index on
+    * @param aUnique ETrue if index should be unique, EFalse otherwise
+    * @param aTableName Name of the table for which the index should be created
+    */
+    void CreateTwoColumnIndexL( const TDesC& anIndexName, 
+                                const TDesC& aFirstColumnName, 
+                                const TDesC& aSecondColumnName, 
+                                const TBool aUnique, const TDesC& aTableName);
+
+};
+
+#endif // TVASDBCREATOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2001 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+// specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+
+#include "exports.inc"
+
+PRJ_MMPFILES
+// specify the .mmp files required for building the important component releasables
+// note that you should specify any .mmp files for test programs further down the file.
+//
+// It's best if the .MMP files are specified in the order in which the components are
+// built, but that eventually shouldn't matter
+//
+// Use C++ style #defines to denote that a component is only built for a particular platform
+//
+// specify "tidy" if the component you need to build doesn't need to be released to
+// the rest of the company
+// specify "ignore" if the MMP file exists but should be ignored - William wants this!
+
+
+VASDBEventNotifier.mmp
+
+
+
+PRJ_TESTMMPFILES
+// specify the .mmp files required for building any test programs here
+//
+// you can specify "manual" to denote that a test should be listed in a generated
+// batch file for running a group of tests which require user input during testing.
+// you can specify "support" to denote that a file is a test support file and shouldn't
+// be listed in a batch file for running a group of tests
+// By default, each test will be listed in a batch file for running a group of tests
+// which can be left to run without requiring watching over by the person running the tests,
+// i.e. tests where no user input is required.  The default will apply if neither "manual"
+// or "support" is specified.
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1 @@
+// exports.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/group/nssvasdbeventnotifier.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+// mmp file
+
+TARGET		VASDBEventNotifier.dll
+TARGETTYPE	dll
+UID 0x1000008d 0x100058F1
+
+SYSTEMINCLUDE	/epoc32/include
+SYSTEMINCLUDE	/epoc32/include/kernel
+
+USERINCLUDE	/VASApi/VASCore/inc
+USERINCLUDE	/VASApi/VASDb/inc
+USERINCLUDE	/VASApi/VASDisruption/inc
+USERINCLUDE	/VASApi/VASRecognition/inc
+USERINCLUDE	../inc 
+
+SOURCEPATH	../src
+SOURCE		VasCVASDBEventMonitor.cpp VasCVASDBEventNotifier.cpp 
+SOURCE		VASTVASDBEvent.cpp
+
+
+LIBRARY		euser.lib edbms.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/inc/nssvascvasdbeventmonitor.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CVASDBMonitor class is an active object that is a wrapper around 
+*               the RDBNotifier class. Events from RDBNotifier are handled by 
+*               encapsulating them in a CNssVASDBEvent object and passing it to all 
+*               its observers. In addition to the events provided by RDBNotifier, 
+*               CVASDBMonitor also provides additional events when a entry is added,
+*               changed or deleted from the VAS DB. CVASDBMonitor owns the list of 
+*               observers of the VAS DB.
+*
+*/
+
+
+#ifndef CNSSVASDBEVENTMONITOR_H
+#define CNSSVASDBEVENTMONITOR_H
+
+//  INCLUDES
+#include <d32dbms.h>
+
+#include "nssvascoreconstant.h"
+#include "nssvascvasdbevent.h"
+#include "nssvasmvasdatabaseobserver.h"
+#include "nssvasctag.h"
+
+
+// CLASS DECLARATION
+
+/**
+*  CNssVASDBEventMonitor is an active object responsible for observing VAS database changes
+*  and notifying all registerted observers of the change.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssVASDBEventMonitor :public CActive
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CNssVASDBEventMonitor* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CNssVASDBEventMonitor();
+
+    public: // New functions
+        
+        /**
+        * Request to start monitoring the VAS DB 
+		* @since 2.0
+        * @param void
+        * @return void
+        */
+        void StartMonitoring();
+
+		/**
+        * Method that adds an observer to the observer list 
+		* @since 2.0
+        * @param aObserver to be added
+        * @return none
+        */
+        void AddObserverL(MNssVASDatabaseObserver* aObserver);
+
+		/**
+        * Method that removes an observer from the observer list.
+		* @since 2.0
+        * @param aObserver to be removed
+        * @return error code
+        */
+        TInt RemoveObserver(MNssVASDatabaseObserver* aObserver);
+
+
+    public: // Functions from base classes
+
+        /**
+        * From CActive, called by RunL of RDBNotifier
+		* @since 2.0
+        * @param void
+		* @return void
+        */
+        void RunL();
+
+		/**
+        * From CActive, cancel outstanding requests
+		* @since 2.0
+        * @param void
+		* @return void
+        */
+        void DoCancel();
+
+		/**
+        * handling of addional events ( tag added, tag deleted, tag changed)
+		* These events can be reported only when the events occur on the same 
+		* thread as that of the observer (client monitoring the event).
+		* @since 2.0
+        * @param aEvent - VAS DB event type
+		* @param aTag - tag on which the event occured
+        * @return void
+        */
+		void HandleDatabaseEventL(CNssVASDBEvent::TVASDBEventType aEvent, CNssTag *aTag);
+
+	private:
+
+        /**
+        * C++ constructor.
+        */
+        CNssVASDBEventMonitor();
+
+        /**
+        * EPOC constructor
+        */
+        void ConstructL();
+
+		/**
+        * Called by RunL() to create an event object and 
+		* call HandleDatabaseEvent() for all observers
+		* Handles Standard Symbian DBMS events
+		* @since 2.0
+        * @param aEvent - Symbian DBMS event
+        * @return void
+        */
+        void HandleDatabaseEventL(RDbNotifier::TEvent aEvent);
+
+
+    private:    // Data
+
+		RDbs					iDbSession;
+		RDbNamedDatabase		iDatabase;
+        RDbNotifier				iNotifier;
+		CArrayPtrFlat<MNssVASDatabaseObserver>* iObservers;
+
+    };
+
+#endif      // CVASDBEVENTMONITOR_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/inc/nssvascvasdbeventnotifier.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVASDBEventNotifier is the implementation class for interface 
+*				 MNssVASDBEventNotifier.
+*
+*/
+
+
+#ifndef CNSSVASDBEVENTNOTIFIER_H
+#define CNSSVASDBEVENTNOTIFIER_H
+
+//  INCLUDES
+#include "nssvasmvasdbeventnotifier.h"
+#include "nssvascvasdatabase.h"
+
+// CLASS DECLARATION
+
+/**
+*  CNssVASDBEventNotifier is the implementation class for interface MNssVASDBEventNotifier.
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssVASDBEventNotifier : public CBase, public MNssVASDBEventNotifier
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * C++ constructor.
+        */
+        CNssVASDBEventNotifier(CNssVASDatabase* aDatabase);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CNssVASDBEventNotifier();
+
+    public: // New functions
+        
+        /**
+        * Add an observer to the VAS DB
+		* @since 2.0
+        * @param aObserver, Observer to be added
+        * @return none
+        */
+        void AddObserverL(MNssVASDatabaseObserver* aObserver);
+
+    public: // Functions from base classes
+
+        /**
+        * Remove an observer from VAS DB
+        * @param aObserver, Observer to be removed
+        * @leave KErrNotFound if given observer has never been added
+        */
+        void RemoveObserverL(MNssVASDatabaseObserver* aObserver);
+        
+  
+    private:
+
+        /**
+        * EPOC constructor 
+        */
+        void ConstructL();
+	
+	private:
+		// pointer to VAS Database
+		CNssVASDatabase* iDatabase;
+    };
+
+#endif      // CVASDBEVENTNOTIFIER_H  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/src/nssvascvasdbevent.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssVASDBEvent encapsulates events occuring on the VAS DB.
+*
+*/
+
+
+// INCLUDE FILES
+#include  "nssvascvasdbevent.h"
+#include  "nssvasctag.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ constructor can NOT contain any code that
+// might leave.
+//
+CNssVASDBEvent::CNssVASDBEvent()
+{
+}
+
+// 2 Phase constructor
+//
+CNssVASDBEvent* CNssVASDBEvent::NewL(TVASDBEventType& aType, MNssTag* aTag)
+{
+	CNssVASDBEvent* self = NewLC(aType, aTag);
+	CleanupStack::Pop(self);
+	return self;
+}
+
+// 2 Phase constructor
+//
+CNssVASDBEvent* CNssVASDBEvent::NewLC(TVASDBEventType& aType, MNssTag* aTag)
+{
+	CNssVASDBEvent* self = new (ELeave) CNssVASDBEvent;
+	CleanupStack::PushL(self);
+	self->ConstructL(aType, aTag);
+	return self;
+}
+
+// EPOC Constructor
+//
+void CNssVASDBEvent::ConstructL(TVASDBEventType& aType, MNssTag *aTag)
+{
+	iType = aType;
+	if(aTag)
+		iTag = ((CNssTag*)aTag)->CopyL();
+}
+
+
+    
+// Destructor
+//
+CNssVASDBEvent::~CNssVASDBEvent()
+{
+	 if(iTag)
+	 {
+		 delete iTag;
+	 }
+}
+
+
+// returns the type of event
+//
+EXPORT_C CNssVASDBEvent::TVASDBEventType CNssVASDBEvent:: Type()
+{
+    return iType;
+}
+
+
+// returns the tag on which the event occured,
+//
+EXPORT_C MNssTag* CNssVASDBEvent::Tag()
+{
+	return iTag;
+}
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/src/nssvascvasdbeventmonitor.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,254 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CVASDBMonitor class is an active object that is a wrapper around 
+*               the RDBNotifier class. Events from RDBNotifier are handled by 
+*               encapsulating them in a CNssVASDBEvent object and passing it to all 
+*               its observers. In addition to the events provided by RDBNotifier, 
+*               CVASDBMonitor also provides additional events when a entry is added,
+*               changed or deleted from the VAS DB. CVASDBMonitor owns the list of 
+*               observers of the VAS DB.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvascresourcehandler.h"
+#include "nssvascvasdbeventmonitor.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::ConstructL
+// C++ constructor can NOT contain any code that
+// might leave.
+// ---------------------------------------------------------
+//
+CNssVASDBEventMonitor::CNssVASDBEventMonitor() : CActive( CActive::EPriorityStandard) 
+    {
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::ConstructL
+// EPOC constructor can leave.
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::ConstructL()
+    {
+    iObservers = new ( ELeave ) CArrayPtrFlat<MNssVASDatabaseObserver>( 1 );
+
+    TFileName serverSideFilename;
+   
+    User::LeaveIfError( iDbSession.Connect() );
+
+    // Open the database.
+    User::LeaveIfError( iDatabase.Open( iDbSession, KVasDatabaseName, KVasDatabaseFormatString ) );
+
+    User::LeaveIfError( iNotifier.Open( iDatabase ) );
+    StartMonitoring();
+    }
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CNssVASDBEventMonitor* CNssVASDBEventMonitor::NewL()
+    {
+    CNssVASDBEventMonitor* self = new (ELeave) CNssVASDBEventMonitor;
+      
+    CleanupStack::PushL( self );
+	CActiveScheduler::Add( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::~CNssVASDBEventMonitor
+// Destructor
+// ---------------------------------------------------------
+//
+CNssVASDBEventMonitor::~CNssVASDBEventMonitor()
+    {
+    Cancel();
+    iNotifier.Close();
+    iDatabase.Close();
+    iDbSession.Close();
+    if ( iObservers )
+        {
+        iObservers->Reset();
+        delete iObservers;
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::StartMonitoring
+// Request function to start monitoring
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::StartMonitoring()
+    {
+    if ( IsActive() )
+        {
+		return;
+        }
+	iStatus=KRequestPending;
+	SetActive();
+	iNotifier.NotifyChange( iStatus );
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::AddObserverL
+// add observer to its list
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::AddObserverL(MNssVASDatabaseObserver* aObserver)
+    {
+	iObservers->AppendL( aObserver );	
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::RemoveObserver
+// remove observer from its list
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+TInt CNssVASDBEventMonitor::RemoveObserver(MNssVASDatabaseObserver* aObserver)
+    {
+	TBool ret = EFalse;
+	if ( iObservers )
+	    {
+		for ( TInt i = 0;i < iObservers->Count(); i++ )
+		    {
+			if ( ( *iObservers )[i] == aObserver )
+			    {
+				iObservers->Delete( i );
+				ret = ETrue;
+				break;
+			    }
+		    }
+	    }
+	if ( ret )
+    	{
+		iObservers->Compress();
+	    }
+	return ( ret? KErrNone : KErrGeneral );			
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::RunL
+// called when standard symbian DBMS events occur
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::RunL()
+    {
+	RDbNotifier::TEvent event = STATIC_CAST( RDbNotifier::TEvent,iStatus.Int() );
+	HandleDatabaseEventL( event );
+	StartMonitoring();
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::DoCancel
+// cancel outstanding requests to RDBNotifier
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::DoCancel()
+    {
+	iNotifier.Cancel();
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::HandleDatabaseEventL
+// Standard Symbian DBMS events handling
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::HandleDatabaseEventL( RDbNotifier::TEvent aEvent )
+    {
+	 if(!iObservers->Count())
+	    {
+		return;
+	    }
+
+	 CNssVASDBEvent::TVASDBEventType type = CNssVASDBEvent::EVASDatabaseEventNull;
+	 switch( aEvent )
+    	 {
+    	 case RDbNotifier::EClose: 
+    	    type = CNssVASDBEvent::EVASDatabaseEventDatabaseClose;
+    	    break; 
+    	 case RDbNotifier::EUnlock:
+	    	 type = CNssVASDBEvent::EVASDatabaseEventDatabaseUnlock;
+		     break;
+		 case RDbNotifier::ECommit:
+	        type = CNssVASDBEvent::EVASDatabaseEventDatabaseCommit;
+		    break;
+		 case RDbNotifier::ERollback:
+		    type = CNssVASDBEvent::EVASDatabaseEventDatabaseRollback;
+		    break;
+		 case RDbNotifier::ERecover:
+		    type = CNssVASDBEvent::EVASDatabaseEventDatabaseRecover;
+		    break;
+		 default:
+		    break;
+    	 }
+	 // for standard symbian DBMS events, the parameter aTag
+	 // does not have any significance, so create a dummy one
+	 MNssTag *dummyTag = NULL;
+	 CNssVASDBEvent *vasDBEvent = CNssVASDBEvent::NewL( type, dummyTag );
+
+	 for(TInt i = 0; i < iObservers->Count(); i++)
+	     {
+		 ( *iObservers )[i]->HandleVASDBEvent( vasDBEvent );
+	     }
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventMonitor::HandleDatabaseEventL()
+// handling of addional events ( tag added, tag deleted, tag changed)
+// wk 15 release has limited functionality where these events can be 
+// reported only when the events occur on the same thread as that 
+// of the observer (client monitoring the event).
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventMonitor::HandleDatabaseEventL( 
+                    CNssVASDBEvent::TVASDBEventType type, CNssTag *aTag )
+{
+	 if ( !iObservers->Count() )
+	    {
+    	return;
+	    }
+
+	 for ( TInt i = 0; i < iObservers->Count(); i++ )
+	 {
+		 CNssVASDBEvent *vasDBEvent = CNssVASDBEvent::NewL( type, aTag );
+		 ( *iObservers )[i]->HandleVASDBEvent( vasDBEvent );
+	 }
+}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/nssvasdbeventnotifier/src/nssvascvasdbeventnotifier.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVASDBEventNotifier is the implementation class for interface 
+*				 MNssVASDBEventNotifier.
+*
+*/
+
+
+// INCLUDE FILES
+#include    "nssvascvasdbeventnotifier.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ constructor can NOT contain any code that
+// might leave.
+//
+CNssVASDBEventNotifier::CNssVASDBEventNotifier(CNssVASDatabase* aDatabase): iDatabase(aDatabase)
+    {
+    }
+
+// Destructor
+CNssVASDBEventNotifier::~CNssVASDBEventNotifier()
+    {
+    
+    }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventNotifier::AddObserverL
+// adds an observer
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventNotifier::AddObserverL(MNssVASDatabaseObserver* aObserver)
+   {
+   iDatabase->AddObserverL(aObserver);
+   }
+
+
+// ---------------------------------------------------------
+// CNssVASDBEventNotifier::RemoveObserverL
+// removes an observer
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CNssVASDBEventNotifier::RemoveObserverL(MNssVASDatabaseObserver* aObserver)
+   {
+   User::LeaveIfError( iDatabase->RemoveObserver(aObserver) );
+   }
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/10201afe.txt	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,10 @@
+;Security policy for NSS VAS DB
+[database]
+read
+capability = ReadUserData
+write
+capability = WriteUserData
+schema
+capability = WriteUserData
+[backup]
+sid = 10201AFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvasbackupobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches changes of the PC-Suite data sync state
+*
+*/
+
+
+#include "nssvasbackupobserver.h"
+#include "rubydebug.h"
+
+#include <sbdefs.h>
+
+// ---------------------------------------------------------
+// CNssTag::NewL
+// NewL
+// ---------------------------------------------------------
+//
+CNssVasBackupObserver* CNssVasBackupObserver::NewL( CNssVasDb& aDb )
+    {
+    CNssVasBackupObserver* self = new (ELeave) CNssVasBackupObserver( aDb );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CNssVasBackupObserver::CNssVasBackupObserver
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+CNssVasBackupObserver::CNssVasBackupObserver( CNssVasDb& aDb ) :
+    CActive( CActive::EPriorityHigh ),
+    iDb( aDb )
+    {
+    // Nothing
+    }
+    
+// ---------------------------------------------------------
+// CNssVasBackupObserver::ConstructL
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+void CNssVasBackupObserver::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasBackupObserver::ConstructL" );
+    User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) );
+       
+    // initial subscription and process current property value
+    iProperty.Subscribe( iStatus );
+    
+    CActiveScheduler::Add( this ); 
+    SetActive();   
+    }
+    
+// ---------------------------------------------------------
+// CNssVasBackupObserver::~CNssVasBackupObserver
+// Destructor
+// ---------------------------------------------------------
+//
+CNssVasBackupObserver::~CNssVasBackupObserver()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+// ---------------------------------------------------------
+// CNssVasBackupObserver::DoCancel
+// Cancel listening now
+// ---------------------------------------------------------
+//    
+void CNssVasBackupObserver::DoCancel() 
+    {
+    iProperty.Cancel();
+    }
+
+// ---------------------------------------------------------
+// CNssVasBackupObserver::RunL
+// Is called, when property changed
+// ---------------------------------------------------------
+//
+void CNssVasBackupObserver::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasBackupObserver::RunL" );
+    
+    if( iStatus != KErrNone ) 
+        {
+        // At least report the error
+        RUBY_ERROR1( "CNssVasBackupObserver::RunL iStatus is [%d]", iStatus.Int() );
+        }
+        
+    // resubscribe before processing new value to prevent missing updates
+    // even if some error happened
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    // property updated, get new value
+	TInt backupFlag;
+	User::LeaveIfError( iProperty.Get( backupFlag ) );
+	switch ( backupFlag & conn::KBURPartTypeMask )
+	    {
+	    case conn::EBURNormal:
+	        // Database can be used again
+	        RUBY_DEBUG0( "CNssVasBackupObserver::RunL Unlock transactions" );
+	        iDb.UnlockTransactionsL();
+	        break;
+	        
+	    case conn::EBURBackupFull:
+	    case conn::EBURBackupPartial:
+	    case conn::EBURRestoreFull:
+	    case conn::EBURRestorePartial:
+	        // Lock the use of database
+	        RUBY_DEBUG0( "CNssVasBackupObserver::RunL Lock transactions" );
+	        iDb.LockTransactionsL();
+	        break;
+	        
+	    case conn::EBURUnset:
+	    default:
+	        RUBY_ERROR1( "CNssVasBackupObserver::RunL backup flag unknown %h ", backupFlag );
+	    }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvasbackupobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watcher for the PC-Suite data sync state
+*
+*/
+
+
+#ifndef NSSBACKUPOBSERVER_H
+#define NSSBACKUPOBSERVER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+
+// Publish & Subscribe of the contact handler activity
+#include <e32property.h>  
+#include "nssvascvasdb.h"
+
+// CONSTANTS
+
+
+// MACROS
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+/**
+* RProperty based data sync watcher implementation
+*/
+NONSHARABLE_CLASS( CNssVasBackupObserver ) : public CActive
+    {
+    public:
+        /** 
+        *  Factory construction
+        *  @param aDb Database 
+        *  @return Constructed and already started observer
+        */
+        static CNssVasBackupObserver* NewL( CNssVasDb& aDb );
+        
+        /** 
+        * Destructor 
+        */
+        ~CNssVasBackupObserver();
+        
+    private:
+        /**
+        * C++ constructor 
+        */
+        CNssVasBackupObserver( CNssVasDb& aDb );
+        
+        /**
+        * Symbian second phase constructor 
+        */
+        void ConstructL();
+        
+        /**
+        * is called when data sync property changed 
+        */
+        void RunL();
+        
+        /**
+        * Is called when system wants immediate cancelling of the watching 
+        */
+        void DoCancel();
+        
+    private:
+        // Publish & Sunscribe property about backup/restore 
+        RProperty   iProperty;
+        
+        // Database to be notified about the backup/restore
+        CNssVasDb& iDb;
+    };
+
+#endif // NSSBACKUPOBSERVER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvasccontextmgr.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,914 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssContextManager provides context processing for the client. CNssContextManager
+*               implements the MNssContextMgr interface, and also provides additional methods for
+*               use by internal VAS components. 
+*
+*/
+
+
+// include files
+#include "nssvasccontextmgr.h"
+#include "nssvascvasdatabase.h"
+#include "nssvasccontextbuilder.h"
+#include "nssvasmresetfactorymodelsclient.h"
+#include "rubydebug.h"
+
+const TInt KContextArrayGranularity = 5;
+
+_LIT( KContextMgrPanic, "contextmgr.cpp");
+
+// ---------------------------------------------------------
+// CNssContextMgr::CNssContextMgr
+// C++ constructor
+// ---------------------------------------------------------
+//
+CNssContextMgr::CNssContextMgr()
+: CActive( EPriorityStandard )
+    {
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::CNssContextMgr
+// overloaded C++ constructor
+// ---------------------------------------------------------
+//
+CNssContextMgr::CNssContextMgr( CNssVASDatabase* aVASDatabase )
+: CActive( EPriorityStandard )
+    {
+	iVasDatabase = aVASDatabase;
+	iState = ENone;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::~CNssContextMgr
+// destructor
+// ---------------------------------------------------------
+//
+CNssContextMgr::~CNssContextMgr()
+    {
+	if ( iContextBuilder )
+	    {
+		delete iContextBuilder;
+		iContextBuilder = NULL;
+	    }
+
+	// Cancel any oustanding requests before destroying self.
+	if( IsActive() )
+	    {
+	    Cancel(); // -> in base class -> goes on to call DoCancel in this class...
+	    }
+	
+	// Delete context list if it has not been delivered to the client yet
+    if ( iContextList )
+        {
+        iContextList->ResetAndDestroy();
+        delete iContextList;
+        }	    
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CNssContextMgr* CNssContextMgr::NewL( CNssVASDatabase* aVASDatabase )
+    {
+    CNssContextMgr* self = NewLC( aVASDatabase );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::NewLC
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CNssContextMgr* CNssContextMgr::NewLC( CNssVASDatabase* aVASDatabase )
+    {
+    CNssContextMgr* self = new (ELeave) CNssContextMgr( aVASDatabase );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::ConstructL
+// EPOC constructor can leave.
+// ---------------------------------------------------------
+//
+void CNssContextMgr::ConstructL()
+    {
+	iContextBuilder = CNssContextBuilder::NewL();
+
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::CreateContextL
+// creates an empty context object
+// ---------------------------------------------------------
+//
+MNssContext* CNssContextMgr::CreateContextL()
+    {
+    return iContextBuilder->CreateContextL(); 
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::GetContext
+// retrives a context fromt he VAS DB based on the name of the context
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::GetContext( MNssGetContextClient* aContextClient, const TDesC& aName )
+    {
+    if ( IsActive() || !aContextClient || aName.Length() == 0 )
+        {
+        return KErrGeneral;
+        }
+
+    if ( iContextList )
+        {
+        iContextList->ResetAndDestroy();
+        delete iContextList;
+        iContextList = NULL;
+        }
+        
+    TInt ret( KErrNone );
+
+    iContextList = iVasDatabase->GetContext( aName );
+
+    if ( !iContextList )
+        {
+        ret = KErrGeneral;
+        }
+    
+    else if ( iContextList->Count() == 0 )
+        {
+        delete iContextList;
+        iContextList = NULL;
+        ret = KErrGeneral;
+        }
+    
+    else
+        {
+    	iState = EGetContextClientGetContext;
+        iGetContextClient = aContextClient;
+
+        TRequestStatus* pRS = &iStatus;
+    	User::RequestComplete( pRS, KErrNone );
+    	SetActive();        
+        }
+    
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::GetContextList
+// retreives a list of contexts from the VAS DB
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::GetContextList( MNssGetContextClient* aContextClient )
+    {
+    if ( IsActive() || !aContextClient )
+        {
+        return KErrGeneral;
+        }
+
+    if ( iContextList )
+        {
+        iContextList->ResetAndDestroy();
+        delete iContextList;
+        iContextList = 0;
+        }
+
+    TInt ret( KErrNone );
+
+    iContextList = iVasDatabase->GetAllContexts();
+
+    if ( !iContextList )
+        {
+        ret = KErrGeneral;
+        }
+
+    else if ( iContextList->Count() == 0 )
+        {
+        delete iContextList;
+        iContextList = NULL;
+        ret = KErrGeneral;
+        }
+        
+    else
+        {
+        iState = EGetContextClientGetContextList;
+        iGetContextClient = aContextClient;
+
+        TRequestStatus* pRS = &iStatus;
+    	User::RequestComplete( pRS, KErrNone );
+    	SetActive();
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::DeleteContext
+// deletes a context from VAS DB
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::DeleteContext( MNssDeleteContextClient* aContextClient,
+                                    MNssContext* aContext )
+    {
+	iState = EDeleteContextClient;
+	iDeleteContextClient = aContextClient;
+	iLocalContext = (CNssContext*)(aContext);
+
+	// will fail if 2 requests come in together
+	TRAPD( error, iLocalContext->BeginDeleteFromSrsL(this) );
+	
+	return error;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::SaveContext
+// saves a context in the vas db
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::SaveContext( MNssSaveContextClient* aContextClient,MNssContext* aContext )
+    {
+    if ( IsActive() || !aContextClient || !aContext )
+        {
+        return KErrGeneral;
+        }
+
+    if ( !( &aContext->ContextName() ) )
+        {
+        return KErrGeneral;
+        }
+
+	iState = ESaveContextClient;
+	iSaveContextClient = aContextClient;
+	iLocalContext = (CNssContext*)(aContext);
+
+	TUint32 modelBankId;
+	TUint32 lexiconId;
+	if ( iVasDatabase->ModelBankAndLexiconExist( modelBankId, lexiconId ) )
+	    {
+		iLocalContext->SetModelBankId( modelBankId );
+	    iLocalContext->SetLexiconId( lexiconId );
+	    iLocalContext->SetModelBankAndLexiconExist( ETrue );
+	    }
+
+	// will fail if 2 requests come in together
+	TRAPD( err, iLocalContext->BeginSaveToSrsL(this) );
+	
+	return err;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::SaveClientData
+// Saves to the VAS DB the client data associated with a context
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::SaveClientData(
+    MNssContext* aContext )
+    {
+    if ( !aContext || !( &aContext->ContextName() ) )
+        {
+        return KErrArgument;
+        }
+
+    return iVasDatabase->SaveContextClientData( (CNssContext*)aContext );
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::GetGlobalContexts
+// retrives a list of context from the VAS DB, that have
+// their global flag ETrue
+// ---------------------------------------------------------
+//
+TMNssContextList* CNssContextMgr::GetGlobalContexts()
+    {
+    return iVasDatabase->GetGlobalContexts();
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::VASDatabaseComplete
+// call back implementation from interface MNssVASDatabaseClient
+// ---------------------------------------------------------
+//
+void CNssContextMgr::VASDatabaseComplete(CArrayPtrFlat<CNssContext> *aContextList, 
+									  CArrayPtrFlat<CNssTag>* /*aTagList*/ ,
+									  CArrayPtrFlat<CNssTagReference>* /*aTagRefList*/,
+									  TNssVASDBClientReturnCode aCode)
+    {
+    switch(iState)
+        {
+        case EGetContextClientGetContext:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                
+                if ( iGetContextClient )
+                    {
+                    // make a copy of the context to return, this copy needs to
+                    // be deleted by the client.
+                    MNssContext *context = NULL;
+                    TRAPD( err, (context = ((*aContextList)[0])->CopyL()) );
+                    aContextList->ResetAndDestroy();
+                    delete aContextList;
+                    if( err == KErrNone )
+                        {
+                        // call back to client with copied context.
+                        iGetContextClient->GetContextCompleted( context, KErrNone );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                        iGetContextClient->GetContextCompleted( context );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY 
+                        }
+                    else
+                        {
+                        // call back to client with error code.
+                        iGetContextClient->GetContextCompleted( NULL, KErrGeneral ); 
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                        iGetContextClient->GetContextFailed( MNssGetContextClient::EVASDBFailure );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                         
+                        }
+                    
+                    }
+                else
+                    {
+                    aContextList->ResetAndDestroy();
+                    delete aContextList;
+                    }
+                }
+            else 
+                {
+                // if get context list from VAS DB failed, there is no list returned back,
+                // thus no need to delete any list.
+                if ( iGetContextClient )
+                    {
+                    iGetContextClient->GetContextCompleted( NULL, KErrGeneral ); 
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    iGetContextClient->GetContextFailed( MNssGetContextClient::EVASDBFailure );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    }
+                }
+            break;
+            
+        case EGetContextClientGetContextList:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                TRAPD( err, CNssContextListToMNssContextListConvertorL( aContextList ) );
+                if ( err != KErrNone && iGetContextClient )
+                    {
+                    iGetContextClient->GetContextCompleted( NULL, err );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    iGetContextClient->GetContextFailed( MNssGetContextClient::EVASDBFailure );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY 
+                    
+                    }
+                }
+            else 
+                {
+                if ( iGetContextClient )
+                    {
+                    iGetContextClient->GetContextCompleted( NULL, KErrGeneral );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    iGetContextClient->GetContextFailed( MNssGetContextClient::EVASDBFailure );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                     
+                    }
+                }
+            break;
+            
+        case EDeleteContextClient:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                if ( iDeleteContextClient )
+                    {		
+                    if ( iLocalContext->CommitSrsChanges() == KErrNone )
+                        {
+                        iDeleteContextClient->DeleteContextCompleted( KErrNone );
+                        }
+                    else
+                        {
+                        iDeleteContextClient->DeleteContextCompleted( KErrGeneral );
+                        }
+                    }
+                }
+            else 
+                {
+                iLocalContext->CommitSrsChanges();
+
+                iDeleteContextClient->DeleteContextCompleted( KErrGeneral );	 
+                }
+            break;
+            
+        case ESaveContextClient:
+            iState = ENone;
+
+            if ( aCode == EVASDBSuccess )
+                {
+                // context has been saved in VAS DB and SRS DB.
+                // model bank and lexicon have been created or existed from before
+                iLocalContext->SetModelBankAndLexiconExist( ETrue );
+                
+                if ( iSaveContextClient )
+                    {
+                    if ( iLocalContext->CommitSrsChanges() == KErrNone )
+                        {
+                        iSaveContextClient->SaveContextCompleted( KErrNone );
+                        }
+                    else
+                        {
+                        iSaveContextClient->SaveContextCompleted( KErrGeneral );
+                        }
+                    }
+                }
+            else // failed to save context in vas db
+                {
+                iLocalContext->RollbackSrsChanges();
+                iSaveContextClient->SaveContextCompleted( KErrGeneral );
+                }
+            break;
+            
+        case ESaveClientDataClient:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                iSaveContextClient->SaveContextCompleted( KErrNone );
+                }
+            else{
+                iSaveContextClient->SaveContextCompleted( KErrGeneral );
+                }
+            break;
+            
+        case EInterCompContextMgrClientGetContext:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                if ( iInterCompContextMgrClient )
+                    {
+                    // make a copy of the context to return, this copy needs to
+                    // be deleted by the client.
+                    CNssContext *context = NULL;
+                    TRAPD( err, (context = ((*aContextList)[0])->CopyL()) );
+                    // delete the context list got from VAS DB.
+                    aContextList->ResetAndDestroy();
+                    delete aContextList;
+                    if ( err == KErrNone )
+                        {
+                        // call back to client with copied context.
+                        iInterCompContextMgrClient->GetContextCompleted( context, KErrNone );
+                        }
+                    else
+                        {
+                        // call back to client with error code.
+                        iInterCompContextMgrClient->GetContextCompleted( 
+                            NULL, err ); 
+                        }
+                    }
+                else 
+                    {
+                    aContextList->ResetAndDestroy();
+                    delete aContextList;
+                    }
+                }
+            else 
+                {
+                if ( iInterCompContextMgrClient)
+                    {
+                    iInterCompContextMgrClient->GetContextCompleted( NULL, KErrGeneral );
+                    }
+                }
+            break;
+            
+        case EInterCompContextMgrClientGetGlobalContexts:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                if ( iInterCompContextMgrClient )
+                    {
+                    iInterCompContextMgrClient->GetGlobalContextsCompleted(
+                        aContextList, KErrNone );
+                    }
+                else
+                    {
+                    aContextList->ResetAndDestroy();
+                    delete aContextList;
+                    }
+                }
+            else 
+                {
+                if ( iInterCompContextMgrClient )
+                    {
+                    iInterCompContextMgrClient->GetContextCompleted(
+                        NULL, KErrGeneral );
+                    }
+                }
+            break;
+            
+        case EInterCompContextMgrClientGetContextList:
+            iState = ENone;
+            if ( aCode == EVASDBSuccess )
+                {
+                if ( iInterCompContextMgrClient )
+                    {
+                    iInterCompContextMgrClient->GetContextListCompleted(
+                        aContextList, NULL );
+                    }
+                else
+                    {
+                    aContextList->ResetAndDestroy();
+                    delete aContextList;
+                    }
+                }
+            else
+                {
+                if ( iInterCompContextMgrClient )
+                    {
+                    iInterCompContextMgrClient->GetContextCompleted( 
+                        NULL, KErrNone );
+                    }
+                }
+            break;
+            
+        default:
+            break;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::HandleSaveSrsDBCompleted
+// call back implementation from MNssCoreSrsDBEventHandler
+// ---------------------------------------------------------
+//
+void CNssContextMgr::HandleSaveSrsDBCompleted()
+    {
+    TInt contextId = KNssVASDbDefaultValue;
+
+    // Save context to VAS DB
+    TInt ret = iVasDatabase->SaveContext( iLocalContext, contextId );
+
+    // Commit SRS DB
+    if ( ret == KErrNone )
+        {
+        iLocalContext->CommitSrsChanges();
+        }
+    else
+        {
+        iLocalContext->RollbackSrsChanges();
+        }
+
+    // When a context is saved for the first time,
+    // a Context ID is assigned for it.
+    if ( iLocalContext->ContextId() == KNssVASDbDefaultValue )
+        {
+        iLocalContext->SetContextId( contextId );
+        }
+
+    // Send callback
+    if ( iSaveContextClient )
+        {
+        if ( ret == KErrNone )
+            {
+            iSaveContextClient->SaveContextCompleted( KErrNone );
+            }
+        else
+            {
+            iSaveContextClient->SaveContextCompleted( KErrGeneral );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::HandleDeleteSrsDBCompleted
+// call back implementation from MNssCoreSrsDBEventHandler
+// NO LONGER USED AFTER SERIALIZATION OF DELETETAG.
+// CNssSpeechItemTrainer TAKES CARE OF DELETING NOW.
+// ---------------------------------------------------------
+//
+void CNssContextMgr::HandleDeleteSrsDBCompleted()
+    {
+    TInt ret = iVasDatabase->DeleteContext( iLocalContext->ContextName() );
+
+    // If VAS DB removal failed, roll back Plugin delete.
+    if ( ret != KErrNone )
+        {
+        iLocalContext->RollbackSrsChanges();
+
+        iDeleteContextClient->DeleteContextCompleted( KErrGeneral );
+        return;
+        }
+
+    // If VAS DB removal was successful, commit the Plugin removal.
+    TInt commitErr;
+    commitErr = iLocalContext->CommitSrsChanges();
+
+    // DB becomes corrupted: VAS DB removal was successful, SRS DB wasn't.
+    if ( commitErr != KErrNone )
+        {
+        iDeleteContextClient->DeleteContextCompleted( KErrGeneral );
+        return;
+        }
+
+    // Both removals were successful.
+    iDeleteContextClient->DeleteContextCompleted( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssContextMgr::HandleResetSrsDBCompleted
+//  call back from SRS DB 
+// -----------------------------------------------------------------------------
+//
+void CNssContextMgr::HandleResetSrsDBCompleted()
+    {
+    if ( iVasDatabase->ResetModelBank( iModelBankId ) == KErrNone )
+        {
+        iContextBuilder->GetContextPortal()->CommitSaveContext();
+        iResetClient->HandleResetComplete( KErrNone );
+        }
+    else{
+        iContextBuilder->GetContextPortal()->RollbackSaveContext();
+        iResetClient->HandleResetComplete( KErrGeneral );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::HandleSrsDBError
+// call back implementation from MNssCoreSrsDBEventHandler
+// ---------------------------------------------------------
+//
+void CNssContextMgr::HandleSrsDBError( MNssCoreSrsDBEventHandler::TNssSrsDBResult /*aResult*/)
+    {
+	switch(iState)
+	    {
+		case ESaveContextClient:
+			iState = ENone;
+			if ( iSaveContextClient )
+			    {
+			    iSaveContextClient->SaveContextCompleted( KErrGeneral );
+			    }
+			break;
+
+		case EDeleteContextClient:
+		    iState = ENone;
+		    if ( iDeleteContextClient)
+		        {
+		        iDeleteContextClient->DeleteContextCompleted( KErrGeneral );
+		        }	
+		    break;
+
+		default:
+			break;
+	    }
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::CNssContextListToMNssContextListConvertorL
+// private method to convert CNssTag list to MNssTag list
+// ---------------------------------------------------------
+//
+void CNssContextMgr::CNssContextListToMNssContextListConvertorL( 
+                        CArrayPtrFlat<CNssContext>* aSourceList )
+    {
+	CArrayPtrFlat<MNssContext>* destinationList =  new (ELeave) CArrayPtrFlat<MNssContext>(1);
+	CleanupStack::PushL( destinationList );
+	CleanupResetAndDestroyPushL( *destinationList );
+	for ( TInt i( 0 ); i < aSourceList->Count(); i++ )
+	    {
+		destinationList->AppendL((MNssContext*) (*aSourceList)[i]);
+	    }
+	aSourceList->Reset();
+	delete aSourceList; 
+	CleanupStack::Pop( destinationList );  // ResetAndDestroy
+	CleanupStack::Pop( destinationList );  // list itself
+	iGetContextClient->GetContextListCompleted( destinationList, KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::TagExist
+// determine if a tags exists for a context in the VAS Database.
+// ---------------------------------------------------------
+//
+TBool CNssContextMgr::TagExist( CNssContext* aContext )
+    {
+	return iVasDatabase->TagExist( aContext );
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::CancelGetContext
+// cancel get context /get context list / get global contexts
+// ---------------------------------------------------------
+//
+void CNssContextMgr::CancelGetContext()
+    {
+	iInterCompContextMgrClient = NULL;
+	
+	iGetContextClient = NULL;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::DoCancel
+// A function required by CActive
+// ---------------------------------------------------------
+//
+void CNssContextMgr::DoCancel()
+    {
+    CancelGetContext();
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::RunL
+// CActive calls this function when higher-priority tasks
+// have been finished.
+// ---------------------------------------------------------
+//
+void CNssContextMgr::RunL()
+    {
+ 	TInt err( iStatus.Int() );
+
+    RUBY_DEBUG1( "CNssContextMgr::RunL, iStatus = %d", err );
+   
+	switch( iState )
+	    {
+        case EGetContextClientGetContext:
+            {
+            iState = ENone;
+
+            MNssContext* context = 0;
+
+        	TRAP( err, (context = ((*iContextList)[0])->CopyL()) );
+		    iContextList->ResetAndDestroy();
+
+            delete iContextList;
+            iContextList = 0;
+
+            if ( iGetContextClient )
+                {
+                if ( context )
+                    {
+                    iGetContextClient->GetContextCompleted( context, KErrNone );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    iGetContextClient->GetContextCompleted( context );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                  
+                    }
+                else
+                    {
+                    iGetContextClient->GetContextCompleted( NULL, KErrGeneral );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    iGetContextClient->GetContextFailed( MNssGetContextClient::EVASDBFailure );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                  
+                    }
+                }
+            else
+                {
+                delete context;
+                }
+            }
+            break;
+
+        case EGetContextClientGetContextList:
+            {
+            CArrayPtrFlat<MNssContext>* contextList = 
+                    new CArrayPtrFlat<MNssContext>( KContextArrayGranularity );
+
+            if ( contextList )
+                {
+                err = KErrNone;
+                for( TInt k = 0; k < iContextList->Count(); k++ )
+                    {
+                    TRAP( err, contextList->AppendL( (*iContextList)[k] ) );
+                    }
+
+                delete iContextList;
+                iContextList = 0;
+
+                if ( err != KErrNone )
+                    {
+                    contextList->ResetAndDestroy();
+                    delete contextList;
+                    contextList = 0;
+                    }
+                }
+
+            if ( iGetContextClient )
+                {
+                if ( contextList )
+                    {
+                    iGetContextClient->GetContextListCompleted( contextList, KErrNone );
+                    }
+                else{
+                    iGetContextClient->GetContextCompleted( NULL, KErrGeneral );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                        
+                    iGetContextClient->GetContextFailed( MNssGetContextClient::EVASDBFailure );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY                  
+                    }
+                }
+            else
+                {
+                contextList->ResetAndDestroy();
+                delete contextList;
+                contextList = NULL;
+                }
+            }
+            break;
+
+        case EInterCompContextMgrClientGetContext:
+            {
+            CArrayPtrFlat<CNssContext>* contextList = iContextList;
+            iContextList = 0;
+
+            if ( contextList )
+                {
+                iInterCompContextMgrClient->GetContextListCompleted(
+                    contextList, NULL );
+                }
+            else{
+                iInterCompContextMgrClient->GetContextCompleted(
+                    NULL, KErrGeneral );
+                }
+            }
+            break;
+
+        default:
+            {
+            User::Panic( KContextMgrPanic, __LINE__ );
+            }
+            break;
+	    }
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::RunError
+// Cleanup function required by CActive
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::RunError(TInt /*aError*/)
+    {
+    if ( iContextList )
+        {
+	    iContextList->ResetAndDestroy();
+        delete iContextList;
+        iContextList = 0;
+        }
+
+	Cancel();
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CNssContextMgr::ResetFactoryModels
+// Resets factory models
+// ---------------------------------------------------------
+//
+TInt CNssContextMgr::ResetFactoryModels( MNssResetFactoryModelsClient* aClient )
+    {
+    if ( !aClient )
+        {
+        return KErrArgument;
+        }
+
+    if ( IsActive() )
+        {
+        return KErrNotReady;
+        }
+
+    iResetClient = aClient;
+
+    // Old ID: We destroy the old (speaker adapted) model bank with this ID.
+    TUint32 oldId;
+
+    // New ID: When we create a new (speaker independent) model bank,
+    //         we save the ID here.
+    iModelBankId = KInvalidModelBankID;
+
+    TInt err = iVasDatabase->GetDefaultModelBankId( oldId );
+
+    if ( err != KErrNone )
+        {
+        return( err );
+        }
+
+    TRAP( err, iContextBuilder->GetContextPortal()->BeginResetModelsL( 
+                        (TSIModelBankID)oldId, iModelBankId, this ) );
+
+    if ( err != KErrNone )
+        {
+        return( err );
+        }   
+
+    return( KErrNone );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvascdbtagselectnotifier.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,227 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssDBTagSelectNotifier provides tag select notification to 
+*               its clients (observers). It itslef receives tag select notification
+*               from Recognition Handler.
+*
+*/
+
+
+// includes
+#include "nssvascdbtagselectnotifier.h"
+#include "nssvascoreconstant.h"
+#include <e32property.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::CNssDBTagSelectNotifier
+// C++ constructor can NOT contain any code that might leave.
+// ---------------------------------------------------------
+//
+CNssDBTagSelectNotifier::CNssDBTagSelectNotifier(): CActive( EPriorityStandard )
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::CNssDBTagSelectNotifier
+// overloaded constructor
+// ---------------------------------------------------------
+//
+CNssDBTagSelectNotifier::CNssDBTagSelectNotifier( CNssVASDatabase* aVasDatabase ): 
+                         CActive( EPriorityStandard ), iVasDatabase( aVasDatabase )
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::ConstructL
+// symbian constructor
+// ---------------------------------------------------------
+//
+void CNssDBTagSelectNotifier::ConstructL()
+    {
+	iObserverList = new (ELeave) CArrayPtrFlat<MNssDBTagSelectNotifierClient>(1);
+	
+    // Define P&S properties
+    TInt err = RProperty::Define( KSINDUID, EVoiceTagSelectionTagId, RProperty::EInt );
+    if ( err != KErrAlreadyExists )
+        {
+        User::LeaveIfError( err );
+        }
+    err = RProperty::Define( KSINDUID, EVoiceTagSelectionContextId, RProperty::EInt );
+    if ( err != KErrAlreadyExists )
+        {
+        User::LeaveIfError( err );
+        }
+        
+    User::LeaveIfError( iProperty.Attach( KSINDUID, EVoiceTagSelectionTagId ) );
+    CActiveScheduler::Add( this );
+    // Subsrcibe for change notifications
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::NewL
+// 2 phase Construction
+// ---------------------------------------------------------
+//
+CNssDBTagSelectNotifier* CNssDBTagSelectNotifier::NewL( CNssVASDatabase* aVasDatabase )
+    {
+	CNssDBTagSelectNotifier* self = NewLC( aVasDatabase );
+	CleanupStack::Pop( self );
+	return ( self );
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::NewLC
+// 2 phase Construction
+// ---------------------------------------------------------
+//
+CNssDBTagSelectNotifier* CNssDBTagSelectNotifier::NewLC( CNssVASDatabase* aVasDatabase )
+    {
+	CNssDBTagSelectNotifier* self = new ( ELeave )CNssDBTagSelectNotifier( aVasDatabase );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return ( self );
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::~CNssDBTagSelectNotifier
+// destructor
+// ---------------------------------------------------------
+//
+CNssDBTagSelectNotifier::~CNssDBTagSelectNotifier()
+    {
+	if ( iObserverList )
+	    {
+		iObserverList->ResetAndDestroy();
+		delete iObserverList;
+		iObserverList = NULL;
+    	}
+    Cancel();
+    iProperty.Close();
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::RegisterForNotification
+// registers a client for notification 
+// ---------------------------------------------------------
+//
+TInt CNssDBTagSelectNotifier::RegisterForNotification( MNssDBTagSelectNotifierClient* aObserver )
+    {
+    TRAPD( err, iObserverList->AppendL( aObserver ) );
+    return err;
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::Deregister
+// Deregister a client from notification
+// ---------------------------------------------------------
+//
+TInt CNssDBTagSelectNotifier::Deregister( MNssDBTagSelectNotifierClient* aObserver )
+    {
+    TBool ret = EFalse;
+    if ( iObserverList )
+	      {
+		    for ( TInt i = 0;i < iObserverList->Count(); i++ )
+			    if ( (*iObserverList)[i] == aObserver )
+			        {
+				      iObserverList->Delete( i );
+				      ret = ETrue;
+			        }
+    	   }
+	  if ( ret )
+	      {
+		    iObserverList->Compress();
+	      }
+	  return (ret ? KErrNone : KErrGeneral);
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::HandleSelection
+// calls all its clients, when notified of a tag slection.
+// ---------------------------------------------------------
+//
+void CNssDBTagSelectNotifier::HandleSelection( CNssTag* aTag )
+    {
+    CNssContext* context = ( CNssContext* ) aTag->Context();
+    RProperty::Set( KSINDUID, EVoiceTagSelectionContextId, context->ContextId() );
+    RProperty::Set( KSINDUID, EVoiceTagSelectionTagId, aTag->TagId() );
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::DoHandleSelectionCallback
+// Forwards the tag selection callback
+// ---------------------------------------------------------
+//
+void CNssDBTagSelectNotifier::DoHandleSelectionCallback( TInt aTagId, TInt aContextId )
+    {
+    if ( iObserverList->Count() )
+        {
+        // Go through all observers that have been registered to this instance
+        for ( TInt i = 0; i < iObserverList->Count(); i++ )
+            {
+            // Find the tags based on ID
+            MNssTagListArray* array = iVasDatabase->GetTag( aTagId );
+            
+            for ( TInt j = 0; j < array->Count(); j++ )
+                {
+                CNssTag* tag = ( CNssTag* )array->At( j );
+                CNssContext* context = ( CNssContext* ) tag->Context();
+                // Check that context IDs match
+                if ( context->ContextId() == aContextId )
+                    {
+                    // Do the callback
+                    (*iObserverList)[i]->HandleSelection( tag );
+                    }
+                }
+                       
+            array->ResetAndDestroy();
+            delete array;
+	        }
+        }
+    }
+    
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::DoCancel
+// From CActive
+// ---------------------------------------------------------
+//
+void CNssDBTagSelectNotifier::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+// ---------------------------------------------------------
+// CNssDBTagSelectNotifier::RunL
+// From CActive
+// ---------------------------------------------------------
+//
+void CNssDBTagSelectNotifier::RunL()
+    {
+    // resubscribe before processing new value to prevent missing updates
+    iProperty.Subscribe( iStatus );
+    SetActive();
+
+    // property updated, get new value
+   iProperty.Get( KSINDUID, EVoiceTagSelectionTagId, iTagId );
+   iProperty.Get( KSINDUID, EVoiceTagSelectionContextId, iContextId );
+   DoHandleSelectionCallback( iTagId, iContextId );
+   }
+   
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvascresourcehandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Reads the VAS resource file and keeps the information in
+*               member variables for later use.
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <barsread.h>
+#include <NssVasResource.rsg>
+#include "NssVasCVasDbSrvdef.h"
+#include "NssVasCResourceHandler.h"
+#include "RubyDebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNssVasResourceHandler::CNssVasResourceHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssVasResourceHandler::CNssVasResourceHandler() : iDatabasePath( NULL ),
+                                                   iDatabaseName( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasResourceHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssVasResourceHandler::ConstructL()
+    {
+    ReadResourceFileL();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasResourceHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssVasResourceHandler* CNssVasResourceHandler::NewL()
+    {
+    CNssVasResourceHandler* self = new ( ELeave ) CNssVasResourceHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasResourceHandler::~CNssVasResourceHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CNssVasResourceHandler::~CNssVasResourceHandler()
+    {
+    delete iDatabasePath;
+    delete iDatabaseName;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasResourceHandler::ReadResourceFileL
+// Reads the data from the resource file.
+// -----------------------------------------------------------------------------
+//
+void CNssVasResourceHandler::ReadResourceFileL()
+    {
+    RUBY_DEBUG_BLOCK( "CVasResourceHandler::ReadResourceFileL" );
+  
+    // letters for drives in search order
+    const TBuf<2> KResourceDrives = _L("cz"); 
+
+    RFs fs;
+ 	
+    // start a file session
+    User::LeaveIfError( fs.Connect() );
+	CleanupClosePushL ( fs );
+
+    // Declare a resource file
+    RResourceFile resourceFile;
+    
+    TFileName name;
+    TInt i( 0 );
+    // try to find from the first driver
+    name.Append( KResourceDrives[i] );
+    name.Append( ':' );
+    name.Append( KDC_RESOURCE_FILES_DIR );
+    name.Append( KResourceFileName );
+
+    TBool found( EFalse );
+    
+    while ( !found && i < KResourceDrives.Length() )
+        {
+        name[0] = KResourceDrives[i++];
+       
+        if ( BaflUtils::FileExists(fs, name) )
+            {
+            // open resource
+            resourceFile.OpenL( fs, name );
+            CleanupClosePushL( resourceFile );
+            found = ETrue;
+            }
+        }
+            
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+	HBufC8* res = resourceFile.AllocReadLC(VASINFO); // Stack: file session, res file, res reader
+
+	TResourceReader theReader;
+	theReader.SetBuffer(res);
+
+    // Get the name of the database file
+    iDatabasePath = theReader.ReadHBufCL();
+    iDatabaseName = theReader.ReadHBufCL();
+
+    // Release resource reader
+    // Close resource file
+    // Close file session
+	CleanupStack::PopAndDestroy( res );
+	CleanupStack::PopAndDestroy( &resourceFile );
+	CleanupStack::PopAndDestroy( &fs );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvasctagmgr.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,751 @@
+/*
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssTagMgr implements the MNssTagMgr interface. In addition, it also provides
+*               methods for internal use by VAS components.
+*
+*/
+
+
+// includes
+#include "nssvasctagmgr.h"
+#include "nssvasccontextmgr.h"
+#include "nssvascvasdatabase.h"
+#include "nssvascspeechitembuilder.h"
+#include "rubydebug.h"
+
+_LIT( KTagMgrPanic, "tagmgr.cpp" );
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CNssTagMgr
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssTagMgr::CNssTagMgr()
+: CActive( CActive::EPriorityStandard )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CNssTagMgr
+// C++ overloaded constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssTagMgr::CNssTagMgr(CNssVASDatabase* aVasDatabase, CNssContextMgr *aContextManager)
+: CActive( CActive::EPriorityStandard ), iTagList( 0 ), iTagRefList( 0 )
+    {
+    iVasDatabase = aVasDatabase;
+    iContextManager = aContextManager;
+    iState = ENone;
+    }
+
+// destructor
+CNssTagMgr::~CNssTagMgr()
+    {
+    Cancel();
+
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        }
+    if ( iSpeechItemBuilder )
+        {
+        delete iSpeechItemBuilder;
+        iSpeechItemBuilder = NULL;
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssTagMgr* CNssTagMgr::NewL( CNssVASDatabase* aVasDatabase, CNssContextMgr *aContextManager )
+    {
+    CNssTagMgr* self = NewLC(aVasDatabase, aContextManager);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssTagMgr* CNssTagMgr::NewLC( CNssVASDatabase* aVasDatabase, CNssContextMgr *aContextManager )
+    {
+    CNssTagMgr* self = new(ELeave) CNssTagMgr(aVasDatabase, aContextManager);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return ( self );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::ConstructL
+// EPOC constructor.
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::ConstructL()
+    {
+    iSpeechItemBuilder = CNssSpeechItemBuilder::NewL( iVasDatabase );
+    
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CreateTagL
+// creates a new tag, taking in the context for the tag
+// -----------------------------------------------------------------------------
+//
+MNssTag* CNssTagMgr::CreateTagL( MNssContext* aContext )
+    {
+    if ( !aContext )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    CNssContext *context = ((CNssContext*)(aContext))->CopyL();
+    CleanupStack::PushL(context);
+    CNssSpeechItem *speechItem = iSpeechItemBuilder->CreateEmptySpeechItemL(*context);
+    CleanupStack::PushL(speechItem);
+    CNssRRD* rrd = CNssRRD::NewL(); 
+    CleanupStack::PushL(rrd);
+    CNssTag *tag = new (ELeave) CNssTag(context, rrd, speechItem);
+    CleanupStack::Pop(rrd);
+    CleanupStack::Pop(speechItem);
+    CleanupStack::Pop(context);
+    return tag;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CreateTagL
+// gets a tag list from VAS DB for a given context
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::GetTagList( MNssGetTagClient* aTagClient,MNssContext* aContext )
+    {
+    if ( IsActive() || !aTagClient || !aContext )
+        {
+        return KErrGeneral;
+        }
+    
+    iState = EGetTagClient;
+    iGetTagClient = aTagClient;
+    
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    
+    iTagList = iVasDatabase->GetTag((CNssContext*)(aContext));
+    
+    if ( !iTagList || iTagList->Count() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete(pRS, KErrNone);
+    SetActive();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::GetTagList
+// gets a tag list from VAS DB for a given name
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::GetTagList( MNssGetTagClient* aTagClient, 
+                             MNssContext* aContext, const TDesC& aName )
+    {
+    if ( IsActive() || !aTagClient || 
+         !aContext || aName.Length() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    iState = EGetTagClient;
+    iGetTagClient = aTagClient;
+    
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    
+    iTagList = iVasDatabase->GetTag((CNssContext*)(aContext), aName);
+    
+    if ( !iTagList || iTagList->Count() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete(pRS, KErrNone);
+    SetActive();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::DeleteTag
+// deletes a tag from VAS 
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::DeleteTag( MNssDeleteTagClient* aTagClient, MNssTag* aTag )
+    {
+    if ( IsActive() || !aTagClient || !aTag )
+        {
+        return KErrGeneral;
+        }
+
+    iState = EDeleteTagClient;
+	iDeleteTagClient = aTagClient;
+	iLocalTag = (CNssTag*) (aTag);
+	iLocalSpeechItem = (CNssSpeechItem*) (iLocalTag->SpeechItem());
+
+    TInt ret( KErrNone );
+
+   	MNssCoreSrsDBEventHandler::TNssSrsDBResult srsDBResult = 
+   	                    MNssCoreSrsDBEventHandler::EVasSuccess;
+    TRAPD( err, (srsDBResult = 
+           iLocalSpeechItem->NSSBeginDeleteFromSrs( iDeleteTagClient, iLocalTag )) );
+
+	if(err != KErrNone || srsDBResult != MNssCoreSrsDBEventHandler::EVasSuccess)
+        {
+		ret = KErrGeneral;
+        }
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::SaveTag
+// saves a tag to VAS 
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::SaveTag( MNssSaveTagClient* aTagClient, MNssTag* aTag )
+    {
+    if ( IsActive() || !aTagClient || !aTag )
+        {
+        return KErrGeneral;
+        }
+    
+    // Client can save only trained tags.
+    if ( aTag->SpeechItem()->TrainedType() == TNssVasCoreConstant::EVasNotTrained )
+        {
+        return KErrNotReady;
+        }
+    
+    iSaveTagClient = aTagClient;
+    
+    iState = ESaveTagClient;
+    
+    /********************* Debug rule ID and grammar ID ***********************/
+    /*
+    RFs session;
+    RFile file;
+    _LIT( aFileName, "c:\\documents\\savetag.txt" );
+    
+      session.Connect();
+      if ( file.Open( session, aFileName, EFileWrite ) != KErrNone )
+      {
+      if ( file.Create( session, aFileName, EFileWrite ) != KErrNone )
+      {
+      User::Panic( _L("SDContrlDebug"), __LINE__ );
+      }
+      }
+      
+        TInt size = 0;
+        file.Seek( ESeekEnd, size );
+        
+          TBuf8<100> debugBuf;
+          debugBuf.AppendFormat( _L8("Saving tag with RID:%d, GID:%d\n"), ((CNssSpeechItem*)aTag->SpeechItem())->RuleID(),((CNssContext*)aTag->Context())->GrammarId() );
+          file.Write( debugBuf );
+          
+            file.Close();
+            session.Close();
+    */
+    /**************************************************************************/
+    TInt ret( KErrNone );
+    CNssTag* tag = (CNssTag*)aTag;
+    TInt err;
+    
+    iLocalSpeechItem = (CNssSpeechItem*)tag->SpeechItem();
+    err = iLocalSpeechItem->NSSBeginSaveToSrs( aTagClient, tag );
+    
+    if ( err != KErrNone )
+        {
+        ret = KErrGeneral;
+        }
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::GetTag
+// get tag from VAS DB based on grammar id and rule id
+// -----------------------------------------------------------------------------
+//
+CNssTag* CNssTagMgr::GetTag( TUint32 aGrammarId, TUint32 aRuleId )
+    {
+    MNssTag* result = 0;
+    
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    
+    iTagList = iVasDatabase->GetTag( aGrammarId, aRuleId );
+    
+    // If there are tags in the list, return the first one.
+    if ( iTagList != 0 )
+        {
+        if ( iTagList->Count() > 0 )
+            {
+            result = (*iTagList)[0];
+            
+            iTagList->Delete( 0 );
+            
+            __ASSERT_DEBUG( iTagList->Count() == 0, User::Panic( KTagMgrPanic, __LINE__ ) );
+            }
+        
+        // Release the memory
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = 0;
+        }
+    
+    // Cast is safe, since only CNssTag implements MNssTag.
+    return( STATIC_CAST( CNssTag*, result ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::GetTags
+// get tags from VAS DB based on theirgrammar id and rule id
+// -----------------------------------------------------------------------------
+MNssTagListArray* CNssTagMgr::GetTags( TNssGrammarIdRuleIdListArray&  aGrammarIdRuleIds)
+    {
+    MNssTagListArray* result = iVasDatabase->GetTags( aGrammarIdRuleIds );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::VASDatabaseComplete
+// call back from CNssVASDatabase 
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::VASDatabaseComplete( CArrayPtrFlat<CNssContext>* /*aContextList*/, 
+                                      CArrayPtrFlat<CNssTag>* /*aTagList*/, 
+                                      CArrayPtrFlat<CNssTagReference>* /*aTagRefList*/,
+                                      MNssVASDatabaseClient::TNssVASDBClientReturnCode /*aCode*/ )
+    {
+    User::Panic( KTagMgrPanic, __LINE__ );
+    }
+ 
+// -----------------------------------------------------------------------------
+// CNssTagMgr::HandleSaveSrsDBCompleted
+//  call back from SRS DB 
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::HandleSaveSrsDBCompleted()
+    {
+    TInt newTagId;
+    
+    CNssSpeechItem* item = (CNssSpeechItem*)iLocalTag->SpeechItem();
+    
+    // Save tag to VAS.
+    TInt ret = iVasDatabase->SaveTag( iLocalTag, newTagId );
+    
+    // If VAS DB saving failed, roll back Plugin DB changes.
+    if ( ret != KErrNone )
+        {
+        CNssSpeechItem* item = (CNssSpeechItem*)iLocalTag->SpeechItem();
+        item->RollbackSrsChanges();
+        
+        if(iSaveTagClient)
+            {
+            iSaveTagClient->SaveTagCompleted( ret );
+            }
+        return;
+        }
+    
+    MNssCoreSrsDBEventHandler::TNssSrsDBResult srsret = item->CommitSrsChanges();
+    
+    if ( srsret == EVasSuccess )
+        {
+        if(iSaveTagClient)
+            {
+            iSaveTagClient->SaveTagCompleted( KErrNone );
+            }
+        }
+    else{
+        if(iSaveTagClient)
+            {
+            iSaveTagClient->SaveTagCompleted( KErrGeneral );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::HandleDeleteSrsDBCompleted
+//  call back from SRS DB 
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::HandleDeleteSrsDBCompleted()
+    {
+    iState = ENone;
+
+    TInt ret = iVasDatabase->DeleteTag( iLocalTag );
+
+    //                      trained, not saved -case
+    if ( ret != KErrNone && ret != KErrNotFound )
+        {
+        iLocalSpeechItem->RollbackSrsChanges();
+
+        iDeleteTagClient->DeleteTagCompleted( ret );
+        return;
+        }
+
+    if ( iLocalSpeechItem->CommitSrsChanges() != MNssCoreSrsDBEventHandler::EVasSuccess )
+        {
+        iDeleteTagClient->DeleteTagCompleted( KErrGeneral );
+        return;
+        }
+
+    iDeleteTagClient->DeleteTagCompleted( KErrNone );
+    return;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::HandleResetSrsDBCompleted
+//  call back from SRS DB 
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::HandleResetSrsDBCompleted()
+    {
+    // Should never be called
+    RUBY_DEBUG0( "CNssTagMgr::HandleResetSrsDBCompleted - ERROR" );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::HandleSrsDBError
+//  call back from SRS DB 
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::HandleSrsDBError( MNssCoreSrsDBEventHandler::TNssSrsDBResult /*aResult*/ )
+    {
+    
+    switch(iState)
+        {
+        case EDeleteTagClient:
+            iState = ENone;
+            iDeleteTagClient->DeleteTagCompleted( KErrGeneral );
+            break;
+        case ESaveTagClient:
+            iState = ENone;
+            iSaveTagClient->SaveTagCompleted( KErrGeneral );
+            break;
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CNssTagListToMNssTagListConvertorL
+//  utility function for CNssTag list to MNssTag list conversion, and call back to client
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::CNssTagListToMNssTagListConvertorL(CArrayPtrFlat<CNssTag>* aSourceList)
+    {
+    CArrayPtrFlat<MNssTag> *destinationList = new (ELeave) CArrayPtrFlat<MNssTag>(1);
+    CleanupStack::PushL(destinationList);
+    for(TInt i = 0; i < aSourceList->Count(); i++)
+        {
+        destinationList->AppendL( (MNssTag*) ((*aSourceList)[i]) );
+        }
+    aSourceList->Reset();
+    delete aSourceList; 
+    CleanupStack::Pop(destinationList);
+    iGetTagClient->GetTagListCompleted(destinationList, KErrNone);
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY    
+    iGetTagClient->GetTagListCompleted( destinationList );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY  
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CancelGetTag
+// cancel get tag for inter-comp clients
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::CancelGetTag()
+    {
+    iInterCompTagMgrClient = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::TagCount
+// gets a tag count from VAS DB for a given context
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::TagCount( MNssContext* aContext )
+    {
+    return iVasDatabase->TagCount( (CNssContext*)aContext );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::Tag
+// gets a tag from VAS DB based on rrd int value and position
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::GetTagList(MNssGetTagClient* aTagClient,MNssContext* aContext,
+                            TInt aNum,TInt aPosition)
+    {
+    if ( IsActive() || !aTagClient || !aContext
+         || aPosition < 0 )
+        {
+        return KErrGeneral;
+        }
+    iState = EGetTagClient;
+    iGetTagClient = aTagClient;
+    
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    
+    iTagList = iVasDatabase->GetTagList( (CNssContext*)aContext, aNum, aPosition );
+    
+    if ( !iTagList || iTagList->Count() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete(pRS, KErrNone);
+    SetActive();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::GetTagList
+// gets a tag from VAS DB based on rrd text value and position
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::GetTagList( MNssGetTagClient* aTagClient,MNssContext* aContext,
+                             TDesC& aText,TInt aPosition )
+    {
+    if ( IsActive() || !aTagClient || !aContext ||
+        aText.Length() == 0 || aPosition < 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    iState = EGetTagClient;
+    iGetTagClient = aTagClient;
+    
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    
+    iTagList = iVasDatabase->GetTagList( (CNssContext*)aContext, aText, aPosition );
+    
+    if ( !iTagList || iTagList->Count() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete(pRS, KErrNone);
+    SetActive();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::GetTagReferenceList
+// get a list of tag references from VAS DB based on a context
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::GetTagReferenceList( MNssGetTagReferenceClient* aTagRefClient,
+                                      MNssContext* aContext)
+    {
+    if ( IsActive() || !aTagRefClient || !aContext )
+        {
+        return KErrGeneral;
+        }
+    
+    iState = EGetTagReferenceClient;
+    iGetTagReferenceClient = aTagRefClient;
+    
+    if ( iTagRefList )
+        {
+        iTagRefList->ResetAndDestroy();
+        delete iTagRefList;
+        iTagRefList = NULL;
+        }
+    
+    iTagRefList = iVasDatabase->GetTagReferenceList( (CNssContext*)aContext );
+    
+    if ( !iTagRefList || iTagRefList->Count() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete(pRS, KErrNone);
+    SetActive();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::GetTag
+// get a tag from VAS DB based on tagreference (using the TagId of the tagreference)
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::GetTag(MNssGetTagClient* aTagClient,MNssTagReference* aTagReference)
+    {
+    CNssTagReference* ctagRef = (CNssTagReference*) aTagReference;
+    
+    if ( IsActive() || !aTagClient || !aTagReference )
+        {
+        return KErrGeneral;
+        }
+    
+    iState = EGetTagClient;
+    iGetTagClient = aTagClient;
+    
+    if( iTagList ) 
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    
+    iTagList = iVasDatabase->GetTag( ctagRef->TagId() );
+    
+    if ( !iTagList || iTagList->Count() == 0 )
+        {
+        return KErrGeneral;
+        }
+    
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete(pRS, KErrNone);
+    SetActive();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::CNssTagRefListToMNssTagRefListConvertorL
+// utility function for CNssTagReference list to MNssTagReference list conversion, 
+// and call back to client
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::CNssTagRefListToMNssTagRefListConvertorL(
+                    CArrayPtrFlat<CNssTagReference>* aSourceList )
+    {
+    
+    CArrayPtrFlat<MNssTagReference> *destinationList = 
+                            new (ELeave) CArrayPtrFlat<MNssTagReference>(1);
+    CleanupStack::PushL(destinationList);
+    for(TInt i = 0; i < aSourceList->Count(); i++)
+        {
+        destinationList->AppendL( (MNssTagReference*) ((*aSourceList)[i]) );
+        }
+    aSourceList->Reset();
+    delete aSourceList; 
+    CleanupStack::Pop(destinationList);
+    iGetTagReferenceClient->GetTagReferenceListCompleted( destinationList,
+                                                          KErrNone );
+    }
+
+
+/************ ACTIVE OBJECT *************/
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::DoCancel
+//
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::RunL
+//
+// -----------------------------------------------------------------------------
+//
+void CNssTagMgr::RunL()
+    {
+	switch (iState)
+	    {
+        case ESaveTagClient:
+            iSaveTagClient->SaveTagCompleted( KErrNone );
+            break;
+
+        case EGetTagClient:
+            {
+            MNssTagListArray* ret = iTagList;
+            iTagList = 0;
+
+            iGetTagClient->GetTagListCompleted( ret, KErrNone );
+#ifndef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY    
+            iGetTagClient->GetTagListCompleted( ret );
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY              
+            }
+            break;
+
+        case EGetTagReferenceClient:
+            {
+            CArrayPtrFlat<MNssTagReference>* ret = iTagRefList;
+            iTagRefList = 0;
+
+            iGetTagReferenceClient->GetTagReferenceListCompleted( ret, KErrNone );
+            }
+            break;
+
+        default:
+            User::Panic( KTagMgrPanic, __LINE__ );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagMgr::RunError
+//
+// -----------------------------------------------------------------------------
+//
+TInt CNssTagMgr::RunError(TInt /*aError*/)
+{
+	Cancel();
+
+    return KErrNone;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvascvasdatabase.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,996 @@
+/*
+* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVasDatabase is responsible for the issuing of requests  to
+*               to the VasDb server and returning the results to the VasDb Managers.
+*
+*/
+
+
+#include "srsfbldvariant.hrh"
+#include <e32base.h>
+#include <e32test.h>
+#include "nssvascvasdatabase.h"
+#include "nssvascspeechitem.h"
+#include "nssvascvasdbsrvdef.h"
+#include "nssvastspeechitemconstant.h"
+#include <f32file.h>
+#include "rubydebug.h"
+
+// Complementary macro for TRAPD:
+// TRAPD( err, doSomething() );
+// REACT( err, return( err ) );
+#define REACT(a,b) if ( a < 0 ) {b;}
+
+const TInt KTagRefListGranularity = 2;
+
+const TInt KFetchedTagRefListGranularity = 50;
+
+#ifdef _DEBUG
+// used in UDEB macros only
+_LIT( KVasDatabasePanic, "CNssVasDatabase.cpp" );
+#endif // _DEBUG
+
+// ============================ Methods ===============================
+
+//-------------------------------------------------------- 
+//C++ default constructor can NOT contain any code that
+// might leave.
+//--------------------------------------------------------    
+CNssVASDatabase::CNssVASDatabase( TInt /*aPriority*/ )
+: iIsLocked( EFalse )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssVASDatabase* CNssVASDatabase::NewLC( TInt aPriority )
+    {
+	CNssVASDatabase* self = new(ELeave)CNssVASDatabase( aPriority );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssVASDatabase* CNssVASDatabase::NewL( TInt aPriority )
+    {
+	CNssVASDatabase* self = NewLC( aPriority );
+	CleanupStack::Pop( self );
+	return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssVASDatabase::ConstructL()
+    {
+    iContextBuilder         = CNssContextBuilder::NewL();
+    iSpeechItemBuilder      = CNssSpeechItemBuilder::NewL( this );
+    iVasDb                  = CNssVasDb::NewL( *iContextBuilder, 
+                                               *iSpeechItemBuilder);
+    iTNssTagRefList         = new(ELeave) TNssTagReferenceListArray( KTagRefListGranularity );
+    }
+
+//------------------------------------------
+// CNssVASDatabase::~CNssVASDatabase
+// Destructor
+//------------------------------------------
+CNssVASDatabase::~CNssVASDatabase()
+    {
+    RUBY_DEBUG0( "CNssVASDatabase::~CNssVASDatabase" ); 
+
+    if ( iGrammarIdRuleIdPackage )
+	    {
+	    delete iGrammarIdRuleIdPackage;
+        }
+
+	if ( iSpeechItemBuilder )
+	    {
+	    delete iSpeechItemBuilder;
+	    }
+
+	if ( iVASDBEventMonitor )
+	    {
+	    delete iVASDBEventMonitor;
+	    }
+
+	if ( iTNssTagRefList )
+	    {
+        iTNssTagRefList->Reset();
+	    delete iTNssTagRefList;
+	    }
+
+	if ( iVasDb )
+	    {
+	    delete iVasDb;
+	    }
+	if ( iContextBuilder )
+	    {
+	    delete iContextBuilder;
+        }	    
+    }
+    
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::OpenDatabase
+// Method to open the database.
+// -----------------------------------------------------------------------------
+//
+TInt CNssVASDatabase::OpenDatabase()
+    {
+    if ( iConnected )
+        {
+        iConnected++;
+        return KErrDbAlreadyOpen;
+        }
+
+    TRAPD( error, iVasDb->OpenDatabaseL() ); 
+
+    if ( error == KErrNone )
+        {
+        iConnected++;
+        }
+
+    return error;
+    }
+	
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::CloseDatabase
+// Method to close the database.
+// -----------------------------------------------------------------------------
+//
+void CNssVASDatabase::CloseDatabase()
+    {
+    // Check if already closed (or never opened)
+    if ( iConnected > 0 )
+        {
+        // Some other VAS instance in the same thread may be using the database.
+        iConnected--;
+
+        // If not, close it.
+        if ( iConnected <= 0 )
+            {
+            iVasDb->CloseDatabase();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::CreateDb
+// Method to create vas database
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::CreateDb()
+    {
+    TRAPD( error, iVasDb->CreateDatabaseL() );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::StartMonitoringDatabaseL
+// Method to start monitoring changes to vas database
+// -----------------------------------------------------------------------------
+void CNssVASDatabase::StartMonitoringDatabaseL()
+    {
+    //iVASDBEventMonitor = CNssVASDBEventMonitor::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::AddObserverL
+// Method to add an observer of the vas database
+// -----------------------------------------------------------------------------
+void CNssVASDatabase::AddObserverL( MNssVASDatabaseObserver* /*aObserver*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::RemoveObserverL
+// Method to remove an observer of the vas database
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::RemoveObserver( MNssVASDatabaseObserver* /*aObserver*/ )
+    {
+	return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::ModelBankAndLexiconExist
+// Method to determine if modelbank and lexicon ids exist.
+// -----------------------------------------------------------------------------
+TBool CNssVASDatabase::ModelBankAndLexiconExist( TUint32 &aModelBankId, TUint32 &aLexiconId )
+    {
+    TBool ret = EFalse;
+
+    TRAPD( err, ret = iVasDb->GetModelBankIdLexiconIdL( aModelBankId, aLexiconId ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return ret;
+    }
+
+//-----------------------------------------------------------------------------
+//CNssVasDatabase::TagExist
+//Method to determine if tags exist for a context.
+//-----------------------------------------------------------------------------
+TBool CNssVASDatabase::TagExist( CNssContext* aContext )
+    {
+    TBool ret( EFalse );
+
+    if ( aContext->ContextId() != KNssVASDbDefaultValue )
+        {
+        TRAPD( error, ret = iVasDb->TagExistL( aContext->ContextId() ) );
+        REACT( error, ret = EFalse );
+        } 
+    else
+        {
+        RUBY_DEBUG0( "CNssVASDatabase::TagExist ERROR:Unsaved context" );
+        }
+
+    return ret;
+    }
+//-----------------------------------------------------------------------------
+//CNssVasDatabase::TagCount
+//Method to get the number of tags for a context.
+//-----------------------------------------------------------------------------
+TInt CNssVASDatabase::TagCount( CNssContext* aContext )
+    {
+    TInt ret( KErrNotFound );
+   
+    if ( aContext->ContextId() != KNssVASDbDefaultValue )
+        {
+        TRAPD( error, ret = iVasDb->TagCountL( aContext->ContextId() ) );
+
+        // To remove warning
+        if ( error != KErrNone )
+            {
+            }
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::SaveContext
+// Method to save a context 
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::SaveContext( CNssContext* aContext, TInt& aContextId )
+    {
+    TInt ret = KErrNone;
+
+    aContextId = aContext->ContextId();
+        
+    if ( aContext->ContextId() == KNssVASDbDefaultValue )
+        {
+        TRAP( ret, iVasDb->SaveContextL( *aContext, aContextId ) );
+        }
+    else
+        {
+        TRAP( ret, iVasDb->UpdateContextL( *aContext ) );
+        }
+        
+    return ret;  
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::SaveContextClientData
+// Method to save the clientdata of a context 
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::SaveContextClientData( CNssContext* aContext )
+    {
+    TRAPD( error, iVasDb->UpdateContextClientDataL( *aContext ) );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetContext
+// Method to get a context by name
+// -----------------------------------------------------------------------------
+CArrayPtrFlat<CNssContext>* CNssVASDatabase::GetContext( const TDesC& aName )
+    {
+    CArrayPtrFlat<CNssContext>* result = NULL;
+
+    TRAPD( error, result = iVasDb->GetContextByNameL( aName ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetGlobalContexts
+// Method to get all global contexts 
+// -----------------------------------------------------------------------------
+CArrayPtrFlat<CNssContext>* CNssVASDatabase::GetGlobalContexts()
+    {
+    CArrayPtrFlat<CNssContext>* result = NULL;
+
+    TRAPD( error, result = iVasDb->GetGlobalContexts() );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+
+    return( result );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetAllContexts
+// Method to get all contexts 
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* CNssVASDatabase::GetAllContexts()
+    {
+    CArrayPtrFlat<CNssContext>* result = NULL;
+
+    TRAPD( error, result = iVasDb->GetAllContexts() );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::SaveTag
+// Method to save a tag 
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::SaveTag( CNssTag* aTag, TInt& aNewId )
+    {
+    TInt ret = KErrNone;
+        
+    if ( aTag->TagId() == KNssVASDbDefaultValue )
+        {
+        TRAP( ret, iVasDb->SaveTagL( *aTag, aNewId ) );
+        }
+    else
+        {
+        // Used to call RNssVasDbSession::UpdateTag
+        // which returned KErrNotSupported
+        ret = KErrNotSupported;
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteTag
+// Method to delete several tags 
+// -----------------------------------------------------------------------------
+//
+TInt CNssVASDatabase::DeleteTags( const RArray<TUint32>& aTagIdArray )
+    {
+    TRAPD( error, iVasDb->DeleteTagsL( aTagIdArray ) );
+
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::SaveTag
+// Method to save several tags 
+// -----------------------------------------------------------------------------
+//
+TInt CNssVASDatabase::SaveTags( RPointerArray<CNssTag>* aTagArray )
+    {
+    RUBY_DEBUG0("CNssVASDatabase::SaveTags");
+        
+    RArray<TInt> tagIdArray;
+    
+    ASSERT( aTagArray );
+    
+    TInt arrayCount = aTagArray ? aTagArray->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+        
+    CArrayPtrFlat<CNssTag>* ctagArray = new CArrayPtrFlat<CNssTag>( arrayCount );
+    
+    for( TInt i( 0 ); i < aTagArray->Count(); i++ )
+        {
+        TRAPD( error, ctagArray->AppendL( (*aTagArray)[i] ) );
+        if( error != KErrNone )
+            {
+            delete ctagArray;
+            return error;
+            }
+        }
+
+    TRAPD( error, iVasDb->SaveTagsL( ctagArray, tagIdArray ) );
+    
+    if( error == KErrNone ) 
+    	{
+    	RUBY_ASSERT_DEBUG( ctagArray->Count() == tagIdArray.Count(), 
+    	                   User::Panic( KVasDatabasePanic, __LINE__ ) );
+
+    	for ( TInt k( 0 ); k < ctagArray->Count(); k++ )
+        	{
+        	(*aTagArray)[k]->SetTagId( tagIdArray[k] );
+        	}
+    	}
+    else 
+    	{
+    	// iSess->SaveTags failed
+    	/** @todo Higher level handler should display some "No memory" label if possible 
+    	Or should we do it here? */
+    	}
+    	
+    delete ctagArray;
+    
+    tagIdArray.Close();
+    	
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTag
+// Method to get a tag by name
+// -----------------------------------------------------------------------------
+MNssTagListArray* CNssVASDatabase::GetTag( const TDesC& aName )
+    {
+    CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result = iVasDb->GetTagL( aName ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    TInt arrayCount = result ? result->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+    
+    array = new CArrayPtrFlat<MNssTag>( arrayCount );
+    if( !array )
+        {
+        return NULL;
+        }
+    
+    if( result )
+        {
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;   
+        }
+        
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTag
+// Method to get a tag by context and name
+// Not fully implemented.
+// -----------------------------------------------------------------------------
+ 
+MNssTagListArray* CNssVASDatabase::GetTag(CNssContext* /*aContext*/,const TDesC& aName)
+    {
+    return GetTag(aName);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTag
+// Method to get a tag by context.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<MNssTag>* CNssVASDatabase::GetTag( CNssContext* aContext )
+    {
+    CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result =  iVasDb->GetTagL( *aContext ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    if( result )
+        {
+        array = new CArrayPtrFlat<MNssTag>( result->Count() );
+        if( !array )
+            {
+            return NULL;
+            }
+        
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            CNssTag* tag = result->At( i );
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;        
+        }
+    
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTag
+// Method to get a tag by grammarid and ruleid.
+// -----------------------------------------------------------------------------
+//
+MNssTagListArray* CNssVASDatabase::GetTag( const TInt aGrammarID, const TInt aRuleID )
+    {
+    iTNssGrammarIdRuleId.iGrammarId = aGrammarID;
+    iTNssGrammarIdRuleId.iRuleId    = aRuleID;
+
+    CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result =  iVasDb->GetTagL( iTNssGrammarIdRuleId ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    TInt arrayCount = result ? result->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+    
+    array = new CArrayPtrFlat<MNssTag>( arrayCount );
+    if( !array )
+        {
+        return NULL;
+        }
+    
+    if( result )
+        {
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;    
+        }
+    
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTags
+// Method to get tags by their grammarid and ruleid.
+// -----------------------------------------------------------------------------
+//
+MNssTagListArray* CNssVASDatabase::GetTags( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds)
+	{
+	CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result =  iVasDb->GetTagsL( aGrammarIdRuleIds ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    TInt arrayCount = result ? result->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+    
+    array = new CArrayPtrFlat<MNssTag>( arrayCount );
+    if( !array )
+        {
+        return NULL;
+        }
+    
+    if( result )
+        {
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;        
+        }
+
+    return array;
+	}
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTag
+// Method to get a tag by tagid
+// -----------------------------------------------------------------------------
+MNssTagListArray* CNssVASDatabase::GetTag( const TUint32 aTagId )
+    {
+    CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result =  iVasDb->GetTagL( aTagId ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    TInt arrayCount = result ? result->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+    
+    array = new CArrayPtrFlat<MNssTag>( arrayCount );
+    if( !array )
+        {
+        return NULL;
+        }
+    
+    if( result )
+        {
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;
+        }
+        
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTagList
+// Method to get tags by rrd int position.
+// -----------------------------------------------------------------------------
+MNssTagListArray* CNssVASDatabase::GetTagList( CNssContext* aContext, TInt aNum, TInt aPosition )
+    {    
+    CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result = iVasDb->GetTagL( aContext->ContextId(),
+                                            aNum, aPosition ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    TInt arrayCount = result ? result->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+    
+    array = new CArrayPtrFlat<MNssTag>( arrayCount );
+    if( !array )
+        {
+        return NULL;
+        }
+    
+    if( result )
+        {
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;        
+        }
+    
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::GetTagList
+// Method to get tags by rrd text value and position.
+// -----------------------------------------------------------------------------
+MNssTagListArray* CNssVASDatabase::GetTagList( CNssContext* aContext, 
+                                               TDesC& aText, TInt aPosition )
+    {
+    CArrayPtrFlat<CNssTag>* result = NULL;
+
+    TRAPD( error, result = iVasDb->GetTagL( aContext->ContextId(),
+                                            aText, aPosition ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+    
+    CArrayPtrFlat<MNssTag>* array = NULL;
+    
+    TInt arrayCount = result ? result->Count() : 0;
+    if( arrayCount == 0 )
+        {
+        arrayCount++;
+        }
+    
+    array = new CArrayPtrFlat<MNssTag>( arrayCount );
+    if( !array )
+        {
+        return NULL;
+        }
+    
+    if( result )
+        {
+        for( TInt i( 0 ); i < result->Count(); i++ )
+            {
+            TRAP( error, array->AppendL( result->At( i ) ) );
+            if( error != KErrNone )
+                {
+                return NULL;
+                }
+            }
+            
+        result->Reset();
+        delete result;        
+        }
+    
+    return array;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteTag
+// Method to delete a tag.
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::DeleteTag( CNssTag *aTag )
+    {
+    TInt ret( KErrNotFound );
+   
+    if ( aTag->TagId() != KNssVASDbDefaultValue )
+        {
+        ret = DeleteTag( aTag->TagId() );
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteTag
+// Method to delete a tag by name.
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::DeleteTag( const TDesC& aName )
+    {
+    TRAPD( error, iVasDb->DeleteTagL( aName ) );
+
+    return( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteTag
+// Method to delete a tag by key/id.
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::DeleteTag( const TUint32 aTagId )
+    {
+    TRAPD( error, iVasDb->DeleteTagL( aTagId ) );
+
+    return( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteContext
+// Method to delete context.
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::DeleteContext( CNssContext* aContext )
+    {
+    return( DeleteContext( aContext->ContextName() ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteContext
+// Method to delete context by name.
+// -----------------------------------------------------------------------------
+TInt CNssVASDatabase::DeleteContext( const TDesC& aName )
+    {
+    TRAPD( error, iVasDb->DeleteContextL( aName ) );
+
+    return( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDatabase::DeleteContext
+// Method to all tag references of a context.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<MNssTagReference>* CNssVASDatabase::GetTagReferenceList( CNssContext* aContext )
+    {
+    TNssTagReferenceListArray* ttagRefArray = NULL;
+   
+    TRAPD( error,
+           ttagRefArray = iVasDb->GetTagReferenceListL( aContext->ContextId() ) );
+
+    // To remove warning
+    if ( error != KErrNone )
+        {
+        }
+
+    if ( !ttagRefArray )
+        {
+        return( NULL );
+        }
+
+    // Convert TNssTagReferences to CNssTagReferences
+    CArrayPtrFlat<MNssTagReference>* result = 
+            new CArrayPtrFlat<MNssTagReference>( KFetchedTagRefListGranularity );
+
+    if ( !result )
+        {
+        delete ttagRefArray;
+        ttagRefArray = 0;
+        return( NULL );
+        }
+
+    TRAPD( err, ConvertTNssTagRefToMNssTagRefL( ttagRefArray, result ) );
+
+    delete ttagRefArray;
+    ttagRefArray = 0;
+
+    if ( err != KErrNone )
+        {
+        result->ResetAndDestroy();
+        delete result;
+        result = 0;
+        }
+
+    return( result );
+    }
+
+
+// ------------------------
+// Private Utility Methods  
+// -----------------------
+
+// -----------------------------------------------------------------------------
+// CNssVASDatabase::ConvertTNssTagRefToMNssTagRefL
+//
+// -----------------------------------------------------------------------------
+//
+void CNssVASDatabase::ConvertTNssTagRefToMNssTagRefL( 
+                            TNssTagReferenceListArray* aTNssTagRef, 
+                            CArrayPtrFlat<MNssTagReference>* aCNssTagRef )
+    {
+    CNssTagReference* tagRefPtr=NULL;
+
+    for ( TInt i( 0 ); i < aTNssTagRef->Count(); i++ )
+        {
+        tagRefPtr = new(ELeave)CNssTagReference();
+        CleanupStack::PushL( tagRefPtr );
+        tagRefPtr->SetTagNameL( (*aTNssTagRef)[i].iTagName );
+        tagRefPtr->SetTagId( (*aTNssTagRef)[i].iTagId );
+	    aCNssTagRef->AppendL( tagRefPtr );
+	    CleanupStack::Pop( tagRefPtr );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDatabase::ConvertDBError
+//
+// -----------------------------------------------------------------------------
+//
+MNssVASDatabaseClient::TNssVASDBClientReturnCode CNssVASDatabase::ConvertDBError( TInt aError )
+    {
+    MNssVASDatabaseClient::TNssVASDBClientReturnCode failcode = 
+                                        MNssVASDatabaseClient::EVASDBFailure;
+
+    switch ( aError )
+        {
+        case KErrNone:
+		    failcode = MNssVASDatabaseClient::EVASDBSuccess;
+        break;
+        case KErrNotFound:
+		    failcode = MNssVASDatabaseClient::EVASDBItemNotFound;
+	    break;
+        case KErrNoMemory:
+            failcode = MNssVASDatabaseClient::EVASDBNoMemory;
+        break;
+        case KErrDiskFull:
+		    failcode = MNssVASDatabaseClient::EVASDBDiskFull;
+	    break;
+        default:
+            failcode = MNssVASDatabaseClient::EVASDBFailure;//just in case
+        break;
+        }
+
+    return failcode;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDatabase::GetDefaultModelBankId
+//
+// -----------------------------------------------------------------------------
+//
+TInt CNssVASDatabase::GetDefaultModelBankId( TUint32& aId )
+    {
+    TRAPD( error, iVasDb->GetDefaultModelBankIdL( aId ) );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDatabase::ResetModelBank
+//
+// -----------------------------------------------------------------------------
+//
+TInt CNssVASDatabase::ResetModelBank( TUint32 aNewId )
+    {
+    TRAPD( error, iVasDb->ResetModelBankL( aNewId ) );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDatabase::UpdateTagRuleIDs
+//
+// -----------------------------------------------------------------------------
+//
+TInt CNssVASDatabase::UpdateTagRuleIDs(
+    const RArray<TNssSpeechItem>& aRetrainedTags )
+    {
+    TRAPD( error, iVasDb->UpdateTagRuleIDsL( aRetrainedTags ) );
+    
+    return( error );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvascvasdb.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,2810 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of VAS database handling
+*
+*/
+
+
+#include "nssvascvasdb.h"
+#include <e32test.h>
+#include <e32std.h>
+#include <e32svr.h>
+#include "rubydebug.h"
+#include "nssvascoreconstant.h"
+#include "nssvascrrd.h"
+
+#include "nssvasbackupobserver.h"
+
+// CONSTANTS
+
+// Name of the DB lock mutex
+_LIT( KLockMutex, "VASDATABASE" );
+
+#ifdef _DEBUG
+// used in UDEB macros only
+_LIT( KVasDbPanic, "VasCNssVasDb.cpp");
+#endif // _UDEB
+
+// Maximum size of tag array
+static const TInt KMaxTagArraySize = 50;
+
+const TInt KContextListGranularity = 5;
+
+const TInt KSqlStatementmaxLength = 120;
+
+// MACROS
+
+// Complementary macro for TRAPD
+#define REACT( err, codeblock ) if ( err != KErrNone ) { codeblock; }
+
+// ============================ Methods ===============================
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::NewL
+// 2-level constructor
+// -----------------------------------------------------------------------------
+//
+CNssVasDb* CNssVasDb::NewL( CNssContextBuilder& contextBuilder,
+	                        CNssSpeechItemBuilder& speechItemBuilder )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::NewL" );
+
+    CNssVasDb* self = new(ELeave) CNssVasDb( contextBuilder,
+                                             speechItemBuilder );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::~CNssVasDb
+// Standard C++ destructor
+// -----------------------------------------------------------------------------
+//
+CNssVasDb::~CNssVasDb()
+    {
+    RUBY_DEBUG0( "CNssVasDb::~CNssVasDb" );
+
+    if ( iLocked )
+        {
+        RUBY_DEBUG0( "Signalling mutex in CNssVasDb::~CNssVasDb" );
+        iMutex.Signal();
+        }
+    else
+        {
+        RUBY_DEBUG0( "NOT signalling mutex in CNssVasDb::~CNssVasDb iLocked = EFalse" );
+        }
+
+    if ( iClientHasOpenedDatabase )
+        {
+        CloseDatabase();
+        }
+
+    iMutex.Close();
+    delete iBackupObserver;
+    iCriticalSection.Close();
+    RUBY_DEBUG0( "CNssVasDb::~CNssVasDb Mutex handle closed" );
+    }
+	
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::CNssVasDb
+// Standard C++ contructor
+// -----------------------------------------------------------------------------
+//
+CNssVasDb::CNssVasDb( CNssContextBuilder& aContextBuilder,
+	                  CNssSpeechItemBuilder& aSpeechItemBuilder )
+: iClientHasOpenedDatabase( EFalse ),
+  iLocked( EFalse ),
+  iContextBuilder( aContextBuilder ),
+  iSpeechItemBuilder( aSpeechItemBuilder )
+    {
+    // empty
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::ConstructL
+// Symbian second constructor.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::ConstructL()
+    {
+    TInt err = iMutex.OpenGlobal( KLockMutex );
+    if ( err != KErrNone )
+        {
+        RUBY_DEBUG0( "CNssVasDb::ConstructL Creating new global mutex" );
+        iMutex.CreateGlobal( KLockMutex );
+        }
+    else
+        {
+        RUBY_DEBUG0( "CNssVasDb::ConstructL Using existing global mutex" );
+        }
+    iCriticalSection.CreateLocal();
+    iBackupObserver = CNssVasBackupObserver::NewL( *this );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::RollbackCleanupFunction
+// This function is used to form iRollbackCleanupItem. When this item is
+// popped from the cleanup stack, it makes a rollback on VAS DB.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::RollbackCleanupFunction( TAny* aArg )
+    {
+    RUBY_DEBUG0( "CNssVasDb::RollbackCleanupFunction" );
+
+    CNssVasDb* me = (CNssVasDb*)aArg;
+
+    me->RollbackTransaction();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::CreateDatabaseL
+// Creates a new database.
+// from a resource file.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::CreateDatabaseL()
+    {
+    User::LeaveIfError( iDbSession.Connect() );
+    CleanupClosePushL( iDbSession );
+    iDbcreator.CreateVasDatabaseL( iDbSession );
+    CleanupStack::PopAndDestroy( &iDbSession );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::OpenDatabaseL
+// Opens the database. Reads the path and file name of the database
+// from a resource file.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::OpenDatabaseL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::OpenDatabaseL" );
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        RFs fs;
+        User::LeaveIfError( fs.Connect() );
+        CleanupClosePushL ( fs ); // Stack: file session
+
+        // Open the database
+	    User::LeaveIfError( iDbSession.Connect() );
+	    
+        User::LeaveIfError( iDatabase.Open( iDbSession, 
+                            KVasDatabaseName, KVasDatabaseFormatString ) );
+        User::LeaveIfError( fs.CharToDrive( KVasDatabaseDrive, iDrive ) );
+
+        if ( iDatabase.IsDamaged() )
+            {
+            RUBY_DEBUG0( "CNssVasDb::OpenDatabaseL Recovering" );
+            User::LeaveIfError( iDatabase.Recover() );
+            }
+            
+        CleanupStack::PopAndDestroy( &fs ); 
+
+	    iClientHasOpenedDatabase = ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::CloseDatabase
+// Closes the database.
+// -----------------------------------------------------------------------------
+//
+TInt CNssVasDb::CloseDatabase()
+    {
+    RUBY_DEBUG0( "CNssVasDb::CloseDatabase" ); 
+  
+    iDatabase.Close();
+    iDbSession.Close();
+    iClientHasOpenedDatabase = EFalse;
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetModelBankIdLexiconIdL
+// Returns the model bank ID and the lexicon ID.
+// -----------------------------------------------------------------------------
+//
+TBool CNssVasDb::GetModelBankIdLexiconIdL( TUint32& aModelBankId, TUint32& aLexiconId )
+    {
+    TBool ret = EFalse;
+    RDbView view;
+  
+    _LIT( KSQLGetModelBankLexicon, "select modelbankid,lexiconid from contexttable" );
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    CleanupClosePushL( view );
+
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( 
+                            KSQLGetModelBankLexicon, EDbCompareNormal ) ) );
+    User::LeaveIfError( view.EvaluateAll() );
+
+    // There is no ModelbankId or LexiconId 
+    if ( view.IsEmptyL() )
+        {
+        User::Leave( KErrNotFound );
+        }
+    // There is a ModelBankId and a LexiconId 
+    ret = ETrue;
+    view.FirstL();
+    view.GetL();
+
+    // Get column set
+    CDbColSet* columns = view.ColSetL();
+    // Get column ordinals
+    TDbColNo modelbankid_col = columns->ColNo( KModelBankIdCol );
+    TDbColNo lexiconid_col = columns->ColNo( KLexiconIdCol );
+    // Cleanup column set
+    delete columns;
+
+    aModelBankId = view.ColUint32( modelbankid_col );
+    aLexiconId   = view.ColUint32( lexiconid_col );
+ 
+    // Close view
+    CleanupStack::PopAndDestroy( &view );
+
+    // Release lock
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::TagExistsL
+// Checks if a context is empty.
+// -----------------------------------------------------------------------------
+//
+TBool CNssVasDb::TagExistL( TInt aContextId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::TagExistL" );
+ 
+    TBool   ret( EFalse );
+    RDbView view;
+
+    CleanupClosePushL(view);
+
+    _LIT( KSQLGetTags, "select * from tagtable " );
+    _LIT( KSQLWhereContextId, "where contextid=" );
+
+    iSQLStatement = KSQLGetTags;
+    iSQLStatement.Append( KSQLWhereContextId );
+    iSQLStatement.AppendNumUC( aContextId );
+    
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+    User::LeaveIfError( view.EvaluateAll() );
+
+    if ( view.IsEmptyL() )
+        {
+        ret = EFalse;
+        }
+    else
+        {
+        ret = ETrue;
+        }
+
+    // Close view
+    CleanupStack::PopAndDestroy( &view );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::TagCountL
+// Returns the number of tags.
+// -----------------------------------------------------------------------------
+//
+TInt CNssVasDb::TagCountL( TInt aContextId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::TagCountL" );
+        
+    RDbView view;
+    TInt    numberOfTags = 0;
+
+    CleanupClosePushL( view );
+
+    _LIT( KSQLGetTags, "select * from tagtable " );
+    _LIT( KSQLWhereContextId, "where contextid=" );
+
+    iSQLStatement = KSQLGetTags;
+    iSQLStatement.Append( KSQLWhereContextId );
+    iSQLStatement.AppendNumUC( aContextId );
+    
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+    User::LeaveIfError( view.EvaluateAll() );
+
+    numberOfTags = view.CountL();
+   
+    view.Close();
+    CleanupStack::PopAndDestroy( &view );
+   
+    return numberOfTags;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::CommitIfSuccess
+// Commits or rolls back accoring to success parameter.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::CommitIfSuccess( RDbDatabase /*aDatabase*/, TInt aSuccess, TBool aCompactIfCommit )
+    {
+    if ( aSuccess >= 0 )
+        {
+        CommitTransaction( aCompactIfCommit );
+        }
+    else
+        {
+        // Otherwise, roll back the transaction and release the lock.
+        RollbackTransaction();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::SaveContextL
+// Saves a newly created context. The Context ID is assigned and returned
+// using the reference parameter.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::SaveContextL( CNssContext& aContext, TInt& aContextId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::SaveContextL" );
+  
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+
+    // Locks the database for the use of this process only
+    TInt error = StartTransaction();
+
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: could not lock database." );
+        
+        User::Leave( KErrGeneral );
+        }
+
+    TRAP( error, SaveContextL( &aContext, aContextId ) );
+    REACT( error, RUBY_DEBUG0( "Context saving failed" ) );
+
+    if ( error == KErrNone )
+        {
+        TRAP ( error, DoUpdateContextClientDataL( aContext ) );
+        }
+    
+    CommitIfSuccess( iDatabase, error, ETrue );
+    
+    User::LeaveIfError( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateContextL
+// Updates the context to VAS DB.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateContextL( CNssContext& aContext )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::UpdateContextL" );
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+
+    TInt error = StartTransaction();
+
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: could not lock database." );
+        
+        User::Leave( KErrGeneral );
+        }
+
+    TRAP( error, DoUpdateContextL( aContext ) );
+    REACT( error, RUBY_DEBUG0( "Context updating failed" ) );
+
+    CommitIfSuccess( iDatabase, error, ETrue );
+    
+    User::LeaveIfError( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateContextInsideTransactionL
+// Updates the context to VAS DB.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateContextInsideTransactionL( CNssContext& aContext )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::UpdateContextInsideTransactionL" );
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+
+    DoUpdateContextL( aContext );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateContextClientDataL
+// Updates the client data of the context.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateContextClientDataL( CNssContext& aContext )   
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::UpdateContextClientDataL" );
+	
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+
+    TInt error = StartTransaction();
+
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: could not lock database." );
+        
+        User::Leave( KErrGeneral );
+        }
+
+    TRAP( error, DoUpdateContextClientDataL( aContext ) );
+
+    CommitIfSuccess( iDatabase, error, ETrue );
+    
+    User::LeaveIfError( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetDefaultModelBankIdL
+// Usually, all contexts use the same Model Bank. This function
+// returns the first model bank ID it finds.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::GetDefaultModelBankIdL( TUint32& aId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::GetDefaultModelBankIdL" );
+      
+    _LIT( KSQLGetAll,"select modelbankid from contexttable");
+
+    iSQLStatement = KSQLGetAll;
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+
+    StartTransaction();
+    CreatePushRollbackItemLC();
+
+    RDbView view;
+
+    CleanupClosePushL(view);
+
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+    User::LeaveIfError( view.EvaluateAll() );
+
+    if ( view.IsEmptyL() )
+        {
+	    User::Leave( KErrNotFound );
+        }
+
+    // Get column set
+    CDbColSet* columns = view.ColSetL();
+    // Get model bank id column ordinal
+	TDbColNo modelbankid_col= columns->ColNo( KModelBankIdCol );
+	delete columns;
+
+	view.FirstL();
+    view.GetL(); // Retrieve the current row - actually reads the row from the database.
+
+    aId = view.ColUint32( modelbankid_col );
+
+    CleanupStack::PopAndDestroy( &view );// close view
+
+    // Rollback cleanup
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::ResetModelBankL
+// Usually, all contexts use the same Model Bank. When the model bank is reseted,
+// (=speaker independent models are resotred and speaker adaptation is destroyed)
+// the model bank ID changes for all contexts.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::ResetModelBankL( TUint32 aNewId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::ResetModelBankL" );
+
+    _LIT( KSQLUpdateModelbank,"update contexttable set modelbankid=");
+
+    iSQLStatement = KSQLUpdateModelbank;
+    iSQLStatement.AppendNumUC( aNewId );
+
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+
+    StartTransaction();
+    CreatePushRollbackItemLC();
+
+    User::LeaveIfError( iDatabase.Execute( iSQLStatement ) );
+
+    CleanupStack::Pop();  // Rollback cleanup item
+
+    User::LeaveIfError( CommitTransaction( ETrue ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetContextByNameL
+// Reads a context from VAS DB by name.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* CNssVasDb::GetContextByNameL(const TDesC& aName)
+    {
+	RUBY_DEBUG_BLOCK("CNssVasDb::GetContextByNameL");
+
+    _LIT( KSQLGetAll,"select * from contexttable ");
+    _LIT( KSQLWhereName,"where name='");
+    _LIT( KTick,"' ");
+
+    iSQLStatement = KSQLGetAll;
+    iSQLStatement.Append( KSQLWhereName );
+    iSQLStatement.Append( aName );
+    iSQLStatement.Append( KTick );
+
+    return GetContextL( iSQLStatement );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetGlobalContexts
+// Reads all global contexts from VAS DB.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* CNssVasDb::GetGlobalContexts()
+    {
+	RUBY_DEBUG0("CNssVasDb::GetGlobalContexts");
+	    
+    _LIT( KSQLGetAll,"select * from contexttable ");
+    _LIT( KSQLWhereGlobal,"where global=1");
+
+    iSQLStatement = KSQLGetAll;
+    iSQLStatement.Append( KSQLWhereGlobal );
+
+    CArrayPtrFlat<CNssContext>* ret( NULL );
+    TRAPD( error, ret = GetContextL( iSQLStatement ) );
+    if ( error != KErrNone )
+        {
+        return NULL;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetAllContexts
+// Reads all contexts from VAS DB.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* CNssVasDb::GetAllContexts()
+    {   
+    RUBY_DEBUG0("CNssVasDb::GetAllContexts");
+    
+    _LIT( KSQLGetAll,"select * from contexttable ");
+
+    iSQLStatement = KSQLGetAll;
+
+    CArrayPtrFlat<CNssContext>* ret( NULL );
+    TRAPD( error, ret = GetContextL( iSQLStatement ) );
+    if ( error != KErrNone )
+        {
+        return NULL;
+        }
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetContextL
+// Executes the SQL query. After the query has selected a list of contexts,
+// these contexts are read from DB to memory.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* CNssVasDb::GetContextL(const TDesC& aSQLStatement)
+    {
+    RUBY_DEBUG_BLOCK("CNssVasDb::GetContextL");
+
+    __ASSERT_DEBUG( aSQLStatement.Left( 6 ).Compare( _L("select") ) == 0,
+                    User::Panic( KVasDbPanic, __LINE__ ) );
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+
+    TInt ret = StartTransaction();
+    RUBY_DEBUG1("Started transaction. Error code [%d]", ret);
+    
+    CreatePushRollbackItemLC();
+    CArrayPtrFlat<CNssContext>* contextList = GetContextInsideTransactionL( aSQLStatement );
+
+    // Rollback cleanup (just to avoid automatic locking)
+    CleanupStack::Pop();  // Rollback cleanup item 
+    CommitTransaction( EFalse );
+
+    return contextList;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetContextInsideTransaction
+// Reads a context by name. Assumes that a transaction has already been started.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* CNssVasDb::GetContextInsideTransactionL( const TDesC& aSQLStatement )
+    {
+    RUBY_DEBUG_BLOCK("CNssVasDb::GetContextInsideTransactionL");
+    RDbView view;
+
+    CleanupClosePushL(view);
+
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( aSQLStatement, EDbCompareNormal ) ) );
+    RUBY_DEBUG0("CNssVasDb::GetContextInsideTransactionL Prepared query");
+    User::LeaveIfError( view.EvaluateAll() );
+    RUBY_DEBUG0("CNssVasDb::GetContextInsideTransactionL Evaluated query");
+
+    if ( view.IsEmptyL() )
+        {
+        RUBY_DEBUG0("CNssVasDb::GetContextInsideTransactionL Empty view. Leaving with KErrNotFound");
+	    User::Leave( KErrNotFound );
+        }
+
+    CArrayPtrFlat<CNssContext>* contextList = 
+            new (ELeave) CArrayPtrFlat<CNssContext>( KContextListGranularity );
+    CleanupStack::PushL( contextList );
+    CleanupResetAndDestroyPushL( *contextList );
+    RUBY_DEBUG0("CNssVasDb::GetContextInsideTransactionL Before FillContextListArrayL");
+
+    FillContextListArrayL(view, *contextList);
+   
+    CleanupStack::Pop( contextList ); // ResetAndDestroy
+    CleanupStack::Pop( contextList );  // array itself
+    CleanupStack::PopAndDestroy( &view );// close view
+
+    return( contextList );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagReferenceList
+// Fetches tag references for all tags in a context.
+// -----------------------------------------------------------------------------
+//
+TNssTagReferenceListArray* CNssVasDb::GetTagReferenceListL( TInt aContextId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::GetTagReferenceListL" );
+    
+    RDbView view;
+    TNssTagReference tagRef;
+
+    TNssTagReferenceListArray* tagArray = 
+            new (ELeave) TNssTagReferenceListArray( KMaxTagArraySize );
+    CleanupStack::PushL( tagArray );
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+
+    // Start transaction - lock database
+    StartTransaction();
+    CreatePushRollbackItemLC();
+
+    // Make a query, which lists all tags in the context.
+    // Making a CNssTagReferece only requires tagid and name.
+    _LIT( KSQLGetTag, "select tagid,name from tagtable where contextid=" );
+    iSQLStatement = KSQLGetTag;
+    iSQLStatement.AppendNumUC( aContextId );
+
+    CleanupClosePushL(view);
+
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+    User::LeaveIfError( view.EvaluateAll() );
+
+    if ( view.IsEmptyL() )
+        {
+	    User::Leave( KErrNotFound );
+        }
+
+    // Get column set
+    CDbColSet* columns = view.ColSetL();
+    // Get column ordinals
+    TDbColNo name_col  = columns->ColNo( KNameCol );
+    TDbColNo tagid_col = columns->ColNo( KTagIdCol );
+
+    delete columns;
+
+    for( view.FirstL(); view.AtRow(); view.NextL() )
+        {
+        view.GetL();
+	    tagRef.iTagName = view.ColDes( name_col );
+	    tagRef.iTagId   = view.ColUint32( tagid_col );
+	    tagArray->AppendL( tagRef );
+        }
+
+    // Close view
+    CleanupStack::PopAndDestroy( &view );
+
+    // Finish transaction - release lock
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+
+    // Return result
+    CleanupStack::Pop( tagArray );
+
+    return( tagArray );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::SaveTagL
+// Saves a newly created tag. When a tag is saved, a Tag ID is assigned to it.
+// This Tag ID is returned in the reference parameter.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::SaveTagL( CNssTag& aTag, TInt& aNewId )
+    {
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+
+    // Locks the database for the use of this process only	
+    
+    TInt error = StartTransaction();
+
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: could not lock database." );
+        
+        User::Leave( KErrGeneral );
+        }
+
+    TInt contextId; // Discard context ID 
+    
+    CNssContext* context = static_cast<CNssContext*> ( aTag.Context() );
+    TRAP( error, SaveContextL( context, contextId ) );
+	
+    if ( error == KErrItemAlreadyExist || error == KErrNone )
+        {
+        TRAP( error, SaveTagL( &aTag, aNewId ) );
+        }
+    else 
+        {
+        RollbackTransaction(); 
+        User::Leave( error );
+        }
+    
+    // Check SavetagL result
+    if ( error != KErrNone )
+        {
+        RollbackTransaction(); 	
+        User::Leave( error );
+        }
+    else
+        {
+        CNssRRD* rrd = static_cast<CNssRRD*>( aTag.RRD() );
+        rrd->SetTagId( aNewId );
+
+        TRAPD( error, SaveRRDL( rrd ) );
+	    REACT( error, RUBY_DEBUG0( "RRD saving failed." ) );
+
+        CommitIfSuccess( iDatabase, error, ETrue );
+        }
+        
+    User::LeaveIfError( error );
+    }
+
+// ---------------------------------------------------------
+// CNssVasDb::SaveTagsL
+// Saves several tags in one commit.
+// ---------------------------------------------------------
+//
+void CNssVasDb::SaveTagsL( CArrayPtrFlat<CNssTag>* aTagArray, RArray<TInt>& aTagIdArray )
+    {
+	CleanupClosePushL( aTagIdArray );
+
+    TInt k( 0 );
+    TInt error( KErrNone );
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+
+    // Locks the database for the use of this process only	
+    User::LeaveIfError( StartTransaction() );
+
+    CreatePushRollbackItemLC(); // Stack: rollback cleanup
+
+    RArray<TInt> contextIds;
+    CleanupClosePushL( contextIds ); // Stack: rollback cleanup, contextIds
+
+    for ( k = 0; k < aTagArray->Count(); k++ )
+        {
+        CNssTag* tag = (*aTagArray)[k];
+        CNssContext* context = static_cast<CNssContext*> ( tag->Context() );
+
+        if ( contextIds.Find( context->ContextId() ) == KErrNotFound )
+            {
+            TInt contextId;
+            TRAP( error, SaveContextL( context, contextId ) );
+
+            // We accept leaves with error KErrAlreadyExists
+            if ( error != KErrNone && error != KErrAlreadyExists )
+                {
+                break;
+                }
+
+            contextIds.Append( context->ContextId() );
+            }
+        }
+
+    // Close context id array
+    CleanupStack::PopAndDestroy( &contextIds ); // Stack: Rollback cleanup
+
+    // We accept leaves with error KErrAlreadyExists
+    if ( error != KErrNone && error != KErrAlreadyExists )
+        {
+        User::Leave( error );
+        }
+
+    TInt id;
+    for ( k = 0; k < aTagArray->Count(); k++ )
+        {
+        CNssTag* tag = (*aTagArray)[k];
+
+        if ( tag->TagId() == KNssVASDbDefaultValue )
+            {
+            SaveTagL( tag, id );
+
+            CNssRRD* rrd = static_cast<CNssRRD*>( tag->RRD() );
+            rrd->SetTagId( id );
+
+	        SaveRRDL( rrd );
+            User::LeaveIfError( aTagIdArray.Append( id ) );
+            }
+        else{
+            UpdateTagInTransactionL( *tag );
+            User::LeaveIfError( aTagIdArray.Append( tag->TagId() ) );
+            }
+        }
+
+    User::LeaveIfError( CommitTransaction( ETrue ) );
+
+    // Pop rollback cleanup
+    // (which would have made database rollback, if a leave had happened)
+    CleanupStack::Pop();  // Rollback cleanup item
+	CleanupStack::Pop();
+    }
+
+// ---------------------------------------------------------
+// CNssVasDb::DeleteTagsL
+// Deletes several tags in one commit.
+// ---------------------------------------------------------
+//
+void CNssVasDb::DeleteTagsL( const RArray<TUint32>& aTagIdArray )
+    {
+    TInt k( 0 );
+   
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+
+    // Locks the database for the use of this process only	
+    User::LeaveIfError( StartTransaction() );
+
+    CreatePushRollbackItemLC();
+
+    for ( k = 0; k < aTagIdArray.Count(); k++ )
+        {
+        DeleteTagInsideTransactionL( aTagIdArray[k] );
+        }
+
+    User::LeaveIfError( CommitTransaction( ETrue ) );
+
+    // Pop rollback cleanup
+    // (which would have made database rollback, if a leave had happened)
+    CleanupStack::Pop();  // Rollback cleanup item
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateTagL
+// Updates the data of an existing tag.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateTagL( CNssTag& aTag )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::UpdateTagL" );	
+
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+	
+    // Locks the database for the use of this process only
+    User::LeaveIfError( StartTransaction() );
+
+    TRAPD( error, UpdateTagInTransactionL( aTag ) );
+
+    CommitIfSuccess( iDatabase, error, ETrue );
+
+    User::LeaveIfError( error );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateTagRuleIDs
+// Changes the Rule IDs of some tags. The Rule ID changes, when
+// and already trained tags is retrained.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateTagRuleIDsL( const RArray<TNssSpeechItem>& aRetrainedTags )
+    {
+    TInt error( KErrNone );
+    if ( !iClientHasOpenedDatabase )
+        {
+        User::Leave( KErrDbNotSet );
+        }
+   
+    _LIT( KSQLUpdateTag,"update tagtable set ");
+    _LIT( KEqual,"=");
+    _LIT( KSQLWhereTagIdIs," where tagid = ");
+
+    TInt count = aRetrainedTags.Count();
+
+    if ( count > 0 )
+        {
+        return;
+        }
+
+    // Start transaction
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    // Make the changes to Rule IDs
+    for ( TInt k( 0 ); k < count; k++ )
+        {
+        // "update tagtable set "
+        iSQLStatement = KSQLUpdateTag;
+
+        // "ruleid=1234"
+        iSQLStatement.Append( KRuleIdCol );
+        iSQLStatement.Append( KEqual );
+        iSQLStatement.AppendNumUC( aRetrainedTags[k].iRuleId );
+
+        // " where tagid = 5678"
+        iSQLStatement.Append( KSQLWhereTagIdIs );
+        iSQLStatement.AppendNumUC( aRetrainedTags[k].iTagId );
+
+        error =  iDatabase.Execute( iSQLStatement );
+        if ( error < KErrNone )
+            {
+            ReleaseDiskSpace();
+            User::Leave( error );
+            }
+        }
+
+    // Commit transaction
+    error = CommitTransaction( ETrue );
+    if ( error )
+        {
+        ReleaseDiskSpace();
+        User::Leave( error );
+        }
+
+    // Pop rollback cleanup object
+    CleanupStack::Pop();  // Rollback cleanup item
+
+    ReleaseDiskSpace();    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::SaveContextL
+// Saves a newly created context. When a context is saved, a Context ID is
+// assigned to it. This id is returned using the reference parameter.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::SaveContextL( CNssContext* aContext, TInt& aContextId )
+    {
+    TBuf<KNssVasDbContextName> name;
+    RDbView view1;
+
+    _LIT( KSQLAdd, "select * from contexttable " );
+    _LIT( KSQLWhereName, "where name='" );
+    _LIT( KTick, "' " );
+
+    //Check to see if a context already exist with the new name
+    iSQLStatement = KSQLAdd;
+    iSQLStatement.Append( KSQLWhereName );
+    iSQLStatement.Append( aContext->ContextName() );
+    iSQLStatement.Append( KTick );
+	
+    CleanupClosePushL( view1 );
+   
+    User::LeaveIfError( view1.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );	
+    User::LeaveIfError( view1.EvaluateAll() );
+
+    if ( !view1.IsEmptyL() ) // context with that name already exist so return status
+        {  
+        // Get column set
+        CDbColSet* columns1 = view1.ColSetL();
+        TDbColNo contextid_col = columns1->ColNo( KContextIdCol );
+
+	    delete columns1;
+
+        view1.FirstL();
+        view1.GetL();
+	    //Get the  unique contextid key just generated
+	    aContextId = view1.ColUint32(contextid_col);
+	    aContext->SetContextId( aContextId );
+
+	    view1.Close();	  
+	    CleanupStack::PopAndDestroy( &view1 );
+        
+        User::Leave( KErrAlreadyExists );
+        }
+    else{
+        view1.Close();
+	    CleanupStack::PopAndDestroy( &view1 );
+	   
+	    RDbView view2;
+
+        CleanupClosePushL( view2 );
+
+	    User::LeaveIfError( view2.Prepare( iDatabase, TDbQuery(KSQLAdd,EDbCompareNormal)));	
+        User::LeaveIfError( view2.EvaluateAll() );
+  
+	    // Get column set
+        CDbColSet* columns = view2.ColSetL();
+        // Get column ordinals
+        TDbColNo name_col = columns->ColNo( KNameCol );
+        TDbColNo global_col = columns->ColNo( KGlobalCol );
+	    TDbColNo grammarid_col = columns->ColNo( KGrammarIdCol );
+	    TDbColNo lexiconid_col = columns->ColNo( KLexiconIdCol );
+	    TDbColNo modelbankid_col = columns->ColNo( KModelBankIdCol );
+	    TDbColNo contextid_col = columns->ColNo( KContextIdCol );
+
+	    delete columns;
+
+	    // Begin process of inserting a row...
+	    view2.InsertL();
+	    // set column values...
+	    view2.SetColL( name_col, aContext->ContextName() );
+	    view2.SetColL( global_col, aContext->IsGlobal() );
+	    view2.SetColL( lexiconid_col, aContext->LexiconId() );
+	    view2.SetColL( grammarid_col, aContext->GrammarId() );
+	    view2.SetColL( modelbankid_col, aContext->ModelBankId() );
+	
+	    // add the row to the table...
+	    view2.PutL();
+	             
+	    view2.GetL();
+        //Get the  unique contextid key just generated
+	    aContextId = view2.ColUint32( contextid_col );
+
+	    aContext->SetContextId( aContextId );
+
+	    name = view2.ColDes( name_col );
+	  
+	    view2.Close();
+	    CleanupStack::PopAndDestroy( &view2 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::SaveTagL
+// Saves a newly created tag. When a tag is saved, a Tag ID is assigned to it.
+// This id is returned using the reference parameter.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::SaveTagL( CNssTag* aTag, TInt& aNewId )
+    {
+	RDbView view;
+ 
+    _LIT( KSQLGet,"select * from tagtable");
+	
+	CleanupClosePushL(view);
+
+	User::LeaveIfError( view.Prepare( iDatabase, TDbQuery(KSQLGet,EDbCompareNormal)));	
+	User::LeaveIfError( view.EvaluateAll());
+    
+	// Get column set
+    CDbColSet* columns = view.ColSetL();
+    // Get column ordinals
+    TDbColNo name_col           = columns->ColNo( KNameCol );
+	TDbColNo tagid_col          = columns->ColNo( KTagIdCol );
+	TDbColNo contextid_col      = columns->ColNo( KContextIdCol );
+	TDbColNo ruleid_col         = columns->ColNo( KRuleIdCol );
+
+	delete columns;
+	  
+	// Begin process of inserting a row...
+	view.InsertL();
+	// set column values...
+	
+	CNssContext* context = static_cast<CNssContext*> ( aTag->Context() );
+	CNssSpeechItem* speechItem = static_cast<CNssSpeechItem*> ( aTag->SpeechItem() );
+	
+	#ifdef __SIND_EXTENSIONS
+	    view.SetColL( name_col, aTag->SpeechItem()->RawText() ); 
+	#else
+	    view.SetColL( name_col, aTag->SpeechItem()->Text() ); 
+	#endif  // __SIND_EXTENSIONS
+	view.SetColL( contextid_col, context->ContextId() );
+	view.SetColL( ruleid_col, speechItem->RuleID() );
+	
+	// add the row to the table...
+	view.PutL();
+
+    aNewId = view.ColUint32( tagid_col );
+
+	// finished - so close the view
+	view.Close();
+	CleanupStack::PopAndDestroy( &view );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::SaveRRDL
+// Reads RRD from DB to memory. Utility function when reading tags.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::SaveRRDL( CNssRRD* aRRD )
+    {
+    TInt position;
+	RDbView view1,view2;
+   
+	_LIT( KSQLAddRRDText, "select * from rrdtexttable");
+	_LIT( KSQLAddRRDId,   "select * from rrdinttable");
+	
+    // Save the integer array, if we have one.
+    if ( aRRD->IntArray() )
+        {
+	    CleanupClosePushL(view1);
+	
+	    User::LeaveIfError( view1.Prepare( iDatabase, TDbQuery( KSQLAddRRDId, EDbCompareNormal ) ) );	
+	    User::LeaveIfError( view1.EvaluateAll());
+
+	    // Get column set	
+        CDbColSet* columns1 = view1.ColSetL();
+        // Get column ordinals
+        TDbColNo tagid_col           = columns1->ColNo( KTagIdCol );
+	    TDbColNo rrdint_col          = columns1->ColNo( KRRDIntCol );
+        TDbColNo rrdposition_col1    = columns1->ColNo( KRRDPositionCol );
+
+	    delete columns1;
+
+	    // Begin process of inserting a row...
+	    // set column values for id table...
+        for( position=0; position<aRRD->IntArray()->Count(); position++ )
+            {
+	        view1.InsertL();
+	        view1.SetColL( tagid_col,aRRD->TagId() );
+	        view1.SetColL(rrdint_col,aRRD->IntArray()->At( position ) );
+	        view1.SetColL(rrdposition_col1,position);
+	        // add the row to the table...
+	        view1.PutL();	   
+	        }	
+	
+	    // finished - so close the view
+	    view1.Close(); 	
+	    CleanupStack::PopAndDestroy( &view1 );
+        }
+
+    // Save the text array, if we have one
+    if ( aRRD->TextArray() )
+        {
+	    CleanupClosePushL( view2 );
+
+        User::LeaveIfError( view2.Prepare( iDatabase, 
+                            TDbQuery( KSQLAddRRDText, EDbCompareNormal ) ) );	
+	    User::LeaveIfError( view2.EvaluateAll() );
+    
+        // Get column set
+        CDbColSet* columns2 = view2.ColSetL();
+        // Get column ordinals
+        TDbColNo tagid_col2       = columns2->ColNo( KTagIdCol );
+	    TDbColNo rrdtext_col2     = columns2->ColNo( KRRDTextCol );
+        TDbColNo rrdposition_col2 = columns2->ColNo( KRRDPositionCol );
+
+	    delete columns2;
+
+	    //set colum values for text table
+	    for( position = 0; position < aRRD->TextArray()->Count(); position++ )
+            {
+	        view2.InsertL();
+	        view2.SetColL( tagid_col2, aRRD->TagId() );
+	        view2.SetColL( rrdtext_col2, aRRD->TextArray()->At( position ) );
+	        view2.SetColL( rrdposition_col2, position );
+	        view2.PutL();	   
+            }	
+	    // add the row to the table...
+	
+	    // finished - so close the view
+	    view2.Close();  
+	    CleanupStack::PopAndDestroy( &view2 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::FillRRDL
+// Reads RRD from DB to memory. Utility function when reading tags.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::FillRRDL( TUint32 aTagId, CNssRRD& aRRD )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::FillRRDL" );
+    
+    TInt position;
+	RDbView view1,view2;
+
+	_LIT( KSQLAddRRDText, "select * from rrdtexttable ");
+	_LIT( KSQLAddRRDId,   "select * from rrdinttable ");
+	_LIT( KSQLWhereTagId,"where tagid=");
+
+	iSQLStatement = KSQLAddRRDId;
+	iSQLStatement.Append( KSQLWhereTagId );
+	iSQLStatement.AppendNumUC( aTagId );
+
+	CleanupClosePushL(view1);
+
+	User::LeaveIfError( view1.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view1.EvaluateAll());
+
+	// Get column set
+    CDbColSet* columns1 = view1.ColSetL();
+    // Get column ordinals
+    TDbColNo tagid_col           = columns1->ColNo( KTagIdCol );
+	TDbColNo rrdint_col          = columns1->ColNo( KRRDIntCol );
+    TDbColNo rrdposition_col1    = columns1->ColNo( KRRDPositionCol );
+	// Cleanup column1 set
+	delete columns1;
+
+	// Begin process of inserting a row...
+	TInt intarraysize = view1.CountL();
+    if ( intarraysize > 0 )
+        {
+        CArrayFixFlat<TInt>* intArray = new (ELeave) CArrayFixFlat<TInt>(intarraysize);
+        CleanupStack::PushL( intArray );
+        intArray->ResizeL( intarraysize );
+        
+        // set column values for id table...
+        for ( view1.FirstL(); view1.AtRow(); view1.NextL() )
+            {
+            view1.GetL();
+            aRRD.SetTagId( view1.ColUint32( tagid_col ) );
+            position = view1.ColUint32( rrdposition_col1 );
+            if ( position < 0 || position >= intarraysize )
+                {
+                RUBY_ERROR2("CNssVasDb::FillRRDL position out of bounds. 0 < %i < %i", 
+                    position, intarraysize );
+                User::Leave( KErrCorrupt );
+                }
+            intArray->At( position ) = view1.ColUint32( rrdint_col );
+            }
+
+        aRRD.SetIntArrayL( intArray );
+        CleanupStack::Pop( intArray );
+        intArray->Reset();
+        delete intArray;
+        }
+    
+	// finished - so close the view
+	view1.Close();
+	CleanupStack::PopAndDestroy( &view1 );
+ 
+	CleanupClosePushL(view2);
+
+	iSQLStatement = KSQLAddRRDText;
+	iSQLStatement.Append( KSQLWhereTagId );
+	iSQLStatement.AppendNumUC( aTagId );
+    User::LeaveIfError( view2.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view2.EvaluateAll() );
+    
+    // Get column set
+    CDbColSet* columns2 = view2.ColSetL();
+    // Get column ordinals
+    TDbColNo tagid_col2       = columns2->ColNo( KTagIdCol );
+	TDbColNo rrdtext_col2     = columns2->ColNo( KRRDTextCol );
+    TDbColNo rrdposition_col2 = columns2->ColNo( KRRDPositionCol );
+   
+	delete columns2;
+    
+	TInt textarraysize = view2.CountL();
+    if ( textarraysize > 0 )
+        {
+        CArrayFixFlat<NssRRDText>* textArray = 
+                    new (ELeave) CArrayFixFlat<NssRRDText>(textarraysize);
+        CleanupStack::PushL( textArray );
+        textArray->ResizeL( textarraysize );
+
+        //set colum values for text table
+        for ( view2.FirstL(); view2.AtRow(); view2.NextL() )
+            {
+            view2.GetL();
+            aRRD.SetTagId( view2.ColUint32( tagid_col2 ) );
+            position      = view2.ColUint32( rrdposition_col2 );
+            if ( position < 0 || position >= textarraysize )
+                {
+                RUBY_ERROR2("CNssVasDb::FillRRDL position out of bounds. 0 < %i < %i", 
+                    position, textarraysize );
+                User::Leave( KErrCorrupt );
+                }
+            textArray->At( position ) = view2.ColDes( rrdtext_col2 );
+            }	
+
+        aRRD.SetTextArrayL( textArray );
+        CleanupStack::Pop( textArray );
+        textArray->Reset();
+        delete textArray;
+        }
+
+	// finished - so close the view
+	view2.Close();
+        
+    CleanupStack::PopAndDestroy( &view2 );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagL
+// Gets a tag by grammar ID and rule ID.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagL( TNssGrammarIdRuleId aGrammarIdRuleId )
+    {
+	CNssContext* context = iContextBuilder.CreateContextL();
+	CleanupStack::PushL( context );
+	RDbView view;
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+	CleanupClosePushL(view);
+
+	_LIT( KSQLGetContext, "select * from contexttable where grammarid=");
+	iSQLStatement.Copy(KSQLGetContext);
+	iSQLStatement.AppendNumUC(aGrammarIdRuleId.iGrammarId);
+
+    TDbQuery dbQuery(iSQLStatement, EDbCompareNormal);
+	User::LeaveIfError( view.Prepare( iDatabase, dbQuery ) );
+	User::LeaveIfError( view.EvaluateAll() );
+
+	view.FirstL(); 
+    FillContextL(view, *context);
+
+	_LIT( KSQLGetTag, "select * from tagtable where ruleid=");
+	_LIT( KSQLAnd," and contextid=");
+	iSQLStatement = KSQLGetTag;
+	iSQLStatement.AppendNumUC( aGrammarIdRuleId.iRuleId );
+    iSQLStatement.Append( KSQLAnd );
+	iSQLStatement.AppendNumUC( context->ContextId() );
+
+    // Close view
+    CleanupStack::PopAndDestroy( &view );
+
+    CArrayPtrFlat<CNssTag>* res = GetTagListByQueryL( iSQLStatement );
+
+    // Pop rollback cleanup item
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+    
+    CleanupStack::PopAndDestroy( context );
+
+    return( res );
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagsL
+// Gets a list of tags by grammar ID and rule ID.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagsL( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds )
+	{
+	CNssContext* context = iContextBuilder.CreateContextL();
+	CleanupStack::PushL( context );
+	RDbView view;
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    Mem::FillZ( context,     sizeof(*context)   );
+
+	CleanupClosePushL(view);
+	
+	_LIT( KSQLGetContext, "select * from contexttable where ");
+	_LIT( KGrammarIdParam, "grammarid=" );
+	_LIT( KOr, " OR ");
+	iSQLStatement.Copy(KSQLGetContext);
+	
+	for( TInt i = 0; i < aGrammarIdRuleIds.Count(); i++)
+		{
+		if( i !=0 )
+			{
+			iSQLStatement.Append(KOr);
+			}
+		iSQLStatement.Append(KGrammarIdParam);
+		iSQLStatement.AppendNumUC(aGrammarIdRuleIds[i].iGrammarId);
+		// same grammar ids usually appear, but that's ok and should not decrease performance
+		}
+		
+	TDbQuery dbQuery(iSQLStatement, EDbCompareNormal);
+	User::LeaveIfError( view.Prepare( iDatabase, dbQuery ));
+	User::LeaveIfError( view.EvaluateAll());
+	
+	_LIT( KSQLGetTags, "select * from tagtable where (");
+	_LIT( KRuleId, "ruleid=");
+	_LIT( KContextId,"contextid=");
+	_LIT( KBracketAnd, " AND (");
+	_LIT( KBracketOr, ") OR (");
+	_LIT( KFinalBracket, ")");
+	
+	// Get column set
+    CDbColSet* columns = view.ColSetL();
+	TDbColNo contextid_col= columns->ColNo( KContextIdCol );
+	TDbColNo grammarid_col= columns->ColNo( KGrammarIdCol );
+	delete columns;
+	TUint32 currContextId;
+	TUint32 currGrammarId;
+	TUint32 currRuleId;
+	
+	iSQLStatement = KSQLGetTags;
+	TBool firstPair = ETrue;
+	while( view.NextL())
+		{
+		view.GetL();
+		// before each iteration, but first, we add ") OR ("
+		if( firstPair )
+			{
+			firstPair = EFalse;
+			}
+		else 
+			{
+			iSQLStatement.Append(KBracketOr);
+			}
+		currContextId = view.ColUint32( contextid_col );
+		currGrammarId = view.ColUint32( grammarid_col );
+		iSQLStatement.Append( KContextId );
+		iSQLStatement.AppendNumUC( currContextId );
+		iSQLStatement.Append( KBracketAnd );
+		// we need to find corresponding rule id
+		TBool someGrammarFoundAlready = EFalse;
+		for( TInt i=0; i<aGrammarIdRuleIds.Count(); i++)
+			{
+			if( currGrammarId == aGrammarIdRuleIds[i].iGrammarId )
+				{
+				if( someGrammarFoundAlready )
+					{
+					iSQLStatement.Append( KOr );
+					}
+				else 
+					{
+					someGrammarFoundAlready = ETrue;
+					}
+				currRuleId = aGrammarIdRuleIds[i].iRuleId;
+				iSQLStatement.Append( KRuleId );
+				iSQLStatement.AppendNumUC( currRuleId );	
+				}
+			}  // for
+		iSQLStatement.Append(KFinalBracket);  // closing ruleid ORs
+		}  // while
+	// Close view
+    CleanupStack::PopAndDestroy( &view );
+    iSQLStatement.Append( KFinalBracket );
+    
+    CArrayPtrFlat<CNssTag>* res = GetTagListByQueryL( iSQLStatement );
+
+    // Pop rollback cleanup item
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+
+    CleanupStack::PopAndDestroy( context );
+
+    return( res );
+	}
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagListByQuery
+// Executes the query and reads matches from DB to memory.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagListByQuery
+// Executes the query and reads matches from DB to memory.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagListByQueryL( const TDesC& aSqlQuery )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::GetTagListByQueryL" );
+
+    __ASSERT_DEBUG( aSqlQuery.Left(6).Compare( _L("select") ) == 0, User::Panic( KVasDbPanic, __LINE__ ) );
+
+	CNssContext* context = NULL;
+	CNssSpeechItem* speechItem = NULL;
+	CNssRRD* rrd = NULL;
+    TInt contextId = -1;
+
+    // 'context' variable is the context of the previous tag.
+    // When a new tag is read, 'context' is updated only if context changes.
+    // Set the ID invalid value in order to force the first tag to read a context.
+    //context.iContextId = (TUint32)-1;
+    //context->SetContextId( -1 );
+
+	RDbView view;
+	CleanupClosePushL( view );
+
+    CArrayPtrFlat<CNssTag>* tagList = new(ELeave)CArrayPtrFlat<CNssTag>( KMaxTagArraySize );
+    CleanupStack::PushL( tagList );
+    CleanupResetAndDestroyPushL( *tagList );
+
+	User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( aSqlQuery, EDbCompareNormal ) ) );
+	User::LeaveIfError( view.EvaluateAll() );
+
+	if ( !view.IsEmptyL() )
+	    {
+   	    for (view.FirstL(); view.AtRow(); view.NextL())
+	        {
+	        context = iContextBuilder.CreateContextL();
+	        CleanupStack::PushL( context );
+	        
+	        speechItem = iSpeechItemBuilder.CreateEmptySpeechItemL( *context );
+	        CleanupStack::PushL( speechItem );
+	        
+            FillSpeechItemL( view, *speechItem, contextId );
+
+            // Get context, if we haven't already done it.
+            if ( context->ContextId() != (TUint32)contextId )
+                {                
+                _LIT( KContextQuery, "select * from contexttable where contextid=" );
+
+                iSQLStatement.Copy( KContextQuery );
+                iSQLStatement.AppendNumUC( contextId );
+
+                CArrayPtrFlat<CNssContext>* contextList = 
+                            GetContextInsideTransactionL( iSQLStatement );
+                CleanupStack::PushL( contextList );
+
+                User::LeaveIfNull( contextList );
+
+                if ( contextList->Count() != 1 )
+                    {
+                    User::Leave( KErrCorrupt );
+                    }
+
+                CleanupStack::Pop( contextList );
+                CleanupStack::PopAndDestroy( speechItem );                
+                CleanupStack::PopAndDestroy( context );
+                
+                context = (*contextList)[0];                
+                delete contextList;
+                
+                CleanupStack::PushL( context );
+                
+	            speechItem = iSpeechItemBuilder.CreateEmptySpeechItemL( *context );
+	            CleanupStack::PushL( speechItem );
+	        	        
+                FillSpeechItemL( view, *speechItem, contextId );
+                }
+                
+            rrd = CNssRRD::NewL();
+            CleanupStack::PushL( rrd );
+            
+            FillRRDL( speechItem->TagId(), *rrd );
+            
+            // Append tag to the array 
+            FillTagListArrayL( *tagList, context, speechItem, rrd );
+            CleanupStack::PopAndDestroy( rrd );
+            CleanupStack::PopAndDestroy( speechItem );
+            CleanupStack::PopAndDestroy( context );
+            }
+        }
+	else
+	    {
+        User::Leave( KErrNotFound );
+	    }
+
+	CleanupStack::Pop( tagList );  // ResetAndDestroy
+    CleanupStack::Pop( tagList );  // array itself
+	// Finished with the view - so close it.
+    CleanupStack::PopAndDestroy( &view );
+
+    return tagList;
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagL
+// Gets a tag by name.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagL(const TDesC& aName)
+    {
+    _LIT( KTick,"' ");
+	_LIT( KSQLGetTag, "select * from tagtable where name='");
+	
+	iSQLStatement = KSQLGetTag;
+	iSQLStatement.Append( aName );
+    iSQLStatement.Append( KTick );
+
+    User::LeaveIfError( StartTransaction() );
+
+    CArrayPtrFlat<CNssTag>* arr = GetTagListByQueryL( iSQLStatement );
+
+    CommitTransaction( EFalse );
+
+    return arr;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagL
+// Gets all tags from a specified context.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagL( const CNssContext& aContext)
+    {
+    RDbView view;
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    CleanupClosePushL( view );
+
+	// Validate the context
+    _LIT( KSQLGetContext, "select * from contexttable where contextid=");
+	iSQLStatement = KSQLGetContext;
+	iSQLStatement.AppendNumUC( aContext.ContextId() );
+
+	User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view.EvaluateAll() );
+
+    if ( view.IsEmptyL() )
+	    {
+        User::Leave( KErrNotFound );
+	    }
+
+	// Finished with the view - so close it.
+    CleanupStack::PopAndDestroy( &view );
+	
+	_LIT( KSQLGetTag, "select * from tagtable where contextid=" );
+	iSQLStatement.Copy( KSQLGetTag );
+	iSQLStatement.AppendNumUC( aContext.ContextId() );
+
+    CArrayPtrFlat<CNssTag>* result = GetTagListByQueryL( iSQLStatement );
+
+    // Transaction finished - free the transaction lock
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::GetTagListFromViewL
+// Reads the tags from DB to memory and appends them to the array.
+// Earlier, the caller has made an SQL query and placed the matches in RDbView.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::GetTagListFromViewL( RDbView& aView, CArrayPtrFlat<CNssTag>* aTagList, 
+                                     CNssContext* aContext )
+    {
+    TInt discardable( 0 );
+
+	for ( aView.FirstL(); aView.AtRow(); aView.NextL() )
+    	{
+    	CNssSpeechItem* speechItem = iSpeechItemBuilder.CreateEmptySpeechItemL( *aContext );
+    	CleanupStack::PushL( speechItem );
+    	
+	    FillSpeechItemL( aView, *speechItem, discardable );
+		CNssRRD* rrd = CNssRRD::NewL();
+		CleanupStack::PushL( rrd );
+		FillRRDL( speechItem->TagId(), *rrd );
+		    
+		FillTagListArrayL( *aTagList, aContext, speechItem, rrd );
+		
+		CleanupStack::PopAndDestroy( rrd );
+		CleanupStack::PopAndDestroy( speechItem );
+	    }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteTagL
+// Gets a list of tags by RRD data.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagL( TInt aContextId, TInt aNum, TInt aPosition )
+    {
+  	RDbView     view;
+	TUint32     tagId;
+	CNssContext* context = iContextBuilder.CreateContextL();
+	CleanupStack::PushL( context );
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    CArrayPtrFlat<CNssTag>* tagArray = new(ELeave)CArrayPtrFlat<CNssTag>(1);
+    CleanupStack::PushL( tagArray );
+    CleanupResetAndDestroyPushL( *tagArray );
+
+    // Get the context based on ContextId
+  	CleanupClosePushL(view);
+
+	_LIT( KSQLGetContext, "select * from contexttable where contextid=" );
+	iSQLStatement.Copy( KSQLGetContext );
+	iSQLStatement.AppendNumUC( aContextId );
+
+	User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view.EvaluateAll() );
+	view.FirstL();
+    view.GetL();
+	TRAPD( error, FillContextL( view, *context ) );
+	// Finished with the view - so close it.
+	view.Close();
+	CleanupStack::PopAndDestroy( &view );
+
+    // If filling of the context failed, return with Not Found
+	if ( error != KErrNone )
+	    {
+        User::Leave( KErrNotFound );
+        }
+
+    // Get the list of TagId from the RRD table based on Num and Position
+	RDbView view1;
+	CleanupClosePushL( view1 );
+
+	_LIT( KSQLGetRRDInt, "select * from rrdinttable where rrdposition=" );
+	_LIT( KSQLAndRRDInt, " and rrdint=" );
+	iSQLStatement = KSQLGetRRDInt;
+	iSQLStatement.AppendNumUC( aPosition );
+	iSQLStatement.Append( KSQLAndRRDInt );
+	iSQLStatement.AppendNumUC( aNum );
+
+	User::LeaveIfError( view1.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view1.EvaluateAll() );
+	
+	if ( view1.IsEmptyL() )
+	    {
+
+        User::Leave( KErrNotFound );
+	    }
+
+    // Get column set
+    CDbColSet* columns = view1.ColSetL();
+    // Get column ordinals
+    TDbColNo tagid_col= columns->ColNo( KTagIdCol );
+    // Cleanup column set
+    delete columns;
+
+    // Select the valid tagId from the list
+	for ( view1.FirstL(); view1.AtRow(); view1.NextL() )
+        {   
+        view1.GetL();
+        tagId = view1.ColUint32( tagid_col );
+
+        // Get the SpeechItem based on the tagId and ContextId
+        RDbView view2;
+		CleanupClosePushL( view2 );
+
+        _LIT( KSQLGetSpeechItem, "select * from tagtable where tagid=" );
+        _LIT( KSQLAndContextId," and contextid=" );
+        iSQLStatement = KSQLGetSpeechItem;
+        iSQLStatement.AppendNumUC( tagId );
+	    iSQLStatement.Append( KSQLAndContextId );
+        iSQLStatement.AppendNumUC( aContextId );
+
+        User::LeaveIfError( view2.Prepare( iDatabase, 
+                            TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+        User::LeaveIfError( view2.EvaluateAll() );
+    
+        if ( !view2.IsEmptyL() )
+	        {
+            GetTagListFromViewL( view2, tagArray, context );
+		    }
+        view2.Close();
+        CleanupStack::PopAndDestroy( &view2 );
+        }
+
+    // close the view 1
+	view1.Close();
+	CleanupStack::PopAndDestroy( &view1 );
+
+    CleanupStack::Pop( tagArray );  // ResetAndDestroy
+    CleanupStack::Pop( tagArray );  // array itself
+
+    // Rollback cleanup
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+    
+    CleanupStack::PopAndDestroy( context );
+
+    return tagArray;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteTagL
+// Gets a list of tags by RRD data.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagL( TInt aContextId, 
+                                            const TDesC& aText, TInt aPosition )
+    {
+  	RDbView view;
+	TUint32 tagId;
+	CNssContext* context = iContextBuilder.CreateContextL();
+	CleanupStack::PushL( context );
+	
+    CArrayPtrFlat<CNssTag>* tagArray = new(ELeave)CArrayPtrFlat<CNssTag>(1);
+    CleanupStack::PushL( tagArray );
+    CleanupResetAndDestroyPushL( *tagArray );
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    // Get the context based on ContextId
+  	CleanupClosePushL( view );
+
+	_LIT( KSQLGetContext, "select * from contexttable where contextid=" );
+	iSQLStatement.Copy( KSQLGetContext );
+	iSQLStatement.AppendNumUC( aContextId );
+
+	User::LeaveIfError( view.Prepare(iDatabase, TDbQuery(iSQLStatement, EDbCompareNormal)));
+	User::LeaveIfError( view.EvaluateAll());
+	view.FirstL();
+    view.GetL();
+	TRAPD( error, FillContextL( view, *context ) );
+	// Finished with the view - so close it.
+	view.Close();
+	CleanupStack::PopAndDestroy( &view );
+
+    // If filling of the context failed, return with Not Found
+	if ( error != KErrNone )
+	    {
+        User::Leave( KErrNotFound );
+        }
+
+    // Get the list of TagId from the RRD table based on text and Position
+	RDbView view1;
+	CleanupClosePushL( view1 );
+
+	_LIT( KSQLGetRRDText, "select * from rrdtexttable where rrdposition=" );
+	_LIT( KSQLAndRRDText, " and rrdtext='" );
+	_LIT( KSQLTick, "'" );
+
+	iSQLStatement = KSQLGetRRDText;
+	iSQLStatement.AppendNumUC( aPosition );
+	iSQLStatement.Append( KSQLAndRRDText );
+	iSQLStatement.Append( aText );
+    iSQLStatement.Append( KSQLTick );
+
+	User::LeaveIfError( view1.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view1.EvaluateAll() );
+	
+	if ( view1.IsEmptyL() )
+	    {
+        User::Leave( KErrNotFound );
+	    }
+
+    // Get column set
+    CDbColSet* columns = view1.ColSetL();
+    // Get column ordinals
+    TDbColNo tagid_col= columns->ColNo( KTagIdCol );
+    // Cleanup column set
+    delete columns;
+
+    // Select the valid tagId from the list
+	for ( view1.FirstL(); view1.AtRow(); view1.NextL() )
+	    {
+        view1.GetL();
+        tagId = view1.ColUint32( tagid_col );
+
+        // Get the SpeechItem based on the tagId and ContextId
+        RDbView view2;
+		CleanupClosePushL( view2 );
+
+        _LIT( KSQLGetSpeechItem, "select * from tagtable where tagid=" );
+        _LIT( KSQLAndContextId, " and contextid=" );
+        iSQLStatement = KSQLGetSpeechItem;
+        iSQLStatement.AppendNumUC( tagId );
+	    iSQLStatement.Append( KSQLAndContextId );
+        iSQLStatement.AppendNumUC( aContextId );
+
+        User::LeaveIfError( view2.Prepare( iDatabase, 
+                            TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+        User::LeaveIfError( view2.EvaluateAll() );
+
+        if ( !view2.IsEmptyL() )
+	        {
+            GetTagListFromViewL( view2, tagArray, context );
+		    }
+        CleanupStack::PopAndDestroy( &view2 );
+        }
+    // close the view 1
+	CleanupStack::PopAndDestroy( &view1 );
+
+    // Roll back transaction
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+
+    CleanupStack::Pop( tagArray );  // ResetAndDestroyPushL
+    CleanupStack::Pop( tagArray );  // array itself
+    CleanupStack::PopAndDestroy( context );
+
+    return tagArray;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteTagL
+// Get a tag by ID.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssTag>* CNssVasDb::GetTagL( TUint32 aTagId )
+    {
+	RDbView view;
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    CleanupClosePushL( view );
+
+
+	_LIT( KSQLGetTag, "select * from tagtable where tagid=");
+
+	iSQLStatement = KSQLGetTag;
+	iSQLStatement.AppendNumUC( aTagId );
+
+    CArrayPtrFlat<CNssTag>* result = GetTagListByQueryL( iSQLStatement );
+
+    // Close view
+    CleanupStack::PopAndDestroy( &view );
+
+    // Roll back transaction
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( EFalse );
+
+    return( result );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteTagL
+// Deletes a tag by name
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DeleteTagL( const TDesC& aName )
+    {
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    TUint32 tagId;
+    RDbView view;
+	
+    CleanupClosePushL(view);
+
+    _LIT( KTick,"' ");
+    _LIT( KSQLGetTag, "select * from tagtable where name='");
+	
+    iSQLStatement = KSQLGetTag;
+    iSQLStatement.Append( aName );
+    iSQLStatement.Append( KTick );
+
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery(iSQLStatement, EDbCompareNormal)));
+    User::LeaveIfError( view.EvaluateAll());
+
+    // Get column set
+    CDbColSet* columns = view.ColSetL();
+    // Get column ordinals
+    TDbColNo tagid_col= columns->ColNo( KTagIdCol );
+    // Cleanup column set
+    delete columns;
+
+    view.FirstL();
+    view.GetL();
+    tagId = view.ColUint32( tagid_col );
+
+    // Close view
+    CleanupStack::PopAndDestroy( &view );
+
+    // Pop rollback item and do commit
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( ETrue );
+
+    DeleteTagL( tagId );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteTagL
+// Deletes a tag by ID
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DeleteTagL( TUint32 aTagId )
+    {
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "CNssVasDb error: database not opened." );
+        
+        User::Leave( KErrNotReady );
+        }
+   
+    // Lock database
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+
+    DeleteTagInsideTransactionL( aTagId );
+
+    // Commit transaction - unlock databaes
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( ETrue );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteTagInsideTransactionL
+// Deletes the RRD information of a tag.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DeleteTagInsideTransactionL( TUint32 aTagId )
+    {
+    TInt error( KErrNone );
+
+    _LIT( KSQLDeleteTag, "delete from tagtable where tagid=");
+
+	ReserveDiskSpaceL( sizeof(CNssTag) );
+
+    iSQLStatement = KSQLDeleteTag;
+    iSQLStatement.AppendNumUC(aTagId);
+
+    error = iDatabase.Execute( iSQLStatement );
+    if ( error < KErrNone )
+        {
+        ReleaseDiskSpace();
+        User::Leave( error );
+        }
+
+    TRAP( error, DeleteRRDL( aTagId ) );
+    
+    ReleaseDiskSpace();
+    
+    User::LeaveIfError( error );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteRRDL
+// Deletes the RRD information of a tag.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DeleteRRDL(TUint32 aTagId)
+    {
+    TInt error( KErrNone );
+    
+    _LIT( KSQLAddRRDText, "delete from rrdtexttable ");
+    _LIT( KSQLAddRRDId,   "delete from rrdinttable ");
+    _LIT( KSQLWhereTagId,"where tagid=");
+
+    iSQLStatement = KSQLAddRRDId;
+    iSQLStatement.Append( KSQLWhereTagId );
+    iSQLStatement.AppendNumUC( aTagId );
+	
+    error = iDatabase.Execute( iSQLStatement );
+   
+    if ( error < KErrNone && error != KErrNotFound )
+        {
+        User::Leave( error );
+        }
+
+    iSQLStatement = KSQLAddRRDText;
+    iSQLStatement.Append( KSQLWhereTagId );
+    iSQLStatement.AppendNumUC( aTagId );
+
+    error = iDatabase.Execute( iSQLStatement );
+
+    if ( error < KErrNone && error != KErrNotFound )
+        {
+        User::Leave( error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DeleteContextL
+// Deletes a context.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DeleteContextL( const TDesC& aName )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::DeleteContextL" );
+    
+    TInt error( KErrNone );
+    TUint32 contextId;
+    TUint32 tagId;
+    RDbView view1,view2;
+    
+    // Begin transaction
+    User::LeaveIfError( StartTransaction() );
+    CreatePushRollbackItemLC();
+    
+    CleanupClosePushL( view1 );
+    
+    // Search the context from DB
+    _LIT( KTick, "' " );
+    _LIT( KSQLGetContext, "select * from contexttable where name='" );
+    
+    iSQLStatement = KSQLGetContext;
+    iSQLStatement.Append( aName );
+    iSQLStatement.Append( KTick );
+    
+    User::LeaveIfError( view1.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+    User::LeaveIfError( view1.EvaluateAll() );
+    
+    // Get column set
+    CDbColSet* columns1 = view1.ColSetL();
+    // Get column ordinals
+    TDbColNo contextid_col= columns1->ColNo( KContextIdCol );
+    // Cleanup column set
+    delete columns1;
+    
+    view1.FirstL();
+    
+    // Doesn't exists, can't delete
+    if ( !view1.AtRow() )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    view1.GetL();
+    contextId = view1.ColUint32( contextid_col );
+    
+    view1.DeleteL();
+    view1.Close();	
+    CleanupStack::PopAndDestroy( &view1 );
+    
+    // Delete all tags, which were in the context.
+    _LIT( KSQLGetTag, "select * from tagtable where contextid=" );
+    
+    iSQLStatement = KSQLGetTag;
+    iSQLStatement.AppendNumUC( contextId );
+    
+    CleanupClosePushL( view2 );
+    
+    User::LeaveIfError( view2.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );
+    User::LeaveIfError( view2.EvaluateAll() );
+    
+    ReserveDiskSpaceL( (sizeof(CNssTag) * view2.CountL()) + sizeof(CNssContext) );
+    
+    view2.FirstL();
+    
+    // If this context has any tags, remove the RRD entries from the RRD table.
+    if ( view2.AtRow() )
+        {
+        // Get column set
+        CDbColSet* columns2 = view2.ColSetL();
+        
+        // Get column ordinals
+        TDbColNo tagid_col = columns2->ColNo( KTagIdCol );
+        // Cleanup column2 set
+        delete columns2;
+        
+        for ( view2.FirstL(); view2.AtRow(); view2.NextL() )
+            {
+            view2.GetL();
+            tagId = view2.ColUint32( tagid_col );
+            RUBY_DEBUG0( "CNssVasDb::DeleteContextL deleting RRD" );
+            // Return value ignored since other tag ids should be iterated through
+            // even though one RRD deletion fails
+            TRAP( error, DeleteRRDL( tagId ) );
+            }
+        
+        view2.Close();
+        }
+    
+    // Remove tags from tag table
+    _LIT( KSQLDeleteTag, "delete from tagtable where contextid=");
+    iSQLStatement = KSQLDeleteTag;
+    iSQLStatement.AppendNumUC( contextId );
+    
+    error = iDatabase.Execute( iSQLStatement );
+    
+    CleanupStack::PopAndDestroy( &view2 );
+    
+    if ( error < KErrNone && error != KErrNotFound )
+        {
+        ReleaseDiskSpace();
+        // Roll back transaction
+        CleanupStack::PopAndDestroy(); // Rollback cleanup item
+        User::Leave( error );
+        }
+   
+    CleanupStack::Pop();  // Rollback cleanup item
+    CommitTransaction( ETrue );
+   
+    ReleaseDiskSpace();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateTagInTransactionL
+// Updates a tag. Assumes that a transaction has been started earlier.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateTagInTransactionL( CNssTag& aTag )
+    {
+    CNssContext* context = static_cast<CNssContext*> ( aTag.Context() );
+    UpdateContextInsideTransactionL( *context );
+    CNssSpeechItem* speechItem = static_cast<CNssSpeechItem*>
+        ( aTag.SpeechItem() );
+    UpdateSpeechItemL( *speechItem );
+    CNssRRD* rrd = static_cast<CNssRRD*> ( aTag.RRD() );
+    UpdateRRDL( *rrd );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DoUpdateContextL
+// Updates an existing context.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DoUpdateContextL( CNssContext& aContext )
+    {
+    _LIT( KSQLUpdateContext,"update contexttable set ");
+    _LIT( KEqual,"=");
+    _LIT( KCommon,",");
+    _LIT( KTick,"'");
+    _LIT( KSQLWhereContextId," where contextid = ");
+   
+    iSQLStatement = KSQLUpdateContext;
+     
+    iSQLStatement.Append( KNameCol );
+    iSQLStatement.Append( KEqual );
+    iSQLStatement.Append( KTick );
+    iSQLStatement.Append( aContext.ContextName() );
+    iSQLStatement.Append( KTick );
+   
+    iSQLStatement.Append( KCommon );
+    iSQLStatement.Append( KGlobalCol );
+    iSQLStatement.Append( KEqual );
+    iSQLStatement.AppendNumUC( aContext.IsGlobal() );
+
+    iSQLStatement.Append( KCommon );
+    iSQLStatement.Append( KGrammarIdCol );
+    iSQLStatement.Append( KEqual );
+    iSQLStatement.AppendNumUC( aContext.GrammarId() );
+
+    iSQLStatement.Append( KCommon );
+    iSQLStatement.Append( KLexiconIdCol );
+    iSQLStatement.Append( KEqual );
+    iSQLStatement.AppendNumUC( aContext.LexiconId() );
+
+    iSQLStatement.Append( KCommon );
+    iSQLStatement.Append( KModelBankIdCol );
+    iSQLStatement.Append( KEqual );
+    iSQLStatement.AppendNumUC( aContext.ModelBankId() );
+
+    iSQLStatement.Append( KSQLWhereContextId );
+    iSQLStatement.AppendNumUC( aContext.ContextId() );
+ 
+    User::LeaveIfError( iDatabase.Execute( iSQLStatement ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::DoUpdateUpdateContextClientDataL
+// Updates the client data of a context.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::DoUpdateContextClientDataL( CNssContext& aContext )
+    {
+	__UHEAP_MARK;
+
+	// Declare a literal string to hold the SQL statement
+	// SELECT KBinaryLexiconColumn , KBinaryLexiconColumn FROM  KLexiconName
+
+	_LIT( KSQLSelect1, "select clientdata from contexttable where name='" );
+
+	TBuf<KSqlStatementmaxLength> sqlStatement;
+	sqlStatement.Append( KSQLSelect1 );
+    sqlStatement.Append( aContext.ContextName() );
+    sqlStatement.Append( '\'' );
+
+	// create a view on the database
+	RDbView view;
+    CleanupClosePushL( view ); // Stack: view
+
+	User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( sqlStatement, EDbCompareNormal ) ) );
+	User::LeaveIfError( view.EvaluateAll() );
+
+	// Get the structure of rowset
+	CDbColSet* colSet = view.ColSetL();
+    CleanupStack::PushL( colSet ); // Stack: view, colset
+    TInt error( KErrNone );
+	
+	if( view.FirstL() )
+		{
+		view.UpdateL();
+
+    
+		// add binary buffer by Using the stream  
+
+		//RDbColWriteStream out;
+		TDbColNo col = colSet->ColNo( _L("clientdata") ); // Ordinal position of client data
+
+    	if ( col == KDbNullColNo )
+        	{
+        	User::Leave( KErrCorrupt );
+        	}
+
+    	view.SetColL( col, aContext.ClientData() ); 
+	
+		view.PutL();
+	
+		// close the view
+    	view.Close();
+		}
+	else 
+		{
+		error = KErrNotFound;
+		}
+    
+    CleanupStack::PopAndDestroy( colSet );
+    CleanupStack::PopAndDestroy( &view );
+
+	__UHEAP_MARKEND;
+
+    User::LeaveIfError( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateRRDL
+// Updates an existing RRD.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateRRDL( CNssRRD& aRRD )
+    {
+    TRAPD( error, DeleteRRDL( aRRD.TagId() ) );
+
+    if ( error != KErrNotFound)
+        {
+        error = KErrNone;
+        }
+
+    User::LeaveIfError( error );
+
+    SaveRRDL( &aRRD );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UpdateSpeechItemL
+// Updates an existing speech item.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UpdateSpeechItemL( CNssSpeechItem& aSpeechItem )
+    {
+    RDbView view;
+    CleanupClosePushL( view );
+ 
+    _LIT( KSQLGet, "select * from tagtable where tagid=" );
+    
+    iSQLStatement = KSQLGet;
+    iSQLStatement.AppendNumUC( aSpeechItem.TagId() );
+
+    User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( iSQLStatement, EDbCompareNormal ) ) );	
+    User::LeaveIfError( view.EvaluateAll());
+    
+    // Get column set
+    CDbColSet* columns = view.ColSetL();
+    // Get column ordinals
+    TDbColNo name_col= columns->ColNo( KNameCol );
+
+    delete columns;
+	  
+    if ( view.FirstL() )
+        {
+        // Begin process of updating a row...
+        view.UpdateL();
+        // set column values...
+#ifdef __SIND_EXTENSIONS        
+        view.SetColL( name_col, aSpeechItem.RawText() ); 
+#else
+        view.SetColL( name_col, aSpeechItem.Text() ); 
+#endif
+
+        // add the row to the table...
+        view.PutL();
+		
+        // finished - so close the view
+        view.Close();
+		}
+    else 
+        {
+        User::Leave( KErrNotFound );
+        }	
+	
+    CleanupStack::PopAndDestroy( &view );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::FillSpeechItemL
+// Reads a TNssSpeechItem from DB to memory. Earlier, the caller has run an SQL
+// query and specifies the matching context in RDbView.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::FillSpeechItemL( RDbView& aView, CNssSpeechItem& aSpeechItem, TInt& aContextId )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::FillSpeechItemL" );
+
+	if ( aView.IsEmptyL() )
+	    {
+		User::Leave( KErrNotFound );
+	    }
+
+	// Get column set
+    CDbColSet* columns = aView.ColSetL();
+    // Get column ordinals
+ 	TDbColNo tagid_col    = columns->ColNo( KTagIdCol );
+ 	TDbColNo contextid_col= columns->ColNo( KContextIdCol );
+	TDbColNo ruleid_col   = columns->ColNo( KRuleIdCol );
+	TDbColNo name_col     = columns->ColNo( KNameCol );
+
+    // Cleanup column set
+    delete columns;
+
+	// Retrieve the current row
+	aView.GetL();
+	aSpeechItem.SetTagId( aView.ColUint32( tagid_col ) );
+	aSpeechItem.SetRuleID( aView.ColUint32( ruleid_col ) );
+	aSpeechItem.SetTextL( aView.ColDes( name_col ) );
+    aContextId = aView.ColUint32( contextid_col );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::FillContextL
+// Reads a context from DB to memory. Earlier, the caller has run an SQL query
+// and specifies the matching context in RDbView.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::FillContextL( RDbView& aView, CNssContext& aContext )
+    {
+    if ( aView.IsEmptyL() )
+	    {
+	    User::Leave( KErrNotFound );
+	    }
+
+	// Get column set
+    CDbColSet* columns = aView.ColSetL();
+    // Get column ordinals
+ 	TDbColNo contextid_col= columns->ColNo( KContextIdCol );
+	TDbColNo name_col = columns->ColNo( KNameCol );
+    TDbColNo global_col = columns->ColNo( KGlobalCol );
+	TDbColNo grammarid_col= columns->ColNo( KGrammarIdCol );
+	TDbColNo lexiconid_col= columns->ColNo( KLexiconIdCol );
+	TDbColNo modelbankid_col= columns->ColNo( KModelBankIdCol );
+    // Cleanup column set
+    delete columns;
+
+	// Retrieve the current row
+	aView.GetL();
+	aContext.SetContextId( aView.ColUint32( contextid_col ) );
+	aContext.SetGlobal( aView.ColUint32( global_col ) );
+	aContext.SetGrammarId( aView.ColUint32( grammarid_col ) );
+	aContext.SetLexiconId( aView.ColUint32( lexiconid_col ) );
+	aContext.SetModelBankId( aView.ColUint32( modelbankid_col ) );
+	aContext.SetNameL( aView.ColDes( name_col ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::FillTagListArrayL
+// Creates a TNssTag from context, speech item and RRD information.
+// Adds a tag to aTagList.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::FillTagListArrayL( CArrayPtrFlat<CNssTag>& aTagList, CNssContext* aContext, 
+                                   CNssSpeechItem* aSpeechItem, CNssRRD* aRRD )
+    {    
+    CNssContext* contextCopy = aContext->CopyL();
+    CNssSpeechItem* speechItenCopy = aSpeechItem->CopyL( contextCopy );
+    CNssRRD* rrdCopy = aRRD->CopyL();
+    CNssTag* tag = new (ELeave) CNssTag( contextCopy, rrdCopy, speechItenCopy );
+    tag->SetTagId( aSpeechItem->TagId() );
+	
+	aTagList.AppendL( tag );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::FillContextListArrayL
+// Utility function to read contexts from DB to memory. Earlier, the caller has
+// run an SQL query and the matches are listed in an RDbView.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::FillContextListArrayL( RDbView& aView, CArrayPtrFlat<CNssContext>& aContextList )
+    {
+    RUBY_DEBUG_BLOCK("CNssVasDb::FillContextListArrayL");
+	TInt pos( 0 );
+
+	// Clear the previous array.
+	aContextList.Reset();
+
+    // Get column set
+    CDbColSet* columns = aView.ColSetL();
+
+    // Get column ordinals
+    TDbColNo name_col       = columns->ColNo( KNameCol );
+    TDbColNo global_col     = columns->ColNo( KGlobalCol );
+	TDbColNo grammarid_col  = columns->ColNo( KGrammarIdCol );
+	TDbColNo lexiconid_col  = columns->ColNo( KLexiconIdCol );
+	TDbColNo modelbankid_col= columns->ColNo( KModelBankIdCol );
+	TDbColNo contextid_col  = columns->ColNo( KContextIdCol );
+
+    // New in 2.8
+    TDbColNo clientdata_col = columns->ColNo( KClientDataCol );
+
+	delete columns;
+
+	for (aView.FirstL(); aView.AtRow(); aView.NextL())
+	    {
+	    aView.GetL(); // Retrieve the current row - actually reads the row from the database.
+       
+        CNssContext* oneContext = iContextBuilder.CreateContextL();
+        CleanupStack::PushL( oneContext );
+       
+        oneContext->SetNameL( aView.ColDes( name_col ) );
+        oneContext->SetGlobal( aView.ColUint32( global_col ) );
+        oneContext->SetContextId( aView.ColUint32( contextid_col ) );
+        oneContext->SetLexiconId( aView.ColUint32( lexiconid_col ) );
+        oneContext->SetGrammarId( aView.ColUint32( grammarid_col ) );
+        oneContext->SetModelBankId( aView.ColUint32( modelbankid_col ) );
+        oneContext->SetClientData( aView.ColDes8( clientdata_col ) );
+       
+	    // Now add the context object to the list (array) of context.
+	    aContextList.InsertL( pos++, oneContext );
+	   
+	    // Copy has been created in aContextList, no need for pointer anymore
+	    CleanupStack::Pop( oneContext );
+	    }
+}
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::StartTransactionL
+// Starts a new transaction.
+// -----------------------------------------------------------------------------
+//
+TInt CNssVasDb::StartTransaction()
+    {
+    RUBY_DEBUG0( "CNssVasDb::StartTransaction" );
+    
+    if ( !iClientHasOpenedDatabase )
+        {
+        RUBY_DEBUG0( "No open DB. E.g. backup/restore in progress" );
+        return KErrNotReady;
+        }
+
+    __ASSERT_DEBUG( iLocked == iDatabase.InTransaction(), User::Panic( KVasDbPanic, __LINE__ ) );
+    
+    iCriticalSection.Wait();
+    if ( iLocked )
+        {
+        // If we already have the lock, no need to take it again
+        RUBY_DEBUG0( "CNssVasDb::StartTransaction DB is already locked by current process" );
+        return KErrNone;
+        }
+
+    // Wait for the mutex so that two processes don't try get the lock simultaneously
+    RUBY_DEBUG0( "Waiting for mutex in CNssVasDb::StartTransaction" );
+    iMutex.Wait();
+    
+    // check if backup is ongoing
+	    
+    TInt readLockErr = iDatabase.Begin();
+
+    // Mutex should make it sure that we have exclusive lock to Database
+    // Thus iDatabase.Begin() should succeed every time
+    __ASSERT_DEBUG( readLockErr == KErrNone, User::Panic( KVasDbPanic, __LINE__ ) );
+   
+    if ( readLockErr == KErrNone )
+        {
+        iLocked = ETrue;
+        }
+
+    RUBY_DEBUG0( "CNssVasDb::StartTransaction completed" );        
+        
+    return readLockErr;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::CommitTransaction
+// Commits changes and releases the lock. If iShouldBeLocked flag is set,
+// opens a new tranaction in order to keep the database locked.
+// -----------------------------------------------------------------------------
+//
+TInt CNssVasDb::CommitTransaction( TBool aCompact )
+    {
+    RUBY_DEBUG0( "CNssVasDb::CommitTransaction" );
+
+    __ASSERT_DEBUG( iLocked == iDatabase.InTransaction(), User::Panic( KVasDbPanic, __LINE__ ) );
+    //__ASSERT_DEBUG( iLocked, User::Panic( _L("VasCNssVasDb.cpp"), __LINE__ ) );
+
+    TInt ret = KErrNone;
+
+    if ( iLocked )
+        {
+        ret = iDatabase.Commit();
+        
+        if ( iDatabase.IsDamaged() )
+            {
+            RUBY_DEBUG0( "CNssVasDb::CommitTransaction Recovering" );
+            ret = iDatabase.Recover();
+            }
+        
+        if ( aCompact )
+            {
+            RUBY_DEBUG0( "CNssVasDb::CommitTransaction compacting DB" );
+            iDatabase.Compact(); 
+            }
+        
+        iLocked = EFalse;
+        
+        RUBY_DEBUG0( "Signalling mutex in CNssVasDb::CommitTransaction" );
+        iMutex.Signal();
+        }
+    else
+        {
+        RUBY_DEBUG0( "ERROR: CNssVasDb::CommitTransaction does nothing, not locked" );
+        }
+        
+    iCriticalSection.Signal();
+    return( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::RollbackTransaction
+// Discards changes and releases the lock.
+// -----------------------------------------------------------------------------
+//
+TInt CNssVasDb::RollbackTransaction()
+    {
+    __ASSERT_DEBUG( iLocked == iDatabase.InTransaction(), User::Panic( KVasDbPanic, __LINE__ ) );
+    __ASSERT_DEBUG( iLocked, User::Panic( KVasDbPanic, __LINE__ ) );
+
+    TInt ret = KErrNone;
+
+    iDatabase.Rollback();
+    
+    iLocked = EFalse;
+    
+    if ( iDatabase.IsDamaged() )
+        {
+        RUBY_DEBUG0( "CNssVasDb::RollbackTransaction Recovering" );
+        ret = iDatabase.Recover();
+        }
+
+
+    RUBY_DEBUG0( "Signalling mutex in CNssVasDb::RollbackTransaction" );
+    iMutex.Signal();
+    iCriticalSection.Signal();
+    
+    return( ret );
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::LockTransactionsL
+// Permit transactions and release database
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::LockTransactionsL()
+    {
+    // lock transactions
+    RUBY_DEBUG_BLOCK( "CNssVasDb::LockTransactionsL" );
+    
+    iCriticalSection.Wait(); // wait until a possible transaction ends
+            
+    // release a database
+    CloseDatabase();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::UnlockTransactionsL
+// Allow transactions and reserve database
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::UnlockTransactionsL()
+    {
+    // unlock transactions
+    RUBY_DEBUG_BLOCK( "CNssVasDb::UnlockTransactionsL" );
+    OpenDatabaseL(); // open database
+    
+    if ( iCriticalSection.IsBlocked() )
+        {        
+        iCriticalSection.Signal(); // allow to do transactions
+        }
+    }
+    	
+// -----------------------------------------------------------------------------
+// CNssVasDb::ReserveDiskSpaceL(
+// Reserves disk space. Leaves (KErrDiskFull), if not
+// enough space.
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::ReserveDiskSpaceL( TInt aRequestSize )
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasDb::ReserveDiskSpaceL" );
+
+#ifdef _DEBUG
+    TInt error = iDbSession.ReserveDriveSpace( iDrive, aRequestSize );
+    if ( error )
+        {
+        RUBY_DEBUG1( "CNssVasDb::ReserveDiskSpaceL fails %d", error );
+        User::Leave( error );
+        }
+#else
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, aRequestSize ) );
+#endif // _DEBUG
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::ReleaseDiskSpace
+// Releases the disk space
+// -----------------------------------------------------------------------------
+//
+void CNssVasDb::ReleaseDiskSpace()
+    {
+    RUBY_DEBUG0( "CNssVasDb::ReleaseDiskSpace" );
+    iDbSession.FreeReservedSpace( iDrive );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVasDb::CreateRollbackItemLC
+// Creates a cleanup item and pushes it to the cleanup stack. In case of a 
+// leave, PopAndDestroying this item will call RollbackCleanupFunction
+// -----------------------------------------------------------------------------
+void CNssVasDb::CreatePushRollbackItemLC() 
+    {
+    TCleanupItem item( RollbackCleanupFunction, this );
+    CleanupStack::PushL( item );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvascvasdbbuilder.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,249 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVasDbBuilder is owned by CNssVASDBMgr. It is responsible for creating
+*               the context manaher, tag manager, vas db event notifier, and tag select 
+*               notifier. This class is a singleton, and is created using the InstanceL(),
+*               and deleted using the RemoveInstance() methods. 
+*
+*/
+
+
+#include "nssvascvasdbbuilder.h"
+#include "rubydebug.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::InstanceL
+// This function returns an instance of CNssVASDBBuilder.
+// Must be called one to one with RemoveInstance(). 
+// -----------------------------------------------------------------------------
+//
+CNssVASDBBuilder* CNssVASDBBuilder::InstanceL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVASDBBuilder::InstanceL" );
+
+	TThreadLocalStorage* pTls = 0;
+	if (Dll::Tls() == 0)
+	    {
+		CNssVASDBBuilder* instance = CNssVASDBBuilder::NewL();
+		CleanupStack::PushL(instance);
+		pTls = new (ELeave) TThreadLocalStorage ();
+		CleanupStack::Pop(instance);
+		pTls->iInstance = instance;
+		pTls->iInstanceCount = 0;
+		Dll::SetTls (pTls);
+	    }
+	else
+	    {
+		pTls = (TThreadLocalStorage *) Dll::Tls();
+	    }
+	pTls->iInstanceCount++;
+	return pTls->iInstance;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::RemoveInstance
+// This method removes one instance of this class by decrementing
+// the number of instances. When the number of instances hit 0,
+// the object is deleted. Must be called one to one with InstanceL(). 
+// -----------------------------------------------------------------------------
+//
+void CNssVASDBBuilder::RemoveInstance() 
+    {
+    RUBY_DEBUG0( "CNssVASDBBuilder::RemoveInstance" );
+
+	TThreadLocalStorage* pTls = (TThreadLocalStorage *) Dll::Tls();
+	if (--pTls->iInstanceCount <= 0)
+	    {
+		delete pTls->iInstance;
+		delete (TThreadLocalStorage *) Dll::Tls();
+		Dll::SetTls (0);
+	    }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::CNssVASDBBuilder
+// C++ constructor
+// -----------------------------------------------------------------------------
+//
+CNssVASDBBuilder::CNssVASDBBuilder()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::ConstructL
+// EPOC Constructor
+// -----------------------------------------------------------------------------
+//
+void CNssVASDBBuilder::ConstructL()
+    {
+	iVasDatabase = CNssVASDatabase::NewL(CActive::EPriorityStandard);
+	iContextMgr = CNssContextMgr::NewL(iVasDatabase);
+    iTagMgr = CNssTagMgr::NewL(iVasDatabase, iContextMgr);
+    iDBTagSelectNotifier = CNssDBTagSelectNotifier::NewL(iVasDatabase);
+    //iVASDBEventNotifier = new (ELeave) CNssVASDBEventNotifier(iVasDatabase);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::NewL
+// 2 phase Construction
+// -----------------------------------------------------------------------------
+//
+CNssVASDBBuilder* CNssVASDBBuilder::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVASDBBuilder::NewL" );
+
+	CNssVASDBBuilder* self = NewLC();
+	CleanupStack::Pop(self);
+	return (self);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::NewLC
+// 2 phase Construction
+// -----------------------------------------------------------------------------
+//
+CNssVASDBBuilder* CNssVASDBBuilder::NewLC()
+    {
+	CNssVASDBBuilder* self = new(ELeave)CNssVASDBBuilder;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return (self);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::~CNssVASDBBuilder
+// destructor
+// -----------------------------------------------------------------------------
+//
+CNssVASDBBuilder::~CNssVASDBBuilder()
+    {
+    RUBY_DEBUG0( "CNssVASDBBuilder::~CNssVASDBBuilder" );
+
+	if(iContextMgr)
+	    {
+	    delete iContextMgr;
+		iContextMgr = NULL;
+	    }
+	if(iTagMgr)
+	    {
+		delete iTagMgr;
+		iTagMgr = NULL;
+	    }
+	if(iDBTagSelectNotifier)
+	    {
+		delete iDBTagSelectNotifier;
+		iDBTagSelectNotifier = NULL;
+	    }
+	if(iVASDBEventNotifier)
+	    {
+		delete iVASDBEventNotifier;
+		iVASDBEventNotifier = NULL;
+	    }
+	if(iVasDatabase)
+	    {
+		iVasDatabase->CloseDatabase();
+		delete iVasDatabase;
+		iVasDatabase = NULL;
+	    }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::InitializeL
+// initialises CNssVASDatabase, by connecting, creating (if not created)
+// and opening the datatabase
+// -----------------------------------------------------------------------------
+//
+void CNssVASDBBuilder::InitializeL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVASDBBuilder::InitializeL" );
+    if( iInitialized )
+    	{
+    	RUBY_DEBUG0( "CNssVASDBBuilder::InitializeL Already initialized. Ignoring" );
+    	return;
+    	}
+
+    TInt err = iVasDatabase->CreateDb();
+    if ( err != KErrNone )
+        {
+        User::Leave( err ); // failed to create database
+        }
+
+	// open database 
+    err = iVasDatabase->OpenDatabase();
+    if ( err != KErrNone && err != KErrDbAlreadyOpen )
+        {
+        RUBY_DEBUG0( "CNssVASDBBuilder::InitializeL ERROR cannot open VAS DB" );
+        
+        User::Leave( err );
+        }
+    iInitialized = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::GetContextMgr
+// gets the context manager
+// -----------------------------------------------------------------------------
+//
+CNssContextMgr* CNssVASDBBuilder::GetContextMgr()
+    {
+	return iContextMgr;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::GetTagMgr
+// gets the tag manager
+// -----------------------------------------------------------------------------
+//
+CNssTagMgr* CNssVASDBBuilder::GetTagMgr()
+    {
+	return  iTagMgr;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::GetVASDBEventNotifier
+// gets the vas db event notifier
+// -----------------------------------------------------------------------------
+//
+CNssVASDBEventNotifier* CNssVASDBBuilder::GetVASDBEventNotifier()
+    {
+	return iVASDBEventNotifier; 
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::GetTagSelectNotifier
+// gets the tag select notifier
+// -----------------------------------------------------------------------------
+//
+CNssDBTagSelectNotifier* CNssVASDBBuilder::GetTagSelectNotifier()
+    {
+	return iDBTagSelectNotifier; 
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVASDBBuilder::Close
+// closes the database
+// -----------------------------------------------------------------------------
+//
+void CNssVASDBBuilder::Close()
+    {
+    RUBY_DEBUG0( "CNssVASDBBuilder::Close" );
+
+	if(iVasDatabase)
+	    {
+		iVasDatabase->CloseDatabase();
+	    }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvascvasdbmgr.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssVASDBMgr is the starting point to begin interaction with VAS. 
+*               The client must first create and Initialize the CNssVASDBMgr; then 
+*               request the ContextMgr, TagMgr, VASDBEventNotifier, or 
+*               TagSelectNotifier to begin using VAS services. 
+*
+*/
+
+
+// INCLUDES
+
+#include <f32file.h>
+#include "nssvascvasdbmgr.h"
+#include "nssvascvasdbbuilder.h"
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::CVASDbMgr
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssVASDBMgr::CNssVASDBMgr ()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::ConstructL
+// EPOC constructor
+// -----------------------------------------------------------------------------
+//
+void CNssVASDBMgr::ConstructL()
+    {
+	iVasDBBuilder = CNssVASDBBuilder::InstanceL();
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::NewL
+// 2-phase constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssVASDBMgr* CNssVASDBMgr::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVASDBMgr::NewL" );
+    
+	CNssVASDBMgr* self = NewLC();
+	CleanupStack::Pop( self );
+	return( self );
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::NewLC
+// 2-phase constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssVASDBMgr* CNssVASDBMgr::NewLC()
+    {
+	CNssVASDBMgr* self = new(ELeave)CNssVASDBMgr;
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return( self );
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::~CNssVASDBMgr
+// 2-phase constructor
+// -----------------------------------------------------------------------------
+//
+CNssVASDBMgr::~CNssVASDBMgr()
+    {
+    RUBY_DEBUG0( "CNssVASDBMgr::~CNssVASDBMgr" );
+
+    if ( iVasDBBuilder )
+        {
+        CNssVASDBBuilder::RemoveInstance();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::InitializeL
+// Initializes the VAS DB Manager
+// -----------------------------------------------------------------------------
+//
+#ifdef __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY 
+EXPORT_C void CNssVASDBMgr::InitializeL()
+    {
+	iVasDBBuilder->InitializeL();
+    }
+#else
+EXPORT_C TInt CNssVASDBMgr::InitializeL()
+    {
+	iVasDBBuilder->InitializeL();
+	return KErrNone;
+    }
+#endif // __SIND_RD_BREAK_PHONEBOOK_COMPATIBILITY
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::GetContextMgr
+// gets the context manager
+// -----------------------------------------------------------------------------
+//
+EXPORT_C MNssContextMgr* CNssVASDBMgr::GetContextMgr()
+    {
+	return iVasDBBuilder->GetContextMgr();
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::GetContextMgr
+// gets the tag manager
+// -----------------------------------------------------------------------------
+//
+EXPORT_C MNssTagMgr* CNssVASDBMgr::GetTagMgr()
+    {
+	return  iVasDBBuilder->GetTagMgr();
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::GetContextMgr
+// gets the VAS DB Event notifier
+// -----------------------------------------------------------------------------
+//
+EXPORT_C MNssVASDBEventNotifier* CNssVASDBMgr::GetVASDBEventNotifier()
+    {
+	return iVasDBBuilder->GetVASDBEventNotifier();
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::GetContextMgr
+// gets the tag select notifier
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssDBTagSelectNotifier* CNssVASDBMgr::GetTagSelectNotifier()
+    {
+	return iVasDBBuilder->GetTagSelectNotifier();
+    }
+
+// -----------------------------------------------------------------------------
+// CVASDbMgr::GetContextMgr
+// Resets factory models
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNssVASDBMgr::ResetFactoryModelsL( MNssResetFactoryModelsClient* aClient )
+    {
+    User::LeaveIfError( 
+        iVasDBBuilder->GetContextMgr()->ResetFactoryModels( aClient )
+        );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvasrvasdbsession.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,556 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RNssVasDbSession is the client-side(proxy) interface through which 
+*               communication with the vasdb server is channelled.
+*
+*/
+
+
+#include "nssvasrvasdbsession.h"
+#include "nssvascvasdb.h"
+
+// Complementary macro for TRAPD:
+// TRAPD( err, doSomething() );
+// REACT( err, return( err ) );
+#define REACT(a,b) if ( a < 0 ) {b;}
+	
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::RNssVasDbSession
+// C++ constructor
+// -----------------------------------------------------------------------------
+//
+RNssVasDbSession::RNssVasDbSession()
+    {
+    iConnected = 0;
+    }
+	
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::~RNssVasDbSession
+// C++ destructor.
+// -----------------------------------------------------------------------------
+//
+RNssVasDbSession::~RNssVasDbSession()
+    {
+    delete iVasDb;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::CreateDatabase
+// Method to create the database.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::CreateDatabase()
+    {
+    TRAPD( error, iVasDb->CreateDatabaseL() );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::OpenDatabase
+// Method to open the database.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::OpenDatabase()
+    {
+    if ( iConnected )
+        {
+        iConnected++;
+        return KErrDbAlreadyOpen;
+        }
+
+    TRAPD( error, iVasDb->OpenDatabaseL() ); 
+
+    if ( error == KErrNone )
+        {
+        iConnected++;
+        }
+
+    return error;
+    }
+	
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::CloseDatabase
+// Method to close the database.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::CloseDatabase()
+    {
+    // Check if already closed (or never opened)
+    if ( iConnected <= 0 )
+        {
+        return( KErrNone );
+        }
+
+    // Some other VAS instance in the same thread may be using the database.
+    iConnected--;
+
+    // If not, close it.
+    if ( iConnected <= 0 )
+        {
+        return iVasDb->CloseDatabase();
+        }
+
+    return( KErrNone );
+    }
+	
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::ModelBankIdLexiconId
+// A method to get the model bank id and lexicon id.
+// -----------------------------------------------------------------------------
+//
+TBool RNssVasDbSession::ModelBankIdLexiconId( TUint32& aModelBankId, TUint32& aLexiconId )
+    {
+    TBool ret = EFalse;
+
+    TRAPD( err, ret = iVasDb->GetModelBankIdLexiconIdL( aModelBankId, aLexiconId ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::TagExist
+// Method to check whether the context has tags or it is empty.
+// -----------------------------------------------------------------------------
+//
+TBool RNssVasDbSession::TagExist(TInt aContextId)
+    {
+    TBool tagExists = EFalse;
+
+    TRAPD( err, tagExists = iVasDb->TagExistL( aContextId ) );
+    REACT( err, tagExists = EFalse );
+
+    return( tagExists );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::TagCount
+// Method to return the number of tags in a context.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::TagCount(TInt aContextId)
+    {
+    TInt ret = 0;
+
+    TRAPD( err, ret = iVasDb->TagCountL( aContextId ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::SaveContext
+// Method to save a context. When a context is saved, a context ID is 
+// assigned to it. The newly assigned ID is returned
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::SaveContext( CNssContext& aContext, TInt& aContextId )
+    {
+    TRAPD( error, iVasDb->SaveContextL( aContext, aContextId ) );
+
+	return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::UpdateContext
+// Method to update the data of a context.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::UpdateContext(CNssContext& aContext)
+    {
+    TInt ret = KErrNone;
+
+    TRAP( ret, iVasDb->UpdateContextL( aContext ) ); 
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::UpdateContextClientData
+// Method to update the client data of a context.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::UpdateContextClientData(CNssContext& aContext)
+    {
+    TInt ret = KErrNone;
+
+    TRAP( ret, iVasDb->UpdateContextClientDataL( aContext ) );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetContextByName
+// Method to get a context by name.
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<CNssContext>* RNssVasDbSession::GetContextByName(const TDesC& aName)
+    {
+    //CArrayFixFlat<CNssContext>* res = 0;
+    CArrayPtrFlat<CNssContext>* res = 0;
+
+    TRAPD( err, res = iVasDb->GetContextByNameL( aName ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetAllGlobalContexts
+// Method to list all global contexts.
+// -----------------------------------------------------------------------------
+//
+//CArrayFixFlat<CNssContext>* RNssVasDbSession::GetGlobalContexts()
+CArrayPtrFlat<CNssContext>* RNssVasDbSession::GetGlobalContexts()
+    {
+    //CArrayFixFlat<CNssContext>* res = 0;
+    CArrayPtrFlat<CNssContext>* res = 0;
+
+    TRAPD( err, res = iVasDb->GetGlobalContexts() );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetAllContexts
+// Method to list all contexts.
+// -----------------------------------------------------------------------------
+//
+//CArrayFixFlat<CNssContext>* RNssVasDbSession::GetAllContexts()
+CArrayPtrFlat<CNssContext>* RNssVasDbSession::GetAllContexts()
+    {
+    //CArrayFixFlat<CNssContext>* res = 0;
+    CArrayPtrFlat<CNssContext>* res = 0;
+
+    TRAPD( err, res = iVasDb->GetAllContexts() );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTag
+// Method to get all tags in a context.
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTag( const TNssContext& aContext )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTag( const CNssContext& aContext )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagL( aContext ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTag
+// Method to get a tag by grammar ID and rule ID.
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTag( TNssGrammarIdRuleId aGrammarIdRuleId )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTag( TNssGrammarIdRuleId aGrammarIdRuleId )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagL( aGrammarIdRuleId ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTags
+// Method to get tags by their grammar ID and rule ID.
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTags( TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTags( 
+                        TNssGrammarIdRuleIdListArray& aGrammarIdRuleIds )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagsL( aGrammarIdRuleIds ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTag
+// Method to get a tag by name (CNssSpeechItem::SetText).
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTag( const TDesC& aName )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTag( const TDesC& aName )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagL( aName ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTag
+// Method to get a tag by RRD data, given RRD integer and the position (0-4)
+// to which the integer is compared.
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTag( TInt aContextId, TInt aNum, TInt aPosition )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTag( TInt aContextId, TInt aNum, TInt aPosition )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagL( aContextId, aNum, aPosition ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTag
+// Method to get a tag by RRD data, given RRD text and the position (0-4)
+// to which the text is compared.
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTag( TInt aContextId, TDesC& aText, TInt aPosition )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTag( TInt aContextId, 
+                                                  const TDesC& aText, TInt aPosition )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagL( aContextId, aText, aPosition ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTag
+// Method to get a tag, given the tag ID.
+// -----------------------------------------------------------------------------
+//
+//TNssTagListArray* RNssVasDbSession::GetTag( TUint32 aTagId )
+CArrayPtrFlat<CNssTag>* RNssVasDbSession::GetTag( TUint32 aTagId )
+    {
+    //TNssTagListArray* res = NULL;
+    CArrayPtrFlat<CNssTag>* res = NULL;
+
+    TRAPD( err, res = iVasDb->GetTagL( aTagId ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( res );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::SaveTag
+// Method to save a tag. During saving, a Tag ID is assigned for the tag.
+// This ID is returned in the refrence parameter.
+// -----------------------------------------------------------------------------
+//
+//TInt RNssVasDbSession::SaveTag( TNssTag& aTag, TInt& aNewId )
+TInt RNssVasDbSession::SaveTag( CNssTag& aTag, TInt& aNewId )
+    {
+    TInt ret = 0;
+
+    TRAPD( err, iVasDb->SaveTagL( aTag, aNewId ) );
+    REACT( err, ret = err );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::SaveTags
+// Method to save a group of tags. During saving, a Tag IDs are assigned
+// for the tags. These IDs is returned in the aTagIdArray.
+// -----------------------------------------------------------------------------
+//
+//TInt RNssVasDbSession::SaveTags( CArrayFixFlat<TNssTag>* aTagArray, RArray<TInt>& aTagIdArray )
+TInt RNssVasDbSession::SaveTags( CArrayPtrFlat<CNssTag>* aTagArray, RArray<TInt>& aTagIdArray )
+    {
+    TRAPD( ret, iVasDb->SaveTagsL( aTagArray, aTagIdArray ) );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::DeleteTag
+// Method to delete a group of tags.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::DeleteTags( const RArray<TUint32>& aTagIdArray )
+    {
+    TRAPD( ret, iVasDb->DeleteTagsL( aTagIdArray ) );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::UpdateTag
+// Method to update the information of an existing tag.
+// -----------------------------------------------------------------------------
+//
+//TInt RNssVasDbSession::UpdateTag( const TNssTag& /*aTag*/ )
+TInt RNssVasDbSession::UpdateTag( const CNssTag& /*aTag*/ )
+    {
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::UpdateTagRuleIDs
+// Method to update the Rule IDs of some tags.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::UpdateTagRuleIDs( const RArray<TNssSpeechItem>& aRetrainedTags )
+    {
+    TRAPD( ret, iVasDb->UpdateTagRuleIDsL( aRetrainedTags ) );
+    return( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::DeleteTag
+// Method to delete a tag by name.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::DeleteTag( const TDesC& aTagName )
+    {
+    TRAPD( error, iVasDb->DeleteTagL( aTagName ) );
+
+    return( error );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::DeleteTag
+// Method to delete a tag by identifier.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::DeleteTag( TInt aTagId )
+    {
+    TRAPD( error, iVasDb->DeleteTagL( aTagId ) );
+
+    return( error );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::DeleteContext
+// Method to delete a context from the database.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::DeleteContext( const TDesC& aName )
+    {
+    TRAPD( err, iVasDb->DeleteContextL( aName ) );
+
+    return( err );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetTagReferenceList
+// Method to get references to all tags in a context.
+// -----------------------------------------------------------------------------
+//
+TNssTagReferenceListArray* RNssVasDbSession::GetTagReferenceList( TInt aContextId )
+    {
+    TNssTagReferenceListArray* result = 0;
+   
+    TRAPD( err, result = iVasDb->GetTagReferenceListL( aContextId ) );
+
+    // To remove warning
+    if ( err != KErrNone )
+        {
+        }
+
+    return( result );
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::GetDefaultModelBankId
+// Method to get the default model bank id
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::GetDefaultModelBankId( TUint32& aId )
+    {
+    TRAPD( err, iVasDb->GetDefaultModelBankIdL( aId ) );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// RNssVasDbSession::ResetModelBank
+// Modifies the context table so that all contexts start using
+// the new id as their model bank id.
+// -----------------------------------------------------------------------------
+//
+TInt RNssVasDbSession::ResetModelBank( TUint32 aNewId )
+    {
+    TRAPD( err, iVasDb->ResetModelBankL( aNewId ) );
+    return err;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasdb/src/nssvastvasdbcreator.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,382 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  TNssVasDbCreator is responsible for creating VasDatabase.db.
+*
+*/
+
+
+#include "nssvastvasdbcreator.h"
+#include <e32cons.h>
+#include <s32file.h>
+#include <d32dbms.h>
+#include "nssvascoreconstant.h"
+
+// in bytes
+const TInt KClientDataColSize = 100;
+
+// ============================ Methods ===============================
+
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::TNssVasDbCreator
+// -----------------------------------------------------------------------------
+//
+TNssVasDbCreator::TNssVasDbCreator()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateVasDatabaseL
+// -----------------------------------------------------------------------------
+//
+void TNssVasDbCreator::CreateVasDatabaseL( RDbs& iDbSession )
+    {
+    RDbNamedDatabase database; 
+    TInt error = database.Create( iDbSession, KVasDatabaseName, KVasDatabaseFormatString );
+    CleanupClosePushL( database );
+    if ( error == KErrAlreadyExists )
+        {
+        // Ignore KErrAlreadyExists, we will use the existing one if it is there
+        error = KErrNone;
+        }
+    else if ( error == KErrNone )
+        {
+        // Create tables
+        CreateTablesAndIndiciesL( database );
+        }
+        
+    CleanupStack::PopAndDestroy( &database ); // Close database
+ 
+    User::LeaveIfError( error );
+    }
+    
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateTablesAndIndiciesL
+// -----------------------------------------------------------------------------
+//	    
+void TNssVasDbCreator::CreateTablesAndIndiciesL( RDbNamedDatabase& aDatabase )
+    {
+    CreateContextTableL( aDatabase );
+    CreateContextIndexL( aDatabase );
+    CreateTagTableL( aDatabase );
+    CreateTagIndexL( aDatabase );
+    CreateRRDTableL( aDatabase );
+    CreateRRDIndexL( aDatabase );
+    CreateWriteLockTableL( aDatabase );
+    }
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateContextTableL
+// -----------------------------------------------------------------------------
+//	   
+/*                   Context Table
+*
+* Was up to 2.0:
+*
+*     name|global|contextid|lexiconid|grammarid|modelbankid
+*     ------------------------------------------------------
+*         |      |         |         |         |
+*
+* In 2.8:
+*
+*  |name|global|contextid|lexiconid|grammarid|modelbankid|clientdata|
+*  |----------------------------------------------------------------|
+*  |    |      |         |         |         |           |          |
+*/
+void TNssVasDbCreator::CreateContextTableL( RDbNamedDatabase& aDatabase )
+    {
+	_LIT(KContextTable, "contexttable");
+	_LIT(KCol1,  "name");
+	_LIT(KCol2,  "global");
+	_LIT(KCol3,  "contextid");
+	_LIT(KCol4,  "lexiconid");
+	_LIT(KCol5,  "grammarid");
+	_LIT(KCol6,  "modelbankid");
+    _LIT(KCol8,  "clientdata"); // NSS Extension(tm)
+
+	// Create the context table definition (columnset).
+	CDbColSet* columns = CDbColSet::NewLC();
+
+	// add column definitions
+
+	// The name column first.
+	TDbCol dbCol1(KCol1, EDbColText,KNssVasDbContextName); 
+	dbCol1.iAttributes = TDbCol::ENotNull;
+	columns->AddL(dbCol1);
+
+	// The global flag column
+	TDbCol dbCol2(KCol2, EDbColUint32);
+	dbCol2.iAttributes = TDbCol::ENotNull;
+	columns->AddL(dbCol2);
+
+	// The context id flag  CDbKey* key = CDbKey::NewLC();
+	TDbCol dbCol3(KCol3, EDbColUint32);
+	dbCol3.iAttributes = TDbCol::EAutoIncrement|TDbCol::ENotNull;
+	columns->AddL(dbCol3);
+
+	// The lexicon id 
+	TDbCol dbCol4(KCol4, EDbColUint32);
+	dbCol4.iAttributes = TDbCol::ENotNull;
+	columns->AddL(dbCol4);
+
+    // The grammar id 
+	TDbCol dbCol5( KCol5, EDbColUint32 );
+	dbCol5.iAttributes = TDbCol::ENotNull;
+	columns->AddL( dbCol5 );
+
+	 // The modelbank id 
+	TDbCol dbCol6( KCol6, EDbColUint32 );
+	dbCol6.iAttributes = TDbCol::ENotNull;
+	columns->AddL( dbCol6 );
+
+	// 100 bytes of client data. New in 2.8.
+	TDbCol dbCol8( KCol8, EDbColBinary, KClientDataColSize );
+    // Can be null
+	columns->AddL( dbCol8 );
+
+    // Now actually create the table.
+	User::LeaveIfError( aDatabase.CreateTable( KContextTable, *columns ) );
+
+	// Cleanup columns
+	CleanupStack::PopAndDestroy( columns );
+    }
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateContextIndexL
+// -----------------------------------------------------------------------------
+//	   
+void TNssVasDbCreator::CreateContextIndexL( RDbNamedDatabase& aDatabase )
+    {
+	_LIT( KTable, "contexttable" );
+	// Same as table name is a bit weird, but we leave it unchanged to avoid
+	// potential incompatibility with some other code, that might access
+	// index by name
+	_LIT( KIndexName, "contexttable");  
+	//_LIT( KCol3,  "contextid" );
+	CreateSingleColumnIndexL( aDatabase, KIndexName, KContextIdCol, ETrue, KTable);
+	
+    }
+
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateTagTableL
+// -----------------------------------------------------------------------------
+//	   
+/*
+*             Tag Table
+*
+*   tagid|contextid|name|ruleid|
+*   -----------------------------
+*        |         |    |      |
+*
+*/
+void TNssVasDbCreator::CreateTagTableL( RDbNamedDatabase& aDatabase )
+    {
+   	_LIT(KTagTable,"tagtable");
+	_LIT(KCol1,  "tagid");
+	_LIT(KCol2,  "contextid");
+	_LIT(KCol3,  "name");
+	_LIT(KCol5,  "ruleid");
+
+
+	// Create the tag table definition (columnset).
+	CDbColSet* columns = CDbColSet::NewLC();
+
+		// The tag id 
+	TDbCol dbCol1(KCol1, EDbColUint32);
+	dbCol1.iAttributes = TDbCol::EAutoIncrement|TDbCol::ENotNull;
+	columns->AddL(dbCol1);
+
+		// The context id 
+	TDbCol dbCol2(KCol2, EDbColUint32);
+	dbCol2.iAttributes = TDbCol::ENotNull;
+	columns->AddL(dbCol2);
+
+	// The speechitem/tag name column.
+	TDbCol dbCol3(KCol3, EDbColText,KNssVasDbSpeechItemName); 
+	dbCol3.iAttributes = TDbCol::ENotNull;
+	columns->AddL(dbCol3);
+
+    // The rule id 
+	TDbCol dbCol5(KCol5, EDbColUint32);
+	dbCol5.iAttributes = TDbCol::ENotNull;
+	columns->AddL(dbCol5);
+
+    // Now actually create the table.
+	User::LeaveIfError ( aDatabase.CreateTable(KTagTable, *columns));
+
+	// Cleanup columns
+	CleanupStack::PopAndDestroy( columns );
+    }
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateTagIndexL
+// -----------------------------------------------------------------------------
+//	  
+void TNssVasDbCreator::CreateTagIndexL( RDbNamedDatabase& aDatabase )
+    {
+	_LIT( KTable, "tagtable" );
+	CreateSingleColumnIndexL(aDatabase, KTable, KTagIdCol, ETrue, KTable);
+	_LIT( KContextIndexName, "tagtable_contextid_idx" );
+	CreateSingleColumnIndexL(aDatabase, KContextIndexName, KContextIdCol, EFalse, KTable);
+	_LIT( KRuleIndexName, "tagtable_ruleid_idx" );
+	CreateSingleColumnIndexL(aDatabase, KRuleIndexName, KRuleIdCol, EFalse, KTable);
+	_LIT( KIndexName, "tagtable_contextid_ruleid_idx" );
+	CreateTwoColumnIndexL( KIndexName, KContextIdCol, KRuleIdCol, ETrue, KTable);
+    }
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateRRDTableL
+// -----------------------------------------------------------------------------
+//	  
+/*   RRD Text Table       RRD Int Table
+*   
+*   tagid|text|pos        tagid|int|pos
+*    --------------        -------------
+*        |    |                |   |
+*/
+void TNssVasDbCreator::CreateRRDTableL( RDbNamedDatabase& aDatabase )
+    {
+	_LIT( KRRDTextTable, "rrdtexttable" );
+	_LIT( KRRDIntTable, "rrdinttable" );
+
+	_LIT( KCol1,    "tagid" );
+	_LIT( KTextCol2,"rrdtext" );
+    _LIT( KIdCol2,  "rrdint" );
+	_LIT( KCol3,    "rrdposition" );
+   
+	// Create the rrd tables definition (columnset).
+	CDbColSet* textcolumns = CDbColSet::NewLC();
+	CDbColSet* intcolumns  = CDbColSet::NewLC();
+
+		// The tag id 
+	TDbCol dbCol1( KCol1, EDbColUint32 );
+	//dbCol1.iAttributes = TDbCol::ENotNull;
+	textcolumns->AddL( dbCol1 );
+    intcolumns->AddL( dbCol1 );
+
+		// The rrd text  
+	TDbCol dbCol2( KTextCol2, EDbColText, KNssVasDbRRDText );
+	//dbCol2.iAttributes = TDbCol::ENotNull;
+	textcolumns->AddL( dbCol2 );
+
+	   //The rrd int
+	TDbCol iddbCol2( KIdCol2, EDbColUint32 );
+	//iddbCol2.iAttributes = TDbCol::ENotNull;
+	intcolumns->AddL( iddbCol2 );
+
+		// The position 
+	TDbCol dbCol3( KCol3, EDbColUint32 );
+	//dbCol3.iAttributes = TDbCol::ENotNull;
+	textcolumns->AddL( dbCol3 );
+    intcolumns->AddL( dbCol3 );
+
+	User::LeaveIfError( aDatabase.CreateTable( KRRDTextTable, *textcolumns ) );
+	User::LeaveIfError( aDatabase.CreateTable( KRRDIntTable, *intcolumns ) );
+
+	// Cleanup textcolumns & idcolumns
+	CleanupStack::PopAndDestroy( intcolumns ); 
+	CleanupStack::PopAndDestroy( textcolumns ); 
+    }
+    
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateRRDIndexL
+// -----------------------------------------------------------------------------
+//	      
+void TNssVasDbCreator::CreateRRDIndexL( RDbNamedDatabase& aDatabase )
+	{
+	_LIT( KRRDTextTable, "rrdtexttable" );
+	_LIT( KRRDIntTable, "rrdinttable" );
+	_LIT( KRRDTextTagIndex, "rrdtexttable_tagid_idx");
+	_LIT( KRRDIntTagIndex, "rrdinttable_tagid_idx" );
+	_LIT( KRRDTextTagPosIndex, "rrdtexttable_tagid_pos_idx");
+	_LIT( KRRDIntTagPosIndex, "rrdinttable_tagid__pos_idx" );
+	// constraints
+	CreateTwoColumnIndexL(KRRDTextTagPosIndex, KTagIdCol, KRRDPositionCol, ETrue, KRRDTextTable);
+	CreateTwoColumnIndexL(KRRDIntTagPosIndex, KTagIdCol, KRRDPositionCol, ETrue, KRRDIntTable);
+	// and for actual searches
+	CreateSingleColumnIndexL(aDatabase, KRRDTextTagIndex, KTagIdCol, EFalse, KRRDTextTable);
+	CreateSingleColumnIndexL(aDatabase, KRRDIntTagIndex, KTagIdCol, EFalse, KRRDIntTable);
+	}
+    
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateWriteLockTableL
+// -----------------------------------------------------------------------------
+//	    
+/*   Write lock table
+*   
+*    temporary 
+*   |---------|
+*   |         |
+*/
+void TNssVasDbCreator::CreateWriteLockTableL( RDbNamedDatabase& aDatabase )
+    {
+	_LIT( KWriteLockTable, "writelocktable" );
+
+	_LIT( KCol1,    "temporary" );
+   
+	// Create the rrd tables definition (columnset).
+	CDbColSet* columns = CDbColSet::NewLC();
+
+    // The tag id 
+	TDbCol dbCol1( KCol1, EDbColUint32 );
+	columns->AddL( dbCol1 );
+
+	User::LeaveIfError( aDatabase.CreateTable( KWriteLockTable, *columns ) );
+
+	// Cleanup columns
+	CleanupStack::PopAndDestroy( columns ); 
+    }
+    
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateSingleColumnIndexL
+// -----------------------------------------------------------------------------
+//	      
+void TNssVasDbCreator::CreateSingleColumnIndexL( RDbNamedDatabase& aDatabase,
+                                                 const TDesC& aIndexName,
+                                                 const TDesC& aColumnName,
+                                                 const TBool aUnique,
+                                                 const TDesC& aTableName)
+	{
+	// Create the index key...
+	CDbKey* key = CDbKey::NewLC();
+
+	// and add the key columns.
+	TDbKeyCol keyCol( aColumnName );
+	key->AddL( keyCol );
+	if( aUnique ) 
+		{
+		key->MakeUnique();
+		}
+	
+	// Create the index
+	User::LeaveIfError( aDatabase.CreateIndex( aIndexName, aTableName, *key ) );
+
+	// Cleanup key
+	CleanupStack::PopAndDestroy(key);
+	}
+
+// -----------------------------------------------------------------------------
+// TNssVasDbCreator::CreateTwoColumnIndexL
+// -----------------------------------------------------------------------------
+//	      
+void TNssVasDbCreator::CreateTwoColumnIndexL( const TDesC& /*anIndexName*/, 
+                                              const TDesC& /*aFirstColumnName*/, 
+                                              const TDesC& /*aSecondColumnName*/, 
+                                              const TBool /*aUnique*/, 
+                                              const TDesC& /*aTableName*/)
+	{
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/inc/nssvascadaptationitem.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MNssAdaptationItem interface class handles speaker adaptation,
+*               when the client wants to decide herself, when to adapt.
+*
+*/
+
+
+#ifndef NSSVASCADAPTATIONITEM_H
+#define NSSVASCADAPTATIONITEM_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <nssvasmadaptationitem.h>
+#include <nssvasmadaptationeventhandler.h>
+#include "nssvascrecognitionhandler.h"
+
+// CLASS DECLARATION
+
+/**
+*  CNssAdaptationItem class
+*  Contains adaptation data.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+class CNssAdaptationItem : public CBase, public MNssAdaptationItem
+    {
+
+    public:  //enum
+
+	  enum TNssRejectTagError
+        {
+        EVasErrorNone,
+        EVasRejectTagFailed,
+        EVasNoTagInContexts,
+        EVasRecognizeUndefinedError10,   // for place holder
+        EVasRecognizeUndefinedError9,
+        EVasRecognizeUndefinedError8,
+        EVasRecognizeUndefinedError7,
+        EVasRecognizeUndefinedError6,
+        EVasRecognizeUndefinedError5,
+        EVasRecognizeUndefinedError4,
+        EVasRecognizeUndefinedError3,
+        EVasRecognizeUndefinedError2,
+        EVasRecognizeUndefinedError1
+        };
+
+    public: // Constructors and destructors
+
+    /**
+    * NewL - 2-phase constructor
+    * @param aRecHandlerHost The recognition handler, which created this item.
+    * @param aRecResult Recognition result contains the data required for adaptation.
+    * @since 2.8
+    */
+    IMPORT_C static CNssAdaptationItem* NewL(
+        CNssRecognitionHandler* aRecHandlerHost,
+        CSIClientResultSet* aRecResult );
+
+    /**
+	* ~MNssAdaptationItem - Destructor  
+    * @since 2.8
+    */
+    IMPORT_C ~CNssAdaptationItem();
+
+public: // Functions from base classes
+
+    /**
+	* AdaptL - Adapts the models using utterance and result
+    * @from MNssAdaptationItem
+    * @since 2.8
+    * @param aHandler Adaptation handler is called when adaptation has finished.
+    * @param aCorrect Which result from the N-best list is the correct one.
+    */
+    IMPORT_C void AdaptL( MNssAdaptationEventHandler *aHandler, TInt aCorrect );
+
+    /**
+    * Adapts the models using the tag information
+    * 
+    * @since 3.2
+    * @param aHandler Event handler for this adaptation
+    * @param aTag Selected tag
+    */ 
+    IMPORT_C void AdaptL( MNssAdaptationEventHandler* aHandler,
+                          MNssTag& aTag );
+
+public: // New functions
+
+    /**
+    * Disable - CNssRecognitionHandler calls this function, when the handler
+    * is destroyed. It deactivates the adaptation item, since adaptation
+    * can't happen without the recognition handler host.
+    * @since 2.8
+    */
+    IMPORT_C void Disable();
+
+    private: // New functions
+
+    /**
+    * 1st phase constructor
+    */
+    CNssAdaptationItem( CNssRecognitionHandler* aRecHandlerHost, CSIClientResultSet* aRecResult );
+
+private: // Data
+
+    // Pointer to the recognition handler host
+    CNssRecognitionHandler* iRecHandler;
+
+    // If the recognition handler host is destroyed, the associated 
+    // adaptation items are deactivated.
+    TBool iIsActive;
+
+    // Recognition result set contains the data required for adaptation.
+    CSIClientResultSet* iAdaptationData;
+    };
+
+#endif // NSSVASCADAPTATIONITEM_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/inc/nssvascrecognitionhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,504 @@
+/*
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssRecognitionHandler class performs the recognition function.  
+*
+*/
+
+
+#ifndef NSSVASCRECOGNITIONHANDLER_H
+#define NSSVASCRECOGNITIONHANDLER_H
+
+//  INCLUDES
+#include <nsssispeechrecognitionutilityobserver.h>
+#include "nssvasmrecognitionhandler.h"
+#include "nssvasccontextmgr.h"
+#include "nssvasmadaptationeventhandler.h"
+
+// FORWARD DECLARATIONS
+
+class CNssSiUtilityWrapper;
+class CNssTagMgr;
+class CNssVASDBBuilder;
+class CNssAdaptationItem;
+
+// CLASS DECLARATION
+
+/**
+*
+*  The CNssRecognitionHandler class performs the recognition function.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssRecognitionHandler :public CBase, 
+                           public MNssRecognitionHandler, 
+                           public MSISpeechRecognitionUtilityObserver
+{
+
+   public:  //enum
+
+        enum TNssRState
+        {
+        EVasIdle,
+        EVasWaitingForLoadModelsComplete,
+        EVasWaitingForLoadLexiconComplete,
+        EVasWaitingForLoadGrammarComplete,
+        EVasWaitingForRecognitionReadyRecognitionInit,
+        EVasWaitingForRecognize,
+        EVasWaitingForRecordStarted,
+        EVasWaitingForEouDetected,
+        EVasWaitingForRecognitionComplete,
+        EVasWaitingForSelectTag,
+        EVasWaitingForUnloadRuleComplete,
+        EVasWaitingForRecognitionReadyRejectTag,
+        EVasDirectAdaptation,
+        EVasIdleAdaptation,
+        EVasCorrectingPluginDatabase
+        };
+
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */        
+        static CNssRecognitionHandler* NewL();
+
+        /**
+        * Two-phased constructor.
+        */    
+        static CNssRecognitionHandler* NewLC();
+        
+        /**
+        * Destructor.
+        */                
+        virtual ~CNssRecognitionHandler();
+
+    public: // Functions from base classes
+
+         /**
+        * Perform initialization for the recognize funtion.
+        * @since 2.0
+        * @param aInitCompleteHandler The event call back to receive recognize 
+        *                             init events.
+        * @param aRecognitionVocabulary List of context, which are active in recognition.
+        * @param aMaxResults The maximum number of voice tags to be recognized.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */               
+        TNssRecognitionResult RecognizeInitL(
+                            MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+                            const CArrayPtrFlat<MNssContext>& aRecognitionVocabulary,
+                            TInt aMaxResults);
+         /**
+        * Perform initialization for the recognize funtion. Automatically loads
+        * the commands and the names as recognition vocabulary.
+        * @since 2.0
+        * @param aInitCompleteHandler The event call back to receive recognize 
+        *                             init events.
+        * @param aMaxResults The maximum number of voice tags to be recognized.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */               
+        TNssRecognitionResult RecognizeInitL(
+                            MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+                            TInt aMaxResults );
+        /**
+        * From MNssRecognitionHandler Interface 
+        * Perform the recognize function.
+        * @since 2.0
+        * @param aEventHandler The event call back to receive recognize events.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */        
+        TNssRecognitionResult Recognize( MNssRecognizeEventHandler* aEventHandler );
+
+        /**
+        * From MNssRecognitionHandler
+        * Starts sampling already before RecognizeInitL and Recognize calls.
+        * This is used to ensure that there is no delay between user notification
+        * and sampling start.
+        *
+        * @since 3.2
+        * @param aInitCompleteHandler Callback handler
+        * @return Return indicating request is valid.
+        */
+        TNssRecognitionResult PreStartSampling( MNssRecognizeInitCompleteHandler* aInitCompleteHandler );
+
+        /**
+        * From MNssRecognitionHandler Interface 
+        * Initiate the Select Tag event.
+        * @since 2.0
+        * @param aClientTag The voice tag which was selected. The tag is owned
+        *                   by the client.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */        
+        TNssRecognitionResult SelectTagL( MNssTag* aClientTag );
+
+        /**
+        * From MNssRecognitionHandler Interface 
+        * Initiate the Select Tag event.
+        * @since 2.0
+        * @param aClientTag The voice tag which was selected. The tag is owned
+        *                   by the client.
+        * @param aNotifyHandlers If false, the global context handlers won't be notified.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */        
+        TNssRecognitionResult SelectTagL( MNssTag* aClientTag, TBool aNotifyHandlers );
+
+        /**
+        * Request Reject Tag, i.e. blacklisting.
+        * @since 2.0 
+        * @param aClientTagList The list of voice tags which is to be rejected, i.e. 
+        *                       blacklisted. The tag list is owned by the client.
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */
+        TNssRecognitionResult RejectTagL(
+                             MNssRejectTagCompleteHandler* aRejectTagCompleteHandler,
+                             CArrayPtrFlat<MNssTag>* aClientTagList );
+
+        /**
+        * From MNssRecognitionHandler Interface 
+        * Cancel the last recognition function.
+        * @since 2.0
+        * @param -
+        * @return TNssRecognitionResult Return indicating request is valid.
+        */                
+        TNssRecognitionResult Cancel();
+ 
+        /**
+        * From MNssRecognitionHandler Interface
+        * Get the adaptation item to adapt, when you know whether
+        * the result was correct or not.
+        * @since 2.0
+        * @param -
+        * @return MNssAdaptationItem The adaptation item.
+        */
+        MNssAdaptationItem* GetAdaptationItemL();
+
+        /**
+        * From MSpeechRecognitionEvent Interface
+        * Handle Speech Recognition Utility event
+        * @since 2.0
+        * @param aEvent The event callback to receive Speech Recognition Utility 
+        *               events.
+        * @param aResult The result value associated with aEvent.
+        * @return -
+        */
+        void MsruoEvent( TUid aEvent, TInt aResult );
+
+    public: // New functions
+
+        /**
+        * AdaptL - called by adaptation item. Adapts the acoustic models.
+        * @since 2.0
+        * @return None
+        */
+        void AdaptL( MNssAdaptationEventHandler* aCallback,
+                     CSIClientResultSet* aResultSet,
+                     TInt aCorrect );
+
+        /**
+        * RemoveAdaptationItem - When an adaptation item is destroyed,
+        * it signals to its "host" recognition handler. This way, the host
+        * knows to remove it from the list of active adaptation items.
+        */
+        void RemoveAdaptationItem( CNssAdaptationItem* anItem );
+
+    private:
+
+        /**
+        * Constructor.
+        */        
+        CNssRecognitionHandler();
+
+       /**
+        * By default Symbian 2nd phase constructor is private.
+        */        
+        void ConstructL();
+
+        /**
+        * Perform required cleanup to get back to the EIdle state and issue the
+        * HandleRecognizeInitError event with RecognizeInitFailed error code
+        * @return void
+        */ 
+        void CleanupRecognizeInitFailed();
+
+        /**
+        * Perform required cleanup to get back to the EIdle state and issue the
+        * HandleRecognizeError event with RecognizeFailed error code
+        * @return void
+        */ 
+        void CleanupRecognizeFailed();
+
+        /**
+        * Perform required cleanup to get back to the EIdle state and issue the
+        * HandleRejectTagError event with RejectTagFailed error code
+        * @return void
+        */ 
+        void CleanupRejectTagFailed();
+
+        /**
+        * Perform required cleanup to get back to the EIdle state
+        * @return void
+        */ 
+        void Cleanup();
+
+        /**
+        * Gracefully terminate and delete the SRF object, iSrsApi.
+        * @return void
+        */ 
+        void DeleteSrf();
+
+        /**
+        * Delete context objects from iContextList
+        * @return void
+        */ 
+        void ClearContextList();
+
+        /**
+        * Delete the tag objects from iTagList
+        * @return void
+        */ 
+        void ClearTagList();
+
+        /**
+        * Delete the TRuleEntry objects from iRuleList
+        * @return void
+        */ 
+        void ClearRuleList();
+
+        /**
+        * Delete entries from iContextStatus
+        * @return void
+        */ 
+        void ClearContextStatus();
+
+        /**
+        * Cleanup and determine the correct event handler
+        * @return void
+        */
+        void UnexpectedEvent();
+
+        /**
+        * Handle LoadModelsComplete SRF event
+        * @return void
+        */
+        void DoLoadModelsComplete();
+
+        /**
+        * Handle LoadModelsFailed SRF event
+        * @return void
+        */
+        void DoLoadModelsFailed();
+
+        /**
+        * Handle LoadLexiconComplete SRF event
+        * @return void
+        */
+        void DoLoadLexiconComplete();
+
+        /**
+        * Handle LoadLexiconFailed SRF event
+        * @return void
+        */
+        void DoLoadLexiconFailed();
+
+        /**
+        * Handle LoadGrammarComplete SRF event
+        * @return void
+        */
+        void DoLoadGrammarComplete();
+
+        /**
+        * Handle LoadGrammarFailed SRF event
+        * @return void
+        */
+        void DoLoadGrammarFailed();
+
+        /**
+        * Handle RecognitionReady SRF event
+        * @return void
+        */
+        void DoRecognitionReady();
+
+        /**
+        * Handle RecognitionComplete SRF event
+        * @return void
+        */
+        void DoRecognitionComplete();
+        
+        /**
+        * Handle RecognitionFailedNoSpeech, RecognitionFailedTooEarly, 
+        * RecognitionFailedTooLong, and RecognitionFailedTooShort SRF events
+        * @param aResult The Msruo event Result code.
+        * @return void
+        */        
+        void DoRecognitionFailedNoSpeech( TInt aResult );
+
+        /**
+        * Handle RecognitionFailedNoMatch SRF event
+        * @return void
+        */
+        void DoRecognitionFailedNoMatch();
+
+        /**
+        * Handle RecognitionFailed SRF event
+        * @return void
+        */
+        void DoRecognitionFailed();
+
+        /**
+        * Handle RecordStarted SRF event
+        * @return void
+        */
+        void DoRecordStarted();
+
+        /**
+        * Handle RecordFailed SRF event
+        * @param aResult The Msruo event Result code.
+        * @return void
+        */
+        void DoRecordFailed( TInt aResult );
+
+        /**
+        * Handle EouDetected SRF event
+        * @return void
+        */
+        void DoEouDetected();
+
+        /**
+        * Handle UnloadRuleComplete SRF event
+        * @return void
+        */
+        void DoUnloadRuleComplete();
+
+        /**
+        * Handle UnloadRuleFailed SRF event
+        * @return void
+        */
+        void DoUnloadRuleFailed();
+        
+        /**
+        * Handle PreStartSampling SRSF event
+        */
+        void DoPreStartSamplingComplete( TInt aError );
+
+        /**
+        * Handle Tag Check for contexts
+        * @return void
+        */
+        void HandleTagCheckL();
+
+        /**
+        * Create the SRF object, iSrsApi.
+        * @return void
+        */ 
+        void CreateSrfL();
+
+        /**
+        * Perform those RecognizeInitL tasks,
+        * which do not depend on vocabulary.
+        */
+        MNssRecognitionHandler::TNssRecognitionResult CommonRecognizeInitL(
+            MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+            TInt aMaxResults );
+
+
+    struct TRuleEntry 
+    {
+        TUint32 ruleId;
+        TUint32 grammarId;
+    };
+
+
+    private:    // Data
+
+        // Pointer to SRS Utility object.
+        CNssSiUtilityWrapper*     iSrsApi;
+
+        // Pointer to SRS to ClientResultSet object, i.e. returned SRS data.
+        CSIClientResultSet*            iSIClientResultSet;
+
+        // Pointer to RecognizeInit Complete Event Handler object.
+        MNssRecognizeInitCompleteHandler* iInitCompleteHandler;
+
+        // Pointer to Recognize Complete Event Handler object.
+        MNssRecognizeEventHandler*        iEventHandler;
+
+        // Pointer to RejectTag Complete Event Handler object.
+        MNssRejectTagCompleteHandler*       iRejectTagCompleteHandler;
+
+        // Pointer to VAS Database Builder object.
+        CNssVASDBBuilder*                 iVasDBBuilder;
+
+        // Pointer to Context Manager object.
+        CNssContextMgr*                   iContextMgr;
+
+        // Pointer to Context List object.
+        TMNssContextList*                 iContextList;
+
+        // Pointer to Tag Manager object.
+        CNssTagMgr*                       iTagMgr;
+
+        // Pointer to Tag List object.
+        CArrayPtrFlat<CNssTag>*           iTagList;
+
+        // Pointer to Rule List object - used during RejectTag 
+        CArrayFixFlat<TRuleEntry>*     iRuleList;
+
+        // Context Status Array - True indicates tags for context exist
+        // False indicates there are not tags in the context
+        CArrayFixFlat<TBool>*           iContextStatus;
+
+        // Current Loop Counter used across asynch Context logic
+        // during RecognizeInit
+        TInt                           iContextCurrentLoopCount;
+
+        // Number of contexts - used across asynch Context logic
+        // during RecognizeInit
+        TInt                           iContextCount;
+
+        // Current Loop Counter used across asynch Result (tag) logic
+        // during Recognize
+        TInt                           iTagCurrentLoopCount;
+
+        // Number of returned Results (tags) -  used across asynch tag logic
+        // during Recognize
+        TInt                           iTagCount;
+
+        // Current Loop Counter used across asynch RejectTag logic
+        TInt                           iRejectTagCurrentLoopCount;
+
+        // Number of rejected tags - used across asynch RejectTag logic
+        TInt                           iRejectTagCount;
+
+        // Maximum number of voice tags to be recognized, requested by client 
+        TInt                           iMaxResults;
+
+        // The current recognition state.
+        TNssRState                        iRState;
+
+        // Array of adaptation items. Each MNssAdaptationItem is
+        // internally linked to some "host" CNssRecognitionHandler.
+        RPointerArray<CNssAdaptationItem> iAdaptItemArray;
+
+        // Callback after adaptation
+        MNssAdaptationEventHandler*       iAdaptationHandler;
+        
+        // Wait loop
+        CActiveSchedulerWait iWait;
+};
+
+#endif // NSSVASCRECOGNITIONHANDLER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/inc/nssvasctagselectdata.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssTagSelectData Class contains the data for tag select 
+*                notification.
+*
+*/
+
+
+#ifndef CNSSTAGSELECTDATA_H
+#define CNSSTATSELECTDATA_H
+
+// INCLUDES
+
+#include "nssvasccontext.h"
+#include "nssvasmtagselecthandler.h"
+
+
+// CLASS DEFINITIONS
+
+/**
+*
+*  The CNssTagSelectData class contains the data for tag select notification. 
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssTagSelectData : public CBase
+{
+
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */		
+        static CNssTagSelectData* NewL(CNssContext* aContext, 
+								    MNssTagSelectHandler* aTagSelectHandler);
+
+        /**
+        * Two-phased constructor.
+        */	
+		static CNssTagSelectData* NewLC(CNssContext* aContext, 
+								     MNssTagSelectHandler* aTagSelectHandler);
+
+        /**
+        * Destructor.
+        */	
+		~CNssTagSelectData();
+
+
+    public: // New functions
+        
+        /**
+        * Get Context
+        * @since 2.0
+        * @return A pointer to the context.
+        */
+        CNssContext* Context();
+
+        /**
+        * Get TagSelectHandler
+        * @since 2.0
+        * @return A pointer to the TagSelectHandler event handler.
+        */
+        MNssTagSelectHandler* TagSelectHandler();
+
+    private:
+
+        /**
+        * Constructor.
+        */	
+		CNssTagSelectData();
+
+       /**
+        * By default Symbian 2nd phase constructor is private.
+        */		
+        void ConstructL(CNssContext* aContext, 
+					    MNssTagSelectHandler* aTagSelectHandler);
+
+    private:
+
+		// Context - The context the selected voice tag appears in
+		CNssContext* iContext;
+
+		// Event Callback - The event handler to be notified when a voice tag is 
+		// selected in the context.
+		MNssTagSelectHandler* iTagSelectHandler;
+
+};
+
+#endif // CNssTagSELECTDATA_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/inc/nssvasctagselectnotification.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssTagSelectNotification class allows the client to
+*                register and deregister for a voice tag select event. 
+*
+*/
+
+
+#ifndef CNSSTAGSELECTNOTIFICATION_H
+#define CNSSTAGSELECTNOTIFICATION_H
+
+// INCLUDES
+
+#include <e32std.h>
+#include "nssvasmtagselectnotification.h"
+#include "nssvasmdbtagselectnotifierclient.h"
+#include "nssvasccontext.h"
+#include "nssvascvasdbbuilder.h"
+
+// FORWARD DECL
+class CNssTag;
+class CNssVASDBBuilder;
+class MNssTagSelectHandler;
+class CNssTagSelectData;
+
+
+// CLASS DEFINITIONS
+
+/**
+*
+*  The CNssTagSelectNotification class performs the recognition function.
+*
+*  @lib NssVASApi.lib
+*  @since 2.8
+*/
+
+class CNssTagSelectNotification : public CBase,
+							   public MNssTagSelectNotification,
+							   public MNssDBTagSelectNotifierClient
+{
+
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */	
+        static CNssTagSelectNotification* NewL();
+
+		/**
+        * Two-phased constructor.
+        */	
+		static CNssTagSelectNotification* NewLC();
+
+        /**
+        * Destructor.
+        */	
+		~CNssTagSelectNotification();
+
+    public: // Functions from base classes
+
+        /**
+		* From MNssTagSelectNotification
+        * Register for voice tag select notification
+        * @since 2.0
+        * @param aContext The voice tag context which determines notification.
+        * @param aTagSelectHandler The event handler for tag select notification.
+        * @return TSelectError Return code to indicate request was valid.
+        */
+        TNssSelectResult RegisterL(MNssContext* aContext,
+					   MNssTagSelectHandler* aTagSelectHandler);
+
+        /**
+	    * From MNssTagSelectNotification
+        * Deegister from voice tag select notification
+        * @since 2.0
+        * @param aContext The voice tag context which determines notification.
+        * @param aTagSelectHandler The event handler for tag select notification,
+		*                          used to deregister the correct client.
+        * @return TSelectError Return code to indicate request was valid.
+        */
+        TNssSelectResult Deregister(MNssContext* aContext,
+			            MNssTagSelectHandler* aTagSelectHandler);
+
+        /**
+	    * From MNssDBTagSelectNotifierClient
+        * HandleSelection is called into the client by CNssDBTagSelectNotifier
+        * @since 2.0
+        * @param aTag  The voice tag which was selected.
+        * @return -
+        */
+		void HandleSelection(CNssTag* aTag);
+
+    private:
+
+        /**
+        * Constructor.
+        */	
+		CNssTagSelectNotification();
+
+       /**
+        * By default Symbian 2nd phase constructor is private.
+        */		
+        void ConstructL();
+
+        /**
+        * CompareContexts compare a context with a Tag Select Data List context
+        * @since 2.0
+        * @param aContext  The context of the voice tag which is selected.
+		* @param aIndex The index of the Tag Select Data List entry to compare
+		*               the aContext with
+        * @return - ETrue if contexts match, EFalse if they do not compare
+        */
+		TBool CompareContexts(CNssContext* aContext, TInt aIndex);
+
+	private:
+
+		// Pointer to VAS Database Builder object.
+		CNssVASDBBuilder* iVasDBBuilder;
+
+		// Pointer to Database Tag Select Notifier object.
+		CNssDBTagSelectNotifier* iDBTagSelectNotifier;
+
+		// Pointer to Tag Select Data List object.
+		CArrayPtrFlat<CNssTagSelectData>* iTagSelectDataList;
+
+};
+
+#endif // CNSSTAGSELECTNOTIFICATION_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/src/nssvascadaptationitem.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CNssAdaptationItem handles speaker adaptation.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvascadaptationitem.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNssAdaptationItem::CNssAdaptationItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssAdaptationItem::CNssAdaptationItem(
+    CNssRecognitionHandler* aRecHandlerHost,
+    CSIClientResultSet*  aRecResult)
+
+ :  iRecHandler( aRecHandlerHost ),
+    iIsActive  ( ETrue ),
+    iAdaptationData( aRecResult )
+
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CNssAdaptationItem::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssAdaptationItem* CNssAdaptationItem::NewL( CNssRecognitionHandler* aHandler, 
+                                                       CSIClientResultSet* aResultSet )
+    {
+    if ( !aHandler || !aResultSet )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CNssAdaptationItem* self = new( ELeave ) CNssAdaptationItem( aHandler, aResultSet );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssAdaptationItem::~CNssAdaptationItem
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssAdaptationItem::~CNssAdaptationItem()
+    {
+    if ( iAdaptationData )
+        {
+        delete iAdaptationData;
+        iAdaptationData = 0;
+        }
+
+    // Announce for the host recognition handler, that we no longer exist.
+    if ( iRecHandler )
+        {
+        iRecHandler->RemoveAdaptationItem( this );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssAdaptationItem::AdaptL
+// Starts adaptation.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNssAdaptationItem::AdaptL( MNssAdaptationEventHandler* aHandler,
+                                          TInt aCorrect )
+    {
+    // This can happen, if the client has deleted the recognition handler.
+    if ( !iRecHandler )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    iRecHandler->AdaptL( aHandler, iAdaptationData, aCorrect );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssAdaptationItem::AdaptL
+// Starts adaptation based on tag
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNssAdaptationItem::AdaptL( MNssAdaptationEventHandler* aHandler,
+                                          MNssTag& aTag )
+    {
+    TInt correctIndex( KErrNotFound );
+    
+    CNssSpeechItem* speechItem = static_cast<CNssSpeechItem*>( aTag.SpeechItem() );
+    CNssContext* context = static_cast<CNssContext*>( aTag.Context() );
+   
+    // Find the index for the correct result
+    for ( TInt iCounter = 0; iCounter < iAdaptationData->ResultCount(); iCounter++ )
+        {
+        const CSIClientResult& result = iAdaptationData->AtL( iCounter );
+        if ( ( result.GrammarID() == context->GrammarId() ) && ( result.RuleID() == speechItem->RuleID() ) )
+            {
+            correctIndex = iCounter;   
+            }
+        }
+    
+    // Leave with KErrNotFound if no match in grammar id and rule id
+    User::LeaveIfError( correctIndex );
+    
+    AdaptL( aHandler, correctIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssAdaptationItem::Disable
+// Host recognition handler calls this function, when it is destroyed.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNssAdaptationItem::Disable()
+    {
+    if ( iIsActive )
+        {
+        RUBY_DEBUG0( "CNssAdaptationItem::Disable() is active" );
+
+        delete iAdaptationData;
+        iAdaptationData = 0;
+       
+        iRecHandler = 0;
+
+        iIsActive = EFalse;
+        }
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/src/nssvascrecognitionhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1859 @@
+/*
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssRecognitionHandler class performs the recognition function.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32property.h>
+#include "nssvascoreconstant.h"
+
+#include "nssvascrecognitionhandler.h"
+#include "nssvasctagmgr.h"
+#include "nssvascadaptationitem.h"
+#include <nsssispeechrecognitionutilityobserver.h>
+
+#ifndef __WINS__
+	// for hardware
+    #include <AudioPreference.h>
+#else
+  // use default values for WINS
+  const TUint KAudioPriorityVoiceDial = 73;
+
+  const TUint KAudioPrefVocosPlayback = 0x00030001;
+  const TUint KAudioPrefVocosTrain = 0x00020001;
+  const TUint KAudioPrefVocosRecog = 0x00010001;
+#endif
+#include "nssvascdbtagselectnotifier.h"
+#include "nssvascoreconstant.h"
+#include "nssvasmrecognizeinitcompletehandler.h"
+#include "nssvascvasdbbuilder.h"
+#include "rubydebug.h"
+
+// maximal number of results that can be handled
+const TInt KMaxResults = 100;
+
+#ifdef _DEBUG
+// Used under UDEB only
+_LIT( KRecognitionHandlerPanic, "VasCNssRecognitionHandler.cpp" );
+#endif  // _DEBUG
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandler* CNssRecognitionHandler::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::NewL" );
+
+    // version of NewLC which leaves nothing on the cleanup stack
+    CNssRecognitionHandler* self=NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandler* CNssRecognitionHandler::NewLC()
+    {
+    CNssRecognitionHandler* self = new (ELeave)  CNssRecognitionHandler();
+    CleanupStack::PushL(self);
+    // push onto cleanup stack 
+    // (in case self->ConstructL leaves)
+    self->ConstructL();      // use two-stage construct
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::~CNssRecognitionHandler
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandler::~CNssRecognitionHandler()
+    {
+    RUBY_DEBUG0( "CNssRecognitionHandler::~CNssRecognitionHandler" );
+    
+    Cleanup();
+    
+    for ( TInt k( 0 ); k < iAdaptItemArray.Count(); k++ )
+        {
+        iAdaptItemArray[k]->Disable();
+        }
+    iAdaptItemArray.Close();
+    
+    CNssVASDBBuilder::RemoveInstance();  // remove iVasDBBuilder instance
+    
+    TInt state( ERecognitionFail );
+    RProperty::Get( KSINDUID, ERecognitionState, state );
+    
+    if ( state == ERecognitionStarted || state == ERecognitionSpeechEnd )
+        {
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail );
+        }
+    // Delete P&S property
+    RProperty::Delete( KSINDUID, ERecognitionState ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::RecognizeInitL
+// Method to perform initialization for the recognize funtion.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::RecognizeInitL(
+    MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+    const CArrayPtrFlat<MNssContext>& aRecognitionVocabulary,
+	TInt aMaxResults)
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::RecognizeInitL" );
+
+    MNssRecognitionHandler::TNssRecognitionResult res = EVasErrorNone;
+
+    // Vocabulary independent initialization:
+    // CSISpeechRecognitionUtility and CSIClientResultSet.
+    res = CommonRecognizeInitL( aInitCompleteHandler, aMaxResults );
+
+    if ( res != EVasErrorNone )
+        {
+        return( res );
+        }
+
+    // Agenda for vocab dependent init:
+    // 1. Get the list of global contexts from VAS DB.
+    //    The information we need is:
+    //     * Model Bank ID, which is the same for all contexts
+    //     * Grammar ID for each context
+    // 2. Load a model bank from SRS DB.
+    // 3. Load the grammars from SRS DB. Each context has one grammar.
+	if ( !iContextList )
+	    {
+		iContextList = new (ELeave) TMNssContextList(1);
+        }
+    else
+        {
+        iContextList->Reset();
+        }
+
+
+    for ( TInt k( 0 ); k < aRecognitionVocabulary.Count(); k++ )
+        {
+        CNssContext* context = ((CNssContext*)aRecognitionVocabulary[k])->CopyL();
+        CleanupStack::PushL( context );
+
+        iContextList->AppendL( context );
+
+        CleanupStack::Pop( context );
+        }
+    iContextCount = iContextList->Count();
+
+    // Check if there are tags in the contexts.
+    // If there are, load a model bank. After that, further initializations
+    // follow: Loading lexicons and grammars.
+	// Check for Tags in contexts and continue recognition
+	TRAPD( err, HandleTagCheckL() );
+
+	if ( err != KErrNone )
+	    {
+        RUBY_DEBUG0( "CNssRecognitionHandler: TRAPD HandleTagCheckL() failed" );
+		// Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+		Cleanup();
+        return EVasRecognitionInitFailed;
+	    }
+
+    return( EVasErrorNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::RecognizeInitL
+// Method to perform initialization for the recognize funtion.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::RecognizeInitL(
+		                   MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+						   TInt aMaxResults)
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::RecognizeInitL" );
+
+    MNssRecognitionHandler::TNssRecognitionResult res = EVasErrorNone;
+
+    // Vocabulary independent initialization:
+    // CSISpeechRecognitionUtility and CSIClientResultSet.
+    res = CommonRecognizeInitL( aInitCompleteHandler, aMaxResults );
+
+    if ( res != EVasErrorNone )
+        {
+        return( res );
+        }
+
+    // Agenda for vocab dependent init:
+    // 1. Get the list of global contexts from VAS DB.
+    //    The information we need is:
+    //     * Model Bank ID, which is the same for all contexts
+    //     * Grammar ID for each context
+    // 2. Load a model bank from SRS DB.
+    // 3. Load the grammars from SRS DB. Each context has one grammar.
+
+    if ( iContextList )
+        {
+        iContextList->Reset();
+        delete iContextList;
+        }
+
+	// Get Global Context List from Vas Db
+    iContextList = iContextMgr->GetGlobalContexts();
+    
+    if ( !iContextList )
+        {
+        return EVasRecognitionInitFailed;
+        }
+
+    iContextCount = iContextList->Count();
+
+
+	// Check for Tags in contexts and continue recognition
+	TRAPD( err, HandleTagCheckL() );
+
+	if ( err != KErrNone )
+	    {
+        RUBY_DEBUG0( "CNssRecognitionHandler: TRAPD HandleTagCheckL() failed" );
+
+		// Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+		Cleanup();
+        return EVasRecognitionInitFailed;
+	    }
+
+	return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::Recognize
+// Method to perform the recognize function.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::Recognize(
+                                        MNssRecognizeEventHandler* aEventHandler )
+    {
+    RUBY_DEBUG0( "CNssRecognitionHandler::Recognize" );
+    
+    if ( iRState != EVasWaitingForRecognize )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler::Recognize - Unexpected Request" );
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        return EVasUnexpectedRequest;
+        }
+    
+    iEventHandler = aEventHandler;
+	   
+    iRState = EVasWaitingForRecordStarted;
+    
+    RUBY_DEBUG0( "CNssRecognitionHandler: SRSF Record()" );
+    
+    // Asynchronous call: next expected event: ERecordStarted
+    
+    TInt errorCode = iSrsApi->Record( KNssVASRecordTime );
+    
+    if ( errorCode != KErrNone )
+        {
+        RUBY_DEBUG1( "CNssRecognitionHandler: Record Err = %d", errorCode );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        return EVasRecognitionFailed;
+        }
+    
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::PreStartSampling
+// Method to start pre-sampling before the actual recognition start.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult 
+CNssRecognitionHandler::PreStartSampling( MNssRecognizeInitCompleteHandler* aInitCompleteHandler )
+    {
+    RUBY_DEBUG0( "" ); 
+    
+    // State check
+    if ( iRState != EVasIdle )
+        {
+        RUBY_DEBUG0( "Unexpected Request" );
+        return EVasUnexpectedRequest;
+        }
+    
+    // Check callback
+    if ( !aInitCompleteHandler )
+        {
+        return EVasInvalidParameter;
+        }    
+    
+    iInitCompleteHandler = aInitCompleteHandler;
+    
+    if ( !iSrsApi )
+        {		
+        TRAPD( err, CreateSrfL() );
+        if ( err != KErrNone )
+            {
+            RUBY_DEBUG0( "SRS creation fails" );
+            iSrsApi = NULL;
+            Cleanup();
+            return EVasRecognitionInitFailed;
+            }    
+        }
+      
+    iSrsApi->SetAudioPriority( KAudioPriorityVoiceDial, 
+                               KAudioPrefVocosTrain, 
+                               KAudioPrefVocosPlayback, 
+                               KAudioPrefVocosRecog );               
+    
+    TInt errorCode = iSrsApi->PreStartSampling();
+    
+    if ( errorCode != KErrNone )
+        {
+        RUBY_DEBUG1( "PreStartSampling Err = %d", errorCode );
+        Cleanup();
+        return EVasRecognitionInitFailed;
+        }    
+    
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::SelectTagL
+// Method to initiate the Select Tag event.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::SelectTagL(
+															   MNssTag *aClientTag)
+    {
+    return SelectTagL( aClientTag, ETrue );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::SelectTagL
+// Method to initiate the Select Tag event.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::SelectTagL( 
+                                                            MNssTag* aClientTag, 
+                                                            TBool aNotifyHandlers )
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::SelectTagL" );
+    
+    if ( iRState != EVasWaitingForSelectTag )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler::SelectTagL - Unexpected Request" );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        
+        Cleanup();
+        return EVasUnexpectedRequest;
+        }
+    
+    if ( !aClientTag )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler: Invalid Parameter" );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        
+        Cleanup();
+        return EVasInvalidParameter;
+        }
+    
+    // Check if we want to notify GlobalContext handlers
+    if ( !aNotifyHandlers )
+        {
+        // No; just cleanup
+        Cleanup();
+        }
+    else
+        { // Yes
+        // make a copy of the client tag, aClientTag, so the client can delete it
+        CNssTag* internalTag = ((CNssTag*)aClientTag)->CopyL();
+        
+        Cleanup();
+        
+        CNssDBTagSelectNotifier *selectNotifier = iVasDBBuilder->GetTagSelectNotifier();
+        
+        selectNotifier->HandleSelection(internalTag);
+        
+        delete internalTag;
+        }
+    
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::RejectTagL
+// Method to perform Reject Tag, i.e. blacklisting.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::RejectTagL(
+						   MNssRejectTagCompleteHandler* aRejectTagCompleteHandler,
+		                   CArrayPtrFlat<MNssTag>* aClientTagList)
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::RejectTagL" );
+    
+    if ( iRState != EVasWaitingForSelectTag )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler::RejectTagL - Unexpected Request" );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 	
+        Cleanup();
+        return EVasUnexpectedRequest;
+        }
+    
+    // Begin a Loop to unload rules. A rule is contained in a tag.
+    // The unload rule requests are Asynchronous. The 
+    // loop is continued and completed in the event handler logic, 
+    // MsruoEvent(aEvent=UnloadRuleComplete).
+    // Loop through the input client tag list to build a Rule List, one rule 	
+    // for each tag. Unload the rule corresponding to each tag.
+    // iRejectTagCurrentLoopCount and iRejectTagCount control the loop.
+    
+    iRejectTagCompleteHandler = aRejectTagCompleteHandler;
+    
+    if (aClientTagList == 0)
+        {
+        // client tag list is NULL error
+        RUBY_DEBUG0( "CNssRecognitionHandler: Invalid Parm: Tag List Null" );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        return EVasInvalidParameter;
+        }
+    iRejectTagCount = aClientTagList->Count(); 
+    
+    if (iRejectTagCount == 0)
+        {
+        // tag list is empty error
+        RUBY_DEBUG0( "NssRecognitionHandler: Invalid Parm: Tag List Empty" );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        return EVasInvalidParameter;
+        }
+    
+    iRejectTagCurrentLoopCount = 0; 
+    
+    if (!iRuleList)
+        {
+        iRuleList = new (ELeave) CArrayFixFlat<TRuleEntry>(iRejectTagCount);
+        }
+    
+    TRuleEntry ruleEntry;
+    
+    for ( TInt index=0; index < iRejectTagCount; index++ )
+        {
+        CNssTag* tempTag = (CNssTag*)aClientTagList->At(index);
+        CNssSpeechItem* speechItem = (CNssSpeechItem*)tempTag->SpeechItem();
+        TUint32 ruleID = speechItem->RuleID();
+        
+        CNssContext* context = (CNssContext*)tempTag->Context();
+        TUint32 grammarID = context->GrammarId();
+        
+        ruleEntry.ruleId = ruleID; 
+        ruleEntry.grammarId = grammarID;
+        
+        iRuleList->AppendL(ruleEntry);
+        }
+    
+    // get the first iRuleList entry = 0. The rest of the entries are
+    // processed in the event handler, MsruoEvent(aEvent=UnloadRuleComplete)
+    ruleEntry = iRuleList->At(iRejectTagCurrentLoopCount);
+    TUint32 ruleID = ruleEntry.ruleId;
+    TUint32 grammarID = ruleEntry.grammarId;
+    
+    iRState = EVasWaitingForUnloadRuleComplete;
+    
+    RUBY_DEBUG0( "CNssRecognitionHandler: SRSF UnloadRule()" );
+    
+    TInt errorCode = iSrsApi->UnloadRule( (TSIGrammarID)grammarID, ruleID );
+    if ( errorCode )
+        {
+        RUBY_DEBUG1( "CNssRecognitionHandler: UnloadRule Err = %d", errorCode );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        return EVasRejectTagFailed;
+        }
+    
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::Cancel
+// Method to cancel the last recognition function.
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult CNssRecognitionHandler::Cancel()
+    {
+    RUBY_DEBUG1( "CNssRecognitionHandler::Cancel() iRState = %d", iRState );
+
+	// a Cancel request for the Idle state requires no action.	
+    if ( iRState == EVasIdle )
+        {
+		return EVasErrorNone;    
+        }
+ 
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+
+	// for all states except Idle call Cleanup which calls SRF cancel and 
+	// transitions to Idle state.
+    Cleanup();
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::GetAdaptationItemL
+// Method to get the adaptation data.
+// -----------------------------------------------------------------------------
+//
+MNssAdaptationItem* CNssRecognitionHandler::GetAdaptationItemL(void)
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::GetAdaptationItemL" );
+	
+    // Check state
+	if ( iRState != EVasWaitingForSelectTag )
+    	{
+        User::Leave( KErrNotReady );
+    	}
+
+    // Client Result Set should be there since the state is what it is.
+    if ( !iSIClientResultSet )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    // Construct adaptation item
+    CNssAdaptationItem* adaptationItem = CNssAdaptationItem::NewL( this, iSIClientResultSet );
+    // Adaptation item now owns the previous Client Result Set.
+    iSIClientResultSet = 0; 
+
+    // Add the item to our catalog of adaptation items.
+    CleanupStack::PushL( adaptationItem );
+    User::LeaveIfError( iAdaptItemArray.Append( adaptationItem ) );
+    CleanupStack::Pop( adaptationItem );
+
+    return( adaptationItem );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::GetAdaptationItemL
+// Method to get the adaptation data.
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::RemoveAdaptationItem(CNssAdaptationItem* anItem)
+    {
+    for ( TInt k( 0 ); k < iAdaptItemArray.Count(); k++ )
+        {
+        if ( iAdaptItemArray[k] == anItem )
+            {
+            iAdaptItemArray.Remove( k );
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::MsruoEvent
+// Method to process the events from SRS utility object
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::MsruoEvent( TUid aEvent, TInt aResult )
+    {
+    RUBY_DEBUG2( "CNssRecognitionHandler::MsruoEvent Event = 0x%x, Result = %d", aEvent.iUid, aResult );
+
+    switch ( aEvent.iUid )
+        {
+        case KUidAsrEventLoadModelsVal:
+            {
+            if (aResult == KErrNone)
+                {
+                DoLoadModelsComplete();
+                }
+            else
+                {
+                DoLoadModelsFailed();
+                }
+            break;
+            }
+            
+        case KUidAsrEventLoadGrammarVal:
+            {
+            if (aResult == KErrNone)
+                {
+                DoLoadGrammarComplete();
+                }
+            else
+                {
+                DoLoadGrammarFailed();
+                }
+            break;
+            }	
+        case KUidAsrEventRecognitionReadyVal:
+            {
+            if (aResult == KErrNone)
+                {
+                DoRecognitionReady();                
+                }
+            else
+                {
+                DoRecognitionFailed();
+                }
+            break;
+            }	
+        case KUidAsrEventRecognitionVal:
+            {
+            
+            if (aResult == KErrNone)
+                {
+                DoRecognitionComplete();
+                }
+            else if ((aResult == KErrAsrNoSpeech) ||
+                (aResult == KErrAsrSpeechTooEarly) ||
+                (aResult == KErrAsrSpeechTooLong) ||
+                (aResult == KErrAsrSpeechTooShort))
+                {
+                DoRecognitionFailedNoSpeech(aResult);
+                }
+            else if (aResult == KErrAsrNoMatch)
+                {
+                DoRecognitionFailedNoMatch();
+                }
+            // Handle Cancelled the same as Failed
+            else
+                {
+                DoRecognitionFailed();
+                }
+            break;
+            }	
+        case KUidAsrEventRecordStartedVal:
+            {
+            DoRecordStarted();
+            break;
+            }
+        case KUidAsrEventRecordVal:
+            {
+            if (aResult != KErrNone)
+                {
+                DoRecordFailed(aResult);
+                }
+            // ignore Record KErrNone
+            break;
+            }
+        case KUidAsrEventEouDetectedVal:
+            {
+            DoEouDetected();
+            break;
+            }
+            
+        case KUidAsrEventUnloadRuleVal:
+            {
+            if (aResult == KErrNone)
+                {
+                DoUnloadRuleComplete();
+                }
+            else
+                {
+                DoUnloadRuleFailed();
+                }
+            break;
+            }	
+            
+        case KUidAsrEventAdaptVal:
+            {
+            if ( iRState != EVasDirectAdaptation && iRState != EVasIdleAdaptation )
+                {
+#ifdef _DEBUG
+                User::Panic( KRecognitionHandlerPanic, __LINE__ );
+#endif
+                return;
+                }
+            
+            if ( iRState == EVasIdleAdaptation )
+                {
+                Cleanup();
+                }
+            
+            if ( aResult == KErrNone )
+                {
+                iAdaptationHandler->HandleAdaptComplete( KErrNone );
+                }
+            else{
+                iAdaptationHandler->HandleAdaptComplete( KErrGeneral );
+                }
+            iRState = EVasWaitingForSelectTag;
+            break;
+            }
+            
+        case KUidAsrEventRemoveRuleVal:
+            {
+            if ( iRState == EVasCorrectingPluginDatabase )
+                {
+                if ( iWait.IsStarted() )
+                    {
+                    iWait.AsyncStop();
+                    }
+                }
+            else
+                {
+                Cleanup();
+                }
+            break;
+            }
+            
+        case KUidAsrEventPreStartSamplingVal:
+            {
+            DoPreStartSamplingComplete( aResult );
+            break;
+            }     
+               
+        default:
+            {
+            UnexpectedEvent();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::CNssRecognitionHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandler::CNssRecognitionHandler()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::ConstructL" );
+    iVasDBBuilder = CNssVASDBBuilder::InstanceL();
+    iVasDBBuilder->InitializeL();
+    
+    iContextMgr = iVasDBBuilder->GetContextMgr();
+    
+    iTagMgr = iVasDBBuilder->GetTagMgr();
+    
+    iRState = EVasIdle;
+    
+    // Define P&S property
+    TInt err = RProperty::Define( KSINDUID, ERecognitionState, RProperty::EInt); 
+    if ( err != KErrNotFound && err != KErrAlreadyExists )
+        {
+        User::LeaveIfError( err );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::CleanupRecognizeInitFailed
+// Perform required cleanup to get back to the Idle state and issue the
+// HandleRecognizeInitError event with RecognizeInitFailed error code
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::CleanupRecognizeInitFailed()
+    {
+    RUBY_DEBUG0( "CNssRecognitionHandler::CleanupRecognizeInitFailed" );
+    
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+    
+    Cleanup();
+    iInitCompleteHandler->HandleRecognizeInitComplete(
+        MNssRecognizeInitCompleteHandler::EVasRecognizeInitFailed );
+    }	
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::CleanupRecognizeFailed
+// Perform required cleanup to get back to the Idle state and issue the
+// HandleRecognizeError event with RecognizeFailed error code
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::CleanupRecognizeFailed()
+    {
+    RUBY_DEBUG0( "CNssRecognitionHandler::CleanupRecognizeFailed" );
+    
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+    
+    Cleanup();
+    iEventHandler->HandleRecognizeComplete( NULL,
+        MNssRecognizeEventHandler::EVasRecognizeFailed);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::CleanupRejectTagFailed
+// Perform required cleanup to get back to the Idle state and issue the
+// HandleRejectTagError event with RejectTagFailed error code
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::CleanupRejectTagFailed()
+    {
+    RUBY_DEBUG0( "CNssRecognitionHandler::CleanupRejectTagFailed" );
+    
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 	
+    
+    Cleanup();
+    iRejectTagCompleteHandler->HandleRejectTagComplete(
+        MNssRejectTagCompleteHandler::EVasRejectTagFailed);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::Cleanup
+// Perform required cleanup to get back to the Idle state
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::Cleanup()
+    {
+    RUBY_DEBUG0( "CNssRecognitionHandler::Cleanup" );
+    
+    if ( iTagMgr )
+        {
+        iTagMgr->CancelGetTag();
+        }
+    if ( iContextMgr )
+        {
+        iContextMgr->CancelGetContext();
+        }
+    DeleteSrf();
+    ClearContextList();
+    ClearTagList();
+    ClearRuleList();
+    ClearContextStatus();
+    
+    iRState = EVasIdle;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler:: DeleteSrf
+// Gracefully terminate and delete the SRF object, iSrsApi.
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DeleteSrf()
+    {
+    if ( iSrsApi )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler::DeleteSrf" );
+        
+        iSrsApi->CancelUtility();
+        
+        iSrsApi->EndRecSession();  // no need to check return code
+        
+        iSrsApi->SetEventHandler(NULL);
+        
+        delete iSrsApi;
+        
+        iSrsApi=NULL;
+        }
+
+    if ( iSIClientResultSet )
+        {
+        delete iSIClientResultSet;
+        iSIClientResultSet = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::ClearContextList
+// Delete the context objects from iContextList
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::ClearContextList()
+    {
+    if (iContextList)
+        {
+        iContextList->ResetAndDestroy();
+        delete iContextList;
+        iContextList = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::ClearTagList
+// Delete the tag objects and tag list, iTagList
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::ClearTagList()
+    {
+    // The client deletes iTagList, its pointers,  and its tags
+    // There is a window in RecognitionComplete while looping
+    // through the ClientResultData and getting corresponding tags from
+    // VasDb (GetTag). If a VasDb error occurs during this loop, 
+    // Recognition still owns the iTagList tags and must delete them.
+    // Otherwise at the end of the GetTag loop the list is given to the
+    // client, and the client deletes the tags.
+    
+    // if iTagList is not NULL, delete iTagList and its tags.
+    
+    if ( iTagList )
+        {
+        iTagList->ResetAndDestroy();
+        delete iTagList;
+        iTagList = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::ClearRuleList
+// Delete the TRuleEntry objects from iRuleList
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::ClearRuleList()
+    {
+    if ( iRuleList )
+        {
+        iRuleList->Reset();
+        delete iRuleList;
+        iRuleList = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::ClearContextStatus
+// Delete the entries from iContextStatus
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::ClearContextStatus()
+    {
+    if ( iContextStatus )
+        {
+        iContextStatus->Reset();
+        delete iContextStatus;
+        iContextStatus = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::UnexpectedEvent
+// Unexpected event occurred. . 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::UnexpectedEvent()
+    {
+    RUBY_DEBUG1( "CNssRecognitionHandler - UnexpectedEvent() iRState = %d", iRState );
+    
+    switch ( iRState )
+        {
+        case EVasIdle:
+            {
+            RUBY_DEBUG0( "CNssRecognitionHandler - Idle, Unexpected Srs Event" );
+            break;
+            }
+            
+            // RecognitionInit
+        case EVasWaitingForLoadModelsComplete:
+        case EVasWaitingForLoadLexiconComplete:
+        case EVasWaitingForLoadGrammarComplete:
+        case EVasWaitingForRecognitionReadyRecognitionInit:
+            {
+            CleanupRecognizeInitFailed();
+            break;
+            }
+            
+            // Recognition
+        case EVasWaitingForRecordStarted:
+        case EVasWaitingForEouDetected:
+        case EVasWaitingForRecognitionComplete:
+            {
+            CleanupRecognizeFailed();
+            break;
+            }
+            
+            // RejectTag
+        case EVasWaitingForUnloadRuleComplete:
+        case EVasWaitingForRecognitionReadyRejectTag:
+            {
+            CleanupRejectTagFailed();
+            break;
+            }
+        case EVasWaitingForRecognize:
+        case EVasWaitingForSelectTag:
+            {
+            // There is no event handler to return to.
+            // Notify P&S
+            RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 			
+            Cleanup();
+            RUBY_DEBUG1( "CNssRecognitionHandler - Invalid State = %d", iRState );
+            break;
+            }
+        default:
+            {
+            // unknown state - do not know event handler to return to
+            // Notify P&S
+            RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+            Cleanup();
+            RUBY_DEBUG1( "CNssRecognitionHandler - Unknown State = %d", iRState );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoPreStartSamplingComplete
+// Handle PreStartSampling SRSF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoPreStartSamplingComplete( TInt aError )
+    {
+    iInitCompleteHandler->HandlePreSamplingStarted( aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoLoadModelsComplete
+// Handle LoadModelsComplete SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoLoadModelsComplete()
+    {
+    if ( iRState != EVasWaitingForLoadModelsComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    /*	iRState = EVasWaitingForLoadLexiconComplete;
+    TUint32 lexiconId = iContextList->
+    At(iContextCurrentLoopCount)->LexiconId();
+      
+    TInt errorCode = iSrsApi->LoadLexicon( (TSILexiconID)lexiconId );
+    if (errorCode)
+        {
+        CleanupRecognizeInitFailed();	
+        }
+    */
+    iRState = EVasWaitingForLoadGrammarComplete;
+    
+    // iContextCurrentLoopCount is 0
+    // set loop count to -1 so Load Grammar Complete converts it back to 0
+    iContextCurrentLoopCount = -1;
+    DoLoadGrammarComplete();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoLoadModelsFailed
+// Handle LoadModelsFailed SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoLoadModelsFailed()
+    {
+    if ( iRState != EVasWaitingForLoadModelsComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    CleanupRecognizeInitFailed();	
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoLoadLexiconComplete
+// Handle LoadLexiconComplete SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoLoadLexiconComplete()
+    {
+    if ( iRState != EVasWaitingForLoadLexiconComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    iRState = EVasWaitingForLoadGrammarComplete;
+    
+    // iContextCurrentLoopCount is 0
+    // set loop count to -1 so Load Grammar Complete converts it back to 0
+    iContextCurrentLoopCount--;
+    DoLoadGrammarComplete();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoLoadLexiconFailed
+// Handle LoadLexiconFailed SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoLoadLexiconFailed()
+    {
+    if ( iRState != EVasWaitingForLoadLexiconComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    CleanupRecognizeInitFailed();			
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoLoadGrammarComplete
+// Handle LoadGrammarComplete SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoLoadGrammarComplete()
+    {
+    if ( iRState != EVasWaitingForLoadGrammarComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    // if there are more contexts, 
+    // continue loading Grammars, into the SRS
+    iContextCurrentLoopCount++;
+    
+    while ( iContextCurrentLoopCount < iContextCount )
+        {
+        TBool status = iContextStatus->At( iContextCurrentLoopCount );
+        // if True, there are tags in the context load the grammar
+        if ( status )
+            {
+            TUint32 grammarId = iContextList->
+                At( iContextCurrentLoopCount )->GrammarId();
+            TInt errorCode = iSrsApi->LoadGrammar( (TSIGrammarID) grammarId ); 
+            if ( errorCode )
+                {
+                RUBY_DEBUG1( "CNssRecognitionHandler: LoadGrammar Err = %d", errorCode );
+                CleanupRecognizeInitFailed();			
+                }
+            return;
+            }
+        
+        // else False, skip the context and go to the next
+        else
+            {
+            iContextCurrentLoopCount++;	
+            }
+        }
+    
+    // are done loading contexts;				
+    iRState = EVasWaitingForRecognitionReadyRecognitionInit;
+    
+    RUBY_DEBUG0( "CNssRecognitionHandler: SRF Recognize" );
+    
+    // Asynchronous call: next expected event:  ERecognitionReady 
+    // dereference iClientResult ptr to make it a reference 
+    TInt errorCode = iSrsApi->Recognize( *iSIClientResultSet );
+    
+    if ( errorCode ) // Check if errorCode is zero (KErrNone) or non-zero.
+        {
+        RUBY_DEBUG1( "CNssRecognitionHandler: Recognize Err = %d", errorCode );
+        CleanupRecognizeInitFailed();
+        }							
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoLoadGrammarFailed
+// Handle LoadGrammarFailed SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoLoadGrammarFailed()
+    {
+    if ( iRState != EVasWaitingForLoadGrammarComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    CleanupRecognizeInitFailed();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecognitionReady
+// Handle RecognitionReady SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecognitionReady()
+    {
+    if ( iRState == EVasWaitingForRecognitionReadyRecognitionInit )
+        {
+        ClearContextStatus();
+        iRState = EVasWaitingForRecognize;
+        
+        RUBY_DEBUG0( "CNssRecognitionHandler: HandleRecognizeInitComplete" );
+       
+        iInitCompleteHandler->HandleRecognizeInitComplete( 
+            MNssRecognizeInitCompleteHandler::EVasErrorNone );
+        }
+    else if ( iRState == EVasWaitingForRecognitionReadyRejectTag )
+        {
+        iRState = EVasWaitingForRecognize;
+        
+        RUBY_DEBUG0( "CNssRecognitionHandler: HandleRejectTagComplete" );
+        
+        iRejectTagCompleteHandler->HandleRejectTagComplete(
+            MNssRejectTagCompleteHandler::EVasErrorNone );
+        }
+    else
+        {
+        UnexpectedEvent();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecognitionComplete
+// Handle RecognitionComplete SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecognitionComplete()
+    {
+    if ( iRState != EVasWaitingForRecognitionComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    
+    TInt resultSetCount = iSIClientResultSet->ResultCount();
+    
+    // allocate the Tag List - the client is responsible for deleting this
+    if (!iTagList)
+        {
+        iTagList = new CArrayPtrFlat<CNssTag>( 1 );
+        if ( !iTagList )
+            {
+            RUBY_DEBUG0( "CNssRecognitionHandler: TRAPD new CTAG Array failed" );
+            CleanupRecognizeFailed();
+            return;
+            }		
+        }
+    
+    // Loop to convert result set data to tags and put the tags 
+    // into a Tag List
+    // Since getTag is asynchronous the loop continues at
+    // member function GetTagCompleted(). Use loop control variables:
+    // iTagCurrentLoopCount and iTagCount
+    
+    iTagCurrentLoopCount = 0;
+    iTagCount = resultSetCount;
+    /*
+    const CSDClientResult& clientResult = iClientResultSet->At(0);
+    */
+    TInt count( iSIClientResultSet->ResultCount() );
+    TInt k( 0 );
+    TInt err( KErrNone );
+    
+    for ( k = 0; k < count; k++ )
+        {
+        const CSIClientResult* clientResult( NULL );
+        TRAP( err, clientResult = &iSIClientResultSet->AtL( k ) );
+        if ( err != KErrNone )
+            {
+            break;
+            }
+        
+        // Get the tag from DB
+        CNssTag* tag = iTagMgr->GetTag( 
+            clientResult->GrammarID(),
+            clientResult->RuleID() );
+        
+        if ( !tag )
+            {
+            RUBY_DEBUG0( "CNssRecognitionHandler::DoRecognitionComplete found a tag which is NOT in VAS database" );
+            TNssRState oldState = iRState;
+            iRState = EVasCorrectingPluginDatabase;
+
+            TInt error = iSrsApi->RemoveRule( clientResult->GrammarID(), clientResult->RuleID() );
+            if ( error == KErrNone && !iWait.IsStarted() )
+                {
+                iWait.Start();
+                }
+            iRState = oldState;
+            }
+        else
+            {
+            // Append it to the "our" tag list (which will be copied
+            // to produce client tag list)
+            TRAP( err, iTagList->AppendL( tag ) );
+        
+            if ( err != KErrNone )
+                {
+                break;
+                }
+            }
+        }
+    
+    // If no tags could be found
+    if ( iTagList->Count() == 0 )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler::DoRecognitionComplete no tags found at all" );
+        // Cleans and makes the "RecognizeFailed" callback.
+        CleanupRecognizeFailed();
+        return;
+        }
+    
+    // Copy the tag list. The copy is sent to the client.
+    CArrayPtrFlat<MNssTag>* clientTagList = NULL;
+    
+    clientTagList = new CArrayPtrFlat<MNssTag>(1);
+    
+    if ( clientTagList == 0 )
+        {
+        // Cleans and makes the "RecognizeFailed" callback.
+        CleanupRecognizeFailed();
+        return;
+        }
+    
+    for ( k = 0; k < iTagList->Count(); k++ )
+        {
+        MNssTag* tag = STATIC_CAST( MNssTag*, (*iTagList)[k] );
+        
+        TRAP( err, clientTagList->AppendL( tag ) );
+        
+        if ( err != KErrNone )
+            {
+            RUBY_DEBUG0( "CRecognitionHandler: TRAPD DestList AppendL failed" );
+            
+            // Don't do the "ResetAndDestroy()" : iTagList still owns the tags.
+            clientTagList->Reset();
+            delete clientTagList;
+            
+            // Cleans and makes the "RecognizeFailed" callback.
+            CleanupRecognizeFailed();
+            return;
+            }			
+        }
+    
+    iRState = EVasWaitingForSelectTag;
+    
+    // After this, clientTagList owns the tags:
+    iTagList->Reset();
+    delete iTagList;
+    iTagList = 0;
+    
+    RUBY_DEBUG0( "CRecognitionHandler: HandleRecognizeComplete" );
+    
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionSuccess ); 
+    
+    iEventHandler->HandleRecognizeComplete(
+        clientTagList, MNssRecognizeEventHandler::EVasErrorNone );
+    
+    //    const CSIClientResult& clientResult = iSIClientResultSet->AtL(0);
+    
+    /******************** Debug recognized tags *********************/
+    /*
+    RFs session;
+    RFile file;
+    _LIT( aFileName, "c:\\documents\\recotag.txt" );
+    
+      session.Connect();
+      if ( file.Open( session, aFileName, EFileWrite ) != KErrNone )
+      {
+      if ( file.Create( session, aFileName, EFileWrite ) != KErrNone )
+      {
+      User::Panic( _L("SDContrlDebug"), __LINE__ );
+      }
+      }
+      
+        for ( TInt k( 0 ); k < iSIClientResultSet->ResultCount(); k++ )
+        {
+        const CSIClientResult& clientResult = iSIClientResultSet->AtL(k);
+        
+          TBuf8<100> debugBuf;
+          debugBuf.AppendFormat( _L8("Recognized tag with RID:%d, GID:%d\n"), clientResult.RuleID(), clientResult.GrammarID() );
+          file.Write( debugBuf );
+          }
+          
+            
+              file.Close();
+              session.Close();
+    */
+    /****************************************************************/
+    
+    // get next tag
+    /*	TUint32 grammarId = clientResult.GrammarID();
+    TUint32 ruleId = clientResult.RuleID();
+    
+      TInt dbErrorCode;
+      dbErrorCode = iTagMgr->GetTag( this, 
+      grammarId, 
+      ruleId);
+      if (dbErrorCode!=KErrNone)
+      {
+        CleanupRecognizeFailed();
+        }
+    */
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecognitionFailedNoSpeech
+// Handle RecognitionFailedNoSpeech, RecognitionFailedTooEarly, 
+// RecognitionFailedTooLong, and RecognitionFailedTooShort SRF events 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecognitionFailedNoSpeech( TInt aResult )
+    {
+    if ( iRState != EVasWaitingForRecognitionComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    
+    MNssRecognizeEventHandler::TNssRecognizeError errCode;
+    errCode = MNssRecognizeEventHandler::EVasRecognizeFailed;
+    if ( aResult == KErrAsrNoSpeech )
+        {
+        errCode = MNssRecognizeEventHandler::EVasRecognitionFailedNoSpeech;
+        }
+    else if ( aResult == KErrAsrSpeechTooEarly )
+        {
+        errCode = MNssRecognizeEventHandler::EVasRecognitionFailedTooEarly;
+        }
+    else if ( aResult == KErrAsrSpeechTooLong )
+        {
+        errCode = MNssRecognizeEventHandler::EVasRecognitionFailedTooLong;
+        }
+    else if ( aResult == KErrAsrSpeechTooShort )
+        {
+        errCode = MNssRecognizeEventHandler::EVasRecognitionFailedTooShort;
+        }
+    
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+    
+    Cleanup();
+    iEventHandler->HandleRecognizeComplete( NULL, errCode );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecognitionFailedNoMatch
+// Handle RecognitionFailedNoMatch SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecognitionFailedNoMatch()
+    {
+    if ( iRState == EVasWaitingForRecognitionReadyRecognitionInit )
+        {
+        CleanupRecognizeInitFailed();
+        }
+    else if ( iRState == EVasWaitingForRecognitionComplete )
+        {
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        iEventHandler->HandleRecognizeComplete( NULL,
+            MNssRecognizeEventHandler::EVasRecognitionFailedNoMatch );	
+        }
+    else if ( iRState == EVasWaitingForRecognitionReadyRejectTag )
+        {
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        iRejectTagCompleteHandler->HandleRejectTagComplete(
+            MNssRejectTagCompleteHandler::EVasNoTagInContexts);
+        }
+    else
+        {
+        UnexpectedEvent();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecognitionFailed
+// Handle RecognitionFailed SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecognitionFailed()
+    {
+    switch ( iRState )
+        {
+        case EVasWaitingForRecognitionReadyRecognitionInit:
+            {
+            CleanupRecognizeInitFailed();
+            break;
+            }
+        case EVasWaitingForRecordStarted:
+        case EVasWaitingForEouDetected:
+        case EVasWaitingForRecognitionComplete:
+            {
+            CleanupRecognizeFailed();
+            break;
+            }
+        case EVasWaitingForRecognitionReadyRejectTag:
+            {
+            CleanupRejectTagFailed();
+            break;
+            }
+        default:
+            {
+            UnexpectedEvent();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecordStarted
+// Handle RecordStarted SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecordStarted()
+    {
+    if ( iRState != EVasWaitingForRecordStarted )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    iRState = EVasWaitingForEouDetected;
+    
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionStarted ); 
+    
+    iEventHandler->HandleRecordStarted(); 
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoRecordFailed
+// Handle RecordFailed SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoRecordFailed( TInt aResult )
+    {
+    if ( iRState != EVasWaitingForEouDetected )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    if ( ( aResult == KErrDied ) ||
+        ( aResult == KErrAccessDenied ) )
+        {
+        
+        Cleanup();
+        iEventHandler->HandleRecognizeComplete( NULL,
+            MNssRecognizeEventHandler::EVasRecognizeAccessDeny );
+        }
+    else
+        {
+        CleanupRecognizeFailed();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoEouDetected
+// Handle EouDetected SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoEouDetected()
+    {
+    if ( iRState != EVasWaitingForEouDetected )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    iRState = EVasWaitingForRecognitionComplete;
+    // Notify P&S
+    RProperty::Set( KSINDUID, ERecognitionState, ERecognitionSpeechEnd ); 
+    
+    iEventHandler->HandleEouDetected();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoUnloadRuleComplete
+// Handle UnloadRuleComplete SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoUnloadRuleComplete()
+    {
+    if ( iRState != EVasWaitingForUnloadRuleComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    // if there are more tags
+    // continue unloading rules, from the SRS
+    iRejectTagCurrentLoopCount++;
+    if ( iRejectTagCurrentLoopCount < iRejectTagCount )
+        {
+        TRuleEntry ruleEntry = iRuleList->At( iRejectTagCurrentLoopCount );
+        TUint32 ruleID = ruleEntry.ruleId;
+        TUint32 grammarID = ruleEntry.grammarId;
+        
+        RUBY_DEBUG0( "CNssRecognitionHandler: SRF UnloadRule" );
+        
+        TInt errorCode = iSrsApi->UnloadRule( (TSIGrammarID)grammarID, ruleID );
+        if ( errorCode )
+            {
+            RUBY_DEBUG1( "CNssRecognitionHandler: UnloadRule Err = %d", errorCode );
+
+            CleanupRejectTagFailed();
+            }
+        }
+    else
+        {
+        ClearRuleList();
+        iRState = EVasWaitingForRecognitionReadyRejectTag;
+        
+        RUBY_DEBUG0( "CNssRecognitionHandler: SRF Recognize" );
+        
+        // dereference iClientResult ptr to make it a reference 
+        //TInt errorCode = iSrsApi->Recognize(*iClientResultSet);
+        TInt errorCode = iSrsApi->Recognize( *iSIClientResultSet );
+        if ( errorCode )
+            {
+            RUBY_DEBUG1( "CNssRecognitionHandler: Recognize Err = %d", errorCode );
+           
+            CleanupRejectTagFailed();
+            }	
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::DoUnloadRuleFailed
+// Handle UnloadRuleFailed SRF event 
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::DoUnloadRuleFailed()
+    {
+    ClearRuleList();
+    if ( iRState != EVasWaitingForUnloadRuleComplete )
+        {
+        UnexpectedEvent();
+        return;
+        }
+    CleanupRejectTagFailed();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::HandleTagCheckL
+// Loop through the contexts to build the ContextStatus array.
+// If there are any tags in any context,
+// Then proceed on with recognition and load models,
+// Else return with EVasNoTagInContexts.
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::HandleTagCheckL()
+    {
+    TBool anyTag = EFalse;
+    CNssContext* context;
+    
+    if ( !iContextStatus )
+        {
+        iContextStatus = new (ELeave) CArrayFixFlat<TBool>( iContextCount );
+        }
+    
+    __ASSERT_DEBUG( iContextCount == iContextList->Count(), User::Panic( KRecognitionHandlerPanic, __LINE__ ) );
+    
+    for ( TInt index=0; index < iContextCount; index++ )
+        {
+        context = iContextList->At( index );
+        // if a tag exists in the requested context, status is set to true
+        // if there are no tags in the requested context, status is set to false
+        TBool status = iContextMgr->TagExist( context );
+        
+        iContextStatus->AppendL( status );
+        if ( status )
+            {
+            // if a tag is found, set to True
+            anyTag = ETrue;
+            }
+        }
+    
+    if ( anyTag )
+        {
+        // True: there are tags, continue recognition
+        iRState = EVasWaitingForLoadModelsComplete;
+        
+        TUint32 modelBankID = iContextList->At( 0 )->ModelBankId();
+        TInt errorCode = iSrsApi->LoadModels( (TSIModelBankID)modelBankID ); 
+        if ( errorCode )
+            {
+            RUBY_DEBUG1( "CNssRecognitionHandler: LoadModels Err = %d", errorCode );
+            
+            CleanupRecognizeInitFailed();
+            }
+        }
+    else
+        {
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        // False: There are no tags in any context.
+        Cleanup();
+        iInitCompleteHandler->HandleRecognizeInitComplete(
+            MNssRecognizeInitCompleteHandler::EVasNoTagInContexts );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::CreateSrfL
+// Create the SRF object, iSrsApi.
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::CreateSrfL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::CreateSrfL" );
+    // passing the CNssRecognitionHandler object as an active event handler
+    // and passing the VAS Api's UID
+    iSrsApi	= CNssSiUtilityWrapper::NewL(*this, KNssVASApiUid);
+    }
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandler::AdaptL
+// Starts adaptation. Called by MNssAdaptationItem.
+// -----------------------------------------------------------------------------
+//
+void CNssRecognitionHandler::AdaptL( MNssAdaptationEventHandler* aHandler,
+                                     CSIClientResultSet* aResult,
+                                     TInt aCorrect )
+    {
+    RUBY_DEBUG_BLOCK( "CNssRecognitionHandler::AdaptL" );
+    
+    if ( !aHandler || !aResult )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    // We can do an adaptation either
+    //  * directly after a recognition (direct adaptation), or
+    //  * when the state is idle (idle adaptation).
+    // In IDLE   Adaptation: We need to create and destroy SRS Utility object.
+    // In DIRECT Adaptation: We need to return to the same state where we left.
+    
+    if ( iRState == EVasIdle )
+        {
+        iRState = EVasIdleAdaptation;
+        
+        CreateSrfL();
+        
+        User::LeaveIfError( iSrsApi->Adapt( *aResult, aCorrect ) );
+        }
+    else if ( iRState == EVasWaitingForSelectTag )
+        {
+        iRState = EVasDirectAdaptation;
+        
+        if ( !iSrsApi )
+            {
+            User::Leave( KErrNotReady );
+            }
+        
+        User::LeaveIfError( iSrsApi->Adapt( *aResult, aCorrect ) );
+        }
+    else
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    iAdaptationHandler = aHandler;
+    }
+
+// -----------------------------------------------------------------------
+// CNssRecognitionHandler::CommonRecognizeInitL
+//
+// Called by RecognizeInitL -variants
+// to perform those initializations,
+// which do not depend on vocabulary.
+// -----------------------------------------------------------------------
+//
+MNssRecognitionHandler::TNssRecognitionResult
+CNssRecognitionHandler::CommonRecognizeInitL( 
+                    MNssRecognizeInitCompleteHandler* aInitCompleteHandler,
+                    TInt aMaxResults )
+    {
+    // Agenda:
+    // 1. Create CSISpeechRecognitoinUtility object
+    //
+    // 2. Call SetPrioritySettings & StartRecSession
+    //    - nothing interesting happens there
+    //
+    // 4. Initialize CSIClientResultSet for storing recongition results
+    //
+    if ( iRState != EVasIdle )
+        {
+        RUBY_DEBUG0( "CNssRecognitionHandler::RecognizeInitL - Unexpected Request" );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        Cleanup();
+        return EVasUnexpectedRequest;
+        }
+    
+    // Check callback
+    if ( !aInitCompleteHandler )
+        {
+        return EVasInvalidParameter;
+        }
+    iInitCompleteHandler = aInitCompleteHandler;
+    
+    // Check that aMaxResults is reasonable (100 is an arbitrary limit)
+    if ( aMaxResults < 0 || aMaxResults > KMaxResults )
+        {
+        return EVasInvalidParameter; 
+        }
+    iMaxResults = aMaxResults;
+    
+    if ( !iSrsApi )
+        {		
+        // Put a trap in case instantiation of SRF leaves
+        TRAPD( err, CreateSrfL() );
+        if ( err != KErrNone )
+            {
+            RUBY_DEBUG0( "CNssRecognitionHandler::RecognizeInitL - create SRS fail" );
+            
+            iSrsApi = NULL;     // For clean up purpose
+            
+            // Notify P&S
+            RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+            
+            Cleanup();
+            return EVasRecognitionInitFailed;
+            }
+        }
+    
+    // Set audio priority. If some other application wants to play/record
+    // while we are recognizing, these priorities determine who gets the access.
+    iSrsApi->SetAudioPriority( KAudioPriorityVoiceDial, 
+                               KAudioPrefVocosTrain, 
+                               KAudioPrefVocosPlayback, 
+                               KAudioPrefVocosRecog );
+    
+    // speaker independent mode recognition session
+    TInt errorCode = iSrsApi->StartRecSession( ENSSSiMode );
+    
+    if ( errorCode != KErrNone )
+        {
+        RUBY_DEBUG1( "CNssRecognitionHandler: StartRecSession Err = %d", errorCode );
+
+        // Notify P&S
+        RProperty::Set( KSINDUID, ERecognitionState, ERecognitionFail ); 
+        
+        Cleanup();
+        return EVasRecognitionInitFailed;
+        }
+    
+    // Create the structure for recognition results
+    if ( !iSIClientResultSet )
+        {
+        iSIClientResultSet = CSIClientResultSet::NewL();
+        }
+    iSIClientResultSet->SetMaxResultsL( iMaxResults );
+    
+    return EVasErrorNone;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/src/nssvascrecognitionhandlerbuilder.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssRecognitionHandlerBuilder class performs initialization 
+*                for CNssRecognitionHandler the  class. 
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvascrecognitionhandlerbuilder.h"
+#include "nssvascrecognitionhandler.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssRecognitionHandlerBuilder* CNssRecognitionHandlerBuilder::NewL()
+{
+	// version of NewLC which leaves nothing on the cleanup stack
+	CNssRecognitionHandlerBuilder* self=NewLC();
+	CleanupStack::Pop(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssRecognitionHandlerBuilder* CNssRecognitionHandlerBuilder::NewLC()
+{
+	CNssRecognitionHandlerBuilder* self = new (ELeave) CNssRecognitionHandlerBuilder();
+    CleanupStack::PushL(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::~CNssRecognitionHandlerBuilder
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandlerBuilder::~CNssRecognitionHandlerBuilder()
+{
+	delete iRecognitionHandler;
+}
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::InitializeL
+// Initialize Recognition Handler
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNssRecognitionHandlerBuilder::InitializeL()
+{
+	iRecognitionHandler = CNssRecognitionHandler::NewL();
+}
+			
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::GetRecognitionHandler
+// Get a Pointer to Recognition Handler
+// -----------------------------------------------------------------------------
+//
+EXPORT_C MNssRecognitionHandler* CNssRecognitionHandlerBuilder::GetRecognitionHandler()
+{
+	return iRecognitionHandler;
+}
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::CNssRecognitionHandlerBuilder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandlerBuilder::CNssRecognitionHandlerBuilder()
+{
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/src/nssvascselectnotificationbuilder.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssSelectNotificationBuilder class performs initialization 
+*                for the CNssTagSelectNotification class. 
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "nssvascselectnotificationbuilder.h"
+#include "nssvasctagselectnotification.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNssSelectNotificationBuilder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssSelectNotificationBuilder* CNssSelectNotificationBuilder::NewL()
+{
+	// version of NewLC which leaves nothing on the cleanup stack
+	CNssSelectNotificationBuilder* self=NewLC();
+	CleanupStack::Pop(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CNssRecognitionHandlerBuilder::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssSelectNotificationBuilder* CNssSelectNotificationBuilder::NewLC()
+{
+    CNssSelectNotificationBuilder* self=new (ELeave) CNssSelectNotificationBuilder();
+    CleanupStack::PushL(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CNssSelectNotificationBuilder::~CNssSelectNotificationBuilder
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssSelectNotificationBuilder::~CNssSelectNotificationBuilder()
+{
+	delete iTagSelectNotification;
+}
+
+// -----------------------------------------------------------------------------
+// CNssSelectNotificationBuilder::InitializeL
+// Initialize Tag Select Notification
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CNssSelectNotificationBuilder::InitializeL()
+{
+	iTagSelectNotification = CNssTagSelectNotification::NewL();
+}
+
+// -----------------------------------------------------------------------------
+// CNssSelectNotificationBuilder::GetTagSelectNotification
+// Get a Pointer to CNssTagSelectNotification
+// -----------------------------------------------------------------------------
+//
+EXPORT_C MNssTagSelectNotification* 
+			              CNssSelectNotificationBuilder::GetTagSelectNotification()
+{
+	return iTagSelectNotification;
+}
+
+// -----------------------------------------------------------------------------
+// CNssSelectNotificationBuilder::CNssSelectNotificationBuilder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssSelectNotificationBuilder::CNssSelectNotificationBuilder()
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/src/nssvasctagselectdata.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssTagSelectData Class contains the data for tag select 
+*                notification.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasctagselectdata.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectData* CNssTagSelectData::NewL(CNssContext* aContext, 
+								     MNssTagSelectHandler* aTagSelectHandler)
+{
+	// version of NewLC which leaves nothing on the cleanup stack
+	CNssTagSelectData* self=NewLC(aContext, 
+							   aTagSelectHandler);
+	CleanupStack::Pop(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectData* CNssTagSelectData::NewLC(CNssContext* aContext, 
+								      MNssTagSelectHandler* aTagSelectHandler)
+{
+    CNssTagSelectData* self=new (ELeave) CNssTagSelectData();
+    // get new, leave if can't
+    CleanupStack::PushL(self);
+    // push onto cleanup stack
+    // (in case self->ConstructL leaves)
+    self->ConstructL(aContext, 
+				     aTagSelectHandler); // use two-stage construct
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::~CNssTagSelectData
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectData::~CNssTagSelectData()
+{
+	delete iContext;
+}
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::Context
+// Member function to get a pointer to the context.
+// -----------------------------------------------------------------------------
+//
+CNssContext* CNssTagSelectData::Context()
+{
+	return iContext;
+}
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::TagSelectHandler
+// Member function to get a pointer the TagSelectHandler event handler.
+// -----------------------------------------------------------------------------
+//
+MNssTagSelectHandler* CNssTagSelectData::TagSelectHandler()
+{
+	return iTagSelectHandler;
+}
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::CNssTagSelectData
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectData::CNssTagSelectData()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectData::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssTagSelectData::ConstructL(CNssContext* aContext, 
+								MNssTagSelectHandler* aTagSelectHandler)
+{	
+	iContext = aContext->CopyL();     // create a new context and make a copy
+
+    iTagSelectHandler = aTagSelectHandler;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvasapi/nssvasrecognition/src/nssvasctagselectnotification.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The CNssTagSelectNotification class allows the client to
+*               register and deregister for a voice tag select event. 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "nssvasctagselectnotification.h"
+#include "nssvasmtagselecthandler.h"
+#include "nssvasctagselectdata.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectNotification* CNssTagSelectNotification::NewL()
+    {
+    // version of NewLC which leaves nothing on the cleanup stack
+    CNssTagSelectNotification* self=NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectNotification* CNssTagSelectNotification::NewLC()
+    {
+    // NewLC with two stage construct
+    CNssTagSelectNotification* self=new (ELeave) CNssTagSelectNotification();
+    // get new, leave if can't
+    CleanupStack::PushL(self);
+    // push onto cleanup stack
+    // (in case self->ConstructL leaves)
+    self->ConstructL();      // use two-stage construct
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::~CNssTagSelectNotification
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectNotification::~CNssTagSelectNotification()
+    {
+    RUBY_DEBUG0( "CNssTagSelectNotification::~CNssTagSelectNotification" );
+    
+    if ( iDBTagSelectNotifier ) 
+        {
+        iDBTagSelectNotifier->Deregister( this );
+        }
+    
+    if ( iTagSelectDataList )
+        {
+        iTagSelectDataList->ResetAndDestroy();
+        delete iTagSelectDataList;
+        }
+    CNssVASDBBuilder::RemoveInstance();  // remove iVasDBBuilder instance
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::RegisterL
+// Method to register for voice tag select notification.
+// -----------------------------------------------------------------------------
+//
+MNssTagSelectNotification::TNssSelectResult CNssTagSelectNotification::RegisterL(
+                                         MNssContext* aContext,
+                                         MNssTagSelectHandler* aTagSelectHandler )
+    {
+    RUBY_DEBUG_BLOCK( "CNssTagSelectNotification::RegisterL" );
+    
+    if ( iTagSelectDataList->Count() == 0 )
+        {
+        // register ourself
+        TInt dbErrorCode;
+        dbErrorCode = iDBTagSelectNotifier->RegisterForNotification( this );
+        if ( dbErrorCode != KErrNone )
+            {
+            return EVasSelectFailed;
+            }
+        }
+    CNssTagSelectData* tagSelectData = CNssTagSelectData::NewL( (CNssContext *) aContext,
+        aTagSelectHandler );
+    
+    CleanupStack::PushL(tagSelectData);  
+    iTagSelectDataList->AppendL( tagSelectData );
+    CleanupStack::Pop(tagSelectData);  // do not destroy tagSelectData; it is appended
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::Deregister
+// Method to deregister from voice tag select notification
+// -----------------------------------------------------------------------------
+//
+MNssTagSelectNotification::TNssSelectResult CNssTagSelectNotification::Deregister(
+                                          MNssContext* aContext,
+                                          MNssTagSelectHandler* aTagSelectHandler )
+    {
+    RUBY_DEBUG0( "CNssTagSelectNotification::Deregister" );
+   
+    // if there is no registration, fail the deregister
+    if ( iTagSelectDataList->Count() == 0 )
+        {
+        return EVasSelectFailed;
+        }
+    
+    // loop through the TagSelectDataList entries
+    // for each context match, check if the event handler also matches
+    // if yes, delete the entry
+    for ( TInt index=0; index < iTagSelectDataList->Count(); index++ )
+        {
+        
+        TBool match = CompareContexts( (CNssContext *) aContext, index );
+        
+        MNssTagSelectHandler* tagSelectHandler;
+        tagSelectHandler = iTagSelectDataList->At( index )->TagSelectHandler();
+        
+        if ( ( match == (TInt)ETrue ) &&
+            (aTagSelectHandler == tagSelectHandler))	
+            {
+            CNssTagSelectData* tagSelectData = iTagSelectDataList->At( index ); 
+            iTagSelectDataList->Delete( index ); 
+            delete tagSelectData;
+            break;  // exit the for loop
+            }
+        }
+    if ( iTagSelectDataList->Count() == 0 )
+        {
+        // deregister ourself
+        TInt dbErrorCode;
+        dbErrorCode = iDBTagSelectNotifier->Deregister( this );
+        if ( dbErrorCode != KErrNone )
+            {
+            RUBY_DEBUG0( "CNssTagSelectNotification, DBTagSelectNotifier->Deregister failed" );
+            }
+        }
+    return EVasErrorNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::HandleSelection
+// Method called into the client by CNssDBTagSelectNotifier
+// -----------------------------------------------------------------------------
+//
+void CNssTagSelectNotification::HandleSelection(CNssTag* aTag)
+    {
+    RUBY_DEBUG0( "CNssTagSelectNotification::HandleSelection" );
+
+    // loop through the TagSelectDataList entries
+    // for each context match, issue a HandleTagSelect response event
+    for ( TInt index=0; index < iTagSelectDataList->Count(); index++ )
+        {
+        TBool result = CompareContexts((CNssContext *)(aTag->Context()), index);
+        if ( result == (TInt)ETrue )
+            {
+            // make a copy of the tag for each client which registered for
+            // the context of aTag
+            // the client is responsible for deleting clientTag
+            CNssTag* clientTag=NULL; 
+            TRAPD( err, ( clientTag = aTag->CopyL() ) );
+            if ( err != KErrNone )
+                {
+                RUBY_DEBUG0( "CNssTagSelectNotification: TRAPD CNssTag CopyL failed" );
+                return;
+                }
+            
+            iTagSelectDataList->At( index )->TagSelectHandler()->
+                HandleTagSelect( (MNssTag*)clientTag );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::CNssTagSelectNotification
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssTagSelectNotification::CNssTagSelectNotification()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssTagSelectNotification::ConstructL()
+    {	
+    iTagSelectDataList = new (ELeave) CArrayPtrFlat<CNssTagSelectData>(1);
+    
+    iVasDBBuilder = CNssVASDBBuilder::InstanceL();
+    
+    iDBTagSelectNotifier = iVasDBBuilder->GetTagSelectNotifier();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssTagSelectNotification::CompareContexts
+// Method to compare a context with a TagSelectDataList entry context.
+// -----------------------------------------------------------------------------
+//
+TBool CNssTagSelectNotification::CompareContexts( CNssContext* aContext, TInt aIndex )
+    {
+    CNssContext* context;
+    context = iTagSelectDataList->At( aIndex )->Context();
+    
+    if ( context->ContextName().Compare( aContext->ContextName() )==0 )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/bmarm/nssvascontacthdlru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,6 @@
+EXPORTS
+	DisableEventHandling__18CNssContactHandler @ 1 NONAME R3UNUSED ; CNssContactHandler::DisableEventHandling(void)
+	EnableEventHandling__18CNssContactHandler @ 2 NONAME R3UNUSED ; CNssContactHandler::EnableEventHandling(void)
+	NewL__18CNssContactHandler @ 3 NONAME R3UNUSED ; CNssContactHandler::NewL(void)
+	"_._18CNssContactHandler" @ 4 NONAME R3UNUSED ; CNssContactHandler::~CNssContactHandler(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/bwins/nssvascontacthdlru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,6 @@
+EXPORTS
+	??1CNssContactHandler@@UAE@XZ @ 1 NONAME ; CNssContactHandler::~CNssContactHandler(void)
+	?DisableEventHandling@CNssContactHandler@@QAEXXZ @ 2 NONAME ; void CNssContactHandler::DisableEventHandling(void)
+	?EnableEventHandling@CNssContactHandler@@QAEXXZ @ 3 NONAME ; void CNssContactHandler::EnableEventHandling(void)
+	?NewL@CNssContactHandler@@SAPAV1@XZ @ 4 NONAME ; class CNssContactHandler * CNssContactHandler::NewL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/data/nssvascontacthandler.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localized resource file of SINDE commands
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME COHA
+
+//  INCLUDES
+#include <sindextensioncommands.loc>
+#include <badef.rh>
+#include <uikon.rh>
+
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// Extensions for name dialling
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE LBUF r_sind_extension_mobile  { txt = qan_sind_extension_mobile; }
+RESOURCE LBUF r_sind_extension_general  { txt = qan_sind_extension_general; }
+RESOURCE LBUF r_sind_extension_home  { txt = qan_sind_extension_home; }
+RESOURCE LBUF r_sind_extension_work  { txt = qan_sind_extension_work; }
+RESOURCE LBUF r_sind_extension_video  { txt = qan_sind_extension_video; }
+RESOURCE LBUF r_sind_extension_message  { txt = qan_sind_extension_message; }
+RESOURCE LBUF r_sind_extension_email  { txt = qan_sind_extension_email; }
+RESOURCE LBUF r_sind_extension_voip  { txt =qan_sind_extension_voip; }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/eabi/nssvascontacthdlru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,10 @@
+EXPORTS
+	_ZN18CNssContactHandler19EnableEventHandlingEv @ 1 NONAME
+	_ZN18CNssContactHandler20DisableEventHandlingEv @ 2 NONAME
+	_ZN18CNssContactHandler4NewLEv @ 3 NONAME
+	_ZN18CNssContactHandlerD0Ev @ 4 NONAME
+	_ZN18CNssContactHandlerD1Ev @ 5 NONAME
+	_ZN18CNssContactHandlerD2Ev @ 6 NONAME
+	_ZTI18CNssContactHandler @ 7 NONAME ; #<TI>#
+	_ZTV18CNssContactHandler @ 8 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for VAS ContactHandler 
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+#include "exports.inc"
+
+PRJ_MMPFILES
+nssvascontacthdlr.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+#include <platform_paths.hrh>
+../loc/sindextensioncommands.loc  APP_LAYER_LOC_EXPORT_PATH(sindextensioncommands.loc)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/group/nssvascontacthdlr.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file NssVAS Contact Handler
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "data_caging_paths.hrh"
+
+target          nssvascontacthdlr.dll
+targettype      dll
+uid             0x1000008d 0x10201aef // UID: 270539503
+
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../data
+START RESOURCE  nssvascontacthandler.rss
+HEADER
+
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+sourcepath      ../src
+
+
+USERINCLUDE     ../inc  ../group  ../src ../../inc
+USERINCLUDE	    ../../group  // for srsfbldvariant.hrh
+
+// This is a SYSTEMINCLUDE macro containing the application
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/connect
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+SOURCE          nssvasccontacthandler.cpp
+SOURCE          nssvasccontacthandlerimpl.cpp
+SOURCE          nssvasdatasyncwatcher.cpp
+SOURCE          nsschbackupobserver.cpp
+
+USERINCLUDE     ../../rubydebug
+
+LIBRARY         euser.lib  
+LIBRARY         cntmodel.lib 
+LIBRARY         nssvasapi.lib
+LIBRARY         pbkeng.lib
+LIBRARY         featmgr.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         sysutil.lib
+LIBRARY         centralrepository.lib
+LIBRARY         cenrepnotifhandler.lib
+
+CAPABILITY      CAP_GENERAL_DLL
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/loc/sindextensioncommands.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,150 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Default (implementation English) resource localisation file for 
+*               SINDE.
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+
+// Name dialing with extensions (SINDE) START
+// ============================================================================
+
+// d:Command which is said by user when a call should be established to the
+// d:mobile number of a certain contact. %U is a name from phonebook.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "Adam Russell mobile".
+// d:Phonebook reference: qtn_phob_lbl_number_mobile
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_mobile               "%U mobile"
+
+// d:Command which is said by user when a call should be established to the 
+// d:fixed line number. %U denotes the name entered to phonebook by user.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "John Smith telephone".
+// d:Phonebook reference: qtn_phob_lbl_number_standard
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_general              "%U telephone"
+
+// d:Command which is said by user when a call should be established to the 
+// d:home number. %U denotes the name entered to phonebook by user.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "Emma Turner home".
+// d:Phonebook reference: qtn_phob_lbl_number_home
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_home                 "%U home"
+
+// d:Command which is said by user when a call should be established to the 
+// d:work number. %U denotes the name entered to phonebook by user.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "John Doe work".
+// d:Phonebook reference: qtn_phob_lbl_number_work
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_work                 "%U work"
+
+// d:Command which is said by user when a call should be established to the
+// d:video number of a certain contact. %U is a name from phonebook.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "Arnold Schwarzenegger video".
+// d:Phonebook reference: qtn_phob_lbl_video
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_video                "%U video"
+
+// d:Command which is said by user when message editor (combined editor for
+// d:SMS and MMS) should be opened with the specified contact. 
+// d:%U is a name from phonebook.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "George Clooney message".
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_message              "%U message"
+
+// d:Command which is said by user when e-mail editor should be opened with the
+// d:specified contact. %U is a name from phonebook.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "Bill Murray e-mail".
+// d:Phonebook reference: qtn_phob_lbl_email
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_email                "%U e-mail"
+
+// d:Command which is said by user when a call should be established to the 
+// d:VOIP number. %U denotes the name entered to phonebook by user.
+// d:Same string will be also said by text-to-speech as verification.
+// d:For example: "John Travolta internet call".
+// d:Phonebook reference: qtn_phob_lbl_voip
+// d:%U has to be either at the beginning or at the end of the string
+// d:(NOT in the middle). If the parameter would be in the middle, SIND
+// d:could not use the string as a voice tag. Also, parameter length cannot
+// d:be restricted (i.e. %U[25]) since this kind of formatting cannot be parsed
+// d:by SIND. 
+// l:None
+// r:3.2
+//
+#define qan_sind_extension_voip                 "%U internet call"
+
+// ============================================================================
+// Name dialing with extensions (SINDE) END
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nsschbackupobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches changes of the PC-Suite data sync state
+*
+*/
+
+
+#include "nsschbackupobserver.h"
+#include "rubydebug.h"
+
+#include <sbdefs.h>
+
+/**
+ @todo generalize the common parts of this class and CNssVasBackupObserver from VAS API
+       At the moment the code is copy-pasted and duplicated
+*/
+
+// ---------------------------------------------------------
+// CNssChBackupObserver::NewL
+// NewL
+// ---------------------------------------------------------
+//
+CNssChBackupObserver* CNssChBackupObserver::NewL( CNssContactHandlerImplementation& aHost )
+    {
+    CNssChBackupObserver* self = new (ELeave) CNssChBackupObserver( aHost );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CNssChBackupObserver::CNssChBackupObserver
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+CNssChBackupObserver::CNssChBackupObserver( CNssContactHandlerImplementation& aHost ) :
+    CActive( CActive::EPriorityHigh ),
+    iHost( aHost )
+    {
+    // Nothing
+    }
+    
+// ---------------------------------------------------------
+// CNssChBackupObserver::ConstructL
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+void CNssChBackupObserver::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "CNssVasBackupObserver::ConstructL" );
+    User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) );
+       
+    // initial subscription and process current property value
+    iProperty.Subscribe( iStatus );
+    
+    CActiveScheduler::Add( this ); 
+    SetActive();   
+    }
+    
+// ---------------------------------------------------------
+// CNssChBackupObserver::~CNssChBackupObserver
+// Destructor
+// ---------------------------------------------------------
+//
+CNssChBackupObserver::~CNssChBackupObserver()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+// ---------------------------------------------------------
+// CNssVasBackupObserver::DoCancel
+// Cancel listening now
+// ---------------------------------------------------------
+//    
+void CNssChBackupObserver::DoCancel() 
+    {
+    iProperty.Cancel();
+    }
+
+// ---------------------------------------------------------
+// CNssChBackupObserver::RunL
+// Is called, when property changed
+// ---------------------------------------------------------
+//
+void CNssChBackupObserver::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssChBackupObserver::RunL" );
+    if( iStatus != KErrNone ) 
+        {
+        // At least report the error
+        RUBY_ERROR1( "CNssChBackupObserver::RunL iStatus is [%d]", iStatus.Int() );
+        }
+        
+    // resubscribe before processing new value to prevent missing updates
+    // even if some error happened
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    // property updated, get new value
+	TInt backupFlag;
+	User::LeaveIfError( iProperty.Get( backupFlag ) );
+    TBool restoreRelated = EFalse;
+	switch ( backupFlag & conn::KBURPartTypeMask )
+	    {
+	    case conn::EBURNormal:
+	        RUBY_DEBUG0( "CNssChBackupObserver::RunL backup/restore not in progress" );
+	        iInProgress = EFalse;
+	        break;
+	        
+	    case conn::EBURBackupFull:
+	    case conn::EBURBackupPartial:
+            restoreRelated = EFalse;
+            iInProgress = ETrue;
+        break;           
+	    case conn::EBURRestoreFull:
+	    case conn::EBURRestorePartial:
+	        RUBY_DEBUG0( "CNssChBackupObserver::RunL backup/restore in progress" );
+            restoreRelated = ETrue;
+	        iInProgress = ETrue;
+	        break;
+	        
+	    case conn::EBURUnset:
+	    default:
+	        RUBY_ERROR1( "CNssChBackupObserver::RunL backup flag unknown %h ", backupFlag );
+	    }
+	    iHost.BackupRestoreStateChanged( restoreRelated, InProgress() );
+    }
+    
+// ---------------------------------------------------------
+// @return ETrue if some backup/restore action is in progress
+//         EFalse otherwise
+// ---------------------------------------------------------
+TBool CNssChBackupObserver::InProgress()
+	{
+	return iInProgress;
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nsschbackupobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watcher for the PC-Suite data sync state
+*
+*/
+
+
+#ifndef NSSCHBACKUPOBSERVER_H
+#define NSSCHBACKUPOBSERVER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+#include "nssvasccontacthandlerimpl.h"
+
+// Publish & Subscribe of the contact handler activity
+#include <e32property.h>  
+
+// CONSTANTS
+
+
+// MACROS
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+ @todo generalize the common parts of this class and CNssVasBackupObserver from VAS API
+       At the moment the code is copy-pasted and duplicated
+*/
+
+
+
+/**
+* RProperty based data sync watcher implementation
+*/
+NONSHARABLE_CLASS( CNssChBackupObserver ) : public CActive
+    {
+    public:
+        /** 
+        *  Factory construction
+        *  @param aDb Database 
+        *  @return Constructed and already started observer
+        */
+        static CNssChBackupObserver* NewL( CNssContactHandlerImplementation& aHost );
+        
+        /** 
+        * Destructor 
+        */
+        ~CNssChBackupObserver();
+        
+        /**
+        * @return ETrue if some backup/restore action is in progress
+        *         EFalse otherwise
+        */
+        TBool InProgress();
+
+    private:
+        /**
+        * C++ constructor 
+        */
+        CNssChBackupObserver( CNssContactHandlerImplementation& aHost );
+        
+        /**
+        * Symbian second phase constructor 
+        */
+        void ConstructL();
+        
+        /**
+        * is called when data sync property changed 
+        */
+        void RunL();
+        
+        /**
+        * Is called when system wants immediate cancelling of the watching 
+        */
+        void DoCancel();
+        
+    private:
+        // Publish & Subscribe property about backup/restore 
+        RProperty   iProperty;
+        
+        // Object to be notified about the backup/restore
+        CNssContactHandlerImplementation& iHost;
+        
+        // ETrue if some backup/restore action is in progress
+        TBool iInProgress;
+    };
+
+#endif // NSSCHBACKUPOBSERVER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nssvasccontacthandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,324 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for maintaining synchronization between the contact DB
+*               and the VAS DB
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssvasccontacthandler.h"
+#include "nssvasccontacthandlerimpl.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+// Thread name
+_LIT( KCHThreadName, "NssVasCHThread" );
+// Thread priority
+const TThreadPriority KCHThreadPriority = EPriorityAbsoluteLow;
+// Thread heap min-max
+const TInt KCHHeapMinSize = KMinHeapSize;
+const TInt KCHHeapMaxSize = 0x300000;
+
+/**
+*  Utility class to handle cleanup of ContactHandler thread
+*/
+NONSHARABLE_CLASS( CContactHandlerStopper ) : public CAsyncOneShot
+    {
+    public:
+        static CContactHandlerStopper* NewL( TInt aPriority );
+        virtual ~CContactHandlerStopper();
+        void StopCH();
+    protected:
+        void RunL();
+        void DoCancel();
+    private:
+        CContactHandlerStopper( TInt aPriority );
+    };
+
+// ---------------------------------------------------------
+// CNssContactHandler::CNssContactHandler
+// C++ constructor.
+// ---------------------------------------------------------
+//       
+CNssContactHandler::CNssContactHandler():
+    iStopper( NULL )
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandler::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+EXPORT_C CNssContactHandler* CNssContactHandler::NewL()
+    {
+    RUBY_DEBUG_BLOCK("CNssContactHandler::NewL");
+    CNssContactHandler* self = new (ELeave) CNssContactHandler();
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandler::ConstructL
+// Second-phase constructor.
+// ---------------------------------------------------------
+//
+void CNssContactHandler::ConstructL()
+    {
+    // Create processing thread
+    RThread chThread;
+
+    iThreadNameBuf.Append( _L( "[" ) );
+    // Add this pointer to the thread name to get it unique
+    iThreadNameBuf.AppendNum( ( TInt ) this );
+    iThreadNameBuf.Append( _L( "]" ) );
+    iThreadNameBuf.Append( KCHThreadName );
+
+    //RUBY_DEBUG1( "CNssContactHandler::ConstructL starting a thread with name: %S", iThreadNameBuf );
+
+    User::LeaveIfError( chThread.Create( iThreadNameBuf, CHThreadFunction, KDefaultStackSize, KCHHeapMinSize, KCHHeapMaxSize, this ) );
+
+    chThread.SetPriority( KCHThreadPriority );
+    chThread.Resume();
+    chThread.Close();    
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandler::~CNssContactHandler
+// Destructor.
+// ---------------------------------------------------------
+//
+EXPORT_C CNssContactHandler::~CNssContactHandler()
+    {
+    RUBY_DEBUG0("CNssContactHandlerImplementation::~CNssContactHandler");
+
+    // Check if Contact Handler thread is still alive
+    RThread chThread;
+
+    _LIT( KProcessThreadDelimeter, "::" );
+    TBuf<256> fullThreadName;
+	RProcess currentProcess;
+    fullThreadName.Append( currentProcess.FullName() );
+    fullThreadName.Append( KProcessThreadDelimeter );
+    fullThreadName.Append( iThreadNameBuf );
+
+    if ( chThread.Open( fullThreadName ) == KErrNone )
+        {
+        // Increase the thread priority to get the cleanup done quickly
+        // Fixes priority inversion problem
+        chThread.SetPriority( RThread().Priority() );
+        RUBY_DEBUG1("CNssContactHandlerImplementation::~CNssContactHandler increased priority to: %d", chThread.Priority() );
+
+        if ( iStopper )
+            {
+            // Start AO which stops the ActiveScheduler in ContactHandler thread
+            // -> ContactHandler thread will clean itself
+            iStopper->StopCH();
+            iStopper = NULL;
+
+            // Wait that cleanup of ContactHandler thread has been done properly
+            TRequestStatus threadCompletion;
+            chThread.Rendezvous( threadCompletion );
+            User::WaitForRequest( threadCompletion );
+            }
+
+        chThread.Kill( KErrNone );
+
+        chThread.Close();
+        }
+    else
+        {
+        //RUBY_ERROR1( "CNssContactHandlerImplementation::~CNssContactHandler failed to open thread: %S", iThreadNameBuf );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandler::DisableEventHandling
+// Disables the event handling.
+// ---------------------------------------------------------
+//
+EXPORT_C void CNssContactHandler::DisableEventHandling()
+   {
+   RUBY_DEBUG0( "CNssContactHandler::DisableEventHandling" );
+   }
+
+// ---------------------------------------------------------
+// CNssContactHandler::EnableEventHandling
+// Enables event handling
+//---------------------------------------------------------
+//
+EXPORT_C void CNssContactHandler::EnableEventHandling()
+   {
+   RUBY_DEBUG0( "CNssContactHandler::EnableEventHandling" );
+   }
+
+// ---------------------------------------------------------
+// CNssContactHandler::SetStopperPointer
+// Sets the pointer to stopper object.
+//---------------------------------------------------------
+//
+void CNssContactHandler::SetStopperPointer( CContactHandlerStopper* aStopper )
+    {
+    iStopper = aStopper;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandler::CHThreadFunction
+// ContactHandler thread function.
+// ---------------------------------------------------------
+//
+TInt CNssContactHandler::CHThreadFunction( TAny* aParams )
+    {
+    TInt result = KErrNone;
+    // CleanupStack creation
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+
+    // ActiveScheduler creation
+    CActiveScheduler* scheduler = NULL;
+    TRAPD( error, scheduler = new (ELeave) CActiveScheduler() );
+    if ( error == KErrNone )
+        {
+        // Take created ActiveScheduler into use
+        CActiveScheduler::Install( scheduler );
+
+        // Create utility object which is used when stopping this thread
+        CNssContactHandler* self = ( CNssContactHandler* )aParams;
+        CContactHandlerStopper* stopper = NULL;
+        TRAP( error, stopper  = CContactHandlerStopper::NewL( EPriorityNormal ) );
+        if ( error == KErrNone )
+            {
+            self->SetStopperPointer( stopper );
+
+            // Implementation of VAS ContactHandler
+            CNssContactHandlerImplementation* impl = NULL;
+            TRAP( error, impl = CNssContactHandlerImplementation::NewL() );
+
+            if ( error == KErrNone )
+                {
+                CActiveScheduler::Start();
+
+                delete impl;
+                self->SetStopperPointer( NULL );
+                delete stopper;
+                delete scheduler;
+                delete cleanupStack;
+
+                // Signal that cleanup of ContactHandler thread is now ok
+                RThread().Rendezvous( KErrNone );
+
+                result = KErrNone;                
+                }  // If created implementation
+            else
+                {
+                RUBY_ERROR1( "CNssContactHandler::CHThreadFunction Failed to create CH implementation. Error [%d]",
+                            error );
+                            
+                self->SetStopperPointer( NULL );
+                delete stopper;
+                delete scheduler;
+                result = error;
+                }
+                
+            // Self pointer not needed anymore
+            self = NULL;
+
+            }  // if created stopper
+        else 
+            {
+            RUBY_ERROR1( "CNssContactHandler::CHThreadFunction Failed to create CContactHandlerStopper. Error [%d]", 
+                        error );
+            delete scheduler;
+            result = error;
+            }
+        
+        }  // if created scheduler
+   else 
+        {
+        RUBY_ERROR1( "CNssContactHandler::CHThreadFunction Failed to create the active scheduler. Error [%d]", 
+                    error );
+        result = error;
+        }
+    
+    return result;
+    }
+
+// ---------------------------------------------------------
+// CContactHandlerStopper::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CContactHandlerStopper* CContactHandlerStopper::NewL( TInt aPriority )
+	{
+	CContactHandlerStopper* self = new (ELeave) CContactHandlerStopper( aPriority );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CContactHandlerStopper::~CContactHandlerStopper
+// Desctructor.
+// ---------------------------------------------------------
+//
+CContactHandlerStopper::~CContactHandlerStopper()
+	{
+    Cancel();
+	}
+
+// ---------------------------------------------------------
+// CContactHandlerStopper::CContactHandlerStopper
+// C++ constructor.
+// ---------------------------------------------------------
+//
+CContactHandlerStopper::CContactHandlerStopper( TInt aPriority ) : 
+    CAsyncOneShot( aPriority )
+	{
+	// Nothing
+	}
+
+// ---------------------------------------------------------
+// CContactHandlerStopper::StopCH
+// Method to request stopping.
+// ---------------------------------------------------------
+//
+void CContactHandlerStopper::StopCH()
+    {
+    Call();
+    }
+
+// ---------------------------------------------------------
+// CContactHandlerStopper::RunL
+// From CActive.
+// ---------------------------------------------------------
+//
+void CContactHandlerStopper::RunL()
+    {
+    CActiveScheduler::Stop();
+    }
+
+// ---------------------------------------------------------
+// CContactHandlerStopper::DoCancel
+// From CActive.
+// ---------------------------------------------------------
+//
+void CContactHandlerStopper::DoCancel()
+    {
+    // Nothing
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nssvasccontacthandlerimpl.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3445 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Responsible for maintaining synchronization between the contact DB
+*               and the VAS DB
+*
+*/
+
+
+/** @todo Read the whole contact in one go.
+
+  Currently Contact handler usually opens the same contact (ReadContactL) two to 
+  three times in order to read its data (mostly often three times).
+  One is in GetContactNickname
+  Second in GetContactTitle
+  Third in DoAddNamesL when deciding what number field should the voice tag 
+        be trained for
+  If we could unite these reads, "reading contacts" phase will be 2-3 times faster.
+  It would make about 10-20% improvement for the training of some 300 contacts */
+
+// INCLUDE FILES
+#include "nssvasccontacthandlerimpl.h"
+#include "nssvasctrainingparameters.h"
+#include <nssvascvasdbmgr.h>
+#include <centralrepository.h>
+#include <f32file.h>
+#include <bautils.h>
+#include <barsc.h>
+#include <barsread.h>
+#include <sysutil.h>
+#include "srsfprivatecrkeys.h"
+
+// Publish & Subscribe of the contact handler activity
+#include <nssvascoreconstant.h>
+
+#include <vascvpbkhandler.h>
+#include <featmgr.h>
+#include "nssvasdatasyncwatcher.h"
+#include "nsschbackupobserver.h"
+#include <StringLoader.h> 
+#include <nssvascontacthandler.rsg>
+#include <data_caging_path_literals.hrh>
+#include "rubydebug.h"
+
+// CONSTANTS
+// Name of the context in the SIND DB. Voice tags for contacts are saved there
+_LIT( KNssCHNameDialContext, "NAMEDIAL" );
+
+// Languages which use lastname-firstname order
+const TLanguage KSwappedLanguages[] = 
+    {
+    ELangHungarian,       // 17
+    ELangTaiwanChinese,   // 29
+    ELangHongKongChinese, // 30
+    ELangJapanese,        // 32
+    ELangPrcChinese,      // 31
+    ELangKorean,          // 65
+    ELangVietnamese       // 96
+    };
+
+// Number of languages that use lastname-firstname order
+const TInt KNumberOfSwappedLanguages = sizeof( KSwappedLanguages ) / sizeof ( TLanguage );
+
+
+// Maximal number of retrials to save tags
+const TInt KVASCHMaxRetry = 2;
+
+// Size of the event 'pack'. Tags are added and deleted in groups.
+// KMaxNamesAtOnce is the maximal size of a group
+const TInt KMaxNamesAtOnce = 100;
+
+// Initial value of the time interval used to detect periodic action. In 
+// microseconds. If KEventMomentsSize events happened  within the 
+// KInitialPeriodicActionInterval, we assume, that periodic action has started
+const TInt KInitialPeriodicActionInterval = 15000000;
+
+// Time interval used to periodically check if there are pending 
+// events to process. In microseconds
+const TInt KPeriodicTimerInterval = 1000000;
+
+// If there are this many consecutive full resyncs initiated by errors during
+// handling normal changes (or during previous full resync), there is probably
+// something consistently wrong at the lower layers. 
+// Full resync trials (and the whole contact handler) should be disabled until
+// reboot after KMaxConsecutiveErrorFullResync consecutive unsuccessful trials
+const TInt KMaxConsecutiveErrorFullResync = 2;
+
+// List of phonebook fields, that are supported by contact handler.
+// I.e. fields, that can be dialed and voice tagged
+/** @todo Consider using information from phonebook about which fields contain numbers
+and using the following lists for priorities only */
+const TPbkFieldId KTaggableFields[] = 
+    { 
+    EPbkFieldIdPhoneNumberMobile, 
+    EPbkFieldIdPhoneNumberGeneral,
+    EPbkFieldIdPhoneNumberStandard, 
+    EPbkFieldIdPhoneNumberHome,
+    EPbkFieldIdPhoneNumberWork, 
+    EPbkFieldIdPhoneNumberVideo,
+    EPbkFieldIdVOIP,
+    EPbkFieldIdXsp
+    };
+const TInt KTaggableFieldsCount = sizeof( KTaggableFields ) / sizeof ( TPbkFieldId );
+
+// List of phonebook fields that are supported by video extension
+const TPbkFieldId KVideoExtensionFields[] = 
+    {
+    EPbkFieldIdPhoneNumberVideo,
+    EPbkFieldIdPhoneNumberMobile,
+    EPbkFieldIdPhoneNumberGeneral,
+    EPbkFieldIdPhoneNumberHome,
+    EPbkFieldIdPhoneNumberWork
+    };
+const TInt KVideoExtensionFieldsCount = sizeof( KVideoExtensionFields ) / sizeof ( TPbkFieldId );
+
+// List of phonebook fields that are supported by message extension
+const TPbkFieldId KMessageExtensionFields[] = 
+    {
+    EPbkFieldIdPhoneNumberMobile,
+    EPbkFieldIdPhoneNumberGeneral,
+    EPbkFieldIdPhoneNumberHome,
+    EPbkFieldIdPhoneNumberWork,
+    EPbkFieldIdPhoneNumberVideo
+    };
+const TInt KMessageExtensionFieldsCount = sizeof( KMessageExtensionFields ) / sizeof ( TPbkFieldId );   
+
+// List of phonebook fields that are supported by VOIP extension
+const TPbkFieldId KVOIPExtensionFields[] = 
+    {
+    EPbkFieldIdVOIP,
+    EPbkFieldIdXsp
+    };
+const TInt KVOIPExtensionFieldsCount = sizeof( KVOIPExtensionFields ) / sizeof ( TPbkFieldId ); 
+
+// Size of the client data per context. Is used to store the context language
+// In bytes
+const TInt KClientDataSize = sizeof(TNssContextClientData);
+
+
+// Number of retries to try to lock the same contact
+// 600 times should stand for 10 mins
+// -1 means trying forever
+const TInt KMaxContactLockRetrials = 600;
+
+// Interval between the ticks of the contact wait timer
+// in microseconds
+const TInt32 KContactWaitInterval = 1000000;
+
+// Bytes that should be free in the disk drive in addition to critical level 
+// before operation is started (100kB)
+const TInt KIncreaseOfDatabaseSizes = 100000;
+
+// Define this if name free-order is enabled
+//#define NSSVAS_CONTACTHANDLER_FREEORDER
+// LOCAL FUNCTION DECLARATIONS
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+#ifdef _DEBUG
+_LIT( KFile, "VasCContactHandlerImpl.cpp" );
+#endif
+
+/**
+* Is used in DoHandleEventFailedL to *asynchronously* simulate successful tag
+*  deletion
+*/
+NONSHARABLE_CLASS( CSuccessfulDeletionSimulator ) : public CAsyncOneShot 
+	{
+	public:
+		CSuccessfulDeletionSimulator( CNssContactHandlerImplementation& aHost );
+		~CSuccessfulDeletionSimulator();
+	protected:
+	    /** Is called by the system after we asked it to Call() closer
+	    */
+		virtual void RunL();
+    private:
+        CNssContactHandlerImplementation& iHost;
+	};
+
+// -----------------------------------------------------------------------------
+// CSuccessfulDeletionSimulator::~CSuccessfulDeletionSimulator
+// Destructor
+// -----------------------------------------------------------------------------
+//	
+CSuccessfulDeletionSimulator::~CSuccessfulDeletionSimulator() 
+    {
+    RUBY_DEBUG0( "~CSuccessfulDeletionSimulator" );
+    if( IsAdded() ) 
+        {
+        RUBY_DEBUG0( "~CSuccessfulDeletionSimulator Request is still in progress, deque it" );
+        Deque();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSuccessfulDeletionSimulator::CSuccessfulDeletionSimulator
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CSuccessfulDeletionSimulator::CSuccessfulDeletionSimulator( CNssContactHandlerImplementation& aHost ) :
+	CAsyncOneShot( CActive::EPriorityStandard ),
+	iHost( aHost )
+	{
+	//nothing
+	}
+	
+// -----------------------------------------------------------------------------
+//  CAppCloser::RunL
+//  Will be called by the system and exits the application
+// -----------------------------------------------------------------------------
+//
+void CSuccessfulDeletionSimulator::RunL() 
+	{
+	RUBY_DEBUG0( "CSuccessfulDeletionSimulator::RunL Start" );
+	if( iStatus == KErrNone ) 
+		{
+		CArrayPtrFlat<MNssTag>* empty = new (ELeave) CArrayPtrFlat<MNssTag>( 1 );
+    	iHost.DoRemoveNamesAfterGetTagList( empty );
+    	// empty will be destroyed in the DoRemoveNamesAfterGetTagList
+		}
+	else 
+		{
+		RUBY_ERROR1( "CSuccessfulDeletionSimulator::RunL Unexpected iStatus [%d]", iStatus.Int() );
+		}
+	RUBY_DEBUG0( "CSuccessfulDeletionSimulator::RunL End" );
+	}
+	
+
+
+// -----------------------------------------------------------------------------
+// CNssContactHandlerImplementation::CNssContactHandlerImplementation
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssContactHandlerImplementation::CNssContactHandlerImplementation( )
+: iState( ECHInitializing ),
+  iSeparator( KNameSeparator()[0] ),
+  iEndOfPeriodicActionInterval( KInitialPeriodicActionInterval )
+    {
+    iClientData.iLanguage = ELangNone;
+    
+    // initialize last RestartTimer calls to be long ago in 
+    // the past (January 1st, 0 AD nominal Gregorian)
+    for( TInt i = 0; i < KEventMomentsSize; i++)
+    	{
+    	iEventMoments[i] = 0;
+    	}
+    }
+
+// -----------------------------------------------------------------------------
+// CNssContactHandlerImplementation::ConstructL
+// EPOC second phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::ConstructL" );
+
+    User::LeaveIfError( iFSession.Connect() );
+
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    iVoIPFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
+    iVideoCallFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony );
+    // Frees the TLS! Must be done after FeatureManager is used.
+    FeatureManager::UnInitializeLib();
+
+    // Before enabling event, start monitoring the PC-suite state
+    iSyncBackupWaiter = new (ELeave) CActiveSchedulerWait;
+    
+    iDataSyncWatcher = CNssDataSyncWatcherFactory::ConstructDataSyncWatcherL( *this );
+    
+    iBackupObserver = CNssChBackupObserver::NewL( *this );
+    
+    iContactWaiter = new (ELeave) CActiveSchedulerWait;
+    
+    iDeletionSimulator = new (ELeave) CSuccessfulDeletionSimulator( *this );
+
+    EnableEventHandling();
+
+    iEventArray.Reset();    // Ready to be used
+
+    TInt errProp = iBusyProperty.Define( KSINDUID, ETrainingContactsState, RProperty::EInt );
+    if( ( errProp != KErrNone ) && ( errProp != KErrAlreadyExists ) ) 
+        {
+        RUBY_ERROR1("CNssContactHandlerImplementation::ConstructL() Failed to define the property. Error [%d]", 
+                    errProp);
+        User::Leave( errProp );
+        }
+        
+    // Publish contact handler as busy before the DB operations
+    errProp = iBusyProperty.Attach( KSINDUID, ETrainingContactsState );
+    if( errProp != KErrNone ) 
+        {
+        // KErrNotFound is also an error as we just defined the property
+        RUBY_ERROR1("CNssContactHandlerImplementation::ConstructL() Failed to attach to property. Error [%d]", 
+                    errProp);
+        User::Leave( errProp );
+        }
+        
+    errProp = iBusyProperty.Set( EContactsTraining );
+    if ( errProp != KErrNone )
+        {
+        RUBY_ERROR1("CNssContactHandlerImplementation::ConstructL() Failed to set property. Error [%d]", 
+                     errProp );
+        User::Leave( errProp )  ;
+        }
+
+    
+    // central repository
+    iRepository = CRepository::NewL( KCRUidSRSFSettings );
+    iRepositoryObserver = CCenRepNotifyHandler::NewL( *this, *iRepository,
+                                                      CCenRepNotifyHandler::EIntKey,
+                                                      KSRSFFullResyncNeeded );
+    iRepositoryObserver->StartListeningL();
+    
+	//Get VAS DB manager
+	iVasDbManager = CNssVASDBMgr::NewL();
+	iVasDbManager->InitializeL();
+	RUBY_DEBUG0( "CNssContactHandlerImplementation::ConstructL iVasDbManager initialized" );
+
+	//Get Tag Manager and Context Manager interfaces
+	iTagManager = iVasDbManager->GetTagMgr();
+	iContextManager = iVasDbManager->GetContextMgr();
+
+    // Prepare training parameters
+    iTrainingParams = CNssTrainingParameters::NewL();
+    
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::ConstructL iTrainingParams prepared" );
+
+    // Set languages which have lastname-firstname order
+    for ( TInt iCounter = 0; iCounter < KNumberOfSwappedLanguages; iCounter++ )
+        {
+        User::LeaveIfError( iSwappedLanguages.Append( KSwappedLanguages[iCounter] ) );
+        }
+
+#ifdef __SINDE_TRAINING
+    // Main array for languages
+    RArray<RTrainingLanguageArray> languages;
+    
+    // Languages for names
+    RArray<TLanguage> nameLanguages;
+    User::LeaveIfError( nameLanguages.Append( User::Language() ) );
+    User::LeaveIfError( nameLanguages.Append( ELangOther ) );
+    User::LeaveIfError( languages.Append( nameLanguages ) );
+    
+    // Languages for extensions
+    RArray<TLanguage> extLanguages;
+    User::LeaveIfError( extLanguages.Append( User::Language() ) );
+    User::LeaveIfError( languages.Append( extLanguages ) );
+    
+    // Store languages to training parameters
+    iTrainingParams->SetSindeLanguages( languages );
+
+    // Close arrays, iTrainingParams has done a copy of these
+    extLanguages.Close();
+    nameLanguages.Close();
+    languages.Close();
+    
+#else
+    // Set the languages
+    RArray<TLanguage> *languages = new (ELeave) RArray<TLanguage>;
+    CleanupStack::PushL( languages );
+    // Always generate a pronunciation in UI language
+    User::LeaveIfError( languages->Append( User::Language() ) );
+    // give some extra languages, which can be selected in engine
+    User::LeaveIfError( languages->Append( ELangOther ) );
+    iTrainingParams->SetLanguages( languages );
+    CleanupStack::Pop( languages );
+#endif
+    
+    // The separator between the first name and the last name
+    iTrainingParams->SetSeparator( iSeparator );
+    
+#ifdef __SIND_EXTENSIONS
+
+    ReadExtensionsL();
+#endif // __SIND_EXTENSIONS    	
+
+	ConnectToPhonebookL();
+	
+    TLitC<9> name = KNssCHNameDialContext;
+
+    // Get context.
+
+    // (1) if we have synced earlier -> we have created a context, and saved the language
+    // (2) if we haven't synced      -> we need to create context
+    //
+    // In case (2), GetContext fails.
+    // We'll assume that GetContext is successful until it fails.
+    iHaveWeEverSynced = ETrue;
+
+    TInt err = iContextManager->GetContext( this, name );
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::ConstructL Requested GetContext. err [%d]", err);
+
+    if ( err != KErrNone )
+        {
+        // The same function is called, whether GetContext fails synchronously
+        // or asynchronously.
+        GetContextCompleted( NULL, KErrNotFound );
+        }
+   	iDeleteTagListArray = new (ELeave) CArrayPtrFlat<MNssTag>(50);
+   	
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+// 
+CNssContactHandlerImplementation* CNssContactHandlerImplementation::NewL( )
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::NewL" );
+    CNssContactHandlerImplementation* self = new (ELeave) CNssContactHandlerImplementation();
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::~CNssContactHandlerImplementation
+// Destructor
+// ---------------------------------------------------------
+// 
+CNssContactHandlerImplementation::~CNssContactHandlerImplementation()
+   {
+   RUBY_DEBUG0( "CNssContactHandlerImplementation::~CNssContactHandlerImplementation FIXED" );
+   
+   iFSession.Close();
+
+   iEventArray.Close();     // Close the RArray
+
+   delete iDataSyncWatcher;
+   delete iBackupObserver;
+   
+   if ( iSyncBackupWaiter != NULL )
+       {
+       if( iSyncBackupWaiter->IsStarted() ) 
+           {
+           iSyncBackupWaiter->AsyncStop();
+           }
+       }
+   delete iSyncBackupWaiter;
+   
+   if ( iContactWaiter != NULL )
+       {
+       if( iContactWaiter->IsStarted() ) 
+           {
+           iContactWaiter->AsyncStop();
+           }
+       }
+   
+
+   delete iContactWaiter;
+   delete iDeletionSimulator;
+   delete iPeriodicHandleEventTimer;
+
+   delete iContext;
+
+   delete iVasDbManager;
+   RProperty::Delete( KSINDUID, ETrainingContactsState );
+   iBusyProperty.Close();
+   
+   delete iRepositoryObserver;
+   delete iRepository;
+   
+   delete iTrainingParams;
+   iTagArray.ResetAndDestroy();
+
+   for( TInt k( 0 ); k < iContactQueue.Count(); k++ )
+       {
+       delete iContactQueue[k].iTitle;
+       }
+   iContactQueue.Close();
+
+   iDelList.Close();
+   iAddList.Close();
+   iRemoveIconList.Close();
+   iVoiceTagAddedList.Close();
+   iSwappedLanguages.Close();
+   
+   DisconnectFromPhonebook();
+   
+#ifdef __SIND_EXTENSIONS
+    
+    for ( TInt i(0); i < iExtensionList.Count(); i++ )
+       {
+       delete iExtensionList[i].iText;
+       }
+
+    iExtensionList.Close();
+#endif // __SIND_EXTENSIONS    
+   }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::HandleEventL
+// Called by phonebook handler when a contact database event
+// occurs
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::HandleEventL( const TPhonebookEvent& aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::HandleEventL" );
+    RUBY_DEBUG2( "CNssContactHandlerImplementation::HandleEventL(). Contact id [%d], event type [%d]", aEvent.iContactId, aEvent.iType );
+    
+    if ( aEvent.iType == EContactChanged ||
+         aEvent.iType == EContactDeleted ||
+         aEvent.iType == EContactAdded   ||
+         aEvent.iType == EUnknownChanges )
+        {
+        if( !CausedByVoiceTagAddition( aEvent ) )
+        	{
+        	// Check if operations can be finished
+        	// There should be enough disk space
+        	if ( NoDiskSpace() )
+        	    {
+        	    RUBY_DEBUG0( "CNssContactHandlerImplementation::HandleEventL not enough disk space, disabling event handling" );
+        	    DisableEventHandling();
+        	    }
+        	else
+        	    {
+                TInt errProp = iBusyProperty.Set( EContactsTraining );
+                if ( errProp != KErrNone )
+                    {
+                    RUBY_ERROR1("CNssContactHandlerImplementation::ConstructL() Failed to set property. Error [%d]", 
+                                 errProp );
+                    User::Leave( errProp )  ;
+                    }
+        	    UpdatePeriodicActionVars();
+	            iEventArray.Append( aEvent );
+
+    	        if ( iState == ECHIdle )
+        	     	{
+            	    RUBY_DEBUG0( "CNssContactHandlerImplementation::HandleEventL() iState == ECHIdle => DoHandleEvent" );
+
+            	    // Process the first new event from the queue
+            	    TRAPD( err, DoHandleEventsL() );
+            	    RUBY_DEBUG1( "CNssContactHandlerImplementation::HandleEventL. Assert would fail and Panic IF err != KErrNone. err [%d]", err );
+                    RUBY_ASSERT_DEBUG( err == KErrNone, User::Panic( KFile, __LINE__ ) );
+                
+                    if ( err != KErrNone )
+                        {
+                        RUBY_ERROR1( "CNssContactHandlerImplementation::HandleEventL. Error [%d] in DoHandleEventsL", err );
+                        }
+                    }
+         	    else 
+	        	    {
+	        	    RUBY_DEBUG1( "CNssContactHandlerImplementation::HandleEventL() iState == [%d] => Do not handle the event right now", iState );
+	        	    } // if iState else
+        	    }
+            }  // if caused be voice tag addition
+	    else
+        	{
+			RUBY_DEBUG2( "CNssContactHandlerImplementation::HandleEventL(). Event for Contact id [%d] was caused by a voice icon addition and will be ignored, eventArray size [%d]", aEvent.iContactId, iEventArray.Count() );
+			if ( ( iVoiceTagAddedList.Count() == 0 ) && ( iState == ECHIdle ) && ( iEventArray.Count() == 0 ) )  
+			    {
+			    RUBY_DEBUG0( "HandleEventL No more voice icon events expected, nothing pending." );
+			    }
+			else 
+			    {
+			    RUBY_DEBUG1( "HandleEventL [%d] voice icon events are still expected", iVoiceTagAddedList.Count() );
+			    }
+        	}
+        }
+    else if ( aEvent.iType == EStoreRestoreBeginning )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::HandleEventL restore begin" );
+        iRestoreRunning = ETrue; // set to differentiate ending of restore or backup
+        }
+    else if ( aEvent.iType == EStoreBackupRestoreCompleted && iRestoreRunning )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::HandleEventL restore end" );
+        // Set value to make full resync
+        SetFullResyncCrFlagL( ETrue );
+        iRestoreRunning = EFalse;
+        } // if event type
+    }
+
+
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoHandleEventL
+// Process the Event from phonebook
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoHandleEventsL()
+	{
+	RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::DoHandleEventsL" );
+	RUBY_DEBUG1( "CNssContactHandlerImplementation::DoHandleEventsL, eventArray size [%d]", iEventArray.Count() );
+
+	// If there is no lengthy higher level routine executed
+	if( !PeriodicAction() ) 
+		{
+		RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventsL !PeriodicAction()" );
+		if ( iHandlerEnabled )
+        	{
+   	    	if ( IsFullResyncNeeded() )
+       		   	{
+       			RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventsL() Full resync if needed. Setting iState to ECHFullResync" );
+				SetState( ECHFullResync );
+           		
+            	iEventArray.Close();
+	
+   	        	FullResyncStart();
+       	    	}
+   			else
+       	   		{
+       			RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventsL() Full resync if NOT needed. Setting iState to ECHHandlingNormalChanges" );
+       			SetState( ECHHandlingNormalChanges );
+
+       			// There are 3 phases in handling events:
+	          	// (1) Make two lists:
+   	     	 	//  * Names to be added
+       	  		//  * Names to be deleted
+          		CollectAddRemoveListsL();
+
+   	      		// (2) Delete the names to be deleted. This operation is asynchronous.
+       	  		DoRemoveNamesL();
+
+       			// (3) After removing names, add the names to be added.
+                // DoRemoveNamesL() starts the step (3)
+         		}
+    		}
+    	else 
+    		{
+    		// In UREL, empty "else" branch will be eliminated by the compiler
+			RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventsL() Handler was disabled" );
+    		}
+		
+   		RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventsL() completed" );
+		
+		}// if !PeriodicAction
+		
+	else 
+		{
+		// In UREL, empty "else" branch will be eliminated by the compiler
+		RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventsL PeriodicAction detected, DoHandleEventsL omitted" );
+		}
+		
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DeleteTagCompleted
+// Called when the deletion of a tag is completed successfully
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DeleteTagCompleted( TInt aErrorCode )
+	{
+	if( aErrorCode == KErrNone )
+	    {
+    	RUBY_DEBUG1( "CNssContactHandlerImplementation::DeleteTagCompleted. Assert iState == ECHHandlingNormalChanges. iState [%d]", iState);
+        RUBY_ASSERT_DEBUG( iState == ECHHandlingNormalChanges, User::Panic( KFile, __LINE__ ) );	    
+	    }
+    else
+        {
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DeleteTagCompleted: tag deletion failed" );
+    	
+    	iNormalChangesError = aErrorCode;
+        }	
+    
+    DoRemoveNamesAfterDeleteTagCompleted();
+	}
+
+// -----------------------------------------------------------------
+// CNssContactHandlerImplementation::GetTagCompleted
+// Called by tag manager when getting of a tag list completes
+// -----------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::GetTagListCompleted(
+    MNssTagListArray* aTagList, TInt aErrorCode )
+    {
+    if( aErrorCode == KErrNone )
+        {
+        if ( iState == ECHHandlingNormalChanges )
+            {
+            DoRemoveNamesAfterGetTagList( aTagList );
+            }
+        else
+            {
+            RUBY_DEBUG1( "CNssContactHandlerImplementation::GetTagListCompleted : Unknown state(%d)\n", iState );
+    		}
+        }
+    else
+        {
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::GetTagListCompleted. Error [%d]", aErrorCode );
+        
+        TRAPD( err, DoHandleEventFailedL() );    // Process the event fail
+        if ( err != KErrNone )
+            {
+            RUBY_ERROR1( "CNssContactHandlerImplementation::GetTagFailed. Error [%d] in DoHandleEventFailedL", err );
+            }
+        }
+	}
+
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DisableEventHandling
+// Disables the event handling. Is used in case of unrecoverable error
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DisableEventHandling()
+   {
+   RUBY_DEBUG0( "CNssContactHandlerImplementation::DisableEventHandling" );
+   iHandlerEnabled = EFalse;
+   }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::EnableEventHandling
+// Enables event handling
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::EnableEventHandling()
+   {
+   RUBY_DEBUG0( "CNssContactHandlerImplementation::EnableEventHandling" );
+   iHandlerEnabled = ETrue;
+   }
+
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::GetContextListCompleted
+// Called by tag manager when GetContextList() completes successfully
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::GetContextListCompleted(
+    MNssContextListArray*  /*aContextList*/, TInt /*aErrorCode*/ )
+    {
+    RUBY_ERROR0( "CNssContactHandlerImplementation::GetContextListCompleted - this function should never be called." );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::CheckErrorSigns
+// Compares client data (saved in VAS context)
+// to state of the phonebook to find out if
+// full synchronization is needed.
+//
+// If full resync is needed initiates it by saving into the event queue
+// special 'full resync event'
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::CheckErrorSigns()
+    {
+    
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::CheckErrorSigns" );
+    TBool errorFound( EFalse );
+    // Full resync, if this is the first time we launch.
+    //              if the UI language has changed.
+    //              if VAS Db and Contact Db time stamps do not match
+    if  ( iClientData.iLanguage == ELangNone ||
+        iClientData.iLanguage != User::Language() )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::CheckErrorSigns language changed." );
+        errorFound = ETrue;
+        }
+    else
+        {
+        // check that is full resyncronization needed
+        iRepository->Get( KSRSFFullResyncNeeded, errorFound );
+        }
+        
+    if ( errorFound )
+        {
+        TPhonebookEvent event;
+       	event.iType = ENullEvent;
+       	event.iContactId = 0;
+        
+        if ( iEventArray.Append( event ) != KErrNone )
+            {
+            RUBY_ERROR0( "CNssContactHandlerImplementation::CheckErrorSigns Failed to append to iEventArray" );
+            }        
+        }
+    
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::GetContextCompleted
+// Called by tag manager, when GetContext() completes successfully
+//
+// Depending on the contact handler state, continues full resync sequence or
+// sets the idle state
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::GetContextCompleted(
+    MNssContext* aContext, TInt aErrorCode )
+	{
+	if( aErrorCode == KErrNone )
+	    {
+        RUBY_ASSERT_DEBUG( iState == ECHInitializing || iState == ECHFullResync,
+                        User::Panic( KFile, __LINE__ ) );
+
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::GetContextCompleted" );
+        iContext = aContext;
+        TRAPD(err,
+
+            iClientData.InternalizeL( iContext->ClientData() );
+
+    	    if ( iState == ECHInitializing )
+    	        {
+    	        // If there are warning sings of error,
+    	        // do full resynchronization.
+    	        CheckErrorSigns();
+
+    	        SetState( ECHIdle );
+    	        RUBY_DEBUG0( "CNssContactHandlerImplementation::GetContextCompleted. Setting iState to ECHIdle" );
+    		
+    	        if ( iEventArray.Count() ) // Verify whether more events in the queue
+    	            {
+    	            
+    	    		RUBY_DEBUG1( "CNssContactHandlerImplementation::GetContextCompletedhere are still [%d] events in the queue. Call DoHandleEvents for them", iEventArray.Count() );
+    				
+    	            DoHandleEventsL(); // Process the 1st new event from the queue
+    	            }
+    	        }
+    	    else if ( iState == ECHFullResync )
+    	        {
+    	        TRAPD( error,  FullResyncCreateChangesL() );
+    	        if( error != KErrNone ) 
+    	            {
+    	            RUBY_ERROR1( "FullResyncCreateChangesL failed with [%d]. Panic, nothing can be done", error );
+    	            RUBY_ASSERT_DEBUG( EFalse, User::Panic( KFile, __LINE__ ) );
+    	            }
+    	        }
+    	    else 
+    	    	{
+    	    	RUBY_ERROR0( "CNssContactHandlerImplementation::GetContextCompleted Unexpected state" );
+    	    	RUBY_ASSERT_DEBUG( EFalse, User::Panic( KFile, __LINE__ ) );
+    	    	}
+    	    );  // TRAPD
+    	if( err != KErrNone ) 
+    		{
+    		RUBY_ERROR1( "CNssContactHandlerImplementation::GetContextCompleted Leaves with [%d] inside", err );
+    		}
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::GetContextCompleted completed" );	    
+	    }
+	    
+	else // aErrorCode != KErrNone
+	    {
+        RUBY_ASSERT_DEBUG( iState == ECHInitializing || iState == ECHFullResync,
+                        User::Panic( KFile, __LINE__ ) );
+
+        if ( iState == ECHInitializing )
+            {
+            iHaveWeEverSynced = EFalse;
+            SetState ( ECHFullResync );
+            FullResyncStart();
+            }	    
+	    }
+
+	}
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::SaveContextCompleted
+// Called when SaveContext() completes successfully
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::SaveContextCompleted( TInt aErrorCode )
+    {
+    if( aErrorCode == KErrNone )
+        {
+        RUBY_ASSERT_DEBUG( iState == ECHInitializing || 
+                        iState == ECHFullResync,
+                        User::Panic( KFile, __LINE__ ) );
+
+        iHaveWeEverSynced = ETrue;
+
+        if ( iState == ECHInitializing )
+            {
+            // Retrive the Context to get the new ContextId from VasDB
+            iContextManager->GetContext( this, KNssCHNameDialContext );
+            }
+        else if ( iState == ECHFullResync )
+            {
+            TRAPD( error, FullResyncCreateChangesL() );
+            if ( error != KErrNone ) 
+                {
+                RUBY_ERROR1( "SaveContextCompleted Failed to create full resync changes. Critical error [%d]", 
+                            error );
+                DisableEventHandling();
+                }  // if error != KErrNone
+            }  // else if ( iState == ECHFullResync )
+        else 
+        	{
+        	// we should never be here, because the condition is checked 
+        	// by ASSERT_DEBUG at the start of the function
+        	RUBY_ERROR0( "CNssContactHandlerImplementation::SaveContextCompleted Unexpected state!" );
+        	}        
+        }
+        
+    else // aErrorCode != KErrNone
+        {
+        // Failed to initialize will collect the events forever and will never process them
+        // Will try to initialize again after reboot
+        RUBY_ERROR0( "CNssContactHandlerImplementation::SaveContextCompleted failed. Staying forever in ECHFullResync" );
+        RUBY_ERROR0( "CNssContactHandlerImplementation::SaveContextCompleted failed. Reboot to try initializing again" );
+        DisableEventHandling();        
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::SaveTagCompleted
+// Called when SaveTag() completes
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::SaveTagCompleted( TInt aErrorCode )
+    {
+    RUBY_ASSERT_DEBUG( iState == ECHHandlingNormalChanges, User::Panic( KFile, __LINE__ ) );
+    
+    DoAddNamesSaveTagCompleted( aErrorCode );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::GetContactTitleL
+// Populates aTitle with either "FirstName LastName" or "CompanyName".
+// "CompanyName" is given only if both First and Last names are missing.
+//---------------------------------------------------------
+//
+HBufC* CNssContactHandlerImplementation::GetContactTitleL( TContactItemId aContactId, 
+                                                           TBool aUseDefaultOrder,
+                                                           TBool& aBothFirstAndLastFound,
+                                                           TVasTagType& aTagType )
+	{
+	RUBY_DEBUG_BLOCKL( "CNssContactHandlerImplementation::GetContactTitleL" );
+    // Find out if lastname-firstname should be used
+    TBool useLastFirstOrder = EFalse;
+    
+    // By default, this function returns firstname and/or lastname
+    aTagType = ETagTypeName;
+
+    if ( aUseDefaultOrder )
+        {
+        useLastFirstOrder = SwapNameOrder();
+        }
+    else
+        {
+        useLastFirstOrder = !SwapNameOrder();
+        }
+    WaitUntilNoSyncBackupIsRunning();
+    ReadContactL( aContactId );
+    
+    HBufC* firstNameText = NULL;
+    HBufC* lastNameText = NULL;
+    HBufC* companyNameText = NULL;
+    
+    TInt firstLength( 0 );
+    TInt lastLength( 0 );
+    TInt companyLength( 0 );    
+    
+    TInt error = KErrNone;
+    
+    // name reading fields are used in Japanese
+	TRAP( error, iPbkHandler->FindFieldL( EPbkFieldIdFirstNameReading ) );
+    if ( error == KErrNotFound ) 
+        {
+        // not found
+        TRAP( error, iPbkHandler->FindFieldL( EPbkFieldIdFirstName ) );
+        }
+        
+    if ( error == KErrNone )
+        {
+        firstNameText = iPbkHandler->TextL().AllocLC();
+        TrimName( firstNameText );
+        firstLength = firstNameText->Length();
+        if ( firstLength == 0 )
+            {
+            CleanupStack::PopAndDestroy( firstNameText );
+            firstNameText = NULL;
+            }
+        }
+
+    TRAP( error, iPbkHandler->FindFieldL( EPbkFieldIdLastNameReading ) );
+    if ( error == KErrNotFound ) 
+        {
+        // not found
+        TRAP( error, iPbkHandler->FindFieldL( EPbkFieldIdLastName ) );
+        }
+        
+    if ( error == KErrNone )
+        {
+        lastNameText = iPbkHandler->TextL().AllocLC();
+        TrimName( lastNameText );
+        lastLength = lastNameText->Length();
+        if ( lastLength == 0 )
+            {
+            CleanupStack::PopAndDestroy( lastNameText );
+            lastNameText = NULL;
+            }        
+        }
+
+    TRAP( error, iPbkHandler->FindFieldL( EPbkFieldIdCompanyName ) );
+    
+    if ( error == KErrNone )
+        {
+        companyNameText = iPbkHandler->TextL().AllocLC();
+        TrimName( companyNameText );
+        companyLength = companyNameText->Length();
+        if ( companyLength == 0 )
+            {
+            CleanupStack::PopAndDestroy( companyNameText );
+            companyNameText = NULL;
+            }         
+        }
+
+    // Use third parameter to return a flag if both lastname and firstname are found
+    if ( ( firstLength > 0 ) && ( lastLength > 0 ) )
+        {
+        aBothFirstAndLastFound = ETrue;
+        }
+    else
+        {
+        aBothFirstAndLastFound = EFalse;
+        }
+
+    HBufC* title( NULL );
+
+#ifdef __SIND_EXTENSIONS
+    if ( firstLength + lastLength > 0 )
+        {
+        TInt spaceForIndexes( 0 );
+        // Find out how much more space is needed for "training indexes"
+        if ( aBothFirstAndLastFound )
+            {
+            spaceForIndexes = 2 * KTrainingIndexSize;
+            }
+        else
+            {
+            spaceForIndexes = KTrainingIndexSize;
+            }
+            
+        title = HBufC::NewL( firstLength + lastLength + spaceForIndexes );
+        
+        // Check the order 
+        if ( useLastFirstOrder )
+            {
+            // Lastname-firstname
+            if ( lastNameText ) 
+                {
+                AppendName( title, lastNameText );
+                }
+            
+            if ( firstNameText )
+                {
+                AppendName( title, firstNameText );
+                }
+            }
+        else
+            {
+            // Firstname-lastname
+            if ( firstNameText )
+                {
+                AppendName( title, firstNameText );
+                }
+                
+            if ( lastNameText ) 
+                {
+                AppendName( title, lastNameText );
+                }
+            }
+        }
+    // Try company name, if the personal name fails.
+    else if ( companyLength > 0 )
+        {
+        aTagType = ETagTypeCompanyName;
+        title = HBufC::NewL( companyLength + KTrainingIndexSize );
+        AppendName( title, companyNameText );
+        }
+#else
+    // Use personal name, if there is one.
+    if ( firstLength + lastLength > 0 )
+        {
+        title = HBufC::NewL( firstLength + 1 + lastLength );
+
+        // Check the order 
+        if ( useLastFirstOrder )
+            {
+            // Lastname-firstname
+            if ( lastNameText ) 
+                {
+                title->Des().Append( lastNameText->Des() );
+
+                if ( firstNameText )
+                    {
+                    // Separator marker
+                    title->Des().Append( iSeparator );
+                    }
+                }
+            
+            if ( firstNameText )
+                {
+                title->Des().Append( firstNameText->Des() );
+                }
+
+
+            }
+        else
+            {
+            // Firstname-lastname
+            if ( firstNameText ) 
+                {
+                title->Des().Append( firstNameText->Des() );
+
+                if ( lastNameText )
+                    {
+                    // Separator marker
+                    title->Des().Append( iSeparator );
+                    }
+                }
+                
+            if ( lastNameText )
+                {
+                title->Des().Append( lastNameText->Des() );
+                }
+
+            }
+        }
+    // Try company name, if the personal name fails.
+    else if ( companyLength > 0 )
+        {
+        aTagType = ETagTypeCompanyName;
+        title = HBufC::NewL( companyLength );
+        title->Des().Append( companyNameText->Des() );
+        }
+#endif // __SIND_EXTENSIONS
+    // It is possible to make a contact without a name.
+    else
+        {
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::ContactTitle: No name, ContactId=[%d]" , aContactId );
+        }
+
+    if ( companyNameText )
+        {
+        CleanupStack::PopAndDestroy( companyNameText );
+        }
+        
+    if ( lastNameText )
+        {
+        CleanupStack::PopAndDestroy( lastNameText );
+        }
+        
+    if ( firstNameText )
+        {
+        CleanupStack::PopAndDestroy( firstNameText );
+        }
+    
+    return title;
+	}
+
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::SwapNameOrder
+// Returns ETrue if name order for current UI language should
+// be lastname-firstname, EFalse otherwise
+//---------------------------------------------------------
+//
+TBool CNssContactHandlerImplementation::SwapNameOrder()
+    {
+    // Find UI language
+    TLanguage uiLanguage = User::Language();
+
+    if ( iSwappedLanguages.Find( uiLanguage ) == KErrNotFound )
+        {
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::GetContactNicknameL
+// Returns nickname for a given contact
+//---------------------------------------------------------
+//
+HBufC* CNssContactHandlerImplementation::GetContactNicknameL( TContactItemId aContactId )
+	{
+	RUBY_DEBUG_BLOCKL( "CNssContactHandlerImplementation::GetContactNicknameL" );
+	WaitUntilNoSyncBackupIsRunning();
+    ReadContactL( aContactId );
+
+	// Get the nick name
+	iPbkHandler->FindFieldL( EPbkFieldIdSecondName );
+
+    // Get the length of the additional name.
+    TInt nickLength = iPbkHandler->TextL().Length();
+
+    HBufC* title = NULL;
+
+#ifdef __SIND_EXTENSIONS
+    // Use personal name, if there is one.
+    if ( nickLength > 0 )
+        {
+        title = HBufC::NewL( nickLength + KTrainingIndexSize );
+        
+        HBufC* nickName = iPbkHandler->TextL().AllocL();
+        TrimName( nickName );
+        AppendName( title, nickName );
+        delete nickName;
+        }
+#else
+    // Use personal name, if there is one.
+    if ( nickLength > 0 )
+        {
+        title = HBufC::NewL( nickLength );
+        title->Des().Append( iPbkHandler->TextL() );
+        }
+#endif // __SIND_EXTENSIONS
+
+    return title;
+	}
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoHandleEventFailed
+// Routine to process when handling the contact event failed
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoHandleEventFailedL()
+    {
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventFailedL start" );
+    
+    // Errors are normal if user deletes contact without a voice tag
+    // E.g. because this contact had no number
+    if( ( iDeleteTagListArray != NULL ) && ( iDeleteTagListArray->Count() > 0 ) ) 
+    	{
+    	// simulate successful deletion, just return no tags for further deletions
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventFailedL Deletion failed. Simulating successful empty deletion" );
+    	iDeletionSimulator->Call();
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventFailedL Called deletion simulator" );
+    	}
+    else 
+    	{
+    	
+	    // Try full resync couple of times. If still fails, stop contact handler. 
+	    // When the phone is booted for the next time, try resyncing again
+    	if( iConsecutiveErrorFullResync < KMaxConsecutiveErrorFullResync ) 
+    		{
+    		iConsecutiveErrorFullResync++;
+    		RUBY_DEBUG1( "CNssContactHandlerImplementation::DoHandleEventFailedL Trying full resync for the [%d] time", iConsecutiveErrorFullResync);
+    		// clean structures that might be already full
+    		iTagArray.ResetAndDestroy();
+
+		    for( TInt k( 0 ); k < iContactQueue.Count(); k++ )
+		    	{
+		       	delete iContactQueue[k].iTitle;
+		       	}
+		   	iContactQueue.Close();
+
+		   	iDelList.Close();
+		   	iAddList.Close();
+		   	iVoiceTagAddedList.Close();
+    		// generate full resync event
+    		TPhonebookEvent event;
+        	event.iType = ENullEvent;
+        	event.iContactId = 0;
+        	iEventArray.Insert( event, 0 );
+        	// will start full resync
+        	iTagArray.ResetAndDestroy();
+        	iSaveCallbackCounter = 0; // simulate completed action
+        	RUBY_DEBUG0( "DoHandleEventFailedL No leaving in the FullResync branch, retrying" );
+        	DoHandleEventsL(); // No leaving in the FullResync branch
+    		} 
+    	else
+	    	{
+	    	RUBY_ERROR1( "CNssContactHandlerImplementation::DoHandleEventFailedL Tried full resync for %d times. Disabling contact handler until reboot", KMaxConsecutiveErrorFullResync );
+    		// Tried several consecutive resyncs, didn't help
+    		// Disable itself until reboot
+    		DisableEventHandling();
+    		}  
+    	}  // if deletion else
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::DoHandleEventFailedL end" );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::PhonebookOrder
+// TLinearOrder comparison function for sorting phonebook events
+// according to their Phonebook ID.
+//---------------------------------------------------------
+//
+TInt CNssContactHandlerImplementation::PhonebookOrder( const TPhonebookEvent& a1, const TPhonebookEvent& a2 )
+    {
+    if ( a1.iContactId != a2.iContactId )
+        {
+        return( a1.iContactId - a2.iContactId );
+        }
+
+    if ( a1.iTime < a2.iTime )
+        {
+        return( -1 );
+        }
+    else if ( a1.iTime > a2.iTime )
+        {
+        return( 1 );
+        }
+    else{
+        return( 0 );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::IsFullResyncNeeded
+// Checks if the event queue contains an event, which
+// launches full resynchronization. If it does, there is
+// no point in processing the other events.
+// ---------------------------------------------------------
+//
+TBool CNssContactHandlerImplementation::IsFullResyncNeeded()
+    {
+    for( TInt k( 0 ); k < iEventArray.Count(); k++ )
+        {
+        // Null event is used inside contact handler to signal full resync.
+        if ( iEventArray[k].iType == ENullEvent
+             || iEventArray[k].iType == EStoreBackupRestoreCompleted 
+             || iEventArray[k].iType == EUnknownChanges )
+            {
+            return ETrue;
+            }
+        }
+
+    return EFalse;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::CollectAddRemoveListsL
+// Given a list of Contact DB Events, this function compiles
+// a list of ids to-be-deleted and ids to-be-added.
+// A Contact DB Event contains:
+//  * Contact ID
+//  * Event type (added, modified, removed)
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::CollectAddRemoveListsL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::CollectAddRemoveListsL" );
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::CollectAddRemoveListsL(). iEventArray.Count [%d]", iEventArray.Count() );
+    TInt k( 0 );
+	
+	RUBY_ASSERT_DEBUG( iAddList.Count() == 0, User::Panic( KFile, __LINE__ ) );
+    RUBY_ASSERT_DEBUG( iDelList.Count() == 0, User::Panic( KFile, __LINE__ ) );
+
+    // We collect two lists:
+    //  * Contacts to be deleted.
+    //  * Contacts to be added.
+
+    TLinearOrder<TPhonebookEvent> order( PhonebookOrder );
+
+    // Sort events according to the phonebook ID. This way, the events
+    // modifying the same name are sequentially.
+    iEventArray.Sort( order );
+	
+
+    // If several events happen for the same contact, fuse them into one event.
+    for ( k = 0; k < iEventArray.Count() - 1; k++ )
+        {
+        if ( iEventArray[k].iContactId == iEventArray[k+1].iContactId )
+            {
+            // Sorting should have preserved the order of the events
+            RUBY_ASSERT_DEBUG(iEventArray[k+1].iTime >= iEventArray[k].iTime, User::Panic( KFile, __LINE__ ) );
+            RUBY_DEBUG1( "CNssContactHandlerImplementation::CollectAddRemoveListsL(). Fusing events for ContactId [%d]", iEventArray[k].iContactId );
+            iEventArray[k+1].iType = EContactChanged;
+            iEventArray.Remove( k );
+
+            // We have removed an element
+            k--;
+            }
+        }
+
+	RUBY_DEBUG1( "CNssContactHandlerImplementation::CollectAddRemoveListsL(). Events sorted and fused iEventArray.Count [%d]", iEventArray.Count() );
+
+    for( k = 0; k < iEventArray.Count() && k < KMaxNamesAtOnce; k++ )
+        {
+        TPhonebookEvent* event = &iEventArray[k];
+
+        switch ( event->iType )
+            {
+            case EContactChanged:
+                {
+                // events caused by saving voice tag field are skipped 
+                // earlier, in HandleDatabaseEventL
+
+                // We need to delete the old name
+                User::LeaveIfError( iDelList.Append( *event ) ); 
+                // and after that, add the new name.
+                User::LeaveIfError( iAddList.Append( *event ) ); 
+                break;
+                }
+            case EContactDeleted:
+                {
+                User::LeaveIfError( iDelList.Append( *event ) );
+                break;
+                }
+            case EContactAdded:
+                {
+                User::LeaveIfError( iAddList.Append( *event ) );
+                break;
+                }
+            default:
+                RUBY_ERROR1( "CNssContactHandlerImplementation::CollectAddRemoveListsL() Unkown event type: %d", event->iType );
+                break;
+            }
+        }
+
+    if ( k < KMaxNamesAtOnce )
+        {
+        iEventArray.Close();
+        }
+    else
+        {
+    	RUBY_DEBUG1( "CNssContactHandlerImplementation::CollectAddRemoveListsL(). k >= KMaxNamesAtOnce [%d]. Deleting first KMaxNamesAtOnce events, they've been sorted into corresponding lists already",
+    	            KMaxNamesAtOnce);
+        for ( k = 0; k < KMaxNamesAtOnce; k++ )
+            {
+            iEventArray.Remove(0);
+            }
+        }
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::CollectAddRemoveListsL() iEventArray.Count [%d]",
+                iEventArray.Count());
+	RUBY_DEBUG2( "CNssContactHandlerImplementation::CollectAddRemoveListsL iDelList.Count() [%d], iAddList.Count() [%d]", iDelList.Count(), iAddList.Count());
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoRemoveNamesL
+// Starts name removal sequence
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoRemoveNamesL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::DoRemoveNamesL" );
+    if ( iDelList.Count() == 0 )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesL Nothing to delete - skipping" );
+
+        RemovingNamesCompletedL();
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesL completed early <= nothing to remove" );
+        return;
+        }
+
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesL - removing" );
+
+    // we have: a list of tag IDs, which should be removed
+    // we need: a list of tags, which should be removed.
+
+    // First, we get the tags which correspond to the tag ids.
+    // We need k async calls to VAS,
+    // where k is the number of tag ids in iDelList.
+    // We get a list of k' tags, where k' >= k.
+    // If some tag has both proper name and a nickname, then k' > k.
+    
+    iContactId = iDelList[0].iContactId;
+
+    if ( iDeleteTagListArray )
+        {
+        iDeleteTagListArray->ResetAndDestroy();
+        }
+    else
+        {
+        iDeleteTagListArray = new (ELeave) CArrayPtrFlat<MNssTag>(50);
+        }
+
+    TInt retCode = iTagManager->GetTagList( this, iContext, iContactId, 0 );
+
+    if ( retCode != KErrNone )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesL failed to GetTagList" );
+        // In the case of change event, try to add names even though they are not found
+        // Might happen in scenario like this:
+        // 1. User adds a name without any phone number -> no voice tag is created
+        // 2. Contact is modified by adding a phone number
+        iDelList.Close();
+        DoAddNamesL();
+        }
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesL completed" );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList
+// If contact database announces that n contacts need to be
+// deleted, we do n calls to GetTagList (the first is from DoRemoveNamesL). 
+// Each callback returns 1 or more tags (name + nickname = 2 tags). 
+// This function processes the callbacks by adding the tags to the 
+// to-be-deleted list.
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList( MNssTagListArray* aTagList )
+    {
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList. iState [%d]", iState );
+
+    if ( iDelList.Count() == 0 ) 
+		{
+		RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList iDelList.Count() == 0" );
+		}
+
+    // Sieve out "false" tags: Those which have a wrong contact ID.
+    /** Why? Maybe user was fast enough to delete these contacts from the phonebook 
+    *   Anyway, why should we keep "false" tags in our db?
+    */
+    for ( TInt i=0; i < aTagList->Count(); i++ )
+        {
+        CArrayFixFlat<TInt>* intArray = aTagList->At(i)->RRD()->IntArray();
+	
+        RUBY_ASSERT_DEBUG( intArray->Count() > 0, User::Panic( KFile, __LINE__ ) );
+
+        if ( intArray->At(0) != iContactId )
+            {
+            RUBY_ERROR2( "DoRemoveNamesAfterGetTagList expected contact id %d, but got contact id: %d", iContactId, intArray->At(0) );
+            delete aTagList->At( i );
+            aTagList->Delete( i );
+            }
+        }
+        
+    TRAPD( err, // trapping is a fix to make the function non-leaving
+
+	    // Add the tags to the to-be-deleted list.
+	    // (there are 1 or 2 tags in aTagList depending on
+	    //  whether nickname is also there or not)
+	    for ( TInt k( 0 ); k < aTagList->Count(); k++ )
+	        {
+	        iDeleteTagListArray->AppendL( (*aTagList)[k] );
+	        }
+
+	    // We have processed this ID
+	    RUBY_DEBUG1( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList Before removal. iDelList.Count [%d]", iDelList.Count() );
+	    if( iDelList.Count() > 0 ) 
+	    	{
+	    	iDelList.Remove( 0 );
+	    	} 
+	    else 
+	    	{
+	    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList Empty iDelList!" );
+	    	}
+	    RUBY_DEBUG1( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList After removal. iDelList.Count [%d]", iDelList.Count() );
+
+	    // If there are still more IDs, convert the next ID into a tag.
+	    if ( iDelList.Count() > 0 )
+	        {
+	        RUBY_DEBUG1( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList There are [%d] contacts to delete. Calling GetTagList for them", iDelList.Count() );
+	        iContactId = iDelList[0].iContactId;
+
+	        TInt retCode 
+	            = iTagManager->GetTagList( this, iContext, iContactId, 0 );
+
+	        if ( retCode != KErrNone )
+	            {
+	            RUBY_DEBUG0( "DoRemoveNamesAfterGetTagList Failed to GetTagList, going to DoHandleEventFailedL" );
+	            TRAP_IGNORE( DoHandleEventFailedL() );      // to handle the process event failed
+	            /** @todo reengineer into single return path */
+	            // Destroy tag list
+	    		aTagList->Reset();
+	    		delete aTagList;
+	    		aTagList = 0;
+	            return;
+	            }
+	        }
+	        
+	    // If we just finished converting the last ID, move to the next phase.
+	    else{
+	        RUBY_DEBUG0( "DoRemoveNamesAfterGetTagList Moving to the next phase" );
+	        DoRemoveNamesCallDeleteTag();
+	        }
+        );  // TRAPD
+        if( err != KErrNone ) 
+        	{
+        	RUBY_ERROR1( "CNssContactHandlerImplementation::DoRemoveNamesAfterGetTagList Leaves with [%d] inside", err );
+        	}
+		// Destroy tag list
+	    aTagList->Reset();
+	    delete aTagList;
+	    aTagList = 0;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoRemoveNamesCallDeleteTag
+// Sends the DeleteTag() calls to lower layers when removing names.
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoRemoveNamesCallDeleteTag()
+    {
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::DoRemoveNamesCallDeleteTag. iDeleteTagListArray->Count() [%d] Setting iDeleteCallbackCounter = 0", 
+                iDeleteTagListArray->Count() );
+    
+    if( iDeleteTagListArray->Count() > 0 ) 
+    	{
+    	
+	    iDeleteCallbackCounter = 0;
+
+	    for ( TInt k( 0 ); k < iDeleteTagListArray->Count(); k++ )
+	        {
+	        TInt ret = 
+	            iTagManager->DeleteTag( this, (*iDeleteTagListArray)[k] );
+
+	        if ( ret != KErrNone )
+	            {
+	            TRAPD( err, DoHandleEventFailedL(); );
+	            if( err != KErrNone ) 
+	            	{
+	            	RUBY_ERROR1( "CNssContactHandlerImplementation::DoRemoveNamesCallDeleteTag Error handling Left with [%d]", err );
+	            	}
+	            return;  /** @todo reengineer into single return path */
+	            }
+	        }
+    	} // if there are tags to delete
+    else
+    	{
+    	// if there were no tags to delete (attempt to delete non-existing tags)
+    	// simulating callback from successful deletion of.. 0 tags
+    	//iDeleteCallbackCounter = -1;
+    	//DeleteTagCompleted();
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesCallDeleteTag Here!" );
+    	}
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoRemoveNamesAfterDeleteTagCompleted
+// DeleteTag() callback calls this funciton. It counts
+// the number of callbacks, and when all callbacks have arrived,
+// goes to the next phase.
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoRemoveNamesAfterDeleteTagCompleted()
+	{
+    iDeleteCallbackCounter++;
+    
+    RUBY_DEBUG2( "CNssContactHandlerImplementation::DoRemoveNamesAfterDeleteTagCompleted. iDeleteCallbackCounter [%d], Count() [%d]", iDeleteCallbackCounter, iDeleteTagListArray->Count() );
+    
+    if ( iDeleteCallbackCounter == iDeleteTagListArray->Count() )
+        {
+        if( iNormalChangesError == KErrNone ) 
+        	{
+        	TRAPD( err, RemovingNamesCompletedL() );
+    		if ( err != KErrNone )
+        		{
+        		RUBY_ERROR1( "CNssContactHandlerImplementation::DoRemoveNamesAfterDeleteTagCompleted. Error [%d] in RemovingNamesCompletedL", err );
+        		}
+        	}
+        else 
+        	{
+        	// There is not much we can do about the deletion error
+        	// Retrying deletion can cause endless cycle
+        	// Sometimes failed deletions are ok (if we tried to delete non-existing tag)
+        	/** @todo reengineer SpeechItemTrainer (and/or SRS plugin) to report deletion 
+        	    of non-existing tag as success. After all they are not in the DB */
+        	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoRemoveNamesAfterDeleteTagCompleted Deletion failed. Still simulating a successful one" );
+        	TRAPD( err, RemovingNamesCompletedL() );
+    		if ( err != KErrNone )
+        		{
+        		RUBY_ERROR1( "CNssContactHandlerImplementation::DoRemoveNamesAfterDeleteTagCompleted. Error [%d] in RemovingNamesCompletedL", err );
+        		}
+        	}  // if (iNormalChangesError == KErrNone) else
+        }  // if count
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::RemovingNamesCompletedL
+// Cleans up after some names have been removed
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::RemovingNamesCompletedL()
+    {
+	RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::RemovingNamesCompletedL" );
+    iDelList.Close();
+
+    if ( iDeleteTagListArray )
+        {
+        iDeleteTagListArray->ResetAndDestroy();
+        iDeleteCallbackCounter = 0;
+        }
+
+    DoAddNamesL();
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoAddNamesL
+// Starts name addition sequence by fetching contacts data and ordering
+// voice tags training
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoAddNamesL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::DoAddNamesL" );
+    TInt k( 0 );
+
+    if ( iAddList.Count() == 0 )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesL Nothing to add. Setting iState = ECHIdle. Return" );
+    	SetState ( ECHIdle );
+    	// If there are events on the list, DoAddNamesCompleted will fire them
+        DoAddNamesCompletedL();  
+        }
+    else 
+        {
+        // Create new tags and train them.
+        for ( k = 0; k < iAddList.Count(); k++ )
+            {
+            // 3 names may be created from one contact:
+            //  * Main name (firstname + lastname XOR companyname)
+            //  * Reversed order name (usually lastname + firstname, depends on the UI language)
+            //      -> only if NSSVAS_CONTACTHANDLER_FREEORDER is defined
+            //  * Nickname
+
+            TContactData contactData;
+
+            contactData.iID = iAddList[k].iContactId;
+            contactData.iSyncTime.UniversalTime();
+
+            // Nickname
+            contactData.iTitle = NULL;
+            TRAPD( err, contactData.iTitle = GetContactNicknameL( iAddList[k].iContactId ) );
+
+            if ( contactData.iTitle != NULL )
+                {
+                CleanupStack::PushL( contactData.iTitle );
+                contactData.iType = ETagTypeNickName;
+                User::LeaveIfError( iContactQueue.Append( contactData ) );
+                CleanupStack::Pop( contactData.iTitle );
+                }
+
+            // Main name ( Using GetContactTitleL() )
+            contactData.iTitle = NULL;
+            TBool bothFound = EFalse;
+            TVasTagType tagType( ETagTypeUnknown );
+            TRAP( err, contactData.iTitle = GetContactTitleL( iAddList[k].iContactId, ETrue, bothFound, tagType ) );
+
+            // If all the name fields are empty, nothing
+            // can be done for the tag. We're finished.
+            if ( contactData.iTitle != NULL )
+                {
+                RUBY_DEBUG2( "CNssContactHandlerImplementation::DoAddNamesL For Contact id [%d] title is: [%S]", iAddList[k].iContactId, contactData.iTitle );
+                CleanupStack::PushL( contactData.iTitle );
+                contactData.iType = tagType;
+                User::LeaveIfError( iContactQueue.Append( contactData ) );
+                CleanupStack::Pop( contactData.iTitle );
+                }
+
+    #ifdef NSSVAS_CONTACTHANDLER_FREEORDER
+            // Default order added previously, now adding
+            // secondary order if both first and lastnames are found
+            if ( bothFound )
+                {
+                contactData.iTitle = NULL;
+                TRAPD( err, contactData.iTitle = GetContactTitleL( iAddList[k].iContactId, EFalse, bothFound, tagType ) );
+                if ( contactData.iTitle != NULL )
+                    {
+                    CleanupStack::PushL( contactData.iTitle );
+                    contactData.iType = tagType;
+                    User::LeaveIfError( iContactQueue.Append( contactData ) );
+                    CleanupStack::Pop( contactData.iTitle );
+                    }
+                }
+    #endif // NSSVAS_CONTACTHANDLER_FREEORDER
+
+            }
+
+        // No tag had any text.
+        if ( iContactQueue.Count() == 0 )
+            {
+            RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesL. No tag had any text, return" );
+            DoAddNamesCompletedL();
+            }
+        else 
+            {
+            // At least some tag has some text
+            RUBY_ASSERT_DEBUG( iTagArray.Count() == 0, User::Panic( KFile, __LINE__ ) );
+
+            for ( k = 0; k < iContactQueue.Count(); k++ )
+                {
+                // (1) Create a new tag
+                if ( iNewTag != NULL ) 
+                    {
+                    // If previous call to this function leaves, iNewTag can 
+                    // be not deleted
+                    delete iNewTag;
+                    iNewTag = NULL;
+                    }
+                iNewTag = iTagManager->CreateTagL( iContext );
+
+                MNssRRD* rrd = iNewTag->RRD();
+                MNssSpeechItem* speechItem = iNewTag->SpeechItem();
+
+                // (2) Fill RRD. RRD contains client-chosen data about the tag.
+                //     In case of name dialing, RRD contains the contact ID,
+                //     which is used later to get the phone number.
+                CArrayFixFlat<TInt> *id = new (ELeave) CArrayFixFlat<TInt>( 1 );
+
+                CleanupStack::PushL( id );
+
+                id->AppendL( iContactQueue[k].iID ); // ID
+                // select a number field for voice tag
+                // TInt fieldIndex( 0 );
+
+        		WaitUntilNoSyncBackupIsRunning();
+                TRAPD( err, ReadContactL( iContactQueue[k].iID ); );
+                if ( err == KErrNone )
+                    {
+                    // 1. Default voice call number set by the user
+                    TInt found = KErrNotFound;
+                    TRAP( found, iPbkHandler->FindDefaultContactFieldL( EDefaultCommand ) );
+                    
+                    if ( found == KErrNotFound )
+                        {
+                        for( TInt i = 0; i < KTaggableFieldsCount; i++) 
+                            {
+                            TRAP( found, iPbkHandler->FindFieldL( KTaggableFields[i] ) );
+                            if( found == KErrNone && ( !iPbkHandler->IsFieldEmptyL() ) )
+                                {
+                                break;  // found field
+                                }
+                            else 
+                                {
+                                // When field->IsEmptyOrAllSpaces(), it is the same for us as no field present
+                                found = KErrNotFound;
+                                }
+                            }  // for i < KTaggableFieldsCount
+                        }
+
+                    if ( found == KErrNone ) // found and is not empty
+                        {
+                        id->AppendL( iPbkHandler->FieldIdL() ); // field ID to array
+                        id->AppendL( EDial );
+                        id->AppendL( iContactQueue[k].iType );
+                        id->AppendL( EDefaultCommand );
+                        rrd->SetIntArrayL ( id );
+                                                
+                        // (3) Set the training text.
+                        speechItem = iNewTag->SpeechItem();
+                        speechItem->SetTextL( *iContactQueue[k].iTitle );
+                 
+                        User::LeaveIfError( iTagArray.Append( iNewTag ) );
+                        // Leave protection for iNewTag completed
+                        // Ownership and deletion responsibility moved
+                        // to iTagArray
+                        iNewTag = NULL;
+                        }
+                    else
+                        {
+                        // field not found or is empty
+                        RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesL Did NOT identify a suitable voice dial field for contact id [%d]", iContactQueue[k].iID);
+                        
+                        
+                        delete iNewTag;
+                        iNewTag = NULL;
+                        }  // if field else
+#ifdef __SIND_EXTENSIONS
+                    
+                    // this part creates separate voice tags for extensions
+                    for ( TInt i(0); i < iExtensionList.Count(); i++ )
+                        {
+                        found = KErrNotFound;
+                        TVasExtensionAction action = iExtensionList[i].iAction;
+                        TPbkFieldId fieldId = iExtensionList[i].iId;
+                        
+                        // default message number
+                        // default video
+                        // default e-mail
+                        // default VOIP  
+                        if ( action == ENewMessage ||
+                             iExtensionList[i].iId == EPbkFieldIdPhoneNumberVideo ||
+                             iExtensionList[i].iId == EPbkFieldIdEmailAddress ||
+                             iExtensionList[i].iId == EPbkFieldIdVOIP )
+                            {
+                            // @todo Should use DefaultMessageField or something similar!!
+                            TRAP( found,
+                                iPbkHandler->FindDefaultContactFieldL( iExtensionList[i].iCommand ) );
+                            }
+                            
+                        /*if ( extensionField == NULL )
+                            {
+                            extensionField = item->FindField( iExtensionList[i].iId );
+                            }
+                            
+                        if ( extensionField == NULL && field != NULL 
+                             && ( action == ENewMessage ) )
+                            {
+                            // if default neither default field or mobile field was not found
+                            // message use normal SIND field
+                            extensionField = field;
+                            fieldId = field->FieldInfo().FieldId();
+                            }*/
+                            
+                        // If field was not found, try to find it based on the priority lists
+                        if ( found == KErrNotFound )
+                            {
+                            found = FindExtensionField( action, iExtensionList[i].iId );
+                            // If field was found, check the field ID
+                            if ( found == KErrNone )
+                                {
+                                fieldId = iPbkHandler->FieldIdL();
+                                }
+                            }
+                            
+                        if ( found == KErrNone )
+                            {
+                            // create new tag
+                            iNewTag = iTagManager->CreateTagL( iContext );
+
+                            rrd = iNewTag->RRD();
+                            speechItem = iNewTag->SpeechItem();
+                            
+                            // set RRD data
+                            CArrayFixFlat<TInt> *extIds = new (ELeave) CArrayFixFlat<TInt>( 1 );
+                            CleanupStack::PushL( extIds );
+
+                            extIds->AppendL( iContactQueue[k].iID ); 
+                            if ( iExtensionList[i].iCommand == EMessageCommand ||
+                                  iExtensionList[i].iCommand == EVideoCommand )
+                                {
+                                TInt id = iPbkHandler->FieldIdL();
+                                if ( id )
+                                    {
+                                    extIds->AppendL( id );
+                                    }
+                                else
+                                    {
+                                    extIds->AppendL( fieldId );
+                                    }
+                                }
+                            else
+                                {
+                                extIds->AppendL( fieldId );
+                                }
+                            extIds->AppendL( action );
+                            extIds->AppendL( iContactQueue[k].iType );
+                            extIds->AppendL( iExtensionList[i].iCommand );
+
+                            rrd->SetIntArrayL ( extIds );
+                                                
+                            // set the training text.
+                            TPtr namePtr( iContactQueue[k].iTitle->Des() );
+                            TPtr extensionPtr( iExtensionList[i].iText->Des() );
+                            HBufC* tempTitle = HBufC::NewLC( namePtr.Length() + extensionPtr.Length() + KTrainingIndexSize );
+                            TPtr titlePtr( tempTitle->Des() );                                                           
+                            
+                            //not work: titlePtr.AppendFormat( extensionPtr, namePtr ); 
+                            
+                            titlePtr = extensionPtr;
+                            AppendExtensionMarker( titlePtr );
+                            TInt index = titlePtr.Find( KExtensionFormatString );
+                            if ( index >= 0 )
+                                {
+                                // replace %U with name
+                                titlePtr.Delete( index, 2 ); // delete %U
+                                titlePtr.Insert( index, namePtr ); 
+                                }
+                            speechItem->SetTextL( titlePtr );
+                        
+                            User::LeaveIfError( iTagArray.Append( iNewTag ) );
+                            iNewTag = NULL; //ownership changed
+                            CleanupStack::PopAndDestroy( tempTitle );  
+                            CleanupStack::PopAndDestroy( extIds );  
+                            }
+                        }
+
+#endif // __SIND_EXTENSIONS                       
+                    // delete id
+                    CleanupStack::PopAndDestroy( id );
+                    }
+                else 
+                    {
+                    // Opening contact failed. E.g. if it was just deleted by user	
+                    RUBY_DEBUG2( "CNssContactHandlerImplementation::DoAddNamesL Failed to open contact id [%d]. Leave [%d]", iContactQueue[k].iID, err);
+                    CleanupStack::PopAndDestroy( id );
+                    delete iNewTag;
+                    iNewTag = NULL;
+                    /** @todo Try reengineering duplicated cleanups into single piece 
+                    of the code */
+                    }
+                }  // for k .. iContactQueue
+
+            if ( iTagArray.Count() == 0 )
+                {
+                // If there are events on the list, DoAddNamesCompleted will fire them
+                DoAddNamesCompletedL();  
+                RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesL. Returned from DoAddNamesCompleted. Setting iState = ECHIdle" );
+        		SetState ( ECHIdle );
+                }
+            else 
+                {
+                RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesL Before training tags. TagCount = [%d]",
+        	            iTagArray.Count() );
+
+                iTrainCallbackCounter = 0;
+                for ( k = 0; k < iTagArray.Count(); k++ )
+                    {
+                    MNssSpeechItem* speechItem = iTagArray[k]->SpeechItem();
+
+                    MNssSpeechItem::TNssSpeechItemResult trainRet 
+                    = speechItem->TrainTextL( this, iTrainingParams );
+
+                    if ( trainRet != MNssSpeechItem::EVasErrorNone )
+                        {
+                        RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesL : TrainTextL call failed." );
+                        // Not much we can do except for timed retry.
+                        // This stops the contact handler.
+                        DoHandleEventFailedL();
+                        break;  // no processing anymore. Quit function
+                        }
+                    }  // for k < iTagArray.Count()
+                }  // if iTagArrayCount != 0
+            }
+        }  // if ( iAddList.Count() != 0 )
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoAddNamesTrainingFinished
+// Called after training of a current pack of tags has finished. 
+// Starts saving tags.
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoAddNamesTrainingFinished()
+    {
+    iSaveCallbackCounter = 0;
+    iRetry = 0; // retry, if save tag fails
+    iNormalChangesError = 0; // to record failures in save tag
+
+    DoAddNamesSaveTag();
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoAddNamesSaveTag
+// This function has two branches:
+// (1) Initiate saving tags
+// (1) After all tags have been saved, go to the next phase.
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoAddNamesSaveTag()
+    {
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesSaveTag" );
+    TInt retCode;
+
+    // If all tags have been saved, go to the next phase.
+    if ( iSaveCallbackCounter == iTagArray.Count() )
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesSaveTag All tags have been saved, go to the next phase" );
+        // Tags saved - go to the next phase
+        if ( iNormalChangesError == KErrNone )
+            {
+            // This function is called once per 100 contacts -> It is ok to use TRAP
+            TRAPD( error, DoAddNamesCompletedL() );
+            if( error != KErrNone ) 
+                {
+                /** @todo Test this branch */
+                // Some fatal error occured
+                RUBY_ERROR1( "DoAddNamesSaveTag DoAddNamesCompletedL failed with [%d]. Disabling SIND",
+                            error );
+                DisableEventHandling();
+                }
+            }
+        else
+            {
+            RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesSaveTag Saving tags failed. Try again a few times" );
+            // Saving tags failed. Try again a few times, and if it still
+            // doesn't work, go to fatal error handler.
+            if ( iRetry < KVASCHMaxRetry )
+                {
+                iRetry++;
+                RUBY_DEBUG2( "CNssContactHandlerImplementation::DoAddNamesSaveTag Retried saving [%d] times. [%d] retries left",
+                            iRetry, KVASCHMaxRetry - iRetry);
+                iSaveCallbackCounter = 0;
+                iNormalChangesError = KErrNone;
+                
+                DoAddNamesSaveTag();
+                }
+            else
+                {
+                RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesSaveTag Retried saving [%d] times. Still saving fails. Handling error", iRetry );
+                NormalChangesHandleError();
+                }
+            }
+        }  // if ( iSaveCallbackCounter == iTagArray.Count() )
+    
+    // If this is the first call to this function,
+    // make "save tag" calls. After that, wait for the callbacks.
+    else if ( iSaveCallbackCounter == 0 )
+        {
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesSaveTag iSaveCallbackCounter == 0. Run SaveTag for [%d] contacts",
+                    iTagArray.Count());
+        for ( TInt k( 0 ); k < iTagArray.Count(); k++ )
+            {
+            retCode = iTagManager->SaveTag( this, iTagArray[k] );
+
+            if ( retCode != KErrNone )
+                {
+                RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesSaveTag - SaveTag failed." );
+				TRAPD( err, DoHandleEventFailedL(); );
+				if( err != KErrNone ) 
+					{
+					RUBY_ERROR1( "CNssContactHandlerImplementation::DoAddNamesSaveTag handling error Left with [%d]", err );
+					}
+                return;
+                }  // if retCode
+            }  // for iTagArray
+        }  // else if iSaveCallbackCounter == 0
+    else 
+    	{
+    	// iSaveCallbackCounter != 0, but different from iTagArray.Count()
+    	// This means, that SaveTag callbacks are still coming. We will wait for them
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesSaveTag. iSaveCallbackCounter != 0, but different from iTagArray.Count()" );
+        }
+    } 
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoAddNamesSaveTagCompleted
+// Saving single tag has completed. 
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoAddNamesSaveTagCompleted( TInt aError )
+    {
+    iSaveCallbackCounter++;
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesSaveTagCompleted iSaveCallbackCounter became [%d]",
+                iSaveCallbackCounter);
+	// |= to let single KErrGeneral fail any number of KErrNone
+    iNormalChangesError |= aError;
+
+    // Check if all tags have been saved.
+    DoAddNamesSaveTag();
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoAddNamesCompleted
+// When adding names has successfully finished, clean up.
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoAddNamesCompletedL()
+    {
+    RUBY_DEBUG2( "CNssContactHandlerImplementation::DoAddNamesCompleted. iDeleteCallbackCounter [%d], Count() [%d]", iDeleteCallbackCounter, iDeleteTagListArray->Count() );
+	TInt initialDeleteTagListCount = iDeleteTagListArray->Count();    
+    
+    iSaveCallbackCounter = 0;
+    iTrainCallbackCounter = 0;
+    
+    // DoAddNamesCompleted if often called after voice tags have been added =>
+    // Nothing has to be done at all
+    TBool changedDatabase = EFalse;  
+
+#ifndef __SIND_EXTENSIONS
+// Set VAS_SETS_VOICETAG on if old behaviour is needed.
+// That is, VAS sets on the voice tag field to Phonebook engine and Phonebook UI checks the contacts DB for voice tags.
+// Off means that VAS does not set voice tag field but instead Phonebook asks from VAS.
+#ifdef VAS_SETS_VOICETAG
+    // add voice tag fields
+    // iTagArray contains only successfully trained tags.
+    // Failed items are removed.
+    for ( TInt i( 0 ); i < iTagArray.Count(); i++ )
+        {
+        MNssRRD* rrd = iTagArray[i]->RRD();
+        CArrayFixFlat<TInt>* intArray = rrd->IntArray();
+        RUBY_ASSERT_DEBUG( intArray->Count() >= 2, User::Panic( KFile, __LINE__ ) );
+        if ( intArray->Count() >= 2 )
+            {
+            TBool committed( EFalse ); // ETrue if contact is committed already
+            TInt contactId( intArray->At( 0 ) );
+            RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesCompleted. Working on contact id [%d]",
+                        contactId);
+            TInt fieldId( intArray->At( 1 ) );
+
+            WaitUntilNoSyncBackupIsRunning();
+            // Open contact item based on id
+            TRAPD( errFor,
+                OpenContactL( contactId );
+                
+                RUBY_DEBUG1( "DoAddNamesCompleted Opened contact [%d]", contactId );
+    			TInt found == KErrNotFound;
+    			TRAP( found, iPbkHandler->FindDefaultContactFieldL( EDefaultCommand ) );
+                if ( found == KErrNotFound )
+                    {
+                    TRAP( found, iPbkHandler->FindFieldL( fieldId ) );
+                    }
+    					// field - field, that SHOULD have voice tag attached
+                        	
+                if ( found == KErrNone )
+                    {
+                    TRAP( error, iPbkHandler->ChangeVoiceTagFieldL( ETrue ) );
+                    if ( error == KErrNone )
+                        {
+                        RUBY_DEBUG1("DoAddNamesCompleted  Successfully added icon to the contact [%d]", 
+                                    contactId);
+                        iPbkHandler->CloseContactL( ETrue );
+                        RUBY_DEBUG1("DoAddNamesCompleted  Successfully committed contact [%d]", 
+                                    contactId);
+                        iVoiceTagAddedList.Append( contactId );
+                        changedDatabase = ETrue;
+                        committed = ETrue;
+                        }
+                    }
+                else
+                    {
+                    // field not found anymore
+                    RUBY_DEBUG2("DoAddNamesCompleted Field [%d] not found in (already deleted from?) contact [%d]",
+                                fieldId, contactId );
+                    iDeleteTagListArray->AppendL( NULL ); // One DeleteTag will generate one callback
+                    iTagManager->DeleteTag( this, iTagArray[i] );
+                    }
+                if ( !committed )
+                    {
+                    RUBY_DEBUG1("DoAddNamesCompleted Did not change contact [%d]. Closing without committing", 
+                       	            contactId);
+                    iPbkHandler->CloseContactL( EFalse );
+                    }
+            );  // TRAPD errFor
+            if ( errFor != KErrNone ) 
+                {
+                RUBY_DEBUG2("CNssContactHandlerImplementation::DoAddNamesCompleted Failed to add icon for contact [%d]. Error [%d]",
+                            contactId, errFor);
+                    // voice tag was not in the contacts database, delete it from VAS
+                    // One DeleteTag will generate one callback
+                iDeleteTagListArray->AppendL( NULL );
+                iTagManager->DeleteTag( this, iTagArray[i] );
+                }
+            }  // if intArray->Count() >= 2
+        }  // for  iTagArray
+#endif // VAS_SETS_VOICETAG
+#endif //__SIND_EXTENSIONS        
+
+    iTagArray.ResetAndDestroy();
+
+    iAddList.Close();
+    
+#ifndef __SIND_EXTENSIONS
+#ifdef VAS_SETS_VOICETAG
+    // Remove voice tag icons for contacts, that failed to be trained or saved
+    for( TInt l = 0 ; l < iRemoveIconList.Count(); l++ ) 
+        {
+        WaitUntilNoSyncBackupIsRunning();
+        TRAPD( error, OpenContactL( iRemoveIconList[l] ) );
+        if ( error != KErrNone ) 
+            {
+            RUBY_DEBUG2( "CNssContactHandlerImplementation::DoAddNamesCompleted Failed to open contact [%d]. Error [%d]", iRemoveIconList[l], error);
+            }
+        else 
+            {           
+            TRAP( error, iPbkHandler->ChangeVoiceTagFieldL( EFalse ) );
+            if ( error == KErrNotFound )
+                {
+                // Nothing to remove. Already no voice tag icon
+                TRAP( error, iPbkHandler->CloseContactL( EFalse ) );
+                if ( error != KErrNone ) 
+                    {
+                    RUBY_ERROR2( "CNssContactHandlerImplementation::DoAddNamesCompleted Failed to close contact [%d]. Error [%d]", iRemoveIconList[l], error);
+                    }
+                }
+            else if ( error != KErrNone )
+                {
+                RUBY_ERROR2( "CNssContactHandlerImplementation::DoAddNamesCompleted  Failed to remove voice tag icon for contact [%d]. Error [%d]", iRemoveIconList[l], error);
+                TRAP( error, iPbkHandler->CloseContactL( EFalse ) );
+                if ( error != KErrNone ) 
+                    {
+                    RUBY_ERROR2( "CNssContactHandlerImplementation::DoAddNamesCompleted Failed to close contact [%d]. Error [%d]", iRemoveIconList[l], error);
+                    }
+                }
+            else
+                {
+                iVoiceTagAddedList.Append( iRemoveIconList[l] );
+                TRAP( error, iPbkHandler->CloseContactL( ETrue ) );
+                if ( error != KErrNone ) 
+                    {
+                    RUBY_ERROR2( "CNssContactHandlerImplementation::DoAddNamesCompleted Failed to commit contact [%d]. Error [%d]", iRemoveIconList[l], error);
+                    }
+                }            
+            
+            }  // if opened contact successfully
+        
+        }
+#endif // VAS_SETS_VOICETAG
+#endif //__SIND_EXTENSIONS
+        
+    iRemoveIconList.Close();
+
+    for( TInt k( 0 ); k < iContactQueue.Count(); k++ )
+        {
+        delete iContactQueue[k].iTitle;
+        iContactQueue[k].iTitle = NULL;
+        }
+    iContactQueue.Close();
+    
+    if( changedDatabase ) 
+    	{
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesCompleted changed DBx" );
+    	WaitUntilNoSyncBackupIsRunning();
+	    TRAPD(err, iPbkHandler->CompressL() );
+	    if ( err )
+    		{
+    		RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesCompleted Contacts DB compression failed. Error [%d]", 
+    		            err);
+    		}
+    	}
+    else 
+    	{
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesCompleted did NOT change DB" );
+    	}
+    	
+    	// full resyncs are always tag additions
+    if( initialDeleteTagListCount == iDeleteTagListArray->Count() ) 
+    	{
+    	SetState( ECHIdle );
+    	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesCompleted Syncing with phonebook generated NO deletions" );
+    	// then full resync will not be initiated
+    	iConsecutiveErrorFullResync = 0;
+	    if ( iEventArray.Count() > 0 )
+        	{
+    		RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesCompleted There are still [%d] events in the queue. Call DoHandleEvents for them",
+    		            iEventArray.Count() );
+        	TRAPD( err, DoHandleEventsL() );
+        	if ( err != KErrNone )
+	            {
+	            RUBY_ERROR1( "CNssContactHandlerImplementation::DoAddNamesCompleted. Error [%d] in DoHandleEventsL", err );
+            	}
+        	}
+    	else 
+       		{
+       		// No self-generated events, and no pending events to handle
+       		// This is the only place in the code, where everything is completed 
+       		// and nothing is pending
+       		RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesCompleted All the updates completed. No DB event is pending" );
+       		
+       		}
+    	} 
+    else 
+    	{
+    	RUBY_DEBUG1( "CNssContactHandlerImplementation::DoAddNamesCompleted Generated [%d] deletions. Starting to wait for callbacks", 
+    		iDeleteTagListArray->Count() - initialDeleteTagListCount);
+    	}
+       	
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::DoAddNamesCompleted completed" );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::NormalChangesHandleError
+// Handle errors which happend when updating normal changes
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::NormalChangesHandleError()
+    {
+    // We can't know, what went wrong.
+    // Stop contact handler, so that the next time the phone is booted
+    // full synchronization happens.
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::NormalChangesHandleError " );
+    TRAPD( err, DoHandleEventFailedL(); );
+    if( err != KErrNone ) 
+        {
+        RUBY_ERROR1( "CNssContactHandlerImplementation::NormalChangesHandleError DoHandleEventFailedL Left with [%d]", err );
+        }
+    }
+
+//---------------------------------------------------------
+// CNssContactHandlerImplementation::HandleTrainComplete
+// Saves the tag after successful training.
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::HandleTrainComplete( TInt aErrorCode )
+    {
+    if( aErrorCode == KErrNone )
+        {
+        RUBY_DEBUG1( "Training OK for %d:th name.", iTrainCallbackCounter );
+
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::HandleTrainComplete. iState [%d]", iState);
+        RUBY_ASSERT_DEBUG( iState == ECHInitializing || 
+                        iState == ECHHandlingNormalChanges,
+                        User::Panic( KFile, __LINE__ ) );
+
+        iTrainCallbackCounter++;
+
+        if ( iTrainCallbackCounter == iTagArray.Count() )
+            {
+            if ( iState != ECHInitializing )
+                {
+                // assert at the beginning of the function guarantees, 
+                // that iState == ECHHandlingNormalChanges 
+                DoAddNamesTrainingFinished();
+                }
+            }        
+        }
+    
+    else // aErrorCode != KErrNone
+        {
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::HandleTrainComplete. Training failed for %d:th name.\n",
+                    iTrainCallbackCounter );
+
+        RUBY_ASSERT_DEBUG( iState == ECHInitializing || 
+                        iState == ECHHandlingNormalChanges,
+                        User::Panic( KFile, __LINE__ ) );
+
+    	// Order removal of voice tag icon if present
+    	MNssRRD* rrd = iTagArray[iTrainCallbackCounter]->RRD();
+        CArrayFixFlat<TInt>* intArray = rrd->IntArray();
+        RUBY_ASSERT_DEBUG( intArray->Count() >= 2, User::Panic( KFile, __LINE__ ) );
+        if ( intArray->Count() >= 2 )
+        	{
+        	TInt error = iRemoveIconList.Append( intArray->At(0) );
+        	if( error != KErrNone ) 
+        		{
+        		RUBY_ERROR2( "CNssContactHandlerImplementation::HandleTrainError Failed to insert [%d] into iRemoveIconList. Error [%d]",
+        					intArray->At(0), error);
+        		}
+            }
+      	else
+            {
+            RUBY_ERROR2( "CNssContactHandlerImplementation::HandleTrainComplete rrd->IntArray()->Count [%d] for iTrainCallbackCounter [%d]", 
+            			intArray->Count(), iTrainCallbackCounter);   	
+            }
+                
+
+        delete iTagArray[ iTrainCallbackCounter ];
+        iTagArray.Remove( iTrainCallbackCounter );
+
+        if ( iTrainCallbackCounter == iTagArray.Count() )
+            {
+            if ( iState == ECHHandlingNormalChanges )
+                {
+                DoAddNamesTrainingFinished();
+                }
+            else 
+            	{
+            	RUBY_ERROR1( "CNssContactHandlerImplementation::HandleTrainComplete Unexpected state [%d]", iState);
+            	}
+            }        
+        }
+    }
+
+//---------------------------------------------------------
+// CNssContactHandlerImplementation::HandleTrainError
+// Handles single tag training failure
+//---------------------------------------------------------
+//
+/*void CNssContactHandlerImplementation::HandleTrainError( enum MNssTrainTextEventHandler::TNssTrainResult )
+    {
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::HandleTrainError Training failed for %d:th name.\n",
+                iTrainCallbackCounter );
+
+    RUBY_ASSERT_DEBUG( iState == ECHInitializing || 
+                    iState == ECHHandlingNormalChanges,
+                    User::Panic( KFile, __LINE__ ) );
+
+	// Order removal of voice tag icon if present
+	MNssRRD* rrd = iTagArray[iTrainCallbackCounter]->RRD();
+    CArrayFixFlat<TInt>* intArray = rrd->IntArray();
+    RUBY_ASSERT_DEBUG( intArray->Count() >= 2, User::Panic( KFile, __LINE__ ) );
+    if ( intArray->Count() >= 2 )
+    	{
+    	TInt error = iRemoveIconList.Append( intArray->At(0) );
+    	if( error != KErrNone ) 
+    		{
+    		RUBY_ERROR2( "CNssContactHandlerImplementation::HandleTrainError Failed to insert [%d] into iRemoveIconList. Error [%d]",
+    					intArray->At(0), error);
+    		}
+        }
+  	else
+        {
+        RUBY_ERROR2( "CNssContactHandlerImplementation::HandleTrainError rrd->IntArray()->Count [%d] for iTrainCallbackCounter [%d]", 
+        			intArray->Count(), iTrainCallbackCounter);   	
+        }
+            
+
+    delete iTagArray[ iTrainCallbackCounter ];
+    iTagArray.Remove( iTrainCallbackCounter );
+
+    if ( iTrainCallbackCounter == iTagArray.Count() )
+        {
+        if ( iState == ECHHandlingNormalChanges )
+            {
+            DoAddNamesTrainingFinished();
+            }
+        else 
+        	{
+        	RUBY_ERROR1( "CNssContactHandlerImplementation::HandleTrainError Unexpected state [%d]", iState);
+        	}
+        }
+    }*/
+
+//---------------------------------------------------------
+// CNssContactHandlerImplementation::FullResyncStart
+// Starts a full synchronization
+//---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::FullResyncStart()
+    {
+    // If we have synchronized earlier, we must delete the old context.
+    if ( iHaveWeEverSynced )
+        {
+        iContextManager->DeleteContext( this, iContext );
+        }
+    else
+        {
+        TRAPD( err, FullResyncCreateContextL() );
+        if ( err != KErrNone )
+            {
+            RUBY_ERROR1( "CNssContactHandlerImplementation::FullResyncStart. Error [%d] in FullResyncCreateContextL", err );
+            }
+        }
+    }
+
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::FullResyncCreateContextL
+// Full resync: Create a new context
+// (prev: Destroy old context, next:populate the context with tags)
+// ------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::FullResyncCreateContextL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::FullResyncCreateContextL" );
+    if ( iContext != 0 )
+        {
+        delete iContext;
+        iContext = 0;
+        }
+
+    iContext = iContextManager->CreateContextL();
+    iContext->SetNameL( KNssCHNameDialContext );
+    iContext->SetGlobal( ETrue );
+
+    TBuf8<KClientDataSize> clientDataBuf;
+    iClientData.iLanguage = User::Language();
+    iClientData.iContactSyncId = KErrNotFound;
+    	
+    TRAPD( error, iClientData.ExternalizeL( clientDataBuf ) );
+    if ( !error )
+        {
+        iContext->SetClientData( clientDataBuf );
+        iContextManager->SaveContext( this, iContext );
+        }
+    }
+
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::FullResyncCreateChanges
+// Create tags and send training requests to VAS.
+// VAS trains them and calls back when it's ready
+// ------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::FullResyncCreateChangesL()
+    {
+	RUBY_DEBUG_BLOCK( "CNssContactHandlerImplementation::FullResyncCreateChangesL" );
+
+    WaitUntilNoSyncBackupIsRunning();
+
+    CContactIdArray* ids = iPbkHandler->ContactIdArrayLC();
+	
+	RUBY_DEBUG0( "CNssContactHandlerImplementation::FullResyncCreateChanges. iContactQueue.Count() == 0" );
+    RUBY_ASSERT_DEBUG( iContactQueue.Count() == 0, User::Panic( KFile, __LINE__ ) );
+    // Create change events for training
+    for ( TInt k( 0 ); k < ids->Count(); k++ )
+        {
+        TPhonebookEvent event;
+        event.iContactId = (*ids)[k];
+        event.iType = EContactAdded;
+        iEventArray.Append( event );
+        }
+
+    CleanupStack::PopAndDestroy( ids ); // Cleanup stack: empty
+
+    // go to processing events
+    SetState ( ECHIdle );
+    TRAPD( err, DoHandleEventsL() );
+    if ( err != KErrNone )
+        {
+        RUBY_ERROR1( "CNssContactHandlerImplementation::FullResyncCreateChanges. Error [%d] in DoHandleEventsL", err );
+        }
+    }
+
+// ------------------------------------------------------------    
+// CNssContactHandlerImplementation::DeleteContextCompleted
+// DeleteContext callback. Deleting a context is part of
+// full synchronization.
+// ------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DeleteContextCompleted( TInt aErrorCode )
+    {
+    if( aErrorCode == KErrNone )
+        {
+        // Go to the next phase of full synchronization
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::DeleteContextCompleted. iState == ECHFullResync, iState [%d]", iState );
+        RUBY_ASSERT_DEBUG( iState == ECHFullResync, User::Panic( KFile, __LINE__ ) );
+        TRAPD( err, FullResyncCreateContextL() );
+        if ( err != KErrNone )
+            {
+            RUBY_ERROR1( "CNssContactHandlerImplementation::DeleteContextCompleted. Error [%d] in FullResyncCreateContextL", err );
+            }        
+        }
+    else
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DeleteContextCompleted failed" );
+        RUBY_ASSERT_DEBUG( iState == ECHFullResync, User::Panic( KFile, __LINE__ ) );
+
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::DeleteContextCompleted - can't handle, stopping." );
+    	TRAPD( err, DoHandleEventFailedL(); );
+    	if( err != KErrNone ) 
+    		{
+    		RUBY_ERROR1( "CNssContactHandlerImplementation::DeleteContextCompleted Left with [%d]", err);
+    		}        
+        }
+    }
+
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::CausedByVoiceTagAddition
+// Check if the event was caused by voice tag field adding
+// ------------------------------------------------------------
+//
+TBool CNssContactHandlerImplementation::CausedByVoiceTagAddition( const TPhonebookEvent& aEvent )
+	{
+	TBool isVoiceTagAddedEvent (EFalse);
+	if( EContactChanged == aEvent.iType )
+		{
+		for ( TInt i = 0; i < iVoiceTagAddedList.Count(); i++ )
+        	{
+        	if ( aEvent.iContactId == iVoiceTagAddedList[i] )
+        		{
+            	isVoiceTagAddedEvent = ETrue;
+            	iVoiceTagAddedList.Remove( i-- );  // "i--" because of removal
+            	// Continue iterations. We are not sure if voice tag for the given 
+            	// contact could be changed twice
+            	}
+        	}  // for
+		}  // if event type
+	return isVoiceTagAddedEvent;
+	}
+
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::PeriodicCallback
+// Static callback required by Symbian Timer services.
+// ------------------------------------------------------------
+//
+TInt CNssContactHandlerImplementation::PeriodicCallback( TAny* pX )
+	{
+	((CNssContactHandlerImplementation*)pX)->DoPeriodicCallback();
+	return KErrNone;  // useless for CPeriodic
+	}
+    
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::DoPeriodicCallback
+// Periodically check if there are some events to process
+// ------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DoPeriodicCallback()
+	{
+	RUBY_DEBUG0( "CNssContactHandlerImplementation::DoPeriodicCallback" );
+	// Check is needed to eliminate unnesessary TRAP and 64 bit time operations
+	// Note, that we are not checking for PeriodicAction(), but for iPeriodicHandleEventTimer == NULL
+	// PeriodicAction() is a method for detection of start of the action,
+	// while iPeriodicHandleEventTimer == NULL says if periodic action is being executed
+	// right *now*
+	
+	if ( ( iState == ECHIdle ) && ( iEventArray.Count() > 0 ) && ( !PeriodicAction() ) ) 
+		{
+		RUBY_DEBUG1( "CNssContactHandlerImplementation::DoPeriodicCallback. iState is ECHIdle, there are [%d] events to handle and no periodic action in progress", iEventArray.Count());
+		TRAPD( err, DoHandleEventsL());
+        if ( err != KErrNone )
+            {
+            RUBY_ERROR1( "CNssContactHandlerImplementation::DoPeriodicCallback. Error [%d] in DoHandleEventsL", err );
+            }
+        }  // if there are some events
+	else
+		{
+		RUBY_DEBUG0( "CNssContactHandlerImplementation::DoPeriodicCallback No events to handle"  );
+		}
+	}
+	
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::PeriodicAction
+// Detects periodic action.
+// Checks if many events have been received "lately"
+// ---------------------------------------------------------
+//
+TBool CNssContactHandlerImplementation::PeriodicAction()
+    {
+    // index of the first recorded call
+    TInt checkedIndex = iEventMomentIndex + 1;
+    checkedIndex = checkedIndex < KEventMomentsSize ? checkedIndex : 0;
+    TTime& checkedTime = iEventMoments[checkedIndex];
+    
+    // Check if the first recorded call happened "lately" = within last 
+    // KPeriodicActionInterval seconds
+    TTime currentTime;
+    currentTime.UniversalTime();
+    TTimeIntervalMicroSeconds diff = currentTime.MicroSecondsFrom( checkedTime );
+    TBool result = diff < iEndOfPeriodicActionInterval;
+    if ( result == EFalse ) 
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::PeriodicAction. Periodic action completed." );
+        RUBY_DEBUG2( "CNssContactHandlerImplementation::PeriodicAction. Periodic action completed. iEventMomentIndex [%d], checkedIndex [%d]", iEventMomentIndex, checkedIndex );
+        RUBY_DEBUG1( "currentTime [%d]", I64INT(currentTime.Int64()));
+        RUBY_DEBUG2( "CNssContactHandlerImplementation::PeriodicAction. diff [%d], iEndOfPeriodicActionInterval [%d]", I64INT(diff.Int64()), I64INT(iEndOfPeriodicActionInterval.Int64() ) );
+        
+        for( TInt i = 0; i < KEventMomentsSize; i++ ) 
+            {
+            RUBY_DEBUG2( "checkedIndex[%d] = [%d]", i, I64INT(iEventMoments[i].Int64() ) );
+            }
+        
+        // Periodic action completed. Or hasn't even been started
+        // Restore timeout values
+        // iEndOfPeriodicActionInterval = KInitialPeriodicActionInterval;
+        if ( iPeriodicHandleEventTimer != NULL ) 
+            {
+            // stop the timer, it was started, when periodic action was started
+            RUBY_DEBUG0( "CNssContactHandlerImplementation::PeriodicAction Stopping the periodic action timer" );
+            iPeriodicHandleEventTimer->Cancel();
+            delete iPeriodicHandleEventTimer;
+            iPeriodicHandleEventTimer = NULL;
+            }
+        }
+    else 
+        {
+        // Periodic action detected
+        // start the timer if it is not running yet
+        if( iPeriodicHandleEventTimer == NULL ) 
+            {
+            TRAPD( err, iPeriodicHandleEventTimer = CPeriodic::NewL( EPriorityNormal ) );
+            if( err != KErrNone ) 
+                {
+                // This is a bad situation, but not the fatal one.
+                // If we cannot use timer to detect end of periodic action,
+                // Let's disable periodic action detection at all
+                RUBY_DEBUG1( "CNssContactHandlerImplementation::PeriodicAction. PeriodicTimer creation failed. Error [%d]. Disabling periodic actions", err);
+                result = EFalse;
+                }
+            else 
+                {  // Timer was created successfully
+                RUBY_DEBUG0( "CNssContactHandlerImplementation::PeriodicAction Starting the periodic action timer" );
+                iPeriodicHandleEventTimer->Start( KPeriodicTimerInterval, KPeriodicTimerInterval, TCallBack( PeriodicCallback, this ) );
+                }
+            }
+        }
+    return result;
+    }
+	
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::UpdatePeriodicActionVars
+// Update variables, used to detect if periodic action is happening
+// ------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::UpdatePeriodicActionVars()
+    {
+    if ( ++iEventMomentIndex >= KEventMomentsSize )
+        {
+        iEventMomentIndex = 0;
+        }
+    iEventMoments[iEventMomentIndex].UniversalTime();
+    
+    // Update values used to detect end of periodic action
+    TTimeIntervalMicroSeconds32 currInterval = MaximalInterval( iEventMoments, KEventMomentsSize, iEventMomentIndex );
+    // 8 times. At the end of action, this would typically be no longer, than 0.5secs
+    // Note, that this is the interval fo KEventMomentsSize events
+    if ( ( currInterval.Int() << 3 ) >= ( KInitialPeriodicActionInterval ) ) 
+        {
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::UpdatePeriodicActionVars. Calculated interval is too big. Reverting periodic interval to the max [%d] mcs", KInitialPeriodicActionInterval);
+        iEndOfPeriodicActionInterval = KInitialPeriodicActionInterval;
+        }
+    else 
+        {
+        currInterval = currInterval.Int() << 3;  
+        RUBY_DEBUG1( "CNssContactHandlerImplementation::UpdatePeriodicActionVars. Adjusting periodic interval to [%d] mcs", currInterval.Int() );
+        iEndOfPeriodicActionInterval = currInterval.Int();
+        }
+    }
+
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::MaximalInterval
+// Return maximal interval from the array of time moments
+// ------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds32 CNssContactHandlerImplementation::MaximalInterval( const TTime aMoments[], const TInt aMomentsLength, const TInt aLastMomentIndex )
+    {
+    RUBY_ASSERT_DEBUG( aMomentsLength > 1, User::Panic( KFile, __LINE__ ) );
+    TInt currIndex( aLastMomentIndex );
+    TInt prevIndex = currIndex - 1 < 0 ? aMomentsLength - 1 : currIndex - 1;
+    TTimeIntervalMicroSeconds32 result( 0 );
+    TTimeIntervalMicroSeconds currInterval;
+    
+    for ( TInt i = 0; i < aMomentsLength - 1; i++ ) 
+        {
+        currInterval = aMoments[currIndex].MicroSecondsFrom( aMoments[prevIndex] );
+        const TInt64& currIntVal = currInterval.Int64();
+        TBool tooBigValue = currIntVal > KMaxTInt;
+        
+        // if high != 0, aMoments were filled in the incorrect way
+        // but we should not bug the user about it
+        if ( tooBigValue ) 
+            {
+            // this cannot be a negative value.. if moments are recorded in the correct order.
+            // Then non-zero high means, that interval is too big to fit into
+            // TTimeIntervalMicroSeconds32
+            RUBY_DEBUG0( "CNssContactHandlerImplementation::MaximalInterval. Maximal interval is out of bounds" );
+            result = TTimeIntervalMicroSeconds32( KMaxTInt );
+            break;
+            }
+        else 
+            {
+            // normal size value
+            // casting is safe - we checked, that it fits into TInt
+            TTimeIntervalMicroSeconds32 currInterval32 ( (TInt)currIntVal );
+            
+            if ( currInterval32 > result ) 
+                {
+                result = currInterval32;
+                }
+            }
+        currIndex = currIndex - 1 < 0 ? aMomentsLength - 1 : currIndex - 1;
+        prevIndex = currIndex - 1 < 0 ? aMomentsLength - 1 : currIndex - 1;
+        }  // for
+    return result;
+    }
+
+// ------------------------------------------------------------
+// CNssContactHandlerImplementation::SetState
+// Sets the contact handler state. 
+// In debug, panics (via asserts) if state change is not legal
+// ------------------------------------------------------------
+//
+void CNssContactHandlerImplementation::SetState( TContactHandlerState aState )
+	{
+    RUBY_DEBUG2( "CNssContactHandlerImplementation::SetState from [%d] to [%d]", iState, aState);
+    switch( aState ) 
+        {
+        case ECHFullResync:
+            // no pending events
+            RUBY_ASSERT_DEBUG( ( iDeleteTagListArray == NULL ) || ( iDeleteCallbackCounter == iDeleteTagListArray->Count() ), User::Panic( KFile, __LINE__ ) );
+            RUBY_ASSERT_DEBUG( iSaveCallbackCounter == iTagArray.Count(), User::Panic( KFile, __LINE__ ) );
+            
+            // full resyncronization needed again if this full resyncronization fails
+            RUBY_TRAP_IGNORE( SetFullResyncCrFlagL( ETrue ) );
+            break;
+        case ECHHandlingNormalChanges:
+            RUBY_ASSERT_DEBUG( iState == ECHIdle, User::Panic( KFile, __LINE__ ) );
+            RUBY_TRAP_IGNORE( SetFullResyncCrFlagL( ETrue ) );
+            break;
+        case ECHIdle:
+            if ( iDeleteTagListArray != NULL ) 
+                {
+                RUBY_ASSERT_DEBUG( (iSaveCallbackCounter == iTagArray.Count() ) || ( iDeleteCallbackCounter == iDeleteTagListArray->Count() ), User::Panic( KFile, __LINE__ ) );
+                }
+            else 
+                {
+                RUBY_ASSERT_DEBUG( ( iSaveCallbackCounter == iTagArray.Count() ) , User::Panic( KFile, __LINE__ ) );
+                }
+            if( iEventArray.Count() == 0 ) 
+                {
+                    // Idle state and no pending events mean, that contact handler
+                    // completed its operations for now
+                    TInt errProp = iBusyProperty.Set( EContactsNoTraining );
+                    if ( errProp != KErrNone )
+                        {
+                        RUBY_ERROR1("CNssContactHandlerImplementation::ConstructL() Failed to set property. Error [%d]", 
+                                    errProp );
+                        // @todo Not a leaving function -> leave commented out
+                        //User::Leave( errProp )  ;
+                        }
+                }
+                
+            // all changes done, no need for resyncronization
+            RUBY_TRAP_IGNORE( SetFullResyncCrFlagL( EFalse ) );
+            
+            break;
+        default:
+            RUBY_ERROR0( "CNssContactHandlerImplementation::SetState Unexpected or unknown state" );
+            RUBY_ASSERT_DEBUG( EFalse, User::Panic( KFile, __LINE__ ) );
+            
+            // failure, full resyncronization needed
+            RUBY_TRAP_IGNORE( SetFullResyncCrFlagL( ETrue ) );
+            break;
+        }
+    // actually switch state
+    iState = aState;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DataSyncStateChanged
+//
+// ---------------------------------------------------------
+//
+void CNssContactHandlerImplementation::DataSyncStateChanged( TBool aRunning )
+    {
+    if( !aRunning && ( iSyncBackupWaiter->IsStarted() ) )
+        {
+        RUBY_DEBUG0( "DataSyncStateChanged Sync became inactive and CH was waiting for it" );
+        iSyncBackupWaiter->AsyncStop();
+        }
+    }
+    
+// ---------------------------------------------------------
+//  Is called when backup/restore status is changed and when backup/restore
+//  state observation was just started
+//  @param aRunning ETrue if some backup/restore action is in progress
+//                  EFalse otherwise
+//  @param aRestoreType ETrue if the event is restore related
+//                      EFalse if the event is backup related
+//  @see CNssChBackupObserver
+// ---------------------------------------------------------
+void CNssContactHandlerImplementation::BackupRestoreStateChanged( TBool aRestoreType, 
+                                                                  TBool aRunning )
+	{
+    RUBY_DEBUG2( "BackupRestoreStateChanged aRestoreType [%d], aRunning [%d]", 
+                  aRestoreType, aRunning );
+    
+    if( aRestoreType && aRunning )
+        {
+        RUBY_DEBUG0( "Setting the Full Resync CR flag" );
+        RUBY_TRAP_IGNORE( SetFullResyncCrFlagL( ETrue ) );
+        }
+    
+    if( !aRunning && ( iSyncBackupWaiter->IsStarted() ) )
+        {
+        RUBY_DEBUG0( "BackupRestoreStateChanged b/r became inactive and CH was waiting for it" );
+        iSyncBackupWaiter->AsyncStop();
+        }	
+	}
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::HandleNotifyInt
+//
+// ---------------------------------------------------------
+// 	
+void CNssContactHandlerImplementation::HandleNotifyInt( TUint32 aId, TInt aNewValue )
+    {
+    RUBY_DEBUG0( "" );
+    
+    if ( aId == KSRSFFullResyncNeeded )
+        {
+        if ( aNewValue == KImmediateResync )
+            {
+            RUBY_DEBUG0( "Immediate full resync requested" );
+            
+            // Write the previous value back to the cenrep
+            TRAP_IGNORE( SetFullResyncCrFlagL( iResyncAtBoot ) );
+            
+            // Create an event that will launch full resync
+            TPhonebookEvent event;
+            event.iType = ENullEvent;
+            event.iContactId = 0;
+        
+            iEventArray.Append( event );
+            
+            // Start resync if nothing is ongoing
+            if ( iState == ECHIdle )
+                {
+                TRAP_IGNORE( DoHandleEventsL() );
+                }
+            }
+        }
+    }
+    
+// ---------------------------------------------------------
+// Sets the central repository full resync flag
+// ---------------------------------------------------------
+void CNssContactHandlerImplementation::SetFullResyncCrFlagL( TBool aResyncNeeded )
+    {
+    RUBY_DEBUG_BLOCKL("");
+    User::LeaveIfError( iRepository->Set( KSRSFFullResyncNeeded, aResyncNeeded ) );
+    iResyncAtBoot = aResyncNeeded;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::WaitUntilNoSyncBackupIsRunning
+//
+// ---------------------------------------------------------
+//    
+void CNssContactHandlerImplementation::WaitUntilNoSyncBackupIsRunning()
+    {
+    RUBY_DEBUG0( "WaitUntilNoSyncBackupIsRunning start" );
+    RUBY_ASSERT_DEBUG( !iSyncBackupWaiter->IsStarted(), User::Panic( KFile, __LINE__ ) );
+    
+    // Disconnection from phonebook should happen only once and only if b/r is running
+    TBool disconnectedFromPb = EFalse;
+    
+    // Check the values until both data sync and backup/restore are not active
+    while( iDataSyncWatcher->InProgress() || iBackupObserver->InProgress() )
+    	{
+    	RUBY_DEBUG2( "WaitUntilNoSyncBackupIsRunning Have to wait. data sync [%d], backup/restore [%d]",
+    				 iDataSyncWatcher->InProgress(), iBackupObserver->InProgress() );
+    	if( !iSyncBackupWaiter->IsStarted() ) 
+            {
+            if( (!disconnectedFromPb) && iBackupObserver->InProgress() )
+            	{
+            	RUBY_DEBUG0( "WaitUntilNoSyncBackupIsRunning Disconnecting from phonebook" );
+            	DisconnectFromPhonebook();
+            	disconnectedFromPb = ETrue;
+            	}
+            iSyncBackupWaiter->Start();
+            }
+        else 
+            {
+            RUBY_ERROR0( "WaitUntilNoSyncBackupIsRunning Attempt to start already active iSyncBackupWaiter. Huge error!" );
+            }
+    	}
+    	
+    if( disconnectedFromPb )
+    	{
+    	RUBY_DEBUG0( "WaitUntilNoSyncBackupIsRunning Reconnecting to phonebook" );
+    	TRAP_IGNORE( ConnectToPhonebookL() );
+    	}
+            
+    RUBY_DEBUG0( "WaitUntilNoSyncBackupIsRunning end" );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::GetContactL
+//
+// ---------------------------------------------------------
+//        
+void CNssContactHandlerImplementation::GetContactL( TContactItemId aContactId, TBool aReadContact ) 
+    {
+    RUBY_DEBUG1( "CNssContactHandlerImplementation::GetContactL. contact id [%d]", aContactId );
+    TInt err = KErrNone;
+    // Number of attempts tries
+    TInt attemptsTried( 0 );
+    do 
+        {
+        if( err == KErrInUse ) // i.e. not the first cycle iteration
+            {
+            RUBY_DEBUG2( "GetContactL Contact [%d] is locked. Waiting one more second. Retrial [%d]", 
+                         aContactId, attemptsTried);
+            // start periodic timer
+            if( attemptsTried == 1)   // i.e exactly the second cycle iteration
+                {
+                RUBY_DEBUG0( "GetContactL Creating periodic timer" );
+                iContactWaitTimer = CPeriodic::NewL( EPriorityNormal );
+                iContactWaitTimer->Start( KContactWaitInterval, KContactWaitInterval, TCallBack( ContactWaitCallback, this ) );
+                }
+            RUBY_DEBUG0( "GetContactL Starting the inner cycle waiting" );
+            iContactWaiter->Start( );
+            RUBY_DEBUG0( "GetContactL Waiting completed, trying to open contact again" );
+            }
+            
+        TRAP( err, iPbkHandler->FindContactL( aContactId, aReadContact ) );
+
+        attemptsTried++;
+        // -1 means forever
+        if( ( KMaxContactLockRetrials != -1 ) && ( attemptsTried >= KMaxContactLockRetrials ) ) 
+            {
+            RUBY_DEBUG1( "GetContactL Tried for [%d] times, still no success", attemptsTried );
+            break;
+            }
+        }
+    while( err == KErrInUse );
+    if( iContactWaitTimer != NULL ) 
+        {
+        iContactWaitTimer->Cancel();
+        delete iContactWaitTimer;
+        iContactWaitTimer = NULL;
+        }
+    // Propagate all the leaves, BUT KErrInUse
+    if( ( err != KErrInUse ) && ( err != KErrNone ) )
+        {
+        User::LeaveIfError( err );
+        }
+    if( err == KErrInUse ) 
+        {
+        RUBY_DEBUG1( "GetContactL Failed to lock contact [%d]. Disabling CH, will resync on reboot", aContactId );
+        DisableEventHandling();
+        User::Leave( KErrInUse );
+        }
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::GetContactL completed" );
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::ReadContactL
+//
+// ---------------------------------------------------------
+//     
+void CNssContactHandlerImplementation::ReadContactL( TContactItemId aContactId )
+    {
+    GetContactL( aContactId, ETrue );
+    }
+    
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::OpenContactL
+//
+// ---------------------------------------------------------
+//     
+void CNssContactHandlerImplementation::OpenContactL( TContactItemId aContactId )
+    {
+    GetContactL( aContactId, EFalse );
+    }
+    
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::ContactWaitCallback
+//
+// ---------------------------------------------------------
+//     
+TInt CNssContactHandlerImplementation::ContactWaitCallback( TAny* pX )
+    {
+	((CNssContactHandlerImplementation*)pX)->DoContactWaitCallback();
+	return KErrNone;  // useless for CPeriodic    
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::DoContactWaitCallback
+//
+// ---------------------------------------------------------
+//             
+void CNssContactHandlerImplementation::DoContactWaitCallback()
+    {
+    iContactWaiter->AsyncStop();
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::NoDiskSpace
+// Checks if there is not enough disk space to finish the
+// operation. Returns ETrue if there is no space.
+// ---------------------------------------------------------
+//    
+TBool CNssContactHandlerImplementation::NoDiskSpace()
+    {
+    RUBY_DEBUG0( "CNssContactHandlerImplementation::NoDiskSpace" );
+    TBool diskSpace( EFalse );
+    TRAP_IGNORE( diskSpace = SysUtil::FFSSpaceBelowCriticalLevelL( &iFSession, KIncreaseOfDatabaseSizes ) );
+    
+    if ( diskSpace )
+        {
+        RUBY_TRAP_IGNORE( SetFullResyncCrFlagL( ETrue ) );
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::NoDiskSpace NOT enough disk space available" );
+        return ETrue;
+        }
+    else
+        {
+        RUBY_DEBUG0( "CNssContactHandlerImplementation::NoDiskSpace There is enough disk space" );
+        return EFalse;
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::TrimName
+// Substitutes separator characters in descriptor with
+// white spaces. Removes extra withspaces. 
+// ---------------------------------------------------------
+//    
+void CNssContactHandlerImplementation::TrimName( HBufC* aBuf )
+    {
+    TPtr ptr = aBuf->Des();
+   
+    for ( TInt findIndex = 0; findIndex < aBuf->Des().Length(); findIndex++ )
+        {
+        if ( ptr[findIndex] == iSeparator )
+            {
+            ptr[findIndex] = ' ';
+            }
+        }
+       
+    ptr.TrimAll();
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::AppendName
+// Appends name to given buffer
+// ---------------------------------------------------------
+//    
+void CNssContactHandlerImplementation::AppendName( HBufC* aBuf, HBufC* aName )
+    {
+    if ( aName->Length() != 0 )
+        {     
+        aBuf->Des().Append( iSeparator );
+        aBuf->Des().Append( KNameTrainingIndex );
+        aBuf->Des().Append( aName->Des() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::AppendExtensionMarker
+// Appends marker for the extensions
+// Parameters should be in format "%U text message"
+// In which case output is "%U_2text message"
+// ---------------------------------------------------------
+//    
+void CNssContactHandlerImplementation::AppendExtensionMarker( TDes& aDes )
+    {
+    if ( aDes.Length() > 0 )
+        {
+        TInt insertPosition( 0 );
+        if ( aDes.Find( KExtensionFormatString ) == 0 )
+            {
+            // Find the first space and insert marker to that position
+            TInt firstSpace( 0 );
+            firstSpace = aDes.Find( _L(" ") );
+            if ( firstSpace == 2 )         // Next character after KExtensionFormatString
+                {
+                aDes.Delete( firstSpace, 1 );
+                }
+            insertPosition = 2;
+            }
+        // Insert marker
+        aDes.Insert( insertPosition, KExtensionTrainingIndex );
+        aDes.Insert( insertPosition, KNameSeparator );
+        }
+    }
+
+/**
+* Establishes the connection to the contact engine and 
+* starts listening to it
+*/ 
+void CNssContactHandlerImplementation::ConnectToPhonebookL()
+	{
+	RUBY_ASSERT_DEBUG( (!iPbkHandler), User::Leave( KErrNotReady ) );
+	iPbkHandler = CVasVPbkHandler::NewL();
+	iPbkHandler->InitializeL();
+	iPbkHandler->CreateContactObserverL( this );
+	}
+
+/** 
+* Clears the connection to the contact engine
+*/
+void CNssContactHandlerImplementation::DisconnectFromPhonebook()
+	{
+	delete iPbkHandler;
+	iPbkHandler = NULL;
+	}
+    
+#ifdef __SIND_EXTENSIONS	
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::ReadExtensionsL
+// Reads the extension resource file
+// ---------------------------------------------------------
+//           
+void CNssContactHandlerImplementation::ReadExtensionsL()
+    {
+    // using StringLoader should be used, but there is no 
+    // access to CCoeEnv
+    
+
+    // letters for drives in search order
+    const TBuf<1> KResourceDrivers = _L("z"); 
+    _LIT( KResourceFileName, "nssvascontacthandler.rsc" );
+    
+    // number of extension commands in the resource file
+    const TInt KExtensionCommandCount = 8;
+   
+    // load resources
+    RResourceFile resourceFile;
+    RFs fs;
+    CleanupClosePushL( fs );
+    TBool found( EFalse );
+    User::LeaveIfError( fs.Connect() );
+   
+        
+    TFileName name;
+    TInt i( 0 );
+    // use the first drive
+    name.Append( KResourceDrivers[i] );
+    name.Append(':');
+    name.Append( KDC_RESOURCE_FILES_DIR );
+    name.Append( KResourceFileName );
+
+    while ( !found && i < KResourceDrivers.Length() )
+        {
+        name[0] = KResourceDrivers[i++];
+
+        BaflUtils::NearestLanguageFile( fs, name );
+       
+        if ( BaflUtils::FileExists(fs, name) )
+            {
+            // open resource
+            resourceFile.OpenL( fs, name );
+            CleanupClosePushL( resourceFile );
+            resourceFile.ConfirmSignatureL();
+            found = ETrue;
+            }
+        }
+
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    for ( TInt extensionIndex( 0 ); extensionIndex < KExtensionCommandCount; extensionIndex++ )
+        {
+        TExtension extension;
+        TResourceReader reader;
+        TBool extentionSupported( ETrue );
+        
+        switch ( extensionIndex )
+            {
+            
+            case 0:
+            reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_MOBILE ) );
+            extension.iId = EPbkFieldIdPhoneNumberMobile;     
+            extension.iAction = EDial;
+            extension.iCommand = EMobileCommand;
+            break;
+            
+            case 1:
+            reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_MESSAGE ) );
+            extension.iId = EPbkFieldIdPhoneNumberMobile;     
+            extension.iAction = ENewMessage;     
+            extension.iCommand = EMessageCommand;
+            break;
+            
+            case 2:
+            reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_GENERAL ) );
+            extension.iId = EPbkFieldIdPhoneNumberGeneral;     
+            extension.iAction = EDial;
+            extension.iCommand = EGeneralCommand;          
+            break;
+            
+            case 3:
+            reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_WORK ) );
+            extension.iId = EPbkFieldIdPhoneNumberWork;     
+            extension.iAction = EDial;
+            extension.iCommand = EWorkCommand; 
+            break;
+            
+            case 4:
+            reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_HOME ) );
+            extension.iId = EPbkFieldIdPhoneNumberHome;     
+            extension.iAction = EDial;
+            extension.iCommand = EHomeCommand;          
+            break;
+            
+            case 5:
+            if ( iVideoCallFeatureSupported )
+                {  
+                reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_VIDEO ) );
+                extension.iId = EPbkFieldIdPhoneNumberVideo;     
+                extension.iAction = EDial;
+                extension.iCommand = EVideoCommand;                
+                }
+            else
+                { 
+                extentionSupported = EFalse;
+                }
+            break; 
+                                                                       
+            case 6:
+            reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_EMAIL ) );
+            extension.iId =EPbkFieldIdEmailAddress ;     
+            extension.iAction = ENewEmail;  
+            extension.iCommand = EEmailCommand;
+            break;
+            
+            case 7:
+            if ( iVoIPFeatureSupported )
+                {                
+                reader.SetBuffer( resourceFile.AllocReadLC( R_SIND_EXTENSION_VOIP ) );
+                extension.iId = EPbkFieldIdVOIP;     
+                extension.iAction = EDial;
+                extension.iCommand = EVoipCommand; 
+                }
+            else
+                {
+                extentionSupported = EFalse;
+                }
+            break; 
+            
+            default:
+            User::Leave( KErrGeneral );  // !!! @todo: PANIC                               
+            }
+        
+        if ( extentionSupported )
+            {           
+            extension.iText = reader.ReadHBufCL();
+            CleanupStack::PushL( extension.iText );    
+            User::LeaveIfError( iExtensionList.Append( extension ) );
+            CleanupStack::Pop( extension.iText );
+            CleanupStack::PopAndDestroy(); // AllocReadLC
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &resourceFile );    
+    CleanupStack::PopAndDestroy( &fs );
+
+    }
+	
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::FindExtensionField
+// Finds the extension field based on priority lists
+// ---------------------------------------------------------
+//        	
+TInt CNssContactHandlerImplementation::FindExtensionField( TVasExtensionAction aAction, 
+                                                           TPbkFieldId aDefaultFieldId )
+    {  
+    TInt found = KErrNotFound;
+    
+    switch ( aDefaultFieldId )
+        {
+        case EPbkFieldIdPhoneNumberVideo:
+            {
+            // Use defaults for video extension
+            found = ExtensionFieldFindLoop( KVideoExtensionFields, KVideoExtensionFieldsCount );
+            break;
+            }
+        
+        case EPbkFieldIdPhoneNumberMobile:
+            {
+            if ( aAction == ENewMessage )
+                {
+                // Use defaults for message extension
+                found = ExtensionFieldFindLoop( KMessageExtensionFields, KMessageExtensionFieldsCount );  
+                }
+            else
+                {
+                TRAP( found, iPbkHandler->FindFieldL( aDefaultFieldId ) );
+                }
+                
+            break;
+            }
+            
+        case EPbkFieldIdVOIP:
+            {
+            // Use defaults for VOIP extension
+            found = ExtensionFieldFindLoop( KVOIPExtensionFields, KVOIPExtensionFieldsCount );  
+                
+            break;
+            }
+        
+        default:
+            {
+            TRAP( found, iPbkHandler->FindFieldL( aDefaultFieldId ) );
+            break;
+            }
+        }
+    return found;
+    }
+
+// ---------------------------------------------------------
+// CNssContactHandlerImplementation::ExtensionFieldFindLoop
+// Finds the extension from the prioroty list arrays
+// ---------------------------------------------------------
+//        	
+TInt CNssContactHandlerImplementation::ExtensionFieldFindLoop( const TPbkFieldId* const aArray, 
+                                                               TInt aCount )
+    {
+    TInt found = KErrNotFound;
+       
+    for ( TInt iCounter = 0; iCounter < aCount; iCounter++ )
+        {
+        TRAP( found, iPbkHandler->FindFieldL( aArray[iCounter] ) );
+        if ( found == KErrNone )
+            {
+            break;
+            }
+        }
+    return found;
+    }
+
+#endif // __SIND_EXTENSIONS
+    	
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nssvasccontacthandlerimpl.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,846 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VAS contact handler implementation
+*
+*/
+
+
+#ifndef NSSCONTACTHANDLERIMPL_H
+#define NSSCONTACTHANDLERIMPL_H
+
+//  INCLUDES
+#include <cenrepnotifyhandler.h>
+
+#include <vasmcontactobserver.h>
+
+#include <nssvasmgetcontextclient.h>
+#include <nssvasmgettagclient.h>
+#include <nssvasmtraintexteventhandler.h>
+#include <nssvasmdeletecontextclient.h>
+#include <nssvasmdeletetagclient.h>
+#include <nssvasmsavetagclient.h>
+#include <nssvasmsavecontextclient.h>
+#include "nssvasdatasyncwatcher.h"
+#include <nssvascoreconstant.h>
+#include "srsfbldvariant.hrh"
+
+// Publish & Subscribe of the contact handler activity
+#include <e32property.h>  
+
+#include <PbkFields.hrh>
+
+// CONSTANTS
+
+// Number of restart timer calls checked during periodic calls check
+const TInt KEventMomentsSize = 3;
+
+// MACROS
+// Deprecated
+#ifdef TEST_MANUAL_SYNC
+#define CNssContactHandler CManualContactHandler
+#endif // TEST_MANUAL_SYNC
+    
+// FORWARD DECLARATIONS
+class CNssTrainingParameters;
+class MVasBasePbkHandler;
+class CNssVASDBMgr;
+class MNssTagMgr;
+class MNssContextMgr;
+class CSuccessfulDeletionSimulator;
+class CRepository;
+class CNssChBackupObserver;
+
+// CLASS DECLARATION
+
+/**
+*  TNssContextClientData contains last last sync time and UI language
+*  which was used when training voice tags.
+*
+*  @lib NssVASContactHdlr.dll
+*  @since 2.8
+*/
+struct TNssContextClientData
+    {
+    TTime iLastSyncTime;
+    TLanguage iLanguage;
+    TContactSyncId iContactSyncId;
+
+    void InternalizeL(const TDesC8& aBuffer)
+        {
+        iLastSyncTime = 0;
+    	iLanguage = ELangOther;
+    	iContactSyncId = KErrNotFound;
+
+        if ( (TUint)aBuffer.Size() > sizeof( TNssContextClientData ) )        
+            {
+            User::Leave( KErrCorrupt );
+            }
+
+        Mem::Copy( this, aBuffer.Ptr(), sizeof( TNssContextClientData ) );
+        }
+
+    void ExternalizeL(TDes8& aBuffer)
+        {
+        if ( (TUint)aBuffer.MaxSize() < sizeof( TNssContextClientData ) )
+            {
+            User::Leave( KErrTooBig );
+            }
+
+        aBuffer.SetLength( 0 );
+        aBuffer.Copy( (TUint8*)this, sizeof( TNssContextClientData ) );
+        }
+    };
+    
+/**
+*  Contact handler creates voice tags out of phonebook contacts and keeps
+*  SIND data in sync with the phonebook
+*
+*  @lib NssVASContactHdlr.dll
+*  @since 2.8
+*/
+NONSHARABLE_CLASS( CNssContactHandlerImplementation ): public CBase,
+                                                       public MVasContactObserver,
+                                                       public MNssGetTagClient,
+                                                       public MNssDeleteTagClient,
+                                                       public MNssGetContextClient,
+                                                       public MNssSaveTagClient,
+                                                       public MNssSaveContextClient,
+                                                       public MNssTrainTextEventHandler,
+                                                       public MNssDeleteContextClient,
+                                                       public MNssDataSyncStateObserver,
+                                                       public MCenRepNotifyHandlerCallback
+    {
+   // DATA TYPES
+    enum TContactHandlerState
+		{
+		ECHIdle,
+    	ECHInitializing,
+    	// contact addition, removal or change
+    	ECHHandlingNormalChanges,
+    	ECHFullResync
+		};
+		
+		
+    struct TExtension
+        {
+        TPbkFieldId iId;
+        HBufC* iText;
+        TVasExtensionAction iAction;
+        TVasExtensionCommand iCommand;
+        };	
+        
+    struct TContactData
+    	{
+    	// Can be 1.Nickname, 2.firstname-lastname or vise versa, 3.Company name
+    	HBufC*                iTitle;
+    	TContactItemId        iID;
+    	TTime                 iSyncTime;
+    	TVasTagType           iType;
+    	};
+
+   public:  // Constructors and destructor
+
+      /**
+      * Two-phased constructor.
+      */
+      static CNssContactHandlerImplementation* NewL( );
+        
+      /**
+      * Destructor.
+      */
+      virtual ~CNssContactHandlerImplementation();
+   public: // New functions
+      
+      /**
+      * Disables the contact handler until EnableEventHandling is called
+      * Typically this means 'until reboot'
+      * Is used in case of unrecoverable error.
+      * 
+      * @todo Move to private?
+      * @return void
+      */
+      void DisableEventHandling();
+
+      /**
+      * Enables the contact handler. 
+      * 
+      * @deprecated Move to private?
+      * @return void
+      */
+      void EnableEventHandling();
+
+    public: // Functions from base classes
+    
+        /**
+        * Is called by phonebook handler when contact change has occurred
+        *
+        * @param aEvent Event to be handled
+        */
+        void HandleEventL( const TPhonebookEvent& aEvent );
+        
+        /**
+        * Is called by tag manager when getting of a tag list is completed 
+        * successfully
+        * From MNssGetTagClient Interface 
+        *
+        * @param aTagList list of tags returned
+        * @param aErrorCode KErrNone if getting of tags has been successfull
+        * @return void
+        */
+        void GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode );
+        
+        /**
+        * Called when the deletion of a tag requested from tag manager
+        * is completed successfully
+        * From MNssDeleteTagClient Interface 
+        * @param aErrorCode KErrNone if tag deletion has been successfull
+        * @return void
+        */
+        void DeleteTagCompleted( TInt aErrorCode );
+        
+        /**
+        * Called by tag manager, when GetContext() completes successfully
+        *
+        * Depending on the contact handler state, continues full resync sequence or
+		* sets the idle state
+        * @param aContext
+        * @param aErrorCode KErrNone if getting of context list was successfull
+        * @return void
+        */
+        void GetContextCompleted(MNssContext* aContext, TInt aErrorCode);
+        
+        /**
+        * Callback to indicate GetContext successed.
+        * @param aContextList - A list of contexts. 
+        *        user has to ResetAndDestroy() after using the list.
+        * @param aErrorCode KErrNone if getting of context list was successfull
+        * @return None
+        */
+        void GetContextListCompleted( MNssContextListArray *aContextList,
+                                      TInt aErrorCode );
+        
+        /**
+        * Is called when SaveContext() completes
+        * @param aErrorCode KErrNone if saving of context was successfull
+        */
+        void SaveContextCompleted( TInt aErrorCode );
+        
+        /**
+        * Callback to indicate taht SaveTag completed successfully
+        * @param aErrorCode KErrNone if saving of tag has was successfull
+        * @return None
+        */
+        void SaveTagCompleted( TInt aErrorCode );
+        
+        /** 
+        *  Is called when data sync status is changed and when data sync state
+        *  observation was just started
+        *  @param aRunning ETrue if from now on data sync process is running
+        *                  EFalse otherwise
+        *  @see MNssDataSyncStateObserver
+        */
+        void DataSyncStateChanged( TBool aRunning );
+        
+        /** 
+        *  Is called when backup/restore status is changed and when backup/restore
+        *  state observation was just started
+        *  @param aRunning ETrue if some backup/restore action is in progress
+        *                  EFalse otherwise
+        *  @param aRestoreType ETrue if the event is restore related
+        *                      EFalse if the event is backup related
+        *  @see CNssChBackupObserver
+        */
+        void BackupRestoreStateChanged( TBool aRestoreType, TBool aRunning );
+        
+        /** 
+        *  From MCenRepNotifyHandlerCallback
+        *  @see MCenRepNotifyHandlerCallback for more information
+        */
+        void HandleNotifyInt( TUint32 aId, TInt aNewValue );
+        
+    private:
+        
+      	/**
+      	* C++ default constructor.
+      	*/
+      	CNssContactHandlerImplementation( );
+
+        /**
+        * Second-phase constructor
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor
+        CNssContactHandlerImplementation( const CNssContactHandlerImplementation& );
+        
+        // Prohibit assigment operator
+        CNssContactHandlerImplementation& operator= ( const CNssContactHandlerImplementation& );
+        
+      	/** 
+      	* Register itself for phonebook database events
+      	*/  
+      	void RegisterForDatabaseEventsL(  );
+
+        /**
+        * Check if the event was caused by voice tag field adding
+        * @param aEvent event from contact db
+        * @return ETrue if voice tag field was added
+        */
+        TBool CausedByVoiceTagAddition( const TPhonebookEvent& aEvent );
+        
+        /**
+        * Get the current contact's title in a buffer
+        * @param aContactId Id of the contact to return title for
+        * @param aUseDefaultOrder If ETrue created title uses preferred 
+        * 		 lastname-firstname order of the current UI language. If 
+        *		 EFalse, uses reverse order
+        * @param aBothFirstAndLastFound Is set to ETrue if returned title 
+        *		 contains both first name and last name. To EFalse otherwise
+        * @param aTagType Set based on found tag type (name or company name)
+        * @return 'Title' of the contact, i.e. value that is pronounced when
+        *		 this contact tag is recognized by SIND
+        */
+        HBufC* GetContactTitleL( TContactItemId aContactId, TBool aUseDefaultOrder, 
+                                 TBool& aBothFirstAndLastFound, TVasTagType& aTagType );
+        
+        /** 
+        * Return the nickname for a given contact
+        *
+        * @exception KErrNotFound if nickname field is not present
+        * @param aContactId Phonebook id of the contact in question
+        * @return NULL if nickname is present, but empty. 
+        *		  Otherwise newly allocated descriptor to the nickname
+        */
+        HBufC* GetContactNicknameL( TContactItemId aContactId );
+        
+        /*
+         * Returns a flag which tells if name order should be changed.
+         * @return ETrue if preferred order of the current UI language is 
+         * lastname-firstname. EFalse otherwise
+         */
+        TBool SwapNameOrder();
+        
+        // Process the Contact Database Events
+        void DoHandleEventsL();
+        
+        /**
+         * Routine to handle failure during processing the event at the lower
+         * layers
+         */ 
+        void DoHandleEventFailedL();
+        
+        /**
+         * Single tag training completed successfully
+         */       
+        void HandleTrainComplete( TInt aErrorCode );
+        
+        /**************** The functions to handle miscellanious changes ***************/
+        
+        // Handling miscellaneous changes has 3 phases:
+        // 1. Fuse add & remove & change events into a list
+        //    of tags to be added and tags to be removed.
+        // 2. Remove tags to be removed.
+        // 3. Add tags to be added
+        
+        
+        /** 
+         * Fuse add & remove & change events into a list of tags to be added
+         * and tags to be removed.
+         */
+        void CollectAddRemoveListsL();
+        
+        
+        /**
+         * Starts adding names: Creates the tags and sends TrainTextL calls.
+         */
+        void DoAddNamesL();
+        
+        /** 
+         * Is called after all the tags scheduled for addition have been 
+         * trained successfully
+         */
+        void DoAddNamesTrainingFinished();
+        
+        /**
+         * Initiates saving tags after they have been trained.
+         * After saving tags started is recursively called for every next
+         * tag to be saved
+         */
+        void DoAddNamesSaveTag();
+        
+        /**
+         * Is called when single tag saving has been completed
+         * @param aError KErrNone if saving was successful, 
+         *				 KErrGeneral otherwise
+         */ 
+        void DoAddNamesSaveTagCompleted( TInt aError );
+        
+        /** 
+         * Cleanup addition-related buffers after new tags have been created, 
+         * trained and saved.
+         * Add voice tag icons to the phonebook
+         */
+        void DoAddNamesCompletedL();
+        
+        
+        /**
+         * Start removing names by requesting list of tags for the first 
+         * contact scheduled for deletion
+         */
+        void DoRemoveNamesL();
+        
+        /**
+         * Callback for handling list of tags, that should be deleted
+         * The first list is requested from DoRemoveNamesL, other - recursively
+         * from DoRemoveNamesAfterGetTagList
+         * @param aTagListArray List of tags to be deleted. Can be empty
+         */ 
+        void DoRemoveNamesAfterGetTagList( MNssTagListArray* aTagListArray );
+        
+        /** 
+         * Send single DeleteTag call to remove the first tag of those that 
+         * are in the to-be-deleted list from VAS
+         * Expects callbacks to DeleteTagCompleted or to DeleteTagFailed
+         */
+        void DoRemoveNamesCallDeleteTag();
+        
+        /**
+         * DeleteTag() callbacks call this funciton. It counts
+		 * the number of callbacks, and when all callbacks have arrived
+		 * goes to the next phase: RemovingNamesCompletedL or
+		 * DoHandleEventFailedL
+         */
+        void DoRemoveNamesAfterDeleteTagCompleted();
+        
+        /**
+         * Tag removal for a pack on names completed successfully. Clean the
+         * deletion tag buffers
+         */ 
+        void RemovingNamesCompletedL();
+        
+        /**
+         *  TLinearOrder comparison function for sorting phonebook events
+         */
+        static TInt PhonebookOrder( const TPhonebookEvent& a1, const TPhonebookEvent& a2 );
+        
+        /*************** The functions to handle miscellanious changes end ************/
+        /**
+        * Compares client data from VAS context to the state of the phonebook
+        * to find out if full synchronization is needed.
+        * Compares client data (saved in VAS context)
+		* to state of the phonebook to find out if
+		* full synchronization is needed.
+		*
+		* If full resync is needed initiates it by saving into the event queue
+		* special 'full resync event'
+        * @since 2.0
+        */       
+        void CheckErrorSigns();
+        
+        /**
+         * Handle errors which happend when updating normal changes
+         */ 
+        void NormalChangesHandleError();
+        
+        /**
+         * Start full resynchronisation
+         */
+        void FullResyncStart();
+        
+        /**
+         * Delete existing context if any, create a new one.
+         * Is a part of full resynchronization sequence
+         */
+        void FullResyncCreateContextL();
+        
+        /**
+         * Simulate phonebook addition events for all the phonebook contacts.
+         * Is a part of full resynchronization sequence
+         */
+        void FullResyncCreateChangesL();
+
+		/**
+		 * Checks if the event queue contains an event, which
+		 * launches full resynchronization
+		 * @return ETrue if full resync request is present in the queue
+		 *		   EFalse otherwise
+		 */
+        TBool IsFullResyncNeeded();
+        
+        /**
+         * Is called when conext deletion has completed successfully.
+         * Is a part of the full synchronization sequence
+         * @param aErrorCode KErrNone if deletion of context was successfull
+         */
+        void DeleteContextCompleted( TInt aErrorCode );
+        
+        /**
+         * Is called when conext deletion fails.
+         * Is a part of the full synchronization sequence
+         */
+        //void DeleteContextFailed( enum MNssDeleteContextClient::TNssDeleteContextClientFailCode  );
+        
+        /**
+         * Static callback required by Symbian Timer services.
+         * Real action happens in the DoPeriodicCallback 
+         * @param pX Pointer to the active instance of CNssContactHandlerImplementation
+         * @return KErrNone. Has no meaning in this case
+         * @see CNssContactHandlerImplementation::DoPeriodicCallback()
+         */
+        static TInt PeriodicCallback( TAny* pX );
+        
+        /**
+         * Timer callback used to check if periodic action completed,
+         * there are events to process and contact handler can do it now 
+         * (is idle). If this is true, initiates event processing
+         */
+        void DoPeriodicCallback();
+        
+        /**
+    	* Checks if it events look like they are periodically sent 
+    	* from some lengthy operation
+    	* @return ETrue if periodic behavior detected, EFalse otherwise
+    	*/
+    	TBool PeriodicAction();
+    	
+    	/**
+    	* Updates variables used for periodic action checks.
+    	* Adds current time to the array of phonebook event moments
+    	*/
+    	void UpdatePeriodicActionVars();
+    	
+    	
+    	/**
+    	* Returns maximal interval between time moments recorded in the  array.
+    	* Moments are stored in a cyclic way, i.e. moment 0 is stored at index 0,
+    	* moment1 at index 2,... moment n at index 0 again
+    	* @param aMoments Array of time moments
+    	* @param aMomensLength Length of the aMoments array. Must be > 1
+    	* @param aLastMomentIndex Index of the last recorded moment within aMoments
+    	* @return Maximal interval. If Maximal interval is too big to fit into
+    	*		  TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32(KMaxTInt)
+    	*		  is returned
+    	*/
+    	TTimeIntervalMicroSeconds32 MaximalInterval( const TTime aMoments[], const TInt aMomentsLength, const TInt aLastMomentIndex );
+    	
+    	/**
+    	* Set the contact handler state. It is the place, where state-related 
+    	* invariants are checked in debug builds. In debug builds panics if
+    	* intended change is illegal
+    	*/
+    	void SetState( TContactHandlerState aState );
+    	
+    	/**
+    	* Returns immediately if neither data sync nor backup is in progress
+    	* Otherwise waits indefinetely until data sync run is over
+    	*/
+    	void WaitUntilNoSyncBackupIsRunning();
+        
+        /**
+         * Sets the central repository full resync flag
+         * @leave CRepository error codes
+         */
+        void SetFullResyncCrFlagL( TBool aResyncNeeded );
+
+#ifdef __SIND_EXTENSIONS	    	
+    	/**
+    	* Read name dialling extension from resource file
+    	*/
+    	void ReadExtensionsL();
+    	
+    	/**
+    	* Finds extension field based on priority lists
+    	*
+    	* @param aAction Extension action
+    	* @return KErrNotFound if contact item field was not found
+    	*/
+    	TInt FindExtensionField( TVasExtensionAction aAction,
+    	                         TPbkFieldId aDefaultFieldId );
+    	                                          
+    	                                          
+        /**
+        * Loops through list of fields
+        *
+        * @param aArray Array field IDs
+        * @param aCount Number of elements in aArray
+        * @param aItem Contact item
+        *
+        * @return KErrNotFound if contact item field was not found
+        */    	                                          
+        TInt ExtensionFieldFindLoop( const TPbkFieldId* const aArray, 
+                                     TInt aCount );
+#endif // __SIND_EXTENSIONS	
+
+    	/**
+         * Reads a contact and returns a phonebook contact item. If contact is 
+         * already locked by something, function keeps trying for a long time.
+         * If still fails, contact handler is disabled and full resync will
+         * be attempted after the reboot
+         *
+         * @param aContactId Contact item id to be read.
+         */           
+        void ReadContactL( TContactItemId aContactId );
+            
+        /**
+         * Opens a contact. If contact is already locked by something,
+         * function keeps trying for a long time.
+         * If still fails, contact handler is disabled and full resync will
+         * be attempted after the reboot
+         *
+         * @param aContactId Contact item id to be opened.
+         */
+        void OpenContactL( TContactItemId aContactId );            
+        
+        /** 
+        * Reads contact from phonebook
+        * 
+        * If contact is already locked by something, function keeps trying for a long time.
+        * If still fails, contact handler is disabled and full resync will
+        * be attempted after the reboot
+        *
+        * @param aContactId Contact of interest
+        * @param aReadContact ETrue for ReadContactL and EFalse for OpenContactL
+        */
+        void GetContactL( TContactItemId aContactId, TBool aReadContact );
+        
+        /**
+         * Static callback required by Symbian Timer services.
+         * Real action happens in the DoContactWaitCallback 
+         * @param pX Pointer to the active instance of CNssContactHandlerImplementation
+         * @return KErrNone. Has no meaning in this case
+         * @see CNssContactHandlerImplementation::DoPeriodicCallback()
+         */
+        static TInt ContactWaitCallback( TAny* pX );
+        
+        /**
+         * Timer callback used to check if phonebook contact is unlocked
+         * Unlocks the waiter
+         */
+        void DoContactWaitCallback();
+        
+        /**
+        * Utility function to check if there isn't enough disk space to perform
+        * the operation.
+        *
+        * @return ETrue if there is not enough disk space, EFalse otherwise
+        */
+        TBool NoDiskSpace();
+        
+        /**
+        * Utility function to substitute all separator characters as white spaces.
+        *
+        * @param aBuf Descriptor which is manipulated
+        */
+        void TrimName( HBufC* aBuf );
+        
+        /**
+        * Utility function to append name to a buffer.
+        *
+        * @param aBuf Descriptor which is appended
+        * @param aName Name
+        */
+        void AppendName( HBufC* aBuf, HBufC* aName );
+
+        /**
+        * Utility function to append extension marker ("_2") to buffer.
+        *
+        * @param aDes Buffer where to do the modification
+        */        
+        void AppendExtensionMarker( TDes& aDes );
+
+		/**
+		* Establishes the connection to the contact engine and 
+		* starts listening to it
+		*/ 
+		void ConnectToPhonebookL();
+		
+		/** 
+		* Clears the connection to the contact engine
+		*/
+		void DisconnectFromPhonebook();
+    	
+   private:    // Data
+       // Phonebook engine
+       MVasBasePbkHandler* iPbkHandler;
+       CNssVASDBMgr* iVasDbManager;
+       MNssTagMgr* iTagManager;
+       MNssContextMgr* iContextManager;
+       TContactHandlerState iState;
+
+       // Id of the contact that is currently deleted
+       /** @todo Why is it not used for additions? Or why it is used at all? */
+       TContactItemId iContactId;
+
+       // Notifier object for the default contact database. 
+       // iContactChangeNotifier attaches contact handler to the phonebook
+       // engine as long as the object exists.
+ //      CPbkContactChangeNotifier* iContactChangeNotifier;
+
+       // Tells if ocntact handler is active
+       TBool iHandlerEnabled;
+
+       // Context used for name dialing
+       MNssContext* iContext;
+
+       // List of raw database events. Also can store special 'full resync' event
+       RArray<TPhonebookEvent> iEventArray;
+
+       // Number of retrials to save tags
+       TInt iRetry;
+
+       // Delimeter between first an last name in the contact title
+       TChar iSeparator;
+       
+       // Array of relevant data from contacts to add
+       // Just id and title
+       RArray<TContactData> iContactQueue;
+
+       // Language specific settings
+       CNssTrainingParameters* iTrainingParams;
+       
+       // List of contacts to add to VAS
+       RArray<TPhonebookEvent> iAddList;
+
+       // List of contacts to remove tags for
+       RArray<TPhonebookEvent> iDelList;
+       
+       // List of contacts, for which voice tag icon has been added OR REMOVED
+       // Is used to ignore events related to the change of voice dial icon
+       RArray<TContactItemId> iVoiceTagAddedList;
+       
+       // List of contacts for which voice tag icon should be removed if present
+       // The need for it occurs if training voice tag fails and before training
+       // icon was present
+       RArray<TContactItemId> iRemoveIconList;
+       
+       // List of tags that are to be trained and saved
+       RPointerArray<MNssTag> iTagArray;
+       
+       // Counts the number of callbacks after TrainText() calls
+       TInt iTrainCallbackCounter;
+       
+       // Counts the number of callbacks after SaveTag() calls
+       TInt iSaveCallbackCounter;
+       
+       // Counts the number of callbacks after DeleteTag() calls
+       TInt iDeleteCallbackCounter;
+       
+       // General information about the context used for name dialing:
+       // language and last sync timestamp
+       TNssContextClientData iClientData;
+       
+       // Tells if full resync happened at least once
+       // I.e. if name dialing context exists
+       TBool iHaveWeEverSynced;
+       
+       // Indicates if error happened during normal event handling
+       // Can be only KErrNone of KErrGeneral
+       TInt iNormalChangesError;
+       
+       // List of tags to be deleted for one contact
+       // (main name + possible nickname )
+       MNssTagListArray* iDeleteTagListArray;
+       
+       // Languages which use lastname-firstname order in names
+       RArray<TLanguage> iSwappedLanguages;
+       
+       // Timer used to ensure, that events queue is checked at least every 30 secs
+       CPeriodic* iPeriodicHandleEventTimer;
+       
+       // Array of event receivement times
+       TTime iEventMoments[KEventMomentsSize];
+    
+       // Index of the last value in iRestartTimerCalls
+       TInt iEventMomentIndex;
+    
+       
+	   // Time interval used to detect END of periodic action. In microseconds
+	   // Note, that it is NOT the value used to command 
+	   // iPeriodicHandleEventTimer
+	   TTimeIntervalMicroSeconds iEndOfPeriodicActionInterval;
+	   
+	   // Counter for consecutive full resyncs forced by error during
+	   // handling normal changes (or also resync changes)
+	   // Is used to prevent endless resyncing in case of some unexpected
+	   // consistent lower level failure
+	   TInt iConsecutiveErrorFullResync;
+	   
+	   // Publish & Subscribe property, that tells external entities if contact
+	   // handler training is ongoing. Note, that it is different from
+	   // the contact handler state
+	   RProperty iBusyProperty;
+	   
+	   // Publish & Subscribe property that watches for the PC-Suite Sync activity
+	   RProperty iSyncProperty;
+
+	   // Temporary container for a tag that is created and used in the
+	   // DoAddNamesL. Member variable is used only because we cannot use
+	   // CleanupStack with MNssTag
+	   MNssTag* iNewTag;
+	   // Informs that VoIP feature is supported.
+	   TBool iVoIPFeatureSupported;
+	   
+	   // Informs that video telephony feature is supported
+	   TBool iVideoCallFeatureSupported;
+	   
+#ifdef __SIND_EXTENSIONS	   
+       // extensions
+	   RArray<TExtension> iExtensionList;
+#endif //__SIND_EXTENSIONS
+
+	   // ETrue if PC-suite data sync is in progress. I.e. contact hanlder should
+	   // delay its actions until iDataSyncRunning is EFalse
+	   TBool iDataSyncRunning;
+	   
+	   // Waits until iDataSyncRunning is EFalse
+	   CActiveSchedulerWait* iSyncBackupWaiter;
+	   
+	   // Waits until contact of interest is unlocked
+	   CActiveSchedulerWait* iContactWaiter;
+	   
+	   // Periodic timer that ticks ones per socond if we are waiting for the
+	   // contact unlock
+	   CPeriodic* iContactWaitTimer;
+	   
+	   // Watches for the data sync state changes
+	   MNssDataSyncWatcher* iDataSyncWatcher;
+	   
+	   // Watches the backup/restore state
+	   CNssChBackupObserver* iBackupObserver;
+	   
+	   // Watches central repository changes
+	   CCenRepNotifyHandler* iRepositoryObserver;
+	   
+	   // Is used to *asynchronously* simulate successful tag deletion
+	   CSuccessfulDeletionSimulator* iDeletionSimulator;
+	   
+	   // To simplify access for the pure utility class
+	   friend class CSuccessfulDeletionSimulator;
+	   
+	   // File server session to find out the available disk space
+	   RFs iFSession;
+	   
+	   // central repository for setting resync needed flag
+	   CRepository* iRepository;
+
+	   // flag for phonebook restore
+	   TBool iRestoreRunning;
+	   
+	   // Current resync flag state
+	   TBool iResyncAtBoot;
+    };
+
+#endif // CONTACTHANDLERIMPL_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nssvasdatasyncwatcher.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches changes of the PC-Suite data sync state
+*
+*/
+
+
+#include "nssvasdatasyncwatcher.h"
+#include "rubydebug.h"
+
+// Destructors cannot be pure virtual
+MNssDataSyncWatcher::~MNssDataSyncWatcher() 
+    {
+    // empty
+    }
+
+
+
+///////////////////////////////////
+// CNssDataSyncWatcherFactory::ConstructDataSyncWatcherL
+//
+// Constructs and returns the data sync watcher according to what's
+// available in the system. I.e RProperty based watcher or
+// shared data client based watcher
+// @param aHost Observer to be notified about data sync state changes
+//
+// @return Constructed and already started watcher
+///////////////////////////////////
+MNssDataSyncWatcher* CNssDataSyncWatcherFactory::ConstructDataSyncWatcherL( 
+                                        MNssDataSyncStateObserver& aHost )
+    {
+    RUBY_DEBUG_BLOCKL( "ConstructDataSyncWatcherL" );
+    MNssDataSyncWatcher* watcher = CNssDataSyncPropertyWatcher::NewL( aHost );
+    return watcher;
+    }
+
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::NewL
+//
+// Two phased construction
+///////////////////////////////////
+CNssDataSyncPropertyWatcher* CNssDataSyncPropertyWatcher::NewL( MNssDataSyncStateObserver& aHost )
+    {
+    CNssDataSyncPropertyWatcher* self = new (ELeave) CNssDataSyncPropertyWatcher( aHost );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::CNssDataSyncPropertyWatcher
+//
+// Constructor
+///////////////////////////////////
+CNssDataSyncPropertyWatcher::CNssDataSyncPropertyWatcher( MNssDataSyncStateObserver& aHost ) :
+    CActive( EPriorityStandard ),
+    iHost( &aHost ),
+    iDataSyncStatus( EDataSyncNotRunning )
+    {
+    // Nothing
+    }
+    
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::ConstructL
+//
+// Second-pase constructor
+///////////////////////////////////
+void CNssDataSyncPropertyWatcher::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "CNssDataSyncPropertyWatcher::ConstructL" );
+    User::LeaveIfError( iProperty.Attach( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus ) );
+    CActiveScheduler::Add( this );
+    // initial subscription and process current property value
+    RunL();
+    }
+    
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::~CNssDataSyncPropertyWatcher
+//
+// Destructor
+///////////////////////////////////
+CNssDataSyncPropertyWatcher::~CNssDataSyncPropertyWatcher()
+    {
+    if( IsAdded() ) 
+        {
+        Deque();
+        }
+    iProperty.Close();
+    }
+    
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::DoCancel
+//
+// Cancel listening now
+///////////////////////////////////
+void CNssDataSyncPropertyWatcher::DoCancel() 
+    {
+    iProperty.Cancel();
+    }
+
+
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::runL
+//
+// Is called, when property changed
+///////////////////////////////////
+void CNssDataSyncPropertyWatcher::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssDataSyncPropertyWatcher::RunL" );
+    if( iStatus != KErrNone ) 
+        {
+        // At least report the error
+        RUBY_ERROR1( "CNssDataSyncPropertyWatcher::RunL iStatus is [%d]", iStatus.Int() );
+        }
+        
+    // resubscribe before processing new value to prevent missing updates
+    // even if some error happened
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    // property updated, get new value
+    TInt dataSyncStatus;
+    if ( iProperty.Get( dataSyncStatus) == KErrNotFound )
+        {
+        // not defined is the same as sync is not running
+        dataSyncStatus = EDataSyncNotRunning;
+        }
+    iDataSyncStatus = static_cast<TDataSyncStatus>( dataSyncStatus );
+    iHost->DataSyncStateChanged( InProgress() );
+
+    }
+    
+///////////////////////////////////
+// CNssDataSyncPropertyWatcher::InProgress
+//
+// Tells if data sync is active right now
+///////////////////////////////////
+TBool CNssDataSyncPropertyWatcher::InProgress()
+	{
+	// There can be several different "running" statuses, but only one "not running"
+    // So check for not running
+	return iDataSyncStatus != EDataSyncNotRunning;
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/nssvascontacthdlr/src/nssvasdatasyncwatcher.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watcher for the PC-Suite data sync state
+*
+*/
+
+
+#ifndef NSSVASDATASYNCWATCHER_H
+#define NSSVASDATASYNCWATCHER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+
+// Publish & Subscribe of the contact handler activity
+#include <e32property.h>  
+
+#include <DataSyncInternalPSKeys.h>
+
+// CONSTANTS
+
+
+// MACROS
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Interface for classes that want to be notified about the PC Suite data
+*  sync status: is it running or not
+*/
+NONSHARABLE_CLASS( MNssDataSyncStateObserver ) 
+    {
+    public:
+        /** 
+        *  Is called when data sync status is changed and when data sync state
+        *  observation was just started
+        *  @param aRunning ETrue if from now on data sync process is running
+        *                  EFalse otherwise
+        */
+        virtual void DataSyncStateChanged( TBool aRunning ) = 0;
+    };
+
+
+/** 
+*  Watches for the changes of the data sync state (is it running) or not
+*  and notifies the host observer about it
+*/
+NONSHARABLE_CLASS( MNssDataSyncWatcher )
+    {
+    public:
+        virtual ~MNssDataSyncWatcher();
+        /**
+        * @return ETrue if data sync is in progress, EFalse otherwise
+        */
+        virtual TBool InProgress() = 0;
+    };
+    
+/** 
+*  Creates and returns 
+*/
+NONSHARABLE_CLASS ( CNssDataSyncWatcherFactory ) : public CBase
+    {
+    public:
+        /**
+        *  Constructs and returns the data sync watcher according to what's
+        *  available in the system. I.e RProperty based watcher or
+        *  shared data client based watcher
+        *  @param aHost Observer to be notified about data sync state changes
+        *
+        *  @return Constructed and already started watcher
+        */
+        static MNssDataSyncWatcher* ConstructDataSyncWatcherL( MNssDataSyncStateObserver& aHost );
+    };
+
+/**
+* RProperty based data sync watcher implementation
+*/
+NONSHARABLE_CLASS ( CNssDataSyncPropertyWatcher ) : public CActive, public MNssDataSyncWatcher
+    {
+    public:
+        /** 
+        *  Factory construction
+        *  @param aHost Observer to be notified about data sync state changes
+        *  @return Constructed and already started CNssDataSyncWatcher
+        */
+        static CNssDataSyncPropertyWatcher* NewL( MNssDataSyncStateObserver& aHost );
+        
+        /** 
+        * Destructor 
+        * Doesn't need to be declared as virtual. Is virtual since CBase 
+        * implementation
+        */
+        ~CNssDataSyncPropertyWatcher();
+        
+        /**
+        * @return ETrue if data sync is in progress, EFalse otherwise
+        */
+        virtual TBool InProgress();
+    private:
+        /** C++ constructor */
+        CNssDataSyncPropertyWatcher( MNssDataSyncStateObserver& aHost );
+        
+        /** Symbian second phase constructor */
+        void ConstructL();
+        
+        /** is called when data sync property changed */
+        void RunL();
+        
+        /** Is called when system wants immediate cancelling of the watching */
+        void DoCancel();
+    private:
+        // Publish & Sunscribe property about the data sync state
+        RProperty   iProperty;
+        
+        // Host to be notified about the state changes
+        MNssDataSyncStateObserver* iHost;
+        
+        // current data sync status
+        TDataSyncStatus iDataSyncStatus;
+    };
+
+#endif // NSSVASDATASYNCWATCHER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/data/10281ced.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 1028 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM registration file
+*
+*/
+
+
+#include "registryinfo.rh"
+#include "nssvuipf.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+{
+dll_uid = 0x10281CED;
+interfaces = 
+    {
+    INTERFACE_INFO
+        {
+        interface_uid = KVuipfEventInterfaceUid;
+        implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x10281CED;
+                version_no = 1;
+                display_name = "profile observer plugin";
+                default_data = "none";
+                opaque_data = "none";
+                } 
+            };
+        }
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/data/vcprofileobserver.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// VCPROFILEOBSERVER_INFO
+// Structure definition for VCPROFILEOBSERVER_INFO
+// -----------------------------------------------------------------------------
+//
+/** @see Vcprofileobserver.rss */
+STRUCT VCPROFILEOBSERVER_INFO
+    {
+    LTEXT profile_folder_name;
+    LTEXT profile_folder_title;
+    LTEXT profile_tooltip_text;
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/data/vcprofileobserver.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// INCLUDES
+
+#include "vcprofileobserver.rh"
+#include <defaultvoicecommands.loc>
+
+// RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+// Vcprofileobserverinfo
+// -----------------------------------------------------------------------------
+//
+RESOURCE VCPROFILEOBSERVER_INFO Vcprofileobserverinfo
+    {
+    profile_folder_name = qtn_vc_main_profiles;
+    profile_folder_title = qtn_vc_title_profiles;
+    profile_tooltip_text = qtn_vc_info_popup_text_prof;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Compilation information for Profile Observer Plugin
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+vuipprofileobserverplugin.mmp
+
+PRJ_TESTEXPORTS
+
+PRJ_TESTMMPFILES
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/group/vuipprofileobserverplugin.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for profile observer plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          vuipprofileobserverplugin.dll
+
+#ifdef SYMBIAN_SECURE_ECOM
+TARGETTYPE      PLUGIN
+#else
+TARGETTYPE      ECOMIIC
+#endif
+
+UID             0x10009d8d 0x10281ced
+CAPABILITY		CAP_ECOM_PLUGIN
+
+SOURCEPATH      ../data
+
+START RESOURCE  10281ced.rss
+TARGET          vuipprofileobserverplugin.rsc
+TARGETPATH      ECOM_RESOURCE_DIR
+END
+
+// Plugin resources
+START RESOURCE      vcprofileobserver.rss 
+HEADER
+TARGETPATH          RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END // Plugin resources
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+SOURCEPATH      ../src
+SOURCE          vcommandprofileobserver.cpp
+SOURCE          vuipprofileobserverplugin.cpp
+SOURCE          vuipprofileobserverecomsupport.cpp
+
+USERINCLUDE     ../../rubydebug
+
+
+// This is a SYSTEMINCLUDE macro containing the application
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/ecom
+// for CleanupResetAndDestroy declared in mmfcontrollerpluginresolver.h
+SYSTEMINCLUDE /epoc32/include/mmf/common
+
+
+LIBRARY     	euser.lib 
+LIBRARY         bafl.lib // for CDesCArrayFlat
+LIBRARY         profileengine.lib
+LIBRARY         profileeng.lib
+LIBRARY         vcommandhandler.lib
+LIBRARY         cone.lib
+LIBRARY         efsrv.lib
+
+/* @todo remove */
+LIBRARY         ecom.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/inc/vcommandprofileobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  class handles profile array changes
+*
+*/
+
+
+#include <e32base.h>
+
+#include <MProEngProfileObserver.h>
+#include <MProEngEngine.h>
+#include <MProEngNotifyHandler.h>
+#include <MProEngProfileNameArrayObserver.h>
+
+#include <vcommandapi.h>
+
+class CDesC16ArrayFlat;
+
+
+/**
+ * CVCommandProfileObserver handles profile array changes 
+ * { new profile, profile removed, profile name edited }
+ * and syncs the voice commands database with the current profiles.
+ *
+ */
+class CVCommandProfileObserver: public CBase, 
+                                public MProEngProfileNameArrayObserver
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        */
+        static CVCommandProfileObserver* NewL();
+      
+        /**
+        * Destructor.
+        *
+        */
+        ~CVCommandProfileObserver();
+
+
+    public: // Functions from base classes
+
+        /**
+        * From MProEngProfileNameArrayObserver
+        *
+        * @return void
+        */        
+        void HandleProfileNameArrayModificationL();
+        
+        /**
+        * From MProEngProfileNameArrayObserver
+        * 
+        * @param aError error code
+        * @return void
+        */        
+        void HandleProfileNameArrayNotificationError( TInt aError );
+
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        *
+        */
+        CVCommandProfileObserver();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        *
+        * @return void
+        */
+        void ConstructL();
+
+        /**
+        * Returns a list of voice commands.
+        *
+        * @return CVCommandArray& list of voice commands
+        */
+        const CVCommandArray& ListVCommandsL();
+
+        /**
+        * Loads profile folder name and profile tooltip text.
+        *
+        * @return void
+        */
+        void LoadProfileDataL();
+
+        /**
+        * Deletes iCommands member variable and thus forces it to be 
+        * reloaded when needed next time.
+        *
+        * @return void
+        */
+        void DeleteCache();
+
+        /**
+        * Adds a profile name change to Vcommand handler.
+        *
+        * @param aOldName old name of the profile
+        * @param aNewName new name for the profile
+        * @return void
+        */
+        void EditProfileNameL( const TDesC& aOldName, const TDesC& aNewName );
+
+        /**
+        * Adds a new profile to VCommand handler.
+        *
+        * @param aNewName Name of the profile to be added
+        * @param aProfileId Id of the new profile
+        * @param aCommit Set as EFalse if saving to Voice Command services is done
+        *                later with CommitAdditionsToVCommandServicesL
+        * @return void
+        */
+        void AddNewProfileL( const TDesC& aNewName, TInt aProfileId, TBool aCommit = ETrue );
+        
+        /**
+        * Adds new profiles to VCommand handler.
+        *
+        * @param aNames Names of the profiles to be added
+        * @param aProfileNames Names of the existing profiles
+        * @param aCommit Set as EFalse if saving to Voice Command services is done
+        *                later with CommitAdditionsToVCommandServicesL
+        * @return void
+        */
+        void AddNewProfilesL( const CDesC16ArrayFlat& aNames,
+                              const MProEngProfileNameArray& aProfileNames,
+                              TBool aCommit = ETrue );
+        
+        /**
+        * Creates a VCommand for the given profile attributes
+        */
+        CVCommand* CreateProfileCommandL( const TDesC& profileName, TInt aProfileId ) const;
+        
+        /**
+        * Removes a profile from VCommand handler.
+        *
+        * @param aName a name of the profile to be removed
+        * @return void
+        */
+        void RemoveProfileL( const TDesC& aName );
+        
+        /**
+        * Removes profiles from VCommand handler.
+        *
+        * @param aNames names of the profiles to be removed
+        * @return void
+        */
+        void RemoveProfilesL( const CDesC16ArrayFlat& aNames );
+
+        /**
+        * Finds the profile index by name.
+        *
+        * @param aName name of a profile
+        * @return TInt index to the vcommand profile, default is KErrNotFound
+        */
+        TInt FindProfileIndexL( const TDesC& aName );
+
+        /** 
+        * Syncronizes the voice commands at VCommand Handler to equal 
+        * to the list of real profiles. This method is called when 
+        * profile observing is started.
+        *
+        * @return void
+        */
+        void SyncVCommandProfilesL();
+     
+    private: // Data
+    
+        MProEngEngine*              iProfileEngine; // owned
+        MProEngProfileNameArray*    iNameArray; // owned
+       
+        MProEngNotifyHandler*       iNotifyHandler; // owned
+      
+        CVCommandHandler*           iService; // owned
+        CVCommandArray*             iCommands; // owned
+        
+        HBufC*                      iProfileFolder; // owned
+        HBufC*                      iFolderTitle; // owned
+        HBufC*                      iProfileTooltip; // owned
+        
+        // Command additions collected into an array
+        RVCommandArray              iAddedCommands;
+        
+        TBool                       iProfileUpdateError;
+        
+    };
+    
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/inc/vuipprofileobserverplugin.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <e32base.h>
+#include <nssvoiceevent.h>
+
+
+// Forward declaration
+//
+class CVCommandProfileObserver;
+
+
+/**
+ * Class which uses VUIP-framework to start profile observing when 
+ * phone is booted.
+ *
+ */
+class CVUIPprofileobserverplugin : public CVoiceEventObserverPluginBase
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CVUIPprofileobserverplugin* NewL();
+      
+        /**
+        * Destructor.
+        */
+        ~CVUIPprofileobserverplugin();
+
+
+    public: // Functions from base classes
+
+        /**
+        * From CVoiceEventObserverPluginBase
+        * @param aEventHandler reference to a voice event handler.
+        */        
+        void InitializeL( MVoiceEventExecutor& aEventHandler );
+
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CVUIPprofileobserverplugin();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+   
+    private: // Data
+    
+        CVCommandProfileObserver*   iProfileObserver; // owned
+    };
+    
+   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/src/vcommandprofileobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,663 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  implements profile changes handling
+*
+*/
+
+
+#include <aknlists.h>
+#include <bautils.h> 
+
+#include <ProEngFactory.h>
+#include <MProEngProfileNameArray.h>
+
+#include <vcprofileobserver.rsg>
+#include <mmfcontrollerpluginresolver.h> // For CleanupResetAndDestroyPushL
+
+#include "vcommandprofileobserver.h"
+#include "rubydebug.h"
+
+
+// ============================ CONSTANTS ===============================
+
+_LIT( KResourceFile, "z:\\resource\\vcprofileobserver.rsc" );
+
+// UID of the profiles application
+const TUid KUidAppProfiles = { 0x100058F8 };
+
+// Executable for changing profiles.
+const TUid KProfileChangerUid = { 0x10281D15 };
+
+// Starting id for profile command arguments
+const TInt KProfileCommandArgumentBase = 200;
+
+// File name to read the icon from
+_LIT( KIconFile, "Z:\\resource\\apps\\vcommand.mif" );
+
+// Index of the profile folder icon in the default folder icon file
+// @see CVCFolderIcon::NewL
+const TInt KProfileFolderIconIndex = 5;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::CVCommandProfileObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVCommandProfileObserver::CVCommandProfileObserver()
+ : iProfileUpdateError( EFalse )
+    {
+    }
+ 
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::ConstructL()
+    {  
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::ConstructL()" );
+    
+    iService = CVCommandHandler::NewL();  
+
+    iProfileEngine = ProEngFactory::NewEngineL();
+    iNameArray = iProfileEngine->ProfileNameArrayLC();     
+    CleanupStack::Pop(); // we can't popup C-class with M-class argument
+     
+    LoadProfileDataL();
+    SyncVCommandProfilesL();
+    
+    // Create the profile engine notify handler only after construction of
+    // other parts have been completed successfully. This way, should
+    // construction fail, we avoid the situation where a callback is executed
+    // on a partially contructed object
+    iNotifyHandler = ProEngFactory::NewNotifyHandlerL();
+    iNotifyHandler->RequestProfileNameArrayNotificationsL( *this );
+    }
+ 
+   
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCommandProfileObserver* CVCommandProfileObserver::NewL() 
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::NewL()" );
+    
+    CVCommandProfileObserver* self = new( ELeave ) CVCommandProfileObserver();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+ 
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::~CVCommandProfileObserver
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CVCommandProfileObserver::~CVCommandProfileObserver()
+    {
+    RUBY_DEBUG0( "CVCommandProfileObserver::~CVCommandProfileObserver()" );
+    
+    if( iProfileEngine ) 
+        {
+        iProfileEngine->Release();    
+        }
+    iProfileEngine = NULL;
+     
+    if( iNameArray ) 
+        {
+        delete iNameArray;
+        iNameArray = NULL;
+        }
+       
+    DeleteCache();
+        
+    delete iService;
+    
+    if ( iNotifyHandler )
+        {
+        iNotifyHandler->CancelProfileNameArrayNotifications();
+        }
+    delete iNotifyHandler;
+    delete iProfileFolder;
+    delete iFolderTitle;
+    delete iProfileTooltip;
+    
+    iAddedCommands.ResetAndDestroy();
+    iAddedCommands.Close();    
+    } 
+  
+ 
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::SyncVCommandProfilesL
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::SyncVCommandProfilesL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::SyncVCommandProfilesL()" );
+    
+    if( !iNameArray || iNameArray->MdcaCount() <= 0 ) 
+        {
+        return;
+        }
+    
+    // Form the set of commands that should be in
+    RVCommandArray profileEngineCommands;
+    CleanupResetAndDestroyPushL( profileEngineCommands );
+    for( TInt i = 0; i < iNameArray->MdcaCount(); i++ )
+        {
+        TInt index = iNameArray->FindByName( iNameArray->MdcaPoint( i ) );
+        TInt profileId = iNameArray->ProfileId( index );
+        CVCommand* command = CreateProfileCommandL( iNameArray->MdcaPoint( i ), profileId );
+        profileEngineCommands.AppendL( command );
+        }
+    
+    // delete cache and force iCommands to be reloaded
+    //
+    DeleteCache();
+
+    const CVCommandArray& storedCommands = ListVCommandsL();
+    CVCommandArray* deduction = storedCommands.ProduceUntrainSetByRunnablesLC( profileEngineCommands );
+    CVCommandArray* addition = storedCommands.ProduceTrainSetByRunnablesLC( profileEngineCommands );
+    
+    iService->RemoveCommandsL( deduction->PointerArray(), ETrue );
+    iService->AddCommandsL( addition->PointerArray(), ETrue );
+    CleanupStack::PopAndDestroy( addition );
+    CleanupStack::PopAndDestroy( deduction );
+    
+    CleanupStack::PopAndDestroy( &profileEngineCommands );
+    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::HandleProfileNameArrayModificationL
+// -----------------------------------------------------------------------------
+//
+// Assume that there will be only one change each time this function is called.
+//
+void CVCommandProfileObserver::HandleProfileNameArrayModificationL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::HandleProfileNameArrayModificationL()" );
+    
+    // delete cache and force iCommands to be reloaded
+    //
+    DeleteCache();
+    
+    // new array of profile names
+    MProEngProfileNameArray* nameArray = iProfileEngine->ProfileNameArrayLC();
+          
+    // copy profile names to two descriptor arrays
+    //
+    CDesC16ArrayFlat* oldNames = new ( ELeave ) CDesCArrayFlat( iNameArray->MdcaCount() );   
+    CleanupStack::PushL( oldNames );
+    
+    CDesC16ArrayFlat* newNames = new ( ELeave ) CDesCArrayFlat( nameArray->MdcaCount() );
+    CleanupStack::PushL( newNames );
+        
+    for( TInt i = 0; i < iNameArray->MdcaCount(); i++ )
+        {
+        oldNames->AppendL( iNameArray->MdcaPoint( i ) );
+        }
+    for( TInt j = 0; j < nameArray->MdcaCount(); j++ )
+        {
+        newNames->AppendL( nameArray->MdcaPoint( j ) );
+        }
+ 
+         
+    // Find changes by deleting equivalent commands from both descriptor arrays.
+    //
+    for( TInt i = 0; i < newNames->MdcaCount(); i++ ) // go through the new names
+        {
+        TName searchStr = newNames->MdcaPoint( i );
+        TInt index;
+        
+        oldNames->Find( searchStr, index, ECmpNormal );
+        
+        if( index != oldNames->MdcaCount() ) // String was found
+            {
+            oldNames->Delete( index );
+            newNames->Delete( i );
+            i--;
+            }
+        }
+      
+      
+    // profile name has been edited
+    //
+    if( newNames->MdcaCount() == oldNames->MdcaCount() ) 
+        {
+    
+        // now we should have a pair of original and changed name
+        //
+        if( newNames->MdcaCount() == 1 ) // let's edit the profile name (old name, new name)
+            {
+            TRAPD( error, EditProfileNameL( oldNames->MdcaPoint( 0 ), newNames->MdcaPoint( 0 ) ) );
+            if ( error == KErrGeneral )
+                {
+                CleanupStack::PopAndDestroy( newNames );    
+                CleanupStack::PopAndDestroy( oldNames );
+                CleanupStack::Pop(); // nameArray ( M-class pointer )
+        
+                delete iNameArray;        
+                iNameArray = nameArray;
+        
+                User::Leave( error );
+                }
+            }
+        }
+    // new profile(s) has been added
+    //
+    else if( newNames->MdcaCount() > oldNames->MdcaCount() ) 
+        {
+        AddNewProfilesL( *newNames, *nameArray );
+        }
+    // profile(s) has been deleted
+    //
+    else 
+        {
+        RemoveProfilesL( *oldNames );
+        }
+    
+    // update old profile names
+    //
+    CleanupStack::PopAndDestroy( newNames );    
+    CleanupStack::PopAndDestroy( oldNames );    
+    CleanupStack::Pop(); // nameArray ( M-class pointer )
+    
+    delete iNameArray;
+    iNameArray = nameArray;
+    
+    if ( iProfileUpdateError )
+        {
+        iProfileUpdateError = EFalse;
+        
+        HandleProfileNameArrayModificationL();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::HandleProfileNameArrayNotificationError
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::HandleProfileNameArrayNotificationError( TInt aError ) 
+    {
+    RUBY_ERROR1( "HandleProfileNameArrayNotificationError: %d", aError );
+    
+    if ( aError == KErrLocked )
+        {
+        iProfileUpdateError = ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::LoadProfileDataL
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::LoadProfileDataL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::LoadProfileDataL()" );
+    
+    RFs fs;
+    CleanupClosePushL( fs );
+    User::LeaveIfError( fs.Connect() );
+    
+    RResourceFile resourceFile;
+    TResourceReader theReader;
+    
+    TFileName name;
+    name.Append( KResourceFile );
+
+    BaflUtils::NearestLanguageFile( fs, name );
+
+    if ( !BaflUtils::FileExists( fs, name ) )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    resourceFile.OpenL( fs, name );
+    CleanupClosePushL( resourceFile );
+
+    // Leaves 'res' to cleanupstack
+    HBufC8* res = resourceFile.AllocReadLC( VCPROFILEOBSERVERINFO );
+    theReader.SetBuffer( res );
+
+    iProfileFolder = theReader.ReadHBufCL();
+    iFolderTitle = theReader.ReadHBufCL();
+    iProfileTooltip = theReader.ReadHBufCL();
+    
+    // Cleanup res 
+    CleanupStack::PopAndDestroy( res );
+    CleanupStack::PopAndDestroy( &resourceFile );
+    CleanupStack::PopAndDestroy( &fs );
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::ListVCommandsL
+// -----------------------------------------------------------------------------
+//
+const CVCommandArray& CVCommandProfileObserver::ListVCommandsL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::ListVCommandsL()" );
+    
+    if( !iCommands )
+        {
+        iCommands = iService->ListCommandsL();
+        }
+        
+    return *iCommands;
+    }
+ 
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::DeleteCache
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::DeleteCache()
+    {
+    RUBY_DEBUG0( "CVCommandProfileObserver::DeleteCache()" );
+    
+    // delete cache and force iCommands to be reloaded
+    //
+    delete iCommands;
+    iCommands = NULL;
+    }
+ 
+ 
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::AddNewProfileL
+// Adds new profile to VCommandhandler.
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::AddNewProfileL( const TDesC& aNewName,
+                                               TInt aProfileId,
+                                               TBool aCommit )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::AddNewProfileL()" );
+    
+    // if profile name doesn't exists
+    //
+    if( FindProfileIndexL( aNewName ) == KErrNotFound )
+        {
+        CVCommand* initialCommand = CreateProfileCommandL( aNewName, aProfileId );
+        CleanupStack::PushL( initialCommand );
+
+        if ( aCommit )
+            {
+            iService->AddCommandL( *initialCommand );
+            CleanupStack::PopAndDestroy( initialCommand );
+
+            // delete cache and force iCommands to be reloaded
+            //
+            DeleteCache();
+            }
+        else
+            {
+            iAddedCommands.AppendL( initialCommand );
+        
+            CleanupStack::Pop( initialCommand );            
+            }
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::AddNewProfilesL
+// Adds new profiles to VCommandhandler.
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::AddNewProfilesL( const CDesC16ArrayFlat& aNames,
+                                                const MProEngProfileNameArray& aProfileNames,
+                                                TBool aCommit )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::AddNewProfilesL()" );
+    
+    RVCommandArray commands;
+    CleanupClosePushL( commands );
+    CleanupResetAndDestroyPushL( commands );
+    
+    for( TInt i = 0; i < aNames.MdcaCount(); i++ )
+        {
+        TInt index = aProfileNames.FindByName( aNames.MdcaPoint(i) );
+        TInt profileId = aProfileNames.ProfileId( index );
+        
+        // if profile name doesn't exists
+        //
+        if( FindProfileIndexL( aNames.MdcaPoint(i) ) == KErrNotFound )
+            {
+            CVCommand* initialCommand = CreateProfileCommandL( aNames.MdcaPoint(i), profileId );
+            CleanupStack::PushL( initialCommand );
+
+            if ( aCommit )
+                {
+                commands.Append( initialCommand );
+                }
+            else
+                {
+                iAddedCommands.AppendL( initialCommand );
+                }
+                
+            CleanupStack::Pop( initialCommand );  
+            }
+        }
+    
+    if ( aCommit )
+        {
+        iService->AddCommandsL( commands );
+                
+        // delete cache and force iCommands to be reloaded
+        //
+        DeleteCache();
+        }
+
+    CleanupStack::PopAndDestroy( &commands );
+    CleanupStack::PopAndDestroy( &commands );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::CreateProfileCommandL
+// Creates a VCommand for the given profile attributes
+// -----------------------------------------------------------------------------
+CVCommand* CVCommandProfileObserver::CreateProfileCommandL( const TDesC& profileName, TInt aProfileId ) const
+        {
+        CVCFolderInfo* folderInfo = CVCFolderInfo::NewL( iFolderTitle->Des(), 
+                                                         iProfileFolder->Des(), 0, 
+                                                         KProfileFolderIconIndex,
+                                                         KIconFile );
+        CleanupStack::PushL( folderInfo );
+        CVCCommandUi* commandUi = CVCCommandUi::NewL( profileName,
+                                                      *folderInfo, ETrue,
+                                                      iProfileTooltip->Des(),
+                                                      KUidAppProfiles );
+        CleanupStack::PopAndDestroy( folderInfo );
+        CleanupStack::PushL( commandUi );
+
+        TBuf8<10>  idDescriptor;
+        idDescriptor.Num( KProfileCommandArgumentBase + aProfileId );
+        CVCRunnable* runnable = CVCRunnable::NewL( KProfileChangerUid, idDescriptor.Left( idDescriptor.Length() ) );
+        CleanupStack::PushL( runnable );
+    
+        CVCommand* command = CVCommand::NewL( profileName,
+                                              *runnable,
+                                              *commandUi );
+        CleanupStack::PopAndDestroy( runnable );
+        CleanupStack::PopAndDestroy( commandUi );
+        return command;
+        }
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::RemoveProfileL
+// Removes profile from VCommandhandler.
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::RemoveProfileL( const TDesC& aName )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::RemoveProfileL()" );
+    
+    TInt idx = 0;
+    while( ( idx = FindProfileIndexL( aName ) ) != KErrNotFound )  
+        {
+        iService->RemoveCommandL( ListVCommandsL()[ idx ] );
+        
+        // delete cache and force iCommands to be reloaded
+        //
+        DeleteCache(); 
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::RemoveProfilesL
+// Removes profiles from VCommandhandler.
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::RemoveProfilesL( const CDesC16ArrayFlat& aNames )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::RemoveProfilesL()" );
+
+    RVCommandArray commands;
+    CleanupClosePushL( commands );
+    
+    for( TInt i = 0; i < aNames.MdcaCount(); i++ )
+        {
+        TInt idx = 0;
+        while( ( idx = FindProfileIndexL( aNames.MdcaPoint(i) ) ) != KErrNotFound )  
+            {
+            commands.Append( &ListVCommandsL()[ idx ] );
+            break;
+            }
+        }
+
+    iService->RemoveCommandsL( commands );
+
+    // delete cache and force iCommands to be reloaded
+    //
+    DeleteCache();
+    
+    CleanupStack::PopAndDestroy( &commands );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVCommandProfileObserver::EditProfileNameL
+// Edits the profile name.
+// -----------------------------------------------------------------------------
+//
+void CVCommandProfileObserver::EditProfileNameL( const TDesC& aOldName, const TDesC& aNewName )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::EditProfileNameL()" );
+    
+    // Get profile id
+    TInt idx = iNameArray->FindByName( aOldName );
+    TInt profileId = iNameArray->ProfileId( idx );
+    
+    idx = FindProfileIndexL( aOldName );
+    
+    // this finds always user edited one, if one exists
+    //
+    if( idx == KErrNotFound )
+        {
+        // for some reason profile doesn't exist in voice command list
+        // so let's add it
+        //
+        return AddNewProfileL( aNewName, profileId ); 
+        }
+    
+    const CVCommand& oldCmd = ListVCommandsL()[ idx ];
+        
+    CVCCommandUi* commandUi = CVCCommandUi::NewL( aNewName, 
+                                                         oldCmd.CommandUi().FolderInfo(), ETrue, 
+                                                         oldCmd.CommandUi().Tooltip(), 
+                                                         oldCmd.CommandUi().IconUid() );
+    CleanupStack::PushL( commandUi );
+                                                      
+    TBuf8<10>  idDescriptor;
+    idDescriptor.Num( profileId );
+    CVCRunnable* runnable = CVCRunnable::NewL( oldCmd.Runnable() );
+    CleanupStack::PushL( runnable );
+    
+    CVCommand* command = CVCommand::NewL( aNewName, *runnable, *commandUi );
+    CleanupStack::PopAndDestroy( runnable );
+    CleanupStack::PopAndDestroy( commandUi );
+    CleanupStack::PushL( command );
+        
+    // Delete old command
+    iService->RemoveCommandL( oldCmd );
+      
+    // delete cache and force iCommands to be reloaded
+    //
+    DeleteCache(); 
+      
+    while( ( idx = FindProfileIndexL( aOldName ) ) != KErrNotFound ) 
+        {
+        iService->RemoveCommandL( ListVCommandsL()[ idx ] );
+        DeleteCache(); 
+        }
+        
+    // Add new command
+    //    
+    iService->AddCommandL( *command );
+    CleanupStack::PopAndDestroy( command ); 
+    
+    // delete cache and force iCommands to be reloaded
+    //
+    DeleteCache(); 
+    }
+
+
+// ---------------------------------------------------------
+// CVCommandProfileObserver::FindProfileIndexL
+// ---------------------------------------------------------
+//
+// Assumes that profiles are in a folder called GetProfileFolderName().
+//
+// Finds always the user edited command if it exists.
+//
+TInt CVCommandProfileObserver::FindProfileIndexL( const TDesC& aName )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandProfileObserver::FindProfileIndexL()" );
+    
+    TInt retval = KErrNotFound;
+    
+    for( TInt i = 0; i < ListVCommandsL().Count(); i++ ) 
+        {
+        if( ListVCommandsL()[ i ].CommandUi().FolderInfo().Title() == iFolderTitle->Des() && 
+            aName == ListVCommandsL()[ i ].CommandUi().WrittenText() ) 
+            {
+            retval = i;
+            
+            // user edited command
+            //
+            if( ListVCommandsL()[ i ].SpokenText() != 
+                ListVCommandsL()[ i ].CommandUi().WrittenText() ) 
+                {
+                break;
+                }
+            }
+        }
+    return retval;    
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/src/vuipprofileobserverecomsupport.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  profile observer vuipf-plugin
+*
+*/
+
+
+#include "vuipprofileobserverplugin.h"
+
+#include <implementationproxy.h>
+#include <nssvuipf.hrh>
+
+
+const TImplementationProxy ImplementationTable[] = 
+    {
+    { {0x10281CED}, (TProxyNewLPtr) CVUIPprofileobserverplugin::NewL }
+    };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+    return ImplementationTable;
+    } 
+ 
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/profileobserverplugin/src/vuipprofileobserverplugin.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  profile observer vuipf-plugin
+*
+*/
+
+
+#include "vuipprofileobserverplugin.h"
+#include "vcommandprofileobserver.h"
+#include "rubydebug.h"
+
+#include <ProEngFactory.h>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVUIPprofileobserverplugin::CVUIPprofileobserverplugin
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVUIPprofileobserverplugin::CVUIPprofileobserverplugin()
+    {
+    }
+   
+ 
+// -----------------------------------------------------------------------------
+// CVUIPprofileobserverplugin::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVUIPprofileobserverplugin::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "CVUIPprofileobserverplugin::ConstructL()" );
+    
+    iProfileObserver = CVCommandProfileObserver::NewL();
+    }
+ 
+   
+// -----------------------------------------------------------------------------
+// CVUIPprofileobserverplugin::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVUIPprofileobserverplugin* CVUIPprofileobserverplugin::NewL() 
+    {
+    RUBY_DEBUG_BLOCK( "CVUIPprofileobserverplugin::NewL()" );
+    
+    CVUIPprofileobserverplugin* self = new( ELeave ) CVUIPprofileobserverplugin();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); 
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVUIPprofileobserverplugin::~CVUIPprofileobserverplugin
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CVUIPprofileobserverplugin::~CVUIPprofileobserverplugin()
+    {
+    RUBY_DEBUG0( "CVUIPprofileobserverplugin::~CVUIPprofileobserverplugin()" );
+    
+    delete iProfileObserver;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVUIPprofileobserverplugin::InitializeL
+// Handle voice event
+// -----------------------------------------------------------------------------
+//
+
+void CVUIPprofileobserverplugin::InitializeL( MVoiceEventExecutor& /*aEventHandler*/ )
+    {
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rom/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,4 @@
+// exports.inc
+srsf.iby                   CORE_APP_LAYER_IBY_EXPORT_PATH(srsf.iby) 
+srsfresources.iby          LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(srsfresources.iby)
+srsf_variant.iby           CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(srsf_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rom/srsf.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for SRSF
+*
+*/
+
+
+#ifndef __SRSF_IBY__
+#define __SRSF_IBY__
+
+#ifdef __SIND
+
+// VCommanExecutor
+file=ABI_DIR\BUILD_DIR\nssvcommandexecutor.exe     PROGRAMS_DIR\nssvcommandexecutor.exe
+ECOM_PLUGIN(nssvcexecutorbearer.dll, nssvcexecutorbearer.rsc)
+
+// VCommandManager
+S60_APP_EXE(vcommandmanager)       // vcommandmanager.exe
+S60_APP_AIF_RSC(vcommandmanager)   // vcommandmanager_reg.rsc
+S60_APP_RESOURCE(vcommandmanager)  // vcommandmanager.rsc (no need to localize!)
+
+// vcexecutorapp
+S60_APP_EXE(vcexecutorapp)       // vcexecutorapp.exe
+S60_APP_AIF_RSC(vcexecutorapp)   // vcexecutorapp_reg.rsc
+ 
+// Plugin handler
+file=ABI_DIR\BUILD_DIR\nssvoiceuipluginhandler.dll  SHARED_LIB_DIR\nssvoiceuipluginhandler.dll
+
+// ProfileObserver
+ECOM_PLUGIN(vuipprofileobserverplugin.dll, vuipprofileobserverplugin.rsc)
+
+// Voice commands XML files
+data=ZPRIVATE\102818E7\defaultvoicecommands.xml     private\102818E7\defaultvoicecommands.xml
+
+#ifdef __BT
+data=ZPRIVATE\102818E7\btvoicecommands.xml          private\102818E7\btvoicecommands.xml
+#endif // __BT
+#ifdef __EMAIL_UI
+data=ZPRIVATE\102818E7\emailvoicecommands.xml       private\102818E7\emailvoicecommands.xml
+#endif // __EMAIL_UI
+#ifdef __IM
+data=ZPRIVATE\102818E7\imvoicecommands.xml          private\102818E7\imvoicecommands.xml
+#endif // __IM
+#ifdef __S60_FM_RADIO_APPLICATION
+data=ZPRIVATE\102818E7\radiovoicecommands.xml       private\102818E7\radiovoicecommands.xml
+#endif // __S60_FM_RADIO_APPLICATION
+#ifdef __SERIES60_REAL_PLAYER
+data=ZPRIVATE\102818E7\realplayervoicecommands.xml  private\102818E7\realplayervoicecommands.xml
+#endif // __SERIES60_REAL_PLAYER
+#ifdef __VIDEO_RECORDER
+data=ZPRIVATE\102818E7\vrvoicecommands.xml          private\102818E7\vrvoicecommands.xml
+#endif // __VIDEO_RECORDER
+#ifdef __MMS_POSTCARD
+data=ZPRIVATE\102818E7\mmspostcardvoicecommands.xml          private\102818E7\mmspostcardvoicecommands.xml
+#endif // __MMS_POSTCARD
+#ifdef __BASIC_LOCATION_INFO_DISPLAY
+data=ZPRIVATE\102818E7\locationvoicecommands.xml          private\102818E7\locationvoicecommands.xml
+#endif // __BASIC_LOCATION_INFO_DISPLAY
+
+//backup registration file 
+data=ZPRIVATE\10201AFE\backup_registration.xml                  private\10201AFE\backup_registration.xml
+data=ZPRIVATE\10201AFF\backup_registration.xml                  private\10201AFF\backup_registration.xml
+
+// For SRSF VAS
+file=ABI_DIR\BUILD_DIR\nssvasapi.dll                            SHARED_LIB_DIR\nssvasapi.dll
+file=ABI_DIR\BUILD_DIR\nssvascontacthdlr.dll                    SHARED_LIB_DIR\nssvascontacthdlr.dll
+file=ABI_DIR\BUILD_DIR\vcommandhandler.dll                      SHARED_LIB_DIR\vcommandhandler.dll
+
+// For SRSF
+
+// Publishes the DLL and the ECOM resource file
+ECOM_PLUGIN( nsssicontrollerplugin.dll, 101ff930.rsc )
+
+// Publishes the DLL and the ECOM resource file
+ECOM_PLUGIN( nssttscontrollerplugin.dll, 101ff933.rsc )
+
+file=ABI_DIR\BUILD_DIR\nssdevasr.dll                            SHARED_LIB_DIR\nssdevasr.dll
+file=ABI_DIR\BUILD_DIR\nsssispeechrecognitiondata.dll           SHARED_LIB_DIR\nsssispeechrecognitiondata.dll
+file=ABI_DIR\BUILD_DIR\nsssispeechrecognitioncustomcommands.dll SHARED_LIB_DIR\nsssispeechrecognitioncustomcommands.dll
+file=ABI_DIR\BUILD_DIR\nsssispeechrecognitionutility.dll        SHARED_LIB_DIR\nsssispeechrecognitionutility.dll
+file=ABI_DIR\BUILD_DIR\nssdevtts.dll                            SHARED_LIB_DIR\nssdevtts.dll   
+file=ABI_DIR\BUILD_DIR\nssttscustomcommands.dll                 SHARED_LIB_DIR\nssttscustomcommands.dll    
+file=ABI_DIR\BUILD_DIR\nssttscommon.dll                         SHARED_LIB_DIR\nssttscommon.dll
+file=ABI_DIR\BUILD_DIR\nssttsutility.dll                        SHARED_LIB_DIR\nssttsutility.dll
+
+// RSpeechSynthesis
+file=ABI_DIR\BUILD_DIR\speechsynthesis.dll                      SHARED_LIB_DIR\speechsynthesis.dll
+file=ABI_DIR\BUILD_DIR\speechsynthesisserver.exe                PROGRAMS_DIR\speechsynthesisserver.exe
+
+data=DATAZ_\resource\nssvasresource.rsc                         RESOURCE_FILES_DIR\nssvasresource.rsc
+data=DATAZ_\resource\nssdevasr.rsc                              RESOURCE_FILES_DIR\nssdevasr.rsc
+data=DATAZ_\resource\nssdevtts.rsc                              RESOURCE_FILES_DIR\nssdevtts.rsc
+
+
+// This is published within ECOM_PLUGIN macro
+// data=\Epoc32\Data\Z\System\Libs\PlugIns\101ff930.rsc         ECOM_RESOURCE_DIR\101ff930.rsc // SI SRS plug-in
+data=DATAZ_\resource\nsssisrscontrollerplugin.rsc               resource\nsssisrscontrollerplugin.rsc
+
+
+// This is published within ECOM_PLUGIN macro
+// data=\Epoc32\Data\Z\System\Libs\PlugIns\101ff933.rsc         ECOM_RESOURCE_DIR\101ff933.rsc // TTS plug-in
+data=DATAZ_\resource\ttspluginsettings.rsc                      resource\ttspluginsettings.rsc
+
+// DBMS security policy files
+// VAS DB
+data=ZPRIVATE\100012a5\policy\10201AFE.spd                      private\100012a5\policy\10201AFE.spd
+// SRS Plugin DB
+data=ZPRIVATE\100012a5\policy\10201AFF.spd                      private\100012a5\policy\10201AFF.spd
+
+// NSS version information
+data=ZPRIVATE\10208ACC\10201AEE.txt                             private\10208ACC\10201AEE.txt
+
+#endif //__SIND
+
+#endif //__SRSF_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rom/srsf_variant.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Variant-specific IBY file for SRSF
+*
+*/
+
+
+#ifndef __SRSF_VARIANT_IBY__
+#define __SRSF_VARIANT_IBY__
+
+#ifdef FF_INCLUDE_CHINESE_DICTIONARY
+data=ZPRIVATE\102818E7\dictvoicecommands.xml        private\102818E7\dictvoicecommands.xml
+#endif // FF_INCLUDE_CHINESE_DICTIONARY
+
+#endif //__SRSF_VARIANT_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rom/srsfresources.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef __SRSFRESOURCES_IBY__
+#define __SRSFRESOURCES_IBY__
+
+#ifdef __SIND
+
+S60_APP_RESOURCE(vcexecutorapp)  // vcexecutorapp.rsc
+
+data = DATAZ_\resource\nssvascontacthandler.rsc   RESOURCE_FILES_DIR\nssvascontacthandler.rsc
+data = DATAZ_\resource\defaultvoicecommands.rsc   RESOURCE_FILES_DIR\defaultvoicecommands.rsc
+data = DATAZ_\resource\vcommandexecutor.rsc       RESOURCE_FILES_DIR\vcommandexecutor.rsc
+data = DATAZ_\resource\vcprofileobserver.rsc      RESOURCE_FILES_DIR\vcprofileobserver.rsc
+
+#endif // __SIND
+
+#endif // __SRSFRESOURCES_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rubydebug/rubydebug.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Debugging utilities implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include "RubyDebug.h"
+
+#ifdef __RUBY_DEBUG_TRACES_TO_FILE
+#include <f32file.h>
+#endif
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::PrintToFile
+// Method for writing traces to a file.
+// -----------------------------------------------------------------------------
+//
+#ifdef __RUBY_DEBUG_TRACES_TO_FILE
+
+#ifdef _DEBUG // UDEB version:
+EXPORT_C void RRubyDebug::PrintToFile( TRefByValue<const TDesC> aFmt, ... )
+    {
+    _LIT( KRubyLogFileName, "\\Logs\\RubyTrace.log" );
+
+    const TInt KRubyDebugMaxLineLength = 0x80; // rest will be truncated
+
+    const TInt KRubyDebugOpenFileRetries = 100;
+    const TInt KRubyDebugOpenFileInterval = 1000;
+
+    const TUint16 KRubyDebugLineSep1 = 0x0d;
+    const TUint16 KRubyDebugLineSep2 = 0x0a;
+
+    // Handle variable argument list
+    VA_LIST list;
+	VA_START( list, aFmt );
+	TBuf<KRubyDebugMaxLineLength+2> aBuf;
+    TTruncateOverflow overflow;
+	aBuf.AppendFormatList( aFmt, list, &overflow );
+	if( aBuf.Length() > ( KRubyDebugMaxLineLength - 2 ) )
+		{
+		aBuf.Delete(aBuf.Length() - 2, 2);
+		}
+	
+    // Add linefeed characters
+    aBuf.Append( KRubyDebugLineSep1 );
+    aBuf.Append( KRubyDebugLineSep2 );
+
+    RFs fs;
+    if ( fs.Connect() == KErrNone )
+        {
+        RFile file;
+
+        // Open file in an exclusive mode so that only one thread 
+        // can acess it simultaneously
+        TUint fileMode = EFileWrite | EFileShareExclusive;
+
+        TInt err = file.Open( fs, KRubyLogFileName, fileMode );
+
+        // Create a file if it doesn't exist
+        if ( err == KErrNotFound )
+            {
+            err = file.Create( fs, KRubyLogFileName, fileMode );
+            }
+        else
+            {
+            // Error in opening the file
+            TInt retryCount = KRubyDebugOpenFileRetries;
+            while ( err == KErrInUse && retryCount-- )
+                {
+                // Some other tread is accessing the file, wait a while...
+                User::After( KRubyDebugOpenFileInterval );
+                err = file.Open( fs, KRubyLogFileName, fileMode );
+                }
+            }
+
+        // Check if we have access to a file
+        if ( err == KErrNone )
+            {
+            TInt offset = 0;
+            if ( file.Seek( ESeekEnd, offset ) == KErrNone )
+                {
+                // Append text to the end of file
+                TPtr8 ptr8( (TUint8*)aBuf.Ptr(), aBuf.Size(), aBuf.Size() );
+                file.Write( ptr8 );
+                }
+            file.Close();
+            }
+
+        fs.Close();
+        }
+    }
+
+#else // UREL version:
+EXPORT_C void RRubyDebug::PrintToFile( TRefByValue<const TDesC> /*aFmt*/, ... )
+    {
+    }
+#endif
+
+#endif // __RUBY_DEBUG_TRACES_TO_FILE
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rubydebug/rubydebug.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,271 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface of debugging utilities.
+*      %version: 1.1.3 %
+*
+*/
+
+
+#ifndef RUBYDEBUG_H
+#define RUBYDEBUG_H
+
+#include "rubydebugcfg.h"
+
+//  INCLUDES
+#include <e32svr.h> // For RDebug
+
+#ifndef RUBY_DISABLE_FUNCTION_NAMES
+    // No sense to store function name longer, than can be printed
+    // 0x100 is the internal RDebug limit
+    const TInt __K_RUBY_FUNCTION_NAME_LENGTH = 0x50;    
+
+    // Prepares function name for printing
+    #define __RUBY_PREPARE_FUNCTION_NAME \
+    TBuf<__K_RUBY_FUNCTION_NAME_LENGTH> __ruby_function_name__;\
+    __ruby_function_name__.Copy( TPtrC8( (TText8*)&__PRETTY_FUNCTION__ ).Left( __K_RUBY_FUNCTION_NAME_LENGTH ) ); \
+
+    // Token to paste the function name into
+    #define __K_RUBY_FUNCTION_NAME_TOKEN "%S "
+    
+    // Comma and function name
+    #define __RUBY_FUNCTION_NAME __ruby_function_name__
+    
+    // A wrapper that prepares and supplies the function name as __ruby_function_name__
+    #define __RUBY_FUNCTION_NAMED( text ) \
+	    {\
+	    __RUBY_PREPARE_FUNCTION_NAME;\
+	    text;\
+	    }
+	    
+	#define __RUBY_FUNCTION_NAME_POINTER8 (TText8*)&__PRETTY_FUNCTION__
+    
+
+#else  // RUBY_DISABLE_FUNCTION_NAMES
+
+    #define __RUBY_PREPARE_FUNCTION_NAME
+    
+    // Don't print the function name
+    #define __K_RUBY_FUNCTION_NAME_TOKEN ""
+    
+    // exclude the whole token, with the comma
+    #define __RUBY_FUNCTION_NAME KNullDesC
+    
+    // no wrapping
+    #define __RUBY_FUNCTION_NAMED( text ) text
+    
+    #define __RUBY_FUNCTION_NAME_POINTER8 NULL
+
+#endif // RUBY_DISABLE_FUNCTION_NAMES
+
+// Macro for printing filename both in unicode and non-unicode builds
+
+
+#ifdef _UNICODE
+	#define __RUBY_WIDEN2(x) L ## x
+	#define __RUBY_WIDEN(x) __RUBY_WIDEN2(x)
+	#define __RUBY_DBG_FILE__ __RUBY_WIDEN(__FILE__)
+#else
+	#define __RUBY_DBG_FILE__ __FILE__
+#endif//_UNICODE
+
+
+
+// Debugging is enabled only in _DEBUG builds
+//#ifdef _DEBUG 
+
+// Select the debug output method
+#ifndef __RUBY_DEBUG_TRACES_TO_FILE
+#define RUBY_DEBUG_METHOD RDebug::Print
+#else
+#define RUBY_DEBUG_METHOD RRubyDebug::PrintToFile
+#endif // __RUBY_DEBUG_TRACES_TO_FILE
+
+//#endif // _DEBUG
+
+#if defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+
+//	#define RUBY_DEBUG_BLOCK(text) \
+//  	RRubyDebug trace_trace( _S(text), _S("" ## __RUBY_DBG_FILE__) , __LINE__, EFalse ); \
+//  	CleanupReleasePushL( trace_trace )
+  	
+//  	#define RUBY_DEBUG_BLOCKL(text) \
+//  	RRubyDebug trace_trace( _S(text), _S("" ## __RUBY_DBG_FILE__), __LINE__, ETrue ); \
+//  	CleanupReleasePushL( trace_trace )
+// A temporary fix to cope with builds on RVCT 530. It didn't compile with _RUBY_DBG_FILE
+	#define RUBY_DEBUG_BLOCK(text) \
+  	RRubyDebug trace_trace( _S(text), _S("") , __LINE__, EFalse, __RUBY_FUNCTION_NAME_POINTER8 ); \
+  	CleanupReleasePushL( trace_trace )
+
+  	#define RUBY_DEBUG_BLOCKL(text) \
+  	RRubyDebug trace_trace( _S(text), _S(""), __LINE__, ETrue, __RUBY_FUNCTION_NAME_POINTER8 ); \
+  	CleanupReleasePushL( trace_trace )
+
+	#define RUBY_DEBUG0(text) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+	#define RUBY_DEBUG1(text, p1) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+	#define RUBY_DEBUG2(text, p1, p2) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, p2, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+#else // Debugging disabled
+
+	// Macros expand to nothing:
+	#define RUBY_DEBUG_BLOCK(text)
+	#define RUBY_DEBUG0(text)    
+	#define RUBY_DEBUG1(text, p1)
+	#define RUBY_DEBUG2(text, p1, p2)
+	#define RUBY_DEBUG_BLOCKL(text)
+
+#endif // defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+
+#if !defined(RUBY_DISABLE_ERRORS) || defined(_DEBUG)
+	// if error messages are allowed (even for UREL)
+	#define RUBY_ERROR0(text) \
+	__RUBY_FUNCTION_NAMED( \
+	    RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+
+	#define RUBY_ERROR1(text, p1) \
+	__RUBY_FUNCTION_NAMED( \
+	RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+
+	#define RUBY_ERROR2(text, p1, p2) \
+	__RUBY_FUNCTION_NAMED( \
+	RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, p2, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+#else
+	// error reporting disabled
+	// Macros expand to nothing:
+	#define RUBY_ERROR_BLOCK(text)
+	#define RUBY_ERROR0(text)    
+	#define RUBY_ERROR1(text, p1)
+	#define RUBY_ERROR2(text, p1, p2)
+#endif  // !defined(RUBY_DISABLE_ERRORS)
+
+#if !defined(RUBY_DISABLE_ASSERT_DEBUG) || defined(_DEBUG)
+	#define RUBY_ASSERT_DEBUG(condition, action) \
+	  __RUBY_FUNCTION_NAMED(\
+		__ASSERT_ALWAYS( condition, RUBY_DEBUG_METHOD(  _L("%S[Error!] %S [Assert failed!] "L###condition L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id())) ); \
+		__ASSERT_DEBUG( (condition), (action) )\
+	  );
+#else
+	// Macro expands to default:
+	#define RUBY_ASSERT_DEBUG(condition, action) __ASSERT_DEBUG(condition,action)
+#endif
+
+// Same as TRAP_IGNORE, but in case of leave, prints the leave code via RUBY_ERROR
+// Can be disabled by RUBY_DISABLE_TRAP_IGNORE or RUBY_DISABLE_ERRORS
+// If disabled, is equivalent to TRAP_IGNORE
+// @see rubydebugcfg.h
+#ifndef RUBY_DISABLE_TRAP_IGNORE 
+    #define RUBY_TRAP_IGNORE( s ) \
+        {\
+        TRAPD( err, s );\
+        if( err != KErrNone )\
+            {\
+            RUBY_ERROR1( "RUBY_TRAP_IGNORE leaves with [%d]", err );\
+            }\
+        }
+#else  // RUBY_DISABLE_TRAP_IGNORE 
+    #define RUBY_TRAP_IGNORE( s ) TRAP_IGNORE( s )
+#endif  // RUBY_DISABLE_TRAP_IGNORE 
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Debug class for printing START, EXIT and LEAVE messages to RDebug in every 
+*  code block. Must be placed in the very beginning of a code block and the
+*  code block cannot leave items in the cleanup stack (like NewLC). 
+*
+*  @since Series 60 2.8
+*
+*  @note If this object is not the topmost item when a code block is exited, 
+*        E32USER-CBase 90 panic is raised (@see CleanupStack::Pop( TAny* )).
+*/
+class RRubyDebug
+    {
+    public:
+        /**
+        * C++ constructor.
+        * @since Series 60 2.8
+        * @param aMsg Debug message.
+        * @param aCalledFromL ETrue if called from RUBY_DEBUG_BLOCK_L
+        */
+        inline RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL,
+                           const TText8* aFunctionName = NULL );
+
+        /**
+        * Destructor.
+        */
+        inline ~RRubyDebug();
+
+        /**
+        * Destructor for Cleanup support. Called when a method leaves.
+        */
+        inline void Release();
+
+        /**
+        * Support for writing traces to file.
+        */
+        IMPORT_C static void PrintToFile( TRefByValue<const TDesC> aFmt, ... );
+
+    private:
+        /**
+        *  Class for truncating debug messages if they are too long.
+        *  @since Series 60 2.8
+        */
+        class TTruncateOverflow : public TDesOverflow
+            {
+            public: // Methods from TDesOverflow
+
+                inline void Overflow( TDes& aDes );
+            };
+
+    private:
+        // A pointer to the debug message
+        TPtrC iMsg;
+        
+        // A pointer to the filename where RUBY_DEBUG_BLOCK is written
+        TPtrC iFileName;
+        
+        // Number of the line where RUBY_DEBUG_BLOCK is written
+        TInt iLine;
+
+		// ETrue if we are called from RUBY_DEBUG_BLOCKL
+        TBool iCalledFromL;
+
+        // Flag that is set when a leave occurs
+        TBool iLeave;
+
+	#ifndef RUBY_DISABLE_FUNCTION_NAMES        
+        // Used only if aFunctionName is defined in constructor
+        HBufC* iFunctionName;
+   	#endif  // RUBY_DISABLE_FUNCTION_NAMES
+        
+    };
+
+#include "rubydebug.inl"
+
+#endif      // RUBYDEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rubydebug/rubydebug.inl	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This module contains the implementation of RRubyDebug class 
+*	             member functions.
+*  %version: 3 %
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+#ifdef _DEBUG
+_LIT( KRubyDebugStart,  "START" );
+_LIT( KRubyDebugStop,   "EXIT" );
+_LIT( KRubyDebugLeave,  "LEAVE!!!" );
+_LIT( KRubyDebugStr,    "%S%S %S [F:%S][L:%d][TId:%d]" );
+#endif
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+#ifdef _DEBUG
+// -----------------------------------------------------------------------------
+// RRubyDebug::RRubyDebug
+// C++ constructor
+// -----------------------------------------------------------------------------
+//
+    
+inline RRubyDebug::RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL,
+                               const TText8* aFunctionName )
+	: iMsg( aMsg ), iFileName( aFileName ), iLine ( aLine ), iCalledFromL ( aCalledFromL ), iLeave ( EFalse )
+	{
+	#ifndef RUBY_DISABLE_FUNCTION_NAMES
+	iFunctionName = NULL;
+	// If function name is defined, use it instead of aMsg
+	if( aFunctionName )
+	    {
+	    TPtrC8 ptr8Name( aFunctionName );
+	    iFunctionName = HBufC::New( ptr8Name.Length() );
+	    if( iFunctionName )
+	        {
+	        // If memory for a 16-bit copy has been allocated successfully
+	        iFunctionName->Des().Copy( ptr8Name );
+	        iMsg.Set( *iFunctionName );
+	        }
+	    }
+	#endif // RUBY_DISABLE_FUNCTION_NAMES
+	TInt id = RThread().Id();
+    iCalledFromL = aCalledFromL;  
+    if( !iCalledFromL) 
+    	{
+    	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id );
+    	}
+    else {
+    	#ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    	// For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id );
+    	#endif
+    	}
+	}    
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::~RRubyDebug
+// Destructor
+// -----------------------------------------------------------------------------
+//
+inline RRubyDebug::~RRubyDebug()
+    {
+    if ( !iLeave ) 
+        {
+        // This is done only if destructor is NOT called from Release().
+        // Otherwise the cleanup stack pops this item automatically.
+        TInt id = RThread().Id();
+        if (!iCalledFromL) 
+        	{
+        	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStop, &iFileName, iLine, id );
+        	}
+        else
+        	{
+        	#ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    		// For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    		RUBY_DEBUG_METHOD( KRubyDebugStr, &KRubyDebugPrefix, &iMsg, &KRubyDebugStop, &iFileName, iLine, id );
+    		#endif
+        	}
+        #ifndef RUBY_DISABLE_FUNCTION_NAMES
+        delete iFunctionName;  // if any
+        #endif  // RUBY_DISABLE_FUNCTION_NAMES
+        CleanupStack::Pop( this ); // E32USER-CBase 90 panic is raised if
+                                   // this is not the topmost item
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::Release()
+// Method that makes it possible to push this object into the cleanup stack.
+// -----------------------------------------------------------------------------
+//
+inline void RRubyDebug::Release()
+    {
+    iLeave = ETrue;
+    TInt id = RThread().Id();
+    RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugLeave, &iFileName, iLine, id );
+    #ifndef RUBY_DISABLE_FUNCTION_NAMES
+    delete iFunctionName;  // if any
+    #endif  // RUBY_DISABLE_FUNCTION_NAMES
+    this->~RRubyDebug();
+    }
+#endif
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::TTruncateOverflow::Overflow()
+// Method for ignoring the overflowing part of a debug message.
+// -----------------------------------------------------------------------------
+//
+inline void RRubyDebug::TTruncateOverflow::Overflow( TDes& /*aDes*/ )
+    {
+    // We ignore the overflowing part of the descriptor...
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rubydebug/rubydebugcfg.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration file for RubyDebug macros
+*  %version: 3 %
+*
+*/
+
+
+#ifndef RUBYDEBUGCFG_H
+#define RUBYDEBUGCFG_H
+
+
+#include <e32cmn.h> // TLitC
+#include <e32def.h> // _LIT
+
+#include "rubydebugconfigselector.h"
+
+// Common settings
+// Is printed at the beginning of the line
+_LIT( __K_RUBY_HEADER, "[<SRSF>] ");
+
+// Is printed after __KRUBY_HEADER for the error messages
+_LIT( __K_RUBY_ERROR, "[Error!] ");
+
+
+#if defined(RUBY_EXTERNAL_VARIANT) && defined(__WINS__)
+// set of options to use when the project is released to the customers
+
+// Uncomment the following line to disable RUBY_DEBUGs. 
+// This has no effect on RUBY_ERRORs
+#define __RUBY_DEBUG_DISABLED
+
+// Uncomment the following line to get traces to C:\Logs\RubyTrace.log
+//#define __RUBY_DEBUG_TRACES_TO_FILE
+
+// Uncomment the following line to stop disable RUBY_ERRORs
+// Error print is always enabled in _DEBUG
+//#define RUBY_DISABLE_ERRORS
+
+// Uncomment the following line to disable extra output for RUBY_ASSERT_DEBUG
+// RUBY_ASSERT_DEBUGs will become usual __ASSERT_DEBUGs
+#define RUBY_DISABLE_ASSERT_DEBUG
+
+// Uncomment the following line to disable automated function name printing
+//#define RUBY_DISABLE_FUNCTION_NAMES
+
+//#define RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+
+// Uncomment the following line to disable leave code printing in RUBY_TRAP_IGNORE
+// macro. It would make it equivalent to TRAP_IGNORE
+// #define RUBY_DISABLE_TRAP_IGNORE
+
+
+#else //  RUBY_EXTERNAL_VARIANT
+// set of options to use in the internal development
+
+// Uncomment the following line to disable RUBY_DEBUGs. 
+// This has no effect on RUBY_ERRORs
+//#define __RUBY_DEBUG_DISABLED
+
+// Uncomment the following line to get traces to C:\Logs\RubyTrace.log
+//#define __RUBY_DEBUG_TRACES_TO_FILE
+
+// Uncomment the following line to stop disable RUBY_ERRORs
+// Error print is always enabled in _DEBUG
+#define RUBY_DISABLE_ERRORS
+
+// Uncomment the following line to disable extra output for RUBY_ASSERT_DEBUG
+// RUBY_ASSERT_DEBUGs will become usual __ASSERT_DEBUGs
+#define RUBY_DISABLE_ASSERT_DEBUG
+
+// Uncomment the following line to disable automated function name printing
+//#define RUBY_DISABLE_FUNCTION_NAMES
+
+//#define RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+
+// Uncomment the following line to disable leave code printing in RUBY_TRAP_IGNORE
+// macro. It would make it equivalent to TRAP_IGNORE
+// #define RUBY_DISABLE_TRAP_IGNORE
+
+#endif  //  RUBY_EXTERNAL_VARIANT
+
+#endif // RUBYDEBUGCFG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/rubydebug/rubydebugconfigselector.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Switches sets of the RubyDebug options. 
+*                @warning DO NOT change the file. At least DO NOT check in the modified version.
+*                Variants should be switched by replacing the whole rubydebugconfigselector.h 
+*                with the help of a Synergy task. 
+*  %version: 3 %
+*
+*/
+
+
+#ifndef RUBYDEBUGCONFIGSELECTOR_H
+#define RUBYDEBUGCONFIGSELECTOR_H
+
+
+// CONSTANTS
+
+/** 
+ * If defined, rubydebug will be tuned with a set of options designed for external users
+ * Typically it means showing all the warnings for hardware builds and only errors for the
+ * SW builds
+ *
+ * If not defined, rubydebug will be tuned for the internal Multimodal UI team development.
+ * Typically it means all the warnings always enabled
+ *
+ * The meaning of the variant is defined in the rubydebugcfg.h
+ * @warning DO NOT change the line. At least DO NOT check in the modified version.
+ *          Variants should be switched by replacing the whole rubydebugconfigselector.h 
+ *          with the help of a Synergy task. 
+ *
+ */
+#define RUBY_EXTERNAL_VARIANT
+
+#endif // RUBYDEBUGCONFIGSELECTOR_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/bwins/nsssispeechrecognitioncustomcommands_sindeu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+EXPORTS
+	??0RSISpeechRecognitionCustomCommands@@QAE@AAVRMMFController@@@Z @ 1 NONAME ; public: __thiscall RSISpeechRecognitionCustomCommands::RSISpeechRecognitionCustomCommands(class RMMFController &)
+	??1CSISpeechRecognitionCustomCommandParser@@UAE@XZ @ 2 NONAME ; public: virtual __thiscall CSISpeechRecognitionCustomCommandParser::~CSISpeechRecognitionCustomCommandParser(void)
+	?ActivateGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 3 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::ActivateGrammar(unsigned short)
+	?Adapt@RSISpeechRecognitionCustomCommands@@QAEHABVCSIClientResultSet@@H@Z @ 4 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::Adapt(class CSIClientResultSet const &,int)
+	?AddPronunciation@RSISpeechRecognitionCustomCommands@@QAEHGABVTDesC16@@W4TLanguage@@AAK@Z @ 5 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddPronunciation(unsigned short,class TDesC16 const &,enum TLanguage,unsigned long &)
+	?AddRule@RSISpeechRecognitionCustomCommands@@QAEHGGKAAK@Z @ 6 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddRule(unsigned short,unsigned short,unsigned long,unsigned long &)
+	?AddRuleVariant@RSISpeechRecognitionCustomCommands@@QAEHGGABV?$RArray@K@@KAAE@Z @ 7 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddRuleVariant(unsigned short,unsigned short,class RArray<unsigned long> const &,unsigned long,unsigned char &)
+	?AddVoiceTag@RSISpeechRecognitionCustomCommands@@QAEHABVMDesC16Array@@ABV?$RArray@W4TLanguage@@@@GGAAK@Z @ 8 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddVoiceTag(class MDesC16Array const &,class RArray<enum TLanguage> const &,unsigned short,unsigned short,unsigned long &)
+	?AddVoiceTags@RSISpeechRecognitionCustomCommands@@QAEHABV?$RPointerArray@VMDesC16Array@@@@ABV?$RArray@W4TLanguage@@@@GGAAV?$RArray@K@@@Z @ 9 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddVoiceTags(class RPointerArray<class MDesC16Array> const &,class RArray<enum TLanguage> const &,unsigned short,unsigned short,class RArray<unsigned long> &)
+	?Cancel@RSISpeechRecognitionCustomCommands@@QAEXXZ @ 10 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::Cancel(void)
+	?CommitChanges@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 11 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CommitChanges(void)
+	?CreateGrammar@RSISpeechRecognitionCustomCommands@@QAEHAAG@Z @ 12 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateGrammar(unsigned short &)
+	?CreateLexicon@RSISpeechRecognitionCustomCommands@@QAEHAAG@Z @ 13 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateLexicon(unsigned short &)
+	?CreateModelBank@RSISpeechRecognitionCustomCommands@@QAEHAAG@Z @ 14 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateModelBank(unsigned short &)
+	?CreateRule@RSISpeechRecognitionCustomCommands@@QAEHGAAK@Z @ 15 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateRule(unsigned short,unsigned long &)
+	?DeactivateGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 16 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::DeactivateGrammar(unsigned short)
+	?EndRecSession@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 17 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::EndRecSession(void)
+	?EndRecord@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 18 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::EndRecord(void)
+	?GetAllClientGrammarIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 19 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllClientGrammarIDs(void)
+	?GetAllClientLexiconIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 20 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllClientLexiconIDs(void)
+	?GetAllClientModelBankIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 21 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllClientModelBankIDs(void)
+	?GetAllGrammarIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 22 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllGrammarIDs(void)
+	?GetAllLexiconIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 23 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllLexiconIDs(void)
+	?GetAllModelBankIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 24 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllModelBankIDs(void)
+	?GetAllModelIDs@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 25 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllModelIDs(unsigned short)
+	?GetAllPronunciationIDs@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 26 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllPronunciationIDs(unsigned short)
+	?GetAllRuleIDs@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 27 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllRuleIDs(unsigned short)
+	?GetEngineProperties@RSISpeechRecognitionCustomCommands@@QAEHABV?$RArray@H@@AAV2@@Z @ 28 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetEngineProperties(class RArray<int> const &,class RArray<int> &)
+	?GetGrammarIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 29 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetGrammarIDArrayL(class RArray<unsigned short> &)
+	?GetLexiconIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 30 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL(class RArray<unsigned short> &)
+	?GetModelBankIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 31 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetModelBankIDArrayL(class RArray<unsigned short> &)
+	?GetModelCount@RSISpeechRecognitionCustomCommands@@QAEHGAAH@Z @ 32 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetModelCount(unsigned short,int &)
+	?GetModelIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 33 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetModelIDArrayL(class RArray<unsigned short> &)
+	?GetPronunciationIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@K@@@Z @ 34 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetPronunciationIDArrayL(class RArray<unsigned long> &)
+	?GetRuleIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@K@@@Z @ 35 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetRuleIDArrayL(class RArray<unsigned long> &)
+	?GetRuleValidity@RSISpeechRecognitionCustomCommands@@QAEHGKAAH@Z @ 36 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetRuleValidity(unsigned short,unsigned long,int &)
+	?GetSIResultSetL@RSISpeechRecognitionCustomCommands@@QAEXAAVCSIClientResultSet@@@Z @ 37 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetSIResultSetL(class CSIClientResultSet &)
+	?LoadEngineParameters@RSISpeechRecognitionCustomCommands@@QAEHABV?$RArray@H@@0@Z @ 38 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadEngineParameters(class RArray<int> const &,class RArray<int> const &)
+	?LoadGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 39 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadGrammar(unsigned short)
+	?LoadLexicon@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 40 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadLexicon(unsigned short)
+	?LoadModels@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 41 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadModels(unsigned short)
+	?NewL@CSISpeechRecognitionCustomCommandParser@@SAPAV1@AAVMSISpeechRecognitionCustomCommandImplementor@@@Z @ 42 NONAME ; public: static class CSISpeechRecognitionCustomCommandParser * __cdecl CSISpeechRecognitionCustomCommandParser::NewL(class MSISpeechRecognitionCustomCommandImplementor &)
+	?Recognize@RSISpeechRecognitionCustomCommands@@QAEHAAVCSIClientResultSet@@@Z @ 43 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::Recognize(class CSIClientResultSet &)
+	?Record@RSISpeechRecognitionCustomCommands@@QAEHVTTimeIntervalMicroSeconds32@@@Z @ 44 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::Record(class TTimeIntervalMicroSeconds32)
+	?RemoveGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 45 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveGrammar(unsigned short)
+	?RemoveLexicon@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 46 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveLexicon(unsigned short)
+	?RemoveModel@RSISpeechRecognitionCustomCommands@@QAEHGG@Z @ 47 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveModel(unsigned short,unsigned short)
+	?RemoveModelBank@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 48 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveModelBank(unsigned short)
+	?RemovePronunciation@RSISpeechRecognitionCustomCommands@@QAEHGK@Z @ 49 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemovePronunciation(unsigned short,unsigned long)
+	?RemoveRule@RSISpeechRecognitionCustomCommands@@QAEHGK@Z @ 50 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveRule(unsigned short,unsigned long)
+	?RemoveRules@RSISpeechRecognitionCustomCommands@@QAEHGAAV?$RArray@K@@@Z @ 51 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveRules(unsigned short,class RArray<unsigned long> &)
+	?SetClientUid@RSISpeechRecognitionCustomCommands@@QAEHVTUid@@@Z @ 52 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::SetClientUid(class TUid)
+	?StartRecSession@RSISpeechRecognitionCustomCommands@@QAEHW4TNSSRecognitionMode@@@Z @ 53 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::StartRecSession(enum TNSSRecognitionMode)
+	?UnloadGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 54 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::UnloadGrammar(unsigned short)
+	?UnloadRule@RSISpeechRecognitionCustomCommands@@QAEHGK@Z @ 55 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::UnloadRule(unsigned short,unsigned long)
+	?AddVoiceTag@RSISpeechRecognitionCustomCommands@@QAEHABVMDesC16Array@@ABV?$RArray@V?$RArray@W4TLanguage@@@@@@GGAAK@Z @ 56 NONAME ; int RSISpeechRecognitionCustomCommands::AddVoiceTag(class MDesC16Array const &, class RArray<class RArray<enum TLanguage> > const &, unsigned short, unsigned short, unsigned long &)
+	?AddVoiceTags@RSISpeechRecognitionCustomCommands@@QAEHABV?$RPointerArray@VMDesC16Array@@@@ABV?$RArray@V?$RArray@W4TLanguage@@@@@@GGAAV?$RArray@K@@@Z @ 57 NONAME ; int RSISpeechRecognitionCustomCommands::AddVoiceTags(class RPointerArray<class MDesC16Array> const &, class RArray<class RArray<enum TLanguage> > const &, unsigned short, unsigned short, class RArray<unsigned long> &)
+	?PreStartSampling@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 58 NONAME ; int RSISpeechRecognitionCustomCommands::PreStartSampling(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/bwins/nsssispeechrecognitioncustomcommandsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,57 @@
+EXPORTS
+	??0RSISpeechRecognitionCustomCommands@@QAE@AAVRMMFController@@@Z @ 1 NONAME ; public: __thiscall RSISpeechRecognitionCustomCommands::RSISpeechRecognitionCustomCommands(class RMMFController &)
+	??1CSISpeechRecognitionCustomCommandParser@@UAE@XZ @ 2 NONAME ; public: virtual __thiscall CSISpeechRecognitionCustomCommandParser::~CSISpeechRecognitionCustomCommandParser(void)
+	?ActivateGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 3 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::ActivateGrammar(unsigned short)
+	?Adapt@RSISpeechRecognitionCustomCommands@@QAEHABVCSIClientResultSet@@H@Z @ 4 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::Adapt(class CSIClientResultSet const &,int)
+	?AddPronunciation@RSISpeechRecognitionCustomCommands@@QAEHGABVTDesC16@@W4TLanguage@@AAK@Z @ 5 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddPronunciation(unsigned short,class TDesC16 const &,enum TLanguage,unsigned long &)
+	?AddRule@RSISpeechRecognitionCustomCommands@@QAEHGGKAAK@Z @ 6 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddRule(unsigned short,unsigned short,unsigned long,unsigned long &)
+	?AddRuleVariant@RSISpeechRecognitionCustomCommands@@QAEHGGABV?$RArray@K@@KAAE@Z @ 7 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddRuleVariant(unsigned short,unsigned short,class RArray<unsigned long> const &,unsigned long,unsigned char &)
+	?AddVoiceTag@RSISpeechRecognitionCustomCommands@@QAEHABVMDesC16Array@@ABV?$RArray@W4TLanguage@@@@GGAAK@Z @ 8 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddVoiceTag(class MDesC16Array const &,class RArray<enum TLanguage> const &,unsigned short,unsigned short,unsigned long &)
+	?AddVoiceTags@RSISpeechRecognitionCustomCommands@@QAEHABV?$RPointerArray@VMDesC16Array@@@@ABV?$RArray@W4TLanguage@@@@GGAAV?$RArray@K@@@Z @ 9 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::AddVoiceTags(class RPointerArray<class MDesC16Array> const &,class RArray<enum TLanguage> const &,unsigned short,unsigned short,class RArray<unsigned long> &)
+	?Cancel@RSISpeechRecognitionCustomCommands@@QAEXXZ @ 10 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::Cancel(void)
+	?CommitChanges@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 11 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CommitChanges(void)
+	?CreateGrammar@RSISpeechRecognitionCustomCommands@@QAEHAAG@Z @ 12 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateGrammar(unsigned short &)
+	?CreateLexicon@RSISpeechRecognitionCustomCommands@@QAEHAAG@Z @ 13 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateLexicon(unsigned short &)
+	?CreateModelBank@RSISpeechRecognitionCustomCommands@@QAEHAAG@Z @ 14 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateModelBank(unsigned short &)
+	?CreateRule@RSISpeechRecognitionCustomCommands@@QAEHGAAK@Z @ 15 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::CreateRule(unsigned short,unsigned long &)
+	?DeactivateGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 16 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::DeactivateGrammar(unsigned short)
+	?EndRecSession@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 17 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::EndRecSession(void)
+	?EndRecord@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 18 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::EndRecord(void)
+	?GetAllClientGrammarIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 19 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllClientGrammarIDs(void)
+	?GetAllClientLexiconIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 20 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllClientLexiconIDs(void)
+	?GetAllClientModelBankIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 21 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllClientModelBankIDs(void)
+	?GetAllGrammarIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 22 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllGrammarIDs(void)
+	?GetAllLexiconIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 23 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllLexiconIDs(void)
+	?GetAllModelBankIDs@RSISpeechRecognitionCustomCommands@@QAEHXZ @ 24 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllModelBankIDs(void)
+	?GetAllModelIDs@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 25 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllModelIDs(unsigned short)
+	?GetAllPronunciationIDs@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 26 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllPronunciationIDs(unsigned short)
+	?GetAllRuleIDs@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 27 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetAllRuleIDs(unsigned short)
+	?GetEngineProperties@RSISpeechRecognitionCustomCommands@@QAEHABV?$RArray@H@@AAV2@@Z @ 28 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetEngineProperties(class RArray<int> const &,class RArray<int> &)
+	?GetGrammarIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 29 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetGrammarIDArrayL(class RArray<unsigned short> &)
+	?GetLexiconIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 30 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL(class RArray<unsigned short> &)
+	?GetModelBankIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 31 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetModelBankIDArrayL(class RArray<unsigned short> &)
+	?GetModelCount@RSISpeechRecognitionCustomCommands@@QAEHGAAH@Z @ 32 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetModelCount(unsigned short,int &)
+	?GetModelIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@G@@@Z @ 33 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetModelIDArrayL(class RArray<unsigned short> &)
+	?GetPronunciationIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@K@@@Z @ 34 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetPronunciationIDArrayL(class RArray<unsigned long> &)
+	?GetRuleIDArrayL@RSISpeechRecognitionCustomCommands@@QAEXAAV?$RArray@K@@@Z @ 35 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetRuleIDArrayL(class RArray<unsigned long> &)
+	?GetRuleValidity@RSISpeechRecognitionCustomCommands@@QAEHGKAAH@Z @ 36 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::GetRuleValidity(unsigned short,unsigned long,int &)
+	?GetSIResultSetL@RSISpeechRecognitionCustomCommands@@QAEXAAVCSIClientResultSet@@@Z @ 37 NONAME ; public: void __thiscall RSISpeechRecognitionCustomCommands::GetSIResultSetL(class CSIClientResultSet &)
+	?LoadEngineParameters@RSISpeechRecognitionCustomCommands@@QAEHABV?$RArray@H@@0@Z @ 38 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadEngineParameters(class RArray<int> const &,class RArray<int> const &)
+	?LoadGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 39 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadGrammar(unsigned short)
+	?LoadLexicon@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 40 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadLexicon(unsigned short)
+	?LoadModels@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 41 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::LoadModels(unsigned short)
+	?NewL@CSISpeechRecognitionCustomCommandParser@@SAPAV1@AAVMSISpeechRecognitionCustomCommandImplementor@@@Z @ 42 NONAME ; public: static class CSISpeechRecognitionCustomCommandParser * __cdecl CSISpeechRecognitionCustomCommandParser::NewL(class MSISpeechRecognitionCustomCommandImplementor &)
+	?Recognize@RSISpeechRecognitionCustomCommands@@QAEHAAVCSIClientResultSet@@@Z @ 43 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::Recognize(class CSIClientResultSet &)
+	?Record@RSISpeechRecognitionCustomCommands@@QAEHVTTimeIntervalMicroSeconds32@@@Z @ 44 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::Record(class TTimeIntervalMicroSeconds32)
+	?RemoveGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 45 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveGrammar(unsigned short)
+	?RemoveLexicon@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 46 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveLexicon(unsigned short)
+	?RemoveModel@RSISpeechRecognitionCustomCommands@@QAEHGG@Z @ 47 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveModel(unsigned short,unsigned short)
+	?RemoveModelBank@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 48 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveModelBank(unsigned short)
+	?RemovePronunciation@RSISpeechRecognitionCustomCommands@@QAEHGK@Z @ 49 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemovePronunciation(unsigned short,unsigned long)
+	?RemoveRule@RSISpeechRecognitionCustomCommands@@QAEHGK@Z @ 50 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveRule(unsigned short,unsigned long)
+	?RemoveRules@RSISpeechRecognitionCustomCommands@@QAEHGAAV?$RArray@K@@@Z @ 51 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::RemoveRules(unsigned short,class RArray<unsigned long> &)
+	?SetClientUid@RSISpeechRecognitionCustomCommands@@QAEHVTUid@@@Z @ 52 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::SetClientUid(class TUid)
+	?StartRecSession@RSISpeechRecognitionCustomCommands@@QAEHW4TNSSRecognitionMode@@@Z @ 53 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::StartRecSession(enum TNSSRecognitionMode)
+	?UnloadGrammar@RSISpeechRecognitionCustomCommands@@QAEHG@Z @ 54 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::UnloadGrammar(unsigned short)
+	?UnloadRule@RSISpeechRecognitionCustomCommands@@QAEHGK@Z @ 55 NONAME ; public: int __thiscall RSISpeechRecognitionCustomCommands::UnloadRule(unsigned short,unsigned long)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/eabi/nsssispeechrecognitioncustomcommands_sindeu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,65 @@
+EXPORTS
+	_ZN34RSISpeechRecognitionCustomCommands10CreateRuleEtRm @ 1 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands10LoadModelsEt @ 2 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands10RemoveRuleEtm @ 3 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands10UnloadRuleEtm @ 4 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11AddVoiceTagERK12MDesC16ArrayRK6RArrayI9TLanguageEttRm @ 5 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11LoadGrammarEt @ 6 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11LoadLexiconEt @ 7 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11RemoveModelEtt @ 8 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11RemoveRulesEtR6RArrayImE @ 9 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayI9TLanguageEttRS5_ImE @ 10 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands12SetClientUidE4TUid @ 11 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13CommitChangesEv @ 12 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13CreateGrammarERt @ 13 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13CreateLexiconERt @ 14 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13EndRecSessionEv @ 15 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13GetAllRuleIDsEt @ 16 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13GetModelCountEtRi @ 17 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13RemoveGrammarEt @ 18 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13RemoveLexiconEt @ 19 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13UnloadGrammarEt @ 20 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands14AddRuleVariantEttRK6RArrayImEmRh @ 21 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands14GetAllModelIDsEt @ 22 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15ActivateGrammarEt @ 23 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15CreateModelBankERt @ 24 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15GetRuleIDArrayLER6RArrayImE @ 25 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15GetRuleValidityEtmRi @ 26 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15GetSIResultSetLER18CSIClientResultSet @ 27 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15RemoveModelBankEt @ 28 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15StartRecSessionE19TNSSRecognitionMode @ 29 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16AddPronunciationEtRK7TDesC169TLanguageRm @ 30 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16GetAllGrammarIDsEv @ 31 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16GetAllLexiconIDsEv @ 32 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16GetModelIDArrayLER6RArrayItE @ 33 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands17DeactivateGrammarEt @ 34 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands18GetAllModelBankIDsEv @ 35 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands18GetGrammarIDArrayLER6RArrayItE @ 36 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands18GetLexiconIDArrayLER6RArrayItE @ 37 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands19GetEnginePropertiesERK6RArrayIiERS1_ @ 38 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands19RemovePronunciationEtm @ 39 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands20GetModelBankIDArrayLER6RArrayItE @ 40 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands20LoadEngineParametersERK6RArrayIiES3_ @ 41 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands22GetAllClientGrammarIDsEv @ 42 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands22GetAllClientLexiconIDsEv @ 43 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands22GetAllPronunciationIDsEt @ 44 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands24GetAllClientModelBankIDsEv @ 45 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands24GetPronunciationIDArrayLER6RArrayImE @ 46 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands5AdaptERK18CSIClientResultSeti @ 47 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands6CancelEv @ 48 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands6RecordE27TTimeIntervalMicroSeconds32 @ 49 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands7AddRuleEttmRm @ 50 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands9EndRecordEv @ 51 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands9RecognizeER18CSIClientResultSet @ 52 NONAME
+	_ZN34RSISpeechRecognitionCustomCommandsC1ER14RMMFController @ 53 NONAME
+	_ZN34RSISpeechRecognitionCustomCommandsC2ER14RMMFController @ 54 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParser4NewLER44MSISpeechRecognitionCustomCommandImplementor @ 55 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParserD0Ev @ 56 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParserD1Ev @ 57 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParserD2Ev @ 58 NONAME
+	_ZTI39CSISpeechRecognitionCustomCommandParser @ 59 NONAME ; #<TI>#
+	_ZTV39CSISpeechRecognitionCustomCommandParser @ 60 NONAME ; #<VT>#
+	_ZN34RSISpeechRecognitionCustomCommands11AddVoiceTagERK12MDesC16ArrayRK6RArrayIS3_I9TLanguageEEttRm @ 61 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayIS5_I9TLanguageEEttRS5_ImE @ 62 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16PreStartSamplingEv @ 63 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/eabi/nsssispeechrecognitioncustomcommandsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,62 @@
+EXPORTS
+	_ZN34RSISpeechRecognitionCustomCommands10CreateRuleEtRm @ 1 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands10LoadModelsEt @ 2 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands10RemoveRuleEtm @ 3 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands10UnloadRuleEtm @ 4 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11AddVoiceTagERK12MDesC16ArrayRK6RArrayI9TLanguageEttRm @ 5 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11LoadGrammarEt @ 6 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11LoadLexiconEt @ 7 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11RemoveModelEtt @ 8 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands11RemoveRulesEtR6RArrayImE @ 9 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayI9TLanguageEttRS5_ImE @ 10 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands12SetClientUidE4TUid @ 11 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13CommitChangesEv @ 12 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13CreateGrammarERt @ 13 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13CreateLexiconERt @ 14 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13EndRecSessionEv @ 15 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13GetAllRuleIDsEt @ 16 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13GetModelCountEtRi @ 17 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13RemoveGrammarEt @ 18 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13RemoveLexiconEt @ 19 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands13UnloadGrammarEt @ 20 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands14AddRuleVariantEttRK6RArrayImEmRh @ 21 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands14GetAllModelIDsEt @ 22 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15ActivateGrammarEt @ 23 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15CreateModelBankERt @ 24 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15GetRuleIDArrayLER6RArrayImE @ 25 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15GetRuleValidityEtmRi @ 26 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15GetSIResultSetLER18CSIClientResultSet @ 27 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15RemoveModelBankEt @ 28 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands15StartRecSessionE19TNSSRecognitionMode @ 29 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16AddPronunciationEtRK7TDesC169TLanguageRm @ 30 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16GetAllGrammarIDsEv @ 31 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16GetAllLexiconIDsEv @ 32 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands16GetModelIDArrayLER6RArrayItE @ 33 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands17DeactivateGrammarEt @ 34 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands18GetAllModelBankIDsEv @ 35 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands18GetGrammarIDArrayLER6RArrayItE @ 36 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands18GetLexiconIDArrayLER6RArrayItE @ 37 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands19GetEnginePropertiesERK6RArrayIiERS1_ @ 38 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands19RemovePronunciationEtm @ 39 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands20GetModelBankIDArrayLER6RArrayItE @ 40 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands20LoadEngineParametersERK6RArrayIiES3_ @ 41 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands22GetAllClientGrammarIDsEv @ 42 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands22GetAllClientLexiconIDsEv @ 43 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands22GetAllPronunciationIDsEt @ 44 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands24GetAllClientModelBankIDsEv @ 45 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands24GetPronunciationIDArrayLER6RArrayImE @ 46 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands5AdaptERK18CSIClientResultSeti @ 47 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands6CancelEv @ 48 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands6RecordE27TTimeIntervalMicroSeconds32 @ 49 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands7AddRuleEttmRm @ 50 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands9EndRecordEv @ 51 NONAME
+	_ZN34RSISpeechRecognitionCustomCommands9RecognizeER18CSIClientResultSet @ 52 NONAME
+	_ZN34RSISpeechRecognitionCustomCommandsC1ER14RMMFController @ 53 NONAME
+	_ZN34RSISpeechRecognitionCustomCommandsC2ER14RMMFController @ 54 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParser4NewLER44MSISpeechRecognitionCustomCommandImplementor @ 55 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParserD0Ev @ 56 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParserD1Ev @ 57 NONAME
+	_ZN39CSISpeechRecognitionCustomCommandParserD2Ev @ 58 NONAME
+	_ZTI39CSISpeechRecognitionCustomCommandParser @ 59 NONAME ; #<TI>#
+	_ZTV39CSISpeechRecognitionCustomCommandParser @ 60 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the bld.inf file which is required by Symbian OS
+*               as part of the standard build procedure.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nsssispeechrecognitioncustomcommands.mmp
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/group/nsssispeechrecognitioncustomcommands.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for NssSiSpeechRecognitionCustomCommands
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include          "../../group/srsfbldvariant.hrh"
+
+TARGET            nsssispeechrecognitioncustomcommands.dll
+TARGETTYPE        DLL
+UID               0x1000008d 0x101F92C
+
+VENDORID          VID_DEFAULT
+
+CAPABILITY        CAP_GENERAL_DLL
+
+#ifdef __SINDE_TRAINING
+#if defined(WINS)
+DEFFILE         ../bwins/nsssispeechrecognitioncustomcommands_sinde.def
+#elif defined(ARMCC)
+DEFFILE         ../eabi/nsssispeechrecognitioncustomcommands_sinde.def
+#else
+DEFFILE         ../bmarm/nsssispeechrecognitioncustomcommands_sinde.def
+#endif
+#endif // __SINDE_TRAINING
+
+SOURCEPATH        ../src
+SOURCE            nsssispeechrecognitioncustomcommands.cpp
+SOURCE            nsssispeechrecognitioncustomcommandparser.cpp
+SOURCE            nsssicustomcommanddata.cpp
+
+USERINCLUDE       ../inc ../src
+USERINCLUDE       ../../group  // for srsfbldvariant.hrh
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE     /epoc32/include/mmf/common
+
+USERINCLUDE       ../../rubydebug
+
+LIBRARY           euser.lib
+LIBRARY           mmfcontrollerframework.lib
+LIBRARY           estor.lib
+LIBRARY           bafl.lib
+LIBRARY           nsssispeechrecognitiondata.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/src/nsssicustomcommanddata.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,320 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Private serialization functions for Custom Commands
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32mem.h>
+#include "nsssicustomcommanddata.h"
+#include "rubydebug.h"
+
+// LOCAL FUNCTION PROTOTYPES
+void CleanupForPointerArrays( TAny* anArray );
+void CleanupResetAndDestroyAndDeletePushL( RPointerArray<MDesCArray>* anArray );
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CleanupForPointerArrays
+//
+// Cleanup function for RPointerArray, which calls ResetAndDestroy()
+// before deleting.
+//
+// Returns: None
+// -----------------------------------------------------------------------------
+//
+void CleanupForPointerArrays(
+    TAny* anArray) // Pointer to RPointerArray<MDesCArray>
+    {
+    RPointerArray<MDesCArray> *array = (RPointerArray<MDesCArray> *)anArray;
+    array->ResetAndDestroy();
+    delete array;
+    }
+
+// -----------------------------------------------------------------------------
+// CleanupResetAndDestroyAndDeletePushL
+//
+// Pushes the RPointerArray to the cleanup stack, so that
+// both the container and its contents are deleted in case of a leave.
+//
+// Returns: None
+// -----------------------------------------------------------------------------
+//
+void CleanupResetAndDestroyAndDeletePushL(
+    RPointerArray<MDesCArray> *anArray) // Array to be destroyed and deleted
+    {
+    TCleanupItem cleanupItem( CleanupForPointerArrays, (TAny *)anArray );
+    CleanupStack::PushL( cleanupItem );
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSpeakerIndependentCustomCommandParser::ExternalizeDesCArrayL
+// Externalizes a string array.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//	
+CBufFlat* SICustomCommandData::ExternalizeDesCArrayL(
+	const MDesCArray& aArray)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+
+    // Write the number of strings
+	stream.WriteInt32L(aArray.MdcaCount());
+
+    // Write strings: First string length, then the characters
+    for( TInt k = 0; k < aArray.MdcaCount(); k++ )
+        {
+        TPtrC text( aArray.MdcaPoint( k ) );
+
+        stream.WriteInt32L( text.Length() );
+
+        if ( text.Length() > 0 )
+            {
+            stream.WriteL( text );
+            }
+        }
+
+	CleanupStack::PopAndDestroy(1); //stream
+	CleanupStack::Pop(); //dataCopyBuffer;
+	return dataCopyBuffer;	
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeakerIndependentCustomCommandParser::InternalizeDesCArrayL
+// Internalizes a string array.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//	
+MDesCArray *SICustomCommandData::InternalizeDesCArrayL(
+	const TDesC8& aBuffer)
+	{
+	CDesCArrayFlat* phraseArray = new CDesCArrayFlat(KExpandSize);
+	CleanupStack::PushL(phraseArray);
+
+	RDesReadStream stream;
+	stream.Open(aBuffer);
+	CleanupClosePushL(stream);
+
+	TInt count = stream.ReadInt32L();
+
+    TInt   phraseBufLength = KDefaultPhraseLen;
+    HBufC *phraseBuf = HBufC::NewLC( phraseBufLength );
+    TPtr   phrase    = phraseBuf->Des();
+
+    for( TInt k = 0; k < count; k++ )
+        {
+        TInt length = stream.ReadInt32L();
+
+        if ( length > phraseBufLength )
+            {
+            CleanupStack::PopAndDestroy( phraseBuf );
+            phraseBuf = HBufC::NewLC( length );
+            phraseBufLength = length;
+            phrase.Set( phraseBuf->Des() );
+            }
+
+        stream.ReadL( phrase, length );
+        phraseArray->AppendL( phrase );
+        phrase.Zero();
+        }
+
+	CleanupStack::PopAndDestroy(2); //phraseBuf, stream
+	CleanupStack::Pop(phraseArray); //phraseArray;
+	return phraseArray;	
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeakerIndependentCustomCommandParser::ExternalizeDesCArrayArrayL
+// Externalizes an array of string arrays.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//	
+CBufFlat* SICustomCommandData::ExternalizeDesCArrayArrayL(
+	const RPointerArray<MDesCArray>& aArrayArray)
+	{
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+
+    stream.WriteInt32L(aArrayArray.Count());
+
+    for( TInt arrayK = 0; arrayK < aArrayArray.Count(); arrayK++ )
+        {
+        const MDesCArray& aArray = *aArrayArray[ arrayK ];
+        // Write the number of strings
+	    stream.WriteInt32L(aArray.MdcaCount());
+
+        // Write strings: First string length, then the characters
+        for( TInt k = 0; k < aArray.MdcaCount(); k++ )
+            {
+            TPtrC text( aArray.MdcaPoint( k ) );
+
+            stream.WriteInt32L( text.Length() );
+
+            if ( text.Length() > 0 )
+                {
+                stream.WriteL( text );
+                }
+            }
+        }
+
+	CleanupStack::PopAndDestroy(1); //stream
+	CleanupStack::Pop(); //dataCopyBuffer;
+	return dataCopyBuffer;	
+	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSpeakerIndependentCustomCommandParser::InternalizeDesCArrayArrayL
+// Internalizes an array of string arrays array.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RPointerArray<MDesCArray> *SICustomCommandData::InternalizeDesCArrayArrayL(
+	const TDesC8& aBuffer)
+	{
+    RPointerArray<MDesCArray>* phraseArrayArray = new (ELeave) RPointerArray<MDesCArray>(KExpandSize);
+    CleanupResetAndDestroyAndDeletePushL(phraseArrayArray);
+
+	RDesReadStream stream;
+	stream.Open(aBuffer);
+	CleanupClosePushL(stream);
+
+	TInt arrayCount = stream.ReadInt32L();
+
+    TInt   phraseBufLength = KDefaultPhraseLen;
+    HBufC *phraseBuf = HBufC::NewL( phraseBufLength );
+    TPtr   phrase    = phraseBuf->Des();
+    CleanupStack::PushL( phraseBuf );
+
+    for( TInt arrayK = 0; arrayK < arrayCount; arrayK++ )
+        {
+        
+	    TInt count = stream.ReadInt32L();
+
+    	CDesCArrayFlat* phraseArray = new CDesCArrayFlat(KExpandSize);
+        CleanupStack::PushL( phraseArray );
+
+        for( TInt k = 0; k < count; k++ )
+            {
+            TInt length = stream.ReadInt32L();
+
+            if ( length > phraseBufLength )
+                {
+                HBufC* newPhraseBuf = HBufC::NewL( length );
+
+                CleanupStack::Pop( phraseArray );
+                CleanupStack::PopAndDestroy( phraseBuf );
+
+                phraseBuf = newPhraseBuf;
+                phraseBufLength = length;
+                phrase.Set( phraseBuf->Des() );
+
+                CleanupStack::PushL( phraseBuf );
+                CleanupStack::PushL( phraseArray );
+                }
+
+            stream.ReadL( phrase, length );
+            phraseArray->AppendL( phrase );
+            phrase.Zero();
+            }
+
+        User::LeaveIfError( phraseArrayArray->Append( phraseArray ) );
+        CleanupStack::Pop( phraseArray );
+        }
+
+	CleanupStack::PopAndDestroy(2); //phraseBuf, stream
+	CleanupStack::Pop(1); //phraseArrayArray
+	return phraseArrayArray;	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSpeakerIndependentCustomCommandParser::InternalizeDesCArrayArrayL
+// Internalizes an array of string arrays array.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* SICustomCommandData::ReadMessageDataLC( TMMFMessage& aMessage, TInt aSlot )
+    {
+    // MMF messages have 2 slots
+    if ( aSlot != 1 && aSlot != 2 )
+    	{
+        RUBY_DEBUG0( "SICustomCommandData::ReadMessageDataLC Leaving with KErrArgument" );
+    	User::Leave( KErrArgument );
+    	}
+        
+
+    TInt size = 0;
+
+    if ( aSlot == 1 )
+        {
+        size = aMessage.SizeOfData1FromClient();
+        }
+    else
+        {
+        size = aMessage.SizeOfData2FromClient();
+        }
+
+    HBufC8* data = HBufC8::NewLC( size );
+    TPtr8 ptr = data->Des();
+
+    if ( aSlot == 1 )
+        {
+        aMessage.ReadData1FromClientL( ptr );
+        }
+    else{
+        aMessage.ReadData2FromClientL( ptr );
+        }
+
+    return( data );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSpeakerIndependentCustomCommandParser::InternalizePronunArrayL
+// Internalizes an array of string arrays array.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void SICustomCommandData::InternalizePronunArrayL(
+    const TDesC8& aData,
+    TInt aCount,
+    RArray<TSIPronunciationID>& aArray )
+    {
+    const TSIPronunciationID* pronunPtr = (const TSIPronunciationID*)aData.Ptr();
+
+    for ( TInt k = 0; k < aCount; k++ )
+        {
+        User::LeaveIfError( aArray.Append( *pronunPtr ) );
+        pronunPtr++;
+        }
+    }
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/src/nsssicustomcommanddata.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Some data serialization functions for Custom Commands
+*
+*/
+
+
+
+#ifndef SICUSTOMCOMMANDDATA_H
+#define SICUSTOMCOMMANDDATA_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <badesca.h>
+#include <nsssispeechrecognitiondataclient.h>
+#include <mmfcontrollerframework.h>
+#include "nsssispeechrecognitioncustomcommandcommon.h"
+
+
+/**
+*  Static functions to internalize and externalize some data types.
+*
+*  @lib nsssispeechrecognitioncustomcommands.lib
+*  @since 2.8
+*/
+class SICustomCommandData // Static classes don't have Symbian prefix
+    {
+    public: // New functions
+        
+ 		/**
+		*	Internalize a string array.
+        * @since	2.8
+        * @param	aBuffer             Buffer to be internalized
+        * @return	Internalized string array
+        */
+        static MDesCArray* InternalizeDesCArrayL(const TDesC8& aBuffer);
+
+		/**
+		*	Externalize a string array.
+        * @since	2.8
+        * @param    aArray              Array to be externalized
+        * @return	The buffer containing the string array
+        */
+        static CBufFlat* ExternalizeDesCArrayL(const MDesCArray& aArray);
+
+		/**
+		*	Internalize a string array.
+        * @since	2.8
+        * @param    aBuffer              Buffer to be internalized
+        * @return	The array of string arrays
+        */
+        static RPointerArray<MDesCArray> *InternalizeDesCArrayArrayL(
+            const TDesC8& aBuffer);
+
+		/**
+		*	Externalize a string array.
+        * @since	2.8
+        * @param    aArray              Array of string arras to be externalized.
+        * @return	The buffer containing the array of string arrays.
+        */
+        static CBufFlat* ExternalizeDesCArrayArrayL(
+	        const RPointerArray<MDesCArray>& aArrayArray);
+
+		/**
+		*	Reads parameter data from TMMFMessage. TMMFMessage has 2 param slots.
+        * @since	2.8
+        * @param    aMessage The message to be read.
+        * @param    aSlot The parameter slot to be read. 1 or 2.
+        * @return	The data from slot X.
+        */
+        static HBufC8* ReadMessageDataLC( TMMFMessage& aMessage, TInt aSlot );
+
+		/**
+		*	Internalizes a pronunciatoin array.
+        * @since	2.8
+        * @param    aData The serialized buffer
+        * @param    aCount How many pronunciations was saved to aData.
+        * @param    aArray Array to be populated.
+        */
+        static void InternalizePronunArrayL(
+            const TDesC8& aData,
+            TInt aCount,
+            RArray<TSIPronunciationID>& aArray );
+   
+    };
+
+#endif // SICUSTOMCOMMANDDATA_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/src/nsssispeechrecognitioncustomcommandcommon.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,687 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the common header file for the speaker independent
+*			    controller. It is used by both the client & server side.
+*
+*/
+
+
+#ifndef NSSSISPEECHRECOGNITIONCUSTOMCOMMANDCOMMON_H
+#define NSSSISPEECHRECOGNITIONCUSTOMCOMMANDCOMMON_H
+
+// INCLUDE FILES
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitiondatacommon.h>
+
+// CONSTANTS
+// (8CA6 = UID for dependent recognition)
+const TUid KUidInterfaceSpeakerIndependent = {0x101F8CA7}; 
+
+const TInt KExpandSize = 5;
+
+// Initial assumption for buffer size. If the text is larger,
+// the buffer is expanded.
+const TInt KDefaultPhraseLen = 50;
+// Hard upper limit on number of languages.
+const TInt KMaxLanguages = 10;
+// Hard upper limit on number of "segments" in the voice tag text
+const TInt KMaxPartitionsInText = 5;
+
+// FORWARD DECLARATIONS
+class TSrsRecognize;
+class TSrsAddPronunciation;
+class TSrsAddRule;
+class TSrsRuleValidity;
+class TSrsGetUtteranceDuration;
+class TSrsGetUtteranceDuration;
+class TSrsPlayUtterance;
+class TSrsAddVoiceTag;
+class TSrsAddSindeVoiceTag;
+class TSrsAddRuleVariant;
+class TSrsAddPronunciationSI;
+
+// DATA TYPES
+
+// These are the custom commands messages used to communicate with
+// the server.
+enum TSrCustomCommandMessages
+{
+        ESrActivateGrammar,
+		ESrAddPronunciation,
+		ESrAddRule,
+		ESrCancel,
+		ESrCommitTrain,
+		ESrCreateGrammar,
+		ESrCreateLexicon,
+		ESrCreateModelBank,
+        ESrDeactivateGrammar,
+		ESrEndRecSession,
+		ESrGetAllModelIDs,
+		ESrGetAllPronunciationIDs,
+		ESrGetAllRuleIDs,
+		ESrGetAvailableStorage,
+		ESrGetEngineProperties,
+		ESrGetModelCount,
+		ESrGetRuleValidity,
+		ESrUtteranceDuration,
+		ESrLoadGrammar,
+		ESrLoadLexicon,
+		ESrLoadModels,
+		ESrPlayUtterance,
+		ESrRecognize,
+		ESrRecord,
+		ESrRemoveGrammar,
+		ESrRemoveLexicon,
+		ESrRemoveModelBank,
+		ESrRemoveModel,
+		ESrRemovePronunciation,
+		ESrRemoveRule,
+		ESrStartRecSession,
+		ESrTrain,
+		ESrUnloadRule,
+		ESrLoadEngineParameters,
+		ESrGetPronunciationIDArraySize,
+		ESrGetPronunciationIDArrayContents,
+		ESrGetRuleIDArraySize,
+		ESrGetRuleIDArrayContents,
+		ESrGetModelIDArraySize,
+		ESrGetModelIDArrayContents,
+		ESrGetClientResultSetSize,
+		ESrGetClientResultSet,
+		ESrSetClientUid,
+		ESrCommitChanges,
+		ESrGetAllClientGrammarIDs,
+		ESrGetAllClientLexiconIDs,
+		ESrGetAllClientModelBankIDs,
+		ESrGetAllGrammarIDs,
+		ESrGetAllLexiconIDs,
+		ESrGetAllModelBankIDs,
+		ESrGetGrammarIDArraySize,
+		ESrGetGrammarIDArrayContents,
+		ESrGetLexiconIDArraySize,
+		ESrGetLexiconIDArrayContents,
+		ESrGetModelBankIDArraySize,
+		ESrGetModelBankIDArrayContents
+// SI extensions
+        ,
+        ESrAdapt,
+        ESrAddPronunciationSI,
+        ESrAddRuleVariant,
+        ESrAddVoiceTag,
+        ESrAddVoiceTags,
+        ESrCreateRule,
+        ESrEndRecord,
+        ESrRecognizeSI,
+        ESrUnloadGrammar,
+        ESrGetClientResultSetSizeSI,
+		ESrRemoveRules,
+        ESrAddSindeVoiceTag,
+        ESrAddSindeVoiceTags,
+        ESrPreStartSampling
+};
+
+typedef TPckgBuf<TSrsRecognize> TSrsRecognizePckg;
+typedef TPckgBuf<TSrsAddPronunciation> TSrsAddPronunciationPckg;
+typedef TPckgBuf<TSrsAddRule> TSrsAddRulePckg;
+typedef TPckgBuf<TSrsRuleValidity> TSrsRuleValidityPckg;
+typedef TPckgBuf<TSrsGetUtteranceDuration> TSrsGetUtteranceDurationPckg;
+typedef TPckgBuf<TSrsPlayUtterance> TSrsPlayUtterancePckg;
+
+typedef TPckgBuf<TInt*> TSrsIntPtrPckg;
+typedef TPckgBuf<TNSSRecognitionMode> TSrsRecognitionModePckg;
+typedef TPckgBuf<TTimeIntervalMicroSeconds32> TSrsTimeIntervalMicroSeconds32Pckg;
+typedef TPckgBuf<TUid> TSrsUidPckg;
+
+typedef TPckgBuf<TSIGrammarID > TSrsGrammarIDPckg;
+typedef TPckgBuf<TSIGrammarID*> TSrsGrammarIDPtrPckg;
+typedef TPckgBuf<TSILexiconID> TSrsLexiconIDPckg;
+typedef TPckgBuf<TSILexiconID*> TSrsLexiconIDPtrPckg;
+typedef TPckgBuf<TSIModelID> TSrsModelIDPckg;
+typedef TPckgBuf<TSIModelID*> TSrsModelIDPtrPckg;
+typedef TPckgBuf<TSIModelBankID> TSrsModelBankIDPckg;
+typedef TPckgBuf<TSIModelBankID*> TSrsModelBankIDPtrPckg;
+typedef TPckgBuf<TSIPronunciationID> TSrsPronunciationIDPckg;
+typedef TPckgBuf<TSIRuleID> TSrsRuleIDPckg;
+typedef TPckgBuf<TSIRuleID*> TSrsRuleIDPtrPckg;
+
+typedef TPckgBuf<TSrsAddVoiceTag> TSrsAddVoiceTagPckg;
+typedef TPckgBuf<TSrsAddSindeVoiceTag> TSrsAddSindeVoiceTagPckg;
+typedef TPckgBuf<TSrsAddRuleVariant> TSrsAddRuleVariantPckg;
+typedef TPckgBuf<TSrsAddPronunciationSI> TSrsAddPronunciationSIPckg;
+
+// CLASS DECLARATION
+
+/**
+*  This is the TSrsRecognize class declaration.
+*
+*  @lib SpeechRecognitionCustomCommands.lib
+*  @since 2.0
+*/
+#if(0)
+class TSrsRecognize
+{
+public:
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	-
+    * @return	-
+    */
+	TSrsRecognize() {}
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	aClientResultSet	Pointer to client result set object.
+    * @return	-
+    */
+	TSrsRecognize(CSDClientResultSet* aClientResultSet) : 
+				iClientResultSet(aClientResultSet){}
+		
+	// member variable pointer to result set
+	CSDClientResultSet* iClientResultSet;
+
+};
+#endif
+/**
+*  This is the TSrsAddPronunciationSI class declaration.
+*
+*  @lib SpeechRecognitionCustomCommands.lib
+*  @since 2.0
+*/
+class TSrsAddPronunciation
+{
+public:
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	-
+    * @return	-
+    */
+	TSrsAddPronunciation() {}
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+	* @param	aLexiconID			lexicon ID
+	* @param	aModelBankID		model bank ID
+	* @param    aModelID			model ID
+	* @param	aPronunciationID	pronunciation ID 
+    * @return	-
+    */
+	TSrsAddPronunciation(TSILexiconID aLexiconID, TSIModelBankID aModelBankID,
+		TSIModelID aModelID, TSIPronunciationID* aPronunciationID) : 
+		iLexiconID(aLexiconID), iModelBankID(aModelBankID), 
+		iModelID(aModelID), iPronunciationID(aPronunciationID)
+	{}
+
+	// lexicon ID member variable 
+	TSILexiconID iLexiconID;
+	// model bank ID member variable 
+	TSIModelBankID iModelBankID;
+	// model ID member variable 
+	TSIModelID iModelID;
+	// pronunciation ID pointer member variable
+	TSIPronunciationID* iPronunciationID;
+};
+
+
+/**
+*  This is the TSrsAddRule class declaration.
+*
+*  @lib SpeechRecognitionCustomCommands.lib
+*  @since 2.0
+*/
+class TSrsAddRule
+{
+public:
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	-
+    * @return	-
+    */
+	TSrsAddRule() {}
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+	* @param	aGrammarID			grammar ID
+	* @param	aLexiconID			lexicon ID
+	* @param	aPronunciationID	pronunciation ID 
+	* @param	aRuleID				rule ID
+    * @return	-
+    */
+	TSrsAddRule(TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+		TSIPronunciationID aPronunciationID, TSIRuleID* aRuleID) : 
+		iGrammarID(aGrammarID), iLexiconID(aLexiconID), 
+		iPronunciationID(aPronunciationID), iRuleID(aRuleID) {}
+
+	// grammar ID member variable
+	TSIGrammarID iGrammarID;
+	// lexicon ID member variable
+	TSILexiconID iLexiconID;
+	// pronunciation ID member variable
+	TSIPronunciationID iPronunciationID;
+	// rule ID pointer member variable
+	TSIRuleID* iRuleID;
+
+};
+
+
+/**
+*  This is the TSrsRuleValidity class declaration.
+*
+*  @lib SpeechRecognitionCustomCommands.lib
+*  @since 2.0
+*/
+class TSrsRuleValidity
+{
+public:
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	-
+    * @return	-
+    */
+	TSrsRuleValidity() {}
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+	* @param	aGrammarID			grammar ID
+	* @param	aRuleID				rule ID
+	& @param	aRuldValid			indicates if the rule is valid
+    * @return	-
+    */
+	TSrsRuleValidity(TSIGrammarID aGrammarID, TSIRuleID aRuleID, TBool* aRuleValid) : 
+		iGrammarID(aGrammarID), iRuleID(aRuleID), iRuleValid(aRuleValid) {}
+
+	// grammar ID member variable
+	TSIGrammarID iGrammarID;
+	// rule ID pointer member variable
+	TSIRuleID iRuleID;
+	// rule valid member variable
+	TBool* iRuleValid; 
+};
+
+/**
+*  This is the TSrsGetUtteranceDuration class declaration.
+*
+*  @lib SpeechRecognitionCustomCommands.lib
+*  @since 2.0
+*/
+class TSrsGetUtteranceDuration
+{
+public:
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	-
+    * @return	-
+    */
+	TSrsGetUtteranceDuration() {}
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+	* @param	aModelBankID		model bank ID
+	* @param	aModelID			model ID
+    * @return	-
+    */
+	TSrsGetUtteranceDuration(TSIModelBankID aModelBankID, TSIModelID aModelID,
+		TTimeIntervalMicroSeconds32* aDuration) : 
+		 iModelBankID(aModelBankID), iModelID(aModelID),
+			iDuration(aDuration) {}
+
+	// model bank ID member variable
+	TSIModelBankID iModelBankID;
+	// model ID member variable
+	TSIModelID iModelID;
+	// utterance duration
+	TTimeIntervalMicroSeconds32* iDuration;
+};
+
+/**
+*  This is the TSrsPlayUtterance class declaration.
+*
+*  @lib SpeechRecognitionCustomCommands.lib
+*  @since 2.0
+*/
+class TSrsPlayUtterance
+{
+public:
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+    * @param	-
+    * @return	-
+    */
+	TSrsPlayUtterance() {}
+
+	/**
+	*	C++ constructor for this class.
+    * @since	2.0
+	* @param	aModelBankID		model bank ID
+	* @param	aModelID			model ID
+    * @return	-
+    */
+	TSrsPlayUtterance(TSIModelBankID aModelBankID, TSIModelID aModelID) : 
+		iModelBankID(aModelBankID), iModelID(aModelID) {}
+
+	// model bank ID member variable
+	TSIModelBankID iModelBankID;
+	// model ID member variable
+	TSIModelID iModelID;
+};
+
+/**
+*  This class is used to moves data required by AddPronunciation method
+*  over the MMF client-server barrier.
+*
+*  @lib SpekaerIndependentCustomCommands.lib
+*  @since 2.8
+*/
+class TSrsAddPronunciationSI
+    {
+    public:
+	/**
+	*	C++ constructor for this class.
+    * @since	2.8
+    * @param	-
+    * @return	-
+    */
+	TSrsAddPronunciationSI() {}
+
+    /**
+    * C++ constructor for this class.
+    * @since 2.8
+    * @param aLexiconID Lexicon identifier
+    * @param aTextLength Length of the text to be trained.
+    * @param aLanguage  Pronunciation language
+    * @param aPronunciation New pronunciation identifier
+    *                       will be assigned to this variable.
+    * @return -
+    */
+
+    TSrsAddPronunciationSI(
+        TSILexiconID aLexiconID,
+        TInt aTextLength,
+        TLanguage aLanguage,
+        TSIPronunciationID& aPronunciationID )
+        {
+        iLexiconID = aLexiconID;
+        iLanguage  = aLanguage;
+        iPronunciationIDPtr = &aPronunciationID;
+        iTextLength = aTextLength;
+        }
+
+    TSILexiconID iLexiconID;
+    TLanguage  iLanguage;
+    TInt iTextLength;
+    TSIPronunciationID *iPronunciationIDPtr;
+    };
+
+
+/**
+*  This class is used to moves data required by AddRuleVariant method
+*  over the MMF client-server barrier.
+*
+*  @lib SpekaerIndependentCustomCommands.lib
+*  @since 2.8
+*/
+class TSrsAddRuleVariant
+    {
+    public:
+	/**
+	*	C++ constructor for this class.
+    * @since	2.8
+    * @param	-
+    * @return	-
+    */
+	TSrsAddRuleVariant() {}
+
+    /**
+    * C++ constructor for this class.
+    * @since 2.8
+    * @param aLexiconID Lexicon identifier
+    * @param aTrainText Text to be trained. LESS THAN KMaxPhraseLen CHARACTERS.
+    * @param aLanguage  Pronunciation language
+    * @param aPronunciation New pronunciation identifier
+    *                       will be assigned to this variable.
+    * @return -
+    */
+
+    TSrsAddRuleVariant(
+        TSIGrammarID aGrammarID,
+        TSILexiconID aLexiconID,
+        TInt         aPronunIDCount,
+        TSIRuleID    aRuleID,
+        TSIRuleVariantID* aRuleVariantID
+        ) :
+        iGrammarID( aGrammarID ),
+        iLexiconID( aLexiconID ),
+        iPronunIDCount( aPronunIDCount ),
+        iRuleID( aRuleID ),
+        iRuleVariantID( aRuleVariantID )
+        {
+        // Nothing
+        }
+
+    TSIGrammarID      iGrammarID;
+    TSILexiconID      iLexiconID;
+    TInt              iPronunIDCount;
+    TSIRuleID         iRuleID;
+    TSIRuleVariantID* iRuleVariantID;
+    };
+
+/**
+*  This class is used to moves data required by AddVoiceTags method
+*  over the MMF client-server barrier.
+*
+*  @lib NssSpeakerIndependentCustomCommands.lib
+*  @since 2.8
+*/
+class TSrsAddVoiceTag
+    {
+    public:
+        /**
+        * C++ constructor for this class.
+        * @since 2.8
+        */
+        TSrsAddVoiceTag() {}
+        
+        /**
+        * C++ constructor for this class.
+        * @since 2.8
+        *
+        * @param aLexiconID Lexicon identifier
+        * @param aGrammarID Grammar identifier
+        * @param aRuleID
+        * @param aLanguageTable Pronunciation languages
+        */
+        TSrsAddVoiceTag( TSILexiconID aLexiconID,
+                         TSIGrammarID aGrammarID,
+                         TSIRuleID* aRuleID,
+                         const RArray<TLanguage>& aLanguageTable ) :
+                         iLexiconID( aLexiconID ),
+                         iGrammarID( aGrammarID ),
+                         iRuleID( aRuleID )
+            {
+            TInt languageCount = 0;
+            
+            if ( &aLanguageTable != NULL )
+                {
+                languageCount = aLanguageTable.Count();
+                }
+            
+            for ( TInt k = 0; k < KMaxLanguages; k++ )
+                {
+                if ( k < languageCount )
+                    {
+                    // If aLanguageTable == NULL, languageCount == 0 and
+                    // this is never called.
+                    iLanguages[ k ] = aLanguageTable[ k ];
+                    }
+                else
+                    {
+                    iLanguages[ k ] = ELangNone;
+                    }
+                }
+            }
+        
+        /**
+        * Returns a copy of language ids in RArray
+        *
+        * @since 2.8
+        * @param aLangArray Array which is filled
+        */
+        void ListLanguagesL( RArray<TLanguage>& aLangArray )
+            {
+            for ( TInt k = 0; iLanguages[ k ] != ELangNone; k++ )
+                {
+                User::LeaveIfError( aLangArray.Append( iLanguages[ k ] ) );
+                }
+            }
+        
+        TSILexiconID iLexiconID;
+        TSIGrammarID iGrammarID;
+        TSIRuleID* iRuleID;
+        TLanguage iLanguages[ KMaxLanguages ];
+    };
+
+/**
+*  This class is used to moves data required by AddSindeVoiceTags method
+*  over the MMF client-server barrier.
+*
+*  @lib NssSpeakerIndependentCustomCommands.lib
+*  @since 3.1
+*/
+class TSrsAddSindeVoiceTag
+    {
+    public:
+        /**
+        * C++ constructor
+        * @since 3.1
+        */
+        TSrsAddSindeVoiceTag() {}
+        
+        /**
+        * C++ constructor.
+        * Makes a copy LanguageArray.
+        *
+        * @since 3.1
+        * @param aLexiconID Lexicon identifier
+        * @param aGrammarID Grammar identifier
+        * @param aRuleID
+        * @param aLanguageTable Pronunciation languages
+        */
+        TSrsAddSindeVoiceTag( TSILexiconID aLexiconID,
+                              TSIGrammarID aGrammarID,
+                              TSIRuleID* aRuleID,
+                              const RArray<RLanguageArray>& aLanguageTable ) :
+                              iLexiconID( aLexiconID ),
+                              iGrammarID( aGrammarID ),
+                              iRuleID( aRuleID )
+            {
+            // Find out how many arrays there are inside the language array
+            TInt languageArrayCount = aLanguageTable.Count();
+            
+            for ( TInt partsInText = 0; partsInText < KMaxPartitionsInText; partsInText++ )
+                {
+                RLanguageArray languages;
+                TInt languageCount = 0;
+                if ( partsInText < languageArrayCount )
+                    {
+                    languages = aLanguageTable[ partsInText ];
+                    languageCount = languages.Count();
+                    }
+         
+                for ( TInt languageCounter = 0; languageCounter < KMaxLanguages; languageCounter++ )
+                    {
+                    if ( languageCounter < languageCount )
+                        {
+                        // Store real value
+                        iLanguages[ KMaxLanguages * partsInText + languageCounter ] = languages[ languageCounter ];
+                        iGrouping[ KMaxLanguages * partsInText + languageCounter ] = partsInText;
+                        }
+                    else
+                        {
+                        // Fill in ELangNone & KErrNotFound to empty spaces
+                        iLanguages[ KMaxLanguages * partsInText + languageCounter ] = ELangNone;
+                        iGrouping[ KMaxLanguages * partsInText + languageCounter ] = KErrNotFound;
+                        }
+                    }
+                }
+            }
+        
+        /**
+        * Returns a copy of language ids in RArray<RLanguageArray>
+        *
+        * @since 3.1
+        * @param aLangArray Array which is filled
+        */
+        void ListLanguagesL( RArray<RLanguageArray>& aLangArray )
+            {
+            aLangArray.Reset();
+            RLanguageArray langArr;
+            CleanupClosePushL( langArr );
+            TInt previousGroup( KErrNotFound );
+            for ( TInt k = 0; k < KMaxLanguages * KMaxPartitionsInText; k++ )
+                {
+                if ( iLanguages[k] != ELangNone )
+                    {
+                    if ( ( previousGroup != iGrouping[k] ) && ( previousGroup != KErrNotFound ) )
+                        {
+                        User::LeaveIfError( aLangArray.Append( langArr ) );
+                        // Ownership transferred
+                        CleanupStack::Pop( &langArr );
+                        // Create new array for next bunch of languages
+                        langArr = RLanguageArray();
+                        CleanupClosePushL( langArr );
+                        }
+                    User::LeaveIfError( langArr.Append( iLanguages[k] ) );
+                    previousGroup = iGrouping[k];
+                    }
+                } // for
+            // Append the last one if there just is something
+            if ( langArr.Count() > 0 )
+                {
+                User::LeaveIfError( aLangArray.Append( langArr ) );
+                }
+            CleanupStack::Pop( &langArr );
+            }
+        
+        // Lexicon ID
+        TSILexiconID iLexiconID;
+
+        // Grammar ID
+        TSIGrammarID iGrammarID;
+
+        // Rule ID pointer, used as a return value to client thread, not owned
+        TSIRuleID* iRuleID;
+
+    private:
+        // Linear array of language ids
+        TLanguage iLanguages[ KMaxLanguages * KMaxPartitionsInText ];
+
+        // Array which maps languages in iLanguages to groups
+        TInt iGrouping[ KMaxLanguages * KMaxPartitionsInText ];
+    };
+
+#endif	// NSSSISPEECHRECOGNITIONCUSTOMCOMMANDCOMMON_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/src/nsssispeechrecognitioncustomcommandparser.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1823 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the implementation of the server side for the
+*               speaker independent controller.
+*
+*/
+
+
+// INCLUDE FILES
+#include "srsfbldvariant.hrh"
+#include <e32std.h>
+#include <nsssispeechrecognitioncustomcommandparser.h>
+#include <nsssispeechrecognitioncustomcommands.h>
+#include "nsssispeechrecognitioncustomcommandcommon.h"
+#include "nsssicustomcommanddata.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::CSISpeechRecognitionCustomCommandParser
+// C++ constructor.
+// -----------------------------------------------------------------------------
+//
+CSISpeechRecognitionCustomCommandParser::CSISpeechRecognitionCustomCommandParser(
+	MSISpeechRecognitionCustomCommandImplementor& aImplementor) :
+	CMMFCustomCommandParserBase(KUidInterfaceSpeakerIndependent),
+	iImplementor(aImplementor),
+    iAdaptationSet( 0 )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::NewL
+// Two-phased constructor.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSISpeechRecognitionCustomCommandParser* 
+			CSISpeechRecognitionCustomCommandParser::NewL(
+	MSISpeechRecognitionCustomCommandImplementor& aImplementor)
+	{
+	return new(ELeave) CSISpeechRecognitionCustomCommandParser(aImplementor);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::~CSISpeechRecognitionCustomCommandParser
+// Destructor for CSISpeechRecognitionCustomCommandParser class
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSISpeechRecognitionCustomCommandParser::
+			~CSISpeechRecognitionCustomCommandParser()
+	{
+	
+	iPronunciationIDs.Close();
+	iRuleIDs.Close();
+	iModelIDs.Close();
+	iGrammarIDs.Close();
+	iLexiconIDs.Close();
+	iModelBankIDs.Close();
+    iLanguageArray.Close();
+    for ( TInt i = 0; i < iLanguageArrayArray.Count(); i++ )
+        {
+        iLanguageArrayArray[i].Close();
+        }
+    iLanguageArrayArray.Close();
+
+	delete iResultCopyBuffer;	
+	//delete iResultSet;
+    delete iSIResultSet;
+    delete iWordArray;
+    delete iAdaptationSet;
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::HandleRequest
+// Handles the client side request.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::HandleRequest(
+	TMMFMessage& aMessage)
+	{
+	ASSERT(aMessage.Destination().InterfaceId() == 
+						KUidInterfaceSpeakerIndependent);
+	TRAPD(error, DoHandleRequestL(aMessage));
+	if(error)
+		aMessage.Complete(error);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoHandleRequestL
+// Decodes aMessage and calls the correct function. This function is trapped by
+// HandleRequest() and the leave code, if any, sent to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoHandleRequestL(
+	TMMFMessage& aMessage)
+    {
+    TPckgBuf<TInt> pckgSize;
+    
+    // call required function to do the requested operation
+    switch( aMessage.Function() )
+        {
+        case ESrAddPronunciation:
+            DoAddPronunciationL(aMessage);
+            break;
+            
+        case ESrAddRule:
+            DoAddRuleL(aMessage);
+            break;
+            
+        case ESrCancel:
+            DoCancel();
+            break;
+            
+        case ESrCommitChanges:
+            DoCommitChangesL();
+            break;
+            
+        case ESrCreateGrammar:
+            DoCreateGrammarL(aMessage);
+            break;
+            
+        case ESrCreateLexicon:
+            DoCreateLexiconL(aMessage);
+            break;
+            
+        case ESrCreateModelBank:
+            DoCreateModelBankL(aMessage);
+            break;
+            
+        case ESrEndRecSession:
+            DoEndRecSessionL();
+            break;
+            
+        case ESrGetAllClientGrammarIDs:
+            DoGetAllClientGrammarIDsL();
+            break;
+            
+        case ESrGetAllClientLexiconIDs:
+            DoGetAllClientLexiconIDsL();
+            break;
+            
+        case ESrGetAllClientModelBankIDs:
+            DoGetAllClientModelBankIDsL();
+            break;
+            
+        case ESrGetAllGrammarIDs:
+            DoGetAllGrammarIDsL();
+            break;
+            
+        case ESrGetAllLexiconIDs:
+            DoGetAllLexiconIDsL();
+            break;
+            
+        case ESrGetAllModelBankIDs:
+            DoGetAllModelBankIDsL();
+            break;
+            
+        case ESrGetAllModelIDs:
+            DoGetAllModelIDsL(aMessage);
+            break;
+            
+        case ESrGetAllPronunciationIDs:
+            DoGetAllPronunciationIDsL(aMessage);
+            break;
+            
+        case ESrGetAllRuleIDs:
+            DoGetAllRuleIDsL(aMessage);
+            break;
+            
+        case ESrGetAvailableStorage:
+            DoGetAvailableStorageL(aMessage);
+            break;
+            
+        case ESrGetEngineProperties:
+            DoGetEnginePropertiesL(aMessage);
+            break;
+            
+        case ESrGetModelCount:
+            DoGetModelCountL(aMessage);
+            break;
+            
+        case ESrGetRuleValidity:
+            DoGetRuleValidityL(aMessage);
+            break;
+            
+        case ESrUtteranceDuration:
+            DoGetUtteranceDurationL(aMessage);
+            break;
+            
+        case ESrLoadGrammar:
+            DoLoadGrammarL(aMessage);
+            break;
+            
+        case ESrActivateGrammar:
+            DoActivateGrammarL(aMessage);
+            break;
+            
+        case ESrDeactivateGrammar:
+            DoDeactivateGrammarL(aMessage);
+            break;
+            
+        case ESrLoadLexicon:
+            DoLoadLexiconL(aMessage);
+            break;
+            
+        case ESrLoadModels:
+            DoLoadModelsL(aMessage);
+            break;
+            
+        case ESrPlayUtterance:
+            DoPlayUtteranceL(aMessage);
+            break;
+            
+        case ESrRecognize:
+            DoRecognizeL(aMessage);
+            break;
+            
+        case ESrRecord:
+            DoRecordL(aMessage);
+            break;
+            
+        case ESrRemoveGrammar:
+            DoRemoveGrammarL(aMessage);
+            break;
+            
+        case ESrRemoveLexicon:
+            DoRemoveLexiconL(aMessage);
+            break;
+            
+        case ESrRemoveModelBank:
+            DoRemoveModelBankL(aMessage);
+            break;
+            
+        case ESrRemoveModel:
+            DoRemoveModelL(aMessage);
+            break;
+            
+        case ESrRemovePronunciation:
+            DoRemovePronunciationL(aMessage);
+            break;
+            
+        case ESrRemoveRule:
+            DoRemoveRuleL(aMessage);
+            break;
+            
+        case ESrRemoveRules:
+            RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoHandleRequestL. case ESrRemoveRules" );
+            DoRemoveRulesL( aMessage );
+            break;
+            
+        case ESrSetClientUid:
+            DoSetClientUidL(aMessage);
+            break;
+            
+        case ESrStartRecSession:
+            DoStartRecSessionL(aMessage);
+            break;
+            
+        case ESrTrain:
+            DoTrainL(aMessage);
+            break;
+            
+        case ESrUnloadRule:
+            DoUnloadRuleL(aMessage);
+            break;
+            
+        case ESrLoadEngineParameters:
+            DoLoadEngineParametersL(aMessage);
+            break;
+            
+        case ESrGetPronunciationIDArraySize:
+            pckgSize() = iPronunciationIDs.Count();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetPronunciationIDArrayContents:
+            DoCopyPronunciationIDArrayL(aMessage);
+            break;
+            
+        case ESrGetRuleIDArraySize:
+            pckgSize() = iRuleIDs.Count();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetRuleIDArrayContents:
+            DoCopyRuleIDArrayL(aMessage);			
+            break;
+            
+        case ESrGetModelIDArraySize:
+            pckgSize() = iModelIDs.Count();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetModelIDArrayContents:
+            DoCopyModelIDArrayL(aMessage);
+            break;
+            
+        case ESrGetGrammarIDArraySize:
+            pckgSize() = iGrammarIDs.Count();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetGrammarIDArrayContents:
+            DoCopyGrammarIDArrayL(aMessage);
+            break;
+            
+        case ESrGetLexiconIDArraySize:
+            pckgSize() = iLexiconIDs.Count();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetLexiconIDArrayContents:
+            DoCopyLexiconIDArrayL(aMessage);
+            break;
+            
+        case ESrGetModelBankIDArraySize:
+            pckgSize() = iModelBankIDs.Count();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetModelBankIDArrayContents:
+            DoCopyModelBankIDArrayL(aMessage);
+            break;
+            
+        case ESrGetClientResultSetSize:
+            DoExternalizeResultSetL();
+            pckgSize() = iResultCopyBuffer->Size();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetClientResultSetSizeSI:
+            DoExternalizeSIResultSetL();
+            pckgSize() = iResultCopyBuffer->Size();
+            aMessage.WriteDataToClientL(pckgSize);
+            break;
+            
+        case ESrGetClientResultSet:
+            DoCopyResultSetL(aMessage);
+            break;
+            
+            // SI main requests
+        case ESrAdapt:
+            DoAdaptL( aMessage );
+            break;
+            
+        case ESrAddPronunciationSI:
+            DoAddPronunciationSIL( aMessage );
+            break;
+            
+        case ESrAddRuleVariant:
+            DoAddRuleVariantL( aMessage );
+            break;
+            
+        case ESrAddVoiceTag:
+            DoAddVoiceTagL( aMessage );
+            break;
+            
+        case ESrAddVoiceTags:
+            DoAddVoiceTagsL( aMessage );
+            break;
+            
+        case ESrCreateRule:
+            DoCreateRuleL( aMessage );
+            break;
+            
+        case ESrEndRecord:
+            DoEndRecordL( aMessage );
+            break;
+            
+        case ESrRecognizeSI:
+            DoRecognizeSIL( aMessage );
+            break;
+            
+        case ESrUnloadGrammar:
+            DoUnloadGrammarL( aMessage );
+            break;
+            
+        case ESrAddSindeVoiceTag:
+            DoAddSindeVoiceTagL( aMessage );
+            break;
+            
+        case ESrAddSindeVoiceTags:
+            DoAddSindeVoiceTagsL( aMessage );
+            break;
+            
+        case ESrPreStartSampling:
+            DoPreStartSamplingL( aMessage );
+            break;
+            
+        default:
+            RUBY_DEBUG1( "CSISpeechRecognitionCustomCommandParser::DoHandleRequestL. Unknown function [%d]. Leaving", aMessage.Function() );
+            User::Leave(KErrNotSupported);
+            
+        }	// end of switch
+    
+    
+    aMessage.Complete(KErrNone);
+    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddPronunciationL
+// Calls the controller plugin to add a pronunciation.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddPronunciationL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoAddPronunciationL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddRuleL
+// Calls the controller plugin to add a rule.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoAddRuleL(
+	TMMFMessage& aMessage)
+	{
+
+	// Async
+	TSrsAddRulePckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TSrsAddRule srsAddRule = pckg();
+
+	iImplementor.MSrAddRuleL( srsAddRule.iGrammarID, srsAddRule.iLexiconID,
+							 srsAddRule.iPronunciationID, *srsAddRule.iRuleID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCancel
+// Calls the controller plugin to cancel the currect asynchronous operation.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoCancel()
+	{
+
+	iImplementor.MSrCancel();
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCommitChanges
+// Saves the current trained model into a permanent storage.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoCommitChangesL()
+	{
+
+	iImplementor.MSrCommitChangesL();
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCreateGrammarL
+// Calls the controller plugin to create a grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoCreateGrammarL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPtrPckg srsGrammarIDPtrPckg;
+	aMessage.ReadData1FromClientL(srsGrammarIDPtrPckg);
+	TSIGrammarID* grammarID = srsGrammarIDPtrPckg();
+	iImplementor.MSrCreateGrammarL(*grammarID) ;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCreateLexiconL
+// Calls the controller plugin to create a lexicon.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoCreateLexiconL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsLexiconIDPtrPckg srsLexiconIDPtrPckg;
+	aMessage.ReadData1FromClientL(srsLexiconIDPtrPckg);
+	TSILexiconID* lexiconID = srsLexiconIDPtrPckg();
+	iImplementor.MSrCreateLexiconL(*lexiconID) ;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCreateModelBankL
+// Calls the controller plugin to create a model bank.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoCreateModelBankL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsModelBankIDPtrPckg modelBankIDPtrPckg;
+	aMessage.ReadData1FromClientL(modelBankIDPtrPckg);
+	TSIModelBankID* modelBankID = modelBankIDPtrPckg();
+	iImplementor.MSrCreateModelBankL(*modelBankID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoEndRecSessionL
+// Calls the controller plugin to end the current recognition session and free
+// the allocated resources.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoEndRecSessionL()
+	{
+
+	iImplementor.MSrEndRecSessionL();
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL
+// Calls the controller plugin to get all client grammar IDs.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL()
+	{
+
+	// Async
+	iGrammarIDs.Reset();
+	iImplementor.MSrGetAllClientGrammarIDsL(iGrammarIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL
+// Calls the controller plugin to get all client lexicon IDs.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL()
+	{
+
+	// Async
+	iLexiconIDs.Reset();
+	iImplementor.MSrGetAllClientLexiconIDsL(iLexiconIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL
+// Calls the controller plugin to get all client model bank IDs.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL()
+	{
+
+	// Async
+	iModelBankIDs.Reset();
+	iImplementor.MSrGetAllClientModelBankIDsL(iModelBankIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL
+// Calls the controller plugin to get all grammar IDs for all clients.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL()
+	{
+
+	// Async
+	iGrammarIDs.Reset();
+	iImplementor.MSrGetAllGrammarIDsL(iGrammarIDs);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL
+// Calls the controller plugin to get all lexicon IDs for all clients.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL()
+	{	
+
+	// Async
+	iLexiconIDs.Reset();
+	iImplementor.MSrGetAllLexiconIDsL(iLexiconIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL
+// Calls the controller plugin to get all model bank IDs.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL()
+	{
+
+	// Async
+	iModelBankIDs.Reset();
+	iImplementor.MSrGetAllModelBankIDsL(iModelBankIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllModelIDsL
+// Calls the controller plugin to get all model IDs from a model bank.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllModelIDsL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetAllModelIDsL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL
+// Calls the controller plugin to get all pronunciation IDs from a lexicon.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL(
+	TMMFMessage& aMessage)
+	{
+
+	// Async
+	TSrsLexiconIDPckg lexiconIDPckg;
+	iPronunciationIDs.Reset();
+	aMessage.ReadData1FromClientL(lexiconIDPckg);
+
+	iImplementor.MSrGetAllPronunciationIDsL(lexiconIDPckg(), iPronunciationIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL
+// Calls the controller plugin to get all rule IDs from a grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL(
+	TMMFMessage& aMessage)
+	{
+
+	// Async
+	TSrsGrammarIDPckg grammarIDPckg;
+	iRuleIDs.Reset();
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+
+	iImplementor.MSrGetAllRuleIDsL(grammarIDPckg(), iRuleIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetAvailableStorageL
+// Calls the controller plugin to get the available storage for training new 
+// models.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetAvailableStorageL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetAvailableStorageL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL
+// Calls the controller plugin to get the engine properties.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL(
+	TMMFMessage& aMessage)
+	{
+
+	RArray<TInt> propertyIDs;
+	RArray<TInt> propertyValues;
+	CleanupClosePushL(propertyIDs);
+	CleanupClosePushL(propertyValues);
+	DoExtractIntArrayFromData1L(aMessage, propertyIDs);
+	iImplementor.MSrGetEnginePropertiesL(propertyIDs,propertyValues);
+	// the custom command is aware of the size of the result, so it can copy the data back directly
+	DoCopyIntArrayL(aMessage, propertyValues);
+	CleanupStack::PopAndDestroy(2); //propertyIDs, propertyValues
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetModelCountL
+// Calls the controller plugin to get the number of models in a model bank.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetModelCountL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetModelCountL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetRuleValidityL
+// Calls the controller plugin to determine if a rule is valid.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetRuleValidityL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsRuleValidityPckg srsRuleValidityPckg;
+	aMessage.ReadData1FromClientL(srsRuleValidityPckg);
+	TSrsRuleValidity srsRuleValidity = srsRuleValidityPckg();
+	iImplementor.MSrGetRuleValidityL( srsRuleValidity.iGrammarID, 
+				srsRuleValidity.iRuleID, *srsRuleValidity.iRuleValid );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL
+// Calls the controller plugin to get the utterance duration.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoLoadGrammarL
+// Calls the controller plugin to load the specified grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoLoadGrammarL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg;
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+	TSIGrammarID grammarID = grammarIDPckg();
+	iImplementor.MSrLoadGrammarL( grammarID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoActivateGrammarL
+// Calls the controller plugin to activate the specified grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoActivateGrammarL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg;
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+	TSIGrammarID grammarID = grammarIDPckg();
+	iImplementor.MSrActivateGrammarL( grammarID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoDeactivateGrammarL
+// Calls the controller plugin to deactivate the specified grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoDeactivateGrammarL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg;
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+	TSIGrammarID grammarID = grammarIDPckg();
+	iImplementor.MSrDeactivateGrammarL( grammarID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoLoadLexiconL
+// Calls the controller plugin to load the specified lexican.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoLoadLexiconL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsLexiconIDPckg lexiconIDPckg;
+	aMessage.ReadData1FromClientL(lexiconIDPckg);
+	TSILexiconID lexiconID = lexiconIDPckg();
+	iImplementor.MSrLoadLexiconL(lexiconID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoLoadModelsL
+// Calls the controller plugin to load all models from a model bank.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoLoadModelsL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsModelBankIDPckg modelBankIDPckg;
+	aMessage.ReadData1FromClientL(modelBankIDPckg);
+	TSIModelBankID modelBankID = modelBankIDPckg();
+	iImplementor.MSrLoadModelsL(modelBankID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoPlayUtteranceL
+// Calls the controller plugin to play a previously recorded utterance.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoPlayUtteranceL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoPlayUtteranceL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRecognizeL
+// Calls the controller plugin to recognize an utterance.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRecognizeL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoRecognizeL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRecordL
+// Calls the controller plugin to start recording an utterance for either 
+// training or recognition
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRecordL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsTimeIntervalMicroSeconds32Pckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TTimeIntervalMicroSeconds32 recordDuration = pckg();
+	iImplementor.MSrRecordL(recordDuration);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoPreStartSamplingL
+// Calls the controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoPreStartSamplingL(
+    TMMFMessage& /*aMessage*/ )
+    {
+    iImplementor.MSrPreStartSamplingL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemoveGrammarL
+// Calls the controller plugin to remove a grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRemoveGrammarL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TSIGrammarID grammarID = pckg();
+	iImplementor.MSrRemoveGrammarL(grammarID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemoveLexiconL
+// Calls the controller plugin to remove a lexicon.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRemoveLexiconL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsLexiconIDPckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TSILexiconID lexiconID = pckg();
+	iImplementor.MSrRemoveLexiconL(lexiconID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemoveModelBankL
+// Calls the controller plugin to remove a model bank and all associated models.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRemoveModelBankL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsModelBankIDPckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TSIModelBankID modelBankID = pckg();
+	iImplementor.MSrRemoveModelBankL(modelBankID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemoveModelL
+// Calls the controller plugin to remove a model from a model bank.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRemoveModelL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsModelBankIDPckg modelBankIDPckg;
+	aMessage.ReadData1FromClientL(modelBankIDPckg);
+	TSIModelBankID modelBankID = modelBankIDPckg();
+	TSrsModelIDPckg modelIDPckg;
+	aMessage.ReadData2FromClientL(modelIDPckg);
+	TSIModelBankID modelID = modelIDPckg();
+	iImplementor.MSrRemoveModelL(modelBankID, modelID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemovePronunciationL
+// Calls the controller plugin to remove a pronunciation.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRemovePronunciationL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsLexiconIDPckg lexiconIDPckg;
+	aMessage.ReadData1FromClientL(lexiconIDPckg);
+	TSILexiconID lexiconID = lexiconIDPckg();
+	TSrsPronunciationIDPckg pronunciationIDPckg;
+	aMessage.ReadData2FromClientL(pronunciationIDPckg);
+	TSIPronunciationID pronunciationID = pronunciationIDPckg();
+	iImplementor.MSrRemovePronunciationL( lexiconID, pronunciationID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemoveRuleL
+// Calls the controller plugin to remove a rule.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoRemoveRuleL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg;
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+	TSIGrammarID grammarID = grammarIDPckg();
+	TSrsRuleIDPckg ruleIDPckg;
+	aMessage.ReadData2FromClientL(ruleIDPckg);
+	TSIRuleID ruleID = ruleIDPckg();
+	iImplementor.MSrRemoveRuleL( grammarID, ruleID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoSetClientUid
+// Sets the client's UID for data ownership identification.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoSetClientUidL(TMMFMessage& aMessage)
+{
+    RUBY_DEBUG_BLOCK( "CSISpeechRecognitionCustomCommandParser::DoSetClientUidL" );
+
+	TSrsUidPckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TUid uid = pckg();
+	iImplementor.MSrSetClientUid(uid);
+
+}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoStartRecSessionL
+// Calls the controller plugin to begin a recognition session.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoStartRecSessionL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsRecognitionModePckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TNSSRecognitionMode mode = pckg();
+	iImplementor.MSrStartRecSessionL( mode );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoTrainL
+// Calls the controller plugin to begin a recognition session.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoTrainL(
+	TMMFMessage& /*aMessage*/)
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoTrainL is NOT supported" );
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoUnloadRuleL
+// Calls the controller plugin to add a rule.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionCustomCommandParser::DoUnloadRuleL(
+	TMMFMessage& aMessage)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg;
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+	TSIGrammarID grammarID = grammarIDPckg();
+	TSrsRuleIDPckg ruleIDPtrPckg;
+	aMessage.ReadData2FromClientL(ruleIDPtrPckg);
+	TSIRuleID ruleID = ruleIDPtrPckg();
+
+	iImplementor.MSrUnloadRuleL( grammarID, ruleID );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoLoadEngineParametersL
+// Calls the controller plugin to upload the parameters into the engine.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoLoadEngineParametersL(
+	TMMFMessage& aMessage)
+	{
+
+	RArray<TInt> parameters;
+	RArray<TInt> values;
+	CleanupClosePushL(parameters);
+	CleanupClosePushL(values);
+	DoExtractIntArrayFromData1L(aMessage, parameters);
+	DoExtractIntArrayFromData2L(aMessage, values);
+	iImplementor.MSrLoadEngineParametersL(parameters,values);
+	CleanupStack::PopAndDestroy(2); // parameters, values
+	
+	}
+
+// ==================== SI Extensions ==========================================
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAdaptL
+// Adapts the acoustic models to a user's voice.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAdaptL(
+    TMMFMessage& aMessage)
+    {
+    HBufC8* resultSetBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 1 );
+
+    TPckgBuf<TInt> correctPckg;
+    aMessage.ReadData2FromClientL( correctPckg );
+
+    RDesReadStream resultSetStream;
+    CleanupClosePushL( resultSetStream );
+    resultSetStream.Open( *resultSetBuf );
+
+    if ( iAdaptationSet )
+        {
+        delete iAdaptationSet;
+        iAdaptationSet = 0;
+        }
+
+    iAdaptationSet = CSIClientResultSet::NewL();
+    iAdaptationSet->InternalizeL( resultSetStream );
+
+    iImplementor.MSrAdaptL( *iAdaptationSet, correctPckg() );
+
+    CleanupStack::PopAndDestroy( &resultSetStream );
+    CleanupStack::PopAndDestroy( resultSetBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddPronunciationSIL
+// Adds a speaker independent pronunciation
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddPronunciationSIL(
+    TMMFMessage& aMessage)
+    {
+    TSrsAddPronunciationSIPckg pckg;
+    TSrsAddPronunciationSI* addPronunData;
+
+    aMessage.ReadData1FromClientL( pckg );
+    addPronunData = &pckg();
+
+    // Read the phrase to be trained.
+    HBufC8* textData = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
+
+    // The phrase is in 8-bit descriptor, altough its structure is 16-bit Unicode.
+    // We make a 16-bit TPtr, which points to the same memory area.
+    TUint16* trainTextAddress = (TUint16*)textData->Ptr();
+    TInt     trainTextLength  = addPronunData->iTextLength;
+
+    // Check against buffer overrun before making the descriptor.
+    TInt trainTextSize = 2 * trainTextLength;
+    if ( trainTextSize > textData->Size() )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    // Make the descriptor.
+    TPtrC16 trainText( trainTextAddress, trainTextLength );
+
+    iImplementor.MSrAddPronunciationL(
+        addPronunData->iLexiconID,
+        trainText,
+        addPronunData->iLanguage,
+        *addPronunData->iPronunciationIDPtr );
+
+    CleanupStack::PopAndDestroy( textData );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddRuleVariantL
+// Adds a rule variant
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+void CSISpeechRecognitionCustomCommandParser::DoAddRuleVariantL(
+    TMMFMessage& aMessage)
+    {
+    TSrsAddRuleVariantPckg pckg;
+    TSrsAddRuleVariant* data;
+
+    aMessage.ReadData1FromClientL( pckg );
+    data = &pckg();
+
+    // Read the second parameter slot of aMessage.
+    HBufC8* pronunChunk = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
+    // Stack: pronunChunk
+
+    RArray<TSIPronunciationID> pronunArray;
+    CleanupClosePushL( pronunArray ); // Stack: pronunChunk, pronunArray
+
+    SICustomCommandData::InternalizePronunArrayL(
+        *pronunChunk,
+        data->iPronunIDCount,
+        pronunArray );
+
+    iImplementor.MSrAddRuleVariantL(
+        data->iGrammarID,
+        data->iLexiconID,
+        pronunArray,
+        data->iRuleID,
+        *data->iRuleVariantID
+        );
+
+    CleanupStack::PopAndDestroy( &pronunArray );
+    CleanupStack::PopAndDestroy( pronunChunk );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddVoiceTag
+// Adds a voice tag
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddVoiceTagL(
+    TMMFMessage& aMessage)
+    {
+    if ( iWordArray != 0 )
+        {
+        delete iWordArray;
+        iWordArray = 0;
+        }
+
+    TSrsAddVoiceTagPckg pckg;
+    TSrsAddVoiceTag *params = &pckg();
+
+    aMessage.ReadData1FromClient( pckg );
+
+    HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
+     // Stack: phraseBuf
+
+    // !!!! Is it able to call ~MDesCArray, as MDesCArray is not derived from CBase?
+    iWordArray = SICustomCommandData::InternalizeDesCArrayL( *phraseBuf );
+
+    iLanguageArray.Reset();
+    params->ListLanguagesL( iLanguageArray );
+
+    iImplementor.MSrAddVoiceTagL(
+        *iWordArray, 
+        iLanguageArray, 
+        params->iLexiconID, 
+        params->iGrammarID, 
+        *params->iRuleID );
+
+    CleanupStack::PopAndDestroy( phraseBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddVoiceTags
+// Adds several voice tags
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddVoiceTagsL(
+    TMMFMessage& aMessage)
+    {
+    RPointerArray<MDesCArray>* phraseArray = 0;
+    // The 2 parameter slots contain:
+    //  1. Headers: Various identifiers
+    //  2. Phrases: Recognition phrases in an array.
+
+    // Header storage
+    TSrsAddVoiceTagPckg pckg;
+    TSrsAddVoiceTag *params = &pckg();
+
+    // Phrase storage
+
+    aMessage.ReadData1FromClient( pckg );
+    HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
+    // Stack: phraseBuf
+
+    phraseArray = SICustomCommandData::InternalizeDesCArrayArrayL( *phraseBuf );
+    CleanupStack::PushL( phraseArray );
+
+    iLanguageArray.Reset();
+    params->ListLanguagesL( iLanguageArray );
+
+    CleanupStack::Pop( phraseArray );
+
+    iImplementor.MSrAddVoiceTagsL(
+        phraseArray,
+        iLanguageArray,
+        params->iLexiconID,
+        params->iGrammarID,
+        iRuleIDs
+        );
+
+    CleanupStack::PopAndDestroy( phraseBuf );
+    }
+
+#ifdef __SINDE_TRAINING
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL
+// 
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL( TMMFMessage& aMessage )
+    {
+    if ( iWordArray != NULL )
+        {
+        delete iWordArray;
+        iWordArray = NULL;
+        }
+
+    TSrsAddSindeVoiceTagPckg pckg;
+    TSrsAddSindeVoiceTag *params = &pckg();
+
+    aMessage.ReadData1FromClient( pckg );
+
+    HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
+     // Stack: phraseBuf
+
+    iWordArray = SICustomCommandData::InternalizeDesCArrayL( *phraseBuf );
+
+    for ( TInt i = 0; i < iLanguageArrayArray.Count(); i++ )
+        {
+        iLanguageArrayArray[i].Close();
+        }
+    iLanguageArrayArray.Reset();
+    params->ListLanguagesL( iLanguageArrayArray );
+
+    iImplementor.MSrAddSindeVoiceTagL( *iWordArray, 
+                                       iLanguageArrayArray, 
+                                       params->iLexiconID, 
+                                       params->iGrammarID, 
+                                       *params->iRuleID );
+
+    CleanupStack::PopAndDestroy( phraseBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL
+//
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL( TMMFMessage& aMessage )
+    {
+    RPointerArray<MDesCArray>* phraseArray = 0;
+    // The 2 parameter slots contain:
+    //  1. Headers: Various identifiers
+    //  2. Phrases: Recognition phrases in an array.
+
+    // Header storage
+    TSrsAddSindeVoiceTagPckg pckg;
+    TSrsAddSindeVoiceTag *params = &pckg();
+
+    // Phrase storage
+
+    aMessage.ReadData1FromClient( pckg );
+    HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
+    // Stack: phraseBuf
+
+    phraseArray = SICustomCommandData::InternalizeDesCArrayArrayL( *phraseBuf );
+    CleanupStack::PushL( phraseArray );
+
+    for ( TInt i = 0; i < iLanguageArrayArray.Count(); i++ )
+        {
+        iLanguageArrayArray[i].Close();
+        }
+    iLanguageArrayArray.Reset();
+    params->ListLanguagesL( iLanguageArrayArray );
+
+
+    iImplementor.MSrAddSindeVoiceTagsL( phraseArray, iLanguageArrayArray,
+                                        params->iLexiconID, params->iGrammarID,
+                                        iRuleIDs );
+
+    CleanupStack::Pop( phraseArray );
+    CleanupStack::PopAndDestroy( phraseBuf );
+    }
+
+#else // __SINDE_TRAINING
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL
+// 
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL( TMMFMessage& /*aMessage*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL
+//
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL( TMMFMessage& /*aMessage*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+#endif // __SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCreateRule
+// Creates an empty rule
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCreateRuleL(
+    TMMFMessage& aMessage)
+    {
+    TSrsAddRulePckg pckg;
+    TSrsAddRule* params = &(pckg());
+
+	aMessage.ReadData1FromClientL(pckg);
+
+    iImplementor.MSrCreateRuleL( params->iGrammarID, *params->iRuleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoEndRecord
+// Stops recognition
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoEndRecordL(
+    TMMFMessage& /*aMessage*/)
+    {
+    iImplementor.MSrEndRecordL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRecognizeSI
+// Starts a speaker independent recognition
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoRecognizeSIL(
+    TMMFMessage& aMessage)
+    {
+	// remove any previous result set, if any
+	if (iSIResultSet != NULL)
+	{
+		delete iSIResultSet;
+		iSIResultSet = NULL;
+	}
+
+    // Read data chunk of CSIClientResultSet
+    HBufC8* dataBuffer = SICustomCommandData::ReadMessageDataLC( aMessage, 1 );
+
+    // Set up stream
+	RDesReadStream stream( *dataBuffer );
+	CleanupClosePushL(stream);
+
+    // Convert chunk to proper type
+	iSIResultSet = CSIClientResultSet::NewL();
+	iSIResultSet->InternalizeL(stream);
+
+    // Recognize
+	iImplementor.MSrRecognizeL(*iSIResultSet);
+
+	CleanupStack::PopAndDestroy(&stream);//stream
+    CleanupStack::PopAndDestroy(dataBuffer);//databuffer
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoUnloadGrammar
+// Deactivates a grammar from the current recognition vocabulary
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoUnloadGrammarL(
+    TMMFMessage& aMessage)
+    {
+	TSrsGrammarIDPckg pckg;
+	aMessage.ReadData1FromClientL(pckg);
+	TSIGrammarID grammarID = pckg();
+
+	iImplementor.MSrUnloadGrammarL(grammarID);
+    }
+
+// ==================== SI Extensions end ======================================
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL
+// Copy the pronunciation IDs to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL(
+	TMMFMessage& aMessage)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	for (TInt i=0;i<iPronunciationIDs.Count();i++)
+	{
+		stream.WriteUint32L(iPronunciationIDs[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL
+// Copy the model IDs to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL(
+	TMMFMessage& aMessage)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	for (TInt i=0;i<iModelIDs.Count();i++)
+	{
+		stream.WriteUint32L(iModelIDs[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	
+//	iModelIDs.Close();
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL
+// Copy the rule IDs to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL(
+	TMMFMessage& aMessage)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	for (TInt i=0;i<iRuleIDs.Count();i++)
+	{
+		stream.WriteUint32L(iRuleIDs[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+
+	}
+	
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoRemoveRules
+// Remove rules by their IDS
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoRemoveRulesL( TMMFMessage& aMessage )
+	{
+    RUBY_DEBUG_BLOCK( "CSISpeechRecognitionCustomCommandParser::DoRemoveRulesL" );
+
+	TSrsGrammarIDPckg grammarIDPckg;
+	aMessage.ReadData1FromClientL(grammarIDPckg);
+	TSIGrammarID grammarID = grammarIDPckg();
+	RArray<TInt> ruleIDs;
+	CleanupClosePushL( ruleIDs );
+//	TMMFMessage& aMessage, 
+//	RArray<TInt>& aArray)
+	DoExtractIntArrayFromData2L(aMessage, ruleIDs);
+
+	
+	iRuleIDs.Reset();
+	for( TInt i = 0; i < ruleIDs.Count(); i++) 
+		{
+		iRuleIDs.Append(ruleIDs[i]);
+		}
+
+	//iImplementor.MSrRemoveRulesL( grammarID, reinterpret_cast<RArray<TUint32>&> ( forwardedRuleIDs ) );
+    iImplementor.MSrRemoveRulesL( grammarID, iRuleIDs );
+
+	CleanupStack::PopAndDestroy();  // ruleIDs
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL
+// Copy the grammar IDs to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL(
+	TMMFMessage& aMessage)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	for (TInt i=0;i<iGrammarIDs.Count();i++)
+	{
+		stream.WriteUint32L(iGrammarIDs[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL
+// Copy the lexicon IDs to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL(
+	TMMFMessage& aMessage)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	for (TInt i=0;i<iLexiconIDs.Count();i++)
+	{
+		stream.WriteUint32L(iLexiconIDs[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL
+// Copy the model bank IDs to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL(
+	TMMFMessage& aMessage)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	for (TInt i=0;i<iModelBankIDs.Count();i++)
+	{
+		stream.WriteUint32L(iModelBankIDs[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoExternalizeResultSetL
+// Externalize the client result set. 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoExternalizeResultSetL()
+	{
+    RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoExternalizeResultSetL is NOT supported" );
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyResultSetL
+// Copy the recognition result set to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoCopyResultSetL(
+	TMMFMessage& aMessage)
+	{
+
+	// make sure we have a copy buffer available.
+	if ( iResultCopyBuffer == NULL )
+	{
+		User::Leave(KErrNotReady);
+	}
+
+	aMessage.WriteDataToClientL(iResultCopyBuffer->Ptr(0));
+	delete iResultCopyBuffer;
+	iResultCopyBuffer = NULL;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoExternalizeSIResultSetL
+// Externalize the client result set. 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoExternalizeSIResultSetL()
+	{
+
+	// make sure we have a result set available.
+	if ( iSIResultSet == NULL )
+	{
+		User::Leave(KErrNotReady);
+	}
+	
+	// allocate the result copy buffer if needed.
+	if (iResultCopyBuffer == NULL ) 
+	{
+		iResultCopyBuffer = CBufFlat::NewL(KExpandSize);
+	}
+	else
+	{
+		iResultCopyBuffer->Reset();	// use existing buffer, clear previous results
+	}
+
+	RBufWriteStream stream;
+	stream.Open(*iResultCopyBuffer);
+	CleanupClosePushL(stream);
+	iSIResultSet->ExternalizeL(stream);
+	delete iSIResultSet; // the controller side version is no longer needed
+	iSIResultSet = NULL;
+	CleanupStack::PopAndDestroy(1); //stream
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L
+// Extract an integer array from client data 1.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L(
+	TMMFMessage& aMessage, 
+	RArray<TInt>& aArray)
+	{
+	TInt size = aMessage.SizeOfData1FromClient();
+	HBufC8* buf = HBufC8::NewL(size);
+	CleanupStack::PushL(buf);
+	TPtr8 ptr = buf->Des();
+	aMessage.ReadData1FromClientL(ptr);
+	DoExtractIntArrayL(ptr,aArray);
+	CleanupStack::PopAndDestroy(buf);
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L
+// Extract an integer array from client data 2.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L(
+	TMMFMessage& aMessage, 
+	RArray<TInt>& aArray)
+	{
+	
+	TInt size = aMessage.SizeOfData2FromClient();
+	HBufC8* buf = HBufC8::NewL(size);
+	CleanupStack::PushL(buf);
+	TPtr8 ptr = buf->Des();
+	aMessage.ReadData2FromClientL(ptr);
+	DoExtractIntArrayL(ptr,aArray);
+	CleanupStack::PopAndDestroy(buf);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayL
+// Extract an integer array from a descriptor into an RArray.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------	
+void CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayL(
+	TDes8& aDescriptor, 
+	RArray<TInt>& aArray)
+	{
+
+	RDesReadStream stream(aDescriptor);
+	CleanupClosePushL(stream);
+	
+	TInt numberElements;
+	numberElements = stream.ReadInt32L();
+
+    TInt i( 0 );
+	for ( i = 0; i<numberElements; i++)
+		{
+		User::LeaveIfError(aArray.Append(stream.ReadInt32L()));
+		}
+	CleanupStack::PopAndDestroy(); //stream
+	
+#ifdef _DEBUG
+        RUBY_DEBUG1( "CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayL Read array of size [%d]", aArray.Count() );
+
+		for( i = 0; i < aArray.Count(); i++) 
+			{
+			RUBY_DEBUG2( "::DoExtractIntArrayL aArray[%d] = [%d]", i, aArray[i] );
+			}
+#endif
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionCustomCommandParser::DoCopyIntArrayL
+// Copy data from an RArray to the client.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------	
+void CSISpeechRecognitionCustomCommandParser::DoCopyIntArrayL(
+	TMMFMessage& aMessage, 
+	const RArray<TInt>& aArray)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+
+	for (TInt i=0;i<aArray.Count();i++)
+	{
+		stream.WriteUint32L(aArray[i]);
+	}
+
+	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+
+	}
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sicc/src/nsssispeechrecognitioncustomcommands.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1308 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the implementation of the client interface for the
+*               speaker independent custom commands.
+*
+*/
+
+
+// INCLUDE FILES
+#include "srsfbldvariant.hrh"
+#include "nsssispeechrecognitioncustomcommands.h"
+#include <nsssispeechrecognitiondatacommon.h>
+#include <badesca.h>
+#include "nsssispeechrecognitioncustomcommandcommon.h"
+#include "nsssicustomcommanddata.h"
+#include "rubydebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RSISpeechRecognitionCustomCommands
+// C++ constructor.
+// -----------------------------------------------------------------------------
+
+EXPORT_C RSISpeechRecognitionCustomCommands::RSISpeechRecognitionCustomCommands(
+	RMMFController& aController) :
+	RMMFCustomCommandsBase(aController, 
+	KUidInterfaceSpeakerIndependent)
+	{
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::AddRule
+// Sends a command to the controller to add a rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddRule(
+	TSIGrammarID aGrammarID, 
+	TSILexiconID aLexiconID, 
+	TSIPronunciationID aPronunciationID, 
+	TSIRuleID& aRuleID)
+	{
+
+	TSrsAddRule srsAddRule(aGrammarID, aLexiconID, aPronunciationID, &aRuleID);
+	TSrsAddRulePckg pckg(srsAddRule);
+	return iController.CustomCommandSync(iDestinationPckg, ESrAddRule,
+											pckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::Cancel
+// Sends a command to the controller to cancel the currect asynchronous 
+// operation.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSISpeechRecognitionCustomCommands::Cancel()
+	{
+
+	iController.CustomCommandSync(iDestinationPckg, ESrCancel,
+											KNullDesC8, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::CommitChanges
+// Sends a command to the controller to commit the current changes.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::CommitChanges()
+	{
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrCommitChanges,
+											KNullDesC8, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::CreateGrammar
+// Sends a command to the controller to create a grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateGrammar(
+	TSIGrammarID& aGrammarID)
+	{
+
+	TSrsGrammarIDPtrPckg srsGrammarIDPtrPckg = &aGrammarID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrCreateGrammar,
+											srsGrammarIDPtrPckg, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::CreateLexicon
+// Sends a command to the controller to create a lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateLexicon(
+	TSILexiconID& aLexiconID)
+	{
+
+	TSrsLexiconIDPtrPckg srsLexiconIDPtrPckg = &aLexiconID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrCreateLexicon,
+											srsLexiconIDPtrPckg, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::CreateModelBank
+// Sends a command to the controller to create a model bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateModelBank(
+	TSIModelBankID& aModelBankID)
+	{
+
+	TSrsModelBankIDPtrPckg modelBankIDPtrPckg = &aModelBankID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrCreateModelBank,
+											modelBankIDPtrPckg, KNullDesC8);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::EndRecSession
+// Sends a command to the controller to end the current recognition session and 
+// free the allocated resources.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::EndRecSession()
+	{
+
+	TInt err = iController.CustomCommandSync(iDestinationPckg, ESrEndRecSession,
+											KNullDesC8, KNullDesC8);
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllClientGrammarIDs
+// Calls the controller plugin to get all client grammar IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllClientGrammarIDs()
+	{
+
+	return iController.CustomCommandSync(iDestinationPckg, 
+			ESrGetAllClientGrammarIDs, KNullDesC8, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllClientLexiconIDs
+// Calls the controller plugin to get all client lexicon IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllClientLexiconIDs()
+	{
+
+	return iController.CustomCommandSync(iDestinationPckg, 
+			ESrGetAllClientLexiconIDs, KNullDesC8, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllClientModelBankIDs
+// Calls the controller plugin to get all client model bank IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllClientModelBankIDs()
+	{
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetAllClientModelBankIDs,
+							KNullDesC8, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllGrammarIDs
+// Calls the controller plugin to get all grammar IDs for all clients.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllGrammarIDs()
+	{
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetAllGrammarIDs,
+							KNullDesC8, KNullDesC8); // Async
+	
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllLexiconIDs
+// Calls the controller plugin to get all lexicon IDs for all clients.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllLexiconIDs()
+	{	
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetAllLexiconIDs,
+							KNullDesC8, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllModelBankIDs
+// Calls the controller plugin to get all model bank IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllModelBankIDs()
+	{
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetAllModelBankIDs,
+							KNullDesC8, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllModelIDs
+// Sends a command to the controller to get all model IDs from a model bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllModelIDs(
+	TSIModelBankID aModelBankID)
+	{
+
+	TSrsModelBankIDPckg modelBankIDPckg = aModelBankID;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetAllModelIDs,
+							modelBankIDPckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllPronunciationIDs
+// Sends a command to the controller to get all pronunciation IDs from a lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllPronunciationIDs(
+	TSILexiconID aLexiconID)
+	{
+
+	TSrsLexiconIDPckg lexiconIDPckg = aLexiconID;
+	return iController.CustomCommandSync(iDestinationPckg, 
+						ESrGetAllPronunciationIDs,
+						lexiconIDPckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetAllRuleIDs
+// Sends a command to the controller to get all rule IDs from a grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetAllRuleIDs(
+	TSIGrammarID aGrammarID)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetAllRuleIDs,
+							grammarIDPckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetEngineProperties
+// Sends a command to the controller to get the engine properties.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetEngineProperties(
+	const RArray<TInt>& aPropertyId, 
+	RArray<TInt>& aPropertyValue)
+	{
+
+	TRAPD(err, DoGetEnginePropertiesL(aPropertyId, aPropertyValue));
+	return err;	
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetModelCount
+// Sends a command to the controller to get the number of models in a model bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetModelCount(
+	TSIModelBankID aModelBankID, TInt& aModelCount)
+	{
+
+	TSrsModelBankIDPckg modelBankPckg = aModelBankID;
+	TSrsIntPtrPckg modelCountPtrPckg = &aModelCount;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetModelCount,
+											modelBankPckg, modelCountPtrPckg);
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetRuleValidity
+// Sends a command to the controller to determine if a rule is valid.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::GetRuleValidity(
+	TSIGrammarID aGrammarID, 
+	TSIRuleID aRuleID, TBool& aValid)
+	{
+
+	TSrsRuleValidity srsRuleValidity(aGrammarID, aRuleID, &aValid);
+	TSrsRuleValidityPckg srsRuleValidityPckg(srsRuleValidity);
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrGetRuleValidity,
+											srsRuleValidityPckg, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::LoadGrammar
+// Sends a command to the controller to load the specified grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadGrammar(
+	TSIGrammarID aGrammarID)
+	{
+
+	TSrsGrammarIDPckg pckg = aGrammarID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrLoadGrammar,
+											pckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::ActivateGrammar
+// Sends a command to the controller to activate a grammar
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::ActivateGrammar(
+	TSIGrammarID aGrammarID)
+	{
+	TSrsGrammarIDPckg pckg = aGrammarID;
+	return iController.CustomCommandSync( iDestinationPckg, ESrActivateGrammar,
+                                          pckg, KNullDesC8 ); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::DeactivateGrammar
+// Sends a command to the controller to deactivate a gramamr
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::DeactivateGrammar(
+	TSIGrammarID aGrammarID)
+	{
+	TSrsGrammarIDPckg pckg = aGrammarID;
+	return iController.CustomCommandSync( iDestinationPckg, ESrDeactivateGrammar,
+                                          pckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::LoadLexicon
+// Sends a command to the controller to load the specified lexican.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadLexicon(
+	TSILexiconID aLexiconID)
+	{
+
+	TSrsLexiconIDPckg pckg = aLexiconID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrLoadLexicon,
+											pckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::LoadModels
+// Sends a command to the controller to load all models from a model bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadModels(
+	TSIModelBankID aModelBankID)
+	{
+
+	TSrsModelIDPckg pckg = aModelBankID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrLoadModels,
+											pckg, KNullDesC8);  // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::Record
+// Sends a command to the controller to start recording an utterance for either 
+// training or recognition
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::Record(
+	TTimeIntervalMicroSeconds32 aRecordTime)
+	{
+
+	TSrsTimeIntervalMicroSeconds32Pckg pckg = aRecordTime;
+	return iController.CustomCommandSync(iDestinationPckg, ESrRecord,
+											pckg, KNullDesC8); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemoveGrammar
+// Sends a command to the controller to remove a grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveGrammar(
+	TSIGrammarID aGrammarID)
+	{
+
+	TSrsGrammarIDPckg pckg = aGrammarID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrRemoveGrammar,
+											pckg, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemoveLexicon
+// Sends a command to the controller to remove a lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveLexicon(
+	TSILexiconID aLexiconID)
+	{
+
+	TSrsLexiconIDPckg pckg = aLexiconID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrRemoveLexicon,
+											pckg, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemoveModelBank
+// Sends a command to the controller to remove a model bank and all associated 
+// models.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveModelBank(
+	TSIModelBankID aModelBankID)
+	{
+
+	TSrsModelBankIDPckg modelBankIDPckg = aModelBankID;
+	return iController.CustomCommandSync(iDestinationPckg, ESrRemoveModelBank,
+											modelBankIDPckg, KNullDesC8);
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemoveModel
+// Sends a command to the controller to remove a model from a model bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveModel(
+	TSIModelBankID aModelBankID, 
+	TSIModelID aModelID)
+	{
+
+	TSrsModelBankIDPckg modelBankIDPckg = aModelBankID;
+	TSrsModelIDPckg modelIDPckg = aModelID;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrRemoveModel,
+										modelBankIDPckg, modelIDPckg); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemovePronunciation
+// Sends a command to the controller to remove a pronunciation.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemovePronunciation(
+	TSILexiconID aLexiconID, 
+	TSIPronunciationID aPronunciationID)
+	{
+
+	TSrsLexiconIDPckg lexiconIDPckg = aLexiconID;
+	TSrsPronunciationIDPckg pronunciationIDPckg = aPronunciationID;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrRemovePronunciation,
+										lexiconIDPckg, pronunciationIDPckg); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemoveRule
+// Sends a command to the controller to remove a rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveRule(
+	TSIGrammarID aGrammarID, 
+	TSIRuleID aRuleID)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
+	TSrsRuleIDPckg ruleIDPckg = aRuleID;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrRemoveRule,
+											grammarIDPckg, ruleIDPckg); // Async
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::RemoveRules
+// Sends a command to the controller to remove a rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::RemoveRules(
+	TSIGrammarID aGrammarID, 
+	RArray<TSIRuleID>& aRuleIDs)
+	{
+    RUBY_DEBUG1( "RSISpeechRecognitionCustomCommands::RemoveRules GrammarID [%d]", aGrammarID );
+	
+	TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
+
+    CBufFlat* flatBuf = 0;
+    
+    /** @todo Implement externalize, that takes arrays of Uint32? */
+    TRAPD( err, flatBuf
+        = ExternalizeIntArrayL( reinterpret_cast<RArray<TInt>&> ( aRuleIDs ) ) );
+	
+    if ( err != KErrNone )
+       	{
+       	delete flatBuf;
+       	return err;
+       	}
+	// SRS will signal, when the rule IDs are ready.
+	TInt ret = iController.CustomCommandSync(iDestinationPckg, ESrRemoveRules,
+                                             grammarIDPckg, flatBuf->Ptr(0) ); // Async
+    delete flatBuf;
+
+    return( ret );
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::SetClientUid
+// Sends a command to the controller to set the client UID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::SetClientUid( TUid aClientUid )
+{
+
+	TSrsUidPckg uidPckg = aClientUid;
+	return iController.CustomCommandSync(iDestinationPckg, 
+						ESrSetClientUid, uidPckg, KNullDesC8);
+
+}
+
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::StartRecSession
+// Sends a command to the controller to begin a recognition session.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::StartRecSession(
+	TNSSRecognitionMode aMode)
+	{
+
+	TSrsRecognitionModePckg recognitionModePckg = aMode;
+	TInt err = iController.CustomCommandSync(iDestinationPckg, 
+						ESrStartRecSession, recognitionModePckg, KNullDesC8);
+
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::UnloadRule
+// Sends a command to the controller to add a rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::UnloadRule(
+	TSIGrammarID aGrammarID, 
+	TSIRuleID aRuleID)
+	{
+
+	TSrsGrammarIDPckg grammarIDPckg = aGrammarID;
+	TSrsRuleIDPckg ruleIDPtrPckg = aRuleID;
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrUnloadRule,
+											grammarIDPckg, ruleIDPtrPckg);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::LoadEngineParameters
+// Sends a command to the controller to load the parameters into
+// the engine.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::LoadEngineParameters(
+	const RArray<TInt>& aParameterId, 
+	const RArray<TInt>& aParameterValue)
+	{
+
+	TRAPD(error, DoLoadEngineParametersL(aParameterId, aParameterValue));
+	return error;	
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetPronunciationIDArrayL
+// Sends a command to get the pronunciation ID array.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetPronunciationIDArrayL(
+	RArray<TSIPronunciationID>& aPronunciationIDs)
+	{
+	CleanupClosePushL( aPronunciationIDs );
+	
+	TPckgBuf<TInt> pckgSize;
+	
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetPronunciationIDArraySize, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+	
+
+	HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetPronunciationIDArrayContents,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+													 
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	for (TInt i=0; i<pckgSize(); i++)
+		{
+		User::LeaveIfError(aPronunciationIDs.Append(stream.ReadUint32L()));
+		}
+
+	CleanupStack::PopAndDestroy(2);//stream, buf
+	CleanupStack::Pop();
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetRuleIDArrayL
+// Sends a command to get the rule ID array.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetRuleIDArrayL(
+	RArray<TSIRuleID>& aRuleIDs)
+	{
+	CleanupClosePushL( aRuleIDs );
+
+	TPckgBuf<TInt> pckgSize;
+	
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetRuleIDArraySize, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+												
+	HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetRuleIDArrayContents,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+													 
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	for (TInt i=0; i<pckgSize(); i++)
+		{
+		User::LeaveIfError(aRuleIDs.Append(stream.ReadUint32L()));
+		}
+
+	CleanupStack::PopAndDestroy(2);//stream, buf
+	CleanupStack::Pop();
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetModelIDArrayL
+// Sends a command to get the model ID array.
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetModelIDArrayL(
+	RArray<TSIModelID>& aModelIDs)
+	{
+	CleanupClosePushL( aModelIDs );
+
+	TPckgBuf<TInt> pckgSize;
+	
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetModelIDArraySize, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+												
+	HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetModelIDArrayContents,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+													 
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	for (TInt i=0; i<pckgSize(); i++)
+		{
+		User::LeaveIfError( aModelIDs.Append( (TSIModelID)stream.ReadUint32L() ) );
+		}
+
+	CleanupStack::PopAndDestroy( 2 );//stream, buf
+	CleanupStack::Pop();
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetGrammarIDArrayL
+// Sends a command to get the grammar ID array.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetGrammarIDArrayL(
+	RArray<TSIGrammarID>& aGrammarIDs)
+	{
+	CleanupClosePushL( aGrammarIDs );
+	
+	TPckgBuf<TInt> pckgSize;
+	
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetGrammarIDArraySize, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+												
+	HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetGrammarIDArrayContents,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+													 
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	for ( TInt i = 0; i < pckgSize(); i++ )
+		{
+		User::LeaveIfError( aGrammarIDs.Append( (TSIGrammarID)stream.ReadUint32L() ) );
+		}
+
+	CleanupStack::PopAndDestroy( 2 );//stream, buf
+	CleanupStack::Pop();//aGrammarIDs
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL
+// Sends a command to get the lexicon ID array.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL(
+	RArray<TSILexiconID>& aLexiconIDs)
+	{
+	CleanupClosePushL( aLexiconIDs );
+
+	TPckgBuf<TInt> pckgSize;
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetLexiconIDArraySize, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+
+    TInt size = pckgSize();
+	HBufC8* buf = HBufC8::NewLC(size*sizeof(TUint32));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetLexiconIDArrayContents,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	for ( TInt i = 0; i < pckgSize(); i++ )
+		{
+		User::LeaveIfError( aLexiconIDs.Append( (TSILexiconID)stream.ReadUint32L() ) );
+		}
+
+	CleanupStack::PopAndDestroy(2);//stream, buf
+	CleanupStack::Pop();
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetLexiconIDArrayL
+// Sends a command to get the lexicon ID array.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetModelBankIDArrayL(
+	RArray<TSIModelBankID>& aModelBankIDs)
+	{
+	CleanupClosePushL( aModelBankIDs );
+
+	TPckgBuf<TInt> pckgSize;
+	
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetModelBankIDArraySize, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+												
+	HBufC8* buf = HBufC8::NewLC(pckgSize()*sizeof(TUint32));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetModelBankIDArrayContents,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+													 
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	for ( TInt i = 0; i < pckgSize(); i++ )
+		{
+		User::LeaveIfError( aModelBankIDs.Append( (TSIModelBankID)stream.ReadUint32L() ) );
+		}
+
+	CleanupStack::PopAndDestroy(2);//stream, buf
+	CleanupStack::Pop();
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::GetSIResultSetL
+// Sends a command to get the speaker independent recognition result set.
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C void RSISpeechRecognitionCustomCommands::GetSIResultSetL(
+	CSIClientResultSet& aResultSet)
+	{
+	
+	TPckgBuf<TInt> pckgSize;
+	
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetClientResultSetSizeSI, 
+												KNullDesC8,
+												KNullDesC8,
+												pckgSize));
+
+	HBufC8* buf = HBufC8::NewLC( pckgSize() );
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+													 ESrGetClientResultSet,
+													 KNullDesC8,
+													 KNullDesC8,
+													 ptr));
+
+	RDesReadStream stream(ptr);
+	CleanupClosePushL(stream);
+
+	aResultSet.InternalizeL(stream);
+	CleanupStack::PopAndDestroy(2);//stream, buf
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::DoRecognizeL
+// Sends a command to get the recognition result set.
+// -----------------------------------------------------------------------------
+//	
+void RSISpeechRecognitionCustomCommands::DoRecognizeL(CSDClientResultSet& /*aResultSet*/)
+	{
+    RUBY_DEBUG0( "RSISpeechRecognitionCustomCommands::DoRecognizeL is NOT supported" );
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::DoRecognizeSIL
+// Sends a command to get the recognition result set.
+// -----------------------------------------------------------------------------
+//	
+void RSISpeechRecognitionCustomCommands::DoRecognizeSIL(CSIClientResultSet& aResultSet)
+	{
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+
+	aResultSet.ExternalizeL(stream);
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
+												ESrRecognizeSI,
+												dataCopyBuffer->Ptr(0),
+												KNullDesC8));
+
+	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::DoGetEnginePropertiesL
+// Sends a command to get the engine properties.
+// -----------------------------------------------------------------------------
+//	
+void RSISpeechRecognitionCustomCommands::DoGetEnginePropertiesL(
+	const RArray<TInt>& aPropertyId, 
+	RArray<TInt>& aPropertyValue)
+	{
+	
+	CBufFlat* param1 = ExternalizeIntArrayL(aPropertyId);
+	CleanupStack::PushL(param1);
+	
+	TInt aNumberResults = aPropertyId.Count(); // same number of values as properties
+	
+	HBufC8* buf = HBufC8::NewLC(aNumberResults *sizeof(TInt));
+	TPtr8 ptr = buf->Des();
+
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrGetEngineProperties, 
+												param1->Ptr(0),
+												KNullDesC8,
+												ptr));
+
+	
+	InternalizeIntArrayL(ptr,aNumberResults,aPropertyValue);
+	CleanupStack::PopAndDestroy(2);//buf,param1
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::DoLoadEngineParametersL
+// Sends a command to load the engine parameters.
+// -----------------------------------------------------------------------------
+//	
+void RSISpeechRecognitionCustomCommands::DoLoadEngineParametersL(
+	const RArray<TInt>& aParameterId, 
+	const RArray<TInt>& aParameterValue)
+	{
+
+	CBufFlat* param1 = ExternalizeIntArrayL(aParameterId);
+	CleanupStack::PushL(param1);
+	CBufFlat* param2 = ExternalizeIntArrayL(aParameterValue);
+	CleanupStack::PushL(param2);
+	User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg, 
+												ESrLoadEngineParameters, 
+												param1->Ptr(0),
+												param2->Ptr(0)));
+												
+	CleanupStack::PopAndDestroy(2); //param2, param1	
+
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::ExternalizeIntArrayL
+// Externalizes an interger array.
+// -----------------------------------------------------------------------------
+//	
+CBufFlat* RSISpeechRecognitionCustomCommands::ExternalizeIntArrayL(
+	const RArray<TInt>& aArray)
+	{
+
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
+	CleanupStack::PushL(dataCopyBuffer);
+	RBufWriteStream stream;
+	stream.Open(*dataCopyBuffer);
+	CleanupClosePushL(stream);
+	
+	stream.WriteInt32L(aArray.Count());
+	
+	for (TInt i=0;i<aArray.Count();i++)
+		stream.WriteUint32L(aArray[i]);
+
+	CleanupStack::PopAndDestroy(1); //stream
+	CleanupStack::Pop(); //dataCopyBuffer;
+	return dataCopyBuffer;	
+	
+	}
+
+// -----------------------------------------------------------------------------
+// RSISpeechRecognitionCustomCommands::InternalizeIntArrayL
+// Internalizes an interger array.
+// -----------------------------------------------------------------------------
+//
+void RSISpeechRecognitionCustomCommands::InternalizeIntArrayL(
+	TDes8& aDes, 
+	TInt aNumberElements, 
+	RArray<TInt>& aArray)
+	{
+	CleanupClosePushL( aArray );
+
+	RDesReadStream stream(aDes);
+	CleanupClosePushL(stream);
+
+	for (TInt i=0; i<aNumberElements; i++)
+		{
+		User::LeaveIfError(aArray.Append(stream.ReadInt32L()));
+		}
+
+	CleanupStack::PopAndDestroy();//stream
+	CleanupStack::Pop();
+	}
+
+/************************** New SI functions start here ***********************/
+
+// -----------------------------------------------------------------------------
+// Adapts speaker independent models according using a correct recognition result.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::Adapt(const CSIClientResultSet& aResultSet, TInt aCorrect)
+    {
+    CBufFlat* dataBuf = 0;
+    RBufWriteStream dataStream;
+    TInt ret = KErrNone;
+    TBool forever = ETrue;
+
+    TPckgBuf<TInt> correctPckg( aCorrect );
+
+    while(forever)
+        {
+// Poor man's exception handling: while and break
+#define BREAK( error ) if ( error != KErrNone ) { break; }
+
+        // Allocate buffer for storing CSIClientResultSet
+        TRAP ( ret, dataBuf = CBufFlat::NewL( KExpandSize ) );
+        BREAK( ret );
+
+        // Open a stream to the buffer
+        dataStream.Open( *dataBuf );
+
+        // Pack the data
+        TRAP ( ret, aResultSet.ExternalizeL( dataStream ) );
+        BREAK( ret );
+
+        // Send through MMF
+        ret = iController.CustomCommandSync(
+            iDestinationPckg,
+            ESrAdapt,
+            dataBuf->Ptr( 0 ),
+            correctPckg );
+
+        break;
+        }
+
+    dataStream.Close();
+    delete dataBuf;
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// Adds a pronunciation to the given lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddPronunciation(
+    TSILexiconID aLexiconID,
+    const TDesC& aTrainText,
+    TLanguage aLanguage,
+    TSIPronunciationID& aPronunciationID)
+    {
+    TSrsAddPronunciationSI srsAddPronunciation( aLexiconID, aTrainText.Length(),
+                                                aLanguage, aPronunciationID );
+    TSrsAddPronunciationSIPckg pckg( srsAddPronunciation );
+
+    TInt    trainTextSize( aTrainText.Size() );
+    TUint8* trainTextPtr = (TUint8*)aTrainText.Ptr();
+    TPtrC8  trainTextDes( trainTextPtr, trainTextSize );
+
+    return iController.CustomCommandSync(iDestinationPckg, ESrAddPronunciationSI,
+                                         pckg, trainTextDes );
+    }
+
+// -----------------------------------------------------------------------------
+// Adds a rule variant to a rule in a grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddRuleVariant(
+    TSIGrammarID aGrammarID,
+    TSILexiconID aLexiconID,
+    const RArray<TSIPronunciationID>& aPronunciationIDs,
+    TSIRuleID aRuleID,
+    TSIRuleVariantID& aRuleVariantID )
+    {
+    TSrsAddRuleVariant srsAddRuleVariant( aGrammarID,
+                                          aLexiconID,
+                                          aPronunciationIDs.Count(),
+                                          aRuleID,
+                                          &aRuleVariantID );
+    TSrsAddRuleVariantPckg pckg( srsAddRuleVariant );
+
+    TUint8* pronunIdPtr = (TUint8*)&(aPronunciationIDs[0]);
+    TPtrC8  pronunIdDes( pronunIdPtr, 
+                         sizeof( TSIPronunciationID ) * aPronunciationIDs.Count()
+                         );
+
+    return iController.CustomCommandSync(iDestinationPckg, ESrAddRuleVariant,
+                                         pckg, pronunIdDes );
+    }
+
+// -----------------------------------------------------------------------------
+// Trains a voice tag. Adds the text to the lexicon, and creates the required
+// rules and rule variants.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTag(
+    const MDesCArray& aTrainArray,
+    const RArray<TLanguage>& aLanguageArray,
+    TSILexiconID aLexiconID,
+    TSIGrammarID aGrammarID,
+    TSIRuleID& aRuleID)
+    {
+    TSrsAddVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, &aRuleID, aLanguageArray );
+    TSrsAddVoiceTagPckg pckg( srsAddVoiceTagData );
+
+    CBufFlat* flatBuf = 0;
+    TRAPD( err, flatBuf
+        = SICustomCommandData::ExternalizeDesCArrayL( aTrainArray ) );
+
+    if ( err != KErrNone )
+        return( err );
+
+    // SRS will signal, when the rule IDs are ready.
+	TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddVoiceTag,
+                                              pckg, flatBuf->Ptr( 0 ) ); // Async
+
+    delete flatBuf;
+
+    return( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// Trains voice tags. If the training fails for some of the names (but not all),
+// it is signaled by setting the Rule ID to KInvalidRuleID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTags(
+    const RPointerArray<MDesCArray>& aTrainArray,
+    const RArray<TLanguage>& aLanguageArray,
+    TSILexiconID aLexiconID,
+    TSIGrammarID aGrammarID,
+    RArray<TSIRuleID>& /*aRuleID*/)
+    {
+    TSrsAddVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, NULL, aLanguageArray );
+    TSrsAddVoiceTagPckg pckg( srsAddVoiceTagData );
+
+    CBufFlat* flatBuf = 0;
+    TRAPD( err, flatBuf
+        = SICustomCommandData::ExternalizeDesCArrayArrayL( aTrainArray ) );
+
+    if ( err != KErrNone )
+        {
+        delete flatBuf;
+        return err;
+        }
+
+    // SRS will signal, when the rule IDs are ready.
+	TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddVoiceTags,
+                                              pckg, flatBuf->Ptr( 0 ) ); // Async
+    delete flatBuf;
+
+    return( ret );
+    }
+
+#ifdef __SINDE_TRAINING
+// -----------------------------------------------------------------------------
+// Trains a voice tag. Adds the text to the lexicon, and creates the required
+// rules and rule variants.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTag( const MDesCArray& aTrainArray,
+                                                               const RArray<RLanguageArray>& aLanguageArray,
+                                                               TSILexiconID aLexiconID,
+                                                               TSIGrammarID aGrammarID,
+                                                               TSIRuleID& aRuleID )
+    {
+    TSrsAddSindeVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, &aRuleID, aLanguageArray );
+    TSrsAddSindeVoiceTagPckg pckg( srsAddVoiceTagData );
+
+    CBufFlat* flatBuf( NULL );
+    TRAPD( err, flatBuf = SICustomCommandData::ExternalizeDesCArrayL( aTrainArray ) );
+
+    if ( err != KErrNone )
+        {
+        return err;
+        }
+
+    // SRS plugin will signal, when the rule IDs are ready.
+	TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddSindeVoiceTag,
+                                              pckg, flatBuf->Ptr( 0 ) ); // Async
+
+    delete flatBuf;
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// Trains voice tags. If the training fails for some of the names (but not all),
+// it is signaled by setting the Rule ID to KInvalidRuleID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::AddVoiceTags( const RPointerArray<MDesCArray>& aTrainArray,
+                                                                const RArray<RLanguageArray>& aLanguageArray,
+                                                                TSILexiconID aLexiconID,
+                                                                TSIGrammarID aGrammarID,
+                                                                RArray<TSIRuleID>& /*aRuleID*/)
+    {
+    TSrsAddSindeVoiceTag srsAddVoiceTagData( aLexiconID, aGrammarID, NULL, aLanguageArray );
+    TSrsAddSindeVoiceTagPckg pckg( srsAddVoiceTagData );
+
+    CBufFlat* flatBuf( NULL );
+    TRAPD( err, flatBuf = SICustomCommandData::ExternalizeDesCArrayArrayL( aTrainArray ) );
+
+    if ( err != KErrNone )
+        {
+        delete flatBuf;
+        return err;
+        }
+
+    // SRS plugin will signal, when the rule IDs are ready.
+	TInt ret = iController.CustomCommandSync( iDestinationPckg, ESrAddSindeVoiceTags,
+                                              pckg, flatBuf->Ptr( 0 ) ); // Async
+    delete flatBuf;
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// Pre-starts sampling before Record() call
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::PreStartSampling()
+    {
+    return iController.CustomCommandSync( iDestinationPckg, ESrPreStartSampling,
+                                          KNullDesC8, KNullDesC8 ); // Async      
+    }
+    
+#endif // SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// Creates a new rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::CreateRule(TSIGrammarID aGrammarID, TSIRuleID& aRuleID)
+    {
+    TSrsAddRule srsCreateRule( aGrammarID, KInvalidLexiconID, KInvalidPronunciationID, &aRuleID );
+    TSrsAddRulePckg pckg( srsCreateRule );
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrCreateRule,
+                                         pckg, KNullDesC8 ); // Async    
+    }
+
+// -----------------------------------------------------------------------------
+// Starts recognition
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::Recognize( CSIClientResultSet& aResultSet )
+    {
+    TRAPD( err, DoRecognizeSIL( aResultSet ) );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// Stops recognition. Unlike Cancel(), this function gives
+// the recognition result, if it can be guessed.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::EndRecord()
+    {
+    return iController.CustomCommandSync( iDestinationPckg, ESrEndRecord,
+                                          KNullDesC8, KNullDesC8 ); // Async
+    }
+
+// -----------------------------------------------------------------------------
+// Deactivates a grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSISpeechRecognitionCustomCommands::UnloadGrammar( TSIGrammarID aGrammarID )
+    {
+    TSrsGrammarIDPckg pckg( aGrammarID );
+
+	return iController.CustomCommandSync(iDestinationPckg, ESrUnloadGrammar,
+                                         pckg, KNullDesC8 ); // Async
+    }
+
+
+/************************** New SI functions stop here ************************/
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/bmarm/nsssispeechrecognitiondatau.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,183 @@
+EXPORTS
+	__9CSIResult @ 1 NONAME R3UNUSED ; CSIResult::CSIResult(void)
+	AdaptationData__12CSIResultSet @ 2 NONAME R3UNUSED ; CSIResultSet::AdaptationData(void)
+	AddL__10CSIGrammarP7CSIRule @ 3 NONAME R3UNUSED ; CSIGrammar::AddL(CSIRule *)
+	AddL__10CSILexiconP16CSIPronunciation @ 4 NONAME R3UNUSED ; CSILexicon::AddL(CSIPronunciation *)
+	AddL__12CSIModelBankPC8CSIModel @ 5 NONAME R3UNUSED ; CSIModelBank::AddL(CSIModel const *)
+	AddL__12CSIResultSetPC9CSIResult @ 6 NONAME R3UNUSED ; CSIResultSet::AddL(CSIResult const *)
+	AddL__14CSITtpWordListP12MDesC16Array @ 7 NONAME R3UNUSED ; CSITtpWordList::AddL(MDesC16Array *)
+	AddL__18CSIClientResultSetPC15CSIClientResult @ 8 NONAME R3UNUSED ; CSIClientResultSet::AddL(CSIClientResult const *)
+	AddL__18CSICompiledGrammarP7CSIRule @ 9 NONAME R3UNUSED ; CSICompiledGrammar::AddL(CSIRule *)
+	AddL__7CSIRuleP14CSIRuleVariant @ 10 NONAME R3UNUSED ; CSIRule::AddL(CSIRuleVariant *)
+	AppendPronunciationL__14CSITtpWordListiP20CSIPronunciationInfo @ 11 NONAME R3UNUSED ; CSITtpWordList::AppendPronunciationL(int, CSIPronunciationInfo *)
+	AtL__12CSIResultSeti @ 12 NONAME R3UNUSED ; CSIResultSet::AtL(int)
+	AtL__C10CSIGrammari @ 13 NONAME R3UNUSED ; CSIGrammar::AtL(int) const
+	AtL__C10CSILexiconi @ 14 NONAME R3UNUSED ; CSILexicon::AtL(int) const
+	AtL__C12CSIModelBanki @ 15 NONAME R3UNUSED ; CSIModelBank::AtL(int) const
+	AtL__C12CSIResultSeti @ 16 NONAME R3UNUSED ; CSIResultSet::AtL(int) const
+	AtL__C14CSITtpWordListi @ 17 NONAME R3UNUSED ; CSITtpWordList::AtL(int) const
+	AtL__C18CSIClientResultSeti @ 18 NONAME R3UNUSED ; CSIClientResultSet::AtL(int) const
+	AtL__C7CSIRulei @ 19 NONAME R3UNUSED ; CSIRule::AtL(int) const
+	CompiledData__C18CSICompiledGrammar @ 20 NONAME R3UNUSED ; CSICompiledGrammar::CompiledData(void) const
+	ConstructL__10CSIGrammar @ 21 NONAME R3UNUSED ; CSIGrammar::ConstructL(void)
+	ConstructL__10CSILexicon @ 22 NONAME R3UNUSED ; CSILexicon::ConstructL(void)
+	ConstructL__12CSIModelBank @ 23 NONAME R3UNUSED ; CSIModelBank::ConstructL(void)
+	ConstructL__12CSIResultSet @ 24 NONAME R3UNUSED ; CSIResultSet::ConstructL(void)
+	ConstructL__13CSIParameters @ 25 NONAME R3UNUSED ; CSIParameters::ConstructL(void)
+	ConstructL__14CSIRuleVariant @ 26 NONAME R3UNUSED ; CSIRuleVariant::ConstructL(void)
+	ConstructL__14CSITtpWordList @ 27 NONAME R3UNUSED ; CSITtpWordList::ConstructL(void)
+	ConstructL__16CSIPronunciation @ 28 NONAME R3UNUSED ; CSIPronunciation::ConstructL(void)
+	ConstructL__18CSICompiledGrammar @ 29 NONAME R3UNUSED ; CSICompiledGrammar::ConstructL(void)
+	ConstructL__20CSIPronunciationInfo @ 30 NONAME R3UNUSED ; CSIPronunciationInfo::ConstructL(void)
+	ConstructL__7CSIRule @ 31 NONAME R3UNUSED ; CSIRule::ConstructL(void)
+	ConstructL__8CSIModel @ 32 NONAME R3UNUSED ; CSIModel::ConstructL(void)
+	ConstructL__9CSIResult @ 33 NONAME R3UNUSED ; CSIResult::ConstructL(void)
+	Count__C10CSIGrammar @ 34 NONAME R3UNUSED ; CSIGrammar::Count(void) const
+	Count__C10CSILexicon @ 35 NONAME R3UNUSED ; CSILexicon::Count(void) const
+	Count__C12CSIModelBank @ 36 NONAME R3UNUSED ; CSIModelBank::Count(void) const
+	Count__C12CSIResultSet @ 37 NONAME R3UNUSED ; CSIResultSet::Count(void) const
+	Count__C14CSITtpWordList @ 38 NONAME R3UNUSED ; CSITtpWordList::Count(void) const
+	Count__C20CSIPronunciationInfo @ 39 NONAME R3UNUSED ; CSIPronunciationInfo::Count(void) const
+	Count__C7CSIRule @ 40 NONAME R3UNUSED ; CSIRule::Count(void) const
+	DeleteL__10CSIGrammarUl @ 41 NONAME R3UNUSED ; CSIGrammar::DeleteL(unsigned long)
+	DeleteL__10CSILexiconUl @ 42 NONAME R3UNUSED ; CSILexicon::DeleteL(unsigned long)
+	DeleteL__12CSIModelBankUs @ 43 NONAME R3UNUSED ; CSIModelBank::DeleteL(unsigned short)
+	DeleteL__12CSIResultSeti @ 44 NONAME R3UNUSED ; CSIResultSet::DeleteL(int)
+	DeleteL__14CSITtpWordListi @ 45 NONAME R3UNUSED ; CSITtpWordList::DeleteL(int)
+	DeleteL__18CSIClientResultSeti @ 46 NONAME R3UNUSED ; CSIClientResultSet::DeleteL(int)
+	DeleteL__18CSICompiledGrammarUl @ 47 NONAME R3UNUSED ; CSICompiledGrammar::DeleteL(unsigned long)
+	DeleteL__7CSIRuleUc @ 48 NONAME R3UNUSED ; CSIRule::DeleteL(unsigned char)
+	ExternalizeL__C10CSIGrammarR12RWriteStream @ 49 NONAME R3UNUSED ; CSIGrammar::ExternalizeL(RWriteStream &) const
+	ExternalizeL__C10CSILexiconR12RWriteStream @ 50 NONAME R3UNUSED ; CSILexicon::ExternalizeL(RWriteStream &) const
+	ExternalizeL__C12CSIResultSetR12RWriteStream @ 51 NONAME R3UNUSED ; CSIResultSet::ExternalizeL(RWriteStream &) const
+	ExternalizeL__C13CSIParametersR12RWriteStream @ 52 NONAME R3UNUSED ; CSIParameters::ExternalizeL(RWriteStream &) const
+	ExternalizeL__C18CSIClientResultSetR12RWriteStream @ 53 NONAME R3UNUSED ; CSIClientResultSet::ExternalizeL(RWriteStream &) const
+	ExternalizeL__C18CSICompiledGrammarR12RWriteStream @ 54 NONAME R3UNUSED ; CSICompiledGrammar::ExternalizeL(RWriteStream &) const
+	Find__C10CSIGrammarUl @ 55 NONAME R3UNUSED ; CSIGrammar::Find(unsigned long) const
+	Find__C10CSILexiconRC6TDesC8 @ 56 NONAME R3UNUSED ; CSILexicon::Find(TDesC8 const &) const
+	Find__C10CSILexiconUl @ 57 NONAME R3UNUSED ; CSILexicon::Find(unsigned long) const
+	Find__C12CSIModelBankUs @ 58 NONAME R3UNUSED ; CSIModelBank::Find(unsigned short) const
+	Find__C7CSIRuleUc @ 59 NONAME R3UNUSED ; CSIRule::Find(unsigned char) const
+	GetPronunciationIDsL__C14CSIRuleVariantRt6RArray1ZUl @ 60 NONAME R3UNUSED ; CSIRuleVariant::GetPronunciationIDsL(RArray<unsigned long> &) const
+	GetPronunciationsL__C14CSITtpWordListiRt13RPointerArray1Z20CSIPronunciationInfo @ 61 NONAME R3UNUSED ; CSITtpWordList::GetPronunciationsL(int, RPointerArray<CSIPronunciationInfo> &) const
+	GrammarID__C10CSIGrammar @ 62 NONAME R3UNUSED ; CSIGrammar::GrammarID(void) const
+	GrammarID__C15CSIClientResult @ 63 NONAME R3UNUSED ; CSIClientResult::GrammarID(void) const
+	GrammarID__C18TSIRuleVariantInfo @ 64 NONAME R3UNUSED ; TSIRuleVariantInfo::GrammarID(void) const
+	GrammarID__C9CSIResult @ 65 NONAME R3UNUSED ; CSIResult::GrammarID(void) const
+	InternalizeL__10CSIGrammarR11RReadStream @ 66 NONAME R3UNUSED ; CSIGrammar::InternalizeL(RReadStream &)
+	InternalizeL__10CSILexiconR11RReadStream @ 67 NONAME R3UNUSED ; CSILexicon::InternalizeL(RReadStream &)
+	InternalizeL__12CSIResultSetR11RReadStream @ 68 NONAME R3UNUSED ; CSIResultSet::InternalizeL(RReadStream &)
+	InternalizeL__13CSIParametersR11RReadStream @ 69 NONAME R3UNUSED ; CSIParameters::InternalizeL(RReadStream &)
+	InternalizeL__18CSIClientResultSetR11RReadStream @ 70 NONAME R3UNUSED ; CSIClientResultSet::InternalizeL(RReadStream &)
+	InternalizeL__18CSICompiledGrammarR11RReadStream @ 71 NONAME R3UNUSED ; CSICompiledGrammar::InternalizeL(RReadStream &)
+	Language__C14CSIRuleVariant @ 72 NONAME R3UNUSED ; CSIRuleVariant::Language(void) const
+	Language__C20CSIPronunciationInfo @ 73 NONAME R3UNUSED ; CSIPronunciationInfo::Language(void) const
+	LexiconID__C10CSILexicon @ 74 NONAME R3UNUSED ; CSILexicon::LexiconID(void) const
+	LexiconID__C14CSIRuleVariant @ 75 NONAME R3UNUSED ; CSIRuleVariant::LexiconID(void) const
+	ListParametersL__C13CSIParametersRt6RArray1ZiT1 @ 76 NONAME R3UNUSED ; CSIParameters::ListParametersL(RArray<int> &, RArray<int> &) const
+	MaxResults__C18CSIClientResultSet @ 77 NONAME R3UNUSED ; CSIClientResultSet::MaxResults(void) const
+	ModelBankID__C12CSIModelBank @ 78 NONAME R3UNUSED ; CSIModelBank::ModelBankID(void) const
+	ModelBankID__C16CSIPronunciation @ 79 NONAME R3UNUSED ; CSIPronunciation::ModelBankID(void) const
+	ModelID__C8CSIModel @ 80 NONAME R3UNUSED ; CSIModel::ModelID(void) const
+	NewLC__10CSIGrammarUs @ 81 NONAME R3UNUSED ; CSIGrammar::NewLC(unsigned short)
+	NewLC__10CSILexiconUs @ 82 NONAME R3UNUSED ; CSILexicon::NewLC(unsigned short)
+	NewLC__12CSIModelBankUs @ 83 NONAME R3UNUSED ; CSIModelBank::NewLC(unsigned short)
+	NewLC__12CSIResultSet @ 84 NONAME R3UNUSED ; CSIResultSet::NewLC(void)
+	NewLC__13CSIParameters @ 85 NONAME R3UNUSED ; CSIParameters::NewLC(void)
+	NewLC__14CSIRuleVariantUcUs @ 86 NONAME R3UNUSED ; CSIRuleVariant::NewLC(unsigned char, unsigned short)
+	NewLC__14CSITtpWordList @ 87 NONAME R3UNUSED ; CSITtpWordList::NewLC(void)
+	NewLC__15CSIClientResult @ 88 NONAME R3UNUSED ; CSIClientResult::NewLC(void)
+	NewLC__15CSIClientResultUsUl @ 89 NONAME R3UNUSED ; CSIClientResult::NewLC(unsigned short, unsigned long)
+	NewLC__16CSIPronunciationUlUs @ 90 NONAME R3UNUSED ; CSIPronunciation::NewLC(unsigned long, unsigned short)
+	NewLC__18CSIClientResultSet @ 91 NONAME R3UNUSED ; CSIClientResultSet::NewLC(void)
+	NewLC__18CSICompiledGrammarUs @ 92 NONAME R3UNUSED ; CSICompiledGrammar::NewLC(unsigned short)
+	NewLC__20CSIPronunciationInfoGt13RPointerArray1Z6HBufC89TLanguage @ 93 NONAME ; CSIPronunciationInfo::NewLC(RPointerArray<HBufC8>, TLanguage)
+	NewLC__7CSIRuleUl @ 94 NONAME R3UNUSED ; CSIRule::NewLC(unsigned long)
+	NewLC__8CSIModelUs @ 95 NONAME R3UNUSED ; CSIModel::NewLC(unsigned short)
+	NewLC__9CSIResult @ 96 NONAME R3UNUSED ; CSIResult::NewLC(void)
+	NewL__10CSIGrammarUs @ 97 NONAME R3UNUSED ; CSIGrammar::NewL(unsigned short)
+	NewL__10CSILexiconUs @ 98 NONAME R3UNUSED ; CSILexicon::NewL(unsigned short)
+	NewL__12CSIModelBankUs @ 99 NONAME R3UNUSED ; CSIModelBank::NewL(unsigned short)
+	NewL__12CSIResultSet @ 100 NONAME R3UNUSED ; CSIResultSet::NewL(void)
+	NewL__13CSIParameters @ 101 NONAME R3UNUSED ; CSIParameters::NewL(void)
+	NewL__14CSIRuleVariantUcUs @ 102 NONAME R3UNUSED ; CSIRuleVariant::NewL(unsigned char, unsigned short)
+	NewL__14CSITtpWordList @ 103 NONAME R3UNUSED ; CSITtpWordList::NewL(void)
+	NewL__15CSIClientResult @ 104 NONAME R3UNUSED ; CSIClientResult::NewL(void)
+	NewL__15CSIClientResultUsUl @ 105 NONAME R3UNUSED ; CSIClientResult::NewL(unsigned short, unsigned long)
+	NewL__16CSIPronunciationUlUs @ 106 NONAME R3UNUSED ; CSIPronunciation::NewL(unsigned long, unsigned short)
+	NewL__18CSIClientResultSet @ 107 NONAME R3UNUSED ; CSIClientResultSet::NewL(void)
+	NewL__18CSICompiledGrammarUs @ 108 NONAME R3UNUSED ; CSICompiledGrammar::NewL(unsigned short)
+	NewL__20CSIPronunciationInfoGt13RPointerArray1Z6HBufC89TLanguage @ 109 NONAME ; CSIPronunciationInfo::NewL(RPointerArray<HBufC8>, TLanguage)
+	NewL__7CSIRuleUl @ 110 NONAME R3UNUSED ; CSIRule::NewL(unsigned long)
+	NewL__8CSIModelUs @ 111 NONAME R3UNUSED ; CSIModel::NewL(unsigned short)
+	NewL__9CSIResult @ 112 NONAME R3UNUSED ; CSIResult::NewL(void)
+	ParameterL__C13CSIParametersi @ 113 NONAME R3UNUSED ; CSIParameters::ParameterL(int) const
+	PhonemeSequence__C16CSIPronunciation @ 114 NONAME R3UNUSED ; CSIPronunciation::PhonemeSequence(void) const
+	PronunciationID__C16CSIPronunciation @ 115 NONAME R3UNUSED ; CSIPronunciation::PronunciationID(void) const
+	PronunciationL__C20CSIPronunciationInfoi @ 116 NONAME R3UNUSED ; CSIPronunciationInfo::PronunciationL(int) const
+	Pronunciation__C9CSIResult @ 117 NONAME R3UNUSED ; CSIResult::Pronunciation(void) const
+	ResultCount__C18CSIClientResultSet @ 118 NONAME R3UNUSED ; CSIClientResultSet::ResultCount(void) const
+	RuleID__C15CSIClientResult @ 119 NONAME R3UNUSED ; CSIClientResult::RuleID(void) const
+	RuleID__C18TSIRuleVariantInfo @ 120 NONAME R3UNUSED ; TSIRuleVariantInfo::RuleID(void) const
+	RuleID__C7CSIRule @ 121 NONAME R3UNUSED ; CSIRule::RuleID(void) const
+	RuleID__C9CSIResult @ 122 NONAME R3UNUSED ; CSIResult::RuleID(void) const
+	RuleL__C10CSIGrammarUl @ 123 NONAME R3UNUSED ; CSIGrammar::RuleL(unsigned long) const
+	RuleVariantID__C14CSIRuleVariant @ 124 NONAME R3UNUSED ; CSIRuleVariant::RuleVariantID(void) const
+	RuleVariantID__C18TSIRuleVariantInfo @ 125 NONAME R3UNUSED ; TSIRuleVariantInfo::RuleVariantID(void) const
+	RuleVariantID__C9CSIResult @ 126 NONAME R3UNUSED ; CSIResult::RuleVariantID(void) const
+	RuleVariantL__C7CSIRuleUc @ 127 NONAME R3UNUSED ; CSIRule::RuleVariantL(unsigned char) const
+	SIResultSet__C18CSIClientResultSet @ 128 NONAME R3UNUSED ; CSIClientResultSet::SIResultSet(void) const
+	Score__C9CSIResult @ 129 NONAME R3UNUSED ; CSIResult::Score(void) const
+	SetAcousticModel__8CSIModelP6HBufC8 @ 130 NONAME R3UNUSED ; CSIModel::SetAcousticModel(HBufC8 *)
+	SetAdaptationData__12CSIResultSetP6HBufC8 @ 131 NONAME R3UNUSED ; CSIResultSet::SetAdaptationData(HBufC8 *)
+	SetCompiledData__18CSICompiledGrammarP6HBufC8 @ 132 NONAME R3UNUSED ; CSICompiledGrammar::SetCompiledData(HBufC8 *)
+	SetGrammarID__15CSIClientResultUs @ 133 NONAME R3UNUSED ; CSIClientResult::SetGrammarID(unsigned short)
+	SetGrammarID__9CSIResultUs @ 134 NONAME R3UNUSED ; CSIResult::SetGrammarID(unsigned short)
+	SetLanguage__14CSIRuleVariant9TLanguage @ 135 NONAME R3UNUSED ; CSIRuleVariant::SetLanguage(TLanguage)
+	SetMaxResultsL__18CSIClientResultSeti @ 136 NONAME R3UNUSED ; CSIClientResultSet::SetMaxResultsL(int)
+	SetModelID__8CSIModelUs @ 137 NONAME R3UNUSED ; CSIModel::SetModelID(unsigned short)
+	SetParameterL__13CSIParametersii @ 138 NONAME R3UNUSED ; CSIParameters::SetParameterL(int, int)
+	SetPhonemeSequenceL__16CSIPronunciationRC6TDesC8 @ 139 NONAME R3UNUSED ; CSIPronunciation::SetPhonemeSequenceL(TDesC8 const &)
+	SetPronunciationIDsL__14CSIRuleVariantRCt6RArray1ZUl @ 140 NONAME R3UNUSED ; CSIRuleVariant::SetPronunciationIDsL(RArray<unsigned long> const &)
+	SetPronunciationL__20CSIPronunciationInfoiP6HBufC8 @ 141 NONAME R3UNUSED ; CSIPronunciationInfo::SetPronunciationL(int, HBufC8 *)
+	SetPronunciation__9CSIResultP16CSIPronunciation @ 142 NONAME R3UNUSED ; CSIResult::SetPronunciation(CSIPronunciation *)
+	SetResultCount__18CSIClientResultSeti @ 143 NONAME R3UNUSED ; CSIClientResultSet::SetResultCount(int)
+	SetRuleID__15CSIClientResultUl @ 144 NONAME R3UNUSED ; CSIClientResult::SetRuleID(unsigned long)
+	SetRuleID__9CSIResultUl @ 145 NONAME R3UNUSED ; CSIResult::SetRuleID(unsigned long)
+	SetRuleVariantID__9CSIResultUc @ 146 NONAME R3UNUSED ; CSIResult::SetRuleVariantID(unsigned char)
+	SetSIResultSet__18CSIClientResultSetP12CSIResultSet @ 147 NONAME R3UNUSED ; CSIClientResultSet::SetSIResultSet(CSIResultSet *)
+	SetScore__9CSIResultl @ 148 NONAME R3UNUSED ; CSIResult::SetScore(long)
+	"_._10CSIGrammar" @ 149 NONAME R3UNUSED ; CSIGrammar::~CSIGrammar(void)
+	"_._10CSILexicon" @ 150 NONAME R3UNUSED ; CSILexicon::~CSILexicon(void)
+	"_._12CSIModelBank" @ 151 NONAME R3UNUSED ; CSIModelBank::~CSIModelBank(void)
+	"_._12CSIResultSet" @ 152 NONAME R3UNUSED ; CSIResultSet::~CSIResultSet(void)
+	"_._13CSIParameters" @ 153 NONAME R3UNUSED ; CSIParameters::~CSIParameters(void)
+	"_._13TSIDiagnostic" @ 154 NONAME R3UNUSED ; TSIDiagnostic::~TSIDiagnostic(void)
+	"_._14CSIRuleVariant" @ 155 NONAME R3UNUSED ; CSIRuleVariant::~CSIRuleVariant(void)
+	"_._14CSITtpWordList" @ 156 NONAME R3UNUSED ; CSITtpWordList::~CSITtpWordList(void)
+	"_._15CSIClientResult" @ 157 NONAME R3UNUSED ; CSIClientResult::~CSIClientResult(void)
+	"_._16CSIPronunciation" @ 158 NONAME R3UNUSED ; CSIPronunciation::~CSIPronunciation(void)
+	"_._18CSIClientResultSet" @ 159 NONAME R3UNUSED ; CSIClientResultSet::~CSIClientResultSet(void)
+	"_._18CSICompiledGrammar" @ 160 NONAME R3UNUSED ; CSICompiledGrammar::~CSICompiledGrammar(void)
+	"_._18TSIRuleVariantInfo" @ 161 NONAME R3UNUSED ; TSIRuleVariantInfo::~TSIRuleVariantInfo(void)
+	"_._20CSIPronunciationInfo" @ 162 NONAME R3UNUSED ; CSIPronunciationInfo::~CSIPronunciationInfo(void)
+	"_._7CSIRule" @ 163 NONAME R3UNUSED ; CSIRule::~CSIRule(void)
+	"_._8CSIModel" @ 164 NONAME R3UNUSED ; CSIModel::~CSIModel(void)
+	"_._9CSIResult" @ 165 NONAME R3UNUSED ; CSIResult::~CSIResult(void)
+	__10CSIGrammarUs @ 166 NONAME R3UNUSED ; CSIGrammar::CSIGrammar(unsigned short)
+	__10CSILexiconUs @ 167 NONAME R3UNUSED ; CSILexicon::CSILexicon(unsigned short)
+	__12CSIModelBankUs @ 168 NONAME R3UNUSED ; CSIModelBank::CSIModelBank(unsigned short)
+	__12CSIResultSet @ 169 NONAME R3UNUSED ; CSIResultSet::CSIResultSet(void)
+	__13CSIParameters @ 170 NONAME R3UNUSED ; CSIParameters::CSIParameters(void)
+	__13TSIDiagnostic @ 171 NONAME R3UNUSED ; TSIDiagnostic::TSIDiagnostic(void)
+	__14CSIRuleVariantUcUs @ 172 NONAME R3UNUSED ; CSIRuleVariant::CSIRuleVariant(unsigned char, unsigned short)
+	__14CSITtpWordList @ 173 NONAME R3UNUSED ; CSITtpWordList::CSITtpWordList(void)
+	__16CSIPronunciationUlUs @ 174 NONAME R3UNUSED ; CSIPronunciation::CSIPronunciation(unsigned long, unsigned short)
+	__18CSICompiledGrammarUs @ 175 NONAME R3UNUSED ; CSICompiledGrammar::CSICompiledGrammar(unsigned short)
+	__18TSIRuleVariantInfoUsUlUc @ 176 NONAME ; TSIRuleVariantInfo::TSIRuleVariantInfo(unsigned short, unsigned long, unsigned char)
+	__20CSIPronunciationInfoGt13RPointerArray1Z6HBufC89TLanguage @ 177 NONAME ; CSIPronunciationInfo::CSIPronunciationInfo(RPointerArray<HBufC8>, TLanguage)
+	__7CSIRuleUl @ 178 NONAME R3UNUSED ; CSIRule::CSIRule(unsigned long)
+	__8CSIModelUs @ 179 NONAME R3UNUSED ; CSIModel::CSIModel(unsigned short)
+	AcousticModel__C8CSIModel @ 180 NONAME R3UNUSED ; CSIModel::AcousticModel(void) const
+	SetPronunciationID__16CSIPronunciationUl @ 181 NONAME R3UNUSED ; CSIPronunciation::SetPronunciationID(unsigned long)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/bwins/nsssispeechrecognitiondatau.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,183 @@
+EXPORTS
+	??0CSICompiledGrammar@@IAE@G@Z @ 1 NONAME ; CSICompiledGrammar::CSICompiledGrammar(unsigned short)
+	??0CSIGrammar@@IAE@G@Z @ 2 NONAME ; CSIGrammar::CSIGrammar(unsigned short)
+	??0CSILexicon@@IAE@G@Z @ 3 NONAME ; CSILexicon::CSILexicon(unsigned short)
+	??0CSIModel@@IAE@G@Z @ 4 NONAME ; CSIModel::CSIModel(unsigned short)
+	??0CSIModelBank@@IAE@G@Z @ 5 NONAME ; CSIModelBank::CSIModelBank(unsigned short)
+	??0CSIParameters@@IAE@XZ @ 6 NONAME ; CSIParameters::CSIParameters(void)
+	??0CSIPronunciation@@IAE@KG@Z @ 7 NONAME ; CSIPronunciation::CSIPronunciation(unsigned long, unsigned short)
+	??0CSIPronunciationInfo@@IAE@V?$RPointerArray@VHBufC8@@@@W4TLanguage@@@Z @ 8 NONAME ; CSIPronunciationInfo::CSIPronunciationInfo(class RPointerArray<class HBufC8>, enum TLanguage)
+	??0CSIResult@@IAE@XZ @ 9 NONAME ; CSIResult::CSIResult(void)
+	??0CSIResultSet@@AAE@XZ @ 10 NONAME ; CSIResultSet::CSIResultSet(void)
+	??0CSIRule@@IAE@K@Z @ 11 NONAME ; CSIRule::CSIRule(unsigned long)
+	??0CSIRuleVariant@@IAE@EG@Z @ 12 NONAME ; CSIRuleVariant::CSIRuleVariant(unsigned char, unsigned short)
+	??0CSITtpWordList@@IAE@XZ @ 13 NONAME ; CSITtpWordList::CSITtpWordList(void)
+	??0TSIDiagnostic@@QAE@XZ @ 14 NONAME ; TSIDiagnostic::TSIDiagnostic(void)
+	??0TSIRuleVariantInfo@@QAE@GKE@Z @ 15 NONAME ; TSIRuleVariantInfo::TSIRuleVariantInfo(unsigned short, unsigned long, unsigned char)
+	??1CSIClientResult@@UAE@XZ @ 16 NONAME ; CSIClientResult::~CSIClientResult(void)
+	??1CSIClientResultSet@@UAE@XZ @ 17 NONAME ; CSIClientResultSet::~CSIClientResultSet(void)
+	??1CSICompiledGrammar@@UAE@XZ @ 18 NONAME ; CSICompiledGrammar::~CSICompiledGrammar(void)
+	??1CSIGrammar@@UAE@XZ @ 19 NONAME ; CSIGrammar::~CSIGrammar(void)
+	??1CSILexicon@@UAE@XZ @ 20 NONAME ; CSILexicon::~CSILexicon(void)
+	??1CSIModel@@UAE@XZ @ 21 NONAME ; CSIModel::~CSIModel(void)
+	??1CSIModelBank@@UAE@XZ @ 22 NONAME ; CSIModelBank::~CSIModelBank(void)
+	??1CSIParameters@@UAE@XZ @ 23 NONAME ; CSIParameters::~CSIParameters(void)
+	??1CSIPronunciation@@UAE@XZ @ 24 NONAME ; CSIPronunciation::~CSIPronunciation(void)
+	??1CSIPronunciationInfo@@UAE@XZ @ 25 NONAME ; CSIPronunciationInfo::~CSIPronunciationInfo(void)
+	??1CSIResult@@UAE@XZ @ 26 NONAME ; CSIResult::~CSIResult(void)
+	??1CSIResultSet@@UAE@XZ @ 27 NONAME ; CSIResultSet::~CSIResultSet(void)
+	??1CSIRule@@UAE@XZ @ 28 NONAME ; CSIRule::~CSIRule(void)
+	??1CSIRuleVariant@@UAE@XZ @ 29 NONAME ; CSIRuleVariant::~CSIRuleVariant(void)
+	??1CSITtpWordList@@UAE@XZ @ 30 NONAME ; CSITtpWordList::~CSITtpWordList(void)
+	??1TSIDiagnostic@@QAE@XZ @ 31 NONAME ; TSIDiagnostic::~TSIDiagnostic(void)
+	??1TSIRuleVariantInfo@@UAE@XZ @ 32 NONAME ; TSIRuleVariantInfo::~TSIRuleVariantInfo(void)
+	?AcousticModel@CSIModel@@UBEAAVTDesC8@@XZ @ 33 NONAME ; class TDesC8 & CSIModel::AcousticModel(void) const
+	?AdaptationData@CSIResultSet@@UAEAAVTDesC8@@XZ @ 34 NONAME ; class TDesC8 & CSIResultSet::AdaptationData(void)
+	?AddL@CSIClientResultSet@@QAEXPBVCSIClientResult@@@Z @ 35 NONAME ; void CSIClientResultSet::AddL(class CSIClientResult const *)
+	?AddL@CSICompiledGrammar@@UAEXPAVCSIRule@@@Z @ 36 NONAME ; void CSICompiledGrammar::AddL(class CSIRule *)
+	?AddL@CSIGrammar@@UAEXPAVCSIRule@@@Z @ 37 NONAME ; void CSIGrammar::AddL(class CSIRule *)
+	?AddL@CSILexicon@@UAEXPAVCSIPronunciation@@@Z @ 38 NONAME ; void CSILexicon::AddL(class CSIPronunciation *)
+	?AddL@CSIModelBank@@UAEXPBVCSIModel@@@Z @ 39 NONAME ; void CSIModelBank::AddL(class CSIModel const *)
+	?AddL@CSIResultSet@@UAEXPBVCSIResult@@@Z @ 40 NONAME ; void CSIResultSet::AddL(class CSIResult const *)
+	?AddL@CSIRule@@UAEXPAVCSIRuleVariant@@@Z @ 41 NONAME ; void CSIRule::AddL(class CSIRuleVariant *)
+	?AddL@CSITtpWordList@@UAEXPAVMDesC16Array@@@Z @ 42 NONAME ; void CSITtpWordList::AddL(class MDesC16Array *)
+	?AppendPronunciationL@CSITtpWordList@@UAEXHPAVCSIPronunciationInfo@@@Z @ 43 NONAME ; void CSITtpWordList::AppendPronunciationL(int, class CSIPronunciationInfo *)
+	?AtL@CSIClientResultSet@@QBEABVCSIClientResult@@H@Z @ 44 NONAME ; class CSIClientResult const & CSIClientResultSet::AtL(int) const
+	?AtL@CSIGrammar@@UBEAAVCSIRule@@H@Z @ 45 NONAME ; class CSIRule & CSIGrammar::AtL(int) const
+	?AtL@CSILexicon@@UBEAAVCSIPronunciation@@H@Z @ 46 NONAME ; class CSIPronunciation & CSILexicon::AtL(int) const
+	?AtL@CSIModelBank@@UBEAAVCSIModel@@H@Z @ 47 NONAME ; class CSIModel & CSIModelBank::AtL(int) const
+	?AtL@CSIResultSet@@UAEAAVCSIResult@@H@Z @ 48 NONAME ; class CSIResult & CSIResultSet::AtL(int)
+	?AtL@CSIResultSet@@UBEABVCSIResult@@H@Z @ 49 NONAME ; class CSIResult const & CSIResultSet::AtL(int) const
+	?AtL@CSIRule@@UBEAAVCSIRuleVariant@@H@Z @ 50 NONAME ; class CSIRuleVariant & CSIRule::AtL(int) const
+	?AtL@CSITtpWordList@@UBEAAVMDesC16Array@@H@Z @ 51 NONAME ; class MDesC16Array & CSITtpWordList::AtL(int) const
+	?CompiledData@CSICompiledGrammar@@UBEAAVTDesC8@@XZ @ 52 NONAME ; class TDesC8 & CSICompiledGrammar::CompiledData(void) const
+	?ConstructL@CSICompiledGrammar@@MAEXXZ @ 53 NONAME ; void CSICompiledGrammar::ConstructL(void)
+	?ConstructL@CSIGrammar@@MAEXXZ @ 54 NONAME ; void CSIGrammar::ConstructL(void)
+	?ConstructL@CSILexicon@@IAEXXZ @ 55 NONAME ; void CSILexicon::ConstructL(void)
+	?ConstructL@CSIModel@@MAEXXZ @ 56 NONAME ; void CSIModel::ConstructL(void)
+	?ConstructL@CSIModelBank@@MAEXXZ @ 57 NONAME ; void CSIModelBank::ConstructL(void)
+	?ConstructL@CSIParameters@@MAEXXZ @ 58 NONAME ; void CSIParameters::ConstructL(void)
+	?ConstructL@CSIPronunciation@@MAEXXZ @ 59 NONAME ; void CSIPronunciation::ConstructL(void)
+	?ConstructL@CSIPronunciationInfo@@MAEXXZ @ 60 NONAME ; void CSIPronunciationInfo::ConstructL(void)
+	?ConstructL@CSIResult@@MAEXXZ @ 61 NONAME ; void CSIResult::ConstructL(void)
+	?ConstructL@CSIResultSet@@EAEXXZ @ 62 NONAME ; void CSIResultSet::ConstructL(void)
+	?ConstructL@CSIRule@@MAEXXZ @ 63 NONAME ; void CSIRule::ConstructL(void)
+	?ConstructL@CSIRuleVariant@@MAEXXZ @ 64 NONAME ; void CSIRuleVariant::ConstructL(void)
+	?ConstructL@CSITtpWordList@@IAEXXZ @ 65 NONAME ; void CSITtpWordList::ConstructL(void)
+	?Count@CSIGrammar@@UBEHXZ @ 66 NONAME ; int CSIGrammar::Count(void) const
+	?Count@CSILexicon@@UBEHXZ @ 67 NONAME ; int CSILexicon::Count(void) const
+	?Count@CSIModelBank@@UBEHXZ @ 68 NONAME ; int CSIModelBank::Count(void) const
+	?Count@CSIPronunciationInfo@@UBEHXZ @ 69 NONAME ; int CSIPronunciationInfo::Count(void) const
+	?Count@CSIResultSet@@UBEHXZ @ 70 NONAME ; int CSIResultSet::Count(void) const
+	?Count@CSIRule@@UBEHXZ @ 71 NONAME ; int CSIRule::Count(void) const
+	?Count@CSITtpWordList@@UBEHXZ @ 72 NONAME ; int CSITtpWordList::Count(void) const
+	?DeleteL@CSIClientResultSet@@QAEXH@Z @ 73 NONAME ; void CSIClientResultSet::DeleteL(int)
+	?DeleteL@CSICompiledGrammar@@UAEXK@Z @ 74 NONAME ; void CSICompiledGrammar::DeleteL(unsigned long)
+	?DeleteL@CSIGrammar@@UAEXK@Z @ 75 NONAME ; void CSIGrammar::DeleteL(unsigned long)
+	?DeleteL@CSILexicon@@UAEXK@Z @ 76 NONAME ; void CSILexicon::DeleteL(unsigned long)
+	?DeleteL@CSIModelBank@@UAEXG@Z @ 77 NONAME ; void CSIModelBank::DeleteL(unsigned short)
+	?DeleteL@CSIResultSet@@UAEXH@Z @ 78 NONAME ; void CSIResultSet::DeleteL(int)
+	?DeleteL@CSIRule@@UAEXE@Z @ 79 NONAME ; void CSIRule::DeleteL(unsigned char)
+	?DeleteL@CSITtpWordList@@UAEXH@Z @ 80 NONAME ; void CSITtpWordList::DeleteL(int)
+	?ExternalizeL@CSIClientResultSet@@UBEXAAVRWriteStream@@@Z @ 81 NONAME ; void CSIClientResultSet::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CSICompiledGrammar@@UBEXAAVRWriteStream@@@Z @ 82 NONAME ; void CSICompiledGrammar::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CSIGrammar@@UBEXAAVRWriteStream@@@Z @ 83 NONAME ; void CSIGrammar::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CSILexicon@@UBEXAAVRWriteStream@@@Z @ 84 NONAME ; void CSILexicon::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CSIParameters@@UBEXAAVRWriteStream@@@Z @ 85 NONAME ; void CSIParameters::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CSIResultSet@@UBEXAAVRWriteStream@@@Z @ 86 NONAME ; void CSIResultSet::ExternalizeL(class RWriteStream &) const
+	?Find@CSIGrammar@@UBEHK@Z @ 87 NONAME ; int CSIGrammar::Find(unsigned long) const
+	?Find@CSILexicon@@UBEHABVTDesC8@@@Z @ 88 NONAME ; int CSILexicon::Find(class TDesC8 const &) const
+	?Find@CSILexicon@@UBEHK@Z @ 89 NONAME ; int CSILexicon::Find(unsigned long) const
+	?Find@CSIModelBank@@UBEHG@Z @ 90 NONAME ; int CSIModelBank::Find(unsigned short) const
+	?Find@CSIRule@@UBEHE@Z @ 91 NONAME ; int CSIRule::Find(unsigned char) const
+	?GetPronunciationIDsL@CSIRuleVariant@@UBEXAAV?$RArray@K@@@Z @ 92 NONAME ; void CSIRuleVariant::GetPronunciationIDsL(class RArray<unsigned long> &) const
+	?GetPronunciationsL@CSITtpWordList@@UBEXHAAV?$RPointerArray@VCSIPronunciationInfo@@@@@Z @ 93 NONAME ; void CSITtpWordList::GetPronunciationsL(int, class RPointerArray<class CSIPronunciationInfo> &) const
+	?GrammarID@CSIClientResult@@QBEGXZ @ 94 NONAME ; unsigned short CSIClientResult::GrammarID(void) const
+	?GrammarID@CSIGrammar@@UBEGXZ @ 95 NONAME ; unsigned short CSIGrammar::GrammarID(void) const
+	?GrammarID@CSIResult@@UBEGXZ @ 96 NONAME ; unsigned short CSIResult::GrammarID(void) const
+	?GrammarID@TSIRuleVariantInfo@@UBEGXZ @ 97 NONAME ; unsigned short TSIRuleVariantInfo::GrammarID(void) const
+	?InternalizeL@CSIClientResultSet@@UAEXAAVRReadStream@@@Z @ 98 NONAME ; void CSIClientResultSet::InternalizeL(class RReadStream &)
+	?InternalizeL@CSICompiledGrammar@@UAEXAAVRReadStream@@@Z @ 99 NONAME ; void CSICompiledGrammar::InternalizeL(class RReadStream &)
+	?InternalizeL@CSIGrammar@@UAEXAAVRReadStream@@@Z @ 100 NONAME ; void CSIGrammar::InternalizeL(class RReadStream &)
+	?InternalizeL@CSILexicon@@UAEXAAVRReadStream@@@Z @ 101 NONAME ; void CSILexicon::InternalizeL(class RReadStream &)
+	?InternalizeL@CSIParameters@@UAEXAAVRReadStream@@@Z @ 102 NONAME ; void CSIParameters::InternalizeL(class RReadStream &)
+	?InternalizeL@CSIResultSet@@UAEXAAVRReadStream@@@Z @ 103 NONAME ; void CSIResultSet::InternalizeL(class RReadStream &)
+	?Language@CSIPronunciationInfo@@UBE?AW4TLanguage@@XZ @ 104 NONAME ; enum TLanguage CSIPronunciationInfo::Language(void) const
+	?Language@CSIRuleVariant@@UBE?AW4TLanguage@@XZ @ 105 NONAME ; enum TLanguage CSIRuleVariant::Language(void) const
+	?LexiconID@CSILexicon@@UBEGXZ @ 106 NONAME ; unsigned short CSILexicon::LexiconID(void) const
+	?LexiconID@CSIRuleVariant@@UBEGXZ @ 107 NONAME ; unsigned short CSIRuleVariant::LexiconID(void) const
+	?ListParametersL@CSIParameters@@UBEXAAV?$RArray@H@@0@Z @ 108 NONAME ; void CSIParameters::ListParametersL(class RArray<int> &, class RArray<int> &) const
+	?MaxResults@CSIClientResultSet@@QBEHXZ @ 109 NONAME ; int CSIClientResultSet::MaxResults(void) const
+	?ModelBankID@CSIModelBank@@UBEGXZ @ 110 NONAME ; unsigned short CSIModelBank::ModelBankID(void) const
+	?ModelBankID@CSIPronunciation@@UBEGXZ @ 111 NONAME ; unsigned short CSIPronunciation::ModelBankID(void) const
+	?ModelID@CSIModel@@UBEGXZ @ 112 NONAME ; unsigned short CSIModel::ModelID(void) const
+	?NewL@CSIClientResult@@SAPAV1@GK@Z @ 113 NONAME ; class CSIClientResult * CSIClientResult::NewL(unsigned short, unsigned long)
+	?NewL@CSIClientResult@@SAPAV1@XZ @ 114 NONAME ; class CSIClientResult * CSIClientResult::NewL(void)
+	?NewL@CSIClientResultSet@@SAPAV1@XZ @ 115 NONAME ; class CSIClientResultSet * CSIClientResultSet::NewL(void)
+	?NewL@CSICompiledGrammar@@SAPAV1@G@Z @ 116 NONAME ; class CSICompiledGrammar * CSICompiledGrammar::NewL(unsigned short)
+	?NewL@CSIGrammar@@SAPAV1@G@Z @ 117 NONAME ; class CSIGrammar * CSIGrammar::NewL(unsigned short)
+	?NewL@CSILexicon@@SAPAV1@G@Z @ 118 NONAME ; class CSILexicon * CSILexicon::NewL(unsigned short)
+	?NewL@CSIModel@@SAPAV1@G@Z @ 119 NONAME ; class CSIModel * CSIModel::NewL(unsigned short)
+	?NewL@CSIModelBank@@SAPAV1@G@Z @ 120 NONAME ; class CSIModelBank * CSIModelBank::NewL(unsigned short)
+	?NewL@CSIParameters@@SAPAV1@XZ @ 121 NONAME ; class CSIParameters * CSIParameters::NewL(void)
+	?NewL@CSIPronunciation@@SAPAV1@KG@Z @ 122 NONAME ; class CSIPronunciation * CSIPronunciation::NewL(unsigned long, unsigned short)
+	?NewL@CSIPronunciationInfo@@SAPAV1@V?$RPointerArray@VHBufC8@@@@W4TLanguage@@@Z @ 123 NONAME ; class CSIPronunciationInfo * CSIPronunciationInfo::NewL(class RPointerArray<class HBufC8>, enum TLanguage)
+	?NewL@CSIResult@@SAPAV1@XZ @ 124 NONAME ; class CSIResult * CSIResult::NewL(void)
+	?NewL@CSIResultSet@@SAPAV1@XZ @ 125 NONAME ; class CSIResultSet * CSIResultSet::NewL(void)
+	?NewL@CSIRule@@SAPAV1@K@Z @ 126 NONAME ; class CSIRule * CSIRule::NewL(unsigned long)
+	?NewL@CSIRuleVariant@@SAPAV1@EG@Z @ 127 NONAME ; class CSIRuleVariant * CSIRuleVariant::NewL(unsigned char, unsigned short)
+	?NewL@CSITtpWordList@@SAPAV1@XZ @ 128 NONAME ; class CSITtpWordList * CSITtpWordList::NewL(void)
+	?NewLC@CSIClientResult@@SAPAV1@GK@Z @ 129 NONAME ; class CSIClientResult * CSIClientResult::NewLC(unsigned short, unsigned long)
+	?NewLC@CSIClientResult@@SAPAV1@XZ @ 130 NONAME ; class CSIClientResult * CSIClientResult::NewLC(void)
+	?NewLC@CSIClientResultSet@@SAPAV1@XZ @ 131 NONAME ; class CSIClientResultSet * CSIClientResultSet::NewLC(void)
+	?NewLC@CSICompiledGrammar@@SAPAV1@G@Z @ 132 NONAME ; class CSICompiledGrammar * CSICompiledGrammar::NewLC(unsigned short)
+	?NewLC@CSIGrammar@@SAPAV1@G@Z @ 133 NONAME ; class CSIGrammar * CSIGrammar::NewLC(unsigned short)
+	?NewLC@CSILexicon@@SAPAV1@G@Z @ 134 NONAME ; class CSILexicon * CSILexicon::NewLC(unsigned short)
+	?NewLC@CSIModel@@SAPAV1@G@Z @ 135 NONAME ; class CSIModel * CSIModel::NewLC(unsigned short)
+	?NewLC@CSIModelBank@@SAPAV1@G@Z @ 136 NONAME ; class CSIModelBank * CSIModelBank::NewLC(unsigned short)
+	?NewLC@CSIParameters@@SAPAV1@XZ @ 137 NONAME ; class CSIParameters * CSIParameters::NewLC(void)
+	?NewLC@CSIPronunciation@@SAPAV1@KG@Z @ 138 NONAME ; class CSIPronunciation * CSIPronunciation::NewLC(unsigned long, unsigned short)
+	?NewLC@CSIPronunciationInfo@@SAPAV1@V?$RPointerArray@VHBufC8@@@@W4TLanguage@@@Z @ 139 NONAME ; class CSIPronunciationInfo * CSIPronunciationInfo::NewLC(class RPointerArray<class HBufC8>, enum TLanguage)
+	?NewLC@CSIResult@@SAPAV1@XZ @ 140 NONAME ; class CSIResult * CSIResult::NewLC(void)
+	?NewLC@CSIResultSet@@SAPAV1@XZ @ 141 NONAME ; class CSIResultSet * CSIResultSet::NewLC(void)
+	?NewLC@CSIRule@@SAPAV1@K@Z @ 142 NONAME ; class CSIRule * CSIRule::NewLC(unsigned long)
+	?NewLC@CSIRuleVariant@@SAPAV1@EG@Z @ 143 NONAME ; class CSIRuleVariant * CSIRuleVariant::NewLC(unsigned char, unsigned short)
+	?NewLC@CSITtpWordList@@SAPAV1@XZ @ 144 NONAME ; class CSITtpWordList * CSITtpWordList::NewLC(void)
+	?ParameterL@CSIParameters@@UBEHH@Z @ 145 NONAME ; int CSIParameters::ParameterL(int) const
+	?PhonemeSequence@CSIPronunciation@@UBEABVTDesC8@@XZ @ 146 NONAME ; class TDesC8 const & CSIPronunciation::PhonemeSequence(void) const
+	?Pronunciation@CSIResult@@UBEAAVCSIPronunciation@@XZ @ 147 NONAME ; class CSIPronunciation & CSIResult::Pronunciation(void) const
+	?PronunciationID@CSIPronunciation@@UBEKXZ @ 148 NONAME ; unsigned long CSIPronunciation::PronunciationID(void) const
+	?PronunciationL@CSIPronunciationInfo@@UBEAAVTDesC8@@H@Z @ 149 NONAME ; class TDesC8 & CSIPronunciationInfo::PronunciationL(int) const
+	?ResultCount@CSIClientResultSet@@QBEHXZ @ 150 NONAME ; int CSIClientResultSet::ResultCount(void) const
+	?RuleID@CSIClientResult@@QBEKXZ @ 151 NONAME ; unsigned long CSIClientResult::RuleID(void) const
+	?RuleID@CSIResult@@UBEKXZ @ 152 NONAME ; unsigned long CSIResult::RuleID(void) const
+	?RuleID@CSIRule@@UBEKXZ @ 153 NONAME ; unsigned long CSIRule::RuleID(void) const
+	?RuleID@TSIRuleVariantInfo@@UBEKXZ @ 154 NONAME ; unsigned long TSIRuleVariantInfo::RuleID(void) const
+	?RuleL@CSIGrammar@@UBEAAVCSIRule@@K@Z @ 155 NONAME ; class CSIRule & CSIGrammar::RuleL(unsigned long) const
+	?RuleVariantID@CSIResult@@UBEEXZ @ 156 NONAME ; unsigned char CSIResult::RuleVariantID(void) const
+	?RuleVariantID@CSIRuleVariant@@UBEEXZ @ 157 NONAME ; unsigned char CSIRuleVariant::RuleVariantID(void) const
+	?RuleVariantID@TSIRuleVariantInfo@@UBEEXZ @ 158 NONAME ; unsigned char TSIRuleVariantInfo::RuleVariantID(void) const
+	?RuleVariantL@CSIRule@@UBEAAVCSIRuleVariant@@E@Z @ 159 NONAME ; class CSIRuleVariant & CSIRule::RuleVariantL(unsigned char) const
+	?SIResultSet@CSIClientResultSet@@QBEAAVCSIResultSet@@XZ @ 160 NONAME ; class CSIResultSet & CSIClientResultSet::SIResultSet(void) const
+	?Score@CSIResult@@UBEJXZ @ 161 NONAME ; long CSIResult::Score(void) const
+	?SetAcousticModel@CSIModel@@UAEXPAVHBufC8@@@Z @ 162 NONAME ; void CSIModel::SetAcousticModel(class HBufC8 *)
+	?SetAdaptationData@CSIResultSet@@UAEXPAVHBufC8@@@Z @ 163 NONAME ; void CSIResultSet::SetAdaptationData(class HBufC8 *)
+	?SetCompiledData@CSICompiledGrammar@@UAEXPAVHBufC8@@@Z @ 164 NONAME ; void CSICompiledGrammar::SetCompiledData(class HBufC8 *)
+	?SetGrammarID@CSIClientResult@@QAEXG@Z @ 165 NONAME ; void CSIClientResult::SetGrammarID(unsigned short)
+	?SetGrammarID@CSIResult@@UAEXG@Z @ 166 NONAME ; void CSIResult::SetGrammarID(unsigned short)
+	?SetLanguage@CSIRuleVariant@@UAEXW4TLanguage@@@Z @ 167 NONAME ; void CSIRuleVariant::SetLanguage(enum TLanguage)
+	?SetMaxResultsL@CSIClientResultSet@@QAEXH@Z @ 168 NONAME ; void CSIClientResultSet::SetMaxResultsL(int)
+	?SetModelID@CSIModel@@UAEXG@Z @ 169 NONAME ; void CSIModel::SetModelID(unsigned short)
+	?SetParameterL@CSIParameters@@UAEXHH@Z @ 170 NONAME ; void CSIParameters::SetParameterL(int, int)
+	?SetPhonemeSequenceL@CSIPronunciation@@UAEXABVTDesC8@@@Z @ 171 NONAME ; void CSIPronunciation::SetPhonemeSequenceL(class TDesC8 const &)
+	?SetPronunciation@CSIResult@@UAEXPAVCSIPronunciation@@@Z @ 172 NONAME ; void CSIResult::SetPronunciation(class CSIPronunciation *)
+	?SetPronunciationIDsL@CSIRuleVariant@@UAEXABV?$RArray@K@@@Z @ 173 NONAME ; void CSIRuleVariant::SetPronunciationIDsL(class RArray<unsigned long> const &)
+	?SetPronunciationL@CSIPronunciationInfo@@UAEXHPAVHBufC8@@@Z @ 174 NONAME ; void CSIPronunciationInfo::SetPronunciationL(int, class HBufC8 *)
+	?SetResultCount@CSIClientResultSet@@QAEXH@Z @ 175 NONAME ; void CSIClientResultSet::SetResultCount(int)
+	?SetRuleID@CSIClientResult@@QAEXK@Z @ 176 NONAME ; void CSIClientResult::SetRuleID(unsigned long)
+	?SetRuleID@CSIResult@@UAEXK@Z @ 177 NONAME ; void CSIResult::SetRuleID(unsigned long)
+	?SetRuleVariantID@CSIResult@@UAEXE@Z @ 178 NONAME ; void CSIResult::SetRuleVariantID(unsigned char)
+	?SetSIResultSet@CSIClientResultSet@@QAEXPAVCSIResultSet@@@Z @ 179 NONAME ; void CSIClientResultSet::SetSIResultSet(class CSIResultSet *)
+	?SetScore@CSIResult@@UAEXJ@Z @ 180 NONAME ; void CSIResult::SetScore(long)
+	?SetPronunciationID@CSIPronunciation@@UAEXK@Z @ 181 NONAME ; public: virtual void __thiscall CSIPronunciation::SetPronunciationID(unsigned long)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/eabi/nsssispeechrecognitiondatau.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,275 @@
+EXPORTS
+	_ZN10CSIGrammar10ConstructLEv @ 1 NONAME
+	_ZN10CSIGrammar12InternalizeLER11RReadStream @ 2 NONAME
+	_ZN10CSIGrammar4AddLEP7CSIRule @ 3 NONAME
+	_ZN10CSIGrammar4NewLEt @ 4 NONAME
+	_ZN10CSIGrammar5NewLCEt @ 5 NONAME
+	_ZN10CSIGrammar7DeleteLEm @ 6 NONAME
+	_ZN10CSIGrammarC1Et @ 7 NONAME
+	_ZN10CSIGrammarC2Et @ 8 NONAME
+	_ZN10CSIGrammarD0Ev @ 9 NONAME
+	_ZN10CSIGrammarD1Ev @ 10 NONAME
+	_ZN10CSIGrammarD2Ev @ 11 NONAME
+	_ZN10CSILexicon10ConstructLEv @ 12 NONAME
+	_ZN10CSILexicon12InternalizeLER11RReadStream @ 13 NONAME
+	_ZN10CSILexicon4AddLEP16CSIPronunciation @ 14 NONAME
+	_ZN10CSILexicon4NewLEt @ 15 NONAME
+	_ZN10CSILexicon5NewLCEt @ 16 NONAME
+	_ZN10CSILexicon7DeleteLEm @ 17 NONAME
+	_ZN10CSILexiconC1Et @ 18 NONAME
+	_ZN10CSILexiconC2Et @ 19 NONAME
+	_ZN10CSILexiconD0Ev @ 20 NONAME
+	_ZN10CSILexiconD1Ev @ 21 NONAME
+	_ZN10CSILexiconD2Ev @ 22 NONAME
+	_ZN12CSIModelBank10ConstructLEv @ 23 NONAME
+	_ZN12CSIModelBank4AddLEPK8CSIModel @ 24 NONAME
+	_ZN12CSIModelBank4NewLEt @ 25 NONAME
+	_ZN12CSIModelBank5NewLCEt @ 26 NONAME
+	_ZN12CSIModelBank7DeleteLEt @ 27 NONAME
+	_ZN12CSIModelBankC1Et @ 28 NONAME
+	_ZN12CSIModelBankC2Et @ 29 NONAME
+	_ZN12CSIModelBankD0Ev @ 30 NONAME
+	_ZN12CSIModelBankD1Ev @ 31 NONAME
+	_ZN12CSIModelBankD2Ev @ 32 NONAME
+	_ZN12CSIResultSet10ConstructLEv @ 33 NONAME
+	_ZN12CSIResultSet12InternalizeLER11RReadStream @ 34 NONAME
+	_ZN12CSIResultSet14AdaptationDataEv @ 35 NONAME
+	_ZN12CSIResultSet17SetAdaptationDataEP6HBufC8 @ 36 NONAME
+	_ZN12CSIResultSet3AtLEi @ 37 NONAME
+	_ZN12CSIResultSet4AddLEPK9CSIResult @ 38 NONAME
+	_ZN12CSIResultSet4NewLEv @ 39 NONAME
+	_ZN12CSIResultSet5NewLCEv @ 40 NONAME
+	_ZN12CSIResultSet7DeleteLEi @ 41 NONAME
+	_ZN12CSIResultSetC1Ev @ 42 NONAME
+	_ZN12CSIResultSetC2Ev @ 43 NONAME
+	_ZN12CSIResultSetD0Ev @ 44 NONAME
+	_ZN12CSIResultSetD1Ev @ 45 NONAME
+	_ZN12CSIResultSetD2Ev @ 46 NONAME
+	_ZN13CSIParameters10ConstructLEv @ 47 NONAME
+	_ZN13CSIParameters12InternalizeLER11RReadStream @ 48 NONAME
+	_ZN13CSIParameters13SetParameterLEii @ 49 NONAME
+	_ZN13CSIParameters4NewLEv @ 50 NONAME
+	_ZN13CSIParameters5NewLCEv @ 51 NONAME
+	_ZN13CSIParametersC1Ev @ 52 NONAME
+	_ZN13CSIParametersC2Ev @ 53 NONAME
+	_ZN13CSIParametersD0Ev @ 54 NONAME
+	_ZN13CSIParametersD1Ev @ 55 NONAME
+	_ZN13CSIParametersD2Ev @ 56 NONAME
+	_ZN13TSIDiagnosticC1Ev @ 57 NONAME
+	_ZN13TSIDiagnosticC2Ev @ 58 NONAME
+	_ZN13TSIDiagnosticD1Ev @ 59 NONAME
+	_ZN13TSIDiagnosticD2Ev @ 60 NONAME
+	_ZN14CSIRuleVariant10ConstructLEv @ 61 NONAME
+	_ZN14CSIRuleVariant11SetLanguageE9TLanguage @ 62 NONAME
+	_ZN14CSIRuleVariant20SetPronunciationIDsLERK6RArrayImE @ 63 NONAME
+	_ZN14CSIRuleVariant4NewLEht @ 64 NONAME
+	_ZN14CSIRuleVariant5NewLCEht @ 65 NONAME
+	_ZN14CSIRuleVariantC1Eht @ 66 NONAME
+	_ZN14CSIRuleVariantC2Eht @ 67 NONAME
+	_ZN14CSIRuleVariantD0Ev @ 68 NONAME
+	_ZN14CSIRuleVariantD1Ev @ 69 NONAME
+	_ZN14CSIRuleVariantD2Ev @ 70 NONAME
+	_ZN14CSITtpWordList10ConstructLEv @ 71 NONAME
+	_ZN14CSITtpWordList20AppendPronunciationLEiP20CSIPronunciationInfo @ 72 NONAME
+	_ZN14CSITtpWordList4AddLEP12MDesC16Array @ 73 NONAME
+	_ZN14CSITtpWordList4NewLEv @ 74 NONAME
+	_ZN14CSITtpWordList5NewLCEv @ 75 NONAME
+	_ZN14CSITtpWordList7DeleteLEi @ 76 NONAME
+	_ZN14CSITtpWordListC1Ev @ 77 NONAME
+	_ZN14CSITtpWordListC2Ev @ 78 NONAME
+	_ZN14CSITtpWordListD0Ev @ 79 NONAME
+	_ZN14CSITtpWordListD1Ev @ 80 NONAME
+	_ZN14CSITtpWordListD2Ev @ 81 NONAME
+	_ZN15CSIClientResult12SetGrammarIDEt @ 82 NONAME
+	_ZN15CSIClientResult4NewLEtm @ 83 NONAME
+	_ZN15CSIClientResult4NewLEv @ 84 NONAME
+	_ZN15CSIClientResult5NewLCEtm @ 85 NONAME
+	_ZN15CSIClientResult5NewLCEv @ 86 NONAME
+	_ZN15CSIClientResult9SetRuleIDEm @ 87 NONAME
+	_ZN15CSIClientResultD0Ev @ 88 NONAME
+	_ZN15CSIClientResultD1Ev @ 89 NONAME
+	_ZN15CSIClientResultD2Ev @ 90 NONAME
+	_ZN16CSIPronunciation10ConstructLEv @ 91 NONAME
+	_ZN16CSIPronunciation19SetPhonemeSequenceLERK6TDesC8 @ 92 NONAME
+	_ZN16CSIPronunciation4NewLEmt @ 93 NONAME
+	_ZN16CSIPronunciation5NewLCEmt @ 94 NONAME
+	_ZN16CSIPronunciationC1Emt @ 95 NONAME
+	_ZN16CSIPronunciationC2Emt @ 96 NONAME
+	_ZN16CSIPronunciationD0Ev @ 97 NONAME
+	_ZN16CSIPronunciationD1Ev @ 98 NONAME
+	_ZN16CSIPronunciationD2Ev @ 99 NONAME
+	_ZN18CSIClientResultSet12InternalizeLER11RReadStream @ 100 NONAME
+	_ZN18CSIClientResultSet14SetMaxResultsLEi @ 101 NONAME
+	_ZN18CSIClientResultSet14SetResultCountEi @ 102 NONAME
+	_ZN18CSIClientResultSet14SetSIResultSetEP12CSIResultSet @ 103 NONAME
+	_ZN18CSIClientResultSet4AddLEPK15CSIClientResult @ 104 NONAME
+	_ZN18CSIClientResultSet4NewLEv @ 105 NONAME
+	_ZN18CSIClientResultSet5NewLCEv @ 106 NONAME
+	_ZN18CSIClientResultSet7DeleteLEi @ 107 NONAME
+	_ZN18CSIClientResultSetD0Ev @ 108 NONAME
+	_ZN18CSIClientResultSetD1Ev @ 109 NONAME
+	_ZN18CSIClientResultSetD2Ev @ 110 NONAME
+	_ZN18CSICompiledGrammar10ConstructLEv @ 111 NONAME
+	_ZN18CSICompiledGrammar12InternalizeLER11RReadStream @ 112 NONAME
+	_ZN18CSICompiledGrammar15SetCompiledDataEP6HBufC8 @ 113 NONAME
+	_ZN18CSICompiledGrammar4AddLEP7CSIRule @ 114 NONAME
+	_ZN18CSICompiledGrammar4NewLEt @ 115 NONAME
+	_ZN18CSICompiledGrammar5NewLCEt @ 116 NONAME
+	_ZN18CSICompiledGrammar7DeleteLEm @ 117 NONAME
+	_ZN18CSICompiledGrammarC1Et @ 118 NONAME
+	_ZN18CSICompiledGrammarC2Et @ 119 NONAME
+	_ZN18CSICompiledGrammarD0Ev @ 120 NONAME
+	_ZN18CSICompiledGrammarD1Ev @ 121 NONAME
+	_ZN18CSICompiledGrammarD2Ev @ 122 NONAME
+	_ZN18TSIRuleVariantInfoC1Etmh @ 123 NONAME
+	_ZN18TSIRuleVariantInfoC2Etmh @ 124 NONAME
+	_ZN18TSIRuleVariantInfoD0Ev @ 125 NONAME
+	_ZN18TSIRuleVariantInfoD1Ev @ 126 NONAME
+	_ZN18TSIRuleVariantInfoD2Ev @ 127 NONAME
+	_ZN20CSIPronunciationInfo10ConstructLEv @ 128 NONAME
+	_ZN20CSIPronunciationInfo17SetPronunciationLEiP6HBufC8 @ 129 NONAME
+	_ZN20CSIPronunciationInfo4NewLE13RPointerArrayI6HBufC8E9TLanguage @ 130 NONAME
+	_ZN20CSIPronunciationInfo5NewLCE13RPointerArrayI6HBufC8E9TLanguage @ 131 NONAME
+	_ZN20CSIPronunciationInfoC1E13RPointerArrayI6HBufC8E9TLanguage @ 132 NONAME
+	_ZN20CSIPronunciationInfoC2E13RPointerArrayI6HBufC8E9TLanguage @ 133 NONAME
+	_ZN20CSIPronunciationInfoD0Ev @ 134 NONAME
+	_ZN20CSIPronunciationInfoD1Ev @ 135 NONAME
+	_ZN20CSIPronunciationInfoD2Ev @ 136 NONAME
+	_ZN7CSIRule10ConstructLEv @ 137 NONAME
+	_ZN7CSIRule4AddLEP14CSIRuleVariant @ 138 NONAME
+	_ZN7CSIRule4NewLEm @ 139 NONAME
+	_ZN7CSIRule5NewLCEm @ 140 NONAME
+	_ZN7CSIRule7DeleteLEh @ 141 NONAME
+	_ZN7CSIRuleC1Em @ 142 NONAME
+	_ZN7CSIRuleC2Em @ 143 NONAME
+	_ZN7CSIRuleD0Ev @ 144 NONAME
+	_ZN7CSIRuleD1Ev @ 145 NONAME
+	_ZN7CSIRuleD2Ev @ 146 NONAME
+	_ZN8CSIModel10ConstructLEv @ 147 NONAME
+	_ZN8CSIModel10SetModelIDEt @ 148 NONAME
+	_ZN8CSIModel16SetAcousticModelEP6HBufC8 @ 149 NONAME
+	_ZN8CSIModel4NewLEt @ 150 NONAME
+	_ZN8CSIModel5NewLCEt @ 151 NONAME
+	_ZN8CSIModelC1Et @ 152 NONAME
+	_ZN8CSIModelC2Et @ 153 NONAME
+	_ZN8CSIModelD0Ev @ 154 NONAME
+	_ZN8CSIModelD1Ev @ 155 NONAME
+	_ZN8CSIModelD2Ev @ 156 NONAME
+	_ZN9CSIResult10ConstructLEv @ 157 NONAME
+	_ZN9CSIResult12SetGrammarIDEt @ 158 NONAME
+	_ZN9CSIResult16SetPronunciationEP16CSIPronunciation @ 159 NONAME
+	_ZN9CSIResult16SetRuleVariantIDEh @ 160 NONAME
+	_ZN9CSIResult4NewLEv @ 161 NONAME
+	_ZN9CSIResult5NewLCEv @ 162 NONAME
+	_ZN9CSIResult8SetScoreEl @ 163 NONAME
+	_ZN9CSIResult9SetRuleIDEm @ 164 NONAME
+	_ZN9CSIResultC1Ev @ 165 NONAME
+	_ZN9CSIResultC2Ev @ 166 NONAME
+	_ZN9CSIResultD0Ev @ 167 NONAME
+	_ZN9CSIResultD1Ev @ 168 NONAME
+	_ZN9CSIResultD2Ev @ 169 NONAME
+	_ZNK10CSIGrammar12ExternalizeLER12RWriteStream @ 170 NONAME
+	_ZNK10CSIGrammar3AtLEi @ 171 NONAME
+	_ZNK10CSIGrammar4FindEm @ 172 NONAME
+	_ZNK10CSIGrammar5CountEv @ 173 NONAME
+	_ZNK10CSIGrammar5RuleLEm @ 174 NONAME
+	_ZNK10CSIGrammar9GrammarIDEv @ 175 NONAME
+	_ZNK10CSILexicon12ExternalizeLER12RWriteStream @ 176 NONAME
+	_ZNK10CSILexicon3AtLEi @ 177 NONAME
+	_ZNK10CSILexicon4FindERK6TDesC8 @ 178 NONAME
+	_ZNK10CSILexicon4FindEm @ 179 NONAME
+	_ZNK10CSILexicon5CountEv @ 180 NONAME
+	_ZNK10CSILexicon9LexiconIDEv @ 181 NONAME
+	_ZNK12CSIModelBank11ModelBankIDEv @ 182 NONAME
+	_ZNK12CSIModelBank3AtLEi @ 183 NONAME
+	_ZNK12CSIModelBank4FindEt @ 184 NONAME
+	_ZNK12CSIModelBank5CountEv @ 185 NONAME
+	_ZNK12CSIResultSet12ExternalizeLER12RWriteStream @ 186 NONAME
+	_ZNK12CSIResultSet3AtLEi @ 187 NONAME
+	_ZNK12CSIResultSet5CountEv @ 188 NONAME
+	_ZNK13CSIParameters10ParameterLEi @ 189 NONAME
+	_ZNK13CSIParameters12ExternalizeLER12RWriteStream @ 190 NONAME
+	_ZNK13CSIParameters15ListParametersLER6RArrayIiES2_ @ 191 NONAME
+	_ZNK14CSIRuleVariant13RuleVariantIDEv @ 192 NONAME
+	_ZNK14CSIRuleVariant20GetPronunciationIDsLER6RArrayImE @ 193 NONAME
+	_ZNK14CSIRuleVariant8LanguageEv @ 194 NONAME
+	_ZNK14CSIRuleVariant9LexiconIDEv @ 195 NONAME
+	_ZNK14CSITtpWordList18GetPronunciationsLEiR13RPointerArrayI20CSIPronunciationInfoE @ 196 NONAME
+	_ZNK14CSITtpWordList3AtLEi @ 197 NONAME
+	_ZNK14CSITtpWordList5CountEv @ 198 NONAME
+	_ZNK15CSIClientResult6RuleIDEv @ 199 NONAME
+	_ZNK15CSIClientResult9GrammarIDEv @ 200 NONAME
+	_ZNK16CSIPronunciation11ModelBankIDEv @ 201 NONAME
+	_ZNK16CSIPronunciation15PhonemeSequenceEv @ 202 NONAME
+	_ZNK16CSIPronunciation15PronunciationIDEv @ 203 NONAME
+	_ZNK18CSIClientResultSet10MaxResultsEv @ 204 NONAME
+	_ZNK18CSIClientResultSet11ResultCountEv @ 205 NONAME
+	_ZNK18CSIClientResultSet11SIResultSetEv @ 206 NONAME
+	_ZNK18CSIClientResultSet12ExternalizeLER12RWriteStream @ 207 NONAME
+	_ZNK18CSIClientResultSet3AtLEi @ 208 NONAME
+	_ZNK18CSICompiledGrammar12CompiledDataEv @ 209 NONAME
+	_ZNK18CSICompiledGrammar12ExternalizeLER12RWriteStream @ 210 NONAME
+	_ZNK18TSIRuleVariantInfo13RuleVariantIDEv @ 211 NONAME
+	_ZNK18TSIRuleVariantInfo6RuleIDEv @ 212 NONAME
+	_ZNK18TSIRuleVariantInfo9GrammarIDEv @ 213 NONAME
+	_ZNK20CSIPronunciationInfo14PronunciationLEi @ 214 NONAME
+	_ZNK20CSIPronunciationInfo5CountEv @ 215 NONAME
+	_ZNK20CSIPronunciationInfo8LanguageEv @ 216 NONAME
+	_ZNK7CSIRule12RuleVariantLEh @ 217 NONAME
+	_ZNK7CSIRule3AtLEi @ 218 NONAME
+	_ZNK7CSIRule4FindEh @ 219 NONAME
+	_ZNK7CSIRule5CountEv @ 220 NONAME
+	_ZNK7CSIRule6RuleIDEv @ 221 NONAME
+	_ZNK8CSIModel13AcousticModelEv @ 222 NONAME
+	_ZNK8CSIModel7ModelIDEv @ 223 NONAME
+	_ZNK9CSIResult13PronunciationEv @ 224 NONAME
+	_ZNK9CSIResult13RuleVariantIDEv @ 225 NONAME
+	_ZNK9CSIResult5ScoreEv @ 226 NONAME
+	_ZNK9CSIResult6RuleIDEv @ 227 NONAME
+	_ZNK9CSIResult9GrammarIDEv @ 228 NONAME
+	_ZTI10CSIGrammar @ 229 NONAME ; #<TI>#
+	_ZTI10CSILexicon @ 230 NONAME ; #<TI>#
+	_ZTI11CYesNoCoder @ 231 NONAME ; #<TI>#
+	_ZTI12CSIModelBank @ 232 NONAME ; #<TI>#
+	_ZTI12CSIResultSet @ 233 NONAME ; #<TI>#
+	_ZTI13CNibble4Coder @ 234 NONAME ; #<TI>#
+	_ZTI13CSIParameters @ 235 NONAME ; #<TI>#
+	_ZTI14CNibble16Coder @ 236 NONAME ; #<TI>#
+	_ZTI14CSIRuleVariant @ 237 NONAME ; #<TI>#
+	_ZTI14CSITtpWordList @ 238 NONAME ; #<TI>#
+	_ZTI15CSIClientResult @ 239 NONAME ; #<TI>#
+	_ZTI16CSIPronunciation @ 240 NONAME ; #<TI>#
+	_ZTI18CSIClientResultSet @ 241 NONAME ; #<TI>#
+	_ZTI18CSICompiledGrammar @ 242 NONAME ; #<TI>#
+	_ZTI18TSIRuleVariantInfo @ 243 NONAME ; #<TI>#
+	_ZTI20CSIGrammarSerializer @ 244 NONAME ; #<TI>#
+	_ZTI20CSILexiconSerializer @ 245 NONAME ; #<TI>#
+	_ZTI20CSIPronunciationInfo @ 246 NONAME ; #<TI>#
+	_ZTI7CSIRule @ 247 NONAME ; #<TI>#
+	_ZTI8CSIModel @ 248 NONAME ; #<TI>#
+	_ZTI9CRLECoder @ 249 NONAME ; #<TI>#
+	_ZTI9CSIResult @ 250 NONAME ; #<TI>#
+	_ZTV10CSIGrammar @ 251 NONAME ; #<VT>#
+	_ZTV10CSILexicon @ 252 NONAME ; #<VT>#
+	_ZTV11CYesNoCoder @ 253 NONAME ; #<VT>#
+	_ZTV12CSIModelBank @ 254 NONAME ; #<VT>#
+	_ZTV12CSIResultSet @ 255 NONAME ; #<VT>#
+	_ZTV13CNibble4Coder @ 256 NONAME ; #<VT>#
+	_ZTV13CSIParameters @ 257 NONAME ; #<VT>#
+	_ZTV14CNibble16Coder @ 258 NONAME ; #<VT>#
+	_ZTV14CSIRuleVariant @ 259 NONAME ; #<VT>#
+	_ZTV14CSITtpWordList @ 260 NONAME ; #<VT>#
+	_ZTV15CSIClientResult @ 261 NONAME ; #<VT>#
+	_ZTV16CSIPronunciation @ 262 NONAME ; #<VT>#
+	_ZTV18CSIClientResultSet @ 263 NONAME ; #<VT>#
+	_ZTV18CSICompiledGrammar @ 264 NONAME ; #<VT>#
+	_ZTV18TSIRuleVariantInfo @ 265 NONAME ; #<VT>#
+	_ZTV20CSIGrammarSerializer @ 266 NONAME ; #<VT>#
+	_ZTV20CSILexiconSerializer @ 267 NONAME ; #<VT>#
+	_ZTV20CSIPronunciationInfo @ 268 NONAME ; #<VT>#
+	_ZTV7CSIRule @ 269 NONAME ; #<VT>#
+	_ZTV8CSIModel @ 270 NONAME ; #<VT>#
+	_ZTV9CRLECoder @ 271 NONAME ; #<VT>#
+	_ZTV9CSIResult @ 272 NONAME ; #<VT>#
+	_ZN16CSIPronunciation18SetPronunciationIDEm @ 273 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for SpeechRecognitionData.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+
+nsssispeechrecognitiondata.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/group/nsssispeechrecognitiondata.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for SISpeechRecognitionData.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET            nsssispeechrecognitiondata.dll
+TARGETTYPE        DLL
+UID               0x1000008D 0x101FF92A // UID: 270530858
+
+CAPABILITY        CAP_GENERAL_DLL
+
+VENDORID          VID_DEFAULT
+
+SOURCEPATH        ../src
+SOURCE            nsssispeechrecognitiondataclient.cpp
+SOURCE            nsssispeechrecognitiondatadevasr.cpp
+SOURCE            nsssispeechrecognitiondatacommon.cpp
+SOURCE            nsssispeechrecognitiondatatest.cpp
+SOURCE            nsssidataserialize.cpp
+
+SYSTEMINCLUDE     ../inc 
+USERINCLUDE       ../src
+USERINCLUDE       ../../rubydebug
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+  
+LIBRARY           euser.lib
+LIBRARY           estor.lib
+     
+LANG              SC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/inc/nsssispeechrecognitiondatatest.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definition of the SISpeechRecognitionDataTest structure and API.
+*
+*/
+
+
+#ifndef __SRSIATA_TEST_H__
+#define __SRSIATA_TEST_H__
+
+//  INCLUDES
+#include <e32base.h>
+
+
+/**
+*  Class to encapsulate diagnostic parameter values.
+*
+*  @lib SpeechRecognitionData.lib
+*  @since 2.5
+*/
+
+class TSIDiagnostic
+{
+public:// Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+	IMPORT_C TSIDiagnostic();
+        /**
+        * Destructor.
+        */
+	IMPORT_C ~TSIDiagnostic();
+
+public:
+	TInt32 iSNR;		// signal to noise ratio
+	TBool iAccepted;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/src/nsssidataserialize.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1528 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Serialization functions for CSIGrammar and CSILexicon
+*
+*/
+
+
+// INCLUDE FILES
+#include "nsssidataserialize.h"
+#include <s32mem.h> // RBuf[Read/Write]Stream
+
+// LOCAL CONSTANTS AND MACROS
+const TUint32 KNibble16Limit = 0xffff;
+const TUint32 KNibble4Limit  = 0xf;
+
+// LOCAL FUNCTION PROTOTYPES
+void Externalize32bitArrayL( RWriteStream& aStream, RArray<TUint32>& aArray );
+void Internalize32bitArrayL( RReadStream& aStream,  RArray<TUint32>& aArray );
+TInt IndexOrderForPhonemes( const TLexiconPhoneme& p1, const TLexiconPhoneme& p2 );
+TInt StringOrderForPhonemes( const TLexiconPhoneme& p1, const TLexiconPhoneme& p2 );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Externalize32bitArrayL
+// Writes an RArray with 32-bit entries to the stream.
+// Returns: None
+// -----------------------------------------------------------------------------
+//
+void Externalize32bitArrayL(
+    RWriteStream&    aStream,  // The stream where to store the array
+    RArray<TUint32>& aArray )  // The array; the entries must be 32-bit.
+    {
+    TInt count = aArray.Count();
+
+    aStream.WriteInt32L( count );
+
+    if ( count > 0 )
+        {
+        TInt* startPtr = (TInt*)&aArray[0];
+        aStream.WriteL( (TUint8*)startPtr, sizeof(TInt) * count );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Internalize32bitArrayL
+// Reads an array from the stream.
+// Returns: None
+// -----------------------------------------------------------------------------
+//
+void Internalize32bitArrayL(
+    RReadStream& aStream,     // The stream to read from
+    RArray<TUint32>& aArray ) // The array to be populated
+    {
+    TInt count = aStream.ReadInt32L();
+    TInt err = KErrNone;
+
+    for ( TInt k( 0 ); k < count; k++ )
+        {
+        TInt value = aStream.ReadInt32L();
+        err |= aArray.Append( value );
+        }
+
+    User::LeaveIfError( err );
+    }
+
+// -----------------------------------------------------------------------------
+// IndexOrderForPhonemes
+// 
+// -----------------------------------------------------------------------------
+//
+TInt IndexOrderForPhonemes( const TLexiconPhoneme& p1, const TLexiconPhoneme& p2 )
+    {
+    return( p1.iIndex - p2.iIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// StringOrderForPhonemes
+// 
+// -----------------------------------------------------------------------------
+//
+TInt StringOrderForPhonemes( const TLexiconPhoneme& p1, const TLexiconPhoneme& p2 )
+    {
+    return( p1.iPhoneme.Compare( p2.iPhoneme ) );
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Implementation of CSILexiconSerializer starts from here.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::CSILexiconSerializer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSILexiconSerializer::CSILexiconSerializer()
+    {
+    iPronunIDs = NULL;
+    iModelBankIDs = NULL;
+    iParamBuf  = NULL;
+    iCount     = 0; 
+    iLexiconID = 0; // !!!! Change to KInvalidLexiconID.
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::~CSILexiconSerializer
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CSILexiconSerializer::~CSILexiconSerializer()
+    {
+    iPronunciations.ResetAndDestroy();
+    iIndexPronuns.ResetAndDestroy();
+
+    iConversionTable.Close();
+
+    delete iPronunIDs;
+    delete iModelBankIDs;
+    delete iParamBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::NextPhonemeL
+// Stores the next phoneme to phonemeBuf and increases the cursor.
+// Returns true if there are still more phonemes.
+// -----------------------------------------------------------------------------
+//
+bool CSILexiconSerializer::NextPhonemeL(
+    TDes8& phonemeBuf,
+    const TDesC8& phonemeSeq,
+    TInt&  aReadIterator )
+    {
+    TInt length = phonemeSeq.Length();
+
+    // Out of phonemes?
+    if ( length == aReadIterator )
+        {
+        return( false );
+        }
+
+    // Cut those phonemes away, which have been processed already.
+    TPtrC8 unfinishedPhonemes = phonemeSeq.Right( length - aReadIterator );
+
+    // Make SeparatorLoc point to the end of the next phoneme.
+    TInt separatorLoc = unfinishedPhonemes.Locate( KPhonemeSeparator );
+
+    // Phoneme length is from [start of unprocessed string] to [separator]...
+    TInt phonemeLength = separatorLoc;
+
+    // ...unless we're dealing with the last phoneme. Then
+    // phonemeLength is from [start of unprocessed string] to [end of string].
+    if ( separatorLoc == KErrNotFound )
+        phonemeLength = length - aReadIterator;
+
+    // Check that the phoneme is not too long.
+    if ( phonemeLength > KMaxPhonemeLength )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    if ( phonemeLength == 0 )
+        {
+        return( false );
+        }
+
+    // Copy
+    phonemeBuf.Copy( unfinishedPhonemes.Ptr(), phonemeLength );
+
+    // Update iterator
+    aReadIterator += phonemeLength; // The phoneme
+    if ( aReadIterator < length )   // The separator
+        {
+        aReadIterator++;
+        }
+
+    return( true );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::SavePronunciationL
+// Converts the ASCII phoneme strings to internal index strings.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconSerializer::SavePronunciationL(CSIPronunciation* aPronun)
+    {
+    TLinearOrder<TLexiconPhoneme> order( StringOrderForPhonemes );
+
+    // This phoneme is used for searching
+    TLexiconPhoneme searchPhoneme;
+    TDes8& phonemeBuf = searchPhoneme.iPhoneme;
+
+    const TDesC8& phonemeSeq = aPronun->PhonemeSequence();
+
+    HBufC8* indexPronun = HBufC8::NewLC( phonemeSeq.Length() );
+
+    TInt phonemeReadIter = 0;
+
+    while( NextPhonemeL( phonemeBuf, phonemeSeq, phonemeReadIter ) )
+        {
+        // Search the phoneme from conversion table.
+        TInt loc = iConversionTable.FindInOrder( searchPhoneme, order );
+
+        // Not found? Add the phoneme as a new phoneme.
+        if ( loc == KErrNotFound )
+            {
+            searchPhoneme.iIndex = iConversionTable.Count();
+            User::LeaveIfError(
+                iConversionTable.InsertInOrder( searchPhoneme, order )
+                );
+
+            // Can't fail: the phoneme has just been added.
+            loc = iConversionTable.FindInOrder( searchPhoneme, order );
+
+            // Make sure that phoneme count fits in TUint8
+            if ( searchPhoneme.iIndex >= 250 )
+                {
+                User::Leave( KErrOverflow );
+                }
+            }
+
+        // Phoneme to index
+        // Case to TUint8 is safe - Checked 10 lines earlier.
+        TUint8 index = (TUint8)iConversionTable[ loc ].iIndex;
+        indexPronun->Des().Append( index );
+        }
+
+    // Add pronunciation to the list of "index-pronunciations"
+    User::LeaveIfError( iIndexPronuns.Append( indexPronun ) );
+    CleanupStack::Pop( indexPronun );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::Index2PhonemeLC
+// Restores an internal index string into ASCII phonemes.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CSILexiconSerializer::Index2PhonemeLC(const TDesC8& aIndexSeq)
+    {
+    TLinearOrder<TLexiconPhoneme> order( IndexOrderForPhonemes );
+    iConversionTable.Sort( order );
+
+    TInt length = 0;
+
+    TInt k( 0 );
+    for( k = 0; k < aIndexSeq.Length(); k++ )
+        {
+        TInt index = aIndexSeq[ k ];
+        length += iConversionTable[ index ].iPhoneme.Length();
+        length++; // Separator ('-')
+        }
+
+    HBufC8* buf = HBufC8::NewLC( length );
+    TPtr8 ptr = buf->Des();
+
+    TInt lastK = aIndexSeq.Length() -1; // Index of the last character
+
+    for( k = 0; k < aIndexSeq.Length(); k++ )
+        {
+        TInt index = aIndexSeq[ k ];
+        ptr.Append( iConversionTable[ index ].iPhoneme );
+
+        // Add separator, except for the last phoneme
+        if ( k != lastK )
+            {
+            ptr.Append( KPhonemeSeparator );
+            }
+        }
+
+    return( buf );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSILexiconSerializer* CSILexiconSerializer::NewLC( const CSILexicon& aLexicon )
+    {
+    CSILexiconSerializer* me = new (ELeave) CSILexiconSerializer;
+    CleanupStack::PushL( me );
+
+    me->ConstructL( aLexicon );
+
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSILexiconSerializer* CSILexiconSerializer::NewLC( RReadStream& aStream )
+    {
+    CSILexiconSerializer* me = new (ELeave) CSILexiconSerializer;
+    CleanupStack::PushL( me );
+
+    me->InternalizeL( aStream );
+
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconSerializer::ConstructL( const CSILexicon& aLexicon )
+    {
+    iLexiconID = aLexicon.LexiconID();
+    iCount     = aLexicon.Count();
+
+    iParamBuf = CBufFlat::NewL( 100 ); // Grow in 100 byte doses
+
+    RArray<TSIModelBankID> modelBankIDs;
+    RArray<TSIPronunciationID> pronunIDs;
+
+    CleanupClosePushL( modelBankIDs );
+    CleanupClosePushL( pronunIDs );
+
+    RBufWriteStream paramStream;
+    paramStream.Open( *iParamBuf );
+    CleanupClosePushL( paramStream );
+
+    // In serialization format, the 5 types of data in pronunciations
+    // are put to 4 piles. Then, the common properties of the data is exploited.
+    for ( TInt k = 0; k < aLexicon.Count(); k++ )
+        {
+        CSIPronunciation* pronun = &aLexicon.AtL( k );
+
+        // 4 types of pronunciation data
+        TInt err = KErrNone;
+        
+        // This is a hack to get the modelid aligned to 4-byte boundary,
+        // for some reason this does not happen in winscw build if 
+        // TSIModelBankID is taken from stack.
+        TSIModelBankID* modelid = new (ELeave) TSIModelBankID;
+        *modelid = pronun->ModelBankID();
+        
+        err |= modelBankIDs.Append( *modelid );
+
+        // Delete temporary modelid 
+        delete modelid;
+        
+        err |= pronunIDs.Append( pronun->PronunciationID() );
+
+        User::LeaveIfError( err );
+
+        SavePronunciationL( pronun );
+
+        // Parameters
+        pronun->CSIParameters::ExternalizeL( paramStream );
+        }
+
+    // Code the piled values
+    // Casts are safe, as all variables are 32-bit (they are just called
+    // with many different names - int, unsigned long, unsigned int)
+    iPronunIDs = CNibble16Coder::NewL( pronunIDs );
+    iModelBankIDs = CRLECoder::NewL( modelBankIDs );
+
+    CleanupStack::PopAndDestroy( &paramStream );
+
+    CleanupStack::PopAndDestroy( 2 ); // Close the RArrays
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::ExternalizeL
+// Stores the object to the stream.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconSerializer::ExternalizeL( RWriteStream& aStream )
+    {
+    aStream.WriteInt32L( KBinaryLexiconID );
+
+    aStream.WriteInt32L( iLexiconID );
+    aStream.WriteInt32L( iCount );
+
+    // Write model bank IDs.
+    iModelBankIDs->ExternalizeL( aStream );
+    // Write pronunciation IDs
+    iPronunIDs->ExternalizeL( aStream );
+
+    // Write pronunciations (converted from phonemes to indices)
+    aStream.WriteInt32L( iIndexPronuns.Count() );
+
+    TInt k( 0 );
+    for ( k = 0; k < iIndexPronuns.Count(); k++ )
+        {
+        HBufC8* pronun = iIndexPronuns[ k ];
+
+        // There is no fixed limit on the length of a phoneme sequence.
+        // It's not even guaranteed that the length fits in 32 bits, damnit!
+        if ( pronun->Length() > 64000 )
+            {
+            User::Leave( KErrNotSupported );
+            }
+
+        aStream.WriteUint16L( pronun->Length() );
+        aStream.WriteL( pronun->Ptr(), pronun->Length() );
+        }
+
+    // Write parameters
+    aStream.WriteInt32L( iParamBuf->Size() );
+    aStream.WriteL( iParamBuf->Ptr(0) );
+
+    // Write phoneme<->index conversion table
+    aStream.WriteInt32L( iConversionTable.Count() );
+    for ( k = 0; k < iConversionTable.Count(); k++ )
+        {
+        aStream.WriteL( (TUint8*)&iConversionTable[k],
+                        sizeof( TLexiconPhoneme ) );
+        }
+
+    // For corruption checking
+    aStream.WriteInt32L( KBinaryLexiconID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::InternalizeL
+// Restores the object from a stream
+// -----------------------------------------------------------------------------
+//
+void CSILexiconSerializer::InternalizeL(RReadStream& aStream)
+    {
+    if ( aStream.ReadInt32L() != KBinaryLexiconID )
+        User::Leave( KErrArgument );
+
+    iLexiconID = (TSILexiconID)aStream.ReadUint32L();
+    iCount     = aStream.ReadInt32L();
+
+    // Read model bank IDs
+    iModelBankIDs = CRLECoder::NewL( aStream );
+    // Read pronunciation IDs
+    iPronunIDs = CNibble16Coder::NewL( aStream );
+
+    // Read pronunciations (converted from phonemes to indices)
+    TInt indexCount = aStream.ReadInt32L();
+
+    if ( indexCount != iCount )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    TInt k( 0 );
+    for ( k = 0; k < indexCount; k++ )
+        {
+        HBufC8* pronun = 0;
+
+        TUint16 length = aStream.ReadUint16L();
+        pronun         = HBufC8::NewLC( length );
+
+        TPtr8 pronunPtr = pronun->Des();
+        aStream.ReadL( pronunPtr, length );
+
+        User::LeaveIfError( iIndexPronuns.Append( pronun ) );
+
+        CleanupStack::Pop( pronun );
+        }
+
+    // Read parameters
+    TInt size = aStream.ReadInt32L();
+    iParamBuf = CBufFlat::NewL( size+4 );
+    iParamBuf->ExpandL( 0, size );
+
+    TPtr8 paramBufPtr = iParamBuf->Ptr(0);
+    aStream.ReadL( paramBufPtr, size );
+
+    // Read phoneme<->index conversion table
+    TInt conversionCount = aStream.ReadInt32L();
+    for ( k = 0; k < conversionCount; k++ )
+        {
+        TLexiconPhoneme lexiconPhoneme;
+
+        aStream.ReadL( (TUint8*)&lexiconPhoneme,
+                        sizeof( TLexiconPhoneme ) );
+
+        User::LeaveIfError( iConversionTable.Append( lexiconPhoneme ) );
+        }
+
+    // For corruption checking
+    if ( aStream.ReadInt32L() != KBinaryLexiconID  )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconSerializer::RestoreL
+// Populates CSILexicon with the newly internalized data.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconSerializer::RestoreL( CSILexicon& aLexicon, TSILexiconID& aLexiconID )
+    {
+    if ( aLexicon.Count() > 0 )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    TSIModelBankID modelBankID = 0;
+    TSIPronunciationID pronunID = 0;
+
+    RBufReadStream paramStream;
+    paramStream.Open( *iParamBuf );
+    CleanupClosePushL( paramStream );
+
+    iModelBankIDs->DecodeReset();
+    iPronunIDs->DecodeReset();
+
+    TInt iterPronunPos = 0;
+
+    for ( TInt pronunK = 0; pronunK < iCount; pronunK++ )
+        {
+        modelBankID = iModelBankIDs->NextL();
+        pronunID   = iPronunIDs->NextL();
+
+        CSIPronunciation* pronun
+            = CSIPronunciation::NewLC( pronunID, modelBankID ); 
+
+        HBufC8* indexSequence = iIndexPronuns[ iterPronunPos ];
+        iterPronunPos++;
+
+        HBufC8* phonemeSequence = Index2PhonemeLC( *indexSequence );
+        pronun->SetPhonemeSequenceL( *phonemeSequence );
+        CleanupStack::PopAndDestroy( phonemeSequence );
+
+        pronun->CSIParameters::InternalizeL( paramStream );
+
+        aLexicon.AddL( pronun );
+        CleanupStack::Pop( pronun );
+        }
+
+    CleanupStack::PopAndDestroy( &paramStream );
+
+    // LexiconID can't be written to CSILexicon with public API.
+    aLexiconID = iLexiconID;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Implementation of CSIGrammarSerializer starts from here.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::CSIGrammarSerializer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIGrammarSerializer::CSIGrammarSerializer()
+    {
+    iGrammarID = KInvalidGrammarID;
+    iCount = 0;
+    iRuleIDs                = NULL;
+    iRuleVariantCounts      = NULL;
+    iRuleVariantIDs         = NULL;
+    iRuleVariantLexiconIDs  = NULL;
+    iRuleVariantLanguages   = NULL;
+    iPronunIDSeqLengths     = NULL;
+    iPronunIDSequences      = NULL;
+    iParamBuf               = NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::~CSIGrammarSerializer
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CSIGrammarSerializer::~CSIGrammarSerializer()
+    {
+    delete iRuleIDs;
+    delete iRuleVariantCounts;
+    delete iRuleVariantIDs;
+    delete iRuleVariantLexiconIDs;
+    delete iRuleVariantLanguages;
+    delete iPronunIDSeqLengths;
+    delete iPronunIDSequences;
+    delete iParamBuf;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIGrammarSerializer* CSIGrammarSerializer::NewLC( const CSIGrammar& aGrammar )
+    {
+    CSIGrammarSerializer* me = new (ELeave) CSIGrammarSerializer();
+    CleanupStack::PushL( me );
+
+    me->ConstructL( aGrammar );
+
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarSerializer::ConstructL( const CSIGrammar& aGrammar )
+    {
+    iParamBuf = CBufFlat::NewL( 100 ); // Grow in 100 byte doses
+    RBufWriteStream paramStream;
+    paramStream.Open( *iParamBuf );
+    CleanupClosePushL( paramStream ); // Cleanp stack: param stream
+
+    RArray<TSIRuleID> ruleIDs;
+    RArray<TUint32> ruleVariantCounts;
+    RArray<TUint32> ruleVariantIDs;
+    RArray<TSILexiconID> ruleVariantLexiconIDs;
+    RArray<TUint32> ruleVariantLanguages;
+    RArray<TUint32> pronunIDSeqLengths;
+    RArray<TSIPronunciationID> pronunIDSequences;
+
+    CleanupClosePushL( ruleIDs );
+    CleanupClosePushL( ruleVariantCounts );
+    CleanupClosePushL( ruleVariantIDs );
+    CleanupClosePushL( ruleVariantLexiconIDs );
+    CleanupClosePushL( ruleVariantLanguages );
+    CleanupClosePushL( pronunIDSeqLengths );
+    CleanupClosePushL( pronunIDSequences  ); // Cleanup stack: param stream, 7 tmp arrays
+
+    TInt err = KErrNone;
+
+    // Pile the data according to type (8 types)
+    for ( TInt ruleK( 0 ); ruleK < aGrammar.Count(); ruleK++ )
+        {
+        CSIRule& rule = aGrammar.AtL( ruleK );
+
+        err |= ruleIDs.Append( rule.RuleID() );
+        err |= ruleVariantCounts.Append( rule.Count() );
+
+        for ( TInt variantK( 0 ); variantK < rule.Count(); variantK++ )
+            {
+            CSIRuleVariant& variant = rule.AtL( variantK );
+
+            err |= ruleVariantIDs.Append( variant.RuleVariantID() );
+            
+            // This is a hack to get the lexid aligned to 4-byte boundary,
+            // for some reason this does not happen in winscw build if 
+            // TSILexiconID is taken from stack.
+            TSILexiconID* lexid = new (ELeave) TSILexiconID;
+            *lexid = variant.LexiconID();
+           
+            err |= ruleVariantLexiconIDs.Append( *lexid );
+            
+            delete lexid;
+            
+            err |= ruleVariantLanguages.Append( variant.Language() );
+
+            TSIPronunciationIDSequence seq;
+            CleanupClosePushL( seq ); // Cleanup stack: param stream, 7 tmp arrays, seq
+            
+            variant.GetPronunciationIDsL( seq );
+
+            err |= pronunIDSeqLengths.Append( seq.Count() );
+
+            for ( TInt k( 0 ); k < seq.Count(); k++ )
+                {
+                err |= pronunIDSequences.Append( seq[k] );
+                }
+
+            CleanupStack::PopAndDestroy( &seq );
+            // Cleanup stack: param stream, 7 tmp arrays
+
+            // Store parameters to a buffer.
+            variant.ExternalizeL( paramStream );
+            }
+
+        User::LeaveIfError( err );
+        }
+
+    // Code the arrays
+    iGrammarID             = aGrammar.GrammarID();
+    iCount                 = aGrammar.Count();
+
+    iRuleIDs               = CNibble16Coder::NewL( ruleIDs );
+    iRuleVariantCounts     = CNibble4Coder::NewL( ruleVariantCounts );
+    iRuleVariantIDs        = CNibble4Coder::NewL( ruleVariantIDs );
+    iRuleVariantLexiconIDs = CRLECoder::NewL( ruleVariantLexiconIDs );
+    // Cast is safe, since TLanguage is 32-bit
+    iRuleVariantLanguages  = CNibble4Coder::NewL( ruleVariantLanguages );
+    iPronunIDSeqLengths    = CNibble4Coder::NewL( pronunIDSeqLengths );
+    iPronunIDSequences     = CNibble16Coder::NewL( pronunIDSequences );
+
+    CleanupStack::PopAndDestroy( 7 ); // Destory 7 tmp arrays
+    CleanupStack::PopAndDestroy( &paramStream ); // Destroy parameter stream
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::ExternalizeL
+// Stores the object to the stream.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarSerializer::ExternalizeL( RWriteStream& aStream )
+    {
+    aStream.WriteUint32L( ( TUint32 ) KBinaryGrammarID );
+    aStream.WriteUint32L( iGrammarID );
+    aStream.WriteUint32L( iCount );
+
+    iRuleIDs              ->ExternalizeL( aStream );
+    iRuleVariantCounts    ->ExternalizeL( aStream );
+    iRuleVariantIDs       ->ExternalizeL( aStream );
+    iRuleVariantLexiconIDs->ExternalizeL( aStream );
+    iRuleVariantLanguages ->ExternalizeL( aStream );
+    iPronunIDSeqLengths   ->ExternalizeL( aStream );
+    iPronunIDSequences    ->ExternalizeL( aStream );
+
+    aStream.WriteInt32L( iParamBuf->Size() );
+    aStream.WriteL( iParamBuf->Ptr(0) );
+
+    aStream.WriteUint32L( ( TUint32 ) KBinaryGrammarID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIGrammarSerializer* CSIGrammarSerializer::NewLC(RReadStream& aStream)
+    {
+    CSIGrammarSerializer* me = new (ELeave) CSIGrammarSerializer();
+    CleanupStack::PushL( me );
+
+    me->ConstructL( aStream );
+
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarSerializer::ConstructL( RReadStream& aStream )
+    {
+    if ( aStream.ReadInt32L() != KBinaryGrammarID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    iGrammarID = (TSIGrammarID)aStream.ReadUint32L();
+    iCount     = aStream.ReadUint32L();
+
+    iRuleIDs              = CNibble16Coder::NewL( aStream );
+    iRuleVariantCounts    = CNibble4Coder::NewL( aStream );
+    iRuleVariantIDs       = CNibble4Coder::NewL( aStream );
+    iRuleVariantLexiconIDs= CRLECoder::NewL( aStream );
+    iRuleVariantLanguages = CNibble4Coder::NewL( aStream );
+    iPronunIDSeqLengths   = CNibble4Coder::NewL( aStream );
+    iPronunIDSequences    = CNibble16Coder::NewL( aStream );
+
+    TInt32 paramSize = aStream.ReadInt32L();
+    iParamBuf = CBufFlat::NewL( paramSize + 4 );
+    iParamBuf->ExpandL( 0, paramSize );
+    TPtr8 paramBufPtr = iParamBuf->Ptr(0);
+    aStream.ReadL( paramBufPtr, paramSize );
+
+    if ( aStream.ReadInt32L() != KBinaryGrammarID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarSerializer::RestoreL
+// Populates the CSIGrammar with newly internalized data.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarSerializer::RestoreL( CSIGrammar& aGrammar, TSIGrammarID& aGrammarID )
+    {
+    if ( aGrammar.Count() != 0 )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    aGrammarID = iGrammarID;
+
+    TBool ready = iRuleIDs && iRuleVariantCounts && iRuleVariantIDs &&
+                  iRuleVariantLexiconIDs && iRuleVariantLanguages &&
+                  iPronunIDSeqLengths && iPronunIDSequences;
+
+    if ( !ready )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    iRuleIDs->DecodeReset();
+    iRuleVariantCounts->DecodeReset();
+    iRuleVariantIDs->DecodeReset();
+    iRuleVariantLexiconIDs->DecodeReset();
+    iRuleVariantLanguages->DecodeReset();
+    iPronunIDSeqLengths->DecodeReset();
+    iPronunIDSequences->DecodeReset();
+
+    RBufReadStream paramStream;
+    CleanupClosePushL( paramStream );
+
+    paramStream.Open( *iParamBuf );
+
+    for ( TInt ruleK( 0 ); ruleK < iCount; ruleK++ )
+        {
+        CSIRule* rule = CSIRule::NewLC( iRuleIDs->NextL() );
+
+        TInt ruleVariantCount = iRuleVariantCounts->NextL();
+
+        for ( TInt variantK( 0 ); variantK < ruleVariantCount; variantK++ )
+            {
+            CSIRuleVariant* variant = CSIRuleVariant::NewLC(
+                (TSIRuleVariantID)iRuleVariantIDs->NextL(),
+                iRuleVariantLexiconIDs->NextL()
+                );
+
+            variant->SetLanguage(
+                (enum TLanguage)iRuleVariantLanguages->NextL() );
+
+            RArray<TSIPronunciationID> pronunIDSeq;
+            CleanupClosePushL( pronunIDSeq );
+
+            TInt seqLength = iPronunIDSeqLengths->NextL();
+            for ( TInt pronunIdK( 0 ); pronunIdK < seqLength; pronunIdK++ )
+                {
+                TInt err = pronunIDSeq.Append( iPronunIDSequences->NextL() );
+                User::LeaveIfError( err );
+                }
+
+            variant->SetPronunciationIDsL( pronunIDSeq );
+            CleanupStack::PopAndDestroy( &pronunIDSeq );
+
+            variant->CSIParameters::InternalizeL( paramStream );
+            rule->AddL( variant );
+            CleanupStack::Pop( variant );
+            }
+
+        aGrammar.AddL( rule );
+        CleanupStack::Pop( rule );
+        }
+
+    CleanupStack::PopAndDestroy( &paramStream );
+    }
+
+
+// -----------------------------------------------------------------------------
+// Implementation of CNibble16Coder starts from here.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CNibble16Coder::CNibble16Coder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNibble16Coder::CNibble16Coder()
+: iMainArray(50),
+  iOverflowArray(10)
+    {
+    DecodeReset();
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble16Coder::NewL
+// Two-phased constructor. Encodes the values given as the argument.
+// -----------------------------------------------------------------------------
+//
+CNibble16Coder* CNibble16Coder::NewL( const RArray<TUint32>& aPlainArray )
+    {
+    CNibble16Coder* me = new (ELeave) CNibble16Coder;
+    CleanupStack::PushL( me );
+
+    TInt count = aPlainArray.Count();;
+    TInt sizeNeeded = (count+1) / 2;
+
+    // Grow the array to be big enough
+    TInt k( 0 );
+    for ( k = 0; k < sizeNeeded; k++ )
+        {
+        User::LeaveIfError( me->iMainArray.Append( 0xffffffff ) );
+        }
+
+    TUint16* storagePtr = 0;
+
+    if ( count > 0 )
+        {
+        storagePtr = (TUint16*)&me->iMainArray[0];
+        }
+
+    for( k = 0; k < count; k++ )
+        {
+        TSIPronunciationID id = aPlainArray[ k ];
+        TBool overflow = false;
+
+        // If the 32-bit value doesn't fit to 16 bits:
+        //  * Put overflow sign to main array
+        //  * Put the real ID to overflow array
+        if ( id >= KNibble16Limit )
+            {
+            overflow = true;
+            id = KNibble16Limit;
+            }
+
+        // Write to the main array
+        // ([overflow sign] OR [id, which fits to 16 bits])
+        *(storagePtr++) = (TUint16)id;
+
+        // If it didn't fit to 16 bits, save it to the overflow array.
+        if ( overflow )
+            {
+            TInt err = me->iOverflowArray.Append( aPlainArray[k] );
+            User::LeaveIfError( err );
+            }
+        }
+
+    CleanupStack::Pop( me );
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble16Coder::NewL
+// Two-phased constructor. Internalizes an array from stream.
+// -----------------------------------------------------------------------------
+//
+CNibble16Coder* CNibble16Coder::NewL( RReadStream& aStream )
+    {
+    CNibble16Coder* me = new (ELeave) CNibble16Coder;
+    CleanupStack::PushL( me );
+
+    if ( aStream.ReadInt32L() != KBinaryNibble16ID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    Internalize32bitArrayL( aStream, me->iMainArray     );
+    Internalize32bitArrayL( aStream, me->iOverflowArray );
+
+    CleanupStack::Pop( me );
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble16Coder::~CNibble16Coder
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CNibble16Coder::~CNibble16Coder()
+    {
+    iMainArray.Close();
+    iOverflowArray.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble16Coder::DecodeReset
+// Moves cursor to the beginning of the array.
+// -----------------------------------------------------------------------------
+//
+void CNibble16Coder::DecodeReset()
+    {
+    iPosition = 0;
+    iOverflowPos = 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble16Coder::NextL
+// Returns a value in the array and moves the cursor forward.
+// -----------------------------------------------------------------------------
+//
+TUint32 CNibble16Coder::NextL()
+    {
+    if ( iPosition >= 2*iMainArray.Count() )
+        User::Leave( KErrOverflow );
+
+    TUint16* storagePtr = (TUint16*)&iMainArray[0];
+
+    // Get the [pronunciation ID] OR [overflow sign] from main array.
+    TSIPronunciationID id = storagePtr[ iPosition ];
+
+    // It was overflow sign; get whole 32-bit ID from overflow array
+    if ( id == KNibble16Limit ) // It was pronunciation ID
+        {
+        if ( iOverflowPos == iOverflowArray.Count() )
+            {
+            User::Leave( KErrOverflow );
+            }
+
+        id = iOverflowArray[ iOverflowPos ];
+        iOverflowPos++;
+        }
+
+    // Update iterator
+    iPosition++;
+
+    return( id );
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble16Coder::ExternalizeL
+// Externalizes the array into a stream.
+// -----------------------------------------------------------------------------
+//
+void CNibble16Coder::ExternalizeL( RWriteStream& aStream )
+    {
+    aStream.WriteInt32L( KBinaryNibble16ID );
+    Externalize32bitArrayL( aStream, iMainArray );
+    Externalize32bitArrayL( aStream, iOverflowArray );
+    }
+
+
+// -----------------------------------------------------------------------------
+// Implementation of CNibble4Coder starts from here.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CNibble4Coder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNibble4Coder* CNibble4Coder::NewL( const RArray<TUint32>& aPlainArray )
+    {
+    CNibble4Coder* me = new (ELeave) CNibble4Coder;
+    CleanupStack::PushL( me );
+    me->DecodeReset();
+
+    TInt count = aPlainArray.Count();
+
+    for ( TInt k( 0 ); k < count; k++ )
+        {
+        TUint compactValue = aPlainArray[ k ];
+        TBool overflow = EFalse;
+
+        // If the value does not fit to 4 bytes, put an overflow sign to main
+        // array, and save the value to a separate overflow array.
+        if ( compactValue >= KNibble4Limit )
+            {
+            compactValue = KNibble4Limit;
+            overflow = true;
+            }
+
+        // Save the compact value
+        if ( me->iSlot == 0 )
+            {
+            User::LeaveIfError( me->iMainArray.Append( compactValue ) );
+            me->iSlot++;
+            }
+        else{
+            // We save 4-bit values to 32-bit variable. So, there are 8 slots
+            // in each 32-bit entry.
+
+            // Shift the value to correct slot. 
+            // Earlier, we have made sure, that compactValue < 16.
+            compactValue = compactValue << (4 * me->iSlot);
+
+            // Put it to the array.
+            me->iMainArray[ me->iPosition ]
+                = compactValue | me->iMainArray[ me->iPosition ];
+
+            // Update iterator
+            me->iSlot++;
+            if ( me->iSlot == 8 )
+                {
+                me->iPosition++;
+                me->iSlot = 0;
+                }
+            }
+
+        // If the value didn't fit to 4 bits, save it to 32-bit overflow array.
+        if ( overflow )
+            {
+            TInt ret = me->iOverflowArray.Append( aPlainArray[ k ] );
+            User::LeaveIfError( ret );
+            }
+        }
+
+    // If the number of entries was not divisible by 8, we have
+    // uninitialized slots in the end. Initialize them with 0xf.
+
+    // If the decoder finds one of these 0xf's, it goes to overflow array,
+    // notices that all entries in the overflow array have been processed,
+    // and leaves.
+    if ( me->iSlot != 0 )
+        {
+        TUint unusedValue = 0xffffffff;
+        unusedValue = unusedValue << (4 * me->iSlot);
+
+        me->iMainArray[ me->iPosition ] 
+            = unusedValue | me->iMainArray[ me->iPosition ];
+        }
+
+    me->DecodeReset();
+    CleanupStack::Pop( me );
+    return me;
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble4Coder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNibble4Coder* CNibble4Coder::NewL( RReadStream& aStream )
+    {
+    CNibble4Coder* me = new (ELeave) CNibble4Coder;
+    CleanupStack::PushL( me );
+    me->DecodeReset();
+
+    if ( aStream.ReadInt32L() != KBinaryNibble4ID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    Internalize32bitArrayL( aStream, me->iMainArray     );
+    Internalize32bitArrayL( aStream, me->iOverflowArray );
+
+    CleanupStack::Pop( me );
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble4Coder::CNibble4Coder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNibble4Coder::CNibble4Coder()
+: iMainArray(50),
+  iOverflowArray(10)
+    {
+    DecodeReset();
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble4Coder::~CNibble4Coder
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CNibble4Coder::~CNibble4Coder()
+    {
+    iMainArray.Close();
+    iOverflowArray.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble4Coder::DecodeReset
+// Moves cursor to the beginning of the array.
+// -----------------------------------------------------------------------------
+//
+void CNibble4Coder::DecodeReset()
+    {
+    iPosition = 0;
+    iSlot     = 0;
+    iOverflowPos = 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble4Coder::NextL
+// Returns a value in the array and moves cursor forwards.
+// -----------------------------------------------------------------------------
+//
+TUint32 CNibble4Coder::NextL()
+    {
+    if ( iPosition >= iMainArray.Count() )
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    TUint result = iMainArray[ iPosition ];
+
+    // In binary, the array entry is something like:
+    // hhhhhhhhhhhhhhhhrrrrllllllllllll (32 bits)
+    // r = result bits we're after
+    // h = higher bits
+    // l = lower bits
+
+    // Drop the lower bits
+    result = result >> (4 * iSlot );
+    // Drop the higher bits
+    result = result & 0xf;
+
+    // If the value didn't fit to 4 bits, get it from the overflow array.
+    if ( result >= KNibble4Limit )
+        {
+        if ( iOverflowPos >= iOverflowArray.Count() )
+            {
+            User::Leave( KErrOverflow );
+            }
+
+        result = iOverflowArray[ iOverflowPos ];
+        iOverflowPos++;
+        }
+
+    // Update iterator
+    iSlot++;
+    if ( iSlot == 8 )
+        {
+        iPosition++;
+        iSlot = 0;
+        }
+
+    return( result );
+    }
+
+// -----------------------------------------------------------------------------
+// CNibble4Coder::ExternalizeL
+// Stores the object to the stream.
+// -----------------------------------------------------------------------------
+//
+void CNibble4Coder::ExternalizeL( RWriteStream& aStream )
+    {
+    aStream.WriteInt32L( KBinaryNibble4ID );
+    Externalize32bitArrayL( aStream, iMainArray );
+    Externalize32bitArrayL( aStream, iOverflowArray );
+    }
+
+
+// -----------------------------------------------------------------------------
+// Implementation of CRLECoder starts from here.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CRLECoder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRLECoder* CRLECoder::NewL( const RArray<TUint16>& aPlainArray )
+    {
+    CRLECoder* me = new (ELeave) CRLECoder;
+    CleanupStack::PushL( me );
+    me->DecodeReset();
+
+    if ( aPlainArray.Count() == 0 )
+        {
+        CleanupStack::Pop();
+        return( me );
+        }
+
+    TInt count = aPlainArray.Count();
+
+    if ( count > 0 )
+        {
+        CRLECoder::TValueAndCount valueCount;
+
+        valueCount.iValue = aPlainArray[ 0 ];
+        valueCount.iCount = 1;
+
+        for ( TInt k( 1 ); k < count; k++ )
+            {
+            if ( aPlainArray[ k ] == valueCount.iValue )
+                {
+                valueCount.iCount++;
+                }
+            else{
+                User::LeaveIfError( me->iRleArray.Append( valueCount ) );
+
+                valueCount.iCount = 1;
+                valueCount.iValue = aPlainArray[ k ];
+                }
+            }
+
+        User::LeaveIfError( me->iRleArray.Append( valueCount ) );
+        }
+
+    CleanupStack::Pop( me );
+    return me;
+    }
+
+// -----------------------------------------------------------------------------
+// CRLECoder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRLECoder* CRLECoder::NewL( RReadStream& aStream )
+    {
+    CRLECoder* me = new (ELeave) CRLECoder;
+    CleanupStack::PushL( me );
+    me->DecodeReset();
+
+    if ( aStream.ReadInt32L() != KBinaryRLEID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    TInt count = aStream.ReadInt32L();
+    TInt err = KErrNone;
+
+    TUint32 value;
+    CRLECoder::TValueAndCount* valuePtr = (CRLECoder::TValueAndCount*)&value;
+
+    for ( TInt k( 0 ); k < count; k++ )
+        {
+        value = aStream.ReadInt32L();
+        err |= me->iRleArray.Append( *valuePtr );
+        }
+
+    User::LeaveIfError( err );
+
+    CleanupStack::Pop( me );
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CRLECoder::CRLECoder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRLECoder::CRLECoder()
+: iRleArray(50)
+    {
+    DecodeReset();
+    }
+
+// -----------------------------------------------------------------------------
+// CRLECoder::~CRLECoder
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CRLECoder::~CRLECoder()
+    {
+    iRleArray.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CRLECoder::DecodeReset
+// Moves cursor to the beginning of the array.
+// -----------------------------------------------------------------------------
+//
+void CRLECoder::DecodeReset()
+    {
+    iPosition = 0;
+    iRepetition = 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CRLECoder::NextL
+// Returns a value in the array and moves cursor forwards.
+// -----------------------------------------------------------------------------
+//
+TUint16 CRLECoder::NextL()
+    {
+    if ( iPosition >= iRleArray.Count() ) 
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    TUint16 result = iRleArray[iPosition].iValue;
+
+    iRepetition++;
+    TUint16 maxRepetitions = iRleArray[iPosition].iCount;
+
+    if ( iRepetition >= maxRepetitions )
+        {
+        iPosition++;
+        iRepetition = 0;
+        }
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CRLECoder::ExternalizeL
+// Stores the object to the stream.
+// -----------------------------------------------------------------------------
+//
+void CRLECoder::ExternalizeL( RWriteStream& aStream )
+    {
+    aStream.WriteInt32L( KBinaryRLEID );
+    TInt count = iRleArray.Count();
+
+    aStream.WriteInt32L( count );
+
+    if ( count > 0 )
+        {
+        TValueAndCount* startPtr = &(iRleArray[0]);
+        aStream.WriteL( (TUint8*)startPtr, sizeof(TValueAndCount) * count );
+        }
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// Implementation of CYesNoCoder starts from here.
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CYesNoCoder::DecodeReset
+// Moves cursor to the beginning of the array.
+// -----------------------------------------------------------------------------
+//
+void CYesNoCoder::DecodeReset()
+    {
+    iPosition = 0;
+    iMask = 0x00000001;
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::NextBit
+// Moves the cursor forwards.
+// -----------------------------------------------------------------------------
+//
+void CYesNoCoder::NextBit(void)
+    {
+    // Increase the iterator.
+    iMask <<= 1;
+    if ( iMask == 0 )
+        {
+        iPosition++;
+        iMask = 1;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CYesNoCoder* CYesNoCoder::NewL()
+    {
+    CYesNoCoder* me = new (ELeave) CYesNoCoder;
+
+    me->DecodeReset();
+
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CYesNoCoder* CYesNoCoder::NewL( RReadStream& aStream )
+    {
+    CYesNoCoder* me = new (ELeave) CYesNoCoder;
+    CleanupStack::PushL( me );
+    me->DecodeReset();
+
+    Internalize32bitArrayL( aStream, me->iStore );
+
+    CleanupStack::Pop( me );
+    return( me );
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::CYesNoCoder
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CYesNoCoder::CYesNoCoder()
+: iStore(10)
+    {
+    DecodeReset();
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::~CYesNoCoder
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CYesNoCoder::~CYesNoCoder()
+    {
+    iStore.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::EncodeL
+// Encodes a bit.
+// -----------------------------------------------------------------------------
+//
+void CYesNoCoder::EncodeL( TBool aValue )
+    {
+    // Do we need to grow the size of the array?
+    if ( iMask == 1 )
+        {
+        User::LeaveIfError( iStore.Append( 0 ) );
+        }
+
+    // Store the value, if it is 'yes'.
+    if ( aValue )
+        {
+        iStore[ iPosition ] |= iMask;
+        }
+
+    // Increase the iterator
+    NextBit();
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::NextL
+// Returns a value in the array and moves cursor forwards.
+// -----------------------------------------------------------------------------
+//
+TBool CYesNoCoder::NextL()
+    {
+    TBool result = iStore[ iPosition ] & iMask;
+
+    // Increase the iterator
+    NextBit();
+
+    return( result );
+    }
+
+// -----------------------------------------------------------------------------
+// CYesNoCoder::ExternalizeL
+// Stores the object to the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+void CYesNoCoder::ExternalizeL( RWriteStream& aStream )
+    {
+    aStream.WriteInt32L( KBinaryYesNoID );
+    Externalize32bitArrayL( aStream, iStore );
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/src/nsssidataserialize.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,688 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Serialization functions for CSIGrammar and CSILexicon
+*
+*/
+
+
+
+#ifndef SIDATASERIALIZE_H
+#define SIDATASERIALIZE_H
+
+//  INCLUDES
+//#include <?include_file>
+#include <nsssispeechrecognitiondatadevasr.h>
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+
+// The grammar and the lexicon have a binary format.
+// These IDs identify the format.
+const TInt32 KBinaryGrammarID   = 0xAACF1234;
+const TInt32 KBinaryCompiledGrammarID = 0xAACF1235;
+const TInt32 KBinaryLexiconID   = 0xAACF1236;
+const TInt32 KBinaryResultSetID = 0xAACF1237;
+const TInt32 KBinaryParameterID = 0xAACF1238;
+
+const TInt32 KBinaryNibble16ID  = 0xAACF1239;
+const TInt32 KBinaryNibble4ID   = 0xAACF123A;
+const TInt32 KBinaryRLEID       = 0xAACF123B;
+const TInt32 KBinaryYesNoID     = 0xAACF123C;
+
+const TInt KShortPronunLimit   = 0xffff;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+struct TLexiconPhoneme // comment
+    {
+    TBuf8<KMaxPhonemeLength+1> iPhoneme;
+    TInt                       iIndex;
+    };
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+
+
+/**
+*  Serialization of CSILexicon
+*  Lexicon is a container of pronunciations. It contains 5 types of information.
+*  This class puts the informaiton to 5 piles, and uses primitive encoding
+*  methods to reduce the space needed. The methods used are:
+*
+*   * Nibble coding: Suppose you have k 32-bit values, but most of them fit to
+*                    16 bit. This method creates a k-length array of 16-bit
+*                    values. If the original value fits, it is placed there.
+*                    If it is too large, the value in this compact array
+*                    signals that the real value is in a 32-bit 'overflow' array.
+*   * RLE coding: For values, which are almost always the same. For example,
+*                 model bank for pronunciations, and lexicon for rule variants.
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+
+
+
+/**
+* Codes 32-bit unsigned integers to 16 bits.
+* Sorts the values to two classes: those, which fit to 16 bits, and those,
+* which require 32 bits. Then those, which require 32 bits are placed to an
+* overflow array.
+*
+* Space is saved, if over 50% of values fit to 16 bits.
+*
+* @lib SISpeechRecognitionData.lib
+* @since 2.8
+*/
+class CNibble16Coder : public CBase
+    {
+public: // Constructors and destructors
+    /**
+    * Codes an array.
+    * @since 2.8
+    * @param aPlainArray Array to be encoded
+    * @return none
+    */
+    static CNibble16Coder* NewL( const RArray<TUint32>& aPlainArray );
+
+    /**
+    * Reads an array from stream.
+    * @since 2.8
+    * @param aStream a stream, where a CNibble16Coder was previously stored.
+    * @return none
+    */
+    static CNibble16Coder* NewL( RReadStream& aStrem );
+
+    /**
+    * Destructor..
+    */
+    ~CNibble16Coder();
+
+public: // New functions
+    /**
+    * Initializes the iterator.
+    * @since 2.8
+    * @param aIterator The iterator
+    * @return none
+    */
+    void DecodeReset();
+
+    /**
+    * Decodes one value. Leaves with KErrOverflow, if all values in the array
+    * have been read.
+    * @since 2.8
+    * @return The decoded value.
+    */
+    TUint32 NextL();
+
+    /**
+    * Externalizes the array to the stream.
+    * @since 2.8
+    * @param aStream Stream to store into.
+    * @return none
+    */
+    void ExternalizeL(RWriteStream& aStream);
+
+private:
+    /**
+    * C++ default constructor.
+    */
+    CNibble16Coder();
+
+private:
+    // Those values, which fit to 16 bits
+    RArray<TUint32> iMainArray;
+
+    // The king size values requiring 32 bits
+    RArray<TUint32> iOverflowArray;
+
+    /**************** Iterator variables ***************/
+    // Intex to the main array
+    TInt iPosition;
+
+    // Index to the overflow array
+    TInt iOverflowPos;
+    /************** Iterator variables end *************/
+    };
+
+/**
+* Codes 32-bit unsigned integers to 4 bits.
+* Sorts the values to two classes: those, which fit to 4 bits, and those,
+* which require 32 bits. Then those, which require 32 bits are placed to an
+* overflow array.
+*
+* @lib SISpeechRecognitionData.lib
+* @since 2.8
+*/
+class CNibble4Coder : public CBase
+    {
+public: // Constructors and destructors
+    /**
+    * Codes an array of 32-bit variables to 2 arrays,
+    * one 4-bit and the other 32-bit.
+    * @since 2.8
+    * @param aMainArray Populated during the function
+    * @param aOverflowArray Populated during the function
+    * @param aPlainArray Array to be encoded
+    * @return none
+    */
+    static CNibble4Coder* NewL( const RArray<TUint32>& aPlainArray );
+
+    /**
+    * Reads an array from stream.
+    * @since 2.8
+    * @param aStream a stream, where a CNibble4Coder was previously stored.
+    * @return none
+    */
+    static CNibble4Coder* NewL( RReadStream& aStrem );
+
+    /**
+    * Destructor..
+    */
+    ~CNibble4Coder();
+
+public: // New functions
+
+    /**
+    * Initializes the iterator.
+    * @since 2.8
+    * @param aIterator The iterator
+    * @return none
+    */
+    void DecodeReset();
+
+    /**
+    * Decodes one value. Leaves with KErrOverflow, if all values in the array
+    * have been read.
+    * @since 2.8
+    * @param aResult Result is placed to this variable.
+    * @param aIterator The iterator
+    * @param aMainArray Contains coded data.
+    * @param aOverflowArray Contains coded data.
+    * @return none
+    */
+    TUint32 NextL();
+
+    /**
+    * Externalizes the array to the stream.
+    * @since 2.8
+    * @param aStream Stream to store into.
+    * @return none
+    */
+    void ExternalizeL(RWriteStream& aStream);
+
+private:
+    /**
+    * C++ default constructor.
+    */
+    CNibble4Coder();
+
+private:
+    // Those values, which fit to 4 bits
+    RArray<TUint32> iMainArray;
+
+    // The values requiring more
+    RArray<TUint32> iOverflowArray;
+
+    /**************** Iterator variables ***************/
+    // Intex to the main array
+    TInt iPosition;
+
+    // 4-bit slot in the 32-bit entry
+    TInt iSlot;
+
+    // Index to the overflow array
+    TInt iOverflowPos;
+    /************** Iterator variables end *************/
+    };
+
+/**
+* Codes 32-bit unsigned integers using Run Length Encoding.
+*
+* @lib SISpeechRecognitionData.lib
+* @since 2.8
+*/
+class CRLECoder : public CBase
+    {
+public: // Constructors and destructors
+    /**
+    * Codes an array of 32-bit variables using Run Length Encoding.
+    * @since 2.8
+    * @param aPlainArray Array to be coded
+    * @return none
+    */
+    static CRLECoder* NewL(const RArray<TUint16>& aPlainArray);
+
+    /**
+    * Internalizes an array from stream.
+    * @since 2.8
+    * @param aStream A stream containing the object.
+    * @return none
+    */
+    static CRLECoder* NewL( RReadStream& aStream );
+
+    /**
+    * Destructor..
+    */
+    ~CRLECoder();
+
+public: // New functions
+
+    /**
+    * Initializes the iterator.
+    * @since 2.8
+    * @return none
+    */
+    void DecodeReset();
+
+    /**
+    * Decodes one value. Leaves with KErrOverflow, if all values in the array
+    * have been read.
+    * @since 2.8
+    * @param aResult Result is placed to this variable.
+    * @param aIterator The iterator
+    * @param aRleArray Contains coded data.
+    * @return none
+    */
+    TUint16 NextL();
+
+    /**
+    * Externalizes the array to the stream.
+    * @since 2.8
+    * @param aStream Stream to store into.
+    * @return none
+    */
+    void ExternalizeL(RWriteStream& aStream);
+
+private:
+    /**
+    * C++ default constructor.
+    */
+    CRLECoder();
+
+private: // Class-internal data types
+
+    typedef struct
+        {
+        // How many times the value is repeated
+        TUint16 iCount;
+        // The value
+        TUint16 iValue;
+
+        } TValueAndCount;
+private:
+
+    // The values, stored using run length encoding.
+    RArray<TValueAndCount> iRleArray;
+
+    /**************** Iterator variables ***************/
+    // Intex to the main array
+    TInt iPosition;
+
+    // RLE repetition counter
+    TUint16 iRepetition;
+    /************** Iterator variables end *************/
+    };
+
+class CYesNoCoder : public CBase
+    {
+public: // Constructors and destructors
+
+    /**
+    * 2-phase constructor.
+    */
+    static CYesNoCoder* NewL();
+
+    /**
+    * Internalizes a bit array from stream.
+    * @since 2.8
+    * @param aStream A stream containing the object.
+    * @return none
+    */
+    static CYesNoCoder* NewL( RReadStream& aStream );
+
+    /**
+    * Destructor..
+    */
+    ~CYesNoCoder();
+
+public: // New functions
+
+    /**
+    * Encodes a single bit. Increases the iterator. 
+    * @since 2.8
+    * @param aValue The bit to be coded (true or false)
+    * @return none
+    */
+    void EncodeL( TBool aValue );
+
+    /**
+    * Initializes the iterator.
+    * @since 2.8
+    * @return none
+    */
+    void DecodeReset();
+
+    /**
+    * Decodes a single bit. Increases the iterator. Leaves, if the storage ends.
+    * @since 2.8
+    * @return Yes or no.
+    */
+    TBool NextL();
+
+    /**
+    * Externalizes the array to the stream.
+    * @since 2.8
+    * @param aStream Stream to store into.
+    * @return none
+    */
+    void ExternalizeL(RWriteStream& aStream);
+
+private:
+    /**
+    * C++ default constructor.
+    */
+    CYesNoCoder();
+
+    /**
+    * Makes the iterator point to the next bit.
+    */
+    void NextBit();
+
+private:
+    // Storage for the bits
+    RArray<TUint32> iStore;
+
+    /**************** Iterator variables ***************/
+    // Points to the correct TUint32 in the array.
+    TInt iPosition;
+
+    // Bit mask for getting the next bit.
+    TUint32 iMask;
+    /************** Iterator variables end *************/
+    };
+
+/**
+* Serialization helper class for CSILexicon.
+*
+* The native form of CSILexicon is an array of pronunciations. This class
+* piles each data type to its own pile - model bank IDs, pronunciations,
+* etc. - and then serializes these piles.
+*
+* @lib SISpeechRecognitionData.lib
+* @since 2.8
+*/
+class CSILexiconSerializer : public CBase
+    {
+public:  // Constructors and destructor
+
+    /**
+    * Two-phased constructor. For externalization.
+    */
+    static CSILexiconSerializer* NewLC( const CSILexicon& aLexicon );
+
+    /**
+    * Two-phased constructor. For internalization.
+    */
+    static CSILexiconSerializer* NewLC( RReadStream& aStream );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CSILexiconSerializer();
+        
+public: // New functions
+        
+    /**
+    * Stores the object to a stream.
+    * @since 2.8
+    * @param aStream Stream to serialize to
+    * @return none
+    */
+    void ExternalizeL( RWriteStream& aStream );
+        
+    /**
+    * Populates a lexicon.
+    * @since 2.8
+    * @param aLexicon The lexicon to internalize to
+    * @param aLexiconID CSILexicon does not contain a function to set
+    *                   Lexicon ID, so we can't return it with aLexicon.
+    * @return none
+    */
+    void RestoreL( CSILexicon& aLexicon, TSILexiconID& aLexiconID );
+
+private:
+        
+    /**
+    * C++ default constructor.
+    */
+    CSILexiconSerializer();
+        
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL(const CSILexicon& aLexicon);
+        
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL(RReadStream& aStream);
+
+    void SavePronunciationL(CSIPronunciation* aPronun);
+    bool NextPhonemeL( TDes8& phonemeBuf, const TDesC8& phonemeSeq,
+                       TInt&  aReadIterator );
+    HBufC8* Index2PhonemeLC(const TDesC8& aIndexSeq);
+
+    void InternalizeL( RReadStream& aStream );
+    // Prohibit copy constructor if not deriving from CBase.
+    // ?classname( const ?classname& );
+    // Prohibit assigment operator if not deriving from CBase.
+    // ?classname& operator=( const ?classname& );
+        
+public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        
+protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        
+private:    // Data
+
+    // !!!! Check the pronunciation storing once more.
+    RPointerArray<CSIPronunciation> iPronunciations;
+    RPointerArray<HBufC8>           iIndexPronuns;
+
+    RArray<TLexiconPhoneme> iConversionTable;
+
+    // Pronunciation IDs as 16-bit nibble-coded numbers
+    CNibble16Coder* iPronunIDs;
+
+    // Model bank IDs as RLEd 32-bit numbers
+    CRLECoder* iModelBankIDs;
+
+    // Parameters are serialized as such, since we know nothing about them.
+    CBufFlat* iParamBuf;
+
+    // Total number of pronunciations
+    TInt iCount; 
+
+    // Lexicon ID
+    TSILexiconID iLexiconID;
+
+    };
+
+/**
+* Serialization helper class for CSIGrammar.
+*
+* The native form of CSIGrammar is an array of rules and rule variants.
+* This class piles each data type to its own pile - model bank IDs,
+* pronunciation IDs, etc. - and then serializes these piles.
+*
+* @lib SISpeechRecognitionData.lib
+* @since 2.8
+*/
+class CSIGrammarSerializer : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor for externalization.
+        */
+        static CSIGrammarSerializer* NewLC( const CSIGrammar& aGrammar );
+        
+        /**
+        * Two-phased constructor for internalization.
+        */
+        static CSIGrammarSerializer* NewLC( RReadStream& aStream );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSIGrammarSerializer();
+        
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+        /**
+        * Stores the object to a stream.
+        * @since 2.8
+        * @param aStream Stream to serialize to
+        * @return none
+        */
+        void ExternalizeL( RWriteStream& aStream );
+
+        /**
+        * Populates the grammar.
+        * @since 2.8
+        * @param aGrammar The grammar to be filled.
+        * @param aGrammarID Grammar ID is returned in this variable, as
+        *                   CSIGrammar does not contain SetGrammarID() method.
+        * @return none
+        */
+        void RestoreL( CSIGrammar& aGrammar, TSIGrammarID& aGrammarID );
+
+    public: // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CSIGrammarSerializer();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( const CSIGrammar& aGrammar );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( RReadStream& aStream );
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+        
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+private:    // Data
+
+    // Grammar ID
+    TSIGrammarID iGrammarID;
+
+    // Rule count
+    TInt       iCount;
+
+    // Rule IDs
+    CNibble16Coder* iRuleIDs;
+
+    // Numbers of rule variant in rules
+    CNibble4Coder* iRuleVariantCounts;
+
+    // Rule variant IDs
+    CNibble4Coder* iRuleVariantIDs;
+
+    // Lexicon IDs of variants
+    CRLECoder* iRuleVariantLexiconIDs;
+
+    // Languages of variants
+    CNibble4Coder* iRuleVariantLanguages;
+
+    // Lengths of the pronunciation sequences
+    CNibble4Coder* iPronunIDSeqLengths;
+
+    // Pronunciation IDs of the pronunciation seuqences
+    CNibble16Coder* iPronunIDSequences;
+
+    CBufFlat* iParamBuf;
+    // Reserved pointer for future extension
+    //TAny* iReserved;
+    };
+
+#endif      // SIDATASERIALIZE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondataclient.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,431 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definition of the SISpeechRecognitionDataClient structure and API.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "nsssispeechrecognitiondataclient.h"
+#include "nsssispeechrecognitiondatadevasr.h"
+#include "nsssispeechrecognitiondatatest.h"
+
+// CONSTANTS
+const TInt32 KBinaryClientResultSetID = 0xAACF1235;
+
+// Does the CSIClientResultSet have an embedded CSIResultSet?
+const TInt KNoResultSet  = 0;
+const TInt KYesResultSet = 1;
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::~CSIClientResult
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResult::~CSIClientResult()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::CSIClientResult
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIClientResult::CSIClientResult()
+	:	iGrammarID(0),
+		iRuleID(0)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::CSIClientResult
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIClientResult::CSIClientResult(TSIGrammarID aGrammarID, TSIRuleID aRuleID)
+	:	iGrammarID(aGrammarID),
+		iRuleID(aRuleID)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIClientResult::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResult* CSIClientResult::NewLC()
+{
+	CSIClientResult* self = new (ELeave) CSIClientResult();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResult* CSIClientResult::NewL()
+{
+	CSIClientResult* self = NewLC();
+	CleanupStack::Pop();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResult* CSIClientResult::NewLC(TSIGrammarID aGrammarID, TSIRuleID aRuleID)
+{
+	CSIClientResult* self = new (ELeave) CSIClientResult(aGrammarID, aRuleID);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResult* CSIClientResult::NewL(TSIGrammarID aGrammarID, TSIRuleID aRuleID)
+{
+	CSIClientResult* self = NewLC(aGrammarID, aRuleID);
+	CleanupStack::Pop();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::SetGrammarID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResult::SetGrammarID(TSIGrammarID aGrammarID)
+{
+	iGrammarID = aGrammarID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::GrammarID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIGrammarID CSIClientResult::GrammarID() const
+{
+	return iGrammarID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::SetRuleID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResult::SetRuleID(TSIRuleID aRuleID)
+{
+	iRuleID = aRuleID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResult::RuleID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleID CSIClientResult::RuleID() const
+{
+	return iRuleID;
+}
+ 
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::~CSIClientResultSet
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResultSet::~CSIClientResultSet()
+{
+	iResultArray.ResetAndDestroy();
+	iResultArray.Close();
+	delete  iSIResultSet;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::CSIClientResultSet
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIClientResultSet::CSIClientResultSet()
+  : iMaxResults(0),
+    iResultCount(0),
+    iResultArray(10),
+    iSIResultSet(NULL)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIClientResultSet::ConstructL()
+{
+    iSIResultSet = CSIResultSet::NewL();
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResultSet* CSIClientResultSet::NewLC()
+{
+	CSIClientResultSet* self = new (ELeave) CSIClientResultSet();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIClientResultSet* CSIClientResultSet::NewL()
+{
+	CSIClientResultSet* self = NewLC();
+	CleanupStack::Pop();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::AddL
+// Adds a result to the set.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResultSet::AddL( const CSIClientResult* aResult)
+	{
+    if ( iResultArray.Count() >= iMaxResults )
+        {
+        User::Leave( KErrOverflow );
+        }
+
+	TInt error = iResultArray.Append(aResult);
+	User::LeaveIfError( error ); 
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::DeleteL
+// Removes a result from the set.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  void  CSIClientResultSet::DeleteL(TInt aIndex) 	
+{
+	if(aIndex<0 || aIndex >= iResultArray.Count())
+		User::Leave(KErrArgument);
+	iResultArray.Remove(aIndex);
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::SetMaxResultsL
+// Sets the maximum number of results, which the client wants get.
+// Less results may be returned for various reasons.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResultSet::SetMaxResultsL(TInt aMaxResults)
+{
+	iMaxResults = aMaxResults;
+
+    while( iResultArray.Count() > iMaxResults )
+        {
+        delete iResultArray[ iMaxResults ];
+        iResultArray.Remove( iMaxResults );
+        }
+/* 
+	for (TInt i = 0; i < aMaxResults; i++)
+	{
+		CSIClientResult* result = CSIClientResult::NewLC();
+		User::LeaveIfError(iResultArray.Append(result));
+		CleanupStack::Pop();
+	}
+*/
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::MaxResults
+// Returns the maximum number of results.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIClientResultSet::MaxResults() const
+{
+	return iMaxResults;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::AtL
+// Used to get a result.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const CSIClientResult& CSIClientResultSet::AtL(TInt aIndex) const
+{
+ 
+	if(aIndex<0 || aIndex >= iResultArray.Count())
+		User::Leave(KErrArgument);
+	return *(iResultArray[aIndex]);
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::SetResultCount
+// Sets the actual number of results, as opposed to maximum number.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResultSet::SetResultCount(TInt aResultCount)
+{
+	iResultCount = aResultCount;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::ResultCount
+// Gets the actual number of results, which is smaller or equal to maximum number.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIClientResultSet::ResultCount() const
+{
+	return iResultCount;
+}
+ 
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::SIClientResultSet
+// Returns the nested lower-level result set.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  CSIResultSet& CSIClientResultSet::SIResultSet() const
+{
+		return *iSIResultSet;
+}
+	
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::SetSIResultSet
+// Sets the nested result set.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResultSet::SetSIResultSet(CSIResultSet* aSIResultSet)
+{
+	delete iSIResultSet;
+	iSIResultSet = aSIResultSet;
+}
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::ExternalizeL
+// Stores the object to the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResultSet::ExternalizeL( RWriteStream& aStream ) const
+    {
+    // Write format ID
+    aStream.WriteInt32L( KBinaryClientResultSetID );
+
+    aStream.WriteInt32L( iMaxResults  );
+    aStream.WriteInt32L( iResultCount );
+
+    TInt count = iResultArray.Count();
+    aStream.WriteInt32L( count );
+
+    for ( TInt k = 0; k < count; k++ )
+        {
+        CSIClientResult* result = iResultArray[ k ];
+
+        aStream.WriteInt32L( result->GrammarID() );
+        aStream.WriteInt32L( result->RuleID()    );
+        }
+
+    if ( iSIResultSet == 0 )
+        {
+        aStream.WriteInt32L( KNoResultSet );
+        }
+    else
+        {
+        aStream.WriteInt32L( KYesResultSet );
+
+        iSIResultSet->ExternalizeL( aStream );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIClientResultSet::InternalizeL
+// Restores the object from the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIClientResultSet::InternalizeL( RReadStream& aStream )
+    {
+    if ( aStream.ReadInt32L() != KBinaryClientResultSetID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    iMaxResults = aStream.ReadInt32L();
+    iResultCount= aStream.ReadInt32L();
+
+    TInt count  = aStream.ReadInt32L();
+
+    for ( TInt k( 0 ); k < count; k++ )
+        {
+        CSIClientResult* result = CSIClientResult::NewLC();
+
+        result->SetGrammarID( (TSIGrammarID)aStream.ReadInt32L() );
+        result->SetRuleID   ( (TSIRuleID)   aStream.ReadInt32L() );
+
+        AddL( result );
+
+        CleanupStack::Pop( result );
+        }
+
+    TInt32 hasNestedResultSet = aStream.ReadInt32L();
+
+    if ( hasNestedResultSet == KYesResultSet )
+        {
+        iSIResultSet->InternalizeL( aStream );
+        }
+
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondatacommon.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains common data shared between SISpeechRecognitionDataClient
+*                and SISpeechRecognitionDataDevASR.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "nsssispeechrecognitiondatacommon.h"
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondatadevasr.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,2575 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definition of the SISpeechRecognitionDataDevASR structure and API.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <s32mem.h>
+#include "nsssispeechrecognitiondatadevasr.h"
+#include "nsssispeechrecognitiondatatest.h"
+#include "nsssidataserialize.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+
+/** Maximal number of pronunciations, that is allowed to be stored per lexicon.
+    0 means no limit.
+    4800 is a maximal number of pronunciations for 400 contacts (400*12) */
+const TInt KMaxPronunciations = 4800;
+
+// Starting value for lexicon usage counter
+const TInt KInitialCounterValue = 1;
+
+// Define this if SINDE lexicon optimization is on
+#define __SIND_LEXICON_OPT
+
+/*****************************************************************************/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIParameters::CSIParameters
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIParameters::CSIParameters()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIParameters::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIParameters::ConstructL()
+{
+} 
+
+// -----------------------------------------------------------------------------
+// CSIParameters::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIParameters* CSIParameters::NewL()
+{
+	CSIParameters* self = NewLC();
+  	CleanupStack::Pop( self );
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIParameters::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIParameters* CSIParameters::NewLC()
+{
+	CSIParameters* self = new (ELeave) CSIParameters();
+    CleanupStack::PushL( self );
+    self->ConstructL(); 
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIParameters::~CSIParameters
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIParameters::~CSIParameters()
+{
+	iParameterValues.Reset();
+	iParameterIDs.Reset();
+}
+
+// -----------------------------------------------------------------------------
+// CSIParameters::SetParameterL
+// Sets a value X to parameter Y.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIParameters::SetParameterL( const TInt aParameterID, const TInt aParameterValue )
+{
+	RUBY_DEBUG_BLOCKL("CSIParameters::SetParameterL");
+    TInt index = iParameterIDs.Find( aParameterID );
+
+    // If the parameter has been set earlier, update the value
+    if ( index != KErrNotFound )
+        {
+        iParameterValues[index] = aParameterValue;
+        }
+    else{
+		// create new item for ID and value
+		User::LeaveIfError( iParameterIDs.Append( aParameterID ) );
+		TInt error = iParameterValues.Append( aParameterValue );
+		if ( error )
+		    {
+			// remove the previously added
+			iParameterIDs.Remove( iParameterIDs.Count() - 1 );
+			User::Leave( error );
+		    }
+        }
+}
+
+// -----------------------------------------------------------------------------
+// CSIParameters::ParameterL
+// Returns the value of a parameter.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIParameters::ParameterL( const TInt aParameterID ) const
+{
+	RUBY_DEBUG_BLOCK("CSIParameters::ParameterL");
+    TInt index = iParameterIDs.Find( aParameterID );
+
+    // Leave, if not found.
+    User::LeaveIfError( index );
+
+    return iParameterValues[index];
+}
+
+// -----------------------------------------------------------------------------
+// CSIParameters::InternalizeL
+// Restores the object from the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIParameters::InternalizeL( RReadStream& aStream )
+    {
+    RUBY_DEBUG_BLOCKL("CSIParameters::InternalizeL");
+    if ( iParameterIDs.Count() > 0 )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    // Check ID 
+    if ( aStream.ReadInt32L() != KBinaryParameterID )
+        User::Leave( KErrCorrupt );
+
+    // Param count; can be 0.
+    TInt count = aStream.ReadInt32L();
+
+    // Read values
+    for( TInt k( 0 ); k < count; k++ )
+        {
+        TInt id    = aStream.ReadInt32L();
+        TInt value = aStream.ReadInt32L();
+
+        SetParameterL( id, value );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIParameters::ExternalizeL
+// Stores the object to a stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIParameters::ExternalizeL(RWriteStream& aStream ) const
+    {
+
+    TInt count = iParameterIDs.Count();
+
+    // Write ID 
+    aStream.WriteInt32L( KBinaryParameterID );
+
+    // Param count; can be 0.
+    aStream.WriteInt32L( count );
+
+    for( TInt k( 0 ); k < count; k++ )
+        {
+        aStream.WriteInt32L( iParameterIDs   [k] );
+        aStream.WriteInt32L( iParameterValues[k] );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIParameters::ListParametersL
+// Populates given arrays with parameter IDs and values.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIParameters::ListParametersL( RArray<TInt>& aParameterIDs, 
+                                              RArray<TInt>& aParameterValues ) const
+    {
+    RUBY_DEBUG_BLOCKL("CSIParameters::ListParametersL");
+    TInt i = 0;
+
+    aParameterIDs.Reset();
+    aParameterValues.Reset();
+
+    // Loop through all parameter IDs
+    for ( i = 0; i < iParameterIDs.Count(); i++ )
+        {
+        aParameterIDs.Append( iParameterIDs[i] );
+        }
+
+    // Loop through all parameter values
+    for ( i = 0; i < iParameterValues.Count(); i++ )
+        {
+        aParameterValues.Append( iParameterValues[i] );
+        }
+    }
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::CSIRuleVariant
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRuleVariant::CSIRuleVariant( const TSIRuleVariantID aRuleVariantID, 
+										const TSILexiconID aLexiconID)
+										:	iRuleVariantID(aRuleVariantID),
+										iLexiconID(aLexiconID),
+										iLanguage( ELangEnglish) // UK English as default
+										
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRuleVariant::ConstructL()
+{
+	CSIParameters::ConstructL();
+} 
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRuleVariant* CSIRuleVariant::NewL(const TSIRuleVariantID aRuleVariantID, 
+											  const TSILexiconID aLexiconID)
+{
+	CSIRuleVariant* self =  NewLC(aRuleVariantID, aLexiconID );
+    CleanupStack::Pop( self );
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRuleVariant* CSIRuleVariant::NewLC(const TSIRuleVariantID aRuleVariantID, 
+											  const TSILexiconID aLexiconID)
+{
+	CSIRuleVariant* self = new (ELeave) CSIRuleVariant(aRuleVariantID, aLexiconID );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::~CSIParameters
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRuleVariant::~CSIRuleVariant()
+{
+	iPronunciationIDs.Reset();
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::RuleVariantID
+// Returns the ID of the rule variant.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleVariantID CSIRuleVariant::RuleVariantID() const
+{
+	return iRuleVariantID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::LexiconID
+// Returns the ID of the lexicon, which contains the pronunciations.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSILexiconID CSIRuleVariant::LexiconID() const
+{
+	return iLexiconID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::SetPronunciationIDsL
+// Sets the pronunciation.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRuleVariant::SetPronunciationIDsL( const TSIPronunciationIDSequence& aPronunciationIDs)
+{
+	RUBY_DEBUG_BLOCKL("CSIRuleVariant::SetPronunciationIDsL");
+	for ( TInt i( 0 ); i < aPronunciationIDs.Count(); i++)
+	{
+		User::LeaveIfError( iPronunciationIDs.Append( aPronunciationIDs[i] ) );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::GetPronunciationIDsL
+// Fetches the pronunciation.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRuleVariant::GetPronunciationIDsL( TSIPronunciationIDSequence& aPronunciationIDs ) const
+{
+	RUBY_DEBUG_BLOCKL("CSIRuleVariant::GetPronunciationIDsL");
+	aPronunciationIDs.Reset();
+	for ( TInt i( 0 ); i < iPronunciationIDs.Count(); i++)
+	{
+		User::LeaveIfError( aPronunciationIDs.Append( iPronunciationIDs[i] ) );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::SetLanguage
+// Sets the pronunciation language.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRuleVariant::SetLanguage(TLanguage aLanguage)
+{
+	iLanguage=aLanguage;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRuleVariant::Language
+// Gets the pronunciation language.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TLanguage CSIRuleVariant::Language() const
+{
+	return iLanguage;
+}
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIRule::CSIRule
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRule::CSIRule(TSIRuleID aRuleID)
+:	iRuleID(aRuleID)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRule::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRule* CSIRule::NewL(const TSIRuleID aRuleID)
+{
+	CSIRule* self = NewLC(aRuleID); 
+	CleanupStack::Pop(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRule* CSIRule::NewLC(const TSIRuleID aRuleID)
+{
+	CSIRule* self = new (ELeave) CSIRule(aRuleID);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+	return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::~CSIRule
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRule::~CSIRule()
+{
+	iRuleVariantArray.ResetAndDestroy();
+}
+
+
+
+
+
+// -----------------------------------------------------------------------------
+// CSIRule::RuleID
+// Returns the ID of the rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleID CSIRule::RuleID() const
+{
+	return iRuleID;
+} 
+
+// -----------------------------------------------------------------------------
+// CSIRule::Count
+// Returns the number of rule variants.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIRule::Count() const
+{
+	return iRuleVariantArray.Count();
+}
+
+
+// -----------------------------------------------------------------------------
+// CSIRule::Compare
+// Compares two CSIRule objects to each other based on ids.
+// -----------------------------------------------------------------------------
+//
+TInt CSIRule::Compare( const CSIRule& aFirst, 
+                       const CSIRule& aSecond )
+    {
+    if ( aFirst.RuleID() < aSecond.RuleID() )
+        {
+        return -1;
+        }
+    if ( aFirst.RuleID() > aSecond.RuleID() )
+        {
+        return 1;
+        }
+    // IDs are equal
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIRule::AtL
+// Used to get a variant.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRuleVariant& CSIRule::AtL(TInt aIndex) const
+{
+	// too much output RUBY_DEBUG_BLOCK("CSIRule::AtL"); 
+	if(aIndex<0 || aIndex >= Count()) 
+		{
+		RUBY_DEBUG2("[Error!]CSIRule::AtL index [%d] is out of bounds. Count is [%d]. Leaving with KErrArgument", aIndex, Count());
+		User::Leave(KErrArgument);
+		}		
+	return *(iRuleVariantArray[aIndex]);
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::Find
+// Returns the index of the variant with given id.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  TInt CSIRule::Find(TSIRuleVariantID aRuleVariantID) const
+{
+	for ( TInt i(0); i < iRuleVariantArray.Count(); i++ )
+	{
+		if ( aRuleVariantID == iRuleVariantArray[i]->RuleVariantID() )
+		{
+			return i;
+		}
+	} 
+	return( KErrNotFound );
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::AddL
+// Adds a rule variant to the rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRule::AddL( CSIRuleVariant* aRuleVariant )
+{
+	RUBY_DEBUG_BLOCKL("CSIRule::AddL");
+    // Check that the rule isn't already there
+	if ( Find( aRuleVariant->RuleVariantID() ) != KErrNotFound )
+	{
+		User::Leave( KErrAlreadyExists );
+	}
+
+    User::LeaveIfError( iRuleVariantArray.Append( aRuleVariant ) );
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::RuleVariantL
+// Used to get a rule variant with given ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  CSIRuleVariant& CSIRule::RuleVariantL(TSIRuleVariantID aRuleVariantID) const
+{
+	RUBY_DEBUG_BLOCK("CSIRule::RuleVariantL");
+	TInt aIndex = Find(aRuleVariantID);
+	
+    User::LeaveIfError( aIndex );
+	
+    return(AtL(aIndex));
+}
+
+// -----------------------------------------------------------------------------
+// CSIRule::DeleteL
+// Deletes the rule variant with given ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIRule::DeleteL(TSIRuleVariantID aRuleVariantID)
+{
+	RUBY_DEBUG_BLOCK("CSIRule::DeleteL");
+    TInt index = User::LeaveIfError( Find( aRuleVariantID ) );
+
+    delete  iRuleVariantArray[index];
+	iRuleVariantArray.Remove(index);
+}
+
+
+
+
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::CSIGrammar
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIGrammar::CSIGrammar(TSIGrammarID aGrammarID)
+:	iGrammarID(aGrammarID)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIGrammar::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIGrammar* CSIGrammar::NewL(const TSIGrammarID aGrammarID)
+{
+    CSIGrammar* self = NewLC(aGrammarID);
+	CleanupStack::Pop(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIGrammar* CSIGrammar::NewLC(const TSIGrammarID aGrammarID)
+{
+	CSIGrammar* self = new (ELeave) CSIGrammar(aGrammarID);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+	return self;
+	
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::~CSIGrammar
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIGrammar::~CSIGrammar()
+{
+	iRuleArray.ResetAndDestroy();
+	iRuleArray.Close();
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::GrammarID
+// Returns the ID of the given grammar.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIGrammarID CSIGrammar::GrammarID() const
+{
+	return iGrammarID;
+}
+
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::AddL
+// Adds a rule to the grammar.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIGrammar::AddL(CSIRule* aRule)
+{
+	// too much output RUBY_DEBUG_BLOCKL("CSIGrammar::AddL");
+
+    // Order function which is used when finding the correct place to insert
+    TLinearOrder<CSIRule> order( CSIRule::Compare );
+
+    // InsertInOrderL does not allow duplicates
+    iRuleArray.InsertInOrderL( aRule, order );
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::DeleteL
+// Deletes a rule with given ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIGrammar::DeleteL(TSIRuleID aRuleID)
+{
+	RUBY_DEBUG_BLOCK("CSIGrammar::DeleteL");
+	TInt index = Find(aRuleID);
+    User::LeaveIfError( index );
+
+	delete iRuleArray[index];
+	iRuleArray.Remove(index);
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::AtL
+// Used to get a rule.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIRule& CSIGrammar::AtL(TInt anIndex) const
+{
+	if(anIndex<0 || anIndex >= Count())
+		{
+		RUBY_DEBUG2("[Error!]CSIGrammar::AtL index [%d] is out of bounds. Count is [%d]. Leaving with KErrArgument", anIndex, Count());
+		User::Leave(KErrArgument);
+		}
+		
+	return *(iRuleArray[anIndex]);
+	
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::Find
+// Finds the index of the rule with given ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIGrammar::Find(TSIRuleID aRuleID) const
+{
+    // Order function which is used when finding the correct item
+    TLinearOrder<CSIRule> order( CSIRule::Compare );
+
+    TInt retVal = KErrNotFound;
+
+    TRAPD( error,
+
+        // Construct a 'dummy' CSIPronunciation so that comparison can be done 
+        // against it
+        CSIRule* rule = CSIRule::NewL( aRuleID );
+
+        CleanupStack::PushL( rule );
+
+        // Use binary search since array is kept in the order of rule ids
+        retVal = iRuleArray.FindInOrderL( rule, order );
+    
+        CleanupStack::PopAndDestroy( rule );
+        );
+
+    if ( error != KErrNone )
+        {
+        return error;
+        }
+    return retVal;
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::Count
+// Returns the number of rules.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIGrammar::Count() const
+{
+	return iRuleArray.Count();
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::RuleL
+// Used to get a rule with given ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  CSIRule&  CSIGrammar::RuleL(TSIRuleID aRuleID) const
+{
+	RUBY_DEBUG_BLOCK("CSIGrammar::RuleL");
+	TInt aIndex = Find(aRuleID);
+#ifdef _DEBUG
+	if( aIndex < 0 ) 
+		{
+		RUBY_DEBUG2("CSIGrammar::RuleL Error [%d] finding aRuleID [%d]. Leaving", aIndex, aRuleID);
+		}
+#endif	
+    User::LeaveIfError( aIndex );
+	
+    return(AtL(aIndex));
+}
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::ExternalizeL
+// Stores the object to the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIGrammar::ExternalizeL( RWriteStream& aWriteStream ) const
+    {
+    aWriteStream.WriteInt32L( KBinaryGrammarID );
+
+    CSIGrammarSerializer* grammarSerializer = CSIGrammarSerializer::NewLC( *this );
+    grammarSerializer->ExternalizeL( aWriteStream );
+    CleanupStack::PopAndDestroy( grammarSerializer );
+
+    aWriteStream.WriteInt32L( KBinaryGrammarID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammar::InternalizeL
+// Restores the object from a stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIGrammar::InternalizeL( RReadStream& aReadStream )
+    {
+    RUBY_DEBUG_BLOCK("CSIGrammar::InternalizeL");
+    if ( iRuleArray.Count() > 0 )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    // Read header: Format ID, grammar ID and number of rules.
+    if ( aReadStream.ReadInt32L() != KBinaryGrammarID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    CSIGrammarSerializer* grammarSerializer
+        = CSIGrammarSerializer::NewLC( aReadStream );
+
+    grammarSerializer->RestoreL( *this, iGrammarID );
+    CleanupStack::PopAndDestroy( grammarSerializer );
+
+    if ( aReadStream.ReadInt32L() != KBinaryGrammarID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+    }
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::CSICompiledGrammar
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSICompiledGrammar::CSICompiledGrammar(TSIGrammarID aGrammarID 
+												)
+												: CSIGrammar(aGrammarID), iValidData(EFalse),  iGrammarCompilerData( NULL )
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSICompiledGrammar::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSICompiledGrammar* CSICompiledGrammar::NewL(TSIGrammarID aGrammarID)
+{
+	CSICompiledGrammar* self = NewLC(aGrammarID) ;    
+	CleanupStack::Pop(self);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSICompiledGrammar* CSICompiledGrammar::NewLC(TSIGrammarID aGrammarID)
+{
+	CSICompiledGrammar* self = new (ELeave) CSICompiledGrammar(aGrammarID) ;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::~CSICompiledGrammar
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSICompiledGrammar::~CSICompiledGrammar()
+{
+	delete iGrammarCompilerData;
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::AddL
+// Adds a new rule to the grammar.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSICompiledGrammar::AddL(CSIRule* aRule)
+{
+	RUBY_DEBUG_BLOCKL("CSICompiledGrammar::AddL");
+	iValidData = EFalse;
+	CSIGrammar::AddL(aRule);
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::DeleteL
+// Delets a rule with given ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSICompiledGrammar::DeleteL(TSIRuleID aRuleID)
+{
+	RUBY_DEBUG_BLOCK("CSICompiledGrammar::DeleteL");
+	iValidData = EFalse;
+	CSIGrammar::DeleteL(aRuleID);
+}
+
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::SetCompiledData
+// Sets the compiled grammar data.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSICompiledGrammar::SetCompiledData( HBufC8* aCompilerData )
+{	 
+	delete  iGrammarCompilerData;
+	iGrammarCompilerData = aCompilerData;
+}
+
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::CompiledData
+// Gets a descriptor to the compiled grammar data.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C   TDesC8&  CSICompiledGrammar::CompiledData() const
+{
+	return *iGrammarCompilerData;
+}
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::ExternalizeL
+// Stores the object to the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSICompiledGrammar::ExternalizeL( RWriteStream& aWriteStream ) const
+    {
+    aWriteStream.WriteInt32L( KBinaryCompiledGrammarID );
+
+    CSIGrammar::ExternalizeL( aWriteStream );
+
+    // Read compiled grammar data
+    if ( iGrammarCompilerData )
+        {
+        TInt length = iGrammarCompilerData->Length();
+        aWriteStream.WriteInt32L( length );
+        aWriteStream.WriteL( iGrammarCompilerData->Des(), length );
+        }
+    else
+        {
+        aWriteStream.WriteInt32L( 0 );
+        }
+
+    // Corruption check
+    aWriteStream.WriteInt32L( KBinaryCompiledGrammarID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSICompiledGrammar::InternalizeL
+// Restores the object from a stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSICompiledGrammar::InternalizeL( RReadStream& aReadStream )
+    {
+    RUBY_DEBUG_BLOCK("CSICompiledGrammar::InternalizeL");
+    if ( aReadStream.ReadInt32L() != KBinaryCompiledGrammarID )
+        User::Leave( KErrCorrupt );
+
+    CSIGrammar::InternalizeL( aReadStream );
+
+    // Read compiled grammar data
+    TInt length = aReadStream.ReadInt32L();
+
+    if ( length > 0 )
+        {
+        iGrammarCompilerData = HBufC8::NewL( length );
+        TPtr8 compilerDataPtr = iGrammarCompilerData->Des();
+        aReadStream.ReadL( compilerDataPtr, length );
+        }
+
+    // Corruption check
+    if ( aReadStream.ReadInt32L() != KBinaryCompiledGrammarID )
+        User::Leave( KErrCorrupt );
+    }
+
+/*****************************************************************************/
+// -----------------------------------------------------------------------------
+// TSIRuleVariantInfo::TSIRuleVariantInfo
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleVariantInfo::TSIRuleVariantInfo( 
+												const TSIGrammarID aGrammarID, 			
+												const TSIRuleID aRuleID, 
+												const TSIRuleVariantID aRuleVariantID )
+												:	iGrammarID( aGrammarID ),
+												iRuleID( aRuleID ),
+												iRuleVariantID( aRuleVariantID )
+{
+    // nothing
+}
+
+// -----------------------------------------------------------------------------
+// TSIRuleVariantInfo::~TSIRuleVariantInfo
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleVariantInfo::~TSIRuleVariantInfo()
+{
+	// nothing
+}
+
+
+// -----------------------------------------------------------------------------
+// TSIRuleVariantInfo::GrammarID
+// Returns the grammar ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIGrammarID TSIRuleVariantInfo::GrammarID() const
+{
+    return iGrammarID;
+}
+// -----------------------------------------------------------------------------
+// TSIRuleVariantInfo::RuleID
+// Return rule identifier.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleID TSIRuleVariantInfo::RuleID() const
+{
+    return iRuleID;
+}
+
+// -----------------------------------------------------------------------------
+// TSIRuleVariantInfo::RuleVariantID
+// Return rule variant identifier.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleVariantID TSIRuleVariantInfo::RuleVariantID() const
+{
+    return iRuleVariantID;
+}
+
+/******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::CSIPronunciation
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciation::CSIPronunciation( const TSIPronunciationID aPronunciationID,
+                                             const TSIModelBankID aModelBankID )
+                                            : iPronunciationID( aPronunciationID ),
+                                              iModelBankID( aModelBankID ),
+                                              iPhonemeSequence( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIPronunciation::ConstructL()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciation* CSIPronunciation::NewL( const TSIPronunciationID aPronunciationID, 
+                                                   const TSIModelBankID aModelBankID )
+    {
+    CSIPronunciation* self = NewLC ( aPronunciationID, aModelBankID );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciation* CSIPronunciation::NewLC( const TSIPronunciationID aPronunciationID, 
+                                                    const TSIModelBankID aModelBankID )
+    {
+    CSIPronunciation* self = new (ELeave) CSIPronunciation( aPronunciationID, aModelBankID );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::~CSIPronunciation
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciation::~CSIPronunciation()
+    {
+    delete iPhonemeSequence;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::Compare
+// Compares two CSIPronunciation objects to each other based on ids.
+// -----------------------------------------------------------------------------
+//
+TInt CSIPronunciation::Compare( const CSIPronunciation& aFirst, 
+                                const CSIPronunciation& aSecond )
+    {
+    if ( aFirst.PronunciationID() < aSecond.PronunciationID() )
+        {
+        return -1;
+        }
+    if ( aFirst.PronunciationID() > aSecond.PronunciationID() )
+        {
+        return 1;
+        }
+    // IDs are equal
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::ComparePhonemes
+// Compares two CSIPronunciation objects to each other based pronunciations.
+// -----------------------------------------------------------------------------
+//
+TInt CSIPronunciation::ComparePhonemes( const CSIPronunciation& aFirst, 
+                                        const CSIPronunciation& aSecond )
+    {
+    if ( aFirst.PhonemeSequence() < aSecond.PhonemeSequence() )
+        {
+        return -1;
+        }
+    if ( aFirst.PhonemeSequence() > aSecond.PhonemeSequence() )
+        {
+        return 1;
+        }
+    // Phoneme sequences are equal
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::PronunciationID
+// Returns the pronunciation ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIPronunciationID CSIPronunciation::PronunciationID() const
+    {
+    return iPronunciationID;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::ModelBankID
+// Returns the pronunciation ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIModelBankID CSIPronunciation::ModelBankID() const
+    {
+    return iModelBankID;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::SetPhonemeSequenceL
+// Sets Phoneme Sequence
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIPronunciation::SetPhonemeSequenceL( const TDesC8& aPhonemeSequence )
+    {
+    if ( iPhonemeSequence )
+        {
+        // delete old data
+        delete iPhonemeSequence;
+        iPhonemeSequence = NULL;
+        }
+	
+    iPhonemeSequence = HBufC8::NewL( aPhonemeSequence.Length() );
+    (*iPhonemeSequence) = aPhonemeSequence;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::PhonemeSequence
+// returns Phoneme Sequence
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CSIPronunciation::PhonemeSequence() const
+    {
+    return *iPhonemeSequence;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIPronunciation::SetPronunciationID
+// Sets the pronunciation ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIPronunciation::SetPronunciationID( TSIPronunciationID aPronunciationID )
+    {
+    iPronunciationID=aPronunciationID;
+    }
+    
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSILexicon::CSILexicon
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSILexicon::CSILexicon( TSILexiconID aLexiconID )
+                               : iLexiconID(aLexiconID)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSILexicon::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSILexicon* CSILexicon::NewL( TSILexiconID aLexiconID )
+    {
+    CSILexicon* self = NewLC( aLexiconID );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSILexicon::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSILexicon* CSILexicon::NewLC( TSILexiconID aLexiconID )
+    {
+    CSILexicon* self = new ( ELeave ) CSILexicon( aLexiconID );
+    CleanupStack::PushL( self );
+    self->ConstructL(); 
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::~CSILexicon
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSILexicon::~CSILexicon()
+    {
+    iPronunciationArray.ResetAndDestroy();
+    iPronunciationArray.Close();
+    iPronunOrder.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::LexiconID
+// Gets the ID of the lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIGrammarID CSILexicon::LexiconID() const
+    {
+    return iLexiconID;
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::AddL
+// Adds a pronunciation.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSILexicon::AddL( CSIPronunciation* aPronunciation )
+    {
+#ifdef __SIND_LEXICON_OPT
+    RUBY_DEBUG_BLOCKL( "CSILexicon::AddL (SINDE optimized)" );
+    
+    RUBY_ASSERT_DEBUG( iPronunciationArray.Count() == iPronunOrder.Count(), User::Leave( KErrCorrupt ) );
+    
+    // Check if current lexicon already holds maximal allowed number of 
+    // pronunciations or that there is no limit
+    if( ( KMaxPronunciations != 0 ) && ( iPronunciationArray.Count() > KMaxPronunciations ) )
+    	{
+    	User::Leave( KErrNoMemory );
+    	}
+
+    if ( aPronunciation == NULL )
+        {
+        User::Leave( KErrArgument );
+        }
+        
+    // Check that pronunciation is not null
+    const TDesC8& phonemeSeq = aPronunciation->PhonemeSequence();
+
+    if ( &phonemeSeq == NULL )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Check if CSIPronunciation which is given as parameter has the usage counter already
+    TRAPD( error, TInt temp = aPronunciation->ParameterL( KLexiconReferenceCounter ) );
+    TBool counterFound( EFalse );
+    
+    if ( error == KErrNone )
+        {
+        counterFound = ETrue;
+        }
+    else
+        {
+        counterFound = EFalse;
+        // New counter
+        aPronunciation->SetParameterL( KLexiconReferenceCounter, KInitialCounterValue );
+        }
+
+    // 1. Insert first based on the phoneme sequence order
+    TLinearOrder<CSIPronunciation> phonemeOrder( CSIPronunciation::ComparePhonemes );
+    TRAP( error, iPronunOrder.InsertInOrderL( aPronunciation, phonemeOrder ) );
+    
+    // Store the index for later use
+    TInt phonemeSeqIndex = iPronunOrder.FindInOrder( aPronunciation, phonemeOrder );
+      
+    // Don't add the same data again
+    if ( error == KErrAlreadyExists )
+        {
+        // Append counter only if it was not found from the parameter
+        // This way externalize/internalize works ok, counter won't be touched when
+        // there is one already
+        if ( !counterFound )
+            {
+            TInt counterValue( 0 );
+            // Just increase the usage counter
+            CSIPronunciation* existingPronun = iPronunOrder[phonemeSeqIndex];
+            counterValue = existingPronun->ParameterL( KLexiconReferenceCounter );
+            counterValue++;
+            existingPronun->SetParameterL( KLexiconReferenceCounter, counterValue );
+            }
+        User::Leave( KErrAlreadyExists );
+        }
+    else
+        {
+        User::LeaveIfError( error );
+        
+        TLinearOrder<CSIPronunciation> order( CSIPronunciation::Compare );
+        
+        // 2. Insert to the array which is kept in the order of pronunciation id
+        TRAPD( error, iPronunciationArray.InsertInOrderL( aPronunciation, order ) );
+        if ( error != KErrNone )
+            {
+            // Remove previously added element from pronunciation ordered table
+            iPronunOrder.Remove( phonemeSeqIndex );
+            User::Leave( error );
+            }
+        }
+
+#else
+    RUBY_DEBUG_BLOCKL("CSILexicon::AddL");
+    
+    // Check if current lexicon already hold maximal alloud number of 
+    // pronunciations or that there is no limit
+    if( ( KMaxPronunciations != 0 ) && ( iPronunciationArray.Count() > KMaxPronunciations ) )
+    	{
+    	User::Leave( KErrNoMemory );
+    	}
+    // Quick check, if pronun id of the added pronunciation is bigger than the
+    // last one which is already in array, we can add that to the last
+    if ( iPronunciationArray.Count() == 0 )
+        {
+        User::LeaveIfError( iPronunciationArray.Append( aPronunciation ) );
+        return;
+        }
+    else
+        {
+        if ( iPronunciationArray[iPronunciationArray.Count() - 1]->PronunciationID() < aPronunciation->PronunciationID() )
+            {
+            User::LeaveIfError( iPronunciationArray.Append( aPronunciation ) );
+            return;
+            }
+        }
+
+    // Check that pronunciation is not null
+    const TDesC8& phonemeSeq = aPronunciation->PhonemeSequence();
+
+    if ( &phonemeSeq == NULL )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Order function which is used when finding the correct place to insert
+    TLinearOrder<CSIPronunciation> order( CSIPronunciation::Compare );
+
+    // InsertInOrderL does not allow duplicates, that is what we actually want!
+    iPronunciationArray.InsertInOrderL( aPronunciation, order );
+#endif // __SIND_LEXICON_OPT
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::AddPronunciationToEndL
+// Adds pronunciation to end of the array
+// -----------------------------------------------------------------------------
+//
+void CSILexicon::AddPronunciationToEndL( CSIPronunciation* aPronunciation )
+    {   
+    TLinearOrder<CSIPronunciation> phonemeOrder( CSIPronunciation::ComparePhonemes );    
+    TInt error = iPronunciationArray.Append( aPronunciation );
+    if ( error != KErrNone )
+        {
+        // Remove previously added element from pronunciation ordered table
+        iPronunOrder.Remove( iPronunOrder.FindInOrder( aPronunciation, phonemeOrder ) );
+        User::Leave( error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::AtL
+// Used to get a pronunciation.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciation& CSILexicon::AtL( TInt anIndex ) const
+    {
+    RUBY_DEBUG_BLOCKL("CSILexicon::AtL");
+    if ( anIndex < 0 || anIndex >= Count() )
+        {
+        RUBY_DEBUG2("CSILexicon::AtL index [%d] is ut of bounds. Count [%d]. Leaving with KErrArg", anIndex, Count());
+        User::Leave( KErrArgument );
+        }
+	return *( iPronunciationArray[anIndex] );
+    } 
+
+// -----------------------------------------------------------------------------
+// CSILexicon::DeleteL
+// Deletes a pronunciation with given ID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSILexicon::DeleteL( TSIPronunciationID aPronunciationID )
+    {
+#ifdef __SIND_LEXICON_OPT
+    RUBY_DEBUG_BLOCK( "CSILexicon::DeleteL (SINDE optimized)" );
+    
+    TInt pronunIdIndex = Find( aPronunciationID );
+    User::LeaveIfError( pronunIdIndex );
+    
+    CSIPronunciation& pronunciation = AtL( pronunIdIndex );
+    
+    TInt counter = pronunciation.ParameterL( KLexiconReferenceCounter );
+    counter--;
+    
+    // If counter reaches zero, then pronunciation should be also deleted
+    if ( counter == 0 )
+        {
+        // Find the index in array ordered by phoneme sequence
+        TLinearOrder<CSIPronunciation> phonemeOrder( CSIPronunciation::ComparePhonemes );
+        TInt phonemeSeqIndex = iPronunOrder.FindInOrder( &pronunciation, phonemeOrder );
+        User::LeaveIfError( phonemeSeqIndex );
+       
+        // Remove from array ordered by pronunciation        
+        iPronunOrder.Remove( phonemeSeqIndex );
+        
+        // Remove from array ordered by pronunciation id
+        delete iPronunciationArray[pronunIdIndex];
+        iPronunciationArray.Remove( pronunIdIndex );        
+        }
+    else
+        {
+        pronunciation.SetParameterL( KLexiconReferenceCounter, counter );
+        }
+#else
+    RUBY_DEBUG_BLOCK("CSILexicon::DeleteL");
+    TInt index = Find( aPronunciationID );
+    User::LeaveIfError( index );
+
+    delete iPronunciationArray[index];
+    iPronunciationArray.Remove( index );
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::Find
+// Finds the index of pronunciation with the given ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSILexicon::Find( TSIPronunciationID aPronunciationID ) const
+    {
+    // Order function which is used when finding the correct item
+    TLinearOrder<CSIPronunciation> order( CSIPronunciation::Compare );
+
+    TInt retVal = KErrNotFound;
+
+    // Construct a 'dummy' CSIPronunciation so that comparison can be done 
+    // against it
+    CSIPronunciation* pronun = NULL;
+    TRAPD( error, pronun = CSIPronunciation::NewL( aPronunciationID, 0 ) );
+    if ( error )
+        {
+        return error;
+        }
+
+    // Use binary search since array is kept in the order of pronunciation ids
+    TRAP( error, retVal = iPronunciationArray.FindInOrderL( pronun, order ) );
+    delete pronun;
+    if ( error )
+        {
+        return error;
+        }
+    return retVal;
+    } 
+
+// -----------------------------------------------------------------------------
+// CSILexicon::Find
+// Finds the index of the pronunciation with the given phoneme sequence.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSILexicon::Find( const TDesC8& aPhonemeSequence ) const
+    {
+#ifdef __SIND_LEXICON_OPT    
+    // Order function which is used when finding the correct item
+    TLinearOrder<CSIPronunciation> order( CSIPronunciation::ComparePhonemes );
+
+    TInt retVal = KErrNotFound;
+
+    // Construct a 'dummy' CSIPronunciation so that comparison can be done 
+    // against it
+    CSIPronunciation* pronun = NULL;
+    TRAPD( error, 
+        pronun = CSIPronunciation::NewL( 0, 0 );
+        pronun->SetPhonemeSequenceL( aPhonemeSequence );
+        // Use binary search since array is kept in the order of pronunciation ids
+        retVal = iPronunOrder.FindInOrderL( pronun, order );
+        ); // TRAPD
+    delete pronun;
+    if ( error )
+        {
+        return error;
+        }
+    
+    // retVal is index to iPronunOrder array, but what we actually need is 
+    // index to iPronunciationArray
+    pronun = iPronunOrder[ retVal ];
+            
+    return Find( pronun->PronunciationID() );
+#else    
+    for ( TInt i=0; i < iPronunciationArray.Count(); i++ )
+	{
+		if ( aPhonemeSequence == iPronunciationArray[i]->PhonemeSequence() )
+		{
+			return i;
+		}
+	}
+	return KErrNotFound;
+#endif // __SIND_LEXICON_OPT	
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::Count
+// Counts the number of pronunciations.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSILexicon::Count() const
+    {
+    return iPronunciationArray.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::ExternalizeL
+// Stores the object to the stream.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSILexicon::ExternalizeL( RWriteStream& aWriteStream ) const
+    {
+    // Externalization involves so many data structures,
+    // That I put them to a dedicated class, CSILexiconSerializer.
+    CSILexiconSerializer* serializer = CSILexiconSerializer::NewLC( *this );
+
+    aWriteStream.WriteInt32L( KBinaryLexiconID );
+    serializer->ExternalizeL( aWriteStream );
+    aWriteStream.WriteInt32L( KBinaryLexiconID );
+
+    CleanupStack::PopAndDestroy( serializer );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexicon::InternalizeL
+// Restores the object from the stream.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSILexicon::InternalizeL( RReadStream& aReadStream )
+    {
+    // Header should be KBinaryLexiconID
+    if ( aReadStream.ReadInt32L() != KBinaryLexiconID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    CSILexiconSerializer* serializer
+        = CSILexiconSerializer::NewLC( aReadStream );
+
+    serializer->RestoreL( *this, iLexiconID );
+
+    CleanupStack::PopAndDestroy( serializer );
+
+    // Last integer should be KBinaryLexiconID
+    if ( aReadStream.ReadInt32L() != KBinaryLexiconID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+    }
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIModel::CSIModel
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModel::CSIModel( const TSIModelID aModelID )
+:	iModelID(aModelID),
+iAcousticModel(NULL)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIModel::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModel* CSIModel::NewL( const TSIModelID aModelID = 0 )
+{
+	CSIModel* self = NewLC( aModelID );
+ 	CleanupStack::Pop( self );
+    return self;
+}
+
+
+// -----------------------------------------------------------------------------
+// CSIModel::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModel* CSIModel::NewLC( const TSIModelID aModelID = 0 )
+{
+	CSIModel* self = new (ELeave) CSIModel( aModelID );
+    CleanupStack::PushL( self );
+    self->ConstructL(); 
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::~CSIModel
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModel::~CSIModel()
+{
+	delete iAcousticModel;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::SetModelID
+// Sets the model ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIModel::SetModelID(const TSIModelID aModelID)
+{
+	iModelID = aModelID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::ModelID
+// Returns the model ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIModelID CSIModel::ModelID() const
+{
+	return iModelID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::SetAcousticModel
+// Sets the model data. CSIModel takes ownership of the data.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIModel::SetAcousticModel( HBufC8*  aAcousticModel)
+{	 
+	delete iAcousticModel;
+	iAcousticModel=aAcousticModel;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModel::AcousticModel
+// Used to get the acoustic data of the model.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C   TDesC8& CSIModel::AcousticModel() const
+{
+	return *iAcousticModel;
+}
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::CSIModelBank
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModelBank::CSIModelBank( const TSIModelBankID aModelBankID)
+:	iModelBankID(aModelBankID)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIModelBank::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModelBank* CSIModelBank::NewL(const TSIModelBankID aModelBankID)
+{
+	CSIModelBank* self =NewLC(aModelBankID);
+ 	CleanupStack::Pop( self );
+    return self;
+}
+
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModelBank* CSIModelBank::NewLC(const TSIModelBankID aModelBankID)
+{
+	CSIModelBank* self = new (ELeave) CSIModelBank(aModelBankID);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::~CSIModelBank
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModelBank::~CSIModelBank()
+{
+	iModelArray.ResetAndDestroy();
+	iModelArray.Close();
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::ModelBankID
+// Returns the ID of the model bank.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIModelBankID CSIModelBank::ModelBankID() const
+{
+	return iModelBankID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::AddL
+// Adds a new model to the bank.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIModelBank::AddL( const CSIModel* aModel)
+{
+	if(Find(aModel->ModelID()) == KErrNotFound)
+	{
+		iModelArray.Append(aModel);
+	}
+	else
+	{
+		User::Leave(KErrAlreadyExists);
+		
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::AtL
+// Used to get a model from the bank.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIModel& CSIModelBank::AtL( const TInt anIndex) const
+{
+	if(anIndex<0 || anIndex >= Count())
+		User::Leave(KErrArgument);
+	
+	return *(iModelArray[anIndex]);
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::Find
+// Finds a model with the given ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIModelBank::Find(const TSIModelID aModelID) const
+{
+	for(TInt i=0; i < iModelArray.Count(); i++)
+	{
+		if(aModelID == iModelArray[i]->ModelID())
+		{
+			return i;
+		}
+	}
+	return KErrNotFound;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::DeleteL
+// Deletes a model with the given ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIModelBank::DeleteL(TSIModelID aModelID)
+{
+	TInt index = Find(aModelID );
+	if ( index != KErrNotFound)
+	{
+		delete iModelArray[index];
+		iModelArray.Remove(index);
+	}
+	
+	else  {
+		User::Leave( KErrNotFound );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBank::Count
+// Returns the number of models in the bank.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIModelBank::Count() const
+{
+	return iModelArray.Count();
+}
+
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::CSIPronunciationInfo
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciationInfo::CSIPronunciationInfo( RPointerArray<HBufC8> aPronunciation,
+                                                     TLanguage aLanguage )
+                                                   : iPronunciationArray( aPronunciation ),
+                                                     iLanguage( aLanguage )
+{
+    // nothing
+}
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIPronunciationInfo::ConstructL()
+{
+	
+	CSIParameters::ConstructL();
+} 
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciationInfo* CSIPronunciationInfo::NewL( RPointerArray<HBufC8> aPronunciation ,TLanguage aLanguage  )
+{
+	CSIPronunciationInfo* self = NewLC( aPronunciation,aLanguage );
+	CleanupStack::Pop( self );
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciationInfo* CSIPronunciationInfo::NewLC( RPointerArray<HBufC8> aPronunciation ,TLanguage aLanguage  )
+{
+	CSIPronunciationInfo* self = new (ELeave) CSIPronunciationInfo( aPronunciation,aLanguage );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+	return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::~CSIPronunciationInfo
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIPronunciationInfo::~CSIPronunciationInfo()
+{
+	iPronunciationArray.ResetAndDestroy();
+	
+} 
+
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::SetPronunciationL
+// Sets the index and phoneme sequence.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIPronunciationInfo::SetPronunciationL(TInt aIndex, HBufC8* aPronunciation)
+{
+	if( aIndex < 0 || aIndex > iPronunciationArray.Count() )
+        {
+        // wrong index
+		User::Leave( KErrArgument );
+        }
+    else if ( aIndex < iPronunciationArray.Count() )
+        {
+        // replace old pronunciation
+        delete iPronunciationArray[aIndex];
+	    iPronunciationArray[aIndex] = aPronunciation;
+        }
+    else if ( aIndex == iPronunciationArray.Count() )
+        {
+        // append new pronunciation
+        iPronunciationArray.Append( aPronunciation );
+        }
+}
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::PhonemeSequence
+// Return phoneme sequence.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TDesC8& CSIPronunciationInfo::PronunciationL(TInt aIndex) const
+{
+	if(aIndex<0 || aIndex >= Count())
+		User::Leave(KErrArgument);
+	
+    return *(iPronunciationArray[aIndex]);
+}
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::Language
+// Returns language.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TLanguage CSIPronunciationInfo::Language() const
+{
+	return iLanguage;
+}
+
+// -----------------------------------------------------------------------------
+// CSIPronunciationInfo::Count
+// Returns the number of pronunciations.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIPronunciationInfo::Count() const
+{
+	return  iPronunciationArray.Count();
+}
+
+
+
+/******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::CSITtpWordList
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSITtpWordList::CSITtpWordList() 
+: 
+iReserved( NULL )
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSITtpWordList::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSITtpWordList* CSITtpWordList::NewL()
+{
+    CSITtpWordList* self = NewLC();
+    CleanupStack::Pop( self );	
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSITtpWordList* CSITtpWordList::NewLC()
+{
+    CSITtpWordList* self = new ( ELeave ) CSITtpWordList();   
+    CleanupStack::PushL( self );
+    self->ConstructL();
+     return self;
+}
+
+// Destructor
+// -----------------------------------------------------------------------------
+// CSITtpWordList::~CSITtpWordList
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSITtpWordList::~CSITtpWordList()
+{
+	iWordArray.ResetAndDestroy();
+	iIndexArray.Close();
+	iPronunciationArray.ResetAndDestroy();
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::AddL
+// Add word to list.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSITtpWordList::AddL(
+								   MDesCArray* aWords)
+{
+	TInt error = iWordArray.Append( aWords );
+	User::LeaveIfError( error );
+	
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::Count
+// Return number of words.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSITtpWordList::Count() const
+{
+	return iWordArray.Count();
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::At
+// Give text of given index
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  MDesCArray& CSITtpWordList::AtL( 
+										  const TInt aIndex ) const
+{
+	if(aIndex<0 || aIndex >= Count())
+		User::Leave(KErrArgument);
+	return *(iWordArray[aIndex]);
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::DeleteL
+// Deletes a word.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C   void CSITtpWordList::DeleteL(TInt aIndex) 	{
+	if(aIndex<0 || aIndex >= Count())
+		User::Leave(KErrArgument);
+	delete iWordArray[aIndex];
+	iWordArray.Remove(aIndex);
+	
+	// delete pronunciation which index match to given
+	for ( TInt i(0); i < iIndexArray.Count(); i++ )
+	{
+		if ( iIndexArray[i] == aIndex )
+		{
+			delete iPronunciationArray[i];
+			iPronunciationArray.Remove(i);
+		}
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::SetPronunciationL
+// Put pronunciation to given index
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSITtpWordList::AppendPronunciationL( 
+													const TInt aIndex, 
+													CSIPronunciationInfo* aPronunciation )
+{
+	TInt error = iPronunciationArray.Append( aPronunciation );
+	User::LeaveIfError( error );
+	error = iIndexArray.Append(  aIndex );
+	if ( error )
+	{
+		// remove the added pronunciation
+		iPronunciationArray.Remove( iPronunciationArray.Count() - 1 );
+		User::Leave( error );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CSITtpWordList::GetPronunciationsL
+// Give pronunciation information of given index
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSITtpWordList::GetPronunciationsL( 
+												 const TInt aIndex,
+												 RPointerArray<CSIPronunciationInfo>& aPronunciations ) const
+{
+    CleanupClosePushL( aPronunciations ); 
+	// clear given array
+	aPronunciations.Reset();
+	
+	// add pronunciation which index match to given
+	for ( TInt i(0); i < iIndexArray.Count(); i++ )
+	{
+		if ( iIndexArray[i] == aIndex )
+		{
+			TInt error = aPronunciations.Append( iPronunciationArray[i] );
+			User::LeaveIfError( error );
+		}
+	}
+	CleanupStack::Pop( &aPronunciations ); 
+}
+/*****************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CSIResult::CSIResult
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResult::CSIResult()
+:	iGrammarID(0),
+iRuleID(0), iRuleVariantID(0)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResult::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResult* CSIResult::NewL()
+{
+	CSIResult* self = NewLC();
+  	CleanupStack::Pop( self );
+    return self;
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CSIResult::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResult* CSIResult::NewLC()
+{
+	CSIResult* self = new (ELeave) CSIResult();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+     return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::~CSIResult
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResult::~CSIResult()
+{
+	delete iSIPronunciation;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::SetGrammarID
+// Sets the grammar ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResult::SetGrammarID(const TSIGrammarID aGrammarID)
+{
+	iGrammarID = aGrammarID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::GrammarID
+// Returns the grammar ID.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIGrammarID CSIResult::GrammarID() const
+{
+	return iGrammarID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::SetRuleID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResult::SetRuleID(const TSIRuleID aRuleID)
+{
+	iRuleID = aRuleID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::RuleID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleID CSIResult::RuleID() const
+{
+	return iRuleID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::SetRuleVariantID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResult::SetRuleVariantID(const TSIRuleVariantID aRuleVariantID)
+{
+	iRuleVariantID = aRuleVariantID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::RuleVariantID
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TSIRuleVariantID CSIResult::RuleVariantID() const
+{
+	return iRuleVariantID;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::SetScore
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResult::SetScore(const TInt32 aScore)
+{
+	iScore = aScore;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::Score
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt32 CSIResult::Score() const
+{
+	return iScore;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::Pronunciation
+// Returns the pronunciation of the recognized word.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  CSIPronunciation& CSIResult::Pronunciation() const 
+{
+	return *iSIPronunciation;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResult::SetPronunciation
+// Returns the recognized pronunciation.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResult::SetPronunciation( CSIPronunciation* aSIPronunciation) 
+{										     
+	iSIPronunciation=aSIPronunciation;
+}
+
+
+/*****************************************************************************/
+
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::CSIResultSet
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResultSet::CSIResultSet()
+:	iAdaptationData(NULL)
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResultSet::ConstructL()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResultSet* CSIResultSet::NewL()
+{
+	CSIResultSet* self = NewLC();
+	CleanupStack::Pop( self );
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResultSet* CSIResultSet::NewLC()
+{
+	CSIResultSet* self = new (ELeave) CSIResultSet();
+    CleanupStack::PushL( self );
+    self->ConstructL(); 
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::~CSIResultSet
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSIResultSet::~CSIResultSet()
+{
+	iResultArray.ResetAndDestroy();
+	iResultArray.Close();
+	delete iAdaptationData ;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::AddL
+// Adds a result to the set.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResultSet::AddL( const CSIResult* aResult)
+{
+	TInt error = iResultArray.Append(aResult);
+	User::LeaveIfError( error ); 
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::AtL
+// Used to get a result.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  CSIResult& CSIResultSet::AtL(const TInt aIndex)
+{
+	if(aIndex<0 || aIndex >= Count())
+		User::Leave(KErrArgument);
+	return *(iResultArray[aIndex]);
+}
+
+EXPORT_C  const CSIResult& CSIResultSet::AtL(const TInt aIndex) const
+{
+	if(aIndex<0 || aIndex >= Count())
+		User::Leave(KErrArgument);
+	return *(iResultArray[aIndex]);
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::Count
+// Counts the number of results in the set.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSIResultSet::Count() const
+{
+	return iResultArray.Count();
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::DeleteL
+// Deletes a result. 
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  void  CSIResultSet::DeleteL(TInt aIndex) 	
+{
+	if(aIndex<0 || aIndex >= Count())
+		User::Leave(KErrArgument);
+	iResultArray.Remove(aIndex);
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::SetAdaptationData
+// Sets the adaptation data.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  void CSIResultSet::SetAdaptationData( HBufC8* aAdaptationData )
+{
+	delete iAdaptationData;
+	iAdaptationData =aAdaptationData;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::AdaptationData
+// Gets the adaptation data.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C   TDesC8& CSIResultSet::AdaptationData( )
+{  
+	return *iAdaptationData;
+}
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::ExternalizeL
+// Stores the object to the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResultSet::ExternalizeL( RWriteStream& aWriteStream ) const
+    {
+    aWriteStream.WriteInt32L( KBinaryResultSetID );
+
+    if ( iAdaptationData != NULL )
+        {
+        aWriteStream.WriteInt32L( iAdaptationData->Length() );
+        aWriteStream.WriteL( *iAdaptationData );
+        }
+    else{
+        aWriteStream.WriteInt32L( 0 );
+        }
+
+    aWriteStream.WriteInt32L( iResultArray.Count() );
+
+    // Write the data
+    for ( TInt k( 0 ); k < iResultArray.Count(); k++ )
+        {
+        CSIResult*        result = iResultArray[ k ];
+        const CSIPronunciation& pronun = result->Pronunciation();
+
+        aWriteStream.WriteInt32L( result->GrammarID() );
+        aWriteStream.WriteInt32L( result->RuleID() );
+        aWriteStream.WriteInt32L( result->RuleVariantID() );
+        aWriteStream.WriteInt32L( result->Score() );
+        result->CSIParameters::ExternalizeL( aWriteStream );
+
+        // !!!! Crashes, if pronunciation is zero.
+
+        // Pronunciations
+        const TDesC8& seq = pronun.PhonemeSequence();
+        TInt length = seq.Length();
+
+        aWriteStream.WriteInt32L( length );
+        aWriteStream.WriteL( seq );
+
+        aWriteStream.WriteInt32L( pronun.PronunciationID() );
+        aWriteStream.WriteInt32L( pronun.ModelBankID() );
+        pronun.ExternalizeL( aWriteStream );
+        }
+
+    aWriteStream.WriteInt32L( KBinaryResultSetID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIResultSet::InternalizeL
+// Restores the object from the stream.
+// (other items were commented in the headers)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSIResultSet::InternalizeL( RReadStream& aReadStream )
+    {
+    if ( iAdaptationData != NULL || iResultArray.Count() > 0 )
+        {
+        User::Leave( KErrInUse );
+        }
+
+    if ( aReadStream.ReadInt32L() != KBinaryResultSetID )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    TInt length = aReadStream.ReadInt32L();
+
+    if ( length )
+        {
+        iAdaptationData = HBufC8::NewL( length );
+        TPtr8 adaptationDataDes = iAdaptationData->Des();
+        aReadStream.ReadL( adaptationDataDes, length );
+        }
+    else{
+        iAdaptationData = 0;
+        }
+
+    TInt resultCount = aReadStream.ReadInt32L();
+
+    for ( TInt k = 0; k < resultCount; k++ )
+        {
+        CSIResult*        result = CSIResult::NewLC();
+
+        result->SetGrammarID    ( (TSIGrammarID)    aReadStream.ReadInt32L() );
+        result->SetRuleID       ( (TSIRuleID)       aReadStream.ReadInt32L() );
+        result->SetRuleVariantID( (TSIRuleVariantID)aReadStream.ReadInt32L() );
+        result->SetScore        ( aReadStream.ReadInt32L() );
+        result->CSIParameters::InternalizeL( aReadStream );
+
+        // Pronunciations
+
+        TInt length = aReadStream.ReadInt32L();
+        HBufC8* seq = HBufC8::NewLC( length );
+
+        TPtr8 seqPtr = seq->Des();
+        aReadStream.ReadL( seqPtr, length );
+
+        TSIPronunciationID pronunciationID = aReadStream.ReadInt32L();
+        TSIModelBankID modelBankID 
+            = (TSIModelBankID)aReadStream.ReadInt32L();
+
+        CSIPronunciation* pronun
+            = CSIPronunciation::NewLC( pronunciationID, modelBankID );
+        pronun->SetPhonemeSequenceL( *seq );
+
+        pronun->CSIParameters::InternalizeL( aReadStream );
+
+        result->SetPronunciation( pronun );
+
+        AddL( result );
+
+        CleanupStack::Pop( pronun );
+        CleanupStack::PopAndDestroy( seq );
+        CleanupStack::Pop( result );
+        }
+
+    if ( aReadStream.ReadInt32L() != KBinaryResultSetID )
+        User::Leave( KErrCorrupt );
+    }
+
+//		void DeleteL(TInt aIndex);
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sispeechrecognitiondata/src/nsssispeechrecognitiondatatest.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains definition of the SISpeechRecognitionDataTest structure and API.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "nsssispeechrecognitiondatatest.h"
+
+EXPORT_C TSIDiagnostic::TSIDiagnostic()
+	:	iSNR(0), iAccepted(EFalse)
+	{}
+
+EXPORT_C TSIDiagnostic::~TSIDiagnostic()
+	{}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/data/101ff930.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM registration information of SD Controller Plugin.
+*
+*/
+
+
+//  INCLUDES
+#include <registryinfo.rh>
+#include <mmfplugininterfaceuids.hrh>
+#include "sipluginimplementationuids.hrh"
+
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// theInfo
+// SD Controller Plugin ECOM registration information.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+    {
+	// UID of the Plugin DLL file.
+	dll_uid = KSIDllUidController;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// ECOM interface UID. The same for all MMF plugins.
+			// ECOM interface changes, when the list of exported functions changes.
+			// MMF interfaces are extended through Custom Commands, so extending the interface
+			// does not add new exported functions.
+			interface_uid = KMmfUidPluginInterfaceController;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = KSIUidController;
+					version_no = 1;
+					display_name = "SI Controller Plugin";
+					default_data = " ";
+					// 0x101FF932 is MMF interface UID. MMF interface changes, when
+					// the list of custom commands is changed.
+					//
+					// The interface is speaker independent custom commands.
+					opaque_data = "<s>Nokia<i>0x101FF932<a>0x300000";
+					}
+				};
+			}
+		};
+    }
+            
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/data/nsssisrscontrollerplugin.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  SI Controller Plugin resource file.
+*
+*/
+
+
+//  INCLUDES
+#include "sicontrollerresource.rh"
+#include "sipluginimplementationuids.hrh"
+
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// siControllerInfo
+// SI Controller Plugin resouce file.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE SICONTROLLER_INFO siControllerInfo
+    {
+/*
+    voice_encoder_uid = KUidCodecPCM16ToAMR;	// AMR encoder
+    voice_decoder_uid = KUidCodecAMRToPCM16;	// AMR decoder
+    compression_rate = 0;			// 4.75 kbit/s
+    max_models_per_bank = 50;
+*/  max_models_in_system = 60;
+	
+    // Plugin database file name
+    db_file_name="c:Sidatabase.db";
+
+    // Language package data file path and prefix
+    data_file_name_prefix="z:\\system\\data\\srsf_";
+	
+    // Language package data file postfix
+    data_file_name_postfix=".bin";
+
+    // Language package data file name seperator
+    data_file_name_seperator="_";
+    }            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project build file for SIControllerPlugin
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/10201aff.spd    /epoc32/release/winscw/udeb/z/private/100012a5/policy/10201aff.spd
+../inc/10201aff.spd    /epoc32/release/winscw/urel/z/private/100012a5/policy/10201aff.spd
+../inc/10201aff.spd    /epoc32/data/z/private/100012a5/policy/10201aff.spd
+
+PRJ_MMPFILES
+sicontrollerplugin.mmp
+
+// End of File  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/group/sicontrollerplugin.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for SIControllerPlugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+TARGET             nsssicontrollerplugin.dll
+TARGETTYPE         PLUGIN
+UID                0x10009D8D 0x101FF930
+
+VENDORID           VID_DEFAULT
+
+SOURCEPATH        ../src
+
+SOURCE            sicontrollerplugininterface.cpp
+SOURCE            sicontrollerplugin.cpp
+SOURCE            sidatabase.cpp
+SOURCE            sicommondb.cpp
+SOURCE            siresourcehandler.cpp
+SOURCE            asrplugindataloader.cpp
+SOURCE            simodelbankdb.cpp
+SOURCE            sigrammardb.cpp
+SOURCE            silexicondb.cpp
+SOURCE            nssbackupobserver.cpp
+
+#ifdef __SINDE_TRAINING
+SOURCE            sindetraining.cpp
+#endif // __SINDE_TRAINING
+
+START RESOURCE    ../data/101ff930.rss
+TARGET            nsssicontrollerplugin.rsc
+END
+
+START RESOURCE    ../data/nsssisrscontrollerplugin.rss
+HEADER
+TARGET            nsssisrscontrollerplugin.rsc
+TARGETPATH        resource
+END
+
+USERINCLUDE       .
+USERINCLUDE       ../inc ../src
+USERINCLUDE       ../../group // for srsfbldvariant.hrh
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE     /epoc32/include/ecom
+SYSTEMINCLUDE     /epoc32/include/connect
+SYSTEMINCLUDE     /epoc32/include/mmf/server  // MmfCodec, MmfBuffer
+SYSTEMINCLUDE     /epoc32/include/mmf/common  // TMMFEvent
+
+
+USERINCLUDE	      ../../rubydebug  
+
+LIBRARY           euser.lib
+LIBRARY           edbms.lib     // Database Management System
+LIBRARY           estor.lib     // File store for database
+LIBRARY           efsrv.lib     // File server session for database
+LIBRARY           bafl.lib      // Resource file
+LIBRARY           nssdevasr.lib // DevASR
+LIBRARY           nsssispeechrecognitiondata.lib  // SI Speech Recognition Data
+LIBRARY           mmfcontrollerframework.lib      // TMMFEvent
+LIBRARY           nsssispeechrecognitioncustomcommands.lib  // Speaker Independent Custom Commands
+#ifdef __SIND_AUTOCONF_LID
+LIBRARY           syslangutil.lib // get installed languages
+#endif // __SIND_AUTOCONF_LID
+#ifdef EABI
+LIBRARY           ecom.lib
+#endif
+#ifdef __SINDE_TRAINING
+LIBRARY          numberconversion.lib
+#endif
+
+CAPABILITY        CAP_ECOM_PLUGIN
Binary file srsf/sisrscontrollerplugin/inc/10201aff.spd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/10201aff.txt	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,10 @@
+;Security policy for NSS VAS DB
+[database]
+read
+capability = ReadUserData
+write
+capability = WriteUserData
+schema
+capability = WriteUserData
+[backup]
+sid = 10201AFF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/asrplugindataloader.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,336 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Language package data file loader 
+*
+*/
+
+
+// INCLUDE FILES
+#include "asrplugindataloader.h"
+#include "sysconfigprovider.h"
+
+
+#ifdef __SIND_AUTOCONF_LID
+#include <syslangutil.h>
+/* MSysConfigProvider is a wrapper for get syslangutil. This makes it easier to test without */
+/* dependency to the actual language configuration in the emulator environment. The test  */
+/* class implements this interface. */
+class TDefaultConfig : public MSysConfigProvider {
+public:
+	TDefaultConfig() {};
+	~TDefaultConfig() {};
+	TInt GetInstalledLanguages( CArrayFixFlat<TInt>*& aLanguages, RFs* aFileServerSession = NULL ) 
+	{
+		return SysLangUtil::GetInstalledLanguages(aLanguages, aFileServerSession);		
+	};
+};
+#endif  // __SIND_AUTOCONF_LID
+
+// Local constants
+
+_LIT( KZDriveLetter, "z" ); 
+ 
+
+#ifdef __SIND_AUTOCONF_LID
+const TUint32 KTtpAutoConfLidPackageType = 1;
+const TUint32 KTtpAutoConfLidPackageID   = 1;
+const TInt KLidBufGranularity = 1000;
+#endif  // __SIND_AUTOCONF_LID
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDataLoaderLoader::CDataLoader
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDataLoader::CDataLoader() 
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CDataLoader::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDataLoader::ConstructL( const TDesC& aPrefixOfFileName,
+							  const TDesC& aSeparator,                                     
+                              const TDesC& aPostfixOfFileName,
+                              MSysConfigProvider *aProvider )
+    {
+    iPrefixOfFileName = HBufC::NewL( aPrefixOfFileName.Length() );
+    (*iPrefixOfFileName) = aPrefixOfFileName;
+    iSeparator = HBufC::NewL( aSeparator.Length() );
+    (*iSeparator) = aSeparator;
+    iPostfixOfFileName = HBufC::NewL( aPostfixOfFileName.Length() );
+    (*iPostfixOfFileName) = aPostfixOfFileName;
+    
+	iProvider = aProvider;
+
+    // Open file session
+    User::LeaveIfError( iFs.Connect() );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataLoader::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDataLoader* CDataLoader::NewL( const TDesC& aPrefixOfFileName,
+								const TDesC& aSeparator,                                     
+                                const TDesC& aPostfixOfFileName,
+                                MSysConfigProvider *aProvider )
+    {
+    CDataLoader* self = new ( ELeave ) CDataLoader();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aPrefixOfFileName,
+					  aSeparator,                                     
+                      aPostfixOfFileName,
+                      aProvider);
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDataLoader::~CDataLoader
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDataLoader::~CDataLoader()
+    {
+    delete iPrefixOfFileName,
+	delete iSeparator,                                     
+    delete iPostfixOfFileName;    
+    
+    iFs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDataLoader::PackageName
+// Construct filename for requested package
+// -----------------------------------------------------------------------------
+//	
+void CDataLoader::PackageName (TFileName &aFileName, TUint32 aPackageType, TUint32 aPackageID) 
+{
+	// Resolve the name of the file
+	// filename is <iPrefixOfFileName>_<PackageType>_<aPackageID><iPostfixOfFileName>
+
+	aFileName.Copy( iPrefixOfFileName->Des() );          //  path/SRSF_
+	aFileName.AppendNumUC( aPackageType );               //  path/SRSF_1
+	aFileName.Append( iSeparator->Des() );               //  path/SRSF_1_
+	aFileName.AppendNumUC( aPackageID );                 //  path/SRSF_1_326
+	aFileName.Append( iPostfixOfFileName->Des() );       //  path/SRSF_1_326.bin
+}
+
+#ifdef __SIND_AUTOCONF_LID
+// -----------------------------------------------------------------------------
+// CDataLoader::AppendLoadL
+// Load language package file to the end of buffer
+// -----------------------------------------------------------------------------
+//	
+void CDataLoader::AppendLoadL( CBufBase *aBuffer,
+								TUint32 aPackageType, 
+								TUint32 aPackageID ) 
+{
+	// Resolve filename
+	TFileName fileName;
+	PackageName (fileName, aPackageType, aPackageID);
+
+	// Load data
+	HBufC8* buffer = NULL;
+	
+	TRAPD( err, buffer = DoLoadL( fileName, 0, KMaxTUint32 ));  // IMPLICIT: LID packages are loaded completely
+ 	if( err == KErrNone && buffer ) 
+ 	{
+		CleanupStack::PushL( buffer );                    // ResizeL may leave below
+
+		TInt prevSize = aBuffer->Size();                  // size before resize
+		TInt newSize  = aBuffer->Size() + buffer->Size(); // new size for lid data buffer
+
+		aBuffer->ResizeL( newSize );                      // resize lid data buffer
+		aBuffer->Write( prevSize, *buffer );              // append data from read buffer
+
+		CleanupStack::PopAndDestroy(buffer);              // buffer copied -> free
+	}
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CDataLoader::LoadSysLangPackagesL
+// Load LID language data to a buffer according to installed system languages
+// -----------------------------------------------------------------------------
+//	
+void CDataLoader::SysLangPackagesToBufferL( CBufBase *aBuffer ) 
+{        
+	MSysConfigProvider *config = iProvider;
+	TDefaultConfig defaultProvider;
+	if (!config) config = &defaultProvider;
+
+	// Get installed languages
+	CArrayFixFlat<TInt>* languages( NULL );
+
+	//User::LeaveIfError (SysLangUtil::GetInstalledLanguages(languages, &iFs));
+	User::LeaveIfError (config->GetInstalledLanguages(languages, &iFs));
+	CleanupStack::PushL( languages ) ;
+
+	// Loop over installed languages
+	for ( TInt i = 0 ; i < languages->Count(); i++ )
+	{
+		AppendLoadL(aBuffer, KTtpAutoConfLidPackageType, languages->At(i));
+	}// next language
+	
+	CleanupStack::PopAndDestroy( languages );
+}
+
+// -----------------------------------------------------------------------------
+// CDataLoader::ConstructLidDataL
+// Load LID language data to a buffer according to installed system languages
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CDataLoader::ConstructLidDataL()
+{
+	CBufBase* lidDataBuffer = CBufSeg::NewL( KLidBufGranularity ) ; // accumulates the binary data from lid model files
+	CleanupStack::PushL( lidDataBuffer ) ;
+
+	SysLangPackagesToBufferL (lidDataBuffer);
+
+	// Prepare returnable data
+	HBufC8* dataBuffer = NULL;
+	
+	if( lidDataBuffer->Size() > 0 ) 
+	{
+		// If any data was loaded, create a buffer for it
+		dataBuffer = HBufC8::NewL( lidDataBuffer->Size() );     // create a returnable buffer
+		TPtr8 dataBufferPtr = dataBuffer->Des();                        // get a modifiable pointer to it
+		lidDataBuffer->Read( 0, dataBufferPtr, lidDataBuffer->Size() ); // put the lid data into it
+	}
+
+	CleanupStack::PopAndDestroy( lidDataBuffer ) ;  
+
+	return dataBuffer;
+}
+#endif  // __SIND_AUTOCONF_LID
+
+
+// -----------------------------------------------------------------------------
+// CDataLoader::LoadData
+// Load language package file. It resolves the name of the language package
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CDataLoader::LoadData( TUint32 aPackageType, 
+								TUint32 aPackageID,
+								TUint32 aStartPosition,
+								TUint32 aEndPosition ) {
+
+	TInt err;
+	HBufC8* buffer = NULL;
+
+#ifdef __SIND_AUTOCONF_LID
+	// If LID data is requested, construct it from installed LID binary files
+	// Otherwise run normal data loading
+
+	if( aPackageType == KTtpAutoConfLidPackageType &&
+		aPackageID   == KTtpAutoConfLidPackageID )
+	{
+		TRAP( err, buffer = ConstructLidDataL() );
+	}
+#endif  // __SIND_AUTOCONF_LID
+
+	if (!buffer)	{
+		TFileName fileName;
+		PackageName (fileName, aPackageType, aPackageID);
+	
+		// Load data    
+		TRAP( err, buffer = DoLoadL( fileName, aStartPosition, aEndPosition ) );
+	}
+
+	if ( err == KErrNone )
+	{
+		return buffer;
+  }
+	else
+	{
+		return NULL;
+	}    
+}
+                                         
+
+
+// -----------------------------------------------------------------------------
+// CDataLoader::DoLoadL
+// Actual file loading function
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CDataLoader::DoLoadL( TFileName& aFileName,
+                              TUint32 aStartPosition, 
+                              TUint32 aEndPosition )
+    {
+    TInt fileSize( 0 );
+    RFile dataFile;
+    TInt readLength;
+
+    // Open file	
+    TInt err = dataFile.Open( iFs, aFileName, EFileRead);
+	 
+		if ( err != KErrNone )	 
+		{		
+			aFileName.Replace(0,1,KZDriveLetter); // "z:\"
+			TInt err = dataFile.Open( iFs, aFileName, EFileRead);		 
+			if ( err != KErrNone )
+          {
+    			return NULL;
+          }
+		}
+
+	CleanupClosePushL( dataFile );
+    // Try to resolve how much should be read
+    readLength = aEndPosition - aStartPosition;
+    User::LeaveIfError( dataFile.Size( fileSize ) );
+
+    if ( aEndPosition != KMaxTUint32 )
+        {
+        // Cannot read more than filesize
+        if ( ( readLength > fileSize ) || ( readLength < 0 ) )
+            {
+            readLength = fileSize;
+            }
+        }
+    else
+        {
+        readLength = fileSize;
+        }
+    
+    // Seek the starting point
+    // Casting needed to convert from uint to int which is needed by Seek()
+    TInt startPosition = ( TInt ) aStartPosition;
+    dataFile.Seek( ESeekStart, startPosition );
+
+    // Reserve enough memory for the data
+    HBufC8* fileBuffer = HBufC8::NewLC( readLength );
+    TPtr8 bufferPtr( fileBuffer->Des() );
+    
+    User::LeaveIfError( dataFile.Read( bufferPtr ) );
+
+    CleanupStack::Pop( fileBuffer );
+    CleanupStack::PopAndDestroy( &dataFile );
+    return fileBuffer;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/asrplugindataloader.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for SI Plugin to read data from file.
+*
+*/
+
+
+#ifndef ASRPLUGINDATALOADER_H
+#define ASRPLUGINDATALOADER_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include "srsfbldvariant.hrh"
+
+
+// FORWARD DECLARATION
+class MSysConfigProvider;
+
+// CLASS DECLARATION
+
+/**
+* Class for SI Plugin to load language package file.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.8
+*/
+class CDataLoader : public CBase
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDataLoader* NewL( const TDesC& aPrefixOfFileName,
+                                  const TDesC& aSeparator,
+                                  const TDesC& aPostfixOfFileName,
+                                  MSysConfigProvider *aProvider = NULL );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDataLoader();
+        
+    public: // New functions
+        
+       /**
+		* Load language package file. It resovles the name of the langage package
+		*
+		* @since 2.8
+		* @param  aPackageType   Type identifier.
+		* @param  aPackageID     Identifier of package.
+		* @param  aStartPosition Starting position within package in bytes.
+		* @param  aEndPosition   Ending position within package in bytes.
+		* @return Pointer to created buffer containing the request data.
+        *         NULL if error occurs during loading.	
+		*/
+        HBufC8* LoadData( TUint32 aPackageType, 
+                          TUint32 aPackageID,
+                          TUint32 aStartPosition ,
+                          TUint32 aEndPosition );
+
+    protected:
+
+       /**
+		* Actual file loading function.
+		*
+		* @since 2.8
+		* @param  aFile			  Data file name
+		* @param  aStartPosition  Starting position within package in bytes.
+		* @param  aEndPosition    Ending position within package in bytes.
+		* @return Pointer to created buffer containing the request data.
+		* 		  NULL if error occurs during loading.	
+		*/
+        HBufC8* DoLoadL( TFileName& aFile,
+                         TUint32 aStartPosition, 
+                         TUint32 aEndPosition );
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CDataLoader();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( const TDesC& aPrefixOfFileName,
+						 const TDesC& aSeparator,                                     
+                         const TDesC& aPostfixOfFileName,
+                         MSysConfigProvider *aProvider);
+
+		/**
+		* Helper function for creating data file names
+		* @param  aFileName	      TFileName where to write the result
+		* @param  aPackageType    Type identifier.
+		* @param  aPackageID      Identifier of package.
+		*/
+		void PackageName (TFileName &aFileName, TUint32 aPackageType, TUint32 aPackageID);
+
+
+#ifdef __SIND_AUTOCONF_LID
+		/**
+		* Special loader for language identification data
+		* @return Pointer to the loaded data
+		*         NULL if error occurs during loading
+		*/ 
+		HBufC8* ConstructLidDataL();
+
+
+		/**
+		* Loads a file to the end of a buffer
+		* @param  aBuffer         The buffer where to load the data
+		* @param  aPackageType    Type identifier.
+		* @param  aPackageID      Identifier of package.
+		*/
+		void AppendLoadL( CBufBase *aBuffer, TUint32 aPackageType, TUint32 aPackageID );
+
+
+		/**
+		* Obtains the list of installed languages in the system and loads the corresponding data files
+		* to the buffer.
+		* @param  aBuffer         The buffer where to load the data
+		*/
+		void SysLangPackagesToBufferL( CBufBase *aBuffer );
+
+#endif  // __SIND_AUTOCONF_LID
+
+        
+    private: // Data
+        
+        // seperator
+        HBufC* iSeparator ;
+        
+        // Prefix of file name 
+        HBufC* iPrefixOfFileName;
+        
+        // Postfix of file name
+        HBufC* iPostfixOfFileName;
+        
+        // File session
+        RFs iFs;
+
+        // Provides language configuration
+        MSysConfigProvider *iProvider;
+    };
+    
+#endif // ASRPLUGINDATALOADER_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/nssbackupobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches changes of the PC-Suite data sync state
+*
+*/
+
+
+#include "nssbackupobserver.h"
+#include "rubydebug.h"
+
+#include <sbdefs.h>
+
+// ---------------------------------------------------------
+// CNssTag::NewL
+// NewL
+// ---------------------------------------------------------
+//
+CNssBackupObserver* CNssBackupObserver::NewL( CSIDatabase& aDb )
+    {
+    CNssBackupObserver* self = new (ELeave) CNssBackupObserver( aDb );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CNssBackupObserver::CNssBackupObserver
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+CNssBackupObserver::CNssBackupObserver( CSIDatabase& aDb ) :
+    CActive( CActive::EPriorityHigh ),
+    iDb( aDb )
+    {
+    // Nothing
+    }
+    
+// ---------------------------------------------------------
+// CNssBackupObserver::ConstructL
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+void CNssBackupObserver::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "CNssBackupObserver::ConstructL" );
+    User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) );
+    
+    // check the current value
+    TInt backupFlag( conn::EBURUnset ); 
+	User::LeaveIfError( iProperty.Get( backupFlag ) );
+	
+    switch ( backupFlag & conn::KBURPartTypeMask )
+	    {
+	    case conn::EBURNormal:
+	        // normal nothing to do
+	        break;
+	        
+	    case conn::EBURBackupFull:
+	    case conn::EBURBackupPartial:
+	    case conn::EBURRestoreFull:
+	    case conn::EBURRestorePartial:
+	        // Lock the use of database
+	        RUBY_DEBUG0( "CNssBackupObserver::ConstructL Lock transactions" );
+	        iDb.LockTransactionsL();
+	        break;
+	        
+	    case conn::EBURUnset:
+	    default:
+	        RUBY_DEBUG0( "CNssBackupObserver::ConstructL unknown value" );
+	    }   
+	     
+    // initial subscription and process current property value
+    iProperty.Subscribe( iStatus );
+    
+    CActiveScheduler::Add( this ); 
+    SetActive();   
+    }
+    
+// ---------------------------------------------------------
+// CNssBackupObserver::~CNssBackupObserver
+// Destructor
+// ---------------------------------------------------------
+//
+CNssBackupObserver::~CNssBackupObserver()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+// ---------------------------------------------------------
+// CNssBackupObserver::DoCancel
+// Cancel listening now
+// ---------------------------------------------------------
+//    
+void CNssBackupObserver::DoCancel() 
+    {
+    iProperty.Cancel();
+    }
+
+// ---------------------------------------------------------
+// CNssBackupObserver::RunL
+// Is called, when property changed
+// ---------------------------------------------------------
+//
+void CNssBackupObserver::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssBackupObserver::RunL" );
+    
+    if( iStatus != KErrNone ) 
+        {
+        // At least report the error
+        RUBY_ERROR1( "CNssBackupObserver::RunL iStatus is [%d]", iStatus.Int() );
+        }
+        
+    // resubscribe before processing new value to prevent missing updates
+    // even if some error happened
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    // property updated, get new value
+	TInt backupFlag;
+	User::LeaveIfError( iProperty.Get( backupFlag ) );
+	switch ( backupFlag & conn::KBURPartTypeMask )
+	    {
+	    case conn::EBURNormal:
+	        // Database can be used again
+	        RUBY_DEBUG0( "CNssBackupObserver::RunL Unlock transactions" );
+	        iDb.UnlockTransactionsL();
+	        break;
+	        
+	    case conn::EBURBackupFull:
+	    case conn::EBURBackupPartial:
+	    case conn::EBURRestoreFull:
+	    case conn::EBURRestorePartial:
+	        // Lock the use of database
+	        RUBY_DEBUG0( "CNssBackupObserver::RunL Lock transactions" );
+	        iDb.LockTransactionsL();
+	        break;
+	        
+	    case conn::EBURUnset:
+	    default:
+	        RUBY_ERROR1( "CNssBackupObserver::RunL backup flag unknown %h ", backupFlag );
+	    }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/nssbackupobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watcher for the PC-Suite data sync state
+*
+*/
+
+
+#ifndef NSSBACKUPOBSERVER_H
+#define NSSBACKUPOBSERVER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+
+// Publish & Subscribe of the contact handler activity
+#include <e32property.h>  
+#include "sidatabase.h"
+
+// CONSTANTS
+
+
+// MACROS
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+/**
+* RProperty based data sync watcher implementation
+*/
+class CNssBackupObserver : public CActive
+    {
+    public:
+        /** 
+        *  Factory construction
+        *  @param aDb Database 
+        *  @return Constructed and already started observer
+        */
+        static CNssBackupObserver* NewL( CSIDatabase& aDb );
+        
+        /** 
+        * Destructor 
+        */
+        ~CNssBackupObserver();
+        
+    private:
+        /**
+        * C++ constructor 
+        */
+        CNssBackupObserver( CSIDatabase& aDb );
+        
+        /**
+        * Symbian second phase constructor 
+        */
+        void ConstructL();
+        
+        /**
+        * is called when data sync property changed 
+        */
+        void RunL();
+        
+        /**
+        * Is called when system wants immediate cancelling of the watching 
+        */
+        void DoCancel();
+        
+    private:
+        // Publish & Sunscribe property about backup/restore 
+        RProperty   iProperty;
+        
+        // Database to be notified about the backup/restore
+        CSIDatabase& iDb;
+    };
+
+#endif // NSSBACKUPOBSERVER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicommondb.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,604 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is the baseclass for all SI Controller Plugin DB
+*               classes. It implements the common database functionalities.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "sicommondb.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+
+// Name of the DB lock mutex
+_LIT( KLockMutex, "SIGRAMMAR" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::CSICommonDB
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSICommonDB::CSICommonDB( RDbNamedDatabase& aDatabase, 
+                          RDbs& aDbSession, TInt aDrive )
+: iDb( aDatabase ),
+  iDbSession( aDbSession ),
+  iDrive( aDrive )
+    {
+    
+    TInt err = iMutex.OpenGlobal( KLockMutex );
+    if ( err != KErrNone )
+        {
+        RUBY_DEBUG0( "CSICommonDB::CSICommonDB Creating new global mutex" );
+        iMutex.CreateGlobal( KLockMutex );
+        }
+    else
+        {
+        RUBY_DEBUG0( "CSICommonDB::CSICommonDB Using existing global mutex" );
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::CSICommonDB
+// Destructor 
+// -----------------------------------------------------------------------------
+//
+CSICommonDB::~CSICommonDB()
+    {
+    if ( iMutex.IsHeld() )
+        {
+        iMutex.Signal();
+        }
+    iMutex.Close();    
+    }
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::CheckIDTableL
+// Each of controller's database files has an ID table.  If the database has no
+// table, this is the first time the database is open, so the ID table is created.
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::CreateIDTableL( const TDesC& aIdTable,
+                                  const TDesC& aIdColumn,
+                                  const TDesC& aIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CSICommonDB::CheckIDTableL - create ID table" );
+    
+    TBuf<150> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // CREATE TABLE aIdTable (aIdColumn COUNTER, KClientUidColumn INTEGER NOT NULL,
+    // KCounterColumn INTEGER NOT NULL, KUsedColumn BIT NOT NULL)
+    _LIT(KSQLCreate1, "CREATE TABLE ");
+    _LIT(KSQLCreate2, " COUNTER, ");
+    _LIT(KSQLCreate3, " INTEGER NOT NULL, ");
+    _LIT(KSQLCreate4, " BIT NOT NULL)");
+    
+    KSQLStatement = KSQLCreate1;
+    KSQLStatement.Append(aIdTable);
+    KSQLStatement.Append(KOpenParen);
+    KSQLStatement.Append(aIdColumn);
+    KSQLStatement.Append(KSQLCreate2);
+    KSQLStatement.Append(KClientUidColumn);
+    KSQLStatement.Append(KSQLCreate3);
+    KSQLStatement.Append(KCounterColumn);
+    KSQLStatement.Append(KSQLCreate3);
+    KSQLStatement.Append(KUsedColumn);
+    KSQLStatement.Append(KSQLCreate4);
+    
+    User::LeaveIfError(iDb.Execute(KSQLStatement));
+    
+    // Create an index on the 'Id' column to ensure 'Id' values are unique
+    // CREATE UNIQUE INDEX aIndex ON aIdTable (aIdColumn)
+    _LIT(KSQLIndex1, "CREATE UNIQUE INDEX ");
+    _LIT(KSQLIndex2, " ON ");
+    
+    KSQLStatement = KSQLIndex1;
+    KSQLStatement.Append(aIndex);
+    KSQLStatement.Append(KSQLIndex2);
+    KSQLStatement.Append(aIdTable);
+    KSQLStatement.Append(KOpenParen);
+    KSQLStatement.Append(aIdColumn);
+    KSQLStatement.Append(KCloseParen);
+    
+    User::LeaveIfError(iDb.Execute(KSQLStatement));
+    }
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::CreateNewIDL
+// This function first checks to see if there is an "unused" ID.  If one is not
+// found, it creates a new row in the table for a new ID.
+// -----------------------------------------------------------------------------
+//
+TUint32 CSICommonDB::CreateNewIDL(
+	const TDesC& aTableName,
+	const TDesC& aIdColumn,
+	TUid aClientUid )
+    {
+    RUBY_DEBUG_BLOCKL( "CSICommonDB::CreateNewIDL" );
+    
+	TUint32 newID( 0 );
+	
+	iMutex.Wait();
+	
+	TRAPD( error, newID = DoCreateNewIDL( aTableName, aIdColumn, aClientUid ) );
+	
+	iMutex.Signal();
+	
+    User::LeaveIfError( error );
+
+	return newID;
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::CountL
+// This function first searches the row with aKey and returns the counter value
+// given that the row is set as "used".
+// -----------------------------------------------------------------------------
+//
+TInt CSICommonDB::CountL( const TDesC& aTableName, const TDesC& aIndex,
+                          TUint aKey )
+	{
+    RUBY_DEBUG_BLOCK( "CSICommonDB::CountL" );
+	RDbTable dbTable;		// Provides access to table data as a rowset
+	TInt count = 0;
+
+	// Open model table
+	User::LeaveIfError(dbTable.Open(iDb, aTableName, RDbTable::EReadOnly));
+	CleanupClosePushL(dbTable);
+	User::LeaveIfError(dbTable.SetIndex(aIndex));
+
+	TDbSeekKey key(aKey);
+	// Return true, if a matching row found
+	if ( dbTable.SeekL(key) )
+		{
+		dbTable.GetL();
+		// Get column set for column ordinals
+		CDbColSet* columns = dbTable.ColSetL();
+		TDbColNo counter_col = columns->ColNo(KCounterColumn);
+		TDbColNo used_col = columns->ColNo(KUsedColumn);
+		delete columns;
+
+		// Check if this row is currently in use
+		TBool used = dbTable.ColInt(used_col);
+		if ( used )
+			{
+			count = dbTable.ColInt(counter_col);
+			}
+		else
+			{
+            RUBY_DEBUG1( "CSICommonDB::CountL - key=%d is unused", aKey );
+			User::Leave(KErrNotFound);
+			}
+		}
+	else
+		{
+        RUBY_DEBUG1( "CSICommonDB::CountL - can't find key=%d", aKey );
+		User::Leave(KErrNotFound);
+		}
+
+    // Cleanup dbTable
+    CleanupStack::PopAndDestroy();
+	return count;
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::CreateDatabaseL
+// Creates a database file if one does not exist yet.
+// -----------------------------------------------------------------------------
+//
+TBool CSICommonDB::FindUnusedIDL(
+	RDbTable& aDbTable )
+	{
+	TBuf<30> KSQLQuery;
+	// Declare a literal string to hold the SQL search-condition for 'unused' row
+	// KUsedColumn = KNotUsed
+	KSQLQuery = KUsedColumn;
+	KSQLQuery.Append(KEqual);
+	KSQLQuery.AppendNum(KNotUsed);
+
+	// Return true, if the table is not empty and a matching row found
+	return (aDbTable.FirstL()  &&  aDbTable.FindL(RDbTable::EForwards, TDbQuery(KSQLQuery)) != KErrNotFound);
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::GetAllClientIDsL
+// This function returns all Ids in the specified table that belong to the specified client.
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::GetAllClientIDsL(
+	const TDesC& aIdTable,
+	const TDesC& aIdColumn,
+	TUid aClientUid,
+	RArray<TUint32>& aIDs )
+	{
+	CleanupClosePushL( aIDs ); 
+	
+	TBuf<100> KSQLStatement;
+	// Declare a literal string to hold the SQL statement
+	// SELECT aIdColumn, KUsedColumn FROM aIdTable WHERE KClientUidColumn = uid
+	// ORDER BY aIdColumn
+	_LIT(KSQLSelect1, "SELECT ");
+	_LIT(KSQLSelect2, " FROM ");
+	_LIT(KSQLSelect3, " WHERE ");
+	_LIT(KSQLSelect4, " ORDER BY ");
+
+	KSQLStatement = KSQLSelect1;
+	KSQLStatement.Append(aIdColumn);
+	KSQLStatement.Append(KNext);
+	KSQLStatement.Append(KUsedColumn);
+	KSQLStatement.Append(KSQLSelect2);
+	KSQLStatement.Append(aIdTable);
+	KSQLStatement.Append(KSQLSelect3);
+	KSQLStatement.Append(KClientUidColumn);
+	KSQLStatement.Append(KEqual);
+	KSQLStatement.AppendNum((TInt) aClientUid.iUid);
+	KSQLStatement.Append(KSQLSelect4);
+	KSQLStatement.Append(aIdColumn);
+
+	RDbView view;
+	CleanupClosePushL(view);
+	User::LeaveIfError(view.Prepare(iDb, TDbQuery(KSQLStatement, EDbCompareNormal)));
+	User::LeaveIfError(view.EvaluateAll());
+
+	// Get column set for column ordinals
+    CDbColSet* columns = view.ColSetL();
+    TDbColNo id_col = columns->ColNo(aIdColumn);
+	TDbColNo used_col = columns->ColNo(KUsedColumn);
+	delete columns;
+
+	TUint32 id;
+	TBool used;
+	// After evaluation, the first call to NextL() is equivalent to FirstL()
+	while ( view.NextL() )
+		{
+		// Retrieve the current row
+		view.GetL();
+		// Check if this row is currently in use
+		used = view.ColInt(used_col);
+		if ( used )
+			{
+			id = view.ColUint32(id_col);
+			User::LeaveIfError(aIDs.Append(id));
+			}
+		}
+
+	// Cleanup view
+    CleanupStack::PopAndDestroy();
+    CleanupStack::Pop();
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::GetAllIDsL
+// This function returns all Ids in the specified table.
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::GetAllIDsL(
+	const TDesC& aIdTable,
+	const TDesC& aIdColumn,
+	RArray<TUint32>& aIDs )
+	{
+	CleanupClosePushL( aIDs ); 
+	
+	TBuf<100> KSQLStatement;
+	// Declare a literal string to hold the SQL statement
+	// SELECT aIdColumn FROM aIdTable WHERE KUsedColumn = KUsed
+	// ORDER BY aIdColumn
+	_LIT(KSQLSelect1, "SELECT ");
+	_LIT(KSQLSelect2, " FROM ");
+	_LIT(KSQLSelect3, " WHERE ");
+	_LIT(KSQLSelect4, " ORDER BY ");
+
+	KSQLStatement = KSQLSelect1;
+	KSQLStatement.Append(aIdColumn);
+	KSQLStatement.Append(KSQLSelect2);
+	KSQLStatement.Append(aIdTable);
+	KSQLStatement.Append(KSQLSelect3);
+	KSQLStatement.Append(KUsedColumn);
+	KSQLStatement.Append(KEqual);
+	KSQLStatement.AppendNum(KUsed);
+	KSQLStatement.Append(KSQLSelect4);
+	KSQLStatement.Append(aIdColumn);
+
+	RDbView view;
+	CleanupClosePushL(view);
+	User::LeaveIfError(view.Prepare(iDb, TDbQuery(KSQLStatement, EDbCompareNormal)));
+	User::LeaveIfError(view.EvaluateAll());
+
+	// Get column set for column ordinals
+    CDbColSet* columns = view.ColSetL();
+    TDbColNo id_col = columns->ColNo(aIdColumn);
+	delete columns;
+
+	TUint32 id;
+	// After evaluation, the first call to NextL() is equivalent to FirstL()
+	while ( view.NextL() )
+		{
+		// Retrieve the current row
+		view.GetL();
+		id = view.ColUint32(id_col);
+		User::LeaveIfError(aIDs.Append(id));
+		}
+
+	// Cleanup view
+    CleanupStack::PopAndDestroy();
+    CleanupStack::Pop(); 
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::IsValidL
+// Checks to see if aKey exists in the table and that it's set to "used".
+// -----------------------------------------------------------------------------
+//
+TBool CSICommonDB::IsValidL( const TDesC& aTableName, const TDesC& aIndex,
+                             TUint aKey )
+	{
+    RUBY_DEBUG_BLOCK( "CSICommonDB::IsValidL" );
+	RDbTable dbTable;		// Provides access to table data as a rowset
+	TBool valid = EFalse;
+
+	// Open table
+	User::LeaveIfError(dbTable.Open(iDb, aTableName, RDbTable::EReadOnly));
+	CleanupClosePushL(dbTable);
+	User::LeaveIfError(dbTable.SetIndex(aIndex));
+
+	TDbSeekKey key(aKey);
+	// Return true, if a matching row found
+	if ( dbTable.SeekL(key) )
+		{
+        RUBY_DEBUG1( "CSICommonDB::IsValidL - %d is found", aKey );
+		dbTable.GetL();
+		// Get column set for column ordinals
+		CDbColSet* columns = dbTable.ColSetL();
+		TDbColNo used_col = columns->ColNo(KUsedColumn);
+		delete columns;
+
+		// Check if this row is currently in use
+		valid = dbTable.ColInt(used_col);
+		}
+
+    // Cleanup dbTable
+    CleanupStack::PopAndDestroy();
+	return valid;
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::ReleaseIdL
+// Releases the ID by marking it as "unused".
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::ReleaseIdL(
+	const TDesC& aTableName,
+	const TDesC& aIdColumn,
+	TUint32 aId )
+	{
+	RUBY_DEBUG_BLOCKL( "CSICommonDB::ReleaseIdL" );
+    	
+	iMutex.Wait();
+	
+	TRAPD( error, DoReleaseIdL( aTableName, aIdColumn, aId ) );
+	
+	iMutex.Signal();
+	
+    User::LeaveIfError( error );
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::UpdateCounterL
+// Updates the counter value of the specified row.
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::UpdateCounterL( const TDesC& aTableName, const TDesC& aIndex,
+                                  TUint aKey, TBool aIncrement )
+	{
+    RUBY_DEBUG_BLOCK( "CSICommonDB::UpdateCounterL" );
+	RDbTable dbTable;		// Provides access to table data as a rowset
+
+	// Open table
+	User::LeaveIfError(dbTable.Open(iDb, aTableName, RDbTable::EUpdatable));
+	CleanupClosePushL(dbTable);
+	User::LeaveIfError(dbTable.SetIndex(aIndex));
+
+	TDbSeekKey key(aKey);
+	// Return true, if a matching row found
+	if ( dbTable.SeekL(key) )
+		{
+		dbTable.GetL();
+		// Get column set for column ordinals
+		CDbColSet* columns = dbTable.ColSetL();
+		TDbColNo counter_col = columns->ColNo(KCounterColumn);
+		delete columns;
+
+		TInt counter = dbTable.ColInt(counter_col);
+
+		if ( aIncrement )
+			{
+			counter++;
+			}
+		else
+			{
+			counter--;
+			}
+		// Update found row
+		dbTable.UpdateL();
+		dbTable.SetColL(counter_col, counter);
+
+		// Write the updated row
+		TRAPD(err, dbTable.PutL());
+		if( err != KErrNone )
+			{
+			// Error: cancel update
+			dbTable.Cancel();
+			dbTable.Reset();
+			User::Leave(err);
+			}
+		}
+	else
+		{
+        RUBY_DEBUG1( "CSICommonDB::UpdateCounterL - can't find key=%d", aKey );
+		User::Leave(KErrNotFound);
+		}
+
+    // Cleanup dbTable
+    CleanupStack::PopAndDestroy();
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::VerifyOwnershipL
+// Checks for data ownership.
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::VerifyOwnershipL( TUid aClientUid, const TDesC& aTableName,
+                                    const TDesC& aIndex, TUint aKey )
+	{
+    RUBY_DEBUG_BLOCK( "CSICommonDB::VerifyOwnershipL" );
+	RDbTable dbTable;		// Provides access to table data as a rowset
+
+	// Open table
+	User::LeaveIfError(dbTable.Open(iDb, aTableName, RDbTable::EReadOnly));
+	CleanupClosePushL(dbTable);
+	User::LeaveIfError(dbTable.SetIndex(aIndex));
+
+	TDbSeekKey key(aKey);
+	// Return true, if a matching row found
+	if ( dbTable.SeekL(key) )
+		{
+        RUBY_DEBUG1( "CSICommonDB::VerifyOwnershipL - %d is found", aKey );
+		dbTable.GetL();
+		// Get column set for column ordinals
+		CDbColSet* columns = dbTable.ColSetL();
+		TDbColNo client_uid_col = columns->ColNo(KClientUidColumn);
+		TDbColNo used_col = columns->ColNo(KUsedColumn);
+		delete columns;
+
+		// Check if this row is currently in use
+		TBool used = dbTable.ColInt(used_col);
+		if ( used )
+			{
+			if ( dbTable.ColInt(client_uid_col) != aClientUid.iUid )
+				{
+				User::Leave(KErrAsrDataRightViolation);
+				}
+			}
+		else
+			{
+            RUBY_DEBUG1( "CSICommonDB::VerifyOwnershipL - key=%d is unused", aKey );
+			User::Leave(KErrNotFound);
+			}
+		}
+	else
+		{
+        RUBY_DEBUG1( "CSICommonDB::VerifyOwnershipL - can't find key=%d", aKey );
+		User::Leave(KErrNotFound);
+		}
+
+    // Cleanup dbTable
+    CleanupStack::PopAndDestroy();
+	}
+
+// -----------------------------------------------------------------------------
+// CSICommonDB::DoReleaseIdL
+// Releases the ID by marking it as "unused".
+// -----------------------------------------------------------------------------
+//
+void CSICommonDB::DoReleaseIdL(
+	const TDesC& aTableName,
+	const TDesC& aIdColumn,
+	TUint32 aId )
+	{
+	TBuf<100> KSQLStatement;
+	// Declare a literal string to hold the SQL statement
+	// UPDATE aTableName SET KUsedColumn = KNotUsed WHERE aIdColumn = aId
+	_LIT(KSQLUpdate1, "UPDATE ");
+	_LIT(KSQLUpdate2, " SET ");
+	_LIT(KSQLUpdate3, " WHERE ");
+
+	KSQLStatement = KSQLUpdate1;
+	KSQLStatement.Append(aTableName);
+	KSQLStatement.Append(KSQLUpdate2);
+	KSQLStatement.Append(KUsedColumn);
+	KSQLStatement.Append(KEqual);
+	KSQLStatement.AppendNum(KNotUsed);
+	KSQLStatement.Append(KSQLUpdate3);
+	KSQLStatement.Append(aIdColumn);
+	KSQLStatement.Append(KEqual);
+	KSQLStatement.AppendNumUC(aId);
+
+	User::LeaveIfError(iDb.Execute(KSQLStatement));
+	}
+	
+// -----------------------------------------------------------------------------
+// CSICommonDB::DoCreateNewIDL
+// This function first checks to see if there is an "unused" ID.  If one is not
+// found, it creates a new row in the table for a new ID.
+// -----------------------------------------------------------------------------
+//
+TUint32 CSICommonDB::DoCreateNewIDL(
+	const TDesC& aTableName,
+	const TDesC& aIdColumn,
+	TUid aClientUid )
+	{
+	RDbTable dbTable;		// Provides access to table data as a rowset
+
+	// Open table
+	User::LeaveIfError(dbTable.Open(iDb, aTableName, RDbTable::EUpdatable));
+	CleanupClosePushL(dbTable);
+
+    // Get column set for column ordinals
+    CDbColSet* columns = dbTable.ColSetL();
+    TDbColNo id_col = columns->ColNo(aIdColumn);
+	TDbColNo uid_col = columns->ColNo(KClientUidColumn);
+    TDbColNo counter_col = columns->ColNo(KCounterColumn);
+    TDbColNo used_col = columns->ColNo(KUsedColumn);
+    delete columns;
+
+    // Is there an unused ID?
+    if( FindUnusedIDL(dbTable) )
+    	{
+		// Yes, update found row
+		dbTable.UpdateL();
+		}
+	else
+		{
+		// No, insert new row
+		dbTable.InsertL();
+		}
+
+	dbTable.SetColL(uid_col, aClientUid.iUid);
+	dbTable.SetColL(counter_col, 0);
+	dbTable.SetColL(used_col, KUsed);
+
+	// Write the updated row
+	TRAPD(err, dbTable.PutL());
+	if( err != KErrNone )
+		{
+		// Error: cancel update
+		dbTable.Cancel();
+		dbTable.Reset();
+		User::Leave(err);
+		}
+
+	TUint32 newID = dbTable.ColUint32(id_col);
+    // Cleanup dbTable
+    CleanupStack::PopAndDestroy();
+	return newID;
+	}
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicommondb.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,241 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is the baseclass for all SI Controller Plugin DB classes.
+*				It implements the common database functionalities.
+*
+*/
+
+
+#ifndef SICOMMONDB_H
+#define SICOMMONDB_H
+
+//  INCLUDES
+#include <d32dbms.h>
+#include <e32svr.h>
+#include <sysutil.h> // Critical Level check
+#include <f32file.h>
+#include "s32strm.h" // Streams
+#include "s32mem.h"  // Buffer streams
+#include "nsssispeechrecognitiondatacommon.h"
+#include "nsssispeechrecognitiondatadevasr.h"
+
+// CONSTANTS
+const TInt KSDDatabaseDrive = EDriveC;
+
+_LIT(KClientUidColumn, "clientUid");
+_LIT(KUsedColumn, "used");
+_LIT(KCounterColumn, "counter");
+
+_LIT(KOpenParen, " (");
+_LIT(KCloseParen, ")");
+_LIT(KEqual, " = ");
+_LIT(KNext, ", ");
+
+
+_LIT(KSIGrammarTable, "siGrammarTable");
+_LIT(KBinaryGrammarColumn, "BinaryGrammarId");
+_LIT(KBinaryGrammarColumnSize, "BinaryGrammarSize");
+_LIT(KGrammarIdTable, "siGrammarIdTable");
+_LIT(KGrammarIdColumn, "grammarId");
+_LIT(KGrammarIndex, "grammarIndex");
+
+_LIT(KSILexiconTable, "siLexiconTable");
+_LIT(KBinaryLexiconColumn, "BinaryLexiconId");
+_LIT(KBinaryLexiconColumnSize, "BinaryLexiconSize");
+_LIT(KLexiconIdTable, "siLexiconIdTable");
+_LIT(KLexiconIdColumn, "lexiconId");
+_LIT(KLexiconIndex, "lexiconIndex");
+
+_LIT(KSIModelBankTable, "siModelBankTable");
+_LIT(KBinaryModelBankColumn, "BinaryModelBankId");
+_LIT(KBinaryModelBankColumnSize, "BinaryModelBankSize");
+_LIT(KModelBankIdTable, "siModelBankIdTable");
+_LIT(KModelBankTable, "siModelBankTable");
+_LIT(KModelBankIdColumn, "modelBankId");
+
+_LIT(KHmmColumn, "hmm");
+_LIT(KHmmChecksumColumn, "hmmChecksum");
+_LIT(KModelBankIndex, "modelBankIndex");
+_LIT(KModelIndex, "modelIndex");
+
+const TInt KNotUsed = 0;
+const TInt KUsed = 1;
+const TSIModelID KModelID=1;
+// CLASS DECLARATION
+
+/**
+*  This class is the base class for all SI Controller Plugin DB classes.
+*  It provides the common functionality for the DB classes.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.0
+*/
+class CSICommonDB : public CBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * C++ default constructor.
+        */
+        CSICommonDB( RDbNamedDatabase& aDatabase, RDbs& aDbSession, TInt aDrive );
+
+ 		/**
+        * Destructor.
+        */
+        virtual ~CSICommonDB();
+
+    public: // New functions
+
+        /**
+        * Checks if the specified ID table exists or not.  If it doesn't exist, it creates one.
+        * @since 2.0
+        * @param	aIdTable		descriptor containing tabel name
+		* @param	aIdColumn		descriptor containing ID column name
+		* @param	aIndex			descriptor containing table index name
+        * @return	-
+        */
+		void CreateIDTableL( const TDesC& aIdTable, const TDesC& aIdColumn, const TDesC& aIndex );
+
+        /**
+        * Creates a new ID in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing table name
+		* @param	aIdColumn		descriptor containing ID column name
+		* @param	aClientUid		client Uid for data ownership
+        * @return	A new ID
+        */
+		TUint32 CreateNewIDL( const TDesC& aTableName, const TDesC& aIdColumn, TUid aClientUid );
+
+        /**
+        * Returns the counter column value after searching for the aKey in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing tabel name
+		* @param	aIndex			descriptor containing table index name
+		* @param	aKey			key to search in the table
+        * @return	Counter
+        */
+		TInt CountL( const TDesC& aTableName, const TDesC& aIndex, TUint aKey );
+
+        /**
+        * Checks if an unused Id exists in the given table.  If found, row is set to
+		* the found row.
+        * @since 2.0
+        * @param	"RDbTable& aDbTable"
+        * @return	ETrue if found
+        */
+        TBool FindUnusedIDL( RDbTable& aDbTable );
+
+        /**
+        * Returns all Ids in the specified table that belong to the specified client.
+        * @since 2.0
+        * @param	aTableName		descriptor containing table name
+		* @param	aIdColumn		descriptor containing ID column name
+        * @param	aClientUid		client's Uid for data ownership
+		* @param	aIDs			reference where Ids are stored
+        */
+		void GetAllClientIDsL( const TDesC& aIdTable, const TDesC& aIdColumn, TUid aClientUid, RArray<TUint32>& aIDs );
+
+        /**
+        * Returns all Ids in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing table name
+		* @param	aIdColumn		descriptor containing ID column name
+		* @param	aIDs			reference where Ids are stored
+        */
+		void GetAllIDsL( const TDesC& aIdTable, const TDesC& aIdColumn, RArray<TUint32>& aIDs );
+
+        /**
+        * Checks if the specified key exists in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing tabel name
+		* @param	aIndex			descriptor containing table index name
+		* @param	aKey			key to search in the table
+        * @return	ETrue if found.
+        */
+		TBool IsValidL( const TDesC& aTableName, const TDesC& aIndex, TUint aKey );
+
+        /**
+        * Sets the specified ID as unused in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing tabel name
+		* @param	aIdColumn		descriptor containing ID column name
+		* @param	aId				ID to be marked as unused
+        */
+		void ReleaseIdL( const TDesC& aTableName, const TDesC& aIdColumn, TUint32 aId );
+
+        /**
+        * Updates the counter value after finding the aKey in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing tabel name
+		* @param	aIndex			descriptor containing table index name
+		* @param	aKey			key to search in the table
+		* @param	aIncrement		Increment if ETrue, decrement otherwise.
+        */
+		void UpdateCounterL( const TDesC& aTableName, const TDesC& aIndex, TUint aKey,
+					TBool aIncrement );
+
+        /**
+        * Checks for data ownership.  Leaves with KErrAsrDataRightViolation if not
+		* owned by this client.
+        * @since 2.0
+		* @param	aClientUid		client's Uid for data ownership
+        * @param	aTableName		descriptor containing tabel name
+		* @param	aIndex			descriptor containing table index name
+		* @param	aKey			key to search in the table
+        */
+		void VerifyOwnershipL( TUid aClientUid, const TDesC& aTableName, const TDesC& aIndex,
+					TUint aKey );
+
+    public:    // Data
+
+		// Database
+        RDbNamedDatabase& iDb;
+
+        // DB session
+        RDbs& iDbSession;
+
+        // drive
+        TInt iDrive;
+        
+    private:  // New functions
+    
+        /**
+        * Creates a new ID in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing table name
+		* @param	aIdColumn		descriptor containing ID column name
+		* @param	aClientUid		client Uid for data ownership
+        * @return	A new ID
+        */
+		TUint32 DoCreateNewIDL( const TDesC& aTableName, const TDesC& aIdColumn, TUid aClientUid );
+		
+		/**
+        * Sets the specified ID as unused in the specified table.
+        * @since 2.0
+        * @param	aTableName		descriptor containing tabel name
+		* @param	aIdColumn		descriptor containing ID column name
+		* @param	aId				ID to be marked as unused
+        */
+		void DoReleaseIdL( const TDesC& aTableName, const TDesC& aIdColumn, TUint32 aId );
+		
+    private:  // Data
+    
+        // Mutex for DB write lock
+        // Makes sure that only one process gets the DB lock
+        RMutex iMutex;
+    };
+
+#endif // SICOMMONDB_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/siconsoletest.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is for unit testing purpose only.
+*
+*/
+
+
+#ifndef __CONSOLETEST__
+/* In order to build PluginConsoleTest.exe, you must uncomment the preprocessor directive
+in SIConsoleTest.h located under /SDControllerPlugin/Src/:  #define __CONSOLETEST__.  
+Once testing is complete, make sure this is commented back or plugin will not build.
+*/
+//#define __CONSOLETEST__
+
+#define __MYTEST__ //?? Here I define a test 
+
+
+#ifdef __CONSOLETEST__
+
+#include <d32dbms.h>
+#include <SpeechRecognitionDataDevASR.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicontrollerplugin.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3929 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the main implementation of the SI Controller Plugin.
+*               Finite State Machine is implemented here.
+*
+*/
+
+
+// INCLUDE FILES
+#include <mmfcodec.h>
+#include <nsssispeechrecognitiondatadevasr.h>
+
+#include <badesca.h>
+#include <mmfbase.h>
+
+#include "sicontrollerplugin.h"
+#include "sicontrollerplugininterface.h"
+#include "sidatabase.h"
+
+#include "siresourcehandler.h"
+#include "asrplugindataloader.h"
+
+#include "sigrammardb.h"
+#include "silexicondb.h"
+#include "simodelbankdb.h"
+
+#include "rubydebug.h"
+ 
+#ifdef __SINDE_TRAINING
+#include "sindetraining.h"
+#endif // __SINDE_TRAINING
+ 
+// Package types for general & language specific TTP data
+ 
+// CONSTANTS
+ 
+// Message types used in RunL
+//const TInt KAddPronunciation			= 1; // Commented out to remove "not referenced" warning
+const TInt KAddRule						= 2;
+const TInt KCreateGrammar				= 3;
+const TInt KCreateLexicon				= 4;
+const TInt KCreateModelBank				= 5;
+const TInt KGetAllClientGrammarIDs		= 6;
+const TInt KGetAllClientLexiconIDs		= 7;
+const TInt KGetAllClientModelBankIDs	= 8;
+const TInt KGetAllGrammarIDs			= 9;
+const TInt KGetAllLexiconIDs			= 10;
+const TInt KGetAllModelBankIDs			= 11;
+const TInt KGetAllModelIDs				= 12;
+const TInt KGetAllPronunciationIDs		= 13;
+const TInt KGetAllRuleIDs				= 14;
+const TInt KGetAvailableStorage			= 15;
+const TInt KGetModelCount				= 16;
+const TInt KGetRuleValidity				= 17;
+const TInt KGetUtteranceDuration		= 18;
+const TInt KLoadGrammar					= 19;
+const TInt KLoadLexicon					= 20;
+const TInt KLoadModels					= 21;
+const TInt KPlayUtterance				= 22;
+const TInt KRecognize					= 23;
+const TInt KRecord						= 24;
+const TInt KRemoveGrammar				= 25;
+const TInt KRemoveLexicon				= 26;
+const TInt KRemoveModelBank				= 27;
+const TInt KRemoveModel					= 28;
+const TInt KRemovePronunciation			= 29;
+const TInt KRemoveRule					= 30;
+const TInt KTrain						= 31;
+const TInt KUnloadRule					= 32;
+
+// SI only functionalities
+const TInt KAdapt					= 33;
+//const TInt KSIAddPronunciation				= 34; // Commented out to remove "not referenced" warning
+const TInt KAddRuleVariant				= 35;
+//const TInt KAddVoiceTag					= 36; // Commented out to remove "not referenced" warning
+const TInt KAddVoiceTags				= 37;
+const TInt KCreateRule					= 38;
+//const TInt KSIRecognize					= 39; // Commented out to remove "not referenced" warning
+const TInt KEndRecord					= 40;
+const TInt KUnloadGrammar 				= 41;
+//const TInt KUpdateGrammarAndLexicon 				= 42; // Commented out to remove "not referenced" warning
+const TInt KGetPronunciationCount				= 43;
+const TInt KGetRuleCount				= 44;
+const TInt KRemoveRules					= 45;
+ 
+//const TInt KAddSIPronunciation			= 43; // Commented out to remove "not referenced" warning
+//const TInt KAddOneSIPronunciation	= 44; // Commented out to remove "not referenced" warning
+
+#ifdef __SINDE_TRAINING
+// SINDE voice tags creation
+const TInt KAddSindeVoiceTags = 46;
+//const TInt KAddSindeVoiceTag = 47; // Commented out to remove "not referenced" warning
+#endif // __SINDE_TRAINING
+
+const TInt KPreStartSampling = 48;
+
+// Define this if SINDE lexicon optimization is on
+#define __SIND_LEXICON_OPT
+
+// Secure ID of voice commands application process
+_LIT_SECURE_ID( KVoiceCommandsAppUid, 0x101f8555 );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// Panic
+// User panic when an unrecoverable error occurs.
+// Returns: -
+// -----------------------------------------------------------------------------
+//
+void Panic( TInt aPanicCode ) // Panic code
+    {
+    _LIT( KSDControllerPanicCategory, "SIControllerPlugin" );
+    User::Panic( KSDControllerPanicCategory, aPanicCode );
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CSIControllerPlugin
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CSIControllerPlugin::CSIControllerPlugin( CSIControllerPluginInterface& aControllerIf )
+                                        : CActive( EPriorityLess ),
+                                          iState( ESiPluginIdle ),
+                                          iControllerIf( aControllerIf ),
+                                          iClientRegistered( EFalse ),  
+                                          iGrammarID( 0 ),
+                                          iDataLoader( NULL )
+    {
+    RUBY_DEBUG0( "CSIControllerPlugin::CSIControllerPlugin" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+// 
+void CSIControllerPlugin::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::ConstructL" );
+    
+    iResourceHandler = CSIResourceHandler::NewL();
+    
+    //  Data loader
+    iDataLoader = CDataLoader::NewL( *(iResourceHandler->iDataFilenamePrefix), 
+        *(iResourceHandler->iDataFilenameSeperator),
+        *(iResourceHandler->iDataFilenamePostfix ) );
+    
+    TFileName dbFileName( *(iResourceHandler->iDbFileName ));
+    
+    // Database instances
+    iSIDatabase = CSIDatabase::NewL( dbFileName );
+    RDbNamedDatabase& database = iSIDatabase->SIDatabase();
+    RDbs& dbSession = iSIDatabase->DbSession();
+    TInt drive = iSIDatabase->DbDrive();
+    iSIGrammarDB = CSIGrammarDB::NewL( database, dbSession, drive );
+    iSILexiconDB = CSILexiconDB::NewL( database, dbSession, drive );
+    iSIModelBankDB = CSIModelBankDB::NewL( database, dbSession, drive );
+
+    iSIDatabase->BeginTransactionL();    
+    
+    if ( !( iSIDatabase->DoesLockTableExistL() ) )
+        {
+        iSIDatabase->CreateLockTableL();
+        }
+
+    // Need to create all 3 ID tables at single transaction
+
+
+    // Create tables if they don't already exist    
+    if ( !( iSIDatabase->DoesModelBankTableExistL() ) )
+        { 
+        iSIModelBankDB->CreateIDTableL();
+        }
+
+    if ( !( iSIDatabase->DoesLexiconTableExistL() ) )
+        { 
+        iSILexiconDB->CreateIDTableL();
+        }
+
+    if ( !( iSIDatabase->DoesGrammarTableExistL() ) )
+        { 
+        iSIGrammarDB->CreateIDTableL();
+        }
+
+    iSIDatabase->CommitChangesL( ETrue );
+
+
+    iSITtpWordList = CSITtpWordList::NewL();
+    
+    iDevASR = CDevASR::NewL( *this );
+    
+    RUBY_DEBUG2( "[%d] CSIControllerPlugin::ConstructL - DevASR[%d]", this, iDevASR );
+    
+#ifdef __SINDE_TRAINING 		
+    iSindeTrainer = CSindeTrainer::NewL( *iDevASR, iControllerIf, *this, 
+                                         *iSIDatabase, *iSIGrammarDB, *iSILexiconDB );
+#endif // __SINDE_TRAINING    
+    
+    // Add active object to active scheduler
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIControllerPlugin* CSIControllerPlugin::NewL( CSIControllerPluginInterface& aControllerIf )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::NewL" );
+    CSIControllerPlugin* self = new( ELeave ) CSIControllerPlugin( aControllerIf );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::~CSIControllerPlugin
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSIControllerPlugin::~CSIControllerPlugin()
+    {
+	RUBY_DEBUG0( "CSIControllerPlugin::~CSIControllerPlugin" );
+
+    RThread().SetPriority( EPriorityNormal );
+
+    Cancel();
+    
+    // if there is any outstanding request, cancel it.
+    if ( iDevASR )
+        {
+        iDevASR->Cancel();
+        }
+    
+    delete iDevASR;
+    delete iResourceHandler;
+    delete iSIGrammarDB;
+    delete iSILexiconDB; // Handled by Grcompiler
+    delete iSIModelBankDB;	
+    delete iDataLoader;
+    
+    delete iSIDatabase;
+    delete iSICompiledGrammarRecompile;
+    
+	iMaxNPronunsForWord.Close();
+    delete iSITtpWordList;
+    
+#ifdef __SINDE_TRAINING 		
+    delete iSindeTrainer;
+#endif // __SINDE_TRAINING
+
+    if ( iTrainArrays != NULL )
+        {
+        iTrainArrays->ResetAndDestroy();
+        iTrainArrays->Close();
+        delete iTrainArrays;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddPronunciationL
+// Calls the lexicon database handler to add a new pronunciation into the lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::AddPronunciationL( TSILexiconID /*aLexiconID*/,
+                                             TSIModelBankID /*aModelBankID*/,
+                                             const TDesC8& /*aPronunciationPr*/,
+                                             TSIPronunciationID& /*aPronunciationID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddPronunciationL 1" );
+    User::Leave( KErrNotSupported );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddPronunciationL
+// Calls the lexicon database handler to add a new pronunciation into the lexicon.
+// -----------------------------------------------------------------------------
+// 
+void CSIControllerPlugin::AddPronunciationL( TSILexiconID /*aLexiconID*/,
+                                             TSIModelBankID /*aModelBankID*/,
+                                             TSIModelID /*aModelID*/, 
+                                             TSIPronunciationID& /*aPronunciationID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddPronunciationL 2" );
+    User::Leave( KErrNotSupported );	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::SDLexiconL
+// -----------------------------------------------------------------------------
+//   
+#ifdef DEVASR_KEEP_SD
+CSDLexicon* CSIControllerPlugin::SDLexiconL( TSILexiconID anID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::SDLexiconL" );
+    
+    User::Leave( KErrNotSupported );
+    return NULL;	
+    }
+#endif
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddRuleL
+// Calls the grammar database handler to add a new rule into the grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::AddRuleL( TSIGrammarID aGrammarID,
+                                    TSILexiconID aLexiconID,
+                                    TSIPronunciationID aPronunciationID,
+                                    TSIRuleID& aRuleID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddRuleL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KAddRule;
+    iGrammarID = aGrammarID;
+    iLexiconID = aLexiconID;
+    iPronunciationID = aPronunciationID;
+    iRuleIDPtr = &aRuleID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleAddRule
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleAddRuleL( TSIGrammarID /*aGrammarID*/,
+                                          TSILexiconID /*aLexiconID*/,
+                                          TSIPronunciationID /*aPronunciationID*/,
+                                          TSIRuleID& /*aRuleID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleAddRuleL" );
+    
+    User::Leave( KErrNotSupported ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::Cancel
+// Cancels the current activity and returns the plugin to Idle state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::Cancel()
+    {
+    RUBY_DEBUG1( "CSIControllerPlugin::Cancel (State=%d)", iState );
+    
+    this->iSIDatabase->Rollback();
+    switch ( iState )
+        {
+        case ESdPluginTrain:
+            iDevASR->Cancel();
+            
+            TRAP_IGNORE( 
+                iSIDatabase->BeginTransactionL();
+                iSIModelBankDB->Reset();
+                iSIDatabase->CommitChangesL( ETrue );
+                ); // TRAP_IGNORE
+               
+            break;
+            
+        case ESiPluginRecognize:
+            iDevASR->Cancel();
+            iState = ESiPluginRecognize; 	
+            break;
+        case ESiPluginTrainText:
+#ifdef __SINDE_TRAINING
+        case ESiPluginTrainSinde:
+#endif // __SINDE_TRAINING
+            iDevASR->Cancel();
+            iState = ESiPluginIdle; 	
+            break;
+        case ESiPluginPlay:
+            iDevASR->Cancel();
+            break;
+            
+        case ESiPluginIdle:
+            // Nothing to cancel
+            break;
+            
+        default:
+            // Unknown state - should never be here
+            break;
+        }
+    
+    // Cancel the active object
+    CActive::Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CommitChangesL
+// Commits (saves) all database changes since the last commit request.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::CommitChangesL( TBool aCommit )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::CommitChangesL" );
+    iSIDatabase->CommitChangesL( aCommit );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CreateGrammarL
+// Calls the grammar database handler to create a new grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::CreateGrammarL( TSIGrammarID& aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::CreateGrammarL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KCreateGrammar;
+    iGrammarIDPtr = &aGrammarID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleCreateGrammarL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleCreateGrammarL( TSIGrammarID& aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleCreateGrammarL" );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        
+        // update model banks if they are not valid anymore
+        RArray<TSIModelBankID> modelBankIDs;
+        CleanupClosePushL( modelBankIDs );
+        iSIModelBankDB->GetAllClientModelBankIDsL( iClientUid, modelBankIDs );
+        for ( TInt i(0); i < modelBankIDs.Count(); i++ )
+            {
+            iSIModelBankDB->UpdateModelBankIfInvalidL( modelBankIDs[i] );
+            }
+        CleanupStack::PopAndDestroy( &modelBankIDs );
+        aGrammarID = iSIGrammarDB->CreateGrammarL(iClientUid);
+        iSIDatabase->CommitChangesL( ETrue );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CreateLexiconL
+// Calls the lexicon database handler to create a new lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::CreateLexiconL( TSILexiconID& aLexiconID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::CreateLexiconL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KCreateLexicon;
+    iLexiconIDPtr = &aLexiconID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleCreateLexiconL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleCreateLexiconL( TSILexiconID& aLexiconID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleCreateLexiconL");
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        aLexiconID = iSILexiconDB->CreateLexiconL(iClientUid);
+        iSIDatabase->CommitChangesL( ETrue );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CreateModelBankL
+// Calls the model database handler to create a new model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::CreateModelBankL( TSIModelBankID& aModelBankID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::CreateModelBankL");
+    
+    if ( IsActive() )
+        {
+        User::Leave(KErrServerBusy);
+        }
+    iRequestFunction = KCreateModelBank;
+    iModelBankIDPtr = &aModelBankID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleCreateModelBankL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleCreateModelBankL( TSIModelBankID& aModelBankID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleCreateModelBankL");
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        aModelBankID = iSIModelBankDB->CreateModelBankL(iClientUid);
+        iSIDatabase->CommitChangesL( ETrue ); 
+        }
+    else
+        {
+        User::Leave(KErrAsrNotRegisted);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::EndRecSessionL
+// Ends recognition session and releases resources.  If not in recognition state,
+// no action is taken.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::EndRecSessionL()
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::EndRecSessionL");
+    
+    switch ( iState )
+        {
+        case ESiPluginRecognize:
+            iDevASR->EndRecSession();
+            // Save the changes during model adaption.
+            iSIDatabase->CommitChangesL( ETrue );  
+            RecognitionReset();
+            break;
+        case ESiPluginIdle:
+            // Ignore if already Idle
+            break;
+        default:
+            // Wrong state
+            User::Leave( KErrNotReady );
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::ActivateGrammarL
+// Activate the grammar for the recognition
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::ActivateGrammarL( TSIGrammarID aGrammarID ) 
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::ActivateGrammarL");
+    iDevASR->ActivateGrammarL(aGrammarID);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::DeactivateGrammarL
+// Deactivate the grammar for the recognition 
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::DeactivateGrammarL(TSIGrammarID aGrammarID ) 
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::DeactivateGrammarL");
+    iDevASR->DeactivateGrammarL(aGrammarID);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllClientGrammarIDsL
+// Returns all grammar Ids that belong to the current client.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllClientGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAllClientGrammarIDsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllClientGrammarIDs;
+    
+    iGrammarIDs = &aGrammarIDs;
+    
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllClientGrammarIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllClientGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAllClientGrammarIDsL");
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSIGrammarDB->GetAllClientGrammarIDsL(iClientUid, aGrammarIDs);
+        iSIDatabase->CommitChangesL( EFalse );
+        
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllClientLexiconIDsL
+// Returns all lexicon Ids that belong to the current client.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllClientLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAllClientLexiconIDsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllClientLexiconIDs;
+    iLexiconIDs = &aLexiconIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllClientLexiconIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllClientLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleGetAllClientLexiconIDsL" );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSILexiconDB->GetAllClientLexiconIDsL( iClientUid, aLexiconIDs );		
+        iSIDatabase->CommitChangesL( EFalse );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllClientModelBankIDsL
+// Returns all model bank Ids that belong to the current client.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllClientModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAllClientModelBankIDsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllClientModelBankIDs;
+    iModelBankIDs = &aModelBankIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllClientModelBankIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllClientModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleGetAllClientModelBankIDsL" );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSIModelBankDB->GetAllClientModelBankIDsL( iClientUid, aModelBankIDs );
+        iSIDatabase->CommitChangesL( EFalse );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllGrammarIDsL
+// Returns all grammar Ids that exist (for all clients).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetAllGrammarIDsL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllGrammarIDs;
+    iGrammarIDs = &aGrammarIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllGrammarIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAllGrammarIDsL");
+    
+    iSIDatabase->BeginTransactionL();
+    iSIGrammarDB->GetAllGrammarIDsL(aGrammarIDs);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllLexiconIDsL
+// Returns all lexicon Ids that exist (for all clients).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAllLexiconIDsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllLexiconIDs;
+    iLexiconIDs = &aLexiconIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllLexiconIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAllLexiconIDsL");
+    
+    iSIDatabase->BeginTransactionL();
+    iSILexiconDB->GetAllLexiconIDsL(aLexiconIDs);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllModelBankIDsL
+// Returns all model bank Ids that exist (for all clients).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetAllModelBankIDsL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllModelBankIDs;
+    iModelBankIDs = &aModelBankIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllModelBankIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAllModelBankIDsL");
+    
+    iSIDatabase->BeginTransactionL();
+    iSIModelBankDB->GetAllModelBankIDsL( aModelBankIDs );
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllModelIDsL
+// Calls the model database handler to get all model IDs in the model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllModelIDsL( TSIModelBankID aModelBankID,
+                                           RArray<TSIModelID>& aModelIDs )
+    { 
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetAllModelIDsL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllModelIDs;
+    iModelBankID = aModelBankID;
+    iModelIDs = &aModelIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllModelIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllModelIDsL( TSIModelBankID aModelBankID,
+                                                 RArray<TSIModelID>& aModelIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleGetAllModelIDsL" );
+    
+    iSIDatabase->BeginTransactionL();
+    iSIModelBankDB->GetAllModelIDsL(aModelBankID, aModelIDs);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllPronunciationIDsL
+// Calls the lexicon database handler to get all pronunciation IDs in the lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllPronunciationIDsL( TSILexiconID aLexiconID,
+                                                  RArray<TSIPronunciationID>& aPronunciationIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAllPronunciationIDsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllPronunciationIDs;
+    iLexiconID = aLexiconID;
+    iPronunciationIDs = &aPronunciationIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllPronunciationIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllPronunciationIDsL( TSILexiconID aLexiconID,
+                                                         RArray<TSIPronunciationID>& aPronunciationIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAllPronunciationIDsL");
+    
+    iSIDatabase->BeginTransactionL();
+    iSILexiconDB->GetAllPronunciationIDsL(aLexiconID, aPronunciationIDs);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAllRuleIDsL
+// Calls the grammar database handler to get all rule IDs in the grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAllRuleIDsL( TSIGrammarID aGrammarID,
+                                          RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAllRuleIDsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAllRuleIDs;
+    iGrammarID = aGrammarID;
+    iRuleIDs = &aRuleIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAllRuleIDsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAllRuleIDsL( TSIGrammarID aGrammarID,
+                                                RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAllRuleIDsL");
+    
+    iSIDatabase->BeginTransactionL();
+    iSIGrammarDB->GetAllRuleIDsL(aGrammarID, aRuleIDs);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetAvailableStorageL
+// Calculates the available number of models that can be trained by subtracting
+// the current total from the system defined max.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetAvailableStorageL( TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetAvailableStorageL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetAvailableStorage;
+    iCountPtr = &aCount;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetAvailableStorageL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetAvailableStorageL( TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetAvailableStorageL");
+    
+    iSIDatabase->BeginTransactionL();
+    TInt count = iSIModelBankDB->AllModelCountL();
+    iSIDatabase->CommitChangesL( EFalse );
+    
+    if ( count > iResourceHandler->iMaxModelsSystem )
+        {
+        aCount = 0;
+        }
+    else
+        {
+        aCount = iResourceHandler->iMaxModelsSystem - count;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetEnginePropertiesL
+// Returns the current recognition engine properties.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+                                                RArray<TInt>& aPropertyValue )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetEnginePropertiesL" );
+    
+    for ( TInt index = 0; index < aPropertyId.Count(); index++ )
+        {
+        switch( aPropertyId[index] )
+            {
+            case KModelStorageCapacity:
+                aPropertyValue.Append( iResourceHandler->iMaxModelsSystem );
+                break;
+                
+            case KMaxLoadableModels:
+                aPropertyValue.Append( iResourceHandler->iMaxModelsPerBank );
+                break;
+                
+            default:
+                aPropertyValue.Append( KErrNotSupported );
+                break;
+            }
+        }
+    
+    iDevASR->GetEnginePropertiesL( aPropertyId, aPropertyValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetModelCountL
+// Calls the model database handler for the number of models in a model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetModelCountL( TSIModelBankID aModelBankID,
+                                          TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetModelCountL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetModelCount;
+    iModelBankID = aModelBankID;
+    iCountPtr = &aCount;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetModelCountL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetModelCountL( TSIModelBankID aModelBankID,
+                                                TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleGetModelCountL" );
+    
+    iSIDatabase->BeginTransactionL();
+    aCount = iSIModelBankDB->ModelCountL( aModelBankID );
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetPronunciationCountL
+// Calls the model database handler for the number of Pronunciation  in a lexicon
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetPronunciationCountL( TSILexiconID aLexiconID,
+                                                  TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetPronunciationCountL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetPronunciationCount;
+    iLexiconID = aLexiconID;
+    iCountPtr = &aCount;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetPronunciationCountL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetPronunciationCountL( TSIModelBankID aLexiconID,
+                                                        TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleGetPronunciationCountL" );
+    
+    iSIDatabase->BeginTransactionL();
+    aCount = iSILexiconDB->PronunciationCountL( aLexiconID );
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetRuleCountL
+// Calls the model database handler for the number of Pronunciation  in a lexicon
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetRuleCountL( TSIGrammarID aGrammarID,
+                                         TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetRuleCountL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetRuleCount;
+    iGrammarID = aGrammarID;
+    iCountPtr = &aCount;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetRuleCountL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetRuleCountL( TSIGrammarID aGrammarID,
+                                               TInt& aCount )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetRuleCountL");
+    
+    iSIDatabase->BeginTransactionL();
+    aCount = iSIGrammarDB->RuleCountL(aGrammarID);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetRuleValidityL
+// Calls the grammar database handler to see if the rule exists in the specified
+// grammar.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetRuleValidityL( TSIGrammarID aGrammarID,
+                                            TSIRuleID aRuleID,
+                                            TBool& aValid )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::GetRuleValidityL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetRuleValidity;
+    iGrammarID = aGrammarID;
+    iRuleID = aRuleID;
+    iValidPtr = &aValid;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetRuleValidityL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetRuleValidityL( TSIGrammarID aGrammarID,
+                                                  TSIRuleID aRuleID,
+                                                  TBool& aValid )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleGetRuleValidityL");
+    
+    iSIDatabase->BeginTransactionL();
+    aValid = iSIGrammarDB->IsRuleValidL(aGrammarID, aRuleID);
+    iSIDatabase->CommitChangesL( EFalse );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::GetUtteranceDurationL
+// Calls the model database handler to get the duration of an utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::GetUtteranceDurationL( TSIModelBankID aModelBankID,
+                                                 TSIModelID aModelID,
+                                                 TTimeIntervalMicroSeconds32& aDuration )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::GetUtteranceDurationL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KGetUtteranceDuration;
+    iModelBankID = aModelBankID;
+    iModelID = aModelID;
+    iDurationPtr = &aDuration;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleGetUtteranceDurationL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleGetUtteranceDurationL( TSIModelBankID /*aModelBankID*/,
+                                                       TSIModelID /*aModelID*/,
+                                                       TTimeIntervalMicroSeconds32& /*aDuration*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleGetUtteranceDurationL" );
+    User::Leave( KErrNotSupported );		
+    }
+
+
+ // -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandlePlayUtteranceL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandlePlayUtteranceL( TSIModelBankID /*aModelBankID*/,
+                                                TSIModelID /*aModelID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandlePlayUtteranceL" );
+    User::Leave( KErrNotSupported );		 
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::LoadEngineParametersL
+// Loads the specified recognizer parameter(s).  These parameters are used to
+// alter the recognizer's default parameters.  The parameters are specified as
+// attribute and value pairs.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::LoadEngineParametersL( const RArray<TInt>& aParameterId,
+                                                 const RArray<TInt>& aParameterValue )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::LoadEngineParametersL" );
+    iDevASR->LoadEngineParametersL( aParameterId, aParameterValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::LoadGrammarL
+// Requests the grammar database handler for a grammar object to be loaded into
+// the recognizer for recognition purpose.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::LoadGrammarL( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::LoadGrammarL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        } 
+    
+    iRequestFunction = KLoadGrammar;
+    iGrammarID = aGrammarID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleLoadGrammarL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleLoadGrammarL( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleLoadGrammarL" );
+    
+    if ( iState == ESiPluginRecognize )
+        {
+        const CSICompiledGrammar* grammar = NULL;
+        // iGrammarDB keeps a reference to the grammar object so we don't
+        // have to push it onto a cleanupstack.
+        
+        iSIDatabase->BeginTransactionL();
+        grammar = iSIGrammarDB->LoadGrammarL(aGrammarID);
+        iSIDatabase->CommitChangesL( EFalse );
+        
+        iDevASR->LoadGrammar( *grammar );
+        }
+    else
+        {
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::LoadLexiconL
+// Requests the lexicon database handler for a lexicon object to be loaded into
+// the recognizer for recognition purpose.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::LoadLexiconL( TSILexiconID aLexiconID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::LoadLexiconL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KLoadLexicon;
+    iLexiconID = aLexiconID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleLoadLexiconL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleLoadLexiconL( TSILexiconID aLexiconID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleLoadLexiconL" );
+    
+    if ( iState == ESiPluginRecognize )
+        {
+        const CSILexicon* lexicon = NULL;
+        // iGrammarDB keeps a reference to the grammar object so we don't
+        // have to push it onto a cleanupstack.
+        
+        iSIDatabase->BeginTransactionL();
+        lexicon = iSILexiconDB->LexiconL( aLexiconID );
+        iSIDatabase->CommitChangesL( EFalse );
+        
+        iDevASR->LoadLexicon( *lexicon );
+        }
+    else
+        {
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::LoadModelsL
+// Requests the model database handler for a model bank object to be loaded into
+// the recognizer for recognition purpose.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::LoadModelsL( TSIModelBankID aModelBankID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::LoadModelsL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KLoadModels;
+    iModelBankID = aModelBankID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleLoadModelsL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleLoadModelsL( TSIModelBankID aModelBankID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleLoadModelsL" );
+    
+    if ( iState == ESiPluginRecognize )
+        { 
+        
+        const CSIModelBank* modelBank = NULL;
+        // iModelBankDB keeps a reference to the modelBank object so we don't
+        // have to push it onto a cleanupstack.
+        iSIDatabase->BeginTransactionL();
+        modelBank = iSIModelBankDB->AllAcousticModelsL( aModelBankID );
+        iSIDatabase->CommitChangesL( EFalse );
+        
+        iDevASR->LoadModels( *modelBank );
+        
+        }
+    else
+        {
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::PlayUtteranceL
+// Plays the user utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::PlayUtteranceL( TSIModelBankID aModelBankID,
+                                         TSIModelID aModelID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::PlayUtteranceL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KPlayUtterance;
+    iModelBankID = aModelBankID;
+    iModelID = aModelID;
+    DoAsynch();
+    }
+ 
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RecognizeL
+// Initiates recognition towards the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RecognizeL( CSDClientResultSet& /*aClientResultSet*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RecognizeL(sd)" );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RecognizeL
+// Initiates recognition towards the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RecognizeL( CSIClientResultSet& aResultSet )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::RecognizeL(si)");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRecognize ;
+    
+    iSIClientResultSet=&aResultSet;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRecognizeL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRecognizeL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleRecognizeL" );
+    
+    if ( iState == ESiPluginRecognize )
+        { 
+        iSIDatabase->BeginTransactionL();
+        
+        if ( iSIGrammarDB->IsGrammarLoaded() )			
+            {			 
+            // ClientResultSet was already saved by RunL 	 
+            iSIResultSet = &( iSIClientResultSet->SIResultSet() );
+            iDevASR->InitRecognizerBE( *iSIResultSet );
+            }
+        else
+            {
+            // Either the loaded grammars are empty (contains no rule) or
+            // all rules have been unloaded.  No need to proceed any further.
+            iSIDatabase->CommitChangesL( ETrue );
+            User::Leave( KErrNotReady );
+            }
+        
+        iSIDatabase->CommitChangesL( ETrue );
+        }
+    else
+        {
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RecordL
+// Initiates recording of user utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RecordL( TTimeIntervalMicroSeconds32 aRecordTime )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RecordL" );
+    
+    RUBY_DEBUG0( "CSIControllerPlugin::RecognizeL Returning thread priority back to normal" );
+    // the priority was lowered in the StartRecSessionL as a quick fix (voice ui 
+    // tone player had too low priority to run. Toi minimize the poorly tested
+    // consequences of the quick-fix, we return priority back to normal
+    // as soon as possible
+ 
+// Temporary fix that makes voiceui work in wk36-> sdks
+//   RThread().SetPriority( EPriorityNormal );
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRecord;
+    iRecordTime = aRecordTime;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRecordL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRecordL( TTimeIntervalMicroSeconds32 aRecordTime )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleRecordL");
+    
+    if ( iState == ESdPluginTrain || iState == ESiPluginRecognize )
+        {
+        iDevASR->Record(aRecordTime);
+        }
+    else
+        {
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::PreStartSamplingL
+// Pre-starts sampling before recognition start.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::PreStartSamplingL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KPreStartSampling;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandlePreStartSamplingL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandlePreStartSamplingL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    iDevASR->PreStartSamplingL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemoveGrammarL
+// Calls the grammar database handler to remove a grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemoveGrammarL( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemoveGrammarL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRemoveGrammar;
+    iGrammarID = aGrammarID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemoveGrammarL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemoveGrammarL( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleRemoveGrammarL");
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSIGrammarDB->RemoveGrammarL( iClientUid, aGrammarID );
+        iSIDatabase->CommitChangesL( ETrue ) ;  
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemoveLexiconL
+// Calls the lexicon database handler to remove a lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemoveLexiconL( TSILexiconID aLexiconID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemoveLexiconL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRemoveLexicon;
+    iLexiconID = aLexiconID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemoveLexiconL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemoveLexiconL( TSILexiconID aLexiconID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleRemoveLexiconL");
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSILexiconDB->RemoveLexiconL( iClientUid, aLexiconID );		
+        iSIDatabase->CommitChangesL( ETrue ) ;  
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemoveModelBankL
+// Calls the model database handler to remove a model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemoveModelBankL( TSIModelBankID aModelBankID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemoveModelBankL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRemoveModelBank;
+    iModelBankID = aModelBankID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemoveModelBankL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemoveModelBankL( TSIModelBankID aModelBankID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleRemoveModelBankL" );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSIModelBankDB->RemoveModelBankL( iClientUid, aModelBankID );
+        iSIDatabase->CommitChangesL( ETrue ) ;  
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemoveModelL
+// Calls the model database handler to remove a model from a model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemoveModelL( TSIModelBankID aModelBankID,
+                                        TSIModelID aModelID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemoveModelL" );
+    
+    if ( IsActive() )
+        {
+        
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRemoveModel;
+    iModelBankID = aModelBankID;
+    iModelID = aModelID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemoveModelL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemoveModelL( TSIModelBankID /*aModelBankID*/,
+                                              TSIModelID /*aModelID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleRemoveModelL" );
+    User::Leave( KErrNotSupported );  
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemovePronunciationL
+// Calls the lexicon database handler to remove a pronunciation from a lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemovePronunciationL( TSILexiconID aLexiconID,
+                                                TSIPronunciationID aPronunciationID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemovePronunciationL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KRemovePronunciation;
+    iLexiconID = aLexiconID;
+    iPronunciationID = aPronunciationID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemovePronunciationL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemovePronunciationL( TSILexiconID aLexiconID,
+                                                      TSIPronunciationID aPronunciationID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleRemovePronunciationL" );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSILexiconDB->RemovePronunciationL( iClientUid, aLexiconID, aPronunciationID );
+        iSIDatabase->CommitChangesL( ETrue ) ; 
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemoveRuleL
+// Calls the grammar database handler to remove a rule from a grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemoveRuleL( TSIGrammarID aGrammarID,
+                                       TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemoveRuleL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iState=ESiPluginRemoveRule;  // handled by database modify function 
+    iRequestFunction = KRemoveRule;
+    iGrammarID = aGrammarID;
+    iRuleID = aRuleID;
+    DoAsynch();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemoveRuleL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemoveRuleL( TSIGrammarID aGrammarID,
+                                             TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleRemoveRuleL" );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        
+        iSICompiledGrammarRecompile = ( CSICompiledGrammar* )iSIGrammarDB->GrammarL( aGrammarID );	
+        // if leave as KErrArgument
+        
+        CSIRule* aRule = &iSICompiledGrammarRecompile->AtL( iSICompiledGrammarRecompile->Find( aRuleID ) );
+        
+        
+        // in a rule , all the variant have same lexicon ID, that is because 
+        // the way it was added in addvoicetags()
+        CSIRuleVariant* rv = &aRule->AtL( 0 );	
+        TSILexiconID lexiconId = rv->LexiconID();	
+        
+        TSIPronunciationIDSequence pronunciationIdSequence;	
+        CleanupClosePushL( pronunciationIdSequence );
+        
+        CSILexicon* lexicon = iSILexiconDB->LexiconL( lexiconId );	
+        CleanupStack::PushL( lexicon ); 
+        
+        for ( TInt i = 0; i < aRule->Count(); i++ )
+            {
+            pronunciationIdSequence.Reset();
+            CSIRuleVariant* rv = &aRule->AtL( i );
+            rv->GetPronunciationIDsL( pronunciationIdSequence );
+            for ( TInt k = 0; k < pronunciationIdSequence.Count(); k++ )
+                {
+                lexicon->DeleteL( pronunciationIdSequence[k] );		
+                }
+            }
+            
+        // Update the lexicon
+        iSILexiconDB->UpdateLexiconL( iClientUid, lexicon );
+        
+        CleanupStack::PopAndDestroy( lexicon );
+        CleanupStack::PopAndDestroy( &pronunciationIdSequence ); 
+        
+        
+        // Recompile the grammar after a deletion
+        // Async call, callback handled in handleeventtp
+        
+        iSICompiledGrammarRecompile->DeleteL( aRuleID );
+        if ( iSICompiledGrammarRecompile->Count() == 0 )
+            {
+            // Reset compiled data to null
+            iSICompiledGrammarRecompile->SetCompiledData( NULL );
+            delete iSICompiledGrammarRecompile;
+            iSICompiledGrammarRecompile = NULL;
+            // Special case, do the callback now since we're not expecting
+            // anything from the lower layers
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveRule, iResult );
+            }
+        else
+            {
+            iDevASR->CompileGrammarL( *iSICompiledGrammarRecompile );
+            }
+        
+        iSIDatabase->CommitChangesL( ETrue );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RemoveRulesL
+// Calls the grammar database handler to remove a set of rules from a grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RemoveRulesL( TSIGrammarID aGrammarID,
+                                        RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RemoveRulesL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iState=ESiPluginRemoveRules;  // handled by database modify function 
+    iRequestFunction = KRemoveRules;
+    iGrammarID = aGrammarID;
+    iRuleIDs = &aRuleIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleRemoveRulesL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// (other items were commented in a header).
+// Note, that request to remove a non-existing rule completes successfully
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleRemoveRulesL( TSIGrammarID aGrammarID,
+                                              RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleRemoveRulesL" );
+    TInt i( 0 );
+
+    RUBY_DEBUG1( "CSIControllerPlugin::HandleRemoveRulesL grammarId [%d]", aGrammarID );
+    RUBY_DEBUG1( "CSIControllerPlugin::HandleRemoveRulesL aRuleIDs.Count() = [%d]", aRuleIDs.Count() );
+    
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        
+        // 1.Get the lexion id 
+        // 2. For each rule, delete it's varant's prounication from lexicon and then delete the rule from grammar
+        // 3. Update lexicon DB.
+        // 4. Recompile the grammar
+        // Get the grammar ,use all rules, so it clean up when iSIGrammarDB is deleted	
+        RUBY_DEBUG1( "CSIControllerPlugin::HandleRemoveRulesL Getting All rules for grammarID [%d]", aGrammarID );
+        
+        iSICompiledGrammarRecompile = ( CSICompiledGrammar* )iSIGrammarDB->GrammarL( aGrammarID );	
+        __UHEAP_MARK;		
+        RPointerArray<CSILexicon> aLexiconArray;
+        CleanupClosePushL( aLexiconArray );
+        RArray<TSILexiconID> aLexiconIDs;
+        CleanupClosePushL( aLexiconIDs );
+        CSILexicon* aLexicon;
+        
+        // if leave as KErrArgument
+        for ( i = 0; i < aRuleIDs.Count(); i++ ) 
+            {		
+            TSIRuleID aRuleID = aRuleIDs[i];
+            TInt removeRuleIndex = iSICompiledGrammarRecompile->Find( aRuleID );
+            CSIRule* aRule = NULL;  // rule to remove
+            if ( removeRuleIndex == KErrNotFound ) 
+                {
+                RUBY_DEBUG1("CSIControllerPlugin::HandleRemoveRulesL RuleID [%d] not found. Probably already deleted", aRuleID );
+                // Nothing to delete in this round.
+                // Proceed to the next one
+                continue;
+                }
+            else if ( removeRuleIndex >= 0 ) 
+                {
+                aRule = &iSICompiledGrammarRecompile->AtL( removeRuleIndex );
+                }
+            else 
+                {
+                // Unknown error
+                User::Leave( removeRuleIndex );
+                }
+            // in a rule , all the variant have same lexicon ID, 
+            // and all the rule's rule variant have same lexicon ID,
+            // one lexicon corresponding to one grammar
+            // that is because  the way it was added in addvoicetags()			
+            CSIRuleVariant* aRv = &aRule->AtL( 0 );	
+            TSILexiconID aLexiconID = aRv->LexiconID();	
+            
+            // This hack ensures 4 byte alignment in winscw
+            TSILexiconID* lexID = new ( ELeave ) TSILexiconID;
+            CleanupStack::PushL( lexID );
+            *lexID = aRv->LexiconID();       
+            // Uniq ids array
+            aLexiconIDs.InsertInSignedKeyOrder( *lexID );
+            CleanupStack::PopAndDestroy( lexID );
+            }	
+        // collect the lexicon according to the uniq lexicon array
+        for ( i = 0; i < aLexiconIDs.Count(); i++ ) 
+            {	
+            aLexicon = iSILexiconDB->LexiconL( aLexiconIDs[i] );				
+            aLexiconArray.Append( aLexicon );
+            }
+        
+        for ( i = 0; i < aRuleIDs.Count(); i++ ) 
+            {
+            TSIRuleID aRuleID = aRuleIDs[i];
+            
+            TInt removeRuleIndex = iSICompiledGrammarRecompile->Find( aRuleID );
+            CSIRule* aRule = NULL;  // rule to remove
+            if ( removeRuleIndex == KErrNotFound ) 
+                {
+                RUBY_DEBUG1("CSIControllerPlugin::HandleRemoveRulesL RuleID [%d] not found. Probably already deleted", aRuleID );
+                // Nothing to delete in this round.
+                // Proceed to the next one
+                continue;
+                }
+            else if ( removeRuleIndex >= 0 ) 
+                {
+                aRule = &iSICompiledGrammarRecompile->AtL( removeRuleIndex );
+                }
+            else 
+                {
+                // Unknown error
+                User::Leave( removeRuleIndex );
+                }
+            
+            // in a rule , all the variant have same lexicon ID, that is because 
+            // the way it was added in addvoicetags()
+            
+            TSIPronunciationIDSequence aIPronunciationIDSequence;	
+            CleanupClosePushL( aIPronunciationIDSequence );
+            
+            for ( TInt i = 0 ; i < aRule->Count() ; i++ ) 
+                {
+                aIPronunciationIDSequence.Reset();
+                CSIRuleVariant* aRv = &aRule->AtL( i );
+                aRv->GetPronunciationIDsL( aIPronunciationIDSequence );
+                TSILexiconID aLexiconID = aRv->LexiconID();
+                TInt aLocation = 0;
+                for ( TInt s = 0 ; s < aLexiconIDs.Count() ; s++ ) 
+                    {
+                    if ( aLexiconIDs[s] == aLexiconID ) 
+                        {
+                        aLocation = s;
+                        break;
+                        }
+                    }
+                
+                CSILexicon* aLexicon =aLexiconArray[aLocation];
+                for ( TInt k = 0 ; k < aIPronunciationIDSequence.Count() ; k++ ) 
+                    {
+                    aLexicon->DeleteL( aIPronunciationIDSequence[k] );
+                    }
+                }
+            
+            // delete aIPronunciationIDSequence
+            CleanupStack::PopAndDestroy( &aIPronunciationIDSequence ); 
+            
+            // Recompile the grammar after a deletion
+            // Async call, callback handled in handleeventtp
+            //delete iSICompiledGrammarRecompile;			
+            iSICompiledGrammarRecompile->DeleteL( aRuleID );
+            }
+        
+        // Update the lexicon
+        for ( i = 0; i < aLexiconArray.Count(); i++ )
+            {
+            iSILexiconDB->UpdateLexiconL( iClientUid, aLexiconArray[i] );
+            }	
+        
+        // clean up 					
+        // Close the arrays
+        //aLexiconIDs.Close();
+        CleanupStack::PopAndDestroy( &aLexiconIDs ); // CleanupClosePushL aLexiconIDs
+        aLexiconArray.ResetAndDestroy();
+        CleanupStack::PopAndDestroy( &aLexiconArray ); //aLexiconArray
+        __UHEAP_MARKEND;
+        
+        if ( iSICompiledGrammarRecompile->Count() == 0 )
+            {
+            // Reset compiled data to null
+            iSICompiledGrammarRecompile->SetCompiledData( NULL );
+            
+            iSIDatabase->BeginTransactionL();
+            // save the compiled grammar
+            TRAPD( error, iSIGrammarDB->UpdateGrammarL( iClientUid,iSICompiledGrammarRecompile ) );
+            iSIDatabase->CommitChangesL( ETrue );
+            if ( error )
+                {
+                iControllerIf.SendSrsEvent( KUidAsrEventRemoveRules, error );
+                delete iSICompiledGrammarRecompile;
+                iState = ESiPluginIdle;
+                return;
+                }	
+            TRAP( error, iSIDatabase->CommitChangesL( ETrue ) );  
+            
+            delete iSICompiledGrammarRecompile;
+            iSICompiledGrammarRecompile = NULL;
+            iState = ESiPluginIdle;
+            
+            // Special case, do the callback now since we're not expecting
+            // anything from the lower layers
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveRules, error );
+            } // if ( iSICompiledGrammarRecompile->Count() == 0 )
+        else
+            {
+            iDevASR->CompileGrammarL( *iSICompiledGrammarRecompile );
+            }
+        
+        } // if ( iClientRegistered )
+        else
+            {
+            User::Leave( KErrAsrNotRegisted );
+            }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::SetClientUid
+// Sets the client's UID for data ownership identification.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::SetClientUid( TUid aClientUid )
+    {
+    RUBY_DEBUG0( "CSIControllerPlugin::SetClientUid") ;
+    iClientUid = aClientUid;
+    iClientRegistered = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::SetPrioritySettings
+// Set the priority settings for this controller.  This is used during recording
+// and playback.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings )
+    {
+    RUBY_DEBUG0( "CSIControllerPlugin::SetPrioritySettings" );
+    iDevASR->SetPrioritySettings( aPrioritySettings );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::StartRecSessionL
+// Initiates a recognition session.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::StartRecSessionL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::StartRecSessionL" );
+    RThread().SetPriority( EPriorityAbsoluteLow );
+    RUBY_DEBUG0( "CSIControllerPlugin::StartRecSessionL Lowered thread priority to absolute low" );
+    //RUBY_DEBUG1( "CSIControllerPlugin::StartRecSessionL Thread id is [%x]", RThread().Id() );
+    
+    if ( iState == ESiPluginIdle )
+        {
+        
+        User::LeaveIfError( iDevASR->StartRecSession( ESiRecognition ) );		
+        iState = ESiPluginRecognize;
+        }
+    else
+        {
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::TrainL
+// Initiates a speaker depedent training session.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::TrainL( TSIModelBankID aModelBankID,
+                                  TSIModelID& aModelID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::TrainL" );
+    
+    if ( IsActive() )
+        {	
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KTrain;
+    iModelBankID = aModelBankID;
+    iModelIDPtr = &aModelID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleTrainL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleTrainL( TSIModelBankID /*aModelBankID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleTrainL" );
+    User::Leave( KErrNotSupported );  
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::UnloadRuleL
+// Unloads a rule from the recognizer for this recognition session.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::UnloadRuleL( TSIGrammarID aGrammarID,
+                                       TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::UnloadRuleL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KUnloadRule;
+    iGrammarID = aGrammarID;
+    iRuleID = aRuleID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleUnloadRuleL
+// This is the asynchronous handle called from the CSIAsyncHandler object.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleUnloadRuleL( TSIGrammarID aGrammarID,
+                                             TSIRuleID aRuleID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleUnloadRuleL" );
+    iDevASR->UnloadRule( aGrammarID, aRuleID ); // for blacklisting only
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleUnloadRuleL
+// Notification from DevASR when feature vectors are available.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::FeatureVectorDataRcvd( const TDesC8& /*aFV*/, 
+                                                 TInt32 /*aSNR*/, 
+                                                 TInt32 /*aPosition*/ ) 
+    {
+    RUBY_DEBUG0( "CSIControllerPlugin::FeatureVectorDataRcvd" ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::DevASREvent
+// Event from DevASR interface.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::DevASREvent( TDevASREvent aEvent,
+                                       TDevASRError aError )
+    {
+    RUBY_DEBUG2( "CSIControllerPlugin::DevASREvent (Event=%d, Error=%d)", aEvent, aError );
+    
+    switch ( iState )
+        {
+        case ESdPluginTrain:
+            TRAP_IGNORE( HandleEventTrainL( aEvent, aError ) );
+            break;
+        case ESiPluginRecognize:
+            HandleEventRecognize( aEvent, aError );
+            break;
+        case ESiPluginPlay:
+            TRAP_IGNORE( HandleEventPlayL( aEvent, aError ) );
+            break;
+        case ESiPluginTrainText:
+            HandleEventTTP( aEvent, aError );
+            break;
+#ifdef __SINDE_TRAINING
+        case ESiPluginTrainSinde:
+            iSindeTrainer->HandleEvent( aEvent, aError );
+            break;
+#endif // __SINDE_TRAINING
+        case ESiPluginRemoveRule:
+            HandleEventRemoveRule( aEvent, aError );
+            break;
+        case ESiPluginRemoveRules:
+            RUBY_DEBUG0( "CSIControllerPlugin::DevASREvent case iState ESiPluginRemoveRules" );
+            HandleEventRemoveRules( aEvent, aError );
+            break;
+        case ESiPluginIdle:
+            break;
+        default:
+            // Unexpected or cancelled message
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RequestSpeechData
+// Get speech data from audio buffer
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RequestSpeechData()
+    {
+    const TInt KBufferMaxLength( 4000 );
+    TInt sizeLeft( iAudioBuffer->Size() - iNSamplesSent * 2 );
+    if ( sizeLeft == 0 )
+        {
+        // nothing
+        }
+    else if ( sizeLeft < KBufferMaxLength*2 )
+        {
+        // last buffer
+        iCurrentAudioBuffer.Set( iAudioBuffer->Right( sizeLeft ) );
+        iDevASR->SendSpeechData( iCurrentAudioBuffer, ETrue   );
+        
+        iNSamplesSent += sizeLeft/2;
+        }
+    else
+        {
+        iCurrentAudioBuffer.Set( iAudioBuffer->Mid( 2*iNSamplesSent, 2*KBufferMaxLength ) );
+        
+        iDevASR->SendSpeechData( iCurrentAudioBuffer, EFalse  );
+        iNSamplesSent += KBufferMaxLength;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::SILexiconL
+// Load lexicon by this call back functionDevAsr Take the owner ship of the lexicon 
+// -----------------------------------------------------------------------------
+//
+CSILexicon* CSIControllerPlugin::SILexiconL( TSILexiconID anID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::SILexiconL");
+    
+    iSIDatabase->BeginTransactionL();
+    CSILexicon* lexicon = iSILexiconDB->LexiconL(anID);
+    iSIDatabase->CommitChangesL( EFalse );
+    
+    return lexicon;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::ConfigurationData
+// DevASR calls this method to get configuration data.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CSIControllerPlugin::ConfigurationData( TUint32 aPackageType, 
+                                                TUint32 aPackageID,
+                                                TUint32 aStartPosition ,
+                                                TUint32 aEndPosition )
+    {
+    RUBY_DEBUG0( "ConfigurationData::MdtoConfigurationData" );
+    return ( iDataLoader->LoadData( aPackageType, aPackageID, 
+                                    aStartPosition, aEndPosition ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::DevASRMessage
+// A message in response to a custom command.  This controller never sends a
+// custom command.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::DevASRMessage( TDesC8& /*aMsg*/ )
+    {
+    // SI Controller Plugin does not implement this event.
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::PlayL
+// Plays the trained user utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::PlayL( TSIModelBankID /*aModelBankID*/,
+                                 TSIModelID /*aModelID*/ )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::PlayL");
+    User::Leave(KErrNotSupported);  
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEventPlayL
+// Handling of DevASR event in Play state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEventPlayL( TDevASREvent/* aEvent*/,
+                                            TDevASRError/* aError*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleEventPlayL" );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEventPlayL
+// Handling of DevASR event in RemoveRule state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEventRemoveRule( TDevASREvent aEvent, 
+                                                 TDevASRError aError ) 
+    {
+    iState = ESiPluginIdle;
+    
+    if ( aError )
+        {
+        iControllerIf.SendSrsEvent(KUidAsrEventRemoveRule, aError);
+        delete iSICompiledGrammarRecompile;
+        iSICompiledGrammarRecompile = NULL;
+        return;
+        }
+    
+    switch (aEvent)
+        {
+        case EDevASRGrammarCompile:
+            {
+            TRAPD( error, 
+                iSIDatabase->BeginTransactionL();
+                // save the compiled grammar
+                iSIGrammarDB->UpdateGrammarL( iClientUid, iSICompiledGrammarRecompile );
+                iSIDatabase->CommitChangesL( ETrue );
+                ); // TRAPD
+            if ( error )
+                {
+                iControllerIf.SendSrsEvent( KUidAsrEventRemoveRule, error );
+                delete iSICompiledGrammarRecompile;
+                iSICompiledGrammarRecompile = NULL;
+                iState = ESiPluginIdle;
+                return;
+                }	
+            TRAP( error, iSIDatabase->CommitChangesL( ETrue ) );  
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveRule, error );
+            
+            delete iSICompiledGrammarRecompile;
+            iSICompiledGrammarRecompile = NULL;
+            iState = ESiPluginIdle;
+            break;
+            
+            }
+        default:
+            // Unexpected or cancelled message
+            RUBY_DEBUG0( "CSIControllerPlugin::HandleEventRemoveRule. Unexpected.") ;
+            break;
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEventRemoveRules
+// Handling of DevASR event in RemoveRules state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEventRemoveRules( TDevASREvent aEvent, 
+                                                  TDevASRError aError ) 
+    {
+    RUBY_DEBUG2( "CSIControllerPlugin::HandleEventRemoveRules. Event [%d], Error [%d]", aEvent, aError );
+    
+    iState = ESiPluginIdle;
+    
+    if ( aError )
+        {
+        iControllerIf.SendSrsEvent(KUidAsrEventRemoveRules, aError);
+        delete iSICompiledGrammarRecompile;
+        iSICompiledGrammarRecompile = NULL;
+        return;
+        }
+    
+    switch ( aEvent )
+        {
+        case EDevASRGrammarCompile:
+            {
+            TRAPD( error, 
+                iSIDatabase->BeginTransactionL();
+                // save the compiled grammar
+                iSIGrammarDB->UpdateGrammarL( iClientUid, iSICompiledGrammarRecompile );
+                iSIDatabase->CommitChangesL( ETrue );
+                ); // TRAPD
+            
+            if ( error )
+                {
+                iControllerIf.SendSrsEvent( KUidAsrEventRemoveRules, error );
+                delete iSICompiledGrammarRecompile;
+                iSICompiledGrammarRecompile = NULL;
+                iState = ESiPluginIdle;
+                return;
+                }	
+            TRAP( error, iSIDatabase->CommitChangesL( ETrue ) );  
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveRules, error );
+            
+            delete iSICompiledGrammarRecompile;
+            iSICompiledGrammarRecompile = NULL;
+            iState = ESiPluginIdle;
+            break;
+            
+            }
+        default:
+            // Unexpected or cancelled message
+            RUBY_DEBUG0( "CSIControllerPlugin::HandleEventRemoveRules. Unexpected." );
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEventTTP
+// Handling of DevASR event in TTP state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEventTTP( TDevASREvent aEvent,
+                                         TDevASRError aError ) 
+    {
+    if ( aError )
+        {
+        iControllerIf.SendSrsEvent(KUidAsrEventAddVoiceTags, aError);
+        iState = ESiPluginIdle;
+        return;
+        }
+    
+    switch ( aEvent )
+        {
+        case EDevASRTrainFromText:
+            //case EDevASRTrainFromTextFinished:
+            {
+            
+            TRAPD( error, 
+                UpdateGrammarAndLexiconDBL( iSITtpWordList, iLexiconID, iGrammarID,*iRuleIDs ); 
+                iSIDatabase->BeginTransactionL();
+                iSICompiledGrammar = ( CSICompiledGrammar* )iSIGrammarDB->LoadGrammarL( iGrammarID );
+                iSIDatabase->CommitChangesL( EFalse );
+                iDevASR->CompileGrammarL( *iSICompiledGrammar );              
+                );
+             if ( error )
+                {
+                iControllerIf.SendSrsEvent( KUidAsrEventAddVoiceTags, error );
+                iState = ESiPluginIdle;
+                return;
+                }
+            
+            break;
+            }
+        case EDevASRGrammarCompile:
+            {
+            TInt error = KErrNone;
+            TRAP( error,
+                iSIDatabase->BeginTransactionL();
+                // save the compiled grammar
+                iSIGrammarDB->UpdateGrammarL( iClientUid, iSICompiledGrammar );
+                iSIDatabase->CommitChangesL( ETrue );
+                ); // TRAP
+            iControllerIf.SendSrsEvent( KUidAsrEventAddVoiceTags, error );
+            iState = ESiPluginIdle;
+            break;
+            }
+        default:
+            // Unexpected or cancelled message
+            RUBY_DEBUG0( "CSIControllerPlugin::HandleEventTTP. Unexpected." );
+            break;
+            
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEventRecognizeL
+// Handling of DevASR event in Recognition state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEventRecognize( TDevASREvent aEvent,
+											    TDevASRError aError )
+    {
+    RUBY_DEBUG2( "CSIControllerPlugin::HandleEventRecognize - Event=%d, Error=%d", aEvent, aError);
+    
+    switch ( aEvent )
+        {
+        case EDevASRLoadModels:
+            //	case EDevASRModelsLoaded:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRLoadModels failed with error [%d]", aError );
+               
+                TRAP_IGNORE( 
+                    iSIDatabase->BeginTransactionL();
+                    iSIModelBankDB->ResetAndDestroy();
+                    iSIDatabase->CommitChangesL( ETrue );
+                    ); // TRAP_IGNORE
+                
+                iState = ESiPluginIdle;
+                }
+            
+            iControllerIf.SendSrsEvent( KUidAsrEventLoadModels, aError );
+            break;
+        case EDevASRLoadLexicon:
+            //	case EDevASRLexiconLoaded:
+            
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRLoadLexicon failed with error [%d]", aError );
+                iSIModelBankDB->ResetAndDestroy();
+                iSILexiconDB->ResetAndDestroy();			
+                iState = ESiPluginIdle;
+                }
+            iControllerIf.SendSrsEvent( KUidAsrEventLoadLexicon, aError );
+            break;
+            
+        case EDevASRLoadGrammar:
+            //	case EDevASRGrammarLoaded:		
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRLoadGrammar failed with error [%d]", aError );
+
+                iSIModelBankDB->ResetAndDestroy();
+                iSILexiconDB->ResetAndDestroy();
+                iSIGrammarDB->ResetAndDestroy();
+                iState = ESiPluginIdle;
+                }
+            iControllerIf.SendSrsEvent( KUidAsrEventLoadGrammar, aError );
+            break;
+            
+        case EDevASRInitRecognitionBackend:
+            //case EDevASRRecBEInitialized:		
+            if ( aError == KErrNone )
+                {
+                iDevASR->InitFrontEnd( ESiRecognition );
+                }
+            else
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRInitRecognitionBackend failed with error [%d]", aError );
+
+                RecognitionReset();
+                iControllerIf.SendSrsEvent( KUidAsrEventRecognition, KErrAsrInitializationFailure );
+                }
+            break;
+            
+        case EDevASRInitFrontend:
+            //case EDevASRFEInitialized:
+            
+            if ( aError == KErrNone )
+                {	
+                iControllerIf.SendSrsEvent( KUidAsrEventRecognitionReady, KErrNone );
+                }
+            else
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRInitFrontend failed with error [%d]", aError );
+
+                RecognitionReset();
+                iControllerIf.SendSrsEvent( KUidAsrEventRecognition, KErrAsrInitializationFailure );
+                }
+            break;
+            
+        case EDevASRRecordStarted:
+            //case EDevASRRecordStarted:
+            
+            iControllerIf.SendSrsEvent( KUidAsrEventRecordStarted, aError );
+            break;
+            
+        case EDevASRRecord:
+            //case	EDevASRRecordFinished:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRRecord failed with error [%d]", aError );
+
+                RecognitionReset();
+                }
+            iControllerIf.SendSrsEvent( KUidAsrEventRecord, aError );
+            break;
+            
+        case EDevASRAdapt: // adaptation finished
+            //		case  EDevASRAdaptFinished: // adaptation finished
+            
+            if ( aError != KErrNone ) 
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRAdapt failed with error [%d]", aError );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventAdapt, aError );
+                }
+            else 
+                {
+                // save the models , iModelBankID decided in loadmodel()
+                TRAPD( error, 
+                    iSIDatabase->BeginTransactionL();
+                    iSIModelBankDB->SaveModelL( iModelBankID );
+                    iSIDatabase->CommitChangesL( ETrue );
+                    ); // TRAPD
+                iControllerIf.SendSrsEvent( KUidAsrEventAdapt, error );
+                }
+            break;
+        case EDevASREouDetected:
+            //case	EDevASRRecordFinished:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASREouDetected failed with error [%d]", aError );
+
+                RecognitionReset();
+                }
+            iControllerIf.SendSrsEvent( KUidAsrEventEouDetected, aError );
+            break;
+            
+            //	case EDevASREouDetected:
+            
+        case EDevASRRecognize:
+            
+            {
+            if ( aError == KErrNone )
+                {
+                
+                // Copy result into client result
+                if ( ProcessRecognitionComplete() > 0 )
+                    {
+                    iResult = KErrNone;		 
+                    }
+                else
+                    {
+                    iResult = KErrAsrNoMatch;
+                    }
+                }
+            else if (aError ==KErrOverflow ||aError ==KErrArgument  )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRRecognize failed with error [%d]", aError );
+
+                iResult = aError;	 
+                }
+            else 
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRRecognize failed with error [%d]", aError );
+
+                if ( aError != KErrAsrNoSpeech &&
+                    aError != KErrAsrSpeechTooEarly &&
+                    aError != KErrAsrSpeechTooLong &&
+                    aError != KErrAsrSpeechTooShort &&
+                    aError != KErrTimedOut &&
+                    aError !=KErrOverflow &&
+                    aError !=KErrArgument 
+                    )
+                    {
+                    RecognitionReset();
+                    }
+                iResult = aError;
+                }
+            
+            iControllerIf.SendSrsEvent(KUidAsrEventRecognition, iResult);
+            
+            //	iControllerIf.SendSrsEvent(KUidAsrEventRecognition, iResult);
+            break;
+            }
+        case EDevASRPlayStarted:
+            iControllerIf.SendSrsEvent(KUidAsrEventPlayStarted, aError);
+            break;
+            
+        case EDevASRPlay:
+            //case EDevASRPlayFinished:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRPlay failed with error [%d]", aError );
+
+                RecognitionReset();
+                }
+            iControllerIf.SendSrsEvent(KUidAsrEventPlay, aError);
+            break;
+        case EDevASRActivateGrammar:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRActivateGrammar failed with error [%d]", aError );
+
+                RecognitionReset();
+                }
+            iControllerIf.SendSrsEvent(KUidAsrEventActivateGrammar, aError);
+            break;
+        case EDevASRDeactivateGrammar:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRDeactivateGrammar failed with error [%d]", aError );
+
+                RecognitionReset();
+                }
+            iControllerIf.SendSrsEvent(KUidAsrEventDeactivateGrammar, aError);
+            break;
+        case EDevASRUnloadGrammar:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRUnloadGrammar failed with error [%d]", aError );
+
+                RecognitionReset();
+                }
+            else 
+                { 	
+                TRAP_IGNORE( 
+                    iSIDatabase->BeginTransactionL();
+                    iSIGrammarDB->UnloadGrammarL( iGrammarID );
+                    iSIDatabase->CommitChangesL( ETrue );
+                    ); // TRAP_IGNORE
+                }
+            
+            iControllerIf.SendSrsEvent(KUidAsrEventUnloadGrammar, aError);
+            break;
+        case EDevASRUnloadRule:
+            if ( aError != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::HandleEventRecognize. EDevASRUnloadRule failed with error [%d]", aError );
+
+                //RecognitionReset();
+                }
+            else 
+                {
+                TRAP_IGNORE( 
+                    iSIDatabase->BeginTransactionL();
+                    iSIGrammarDB->UnloadRuleL( iGrammarID, iRuleID );
+                    iSIDatabase->CommitChangesL( ETrue );
+                    ); // TRAPD
+                }
+            iControllerIf.SendSrsEvent( KUidAsrEventUnloadRule, aError );
+            break;
+            
+        default:
+            // Unexpected or cancelled message
+            RUBY_DEBUG0( "CSIControllerPlugin::HandleEventRecognize. Unexpected." );
+
+            break;
+        }
+        
+}
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEventTrainL
+// Handling of DevASR event in Train state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEventTrainL( TDevASREvent /*aEvent*/,
+										     TDevASRError /*aError*/ )
+{
+	RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleEventTrainL" );
+	User::Leave( KErrNotSupported );  
+}
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CreateNewRuleL
+// Create a empty rule into a given grammar
+// -----------------------------------------------------------------------------
+//                                 
+CSIRule* CSIControllerPlugin::CreateNewRuleL( CSICompiledGrammar* aGrammar ) 
+    {
+    RUBY_DEBUG_BLOCKL("CSIControllerPlugin::CreateNewRuleL");
+    TInt aID=0;
+    TInt Count=aGrammar->Count();
+    // existing myRuleVariantID
+    RArray<TSIRuleID> myIDs;
+    myIDs.Reset();
+    for( TInt i = 0; i < Count; i++ ) 
+        {
+        CSIRule* aRule=&(aGrammar->AtL(i));
+        myIDs.Append(aRule->RuleID());
+        } 
+    // Find a uniq new id 
+    iSIDatabase->BeginTransactionL();
+    aID=iSIGrammarDB->GetNewID(myIDs);
+    iSIDatabase->CommitChangesL( EFalse );
+    
+    myIDs.Close(); 
+    CSIRule* aRule = CSIRule::NewL(aID); 
+    return( aRule );
+    } 
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddNewRuleVariantL
+// Create new rule variant within a rule
+// -----------------------------------------------------------------------------
+//      
+void CSIControllerPlugin::AddNewRuleVariantL( CSIRule& aRule, 
+                                              TSILexiconID aLexiconID, 
+                                              RArray<TSIPronunciationID>& aPronunciationIDs, 
+                                              CSIParameters& aParameters ) 	
+    {
+    RUBY_DEBUG_BLOCKL( "CSIControllerPlugin::AddNewRuleVariantL" );
+    // existing myRuleVariantID
+    RArray<TSIRuleID> myID;
+    myID.Reset();
+    TInt i( 0 );
+    for( i = 0; i < aRule.Count(); i++ ) {
+        CSIRuleVariant* aRuleVariant=&(aRule.AtL(i));
+        myID.Append(aRuleVariant->RuleVariantID());
+        }
+    
+    iSIDatabase->BeginTransactionL();
+    
+    // Find a uniq new id 
+    TSIRuleVariantID aRuleVariantID=STATIC_CAST(TSIRuleVariantID,iSIGrammarDB->GetNewID(myID));
+    myID.Close();	
+    
+    iSIDatabase->CommitChangesL( ETrue );
+    
+    // add the rule variant to the rule
+    CSIRuleVariant* ruleVariant= CSIRuleVariant::NewL(aRuleVariantID,aLexiconID);
+    CleanupStack::PushL( ruleVariant );	
+    ruleVariant->SetPronunciationIDsL( aPronunciationIDs );
+    RArray<TInt> parameterIDs;
+    CleanupClosePushL( parameterIDs );
+    RArray<TInt> parameterValues;
+    CleanupClosePushL( parameterValues );
+    
+    // copy parameters
+    aParameters.ListParametersL( parameterIDs, parameterValues );
+    
+    if ( parameterIDs.Count() != parameterValues.Count() )
+        {
+        User::Leave( KErrCorrupt );
+        }
+    for ( i = 0; i < parameterIDs.Count(); i++ )
+        {
+        ruleVariant->SetParameterL( parameterIDs[i], parameterValues[i] );
+        }
+    
+    CleanupStack::PopAndDestroy(); // parameterValues
+    CleanupStack::PopAndDestroy(); // parameterIDs
+    aRule.AddL( ruleVariant );
+    CleanupStack::Pop( ruleVariant );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CreateNewPronunciationL
+// Create a empty pronunciation into a given lexicon
+// -----------------------------------------------------------------------------
+//                                 
+TSIPronunciationID CSIControllerPlugin::CreateNewPronunciationL( CSILexicon* aLexicon, 
+                                                                 TDesC8& aPronunciationPr,
+												                 TSIModelBankID aModelBankID) 	
+    {
+    RUBY_DEBUG_BLOCKL( "CSIControllerPlugin::CreateNewPronunciationL" );
+    
+    TSIPronunciationID pronunciationID( 0 );
+    
+    if ( aLexicon->Count() )
+        {
+        pronunciationID = aLexicon->AtL( aLexicon->Count() - 1 ).PronunciationID() + 1;
+        }
+    
+    //    RUBY_DEBUG1("pronunID = %i", pronunciationID );
+    // add the Pronunciation  to the Pronunciation
+    CSIPronunciation* pronunciation = CSIPronunciation::NewL( pronunciationID, aModelBankID );
+    
+    CleanupStack::PushL( pronunciation );	
+    pronunciation->SetPhonemeSequenceL( aPronunciationPr );
+    TRAPD( error, aLexicon->AddL( pronunciation ) );
+    if ( error == KErrAlreadyExists )
+        {
+#ifdef __SIND_LEXICON_OPT
+        // Take the existing pronunciation ID
+        TInt index = aLexicon->Find( aPronunciationPr );
+        pronunciationID = aLexicon->AtL( index ).PronunciationID();
+        
+        CleanupStack::PopAndDestroy( pronunciation ); 
+#else       
+        // try to find non-existing id in the middle of range
+        RUBY_DEBUG0( "pronunID already exists" );
+        RArray<TSIPronunciationID> myPronunciationID;
+        myPronunciationID.Reset();
+        for ( TInt i = 0; i < aLexicon->Count(); i++ )
+            {
+            CSIPronunciation* tmpPronunciation=&( aLexicon->AtL( i ) );
+            myPronunciationID.Append( tmpPronunciation->PronunciationID() );
+            }
+        
+        // Find a uniq new id 
+        iSIDatabase->BeginTransactionL();
+        pronunciationID = iSILexiconDB->GetNewID( myPronunciationID );
+        iSIDatabase->CommitChangesL( ETrue );
+        
+        pronunciation->SetPronunciationID( pronunciationID );
+        
+        myPronunciationID.Close();
+        aLexicon->AddL( pronunciation );
+#endif // __SIND_LEXICON_OPT
+        }
+    else
+        {
+        User::LeaveIfError( error );
+#ifdef __SIND_LEXICON_OPT        
+        CleanupStack::Pop( pronunciation );     
+#endif // __SIND_LEXICON_OPT
+        }
+
+#ifndef __SIND_LEXICON_OPT
+    CleanupStack::Pop( pronunciation );
+#endif // __SIND_LEXICON_OPT
+    
+    RUBY_DEBUG1( "CSIControllerPlugin::CreateNewPronunciationL pronunciationID=%x", pronunciationID );
+    return pronunciationID;    
+    }	
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::UpdateGrammarAndLexiconDBL
+// Save TTP result into the given grammar and lexicon of the plugin database
+// -----------------------------------------------------------------------------
+//                                 
+void CSIControllerPlugin::UpdateGrammarAndLexiconDBL( CSITtpWordList* aSITtpWordList, 
+                                                      TSILexiconID aLexiconID, 
+                                                      TSIGrammarID aGrammarID, 
+                                                      RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::UpdateGrammarAndLexiconDBL" );
+    CleanupClosePushL( aRuleIDs ); 
+    
+    iSITtpWordList = aSITtpWordList;
+    iLexiconID = aLexiconID;
+    iGrammarID = aGrammarID;
+    iRuleIDs = &aRuleIDs;
+    
+    aRuleIDs.Reset();
+    
+    iSIDatabase->BeginTransactionL();
+    
+    // is grammar already in database?
+    iSIGrammarDB->VerifyOwnershipL( iClientUid, KGrammarIdTable, KGrammarIndex, iGrammarID ); 
+    CSICompiledGrammar*  aGrammar = (CSICompiledGrammar* )iSIGrammarDB->GrammarL( iGrammarID );
+    CleanupStack::PushL( aGrammar );	
+    
+    //is lexicion already in database?
+    iSILexiconDB->VerifyOwnershipL( iClientUid, KLexiconIdTable, KLexiconIndex, iLexiconID );		   
+    CSILexicon* aLexicon = iSILexiconDB->LexiconL( iLexiconID );
+    CleanupStack::PushL( aLexicon );	
+    
+    iSIDatabase->CommitChangesL( EFalse );  
+    
+    
+    // unpack the iSITtpWordList;
+    for ( TInt i = 0; i < iSITtpWordList->Count(); i++ )
+        {
+        //iSIDatabase->BeginTransactionL();  
+        // Get pronunciations
+        RPointerArray<CSIPronunciationInfo> pronunciations;
+        RArray<TSIPronunciationID> pronunciationIDs;
+        CleanupClosePushL( pronunciationIDs );
+        CleanupClosePushL( pronunciations );
+        iSITtpWordList->GetPronunciationsL( i, pronunciations );
+   
+        RUBY_DEBUG1( "CSIControllerPlugin::UpdateGrammarAndLexiconDBL pronunciations.Count=%d", pronunciations.Count() );
+        
+        // if pronunciation generation failed, skip that word.
+        if ( pronunciations.Count() == 0 )
+            {
+            CleanupStack::PopAndDestroy( &pronunciations ); 
+            CleanupStack::PopAndDestroy( &pronunciationIDs );
+            User::LeaveIfError( aRuleIDs.Append( KInvalidRuleID ) );
+            continue;
+            }
+        
+        // Create a empty rule into grammar, one name -> one rule; 
+        TSIRuleID ruleID;
+        
+        
+        CSIRule* rule=CreateNewRuleL(aGrammar);
+        CleanupStack::PushL(  rule );	
+        ruleID=rule->RuleID();
+        User::LeaveIfError( aRuleIDs.Append( ruleID ) );
+        
+        for(TInt k=0;k<pronunciations.Count();k++) 
+            {
+            pronunciationIDs.Reset();
+            
+            for ( TInt n = 0; n < pronunciations[k]->Count(); n++ ) 
+                {	
+                // Add Prounication into lexicon
+                
+                TSIPronunciationID aPronunciationID = CreateNewPronunciationL( aLexicon,pronunciations[k]->PronunciationL( n ),
+                    iModelBankID );
+                User::LeaveIfError( pronunciationIDs.Append( aPronunciationID ) ); 
+                }
+            
+            // Add RuleVariant into grammar
+            AddNewRuleVariantL(*rule, aLexiconID, pronunciationIDs, *pronunciations[k] );                          
+            }
+        
+        
+        aGrammar->AddL( rule );
+        CleanupStack::Pop( rule );
+        
+        // Close the arrays
+        CleanupStack::PopAndDestroy( &pronunciations ); 
+        CleanupStack::PopAndDestroy( &pronunciationIDs );
+        }
+    
+    RUBY_DEBUG0( "CSIControllerPlugin::UpdateGrammarAndLexiconDBL" );
+    
+    iSIDatabase->BeginTransactionL();
+    iSIGrammarDB->UpdateGrammarL( iClientUid,aGrammar );
+    iSILexiconDB->UpdateLexiconL( iClientUid,aLexicon );
+    iSIDatabase->CommitChangesL( ETrue );  
+    CleanupStack::PopAndDestroy( 2 ); // aGrammar aLexicon	
+    
+    CleanupStack::Pop(); //aRuleIDs
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RecognitionReset
+// Terminate recognition session.  Free up resources and return to IDLE state.
+// -----------------------------------------------------------------------------
+//                                 
+void CSIControllerPlugin::RecognitionReset()
+    {
+    iSIModelBankDB->ResetAndDestroy();
+    iSILexiconDB->ResetAndDestroy();  // Grcompiler takes the ownership of it
+    iSIGrammarDB->ResetAndDestroy();
+    iState = ESiPluginIdle;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::ProcessTrainCompleteL
+// Training is complete.  Store the acoustic model and user utterance into the
+// model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::ProcessTrainCompleteL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::ProcessTrainCompleteL" );
+    // No need to train it at all  
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::ProcessRecognitionCompleteL
+// Recogntion is complete.  Transfer the result from the recognizer into the result
+// object sent by the client.
+// -----------------------------------------------------------------------------
+//
+TInt CSIControllerPlugin::ProcessRecognitionComplete()
+    {
+    RUBY_DEBUG0( "CSIControllerPlugin::ProcessRecognitionComplete" );
+    
+    const CSIResult* result = 0;
+    CSIClientResult* clientResult = 0;
+    
+    TInt resultsAvailable = iSIResultSet->Count();
+    TInt resultsWanted    = iSIClientResultSet->MaxResults();
+    TInt count            = Min( resultsAvailable, resultsWanted );
+    
+    // Copy the results from the recognizer into client's result set object
+    TInt resCount = 0;
+    
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        TRAPD( err, result = &( iSIResultSet->AtL( i ) ) );
+        if ( err )
+            {
+            return 0; 	 	
+            }
+        RUBY_DEBUG2( "CSIControllerPlugin::ProcessRecognitionComplete rank(%d): grammarId(%d)", i+1, result->GrammarID() );
+        RUBY_DEBUG2( "CSIControllerPlugin::ProcessRecognitionComplete ruleId(%d), score(%d)", result->RuleID(), result->Score() );
+
+        if ( result->Score() > 0 )
+            {
+            TRAP( err, clientResult = CSIClientResult::NewL( result->GrammarID(), 
+                                                             result->RuleID() ) );
+            if ( err ) 
+                {
+                return 0; 	 	
+                }			
+            TRAP( err, iSIClientResultSet->AddL( clientResult ) );
+            if ( err ) 
+                {
+                return 0; 	 	
+                }
+            resCount++;
+            }
+        else
+            {
+            break;
+            }
+        }
+    
+    iSIClientResultSet->SetResultCount( resCount );
+    return resCount;
+    } 
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::DoCancel
+// Cancel handle from CActive class.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::RunL
+// RunL from CActive class.  Check which message got saved and call the
+// appropriate handle function.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::RunL" );
+    switch ( iRequestFunction )
+        {
+        case KAddRule:
+            TRAP( iResult, HandleAddRuleL( iGrammarID, iLexiconID, iPronunciationID, *iRuleIDPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventAddRule, iResult );
+            break;
+            
+        case KCreateGrammar:
+            TRAP( iResult, HandleCreateGrammarL( *iGrammarIDPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventCreateGrammar, iResult );
+            break;
+            
+        case KCreateLexicon: 
+            TRAP( iResult, HandleCreateLexiconL( *iLexiconIDPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventCreateLexicon, iResult );
+            break;
+            
+        case KCreateModelBank:
+            TRAP( iResult, HandleCreateModelBankL( *iModelBankIDPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventCreateModelBank, iResult );
+            break;
+            
+        case KGetAllClientGrammarIDs:
+            TRAP( iResult, HandleGetAllClientGrammarIDsL( *iGrammarIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllClientGrammarIDs, iResult );
+            break;
+            
+        case KGetAllClientLexiconIDs:
+            TRAP( iResult, HandleGetAllClientLexiconIDsL( *iLexiconIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllClientLexiconIDs, iResult );
+            break;
+            
+        case KGetAllClientModelBankIDs:
+            TRAP( iResult, HandleGetAllClientModelBankIDsL( *iModelBankIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllClientModelBankIDs, iResult );
+            break;
+            
+        case KGetAllGrammarIDs:
+            TRAP( iResult, HandleGetAllGrammarIDsL( *iGrammarIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllGrammarIDs, iResult );
+            break;
+            
+        case KGetAllLexiconIDs:
+            TRAP( iResult, HandleGetAllLexiconIDsL( *iLexiconIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllLexiconIDs, iResult );
+            break;
+            
+        case KGetAllModelBankIDs:
+            TRAP( iResult, HandleGetAllModelBankIDsL( *iModelBankIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllModelBankIDs, iResult );
+            break;
+            
+        case KGetAllModelIDs:
+            TRAP( iResult, HandleGetAllModelIDsL( iModelBankID, *iModelIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllModelIDs, iResult );
+            break;
+            
+        case KGetAllPronunciationIDs:
+            TRAP( iResult, HandleGetAllPronunciationIDsL( iLexiconID, *iPronunciationIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllPronunciationIDs, iResult );
+            break;
+            
+        case KGetAllRuleIDs:
+            TRAP( iResult, HandleGetAllRuleIDsL( iGrammarID, *iRuleIDs ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAllRuleIDs, iResult );
+            break;
+            
+        case KGetAvailableStorage:
+            TRAP( iResult, HandleGetAvailableStorageL( *iCountPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetAvailableStorage, iResult );
+            break;
+            
+        case KGetModelCount:
+            TRAP( iResult, HandleGetModelCountL( iModelBankID, *iCountPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetModelCount, iResult );
+            break;
+            
+        case KGetPronunciationCount:
+            TRAP( iResult, HandleGetPronunciationCountL( iLexiconID, *iCountPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetPronunciationCount, iResult );
+            break;
+            
+        case KGetRuleCount:
+            TRAP( iResult, HandleGetRuleCountL( iGrammarID, *iCountPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetRuleCount, iResult );
+            break;	
+        case KGetRuleValidity:
+            TRAP( iResult, HandleGetRuleValidityL( iGrammarID, iRuleID, *iValidPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetRuleValidity, iResult );
+            break;
+            
+        case KGetUtteranceDuration:
+            TRAP( iResult, HandleGetUtteranceDurationL( iModelBankID, iModelID, *iDurationPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventGetUtteranceDuration, iResult );
+            break;
+            
+        case KLoadGrammar:
+            TRAP( iResult, HandleLoadGrammarL( iGrammarID ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KLoadGrammar. HandleLoadGrammarL Left with error [%d]", iResult );
+                // iGrammarDB needs to be reset also since multiple grammars can
+                // be loaded and this may not be the first grammar.
+                iSIModelBankDB->ResetAndDestroy();
+                iSILexiconDB->ResetAndDestroy();
+                iSIGrammarDB->ResetAndDestroy();
+                iState = ESiPluginIdle;
+                iControllerIf.SendSrsEvent( KUidAsrEventLoadGrammar, iResult );
+                }
+            break;
+            
+        case KLoadLexicon:
+            TRAP(iResult, HandleLoadLexiconL( iLexiconID ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KLoadLexicon. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                // iLexiconDB needs to be reset also since multiple lexicons can
+                // be loaded and this may not be the first lexicon.
+                iSIModelBankDB->ResetAndDestroy();
+                iSILexiconDB->ResetAndDestroy();
+                iState = ESiPluginIdle;
+                iControllerIf.SendSrsEvent( KUidAsrEventLoadLexicon, iResult );
+                }
+            break;
+            
+        case KLoadModels:
+            TRAP(iResult, HandleLoadModelsL( iModelBankID ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KLoadModels. HandleLoadGrammarL Left with error [%d]", iResult );
+                
+                if ( iResult == KErrCorrupt )
+                    {
+                    RUBY_DEBUG0( "CSIControllerPlugin::RunL. KLoadModels. Try to update models" );
+                    TRAP( iResult,
+                        iSIModelBankDB->UpdateModelBankIfInvalidL( iModelBankID );
+                        HandleLoadModelsL( iModelBankID );
+                    );
+                    }
+
+                if ( iResult != KErrNone )
+                    {
+                    // iModelBankDB needs to be reset also since multiple model banks can
+                    // be loaded and this may not be the first model bank.
+                    iSIModelBankDB->ResetAndDestroy();
+                    iState = ESiPluginIdle;
+                    
+                    iControllerIf.SendSrsEvent( KUidAsrEventLoadModels, iResult );
+                    }
+                }
+            break;
+            
+        case KRecognize:
+            TRAP( iResult, HandleRecognizeL() );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KRecognize. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                if ( iResult != KErrAsrNoMatch )
+                    {
+                    RecognitionReset();
+                    }
+                iControllerIf.SendSrsEvent( KUidAsrEventRecognition, iResult );
+                }
+            break;
+            
+        case KRecord:
+            TRAP( iResult, HandleRecordL( iRecordTime ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KRecord. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventRecord, iResult );
+                }
+            break;
+            
+        case KRemoveGrammar:
+            TRAP( iResult, HandleRemoveGrammarL( iGrammarID ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveGrammar, iResult );
+            break;
+            
+        case KRemoveLexicon:
+            TRAP( iResult, HandleRemoveLexiconL( iLexiconID ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveLexicon, iResult );
+            break;
+            
+        case KRemoveModelBank:
+            TRAP( iResult, HandleRemoveModelBankL( iModelBankID ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveModelBank, iResult );
+            break;
+            
+        case KRemoveModel:
+            TRAP( iResult, HandleRemoveModelL( iModelBankID, iModelID ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventRemoveModel, iResult );
+            break;
+            
+        case KRemovePronunciation:
+            TRAP( iResult, HandleRemovePronunciationL( iLexiconID, iPronunciationID ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventRemovePronunciation, iResult );
+            break;
+            
+        case KRemoveRule:
+            TRAP( iResult, HandleRemoveRuleL( iGrammarID, iRuleID ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KRemoveRule. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventRemoveRule, iResult );
+                }
+            break;
+        case KRemoveRules:
+            TRAP( iResult, HandleRemoveRulesL( iGrammarID, *iRuleIDs ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KRemoveRules. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventRemoveRules, iResult );
+                }
+            break;
+            
+        case KTrain:
+            TRAP( iResult, HandleTrainL( iModelBankID ) );
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KTrain. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventTrain, iResult );
+                }
+            break;
+            
+        case KUnloadRule:
+            TRAP( iResult, HandleUnloadRuleL(iGrammarID, iRuleID));
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KUnloadRule. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventUnloadRule, iResult );
+                }
+            break;
+            
+            
+            // SI Component
+        case KAdapt:
+            TRAP( iResult, HandleAdaptL(*iSIClientResultSet ,iCorrect)) ;
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KAdapt. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                iControllerIf.SendSrsEvent( KUidAsrEventAdapt , iResult );
+                }
+            break;
+            /*	case KSIAddPronunciation:
+            TRAP(iResult, HandleAddPronunciationL(iLexiconID, iTrainTextPtr,
+            iLanguage, iPronunciationIDPtr)) ;
+            iControllerIf.SendSrsEvent(KUidAsrEventAddPronunciation, iResult);
+            break;
+            */		
+        case KAddRuleVariant:
+            TRAP( iResult, HandleAddRuleVariantL( iGrammarID, iLexiconID, *iPronunciationIDs, iRuleID, *iRuleVariantIDPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventAddRuleVariant, iResult );				
+            break;
+            /*	
+            case KAddVoiceTag:
+            TRAP(iResult, HandleAddVoiceTagL( *iTrainArray, *iLanguageArray, 
+            iLexiconID, iGrammarID, iRuleIDPtr)) ;
+            iControllerIf.SendSrsEvent(KUidAsrEventAddVoiceTag, iResult);
+            break;
+            */	
+        case KAddVoiceTags:
+            TRAP( iResult, HandleAddVoiceTagsL( iTrainArrays, *iLanguageArray, iLexiconID,
+                iGrammarID /* ,*iRuleIDs */) );
+            // AddVoiceTags contain several async functions,
+            // KUidAsrEventAddVoiceTags will be sent when the AddVoiceTags complete
+            if ( iResult != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIControllerPlugin::RunL. KAddVoiceTags. HandleLoadGrammarL Left with error [%d]", iResult );
+
+                // Clean up the iTrainArrays
+                if ( iTrainArrays )
+                    {
+                    iTrainArrays->ResetAndDestroy();
+                    iTrainArrays->Close();
+                    delete iTrainArrays;
+                    iTrainArrays = NULL;
+                    }
+                // Send error message
+                iControllerIf.SendSrsEvent( KUidAsrEventAddVoiceTags, iResult );
+                }
+            iTrainArrays = NULL;                
+            break;
+
+#ifdef __SINDE_TRAINING
+        case KAddSindeVoiceTags:
+            RUBY_DEBUG0( "CSIControllerPlugin::RunL KAddSindeVoiceTags" );
+            
+#ifdef _DEBUG
+            for ( TInt i = 0; i < iLanguageArrayArray->Count(); i++ )
+                {
+                RUBY_DEBUG1( "Contents of element %d:", i );
+                RLanguageArray langArr = (*iLanguageArrayArray)[i];
+                for ( TInt j = 0; j < langArr.Count(); j++ )
+                    {
+                    RUBY_DEBUG2( "Index: %d Language: %d", j, langArr[j] );
+                   }
+                }
+#endif // _DEBUG
+
+            TRAP( iResult, HandleAddSindeVoiceTagsL( iTrainArrays, *iLanguageArrayArray, iLexiconID, iGrammarID ) );
+
+            if ( iResult != KErrNone ) 
+                {
+                iTrainArrays->ResetAndDestroy();
+                iTrainArrays->Close();
+                delete iTrainArrays;
+                iTrainArrays = NULL;
+                
+                // Send error message
+                iControllerIf.SendSrsEvent( KUidAsrEventAddVoiceTags, iResult );
+                }
+            iTrainArrays = NULL;
+            break;
+#endif
+        case KCreateRule:
+            TRAP(iResult, HandleCreateRuleL( iGrammarID,*iRuleIDPtr ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventCreateRule, iResult );
+            break;
+            /*	case KSIRecognize:
+            TRAP(iResult, HandleRecognizeL(*(CSIClientResultSet*)iSIClientResultSet)) ;
+            //        iControllerIf.SendSrsEvent(KUidAsrEventSIRecognize, iResult);
+            break;
+            */
+        case KEndRecord:
+            TRAP( iResult, HandleEndRecordL( ) );
+            iControllerIf.SendSrsEvent( KUidAsrEventEndRecord, iResult );
+            break;
+        case KUnloadGrammar:
+            TRAP( iResult, HandleUnloadGrammarL( iGrammarID ) ) ;
+            // UnloadGrammar contain several async functions,
+            // KUidAsrEventUnloadGrammar will be sent when the UnloadGrammar complete		
+            //iControllerIf.SendSrsEvent(KUidAsrEventUnloadGrammar, iResult);
+            break;		
+            /*case KUpdateGrammarAndLexicon:
+            TRAP(iResult, HandleUpdateGrammarAndLexiconL(iSITtpWordList,iLexiconID,iGrammarID,*iRuleIDs));
+            iControllerIf.SendSrsEvent(KUidAsrEventUpdateGrammarAndLexicon, iResult);				
+            
+              break;
+            */
+            
+        case KPreStartSampling:
+            TRAP( iResult, HandlePreStartSamplingL() );
+            iControllerIf.SendSrsEvent( KUidAsrEventPreStartSampling, iResult );
+            break;
+            
+        default:
+            // No action
+            break;
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::DoAsynch
+// This method completes the request status and set the object active
+// to provide asynchronous behavior.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::DoAsynch()
+    {
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete( pRS, KErrNone );
+    SetActive();
+    }
+
+// ============================SI MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AdaptL
+// Calls the devasr for adaptation
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::AdaptL( CSIClientResultSet& aResultSet ,TInt aCorrect ) 
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AdaptL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KAdapt;
+    
+    iSIClientResultSet  = &aResultSet;
+    iCorrect = aCorrect;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleAdaptL
+// Calls the devasr for adaptation
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleAdaptL( CSIClientResultSet& aResultSet, 
+                                        TInt aCorrect ) 
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleAdaptL" );
+    if ( iState == ESiPluginRecognize )
+        {
+        iSIDatabase->BeginTransactionL();
+        if ( iSIGrammarDB->IsGrammarLoaded() )
+            
+            {
+            iDevASR->AdaptL( aResultSet.SIResultSet(), aCorrect );
+            }
+        else
+            {
+            // Either the loaded grammars are empty (contains no rule) or
+            // all rules have been unloaded.  No need to proceed any further.
+            iSIDatabase->CommitChangesL( EFalse );
+            
+            User::Leave( KErrAsrNoMatch );
+            }
+        
+        iSIDatabase->CommitChangesL( EFalse );
+        }
+    else
+        {
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddPronunciationL
+// Adds a new pronunciation for the given model into the specified lexicon.
+// -----------------------------------------------------------------------------
+//                                 
+void CSIControllerPlugin::AddPronunciationL( TSILexiconID /*aLexiconID*/,
+                                             const TDesC& /*aTrainText*/,
+                                             TLanguage /*aLanguage*/,
+                                             TSIPronunciationID& /*aPronunciationID*/)  
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddPronunciationL" );
+    User::Leave( KErrNotSupported );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddRuleVariantLtionL
+// Adds a new rule variant for the given pronunciation into the specified grammar.
+// -----------------------------------------------------------------------------
+//                                 
+void CSIControllerPlugin::AddRuleVariantL( TSIGrammarID aGrammarID,
+                                           TSILexiconID aLexiconID,
+                                           RArray<TSIPronunciationID>& aPronunciationIDs, 
+                                           TSIRuleID aRuleID,										  
+                                           TSIRuleVariantID& aRuleVariantID )
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::AddRuleVariantL");
+    
+    if ( IsActive() )
+        {
+        User::Leave(KErrServerBusy);
+        }
+    iRequestFunction = KAddRuleVariant;
+    iGrammarID = aGrammarID;
+    iRuleID = aRuleID;
+    iLexiconID = aLexiconID;
+    iRuleVariantIDPtr = &aRuleVariantID;	
+    iPronunciationIDs = &aPronunciationIDs;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleAddRuleVariantL
+// Adds a new rule variant for the given pronunciation into the specified grammar.
+// -----------------------------------------------------------------------------
+//                                 
+void CSIControllerPlugin::HandleAddRuleVariantL( TSIGrammarID aGrammarID, 
+                                                 TSILexiconID aLexiconID,
+                                                 RArray<TSIPronunciationID>& aPronunciationIDs, 
+                                                 TSIRuleID aRuleID,
+                                                 TSIRuleVariantID& aRuleVariantID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleAddRuleVariantL" );
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSIGrammarDB->AddRuleVariantL( iClientUid, aGrammarID, aLexiconID, 
+                                       aPronunciationIDs, aRuleID, aRuleVariantID ); 
+        iSIDatabase->CommitChangesL( ETrue );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddVoiceTagL
+// Trains a new voice tag.
+// -----------------------------------------------------------------------------
+//  
+void CSIControllerPlugin::AddVoiceTagL( MDesCArray& /*aTrainArray*/, 
+                                        RArray<TLanguage>& /*aLanguageArray*/, 
+                                        TSILexiconID /*aLexiconID*/,
+                                        TSIGrammarID /*aGrammarID*/, 
+                                        TSIRuleID& /*aRuleID*/)
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddVoiceTagL" );
+    User::Leave( KErrNotSupported );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddVoiceTagsL
+// Adds several new voice tags.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::AddVoiceTagsL( RPointerArray<MDesCArray>& aTrainArrays,
+                                         RArray<TLanguage>& aLanguageArray, 
+                                         TSILexiconID aLexiconID,
+                                         TSIGrammarID aGrammarID, 
+                                         RArray<TSIRuleID>& aRuleIDs)
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::AddVoiceTagsL");
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+        
+    // Use low priority for training (if training is not done from Voice Commands app)        
+    if ( RProcess().SecureId() != KVoiceCommandsAppUid )
+        {
+        RThread().SetPriority( EPriorityAbsoluteLow );
+        }
+    
+    iState = ESiPluginTrainText;
+    //	iTtpState=EAddVoiceTags;
+    
+    iRequestFunction = KAddVoiceTags ;
+    iLexiconID= aLexiconID;
+    iGrammarID = aGrammarID;
+    
+    iRuleIDs = &aRuleIDs;
+    iLanguageArray = &aLanguageArray;
+    iTrainArrays = &aTrainArrays;
+    
+    DoAsynch();
+    }
+
+#ifdef __SINDE_TRAINING
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddSindeVoiceTagL
+// Trains a new voice tag.
+// -----------------------------------------------------------------------------
+//  
+void CSIControllerPlugin::AddSindeVoiceTagL( MDesCArray& /*aTrainArray*/, 
+                                             RArray<RLanguageArray>& /*aLanguageArray*/, 
+                                             TSILexiconID /*aLexiconID*/,
+                                             TSIGrammarID /*aGrammarID*/, 
+                                             TSIRuleID& /*aRuleID*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddSindeVoiceTagL" );
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::AddSindeVoiceTagsL
+// Adds several new voice tags.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::AddSindeVoiceTagsL( RPointerArray<MDesCArray>& aTrainArrays,
+                                              RArray<RLanguageArray>& aLanguageArray, 
+                                              TSILexiconID aLexiconID,
+                                              TSIGrammarID aGrammarID, 
+                                              RArray<TSIRuleID>& aRuleIDs )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::AddSindeVoiceTagsL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+
+    // Use low priority for training (if training is not done from Voice Commands app)
+    if ( RProcess().SecureId() != KVoiceCommandsAppUid )
+        {
+        RThread().SetPriority( EPriorityAbsoluteLow );
+        }
+    
+    iState = ESiPluginTrainSinde;
+    
+    iRequestFunction = KAddSindeVoiceTags;
+    iLexiconID = aLexiconID;
+    iGrammarID = aGrammarID;
+    
+    // Store parameters for asynchronous processing
+    iRuleIDs = &aRuleIDs;
+    iLanguageArrayArray = &aLanguageArray;
+    iTrainArrays = &aTrainArrays;
+    
+    DoAsynch();
+    }
+#endif // __SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleAddVoiceTagsL
+// Adds several new voice tags.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleAddVoiceTagsL( RPointerArray<MDesCArray>* aTrainArrays,
+                                               RArray<TLanguage>& aLanguageArray, 
+                                               TSILexiconID aLexiconID,
+											   TSIGrammarID aGrammarID ) 
+    {
+    RUBY_DEBUG_BLOCK("CSIControllerPlugin::HandleAddVoiceTagsL");
+    // 
+    // first test if both KLexiconID lexicon and KGrammarID are created
+    if ( IsLexiconIDInvalid( aLexiconID ) || IsGrammarIDInvalid( aGrammarID ) )
+        {
+        User::Leave( KErrNotFound ); // no such grammar exist in Database
+        }
+    // Need to clean the iSITtpWordList before adding new arrays
+    delete iSITtpWordList;
+    iSITtpWordList = NULL;
+    iSITtpWordList = CSITtpWordList::NewL();
+    if ( iState == ESiPluginTrainText )
+        { 
+        for ( TInt i=0; i < aTrainArrays->Count(); i++ )
+            {            
+            iSITtpWordList->AddL( ( *aTrainArrays )[i] );
+            // If next AddL fails, we must not delete the objects twice - once in
+            // aTrainArray->ResetAndDestroy() and second time in ~CSITtpWordList.
+            ( *aTrainArrays )[i] = NULL;
+            }
+        aTrainArrays->ResetAndDestroy();
+        aTrainArrays->Close();
+        delete aTrainArrays;
+        aTrainArrays = NULL;
+        
+        // Set Max prnounication per word 
+        iMaxNPronunsForWord.Reset();	
+        iMaxNPronunsForWord.Append( aLanguageArray.Count() );
+        
+        RUBY_DEBUG1( "CSIControllerPlugin::AddVoiceTagsL(aLanguageArray.Count=%d)", aLanguageArray.Count() );
+        
+        iDevASR->StartTrainingFromTextL(*iSITtpWordList,aLanguageArray,iMaxNPronunsForWord);
+        }
+    else
+        {   
+        // Wrong state
+        User::Leave( KErrAsrInvalidState );
+        }
+    }
+
+#ifdef __SINDE_TRAINING
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleAddVoiceTagsL
+// Adds several new voice tags.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleAddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArrays,
+                                                    RArray<RLanguageArray>& aLanguageArray, 
+                                                    TSILexiconID aLexiconID,
+											        TSIGrammarID aGrammarID ) 
+    {
+    // First test if both KLexiconID lexicon and KGrammarID are created
+    if ( IsLexiconIDInvalid( aLexiconID ) || IsGrammarIDInvalid( aGrammarID ) )
+        {
+        User::Leave( KErrNotFound ); // no such grammar exist in Database
+        }
+  
+    iSindeTrainer->AddSindeVoiceTagsL( aTrainArrays, aLanguageArray, 
+                                       aLexiconID, aGrammarID, iModelBankID, 
+                                       iClientUid, *iRuleIDs );
+
+    }
+#endif // __SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::IsGrammarIDInvalid
+// is the grammar id valid in the database
+// -----------------------------------------------------------------------------
+//
+TBool CSIControllerPlugin::IsGrammarIDInvalid( TSIGrammarID aGrammarID )
+    {
+    TInt i(0);
+    RArray<TSIGrammarID> aGrammarIDs;
+    
+    TRAPD( error, 
+        iSIDatabase->BeginTransactionL();
+        iSIGrammarDB->GetAllGrammarIDsL( aGrammarIDs );
+        iSIDatabase->CommitChangesL( EFalse );
+        ); // TRAPD
+    
+    if ( error == KErrNone )
+        {
+        for( i = 0; i < aGrammarIDs.Count(); i++ ) 
+            {
+            if ( aGrammarIDs[i] == aGrammarID )
+                {
+                break;
+                }
+            if ( i == aGrammarIDs.Count() )
+                {
+                aGrammarIDs.Close();
+                return ETrue; // no such Lexicon exist in Database
+                }
+            }
+        }
+    aGrammarIDs.Close();
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::IsLexiconIDInvalid
+// is the lexicon id valid in the database
+// -----------------------------------------------------------------------------
+//
+TBool CSIControllerPlugin::IsLexiconIDInvalid( TSILexiconID aLexiconID )
+    {
+    // first test if both KLexiconID lexicon and KLexiconID are created
+    TInt i(0);
+    RArray<TSILexiconID> aLexiconIDs;
+
+    TRAPD( error,     
+        iSIDatabase->BeginTransactionL();
+        iSILexiconDB->GetAllLexiconIDsL( aLexiconIDs );
+        iSIDatabase->CommitChangesL( EFalse );
+        ); //TRAPD
+        
+    if ( error == KErrNone )
+        {
+        for( i = 0; i < aLexiconIDs.Count(); i++ ) 
+            {
+            if ( aLexiconIDs[i] == aLexiconID ) 
+                {
+                break;
+                }
+            if ( i == aLexiconIDs.Count() ) 
+                {
+                aLexiconIDs.Close();
+                return ETrue; // no such Lexicon exist in Database
+                }
+            }
+        }
+
+    aLexiconIDs.Close();
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::CreateRuleL
+// Creates a new empty rule.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::CreateRuleL( TSIGrammarID aGrammarID, 
+                                       TSIRuleID& aRuleID ) 
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::CreateRuleL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KCreateRule ;
+    iGrammarID = aGrammarID; 
+    iRuleIDPtr= &aRuleID;
+    
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleCreateRuleL
+// Creates a new empty rule.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleCreateRuleL( TSIGrammarID aGrammarID, 
+                                             TSIRuleID& aRuleID ) 
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleCreateRuleL" );
+    if ( iClientRegistered )
+        {
+        iSIDatabase->BeginTransactionL();
+        iSIGrammarDB->CreateRuleL( iClientUid, aGrammarID, aRuleID ); 
+        iSIDatabase->CommitChangesL( EFalse );
+        }
+    else
+        {
+        User::Leave( KErrAsrNotRegisted );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::EndRecordL
+// End recordingEnds recording. Unlike Cancel(), this function may return a 
+// recognition result if adequate number of samples was already recorded.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::EndRecordL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::EndRecordL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KEndRecord ; 
+    DoAsynch();
+}
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleEndRecordL
+// End recordingEnds recording. Unlike Cancel(), this function may return a 
+// recognition result if adequate number of samples was already recorded.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleEndRecordL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleEndRecordL" );
+    iDevASR->EndRecord();	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::UnloadGrammarL
+// Unload a grammar from memory
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::UnloadGrammarL( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::UnloadGrammarL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    iRequestFunction = KUnloadGrammar ;
+    iGrammarID=aGrammarID;
+    DoAsynch();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPlugin::HandleUnloadGrammarL
+// Unload a grammar from memory
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPlugin::HandleUnloadGrammarL( TSIGrammarID aGrammarID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPlugin::HandleUnloadGrammarL" );
+    
+    iSIDatabase->BeginTransactionL();
+    CSICompiledGrammar* LoadedGrammar =iSIGrammarDB->FindGrammarL( aGrammarID );	 
+    iSIDatabase->CommitChangesL( EFalse );
+        
+    iDevASR->UnloadGrammar( *LoadedGrammar );	// async call to unload grammar in devasr
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicontrollerplugin.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1092 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the main implementation of the SI Controller Plugin.
+*               Finite State Machine is implemented here.
+*
+*/
+
+
+#ifndef SICONTROLLERPLUGIN_H
+#define SICONTROLLERPLUGIN_H
+
+// ============================================================================
+// Uncomment the following directive for Bit Exact Testing.
+// ============================================================================
+//
+ 
+// INCLUDES
+#include "srsfbldvariant.hrh"
+#include <nsssispeechrecognitiondataclient.h>
+#include <nsssispeechrecognitiondatacommon.h>
+#include <nssdevasr.h>
+#include <d32dbms.h>
+
+// FORWARD DECLARATIONS
+class CSIControllerPluginInterface;
+class CDevASR;
+class CSIResourceHandler;
+class CSDClientResultSet;
+
+class CSIGrammarDB; 
+class CSIModelBankDB;
+class CSILexiconDB; 
+class CDataLoader;
+class CSIDatabase;
+
+#ifdef __SINDE_TRAINING
+class CSindeTrainer;
+#endif // __SINDE_TRAINING
+
+// CLASS DECLARATION
+
+/**
+*  This is the main class of SI Controller Plugin
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.0
+*/
+class CSIControllerPlugin : public CActive, public MDevASRObserver
+{
+public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.    CSIControllerPluginInterface& aControllerIf
+    */
+    static CSIControllerPlugin* NewL( CSIControllerPluginInterface& aControllerInterface );
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CSIControllerPlugin();
+    
+public: // Functions from base classes
+    
+    /**
+    * From MDevASRObserver
+    * Spontaneous or non-spontaneous event received from DevASR.
+    * @since 2.0
+    * @param    aEvent                event code
+    * @param    aError                error code
+    */
+    void DevASREvent( TDevASREvent aEvent, TDevASRError aError );
+    
+    /**
+    * From MDevASRObserver
+    * Notification from DevASR when feature vectors are available.
+    * @since 2.0
+    * @param    aFV                    buffer containing the feature vector data
+    * @param    aSNR                signal-to-noise ratio
+    * @param    aPosition            indicates whether the feature vector is the first, middle, or end.
+    */
+    void FeatureVectorDataRcvd( const TDesC8& aFV, TInt32 aSNR, TInt32 aPosition ); 
+    
+    /**
+    * From MDevASRObserver
+    * A message in response to a custom command.
+    * @since 2.0
+    * @param    aMsg                buffer containing the message
+    */
+    void DevASRMessage( TDesC8& aMsg );
+
+    /**
+    * From MDevASRObserver
+    * DevASR calls this method to get lexicon data.
+    * @since 2.8
+    * @param    anID lexicon ID
+    * @return    Lexicon object
+    */
+    CSILexicon* SILexiconL( TSILexiconID anID );
+    
+    /**
+    * DevASR calls this method to get configuration data.
+    *
+    * @since 2.8
+    * @param "TUint32 aPackageType" Type identifier.
+    * @param "TUint32 aPackageID" Identifier of package.
+    * @param "TUint32 aStartPosition" Starting position within package in bytes.
+    * @param "TUint32 aEndPosition" Ending position within package in bytes.
+    * @return Pointer to created buffer containing the request data.
+    */
+    HBufC8* ConfigurationData( TUint32 aPackageType, 
+                               TUint32 aPackageID,
+                               TUint32 aStartPosition,
+                               TUint32 aEndPosition );
+    
+    /**
+    * Get speech data from audio buffer
+    *
+    * @since 2.8
+    */    
+    void RequestSpeechData();    
+    
+#ifdef DEVASR_KEEP_SD
+    CSDLexicon* SDLexiconL( TSILexiconID anID ) ;
+#endif
+    
+public: // New functions
+    
+    /**
+    * Adds a new pronunciation for the given model into the specified lexicon.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id, where the new pronunciation is added to
+    * @param    aModelBankID        model bank Id
+    * @param    aModelID            model Id
+    * @param    aPronunciationID    reference where a new pronunciation Id is assigned to
+    */
+    void AddPronunciationL( TSILexiconID aLexiconID, TSIModelBankID aModelBankID,
+        TSIModelID aModelID, TSIPronunciationID& aPronunciationID );
+    
+    void AddPronunciationL( TSILexiconID aLexiconID, TSIModelBankID aModelBankID,
+        const TDesC8& aPronunciationPr, TSIPronunciationID& aPronunciationID );
+    
+    /**
+    * Adds a new rule for the given pronunciation into the specified grammar.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id, where the new rule is added to
+    * @param    aLexiconID            lexicon Id
+    * @param    aPronunciationID    pronunciation Id
+    * @param    aRuleID                reference where a new rule Id is assigned to
+    */
+    void AddRuleL( TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+        TSIPronunciationID aPronunciationID, TSIRuleID& aRuleID );
+    
+    /**
+    * Cancels the current activity and returns the plugin to Idle state.
+    * @since 2.0
+    */
+    void Cancel();
+    
+    /**
+    * Commits (saves) the current trained model into a permanent storage.
+    * @since 2.0
+    */
+    void CommitChangesL( TBool aCompact );
+    
+    /**
+    * Creates a new grammar.
+    * @since 2.0
+    * @param    aGrammarID            reference where a new rule Id is assigned to
+    */
+    void CreateGrammarL( TSIGrammarID& aGrammarID );
+    
+    /**
+    * Creates a new lexicon.
+    * @since 2.0
+    * @param    aLexiconID            reference where a new lexicon Id is assigned to
+    */
+    void CreateLexiconL( TSILexiconID& aLexiconID );
+    
+    /**
+    * Creates a new model bank.
+    * @since 2.0
+    * @param    aModelBankID        reference where a new model bank Id is assigned to
+    */
+    void CreateModelBankL( TSIModelBankID& aModelBankID );
+    
+    /**
+    * Ends the current recognition session.  Resources allocated for recognition are freed.
+    * @since 2.0
+    * @param    -
+    */
+    void EndRecSessionL();
+    
+    /**
+    * Returns all grammar Ids that belong to the current client, whose UID was set
+    * with SetClientUidL().
+    * @since 2.0
+    * @param    aGrammarIDs            reference where grammar Ids are stored
+    */
+    void GetAllClientGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+    
+    /**
+    * Returns all lexicon Ids that belong to the current client, whose UID was set
+    * with SetClientUidL().
+    * @since 2.0
+    * @param    aLexiconIDs            reference where lexicon Ids are stored
+    */
+    void GetAllClientLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+    
+    /**
+    * Returns all model bank Ids that belong to the current client, whose UID was set
+    * with SetClientUidL().
+    * @since 2.0
+    * @param    aModelBankIDs        reference where model bank Ids are stored
+    */
+    void GetAllClientModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs );
+    
+    /**
+    * Returns all grammar Ids that exist (for all clients).
+    * @since 2.0
+    * @param    aGrammarIDs            reference where grammar Ids are stored
+    */
+    void GetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+    
+    /**
+    * Returns all lexicon Ids that exist (for all clients).
+    * @since 2.0
+    * @param    aLexiconIDs            reference where lexicon Ids are stored
+    */
+    void GetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+    
+    /**
+    * Returns all model bank Ids that exist (for all clients).
+    * @since 2.0
+    * @param    aModelBankIDs        reference where model bank Ids are stored
+    */
+    void GetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs );
+    
+    /**
+    * Returns all model Ids that exist in the specified model bank.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    * @param    aModelIDs            reference where model Ids are stored
+    */
+    void GetAllModelIDsL( TSIModelBankID aModelBankID, RArray<TSIModelID>& aModelIDs );
+    
+    /**
+    * Returns all pronunciation Ids that exist in the specified lexicon.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id
+    * @param    aPronunciationIDs    reference where pronunciation Ids are stored
+    */
+    void GetAllPronunciationIDsL( TSILexiconID aLexiconID,
+        RArray<TSIPronunciationID>& aPronunciationIDs );
+    
+    /**
+    * Returns all rule Ids that exist in the specified grammar.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    * @param    aRuleIDs            reference where rule Ids are stored
+    */
+    void GetAllRuleIDsL( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+    
+    /**
+    * Returns the number of models available for training system wide, based on
+    * available disk space.
+    * @since 2.0
+    * @param    aCount                reference where the number of available models is set
+    */
+    void GetAvailableStorageL( TInt& aCount );
+    
+    /**
+    * Returns the engine properties specified by the engine property ID array.
+    * On return aPropertyValue contains an array of engine properties.
+    * @since 2.0
+    * @param    aPropertyId            constant reference to array of engine property Ids
+    * @param    aPropertyValue        reference to array of engine property values
+    */
+    void GetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+        RArray<TInt>& aPropertyValue );
+    
+    /**
+    * Returns the number of models in the specified model bank.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    * @param    aCount                reference where the number of models is set
+    */
+    void GetModelCountL( TSIModelBankID aModelBankID, TInt& aCount );
+
+    /**
+    * Returns the number of pronunciationin the specified lexicon.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id
+    * @param    aCount                reference where the number of models is set
+    */
+    
+    void GetPronunciationCountL(TSILexiconID aLexiconID, TInt& aCount );
+
+    /**
+    * Returns the number of rules in the specified grammar.
+    * @since 2.0
+    * @param    aGrammarID        Grammar Id
+    * @param    aCount                reference where the number of models is set
+    */
+    void GetRuleCountL(TSIGrammarID aGrammarID, TInt& aCount );
+    
+    /**
+    * Checks if the rule is valid or not.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    * @param    aRuleID                rule Id
+    * @param    aValid                reference where the validity of the rule is set
+    */
+    void GetRuleValidityL( TSIGrammarID aGrammarID, TSIRuleID aRuleID, TBool& aValid );
+    
+    /**
+    * Returns the duration of the utterance for the specified model.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    * @param    aModelID            model Id
+    * @param    aDuration            reference where the duration of utterance is set
+    */
+    void GetUtteranceDurationL( TSIModelBankID aModelBankID, TSIModelID aModelID,
+        TTimeIntervalMicroSeconds32& aDuration );
+    
+    /**
+    * Loads the specified recognizer parameter(s).  These parameters are used to
+    * alter the recognizer's default parameters.  The parameters are specified as
+    * attribute and value pairs.
+    * @since 2.0
+    * @param    aParameterID        list of parameter Ids
+    * @param    aParameterValue        list of parameter values
+    */
+    void LoadEngineParametersL( const RArray<TInt>& aParameterId,
+        const RArray<TInt>& aParameterValue );
+    
+    /**
+    * Loads the specified grammar into the recognizer; done prior to recognition.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    */
+    void LoadGrammarL( TSIGrammarID aGrammarID );
+    
+    /**
+    * Loads the specified lexicon into the recognizer; done prior to recognition.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id
+    */
+    void LoadLexiconL( TSILexiconID aLexiconID );
+    
+    /**
+    * Loads the specified model bank into the recognizer; done prior to recognition.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    */
+    void LoadModelsL( TSIModelBankID aModelBankID );
+    
+    /**
+    * Plays the previously trained utterance.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    * @param    aModelID            model Id, whose utterance is played
+    */
+    void PlayUtteranceL( TSIModelBankID aModelBankID, TSIModelID aModelID );
+    
+    /**
+    * Initiates recognition; performed following loading of model bank, lexicon, and grammar.
+    * @since 2.0
+    * @param    aClientResultSet    reference where the recognition result is set
+    */
+    void RecognizeL( CSDClientResultSet& aClientResultSet );
+    
+    /**
+    * Records uder utterance for training and recognition.
+    * @since 2.0
+    * @param    aRecordTime            recording time in microseconds
+    */
+    void RecordL( TTimeIntervalMicroSeconds32 aRecordTime );
+    
+    /**
+    * Pre-starts sampling.
+    * @since 3.2
+    */
+    void PreStartSamplingL();
+    
+    /**
+    * Removes the specified grammar from the permanent storage.
+    * Removing a grammar will remove all rules within the grammar.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    */
+    void RemoveGrammarL( TSIGrammarID aGrammarID );
+    
+    /**
+    * Removes the specified lexicon from the permanent storage.
+    * Removing a lexicon will remove all pronunciations within the lexicon.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id
+    */
+    void RemoveLexiconL( TSILexiconID aLexiconID );
+    
+    /**
+    * Removes the specified model bank from the permanent storage.
+    * Removing a model bank will remove all models within the model bank.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    */
+    void RemoveModelBankL( TSIModelBankID aModelBankID );
+    
+    /**
+    * Removes the specified model from the specified model bank permanently.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    * @param    aModelID            model Id
+    */
+    void RemoveModelL( TSIModelBankID aModelBankID, TSIModelID aModelID );
+    
+    /**
+    * Removes the specified pronunciation from the specified lexicon permanently.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id
+    * @param    aPronunciationID    pronunciation Id
+    */
+    void RemovePronunciationL( TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID );
+    
+    /**
+    * Removes the specified rule from the specified grammar permanently.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    * @param    aRuleID                rule Id
+    */
+    void RemoveRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+    /**
+    * Removes the specified rules from the specified grammar permanently.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    * @param    aRuleIDs            rule Ids
+    */
+    void RemoveRulesL(TSIGrammarID aGrammarID,RArray<TSIRuleID>& aRuleIDs );
+    
+    /**
+    * Sets the client's UID for data ownership identification.
+    * @since 2.0
+    * @param    aClientUid            client's UID
+    */
+    void SetClientUid( TUid aClientUid );
+    
+    /**
+    * Sets the priority settings for this controller.
+    * @since 2.0
+    * @param    aPrioritySettings    new priority settings
+    */
+    void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings );
+    
+    /**
+    * Starts a new recognition session.
+    * @since 2.0
+    */
+    void StartRecSessionL();
+    
+    /**
+    * Trains a new model into the specified model bank.
+    * @since 2.0
+    * @param    aModelBankID        model bank Id
+    * @param    aModelID            reference where a new model Id is assigned to
+    */
+    void TrainL( TSIModelBankID aModelBankID, TSIModelID& aModelID );
+    
+    /**
+    * Unloads the specified rule from the specified grammar in temporary memory, previously
+    * loaded with LoadGrammarL.  The rule in the permanent storage remains intact.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id
+    * @param    aRuleID                rule Id
+    */
+    void UnloadRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+    
+    
+    // SI component
+    
+    /**
+    *  
+    * Does speaker adapation to speaker independent models
+    * @since 2.8
+    * @param    aResultSet            a recognition result containing adaptation data
+    * @param    aCorrect            identifies the correct recognition result from the N-best list.
+    */
+    void AdaptL( CSIClientResultSet& aResultSet ,TInt aCorrect );
+
+    /**
+    * Adds a new pronunciation for the given model into the specified lexicon.
+    * @since 2.0
+    * @param    aLexiconID            lexicon Id
+    * @param    aTrainText:            the text to be trained
+    * @param    aTrainText:            the text to be trained        
+    * @param    aLanguage            the pronunciation language    
+    * @param    aPronunciationID: reference where a new pronunciation identifier is set.
+    */
+    void AddPronunciationL( TSILexiconID aLexiconID,
+                            const TDesC& aTrainText, 
+                            TLanguage aLanguage, 
+                            TSIPronunciationID& aPronunciationID );
+
+    /**
+    * From MSpeechRecognitionCustomCommandImplementor
+    * Adds a new rule variant for the given pronunciation into the specified grammar.
+    * @since 2.0
+    * @param    aGrammarID            grammar Id, where the new rule is added to
+    * @param    aLexiconID            lexicon Id
+    * @param    aPronunciationIDs    pronunciation Id array
+    * @param    aRuleVariantID        reference where a new rule Variant Id is assigned to
+    */
+    void AddRuleVariantL( TSIGrammarID aGrammarID, 
+                          TSILexiconID aLexiconID,
+                          RArray<TSIPronunciationID>& aPronunciationIDs, 
+                          TSIRuleID aRuleID,TSIRuleVariantID& aRuleVariantID );
+
+    /**
+    * Trains a new voice tag. The recognition phrase is the concatenation of words in the aTrainArray. 
+    * Pronunciations are created with all given languages, which are supported.
+    * @since 2.8
+    * @param    aTrainArray:        Recognition phrase is formed by concatenating the descriptors in this array.
+    * @param    aLanguageArray        Pronunciations are created with these languages. Not all languages are supported. The argument can be NULL.
+    * @param    aLexiconID            lexicon Id
+    * @param    aGrammarID            grammar Id, where the new rule is added to
+    * @param    aRuleID        reference where a new rule Id is assigned to
+    */
+    void AddVoiceTagL( MDesCArray& aTrainArray, 
+                       RArray<TLanguage>& aLanguageArray, 
+                       TSILexiconID aLexiconID, 
+                       TSIGrammarID aGrammarID, 
+                       TSIRuleID& aRuleID );
+    
+    /**
+    * Adds several new voice tags.
+    * @since 2.8
+    * @param    aTrainArray : An array of MDesCArrays. The recognition phrases are formed by concatenating the descriptors in the MDesCArrays.
+    * @param    aLanguageArray        Pronunciations are created with these languages. Not all languages are supported. The argument can be NULL.
+    * @param    aLexiconID            lexicon Id
+    * @param    aGrammarID            grammar Id, where the new rule is added to
+    * @param    aRuleID        reference where a new rule Id is assigned to
+    */
+    void AddVoiceTagsL( RPointerArray<MDesCArray>& aTrainArray,
+                        RArray<TLanguage>& aLanguageArray, 
+                        TSILexiconID aLexiconID, 
+                        TSIGrammarID aGrammarID,
+                        RArray<TSIRuleID>& aRuleID );
+    
+#ifdef __SINDE_TRAINING
+    /**
+    * Trains one new SINDE voice tag. The recognition phrase is the 
+    * concatenation of words in the aTrainArray. Pronunciations are 
+    * created with all given languages, which are supported.
+    *
+    * @since 3.1
+    * @param aTrainArray Recognition phrase is formed by concatenating 
+    *                    the descriptors in this array.
+    * @param aLanguageArray Pronunciations are created with these languages..
+    * @param aLexiconID Lexicon Id
+    * @param aGrammarID Grammar Id, where the new rule is added to.
+    * @param aRuleID Reference where a new rule Id is assigned to.
+    */
+    void AddSindeVoiceTagL( MDesCArray& aTrainArray, 
+                            RArray<RLanguageArray>& aLanguageArray, 
+                            TSILexiconID aLexiconID, 
+                            TSIGrammarID aGrammarID, 
+                            TSIRuleID& aRuleID );
+    
+    /**
+    * Adds several new SINDE voice tags.
+    *
+    * @since 3.1
+    * @param aTrainArray Recognition phrase is formed by concatenating 
+    *                    the descriptors in this array.
+    * @param aLanguageArray Pronunciations are created with these languages..
+    * @param aLexiconID Lexicon Id
+    * @param aGrammarID Grammar Id, where the new rule is added to.
+    * @param aRuleID Reference where a new rule Ids are assigned to.
+    */
+    void AddSindeVoiceTagsL( RPointerArray<MDesCArray>& aTrainArray,
+                             RArray<RLanguageArray>& aLanguageArray, 
+                             TSILexiconID aLexiconID, 
+                             TSIGrammarID aGrammarID,
+                             RArray<TSIRuleID>& aRuleID );
+
+#endif // __SINDE_TRAINING
+
+    /**
+    * Creates a new empty rule.
+    * @since 2.8
+    * @param    aGrammarID            grammar Id, where the new rule is added to
+    * @param    aRuleID        reference where a new rule Id is assigned to
+    */
+    void CreateRuleL( TSIGrammarID aGrammarID, TSIRuleID& aRuleID );
+
+    /**
+    * Initiates recognition; performed following loading of model bank, lexicon, and grammar.
+    * @since 2.8
+    * @param    aResultSet: reference where the recognition result is set. 
+    */   
+    void RecognizeL( CSIClientResultSet& aResultSet );
+
+    /**
+    * Ends recording. Unlike Cancel(), this function may return a recognition 
+    * result if adequate number of samples was already recorded.        
+    * @since 2.8
+    */         
+    void EndRecordL();
+
+    /**
+    * Unloads the specified grammar from the temporary memory, 
+    * previously loaded with MSrLoadGrammarL. The grammar in the permanent storage remains intact. 
+    * result if adequate number of samples was already recorded.        
+    * @since 2.0
+    * @param    aGrammarID            grammar Id, where the new rule is added to
+    */ 
+    void UnloadGrammarL( TSIGrammarID aGrammarID );
+
+    /**
+     * Activate the grammar for the recognition         
+    * @since 2.8
+    * @param    aGrammarID            grammar Id 
+    */
+    void  ActivateGrammarL( TSIGrammarID aGrammarID ) ;
+    /**
+     * Deactivate the grammar          
+    * @since 2.8
+    * @param    aGrammarID            grammar Id
+    */    
+    void DeactivateGrammarL( TSIGrammarID aGrammarID );     
+        
+    /**
+    * Create a empty rule into a given grammar
+    * @since 2.8
+    * @param    aGrammar  : a compiled grammar 
+    * @return    Created rule
+    */    
+    CSIRule* CreateNewRuleL( CSICompiledGrammar* aGrammar );
+    
+    /**
+    * Create a pronunciation into a given lexicon
+    * @since 2.8
+    * @param    aLexicon          : a lexicon  
+    * @param    aPronunciationPr  : phoneme sequence of the pronunciation
+    * @param    aModelBankID      : modelbank id 
+    * @return    Created pronunciation id
+    */            
+    TSIPronunciationID CreateNewPronunciationL( CSILexicon* aLexicon,
+                                                TDesC8& aPronunciationPr,
+                                                TSIModelBankID aModelBankID );
+    
+    /**
+    * Add rule variants into a given rule
+    * @since 2.8
+    * @param    aRule              :    a given rule
+    * @param    aLexiconID          : a lexicon ID, the added rule variant's pronunciations belong to this lexicon
+    * @param    aPronunciationIDs : array of Pronunciation IDs,
+    * @param    aParameters          : other parameters,such as language ID, for rule variants
+    */            
+    void AddNewRuleVariantL( CSIRule& aRule,
+                             TSILexiconID aLexiconID,
+                             RArray<TSIPronunciationID>& aPronunciationIDs, 
+                             CSIParameters& aParameters );    
+    
+    // Test functions
+    CSIRule*  CreateRule1L(void);    
+    CSIRule*  CreateRule2L(void);
+    void CheckRule1L(const CSIRule* aRule);
+    void CheckRule2L(const CSIRule* aRule);
+#ifdef __CONSOLETEST__
+    
+    // Unit Test
+    public:
+        
+        // Returns reference to a database
+        RDbNamedDatabase& GetDb();
+        
+        // Returns reference to model bank array
+        RPointerArray<CSIModelBank>& ModelBankArray();
+        
+        // Returns current plugin state
+        TInt PluginState();
+#endif
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CSIControllerPlugin( CSIControllerPluginInterface& aControllerIf );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * RunL from CActive class.
+        */
+        void RunL();
+        
+        /**
+        * Cancel handle from CActive class.
+        */
+        void DoCancel();
+        
+        /**
+        * This method completes the request status and set the object active
+        * to provide asynchronous behavior.
+        * @since 2.0
+        */
+        void DoAsynch();
+        
+        /**
+        * Plays the previously trained utterance.
+        * @since 2.0
+        * @param    aModelBankID        model bank Id
+        * @param    aModelID            model Id, whose utterance is played
+        */
+        void PlayL( TSIModelBankID aModelBankID, TSIModelID aModelID );
+        
+        /**
+        * Handles DevASR events received while in Training state.
+        * @since 2.0
+        * @param    aEvent                event code
+        * @param    aError                error code
+        */
+        void HandleEventTrainL( TDevASREvent aEvent, TDevASRError aError );
+        
+        /**
+        * Handles DevASR events received while in Recognition state.
+        * @since 2.0
+        * @param    aEvent                event code
+        * @param    aError                error code
+        */
+        void HandleEventRecognize( TDevASREvent aEvent, TDevASRError aError );
+
+        /**
+        * Handles DevASR events received while in remove rule state.
+        * @since 2.8
+        * @param    aEvent                event code
+        * @param    aError                error code
+        */    
+        void HandleEventRemoveRule( TDevASREvent aEvent, TDevASRError aError );
+
+        /**
+        * Handles DevASR events received while in remove rules state.
+        * @since 2.8
+        * @param    aEvent                event code
+        * @param    aError                error code
+        */    
+        void HandleEventRemoveRules( TDevASREvent aEvent, TDevASRError aError );
+        
+        /**
+        * Handles DevASR events received while in TTP state.
+        * @since 2.8
+        * @param    aEvent                event code
+        * @param    aError                error code
+        */        
+        void HandleEventTTP( TDevASREvent aEvent,
+                             TDevASRError aError );
+        
+        /**
+        * Handles DevASR events received while in Play state.
+        * @since 2.0
+        * @param    aEvent                event code
+        * @param    aError                error code
+        */
+        void HandleEventPlayL( TDevASREvent aEvent, TDevASRError aError );
+     
+        /**
+        * Frees memory allocated during recognition and resets the state to Idle.
+        * @since 2.0
+        */
+        void RecognitionReset();
+        
+        /**
+        * Handles the acoustic model and the user utterance from DevASR received upon
+        * TrainComplete event.
+        * @since 2.0
+        */
+        void ProcessTrainCompleteL();
+        
+        /**
+        * Handles the transfer of recognition result from DevASR into client's
+        * recognition result.
+        * @since 2.0
+        * @return    Number of results to the client
+        */
+        TInt ProcessRecognitionComplete();
+        
+        /**
+        * Save TTP result into the given grammar and lexicon of the plugin database
+        * @since 2.8
+        * @param    aSITtpWordList      :    data structure contains ttp results, word entries and their corresponding prounication
+        * @param    aLexiconID          : a lexicon ID, the added rule variant's pronunciations belong to this lexicon
+        * @param    aRuleIDs          : array of generated Rule IDs,
+        * @param    aParameters          : other parameters,such as language ID, for rule variants
+        */
+//        void  UpdateGrammarAndLexiconL(CSITtpWordList* aSITtpWordList , TSILexiconID aLexiconID, TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs);
+        
+        /**
+        * Save TTP result into the given grammar and lexicon of the plugin database
+        * @since 2.8
+        * @param    aSITtpWordList      :    data structure contains ttp results, word entries and their corresponding prounication
+        * @param    aLexiconID          : a lexicon ID, the added rule variant's pronunciations belong to this lexicon
+        * @param    aGrammarID          : a grammar Id                
+        * @param    aRuleIDs          : array of generated Rule IDs,
+        */
+        void  UpdateGrammarAndLexiconDBL( CSITtpWordList* aSITtpWordList, 
+                                          TSILexiconID aLexiconID, 
+                                          TSIGrammarID aGrammarID, 
+                                          RArray<TSIRuleID>& aRuleIDs );
+         
+        /**
+        * Is the lexicon id valid in the database
+        * @since 2.8
+        * @param    aLexiconID          : a lexicon ID,  
+        * @return    True or false
+        */
+        TBool  IsLexiconIDInvalid( TSILexiconID aLexiconID );
+    
+        /**
+        * Is the Grammar id valid in the database
+        * @since 2.8
+        * @param    aGrammarID          : a grammar Id
+        * @return    True or false
+        */
+        TBool  IsGrammarIDInvalid( TSIGrammarID aGrammarID );
+
+        // ============================================================================
+        // These methods are handlers for asynchronous messages that are called from
+        // the RunL.  The parameters are identical to how they were initially received
+        // under Public section of this class, therefore not repeated here.
+        // ============================================================================
+        //
+//        void HandleAddPronunciationL( TSILexiconID aLexiconID, TSIModelBankID aModelBankID,
+//            TSIModelID aModelID, TSIPronunciationID& aPronunciationID );
+        
+//        void HandleAddPronunciationL( TSILexiconID aLexiconID, TSIModelBankID aModelBankID,
+//            TDesC8& aPronunciationPr, TSIPronunciationID& aPronunciationID );
+        
+        void HandleAddRuleL( TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+            TSIPronunciationID aPronunciationID, TSIRuleID& aRuleID );
+        
+        void HandleCreateGrammarL( TSIGrammarID& aGrammarID );
+        
+        void HandleCreateLexiconL( TSILexiconID& aLexiconID );
+        
+        void HandleCreateModelBankL( TSIModelBankID& aModelBankID );
+        
+        void HandleGetAllClientGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+        
+        void HandleGetAllClientLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+        
+        void HandleGetAllClientModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs );
+        
+        void HandleGetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+        
+        void HandleGetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+        
+        void HandleGetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs );
+        
+        void HandleGetAllModelIDsL( TSIModelBankID aModelBankID, RArray<TSIModelID>& aModelIDs );
+        
+        void HandleGetAllPronunciationIDsL( TSILexiconID aLexiconID,
+            RArray<TSIPronunciationID>& aPronunciationIDs );
+        
+        void HandleGetAllRuleIDsL( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+        
+        void HandleGetAvailableStorageL( TInt& aCount );
+        
+        void HandleGetModelCountL( TSIModelBankID aModelBankID, TInt& aCount );
+        
+        void HandleGetPronunciationCountL(TSIModelBankID aLexiconID,TInt& aCount );
+        
+        void HandleGetRuleCountL(TSIGrammarID aGrammarID,TInt& aCount );
+
+        void HandleGetRuleValidityL( TSIGrammarID aGrammarID, TSIRuleID aRuleID, TBool& aValid );
+        
+        void HandleGetUtteranceDurationL( TSIModelBankID aModelBankID, TSIModelID aModelID,
+            TTimeIntervalMicroSeconds32& aDuration );
+        
+        void HandleLoadGrammarL( TSIGrammarID aGrammarID );
+        
+        void HandleLoadLexiconL( TSILexiconID aLexiconID );
+        
+        void HandleLoadModelsL( TSIModelBankID aModelBankID );
+                
+        void HandleRecognizeL();
+        
+        void HandleRecordL( TTimeIntervalMicroSeconds32 aRecordTime );
+        
+        void HandleRemoveGrammarL( TSIGrammarID aGrammarID );
+        
+        void HandleRemoveLexiconL( TSILexiconID aLexiconID );
+        
+        void HandleRemoveModelBankL( TSIModelBankID aModelBankID );
+        
+        void HandleRemoveModelL( TSIModelBankID aModelBankID, TSIModelID aModelID );
+        
+        void HandleRemovePronunciationL( TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID );
+        
+        void HandleRemoveRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+        
+        void  HandleRemoveRulesL( TSIGrammarID aGrammarID,RArray<TSIRuleID>& aRuleIDs );
+        
+        void HandleTrainL( TSIModelBankID aModelBankID );
+        
+        void HandleUnloadRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+        
+        void HandlePlayUtteranceL(TSIModelBankID aModelBankID, TSIModelID aModelID); 
+        // SI component
+        
+        void HandleAdaptL(CSIClientResultSet& aResultSet ,TInt aCorrect);
+        
+        
+//        void HandleAddPronunciationL(TSILexiconID aLexiconID,  TPtrC& aTrainText,
+//            TLanguage aLanguage, TSIPronunciationID* aPronunciationID) ;
+        
+        void HandleAddRuleVariantL(TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+            RArray<TSIPronunciationID>& aPronunciationIDs,TSIRuleID aRuleID, TSIRuleVariantID& aRuleVariantID );
+        
+        void HandleAddVoiceTagL( MDesCArray& aTrainArray,  RArray<TLanguage>& aLanguageArray, 
+            TSILexiconID aLexiconID, TSIGrammarID aGrammarID, TSIRuleID* aRuleIDPtr);
+        
+        void HandleAddVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,  RArray<TLanguage>& aLanguageArray, TSILexiconID aLexiconID,
+            TSIGrammarID aGrammarID/*, 
+            RArray<TSIRuleID>& aRuleID*/);
+
+#ifdef __SINDE_TRAINING            
+        void HandleAddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArrays,
+                                       RArray<RLanguageArray>& aLanguageArray,
+                                       TSILexiconID aLexiconID,
+                                       TSIGrammarID aGrammarID );
+#endif // __SINDE_TRAINING
+        
+        void HandleCreateRuleL(TSIGrammarID aGrammarID, TSIRuleID& aRuleID) ;
+        
+//        void HandleRecognizeL( CSIClientResultSet& aResultSet );
+        
+        void HandleEndRecordL();
+        
+        void HandleUnloadGrammarL( TSIGrammarID aGrammarID );
+        
+//        void  HandleUpdateGrammarAndLexiconL(CSITtpWordList* iSITtpWordList , TSILexiconID aLexiconID, TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleID);
+        
+        void HandlePreStartSamplingL();
+        
+    private:    // Data
+        
+        // SI Controller Plugin states
+        enum TControllerState
+            {
+            ESiPluginIdle,
+            ESdPluginTrain,
+            ESiPluginRecognize,
+            ESiPluginAdapt,
+            ESiPluginTrainText,
+            ESiPluginRemoveRule ,
+            ESiPluginRemoveRules,
+            ESiPluginPlay,
+            ESiPluginTrainSinde
+            };
+        
+        
+         // SI Controller Plugin state
+        TControllerState iState;
+        // Result to be sent to the client
+        TInt iResult;
+        
+        // Reference to Controller Interface
+        CSIControllerPluginInterface& iControllerIf;
+
+        // SI Database
+        CSIDatabase* iSIDatabase;
+        
+        
+        // SI part
+        // Model Bank database
+        CSIModelBankDB* iSIModelBankDB;
+        // Lexicon database
+        CSILexiconDB* iSILexiconDB;
+        // Grammar database
+        CSIGrammarDB* iSIGrammarDB;
+        TBool iVoiceTagDBLocked;        
+        // Resource file handler
+        CSIResourceHandler* iResourceHandler;
+        
+        // Client's UID for data ownership identification
+        TUid iClientUid;
+        TBool iClientRegistered;
+        
+        // DevASR
+        CDevASR* iDevASR;
+        
+        CSIResultSet* iSIResultSet;                    // Used during recognition
+        
+        /// Begin: data used in async handling of requests
+        TInt iRequestFunction;
+        TSIGrammarID iGrammarID;
+        TSILexiconID iLexiconID;
+        TSIModelBankID iModelBankID;
+        TSIRuleID iRuleID;
+        TSIRuleVariantID iRuleVariantID;
+        TSIPronunciationID iPronunciationID;
+        //RArray<TSIPronunciationID> iPronunciationIDs;
+        TSIModelID iModelID;
+        TTimeIntervalMicroSeconds32 iRecordTime;
+        TSIGrammarID* iGrammarIDPtr;
+        TSILexiconID* iLexiconIDPtr;
+        
+        TSIModelBankID* iModelBankIDPtr;
+        TSIRuleID* iRuleIDPtr;
+        TSIRuleVariantID* iRuleVariantIDPtr;
+        TSIPronunciationID* iPronunciationIDPtr;
+        TSIModelID* iModelIDPtr;
+        TInt* iCountPtr;
+        TBool* iValidPtr;
+        TTimeIntervalMicroSeconds32* iDurationPtr;
+
+
+     
+        RArray<TSIGrammarID>* iGrammarIDs;
+        RArray<TSILexiconID>* iLexiconIDs;
+
+        RArray<TSIModelBankID>* iModelBankIDs;
+        RArray<TSIModelID>* iModelIDs;
+        RArray<TSIPronunciationID>* iPronunciationIDs;
+        RArray<TSIRuleID>* iRuleIDs;
+
+        // End: data used in async handling of requests
+        
+        
+        // SI componet
+        CSIClientResultSet* iSIClientResultSet ;
+
+        TInt iCorrect;     
+        TPtrC iTrainTextPtr;
+        TLanguage iLanguage;
+        RArray<TLanguage>* iLanguageArray;
+        RArray<RLanguageArray>* iLanguageArrayArray;
+        MDesCArray *iTrainArray ;
+        RPointerArray<MDesCArray>* iTrainArrays;
+        CSITtpWordList* iSITtpWordList;    
+        RArray<TUint32> iMaxNPronunsForWord;
+        TPtrC8 iPronunciationPr;
+        CSICompiledGrammar *iSICompiledGrammar;
+        TSIPronunciationID* iLastAddedPronunciationIDPtr;
+        TSIRuleID* iLastAddedRuleIDPtr;
+
+        // recompile grammar during remove rule .
+        CSICompiledGrammar* iSICompiledGrammarRecompile; // Pointer to grammar to in remove rule
+        TSIGrammarID iGrammarIDRecompile;
+        TBool iIsGrammarRecompile;
+        TSIRuleID iRuleIDRemove;
+        TBool iIsRecompileGrammarActive;
+
+        // TTP data loader
+        
+        //CTTPDataLoader* iTtpLoader;
+        CDataLoader* iDataLoader;
+        
+        // Audio 
+        HBufC8* iAudioBuffer;
+        TInt iNSamplesSent;
+        TPtrC8 iCurrentAudioBuffer;
+        
+        TTimeIntervalMicroSeconds32 iRecordDurations;
+        //TSIRuleVariantID iRuleVariantID;
+         RDbNotifier iRDbNotifier;
+         
+#ifdef __SINDE_TRAINING         
+         // Class which takes care of SINDE type of training process
+         CSindeTrainer* iSindeTrainer;
+#endif // __SINDE_TRAINING
+    };
+    
+#endif // __CSIControllerPlugin_H__
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicontrollerplugininterface.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1031 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the main interface of the SI Controller Plugin.
+*
+*/
+
+
+// INCLUDE FILES
+#include "srsfbldvariant.hrh"
+#include <mmfcontrollerframeworkbase.h>
+#include <nsssispeechrecognitioncustomcommandparser.h>
+#include <implementationproxy.h>
+#include "sicontrollerplugininterface.h"
+#include "sicontrollerplugin.h"
+#include "sipluginimplementationuids.hrh"
+#include "rubydebug.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::CSIControllerPluginInterface
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CSIControllerPluginInterface::CSIControllerPluginInterface()
+    {
+    RUBY_DEBUG0( "CSIControllerPluginInterface::CSIControllerPluginInterface" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+#ifndef __CONSOLETEST__
+
+void CSIControllerPluginInterface::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPluginInterface::ConstructL" );
+    
+    iController = CSIControllerPlugin::NewL(*this);
+    
+    CSISpeechRecognitionCustomCommandParser* speechRecognitionParser =
+        CSISpeechRecognitionCustomCommandParser::NewL(*this);
+    CleanupStack::PushL(speechRecognitionParser);
+    AddCustomCommandParserL(*speechRecognitionParser);
+    // The parser is owned by the controller framework
+    CleanupStack::Pop(speechRecognitionParser);
+    }
+
+#else	// __CONSOLETEST__ defined
+
+// Unit Test
+void CSIControllerPluginInterface::ConstructL( MSrsObserver* aObserver )
+    {
+    iController = CSIControllerPlugin::NewL(*this);
+    iObserver = aObserver;
+    }
+
+// Unit Test
+void CSIControllerPluginInterface::ConstructL()
+    {
+    iController = CSIControllerPlugin::NewL(*this);
+    iObserver = NULL;
+    }
+
+#endif	// __CONSOLETEST__
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIControllerPluginInterface* CSIControllerPluginInterface::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIControllerPluginInterface::NewL" );
+    
+    CSIControllerPluginInterface* self = new( ELeave ) CSIControllerPluginInterface;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::~CSIControllerPluginInterface
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CSIControllerPluginInterface::~CSIControllerPluginInterface()
+    {
+    RUBY_DEBUG0( "CSIControllerPluginInterface::~CSIControllerPluginInterface" );
+    delete iController;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::AddDataSourceL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::AddDataSourceL( MDataSource& /*aDataSource*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::AddDataSinkL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::AddDataSinkL( MDataSink& /*aDataSink*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::RemoveDataSourceL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::RemoveDataSourceL( MDataSource& /*aDataSource*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::RemoveDataSinkL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::RemoveDataSinkL( MDataSink& /*aDataSink*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::ResetL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::ResetL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::PrimeL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::PrimeL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::PlayL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::PlayL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::PauseL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::PauseL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::StopL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::StopL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::PositionL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CSIControllerPluginInterface::PositionL() const
+    {
+    User::Leave( KErrNotSupported );
+    return TTimeIntervalMicroSeconds( 0 ); // Just to make the compiler happy
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::SetPositionL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::SetPositionL( const TTimeIntervalMicroSeconds& /*aPosition*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::DurationL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CSIControllerPluginInterface::DurationL() const
+    {
+    User::Leave( KErrNotSupported );
+    return TTimeIntervalMicroSeconds( 0 ); // Just to make the compiler happy
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::SetPrioritySettings
+// Set the priority settings for this controller.  This is used during recording
+// and playback.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings )
+    {
+    iController->SetPrioritySettings( aPrioritySettings );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::GetNumberOfMetaDataEntriesL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::GetNumberOfMetaDataEntriesL( TInt& /*aNumberOfEntries*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::GetMetaDataEntryL
+// This function is not supported.
+// -----------------------------------------------------------------------------
+//
+CMMFMetaDataEntry* CSIControllerPluginInterface::GetMetaDataEntryL( TInt /*aIndex*/ )
+    {
+    User::Leave( KErrNotSupported );
+    return NULL; // Just to make the compiler happy
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddPronunciationL
+// Adds a new pronunciation into the lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddPronunciationL( TSILexiconID aLexiconID,
+                                                         TSIModelBankID aModelBankID,
+                                                         TSIModelID aModelID,
+                                                         TSIPronunciationID& aPronunciationID )
+    {
+    iController->AddPronunciationL(aLexiconID, aModelBankID, aModelID, aPronunciationID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddRuleL
+// Adds a new rule into the grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddRuleL( TSIGrammarID /*aGrammarID*/,
+                                                TSILexiconID /*aLexiconID*/,
+                                                TSIPronunciationID /*aPronunciationID*/,
+                                                TSIRuleID& /*aRuleID*/ )
+    {
+    User::Leave( KErrNotSupported );	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrCancel
+// Cancels the current activity and returns the plugin to Idle state.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrCancel()
+    {
+    iController->Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrCommitTrainL
+// Training is complete.  Call model database handler to save the model into the
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrCommitChangesL()
+    {
+    iController->CommitChangesL( ETrue );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrCreateGrammarL
+// Creates a new grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrCreateGrammarL( TSIGrammarID& aGrammarID )
+    {
+    iController->CreateGrammarL( aGrammarID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrCreateLexiconL
+// Creates a new lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrCreateLexiconL( TSILexiconID& aLexiconID )
+    {
+    iController->CreateLexiconL( aLexiconID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrCreateModelBankL
+// Creates a new model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrCreateModelBankL( TSIModelBankID& aModelBankID )
+    {
+    iController->CreateModelBankL( aModelBankID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrEndRecSessionL
+// Ends recognition session and releases resources.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrEndRecSessionL()
+    {
+    iController->EndRecSessionL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllClientGrammarIDsL
+// Returns all grammar Ids that belong to the current client.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllClientGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    iController->GetAllClientGrammarIDsL( aGrammarIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllClientLexiconIDsL
+// Returns all lexicon Ids that belong to the current client.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllClientLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    iController->GetAllClientLexiconIDsL( aLexiconIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllClientModelBankIDsL
+// Returns all model bank Ids that belong to the current client.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllClientModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    iController->GetAllClientModelBankIDsL( aModelBankIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllGrammarIDsL
+// Returns all grammar Ids that exist (for all clients).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    iController->GetAllGrammarIDsL( aGrammarIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllLexiconIDsL
+// Returns all lexicon Ids that exist (for all clients).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    iController->GetAllLexiconIDsL( aLexiconIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllModelBankIDsL
+// Returns all model bank Ids that exist (for all clients).
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    iController->GetAllModelBankIDsL( aModelBankIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllModelIDsL
+// Gets all model IDs in the model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllModelIDsL( TSIModelBankID aModelBankID,
+                                                       RArray<TSIModelID>& aModelIDs )
+    {
+    iController->GetAllModelIDsL( aModelBankID, aModelIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllPronunciationIDsL
+// Gets all pronunciation IDs in the lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllPronunciationIDsL( TSILexiconID aLexiconID,
+                                                               RArray<TSIPronunciationID>& aPronunciationIDs )
+    {
+    iController->GetAllPronunciationIDsL( aLexiconID, aPronunciationIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAllRuleIDsL
+// Gets all rule IDs in the grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAllRuleIDsL( TSIGrammarID aGrammarID,
+                                                      RArray<TSIRuleID>& aRuleIDs )
+    {
+    iController->GetAllRuleIDsL( aGrammarID, aRuleIDs );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetAvailableStorageL
+// Calculates the available number of models that can be trained by subtracting
+// the current total from the system defined max.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetAvailableStorageL( TInt& /*aCount*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetEnginePropertiesL
+// Returns the current recognition engine properties.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+                                                            RArray<TInt>& aPropertyValue )
+    {
+    iController->GetEnginePropertiesL( aPropertyId, aPropertyValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetModelCountL
+// Gets the number of models in a model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetModelCountL( TSIModelBankID aModelBankID,
+													  TInt& aCount )
+    {
+    iController->GetModelCountL( aModelBankID, aCount );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetPronunciationCountL
+//  
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetPronunciationCountL( TSILexiconID aLexiconID, 
+                                                              TInt& aCount )
+    {
+    iController->GetPronunciationCountL( aLexiconID, aCount );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetRuleCountL
+//  
+// -----------------------------------------------------------------------------
+//	
+void CSIControllerPluginInterface::MSrGetRuleCountL( TSIGrammarID aGrammarID, TInt& aCount )
+    {
+    iController->GetRuleCountL(aGrammarID, aCount);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetRuleValidityL
+// Checks to see if a rule exists in the specified grammar or not.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetRuleValidityL( TSIGrammarID aGrammarID,
+                                                        TSIRuleID aRuleID,
+                                                        TBool& aValid )
+    {
+    iController->GetRuleValidityL(aGrammarID, aRuleID, aValid);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrGetUtteranceDurationL
+// Gets the duration of an utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrGetUtteranceDurationL( TSIModelBankID /*aModelBankID*/,
+                                                             TSIModelID /*aModelID*/,
+                                                             TTimeIntervalMicroSeconds32& /*aDuration*/ )
+    {
+    User::Leave(KErrNotSupported);	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrLoadEngineParametersL
+// Loads the specified recognizer parameter(s).  These parameters are used to
+// alter the recognizer's default parameters.  The parameters are specified as
+// attribute and value pairs.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrLoadEngineParametersL( const RArray<TInt>& aParameterId,
+                                                             const RArray<TInt>& aParameterValue )
+    {
+    iController->LoadEngineParametersL(aParameterId, aParameterValue);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrLoadGrammarL
+// Loads the specified grammar into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrLoadGrammarL( TSIGrammarID aGrammarID )
+    {
+    iController->LoadGrammarL(aGrammarID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrLoadLexiconL
+// Loads the specified lexicon into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrLoadLexiconL( TSILexiconID /*aLexiconID*/ )
+    {
+    User::Leave(KErrNotSupported);	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrLoadModelsL
+// Loads the specified model bank into the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrLoadModelsL( TSIModelBankID aModelBankID)
+    {
+    iController->LoadModelsL(aModelBankID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrActivateGrammarL
+//  
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrActivateGrammarL( TSIGrammarID aGrammarID )
+    {
+    iController->ActivateGrammarL(aGrammarID );
+    } 
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrDeactivateGrammarL
+//  
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrDeactivateGrammarL( TSIGrammarID aGrammarID )
+    {
+    iController->DeactivateGrammarL(aGrammarID);
+    } 
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrPlayUtteranceL
+// Plays the user utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrPlayUtteranceL( TSIModelBankID /*aModelBankID*/,
+                                                      TSIModelID /*aModelID*/ )
+    {
+    // Not supported in SI 
+    User::Leave(KErrNotSupported);	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRecognizeL
+// Initiates recognition towards the recognizer.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRecognizeL( CSDClientResultSet& /*aResultSet*/ )
+    {
+    // Not supported in SI 
+    User::Leave(KErrNotSupported);	
+    //	iController->RecognizeL(aResultSet);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRecordL
+// Initiates recording of user utterance.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime )
+    {
+    iController->RecordL(aRecordTime);
+    }
+    
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrPreStartSamplingL
+// Starts sampling
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrPreStartSamplingL()
+    {
+    iController->PreStartSamplingL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemoveGrammarL
+// Removes the specified grammar from the permanent storage.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemoveGrammarL( TSIGrammarID aGrammarID )
+    {
+    iController->RemoveGrammarL(aGrammarID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemoveLexiconL
+// Removes the specified lexicon from the permanent storage.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemoveLexiconL( TSILexiconID aLexiconID )
+    {
+    iController->RemoveLexiconL(aLexiconID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemoveModelBankL
+// Removes the specified model bank from the permanent storage.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemoveModelBankL( TSIModelBankID aModelBankID )
+    {
+    iController->RemoveModelBankL(aModelBankID);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemoveModelL
+// Removes the specified model from the specified model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemoveModelL( TSIModelBankID /*aModelBankID*/,
+                                                    TSIModelID /*aModelID*/ )
+    {
+    User::Leave(KErrNotSupported);	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemovePronunciationL
+// Removes the specified pronunciation from the specified lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemovePronunciationL( TSILexiconID aLexiconID,
+                                                            TSIPronunciationID aPronunciationID )
+    {
+    iController->RemovePronunciationL(aLexiconID, aPronunciationID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemoveRuleL
+// Removes the specified rule from the specified grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemoveRuleL( TSIGrammarID aGrammarID,
+                                                   TSIRuleID aRuleID )
+    {
+    iController->RemoveRuleL(aGrammarID, aRuleID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRemoveRulesL
+// Removes the specified rules from the specified grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRemoveRulesL( TSIGrammarID aGrammarID,
+                                                    RArray<TSIRuleID>& aRuleIDs )
+    {
+    //   User::Leave( KErrNotSupported );
+    iController->RemoveRulesL(aGrammarID, aRuleIDs);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrSetClientUid
+// Sets the client's UID for data ownership identification.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrSetClientUid( TUid aClientUid )
+    {
+    iController->SetClientUid(aClientUid);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrStartRecSessionL
+// Starts a new recognition session.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrStartRecSessionL( TNSSRecognitionMode aMode )
+    { 
+    if ( aMode == ENSSSiMode)
+        {
+        iController->StartRecSessionL();
+        }
+    else
+        {
+        User::Leave(KErrNotSupported);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrTrainL
+// Trains a new model into the specified model bank.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrTrainL( TSIModelBankID aModelBankID,
+                                              TSIModelID& aModelID )
+    {
+    iController->TrainL(aModelBankID, aModelID);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrUnloadRuleL
+// Unloads a rule from the recognizer for this recognition session.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrUnloadRuleL( TSIGrammarID aGrammarID,
+                                                   TSIRuleID aRuleID )
+    {
+    iController->UnloadRuleL(aGrammarID, aRuleID);
+    }
+
+
+///SI only functionalities
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAdaptL
+// Does speaker adapation to speaker independent models
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAdaptL( CSIClientResultSet& aResultSet,
+                                              TInt aCorrect)
+    {
+    iController->AdaptL( aResultSet, aCorrect );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddPronunciationL
+// AAdds a new pronunciation for the given model into the specified lexicon.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddPronunciationL( TSILexiconID aLexiconID, 
+                                                         const TDesC& aTrainText,
+                                                         TLanguage aLanguage, 
+                                                         TSIPronunciationID& aPronunciationID )
+    {
+    iController->AddPronunciationL( aLexiconID, aTrainText,aLanguage,aPronunciationID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddRuleVariantL
+// Adds a new rule variant for the given pronunciation into the specified grammar.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddRuleVariantL( TSIGrammarID aGrammarID, 
+                                                       TSILexiconID aLexiconID,
+                                                       RArray<TSIPronunciationID>& aPronunciationIDs,
+                                                       TSIRuleID aRuleID,
+                                                       TSIRuleVariantID& aRuleVariantID ) 
+    {
+    iController->AddRuleVariantL( aGrammarID, aLexiconID, aPronunciationIDs,
+                                  aRuleID, aRuleVariantID ) ;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddVoiceTagsL
+// Trains a new voice tag. The recognition phrase is the concatenation of words in the aTrainArray. 
+// Pronunciations are created with all given languages, which are supported.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,
+                                                     RArray<TLanguage>& aLanguageArray, 
+                                                     TSILexiconID aLexiconID,
+                                                     TSIGrammarID aGrammarID,
+                                                     RArray<TSIRuleID>& aRuleID ) 
+    {
+    iController->AddVoiceTagsL( *aTrainArray, aLanguageArray,   aLexiconID,
+                                 aGrammarID, aRuleID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddVoiceTagL
+// Trains a new voice tag.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddVoiceTagL( MDesCArray& aTrainArray, 
+                                                    RArray<TLanguage>& aLanguageArray, 
+                                                    TSILexiconID aLexiconID,
+                                                    TSIGrammarID aGrammarID, 
+                                                    TSIRuleID& aRuleID) 
+    {
+    iController->AddVoiceTagL( aTrainArray, aLanguageArray,   aLexiconID,
+                               aGrammarID,  aRuleID );
+    }
+
+#ifdef __SINDE_TRAINING
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddSindeVoiceTagL
+// Trains a new SINDE voice tag.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddSindeVoiceTagL( MDesCArray& aTrainArray,
+                                                         RArray<RLanguageArray>& aLanguageArray,
+                                                         TSILexiconID aLexiconID,
+                                                         TSIGrammarID aGrammarID,
+                                                         TSIRuleID& aRuleID )
+    {
+    iController->AddSindeVoiceTagL( aTrainArray, aLanguageArray,
+                                    aLexiconID, aGrammarID, aRuleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddSindeVoiceTagL
+// Trains a new SINDE voice tag.
+// -----------------------------------------------------------------------------
+//    
+void CSIControllerPluginInterface::CSIControllerPluginInterface::MSrAddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,
+                                                                                        RArray<RLanguageArray>& aLanguageArray,
+                                                                                        TSILexiconID aLexiconID,
+                                                                                        TSIGrammarID aGrammarID,
+                                                                                        RArray<TSIRuleID>& aRuleID )
+    {
+    iController->AddSindeVoiceTagsL( *aTrainArray, aLanguageArray,
+                                     aLexiconID, aGrammarID, aRuleID );
+    }
+
+#else // __SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddSindeVoiceTagL
+// Trains a new SINDE voice tag.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrAddSindeVoiceTagL( MDesCArray& /*aTrainArray*/,
+                                                         RArray<RLanguageArray>& /*aLanguageArray*/,
+                                                         TSILexiconID /*aLexiconID*/,
+                                                         TSIGrammarID /*aGrammarID*/,
+                                                         TSIRuleID& /*aRuleID*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrAddSindeVoiceTagL
+// Trains a new SINDE voice tag.
+// -----------------------------------------------------------------------------
+//    
+void CSIControllerPluginInterface::CSIControllerPluginInterface::MSrAddSindeVoiceTagsL( RPointerArray<MDesCArray>* /*aTrainArray*/,
+                                                                                        RArray<RLanguageArray>& /*aLanguageArray*/,
+                                                                                        TSILexiconID /*aLexiconID*/,
+                                                                                        TSIGrammarID /*aGrammarID*/,
+                                                                                        RArray<TSIRuleID>& /*aRuleID*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+#endif // __SINDE_TRAINING
+    
+
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrCreateRuleL
+// Creates a new empty rule.
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrCreateRuleL( TSIGrammarID aGrammarID, 
+                                                   TSIRuleID& aRuleID )  
+    {
+    iController->CreateRuleL( aGrammarID, aRuleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrRecognizeL
+// Initiates recognition; performed following loading of model bank, lexicon, and grammar
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrRecognizeL( CSIClientResultSet& aResultSet ) 
+    {
+    iController->RecognizeL( aResultSet );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrEndRecordL
+// Ends recording. Unlike Cancel(), this function may return a recognition
+// result if adequate number of samples was already recorded. 
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrEndRecordL() 
+    {
+    iController->EndRecordL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::MSrUnloadGrammarL
+// Unloads the specified grammar from the temporary memory, 
+// previously loaded with MSrLoadGrammarL. The grammar in the permanent storage remains intact. 
+// result if adequate number of samples was already recorded.		        
+// -----------------------------------------------------------------------------
+//
+void CSIControllerPluginInterface::MSrUnloadGrammarL( TSIGrammarID aGrammarID ) 
+    {
+    iController->UnloadGrammarL( aGrammarID ) ;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIControllerPluginInterface::SendSrsEvent
+// Sends an event to the client.
+// -----------------------------------------------------------------------------
+//
+#ifndef __CONSOLETEST__
+
+void CSIControllerPluginInterface::SendSrsEvent( TUid aEvent,
+                                                 TInt aResult )
+    {
+    RUBY_DEBUG2( "CSIControllerPluginInterface::SendSrsEvent: %d, result [%d]", aEvent, aResult );
+    TMMFEvent event( aEvent, aResult );
+    DoSendEventToClient( event );
+    }
+
+#else
+
+// Unit Test
+void CSIControllerPluginInterface::SendSrsEvent(
+                                                TUid aEvent,
+                                                TInt aResult )
+    {
+    iObserver->SrsEvent(aEvent, aResult);
+    }
+
+#endif
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+#ifdef __CONSOLETEST__
+// Unit Test
+
+// Two-phased constructor
+CSIControllerPluginInterface* CSIControllerPluginInterface::NewL(
+                                                                 MSrsObserver* aObserver )
+    {
+    CSIControllerPluginInterface* self = new( ELeave ) CSIControllerPluginInterface();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL(aObserver);
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+// Returns reference to a database
+RDbNamedDatabase& CSIControllerPluginInterface::GetDb()
+    {
+    return iController->GetDb();
+    }
+
+
+// Returns reference to model bank array
+RPointerArray<CSIModelBank>& CSIControllerPluginInterface::ModelBankArray()
+    {
+    return iController->ModelBankArray();
+    }
+
+// Returns current plugin state
+TInt CSIControllerPluginInterface::PluginState()
+    {
+    return iController->PluginState();
+    }
+
+#endif
+
+
+// __________________________________________________________________________
+// Exported proxy for instantiation method resolution
+// Define the interface UIDs
+
+#ifndef __CONSOLETEST__
+/**
+*
+* ImplementationTable
+*
+*/
+const TImplementationProxy ImplementationTable[] =
+    {
+        {{KSIUidController}, ( TProxyNewLPtr ) CSIControllerPluginInterface::NewL}		// defined in SIPluginImplementationUIDs.hrh
+    };
+
+/**
+* ImplementationGroupProxy
+* @param aTableCount
+* @returns "TImplementationProxy*"
+*/
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    
+    return ImplementationTable;
+    }
+
+#endif // __CONSOLETEST__
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicontrollerplugininterface.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,752 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the main interface of the SI Controller Plugin.
+*
+*/
+
+
+
+#ifndef SICONTROLLERPLUGININTERFACE_H
+#define SICONTROLLERPLUGININTERFACE_H
+
+// INCLUDES
+#include <mmfcontroller.h>
+#include <nsssispeechrecognitioncustomcommandimplementor.h>
+#include <nsssispeechrecognitiondataclient.h>
+
+// FORWARD DECLARATIONS
+class CSIControllerPlugin;
+class CSDClientResultSet;
+
+
+// CLASS DECLARATION
+
+/**
+*  This is the main interface class of SI Controller Plugin
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.8
+*/
+class CSIControllerPluginInterface : public CMMFController,
+public MSISpeechRecognitionCustomCommandImplementor
+{
+public:  // Constructors and destructor
+	
+    /**
+    * Two-phased constructor.
+	*/
+	static CSIControllerPluginInterface* NewL();
+	
+	/**
+	* Destructor.
+	*/
+	virtual ~CSIControllerPluginInterface();
+	
+public: // Functions from base classes
+	
+    /**
+    * From CMMFController
+    * Add a data source to the controller plugin.
+    * @since 2.8
+    * @param aDataSource reference to the data source to be added
+	*/
+	void AddDataSourceL( MDataSource& aDataSource );
+	
+	/**
+	* From CMMFController
+	* Add a data sink to the controller plugin. Not supported.
+	* @since 2.8
+	* @param	aDataSink			reference to the data sink to be added
+	*/
+	void AddDataSinkL( MDataSink& aDataSink );
+	
+	/**
+	* From CMMFController
+	* Remove a data source from the controller plugin. Not supported.
+	* @since 2.8
+	* @param	aDataSource			reference to the data source to be removed
+	*/
+	void RemoveDataSourceL( MDataSource& aDataSource );
+	
+	/**
+	* From CMMFController
+	* Remove a data sink from the controller plugin. Not supported.
+	* @since 2.8
+	* @param	aDataSink			reference to the data sink to be removed
+	*/
+	void RemoveDataSinkL( MDataSink& aDataSink );
+	
+	/**
+	* From CMMFController
+	* Reset the controller plugin. Not supported.
+	* @since 2.8
+	*/
+	void ResetL();
+	
+	/**
+	* From CMMFController
+	* Prime the controller plugin. Not supported.
+	* @since 2.8
+	*/
+	void PrimeL();
+	
+	/**
+	* From CMMFController
+	* Commence playback. Not supported.
+	* @since 2.8
+	*/
+	void PlayL();
+	
+	/**
+	* From CMMFController
+	* Pause the controller plugin. Not supported.
+	* @since 2.8
+	*/
+	void PauseL();
+	
+	/**
+	* From CMMFController
+	* Stop the controller plugin. Not supported.
+	* @since 2.8
+	*/
+	void StopL();
+	
+	/**
+	* From CMMFController
+	* Get the current position. Not supported.
+	* @since 2.8
+	*/
+	TTimeIntervalMicroSeconds PositionL() const;
+	
+	/**
+	* From CMMFController
+	* Set the current position. Not supported.
+	* @since 2.8
+	* @param	aPosition			desired position in microseconds
+	*/
+	void SetPositionL( const TTimeIntervalMicroSeconds& aPosition );
+	
+	/**
+	* From CMMFController
+	* Get the duration of the clip. Not supported.
+	* @since 2.8
+	*/
+	TTimeIntervalMicroSeconds DurationL() const;
+	
+	/**
+	* From CMMFController
+	* Set the priority settings for this controller.
+	* @since 2.8
+	* @param	aPrioritySettings	new priority settings
+	*/
+	void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings );
+	
+	/**
+	* From CMMFController
+	* Retrieve the number of meta data entries in the clip. Not supported.
+	* @since 2.8
+	* @param	aNumberOfEntries	reference where the number of entries is set
+	*/
+	void GetNumberOfMetaDataEntriesL( TInt& aNumberOfEntries );
+	
+	/**
+	* From CMMFController
+	*	Retrieve a meta data entry from the clip. Not supported.
+	* @since 2.8
+	* @param	aIndex				index of the meta data entry to retrieve
+	*/
+	CMMFMetaDataEntry* GetMetaDataEntryL( TInt aIndex );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Adds a new pronunciation for the given model into the specified lexicon.
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id, where the new pronunciation is added to
+	* @param	aModelBankID		model bank Id
+	* @param	aModelID			model Id
+	* @param	aPronunciationID	reference where a new pronunciation Id is assigned to
+	*/
+	//SD Remove
+	void MSrAddPronunciationL( TSILexiconID aLexiconID, TSIModelBankID aModelBankID,
+		TSIModelID aModelID,TSIPronunciationID& aPronunciationID );
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Adds a new rule for the given pronunciation into the specified grammar.
+    * @since 2.8
+    * @param	aGrammarID			grammar Id, where the new rule is added to
+    * @param	aLexiconID			lexicon Id
+    * @param	aPronunciationID	pronunciation Id
+    * @param	aRuleID				reference where a new rule Id is assigned to
+	*/
+	//SD Remove
+	void MSrAddRuleL( TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+		TSIPronunciationID aPronunciationID, TSIRuleID& aRuleID );
+	
+	/**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Cancels the current activity and returns the plugin to Idle state.
+    * @since 2.8
+	*/
+	void MSrCancel();
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Commits (saves) the current trained model into a permanent storage.
+	* @since 2.8
+	*/
+	void MSrCommitChangesL();
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Creates a new grammar.
+	* @since 2.8
+	* @param	aGrammarID			reference where a new rule Id is assigned to
+	*/
+	void MSrCreateGrammarL( TSIGrammarID& aGrammarID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Creates a new lexicon.
+	* @since 2.8
+	* @param	aLexiconID			reference where a new lexicon Id is assigned to
+	*/
+	void MSrCreateLexiconL( TSILexiconID& aLexiconID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Creates a new model bank.
+	* @since 2.8
+	* @param	aModelBankID		reference where a new model bank Id is assigned to
+	*/
+	void MSrCreateModelBankL( TSIModelBankID& aModelBankID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Ends the current recognition session.  Resources allocated for recognition are freed.
+	* @since 2.8
+	* @param	aModelBankID		reference where a new model bank Id is assigned to
+	*/
+	void MSrEndRecSessionL();
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all grammar Ids that belong to the current client, whose UID was set
+	* with MSrSetClientUid().
+	* @since 2.8
+	* @param	aGrammarIDs			reference where grammar Ids are stored
+	*/
+	void MSrGetAllClientGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all lexicon Ids that belong to the current client, whose UID was set
+	* with MSrSetClientUid().
+	* @since 2.8
+	* @param	aLexiconIDs			reference where lexicon Ids are stored
+	*/
+	void MSrGetAllClientLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all model bank Ids that belong to the current client, whose UID was set
+	* with MSrSetClientUid().
+	* @since 2.8
+	* @param	aModelBankIDs		reference where model bank Ids are stored
+	*/
+	void MSrGetAllClientModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all grammar Ids that exist (for all clients).
+	* @since 2.8
+	* @param	aGrammarIDs			reference where grammar Ids are stored
+	*/
+	void MSrGetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all lexicon Ids that exist (for all clients).
+	* @since 2.8
+	* @param	aLexiconIDs			reference where lexicon Ids are stored
+	*/
+	void MSrGetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all model bank Ids that exist (for all clients).
+	* @since 2.8
+	* @param	aModelBankIDs		reference where model bank Ids are stored
+	*/
+	void MSrGetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all model Ids that exist in the specified model bank.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	* @param	aModelIDs			reference where model Ids are stored
+	*/
+	//SD
+	void MSrGetAllModelIDsL( TSIModelBankID aModelBankID, RArray<TSIModelID>& aModelIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns all pronunciation Ids that exist in the specified lexicon.
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id
+	* @param	aPronunciationIDs	reference where pronunciation Ids are stored
+	*/
+	void MSrGetAllPronunciationIDsL( TSILexiconID aLexiconID,
+		RArray<TSIPronunciationID>& aPronunciationIDs );
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Returns all rule Ids that exist in the specified grammar.
+    * @since 2.8
+    * @param	aGrammarID			grammar Id
+    * @param	aRuleIDs			reference where rule Ids are stored
+	*/
+	void MSrGetAllRuleIDsL( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns the number of models available for training system wide, based on
+	* available disk space.
+	* @since 2.8
+	* @param	aCount				reference where the number of available models is set
+	*/
+	//SD
+	void MSrGetAvailableStorageL( TInt& aCount );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns the engine properties specified by the engine property ID array.
+	* On return aPropertyValue contains an array of engine properties.
+	* @since 2.8
+	* @param	aPropertyId			constant reference to array of engine property Ids
+	* @param	aPropertyValue		reference to array of engine property values
+	*/
+	void MSrGetEnginePropertiesL( const RArray<TInt>& aPropertyId,
+		RArray<TInt>& aPropertyValue );
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Returns the number of models in the specified model bank.
+    * @since 2.8
+    * @param	aModelBankID		model bank Id
+    * @param	aCount				reference where the number of models is set
+	*/
+	//SD
+	void MSrGetModelCountL( TSIModelBankID aModelBankID, TInt& aCount );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Checks if the rule is valid or not.
+	* @since 2.8
+	* @param	aGrammarID			grammar Id
+	* @param	aRuleID				rule Id
+	* @param	aValid				reference where the validity of the rule is set
+	*/
+	void MSrGetRuleValidityL( TSIGrammarID aGrammarID, TSIRuleID aRuleID, TBool& aValid );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Returns the duration of the utterance for the specified model.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	* @param	aModelID			model Id
+	* @param	aDuration			reference where the duration of utterance is set
+	*/
+	//SD
+	void MSrGetUtteranceDurationL( TSIModelBankID aModelBankID, TSIModelID aModelID,
+		TTimeIntervalMicroSeconds32& aDuration );
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Loads the specified recognizer parameter(s).  These parameters are used to
+    * alter the recognizer's default parameters.  The parameters are specified as
+    * attribute and value pairs.
+    * @since 2.8
+    * @param	aParameterID		list of parameter Ids
+    * @param	aParameterValue		list of parameter values
+	*/
+	void MSrLoadEngineParametersL( const RArray<TInt>& aParameterId,
+		const RArray<TInt>& aParameterValue );
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Loads the specified grammar into the recognizer; done prior to recognition.
+    * @since 2.8
+    * @param	aGrammarID			grammar Id
+	*/
+	void MSrLoadGrammarL( TSIGrammarID aGrammarID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Loads the specified lexicon into the recognizer; done prior to recognition.
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id
+	*/
+	void MSrLoadLexiconL( TSILexiconID aLexiconID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Loads the specified model bank into the recognizer; done prior to recognition.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	*/
+	void MSrLoadModelsL( TSIModelBankID aModelBankID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Plays the previously trained utterance.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	* @param	aModelID			model Id, whose utterance is played
+	*/
+	//SD
+	void MSrPlayUtteranceL( TSIModelBankID aModelBankID, TSIModelID aModelID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Initiates recognition; performed following loading of model bank, lexicon, and grammar.
+	* @since 2.8
+	* @param	aResultSet			reference where the recognition result is set
+	*/
+	//SD
+	void MSrRecognizeL( CSDClientResultSet& aResultSet );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Records uder utterance for training and recognition.
+	* @since 2.8
+	* @param	aRecordTime			recording time in microseconds
+	*/
+	void MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime );
+	
+    /**
+	* From MSISpeechRecognitionCustomCommandImplementor.
+	* Starts sampling before MSrRecordL call.
+	*
+	* @since 3.2
+	*/
+	void MSrPreStartSamplingL();	
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Removes the specified grammar from the permanent storage.
+	* Removing a grammar will remove all rules within the grammar.
+	* @since 2.8
+	* @param	aGrammarID			grammar Id
+	*/
+	void MSrRemoveGrammarL( TSIGrammarID aGrammarID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Removes the specified lexicon from the permanent storage.
+	* Removing a lexicon will remove all pronunciations within the lexicon.
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id
+	*/
+	void MSrRemoveLexiconL( TSILexiconID aLexiconID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Removes the specified model bank from the permanent storage.
+	* Removing a model bank will remove all models within the model bank.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	*/
+	void MSrRemoveModelBankL( TSIModelBankID aModelBankID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Removes the specified model from the specified model bank.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	* @param	aModelID			model Id
+	*/
+	//SD
+	void MSrRemoveModelL( TSIModelBankID aModelBankID, TSIModelID aModelID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Removes the specified pronunciation from the specified lexicon.
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id
+	* @param	aPronunciationID	pronunciation Id
+	*/
+	void MSrRemovePronunciationL( TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Removes the specified rule from the specified grammar.
+	* @since 2.8
+	* @param	aGrammarID			grammar Id
+	* @param	aRuleID				rule Id
+	*/
+	void MSrRemoveRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+	
+    /**
+	* From MSISpeechRecognitionCustomCommandImplementor
+    * Removes the specified rules from the specified grammar permanently.
+    * If the rule contains rule variants, they are also destoryed.
+    * @since	2.8
+    * @param	aGrammarID			grammar Id
+    * @param	aRuleIDs			array of rule ids
+    */
+    void MSrRemoveRulesL( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Sets the client's UID for data ownership identification.
+	* @since 2.8
+	* @param	aClientUid			client's UID
+	*/
+	void MSrSetClientUid( TUid aClientUid );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Starts a new recognition session.
+	* @since 2.8
+	* @param	aMode				recognition mode
+	*/
+	void MSrStartRecSessionL( TNSSRecognitionMode aMode );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Trains a new model into the specified model bank.
+	* @since 2.8
+	* @param	aModelBankID		model bank Id
+	* @param	aModelID			reference where a new model Id is assigned to
+	*/
+	//SD
+	void MSrTrainL( TSIModelBankID aModelBankID, TSIModelID& aModelID );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Unloads the specified rule from the specified grammar in temporary memory, previously
+	* loaded with LoadGrammarL.  The rule in the permanent storage remains intact.
+	* @since 2.8
+	* @param	aGrammarID			grammar Id
+	* @param	aRuleID				rule Id
+	*/
+	void MSrUnloadRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+	
+	///SI Component
+	
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Does speaker adapation to speaker independent models
+	* @since 2.8
+	* @param	aResultSet			a recognition result containing adaptation data
+	* @param	aCorrect			identifies the correct recognition result from the N-best list.
+	*/           
+	void MSrAdaptL( CSIClientResultSet& aResultSet ,TInt aCorrect);
+
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Adds a new pronunciation for the given model into the specified lexicon.
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id
+	* @param	aTrainText:			the text to be trained
+ 	* @param	aLanguage			the pronunciation language	
+	* @param	aPronunciationID: reference where a new pronunciation identifier is set.
+	*/
+	void MSrAddPronunciationL(TSILexiconID aLexiconID, const TDesC& aTrainText,
+		TLanguage aLanguage, TSIPronunciationID& aPronunciationID) ;
+	
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Adds a new rule variant for the given pronunciation into the specified grammar.
+    * @since 2.8
+    * @param	aGrammarID			grammar Id, where the new rule is added to
+    * @param	aLexiconID			lexicon Id
+    * @param	aPronunciationIDs	pronunciation Id array
+    * @param	aRuleVariantID		reference where a new rule Variant Id is assigned to
+	*/
+	void MSrAddRuleVariantL(TSIGrammarID aGrammarID, TSILexiconID aLexiconID,
+		RArray<TSIPronunciationID>& aPronunciationIDs, TSIRuleID aRuleID, TSIRuleVariantID& aRuleVariantID );
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Trains a new voice tag. The recognition phrase is the concatenation of words in the aTrainArray. 
+    * Pronunciations are created with all given languages, which are supported.
+    * @since 2.8
+    * @param	aTrainArray:		Recognition phrase is formed by concatenating the descriptors in this array.
+    * @param	aLanguageArray		Pronunciations are created with these languages. Not all languages are supported. The argument can be NULL.
+    * @param	aLexiconID			lexicon Id
+    * @param	aGrammarID			grammar Id, where the new rule is added to
+    * @param	aRuleID		reference where a new rule Id is assigned to
+	*/
+	void MSrAddVoiceTagL( MDesCArray& aTrainArray,  RArray<TLanguage>& aLanguageArray, 
+		TSILexiconID aLexiconID, TSIGrammarID aGrammarID, TSIRuleID& aRuleID);
+	
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Adds several new voice tags.
+    * @since 2.8
+    * @param	aTrainArray : An array of MDesCArrays. The recognition phrases are formed by concatenating the descriptors in the MDesCArrays.
+    * @param	aLanguageArray		Pronunciations are created with these languages. Not all languages are supported. The argument can be NULL.
+    * @param	aLexiconID			lexicon Id
+    * @param	aGrammarID			grammar Id, where the new rule is added to
+    * @param	aRuleID		reference where a new rule Id is assigned to
+	*/
+	void MSrAddVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,  RArray<TLanguage>& aLanguageArray, TSILexiconID aLexiconID,
+		TSIGrammarID aGrammarID,  RArray<TSIRuleID>& aRuleID );
+	
+	/**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Creates a new empty rule.
+    * @since 2.8
+    * @param	aGrammarID			grammar Id, where the new rule is added to
+    * @param	aRuleID		reference where a new rule Id is assigned to
+	*/
+	void MSrCreateRuleL( TSIGrammarID aGrammarID, TSIRuleID& aRuleID );
+
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Initiates recognition; performed following loading of model bank, lexicon, and grammar.
+	* @since 2.8
+	* @param	aResultSet: reference where the recognition result is set. 
+	*/		
+	void MSrRecognizeL( CSIClientResultSet& aResultSet );
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Ends recording. Unlike Cancel(), this function may return a recognition 
+	* result if adequate number of samples was already recorded.		
+	* @since 2.8
+	*/				
+	void MSrEndRecordL();
+	
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Unloads the specified grammar from the temporary memory, 
+	* previously loaded with MSrLoadGrammarL. The grammar in the permanent storage remains intact. 
+	* result if adequate number of samples was already recorded.		
+	* @since 2.8
+	* @param	aGrammarID			grammar Id,  
+	*/	
+	void MSrUnloadGrammarL( TSIGrammarID aGrammarID );
+		
+	/**
+	* From MSISpeechRecognitionCustomCommandImplementor
+	* Activiate specified grammar after deactivating. 	
+	* @since 2.8
+	* @param	aGrammarID			grammar Id,  
+	*/	
+	void MSrActivateGrammarL( TSIGrammarID aGrammarID );
+			
+	/**
+	* 
+	* Deactivates a specified grammar.
+	* @since 2.8
+	* @param	aGrammarID			grammar Id,  
+	*/	
+	void MSrDeactivateGrammarL( TSIGrammarID aGrammarID );
+				
+	/**
+	* 
+	* Get the number of Pronunciations in the lexicon  
+	* @since 2.8
+	* @param	aLexiconID			lexicon Id, 
+	* @param	aCount				number of pronunciations, 		
+	*/	
+	void MSrGetPronunciationCountL( TSILexiconID aLexiconID, TInt& aCount );
+	
+	/**
+	* 
+	* Get the number of rules in the Grammar 
+	* @since 2.8
+	* @param	aGrammarID			grammar Id, 
+	* @param	aCount				number of rules, 		
+	*/	
+	void MSrGetRuleCountL( TSIGrammarID aGrammarID, TInt& aCount );
+
+    
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Trains one SINDE voice tag. Adds the text to the lexicon, and 
+    * creates the required rules and rule variants.
+    * 
+    * @since 3.1
+    * @param aTrainArray The phrase to be trained, split into subwords
+    * @param aLanguageArray The pronunciation languages for each of the 
+    * @param aLexiconID Lexicon identifier
+    * @param aGrammarID Grammar identifier
+    * @param aRuleID Reference, where the new rule identifier is assigned to.
+    */
+    void MSrAddSindeVoiceTagL( MDesCArray& aTrainArray,
+                               RArray<RLanguageArray>& aLanguageArray,
+                               TSILexiconID aLexiconID,
+                               TSIGrammarID aGrammarID,
+                               TSIRuleID& aRuleID );
+    
+    /**
+    * From MSISpeechRecognitionCustomCommandImplementor
+    * Trains SINDE voice tags. If the training fails for some of the names
+    * (but not all), it is signaled by setting the Rule ID to KInvalidRuleID.
+    * 
+    * @since 3.1
+    * @param aTrainArray The phrase to be trained, split into subwords
+    * @param aLanguageArray The pronunciation languages
+    * @param aLexiconID Lexicon identifier
+    * @param aGrammarID Grammar identifier
+    * @param aRuleID Referenceto an array, where the new
+    *                rule identifiers are assigned to.
+    */
+    void MSrAddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArray,
+                                RArray<RLanguageArray>& aLanguageArray,
+                                TSILexiconID aLexiconID,
+                                TSIGrammarID aGrammarID,
+                                RArray<TSIRuleID>& aRuleID );
+    
+    
+	public: // New functions
+		
+        /**
+        * Sends an event to the client.
+        * @since 2.8
+        * @param	aEvent				event
+        * @param	aResult				result
+        */
+        void SendSrsEvent( TUid aEvent, TInt aResult );
+	
+    private:
+		
+        /**
+        * C++ default constructor.
+        */
+        CSIControllerPluginInterface();
+		
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+		
+		
+    private:    // Data
+		
+		// SI Controller Plugin Implementation
+		CSIControllerPlugin* iController;
+
+    };
+	
+#endif // SICONTROLLERPLUGININTERFACE_H
+	
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sicontrollerresource.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Structure definition for resource file.
+*
+*/
+
+
+//  INCLUDES
+#include "sipluginimplementationuids.hrh"
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// SICONTROLLER_INFO
+// Structure definition for SIControllerPlugin resource file.
+// -----------------------------------------------------------------------------
+//
+STRUCT SICONTROLLER_INFO
+    {
+    /*LONG	voice_encoder_uid = KUidCodecPCM16ToGSM610;	// GSM 6.10 FR encoder
+    LONG	voice_decoder_uid = KUidCodecGSM610ToPCM16;	// GSM 6.10 FR decoder
+    WORD	compression_rate = -1;				// NotSupported by default	
+    */
+	WORD	max_models_per_bank;
+	
+    WORD	max_models_in_system;
+ 	LTEXT	db_file_name;
+	LTEXT	data_file_name_prefix;
+	LTEXT	data_file_name_postfix;
+	LTEXT	data_file_name_seperator;
+    WORD	user_define_1;					// Reserved
+    WORD	user_define_2;					// Reserved
+    WORD	user_define_3;					// Reserved
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sidatabase.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,514 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the SI Controller Plugin database.
+*
+*/
+
+
+// INCLUDE FILES
+#include "sidatabase.h"
+#include "rubydebug.h"
+#include "nssbackupobserver.h"
+
+
+// CONSTANTS
+// Estimate size in bytes for an empty database
+// const TInt KSizeEstimateDb = 650;
+
+// Plugin database format string for secure DBMS
+_LIT( KPluginDatabaseFormatString, "SECURE[10201AFF]" );
+
+// Name of the DB lock mutex
+_LIT( KLockMutex, "SIDATABASE" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::CSIDatabase
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIDatabase::CSIDatabase( TFileName aDatabaseFileName )
+                        : iOpenTransaction( EFalse ),
+                          iDatabaseFileName( aDatabaseFileName ),
+                          iDatabaseOpen( EFalse )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CSIDatabase::ConstructL" );
+    // Checks to see if the Database already exists.  If not, it creates one.
+    User::LeaveIfError( iDbSession.Connect() );
+    CreateDatabaseL();
+    OpenDatabaseL();
+    
+    TInt err = iMutex.OpenGlobal( KLockMutex );
+    if ( err != KErrNone )
+        {
+        RUBY_DEBUG0( "CSIDatabase::ConstructL Creating new global mutex" );
+        iMutex.CreateGlobal( KLockMutex );
+        }
+    else
+        {
+        RUBY_DEBUG0( "CSIDatabase::ConstructL Using existing global mutex" );
+        }
+        
+    iCriticalSection.CreateLocal();
+    iBackupObserver = CNssBackupObserver::NewL( *this );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIDatabase* CSIDatabase::NewL( TFileName aSDDatabaseFileName )
+    {
+    RUBY_DEBUG_BLOCKL( "CSIDatabase::NewL" );
+    
+    CSIDatabase* self = new( ELeave ) CSIDatabase( aSDDatabaseFileName );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::Rollback
+// Rollback all changes to the database. 
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::Rollback()
+    {
+    RUBY_DEBUG0( "CSIDatabase::Rollback" );
+    if ( iOpenTransaction )
+        {
+        iDb.Rollback();
+        // Try to recover the database, if it is damaged
+        if( iDb.IsDamaged() )
+            {
+            iDb.Recover();
+            }
+        iMutex.Signal();
+        iCriticalSection.Signal();
+        iOpenTransaction = EFalse;
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::~CSIDatabase
+// Destructor 
+// -----------------------------------------------------------------------------
+//
+CSIDatabase::~CSIDatabase()
+    {
+    // Rollback if there are any changes not commited
+    if ( iOpenTransaction )
+        {
+        iDb.Rollback();
+        // Try to recover the database, if it is damaged
+        if( iDb.IsDamaged() )
+            {
+            iDb.Recover();
+            }
+        // Signal mutex if somebody happens to be waiting in BeginTransactionL()
+        iMutex.Signal();
+        }
+        
+    delete iBackupObserver;
+    iCriticalSection.Close();
+
+    iDb.Close();
+    iDbSession.Close();
+    iDatabaseOpen = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::BeginTransactionL
+// Begins a database transaction if not already. Waits until exclusive write lock
+// has been gained.
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::BeginTransactionL()
+    {
+   
+
+    if ( iOpenTransaction )
+        {
+        // If we already have the lock, no need to take it again
+        RUBY_DEBUG0( "CSIDatabase::BeginTransactionL DB is already locked by current process" );
+        return;
+        }
+    
+    // Take mutex to ensure that only one process tries to gain the lock
+    iMutex.Wait();
+    iCriticalSection.Wait();
+    
+    // Taking the global mutex makes it sure that this should succeed every time
+    TInt readLockErr = iDb.Begin();
+
+    if ( readLockErr == KErrNone )
+        {
+        iOpenTransaction = ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::CommitChangesL
+// Commits all changes to the database.
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::CommitChangesL( TBool aCompact )
+    {
+    if ( iOpenTransaction )
+        {
+        TInt err = iDb.Commit();
+        
+        RUBY_DEBUG1( "CSIDatabase::CommitChangesL iDb.Commit() [%d]", err );
+        
+        if ( err != KErrNone )
+            {
+            iDb.Rollback();
+            // Try to recover the database, if it is damaged
+            if( iDb.IsDamaged() )
+                {
+                iDb.Recover();
+                }
+                
+            iMutex.Signal();
+            iCriticalSection.Signal();  
+            iOpenTransaction = EFalse;
+            User::Leave( err );
+            }
+        
+        if ( aCompact )
+            {
+            RUBY_DEBUG0( "CSIDatabase::CommitChangesL compacting DB" );
+            TInt error = iDb.Compact();
+            if ( error != KErrNone )
+                {
+                RUBY_DEBUG1( "CSIDatabase::CommitChangesL compact error: [%d]", error );
+                }
+            }
+        
+        // Signal waiting BeginTransactionL()
+        iMutex.Signal();
+        iCriticalSection.Signal();  
+        iOpenTransaction = EFalse;
+        
+        User::LeaveIfError( err );
+        }
+        
+          
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DoIDTablesExistL
+// Checks to see if ID tables exist.
+// -----------------------------------------------------------------------------
+//
+TBool CSIDatabase::DoIDTablesExistL()
+    {
+    // Get db table names list
+    CDbTableNames* table_names = iDb.TableNamesL();
+    TInt count = table_names->Count();
+    delete table_names;
+    // 1 is for the lock table!
+    return ( count > 1 );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DoesLockTableExistL
+// Checks to see if lock table exists
+// -----------------------------------------------------------------------------
+//
+TBool CSIDatabase::DoesLockTableExistL()
+    {
+    // Get db table names list
+    CDbTableNames* table_names = iDb.TableNamesL();
+    TInt count = table_names->Count();
+
+    for ( TInt counter = 0 ; counter < count ; counter++ )
+        {
+        if ( (*table_names)[counter] == _L( "writelocktable" ) )
+            {
+            delete table_names;
+            return ETrue;
+            }
+        }
+
+    delete table_names;
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DoesModelBankTableExistL
+// Checks to see if model bank table exists
+// -----------------------------------------------------------------------------
+//
+TBool CSIDatabase::DoesModelBankTableExistL()
+    {
+    // Get db table names list
+    CDbTableNames* table_names = iDb.TableNamesL();
+    TInt count = table_names->Count();
+
+    for ( TInt counter = 0 ; counter < count ; counter++ )
+        {
+        if ( (*table_names)[counter] == _L( "siModelBankIdTable" ) )
+            {
+            delete table_names;
+            return ETrue;
+            }
+        }
+
+    delete table_names;
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DoesLexiconTableExistL
+// Checks if lexicon table exists
+// -----------------------------------------------------------------------------
+//
+TBool CSIDatabase::DoesLexiconTableExistL()
+    {
+    // Get db table names list
+    CDbTableNames* table_names = iDb.TableNamesL();
+    TInt count = table_names->Count();
+
+    for ( TInt counter = 0 ; counter < count ; counter++ )
+        {
+        if ( (*table_names)[counter] == _L( "siLexiconIdTable" ) )
+            {
+            delete table_names;
+            return ETrue;
+            }
+        }
+
+    delete table_names;
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DoesGrammarTableExistL
+// Checks if grammar table exists
+// -----------------------------------------------------------------------------
+//
+TBool CSIDatabase::DoesGrammarTableExistL()
+    {
+    // Get db table names list
+    CDbTableNames* table_names = iDb.TableNamesL();
+    TInt count = table_names->Count();
+
+    for ( TInt counter = 0 ; counter < count ; counter++ )
+        {
+        if ( (*table_names)[counter] == _L( "siGrammarIdTable" ) )
+            {
+            delete table_names;
+            return ETrue;
+            }
+        }
+
+    delete table_names;
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::SIDatabase
+// Returns a reference to the database.
+// -----------------------------------------------------------------------------
+//
+RDbNamedDatabase& CSIDatabase::SIDatabase()
+    {
+    return iDb;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::CreateDatabaseL
+// Creates a database file if one does not exist yet.
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::CreateDatabaseL()
+    {
+    RUBY_DEBUG_BLOCKL( "CSIDatabase::CreateDatabaseL" );
+    
+    // Get the drive of the database file
+    iDatabaseDrive = EDriveC;
+    if ( iDatabaseFileName.Locate( 'c' ) == 0 || iDatabaseFileName.Locate( 'C' ) == 0 )
+        {
+        iDatabaseDrive = EDriveC;
+        }
+    else if ( iDatabaseFileName.Locate( 'd' ) == 0 || iDatabaseFileName.Locate( 'D' ) == 0 )
+        {
+        iDatabaseDrive = EDriveD;
+        }
+    else if ( iDatabaseFileName.Locate( 'z' ) == 0 || iDatabaseFileName.Locate( 'Z' ) == 0 )
+        {
+        iDatabaseDrive = EDriveZ;
+        }
+    
+    else if ( iDatabaseFileName.Locate( 'e' ) == 0 || iDatabaseFileName.Locate( 'E' ) == 0 )
+        {
+        iDatabaseDrive = EDriveE;
+        }
+    else
+        {
+        User::Leave( KErrPathNotFound );
+        }
+    
+    RDbNamedDatabase database;
+    TInt ret = database.Create( iDbSession, iDatabaseFileName, KPluginDatabaseFormatString );
+    if ( ret == KErrAlreadyExists )
+        {
+        // Ignore KErrAlreadyExists, we will use the existing one if it is there
+        ret = KErrNone;
+        }
+    database.Close();
+    User::LeaveIfError( ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::OpenDatabaseL
+// Opens the database.
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::OpenDatabaseL()
+    {
+    if ( !iDatabaseOpen )
+        {
+        
+        User::LeaveIfError( iDb.Open( iDbSession, iDatabaseFileName, KPluginDatabaseFormatString ) );
+        
+        // Try to recover the database, if it is damaged
+        if( iDb.IsDamaged() )
+            {
+            RUBY_DEBUG0( "CSIDatabase::OpenDatabaseL - Db is damaged. Attempt to recover." );
+            
+            User::LeaveIfError( iDb.Recover() );
+            }
+        
+        iDatabaseOpen = ETrue;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSIDatabase::CloseDatabase
+// Closes the database.
+// -----------------------------------------------------------------------------
+//
+TInt CSIDatabase::CloseDatabase()
+    {
+    RUBY_DEBUG0( "CSIDatabase::CloseDatabase" ); 
+  
+    iDb.Close();
+    iDatabaseOpen = EFalse;
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DbSession
+// Return reference to DB session.
+// -----------------------------------------------------------------------------
+//
+RDbs& CSIDatabase::DbSession()
+    {
+    return iDbSession;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::DbDrive
+// Returns a drive for DB file.
+// -----------------------------------------------------------------------------
+//
+TInt CSIDatabase::DbDrive()
+    {
+    return iDatabaseDrive;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::CreateLockTableL
+// Creates a dummy table to gain write-lock at the beginning of each transaction.
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::CreateLockTableL()
+    {
+    // Create writelocktable
+    // This table is accessed every time when transaction starts to gain
+    // exclusive locking of the DB
+    _LIT( KWriteLockTable, "writelocktable" );
+    
+    _LIT( KCol1, "temporary" );
+    
+    OpenDatabaseL();
+    
+    // Create the rrd tables definition (columnset).
+    CDbColSet* columns = CDbColSet::NewLC();
+    
+    // The tag id 
+    TDbCol dbCol1( KCol1, EDbColUint32 );
+    columns->AddL( dbCol1 );
+    
+    User::LeaveIfError( iDb.CreateTable( KWriteLockTable, *columns ) );
+    
+    // Cleanup columns
+    CleanupStack::PopAndDestroy( columns ); 
+    }
+    
+// -----------------------------------------------------------------------------
+// CSIDatabase::LockTransactionsL
+// Permit transactions and release database
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::LockTransactionsL()
+    {
+    // lock transactions
+    RUBY_DEBUG_BLOCK( "CSIDatabase::LockTransactionsL" );
+    
+    iCriticalSection.Wait(); // wait until a possible transaction ends
+            
+    // release a database
+    CloseDatabase();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIDatabase::UnlockTransactionsL
+// Allow transactions and reserve database
+// -----------------------------------------------------------------------------
+//
+void CSIDatabase::UnlockTransactionsL()
+    {
+    // unlock transactions
+    RUBY_DEBUG_BLOCK( "CSIDatabase::UnlockTransactionsL" );
+    OpenDatabaseL(); // open database
+    
+    if ( iCriticalSection.IsBlocked() )
+        {        
+        iCriticalSection.Signal(); // allow to do transactions
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sidatabase.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,211 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the SI Controller Plugin database.
+*
+*/
+
+
+
+#ifndef SIDATABASE_H
+#define SIDATABASE_H
+
+//  INCLUDES
+#include <d32dbms.h>
+#include <e32svr.h>
+#include <sysutil.h> // Critical Level check
+#include <f32file.h>
+
+
+class CNssBackupObserver;
+
+// CLASS DECLARATION
+
+/**
+*  This class is the base class for all SI Controller Plugin DB classes.
+*  It provides the common functionality for the DB classes.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.8
+*/
+class CSIDatabase : public CBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CSIDatabase* NewL(TFileName aDatabaseFileName);
+
+ 		/**
+        * Destructor.
+        */
+        virtual ~CSIDatabase();
+
+    public: // New functions
+
+        /**
+        * Begins a database transaction if not already.
+        * @since 2.8
+        * @return	Reference to the database.
+        */
+		void BeginTransactionL();
+
+        /**
+        * Commits all changes to the database.
+        * @since 2.8
+        */
+		void CommitChangesL( TBool aCompact );
+
+        /**
+        * Rollback all changes to the database.
+        * @since 2.8
+        */
+		void Rollback();
+
+        /**
+        * Checks to see if ID tables exist.
+        * @since 2.8
+        * @return	ETrue if ID tables exist; EFalse otherwise.
+        */
+		TBool DoIDTablesExistL();
+
+        /**
+        * @todo Add comments
+        */
+        TBool DoesLockTableExistL();
+
+        /**
+        * @todo Add comments
+        */
+        TBool DoesModelBankTableExistL();
+
+        /**
+        * @todo Add comments
+        */
+        TBool DoesLexiconTableExistL();
+
+        /**
+        * @todo Add comments
+        */
+        TBool DoesGrammarTableExistL();
+
+
+        /**
+        * Returns a reference to the database.
+        * @since 2.8
+        * @return	Reference to the database.
+        */
+		RDbNamedDatabase& SIDatabase();
+
+        /**
+        * Returns a reference to DB session.
+        * @since 2.8
+        * @return	Reference to the database.
+        */
+		RDbs& DbSession();
+
+        /**
+        * Returns a drive for DB file.
+        * @since 2.8
+        * @return	Reference to the session.
+        */
+		TInt DbDrive();
+
+        /**
+        * Creates a small table to the database. Writing of this table is tried
+        * when acquiring for a write lock.
+        */
+        void CreateLockTableL();
+
+		/**
+		* Permit transactions. Used when e.g. backup or restore begins 
+		* @since 3.1
+		*/
+		void LockTransactionsL();
+
+		/**
+		* Allow transactions. Used when e.g. backup or restore ends 
+		* @since 3.1
+		*/
+		void UnlockTransactionsL();
+		
+        /**
+        * Opens a database session.  If database file doesn't exist, it creates one.
+        * @since 2.8
+        */
+        void OpenDatabaseL();
+        
+        /**
+	    * Close database.
+	    * @since 3.1
+	    * @return Symbian-wide error codes
+	    */
+		TInt  CloseDatabase();
+		
+     private:
+
+        /**
+        * C++ default constructor.
+        */
+        CSIDatabase(TFileName aDbFileName);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Creates a new database file.
+        * @since 2.8
+        */
+		void CreateDatabaseL();
+
+
+
+
+    public:    // Data
+
+		// Database session
+		RDbs iDbSession;
+
+		// Database
+        RDbNamedDatabase iDb;
+
+		// Indication for outstanding transaction by this client
+		TBool iOpenTransaction;
+
+		// Name of the database file	
+		TFileName iDatabaseFileName;
+
+        // drive for the database file
+        TInt iDatabaseDrive;
+
+        // Indication if database connection is open
+        TBool iDatabaseOpen;
+
+        // Mutex for DB write lock
+        // Makes sure that only one process gets the DB lock
+        RMutex iMutex; 
+        
+        // Critical section is used in locking transactions inside one object
+        RCriticalSection iCriticalSection;
+        
+        // backup and restore observer
+        CNssBackupObserver* iBackupObserver;
+        
+    };
+
+#endif // SIDATABASE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sigrammardb.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,806 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the storage and access of speaker independent
+*               grammars.  It is also responsible for allocating memory when
+*               loading grammars into the recognizer.
+*
+*/
+
+
+// INCLUDE FILES
+#include "sigrammardb.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::CSIGrammarDB
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIGrammarDB::CSIGrammarDB( RDbNamedDatabase& aDatabase, 
+                            RDbs& aDbSession,
+                            TInt aDrive )
+: CSICommonDB(aDatabase, aDbSession, aDrive )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::ConstructL()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIGrammarDB* CSIGrammarDB::NewL( RDbNamedDatabase& aDatabase, 
+                                  RDbs& aDbSession,
+                                  TInt aDrive )
+    {
+    RUBY_DEBUG_BLOCK( "CSIGrammarDB::NewL" );
+    
+    CSIGrammarDB* self 
+        = new( ELeave ) CSIGrammarDB( aDatabase, aDbSession, aDrive );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );	
+    return self;
+    }
+  
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::~CSIGrammarDB
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSIGrammarDB::~CSIGrammarDB()
+    {
+    RUBY_DEBUG0( "CSIGrammarDB::~CSIGrammarDB" );
+	// Delete all elements of the array before deleting the array
+	iGrammarArray.ResetAndDestroy();
+	iGrammarArray.Close();	
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::CreateGrammarL
+// Creates a new grammar  in the database.
+// -----------------------------------------------------------------------------
+//
+TSIGrammarID CSIGrammarDB::CreateGrammarL( TUid aClientUid )
+    {
+    RUBY_DEBUG_BLOCK( "CSIGrammarDB::CreateGrammarL" );
+
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, sizeof( CSIGrammar ) ) );
+	
+	TSIGrammarID grammarID = STATIC_CAST(TSIGrammarID,CreateNewIDL(KGrammarIdTable, KGrammarIdColumn, aClientUid));
+	// Construct the table name using the new grammar ID
+	TBuf<40> KGrammarName( KSIGrammarTable );
+    KGrammarName.AppendNumUC( grammarID );
+    RUBY_DEBUG1( "CSIGrammarDB::CreateGrammarL grammar ID: %i", grammarID );
+	
+	// Create a table definition
+	CDbColSet* columns = CDbColSet::NewLC();
+	
+	// add the columns  
+	// 1) Binary data, 2) binary data size
+	columns->AddL( TDbCol( KBinaryGrammarColumn, EDbColLongBinary ) );
+	columns->AddL( TDbCol( KBinaryGrammarColumnSize, EDbColUint32 ) );
+	
+	// Create a table
+	TInt err =iDb.CreateTable( KGrammarName, *columns );
+	
+	if ( err != KErrNone )
+	    {
+		// Failed to create the table.
+		// Need to release the new grammar ID and leave.
+		ReleaseIdL( KGrammarIdTable, KGrammarIdColumn, grammarID );
+		User::Leave( err );
+	    }
+
+	// Cleanup the column set
+	CleanupStack::PopAndDestroy( columns );
+	
+	// Construct the table name using the provided grammar ID
+	// Declare a literal string to hold the SQL statement
+	// SELECT KBinaryGrammarColumn , KBinaryGrammarColumn FROM  KGrammarName
+ 	_LIT(KSQLSelect1,"select  ");	
+	_LIT(KSQLSelect2," from  ");		
+	TBuf<120> KSQLStatement;		
+	KSQLStatement.Append(KSQLSelect1  );	
+	KSQLStatement.Append(KBinaryGrammarColumn );
+	KSQLStatement.Append(KNext);
+	KSQLStatement.Append(KBinaryGrammarColumnSize );	
+	KSQLStatement.Append(KSQLSelect2  );
+	KSQLStatement.Append(KGrammarName); 
+	
+	// Create a view on the database
+	RDbView view;
+	User::LeaveIfError(view.Prepare(iDb,TDbQuery(KSQLStatement,EDbCompareNormal)));
+	User::LeaveIfError(view.EvaluateAll());
+	
+	// Get the structure of rowset
+	CDbColSet* colSet = view.ColSetL(); 
+ 	// Insert a row
+	view.InsertL();
+	view.PutL();
+ 	// Close the view
+	view.Close();
+	delete colSet; 
+
+	// Put a empty grammar into the database
+	CSICompiledGrammar *aSICompiledGrammar=CSICompiledGrammar::NewL(grammarID);
+ 	CleanupStack::PushL(aSICompiledGrammar);
+	UpdateGrammarL(aClientUid,aSICompiledGrammar);
+	CleanupStack::PopAndDestroy(aSICompiledGrammar);
+
+    iDbSession.FreeReservedSpace( iDrive );
+
+ 	return grammarID;
+    } 
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::UpdateGrammarL
+// Inserts the externalized SI compiled grammar  into the specified grammar table.
+// Save the grammar into the database
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::UpdateGrammarL( TUid aClientUid, 
+                                   CSICompiledGrammar *aSICompiledGrammar )
+    {
+	RUBY_DEBUG_BLOCK( "CSIGrammarDB::UpdateGrammarL" );
+
+	// verify ownership 
+	TSIGrammarID aGrammarID=aSICompiledGrammar->GrammarID();
+	VerifyOwnershipL(aClientUid, KGrammarIdTable, KGrammarIndex, aGrammarID);
+	
+	// Construct the table name using the provided grammar ID
+	// Declare a literal string to hold the SQL statement
+	// SELECT KBinaryGrammarColumn , KBinaryGrammarColumn FROM  KGrammarName
+	TBuf<40> KGrammarName(KSIGrammarTable);
+    KGrammarName.AppendNumUC(aGrammarID);	
+	_LIT(KSQLSelect1,"select  ");	
+	_LIT(KSQLSelect2," from  ");		
+	TBuf<120> KSQLStatement;		
+	KSQLStatement.Append(KSQLSelect1  );	
+	KSQLStatement.Append(KBinaryGrammarColumn );
+	KSQLStatement.Append(KNext);
+	KSQLStatement.Append(KBinaryGrammarColumnSize );	
+	KSQLStatement.Append(KSQLSelect2  );
+	KSQLStatement.Append(KGrammarName); 
+	
+	// Create a view on the database
+	RDbView view;
+	User::LeaveIfError( view.Prepare( iDb, TDbQuery( KSQLStatement,EDbCompareNormal ) ) );
+	User::LeaveIfError( view.EvaluateAll() );
+	CleanupClosePushL( view );
+	
+	// Get the structure of rowset
+	CDbColSet* colSet = view.ColSetL();
+	CleanupStack::PushL( colSet );
+	view.FirstL(); 
+	view.UpdateL();
+  
+	// Externalize a compiled grammar
+	CBufFlat* dataCopyBuffer = CBufFlat::NewL( 100 ); // 100 = expand 100 bytes
+    CleanupStack::PushL( dataCopyBuffer );              // when the buffer is full
+ 	RBufWriteStream stream;
+	stream.Open( *dataCopyBuffer );
+    CleanupClosePushL( stream );
+	aSICompiledGrammar->ExternalizeL( stream );
+	CleanupStack::PopAndDestroy( &stream );
+	
+	TPtr8 aWriteBuf( dataCopyBuffer->Ptr( 0 ) );
+	TInt BufSize = aWriteBuf.Size();
+	
+	// add binary buffer by Using the stream  
+	RDbColWriteStream out;
+	TDbColNo col = colSet->ColNo( KBinaryGrammarColumn ); // Ordinal position of long column	
+	out.OpenLC( view, col );
+	out.WriteL( aWriteBuf );	
+	out.Close();	
+	CleanupStack::PopAndDestroy(); // out
+
+	// add  size of the buffer
+	col = colSet->ColNo( KBinaryGrammarColumnSize ); // Ordinal position of  size	
+	view.SetColL( col, BufSize ); 	
+	view.PutL();
+ 
+	CleanupStack::PopAndDestroy( dataCopyBuffer );
+	CleanupStack::PopAndDestroy( colSet );
+
+	// close the view
+	CleanupStack::PopAndDestroy( &view ); // Close view
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::FindGrammarL
+// Find a grammar from loaded grammar array
+// -----------------------------------------------------------------------------
+CSICompiledGrammar*  CSIGrammarDB::FindGrammarL(TSIGrammarID aGrammarID) 
+    {
+    RUBY_DEBUG_BLOCK( "CSIGrammarDB::FindGrammarL" );
+    
+    TInt i(0);
+    CSICompiledGrammar* aGrammar=NULL;
+    
+    // Check if grammar already loaded
+    for ( i = 0; i < iGrammarArray.Count(); i++ )
+        {
+        if ( iGrammarArray[i]->GrammarID()==aGrammarID  )
+            { 
+            aGrammar=iGrammarArray[i];
+            break;
+            }		
+        }
+    // Can not found in the loaded grammar array
+    if(i==iGrammarArray.Count())
+        User::Leave(KErrNotFound);
+    
+    return aGrammar;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::GetNewID
+// Get a new uniq ID 
+// -----------------------------------------------------------------------------
+TInt CSIGrammarDB::GetNewID( RArray<TSIRuleID>& aMyIds )
+    {
+    RArray<TSIRuleID> myIDs = aMyIds;
+    TInt Count = myIDs.Count();
+    TInt id = 0;
+    if ( Count == 0 )
+        {
+        id = 1; // empty ,first id will be 1
+        }
+    else
+        { 
+        // Find a unique  ID
+        myIDs.SortUnsigned();
+        id = myIDs[myIDs.Count() - 1] + 1; //by default , the last one 
+        for ( TInt i = 0; i < myIDs.Count(); i++ )
+            {
+            TInt index = i + 1; 
+            TInt s = myIDs[i];
+            if ( s > index )
+                {
+                id = index;
+                break;
+                }
+            }
+        }
+    return id;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::CreateRuleL
+// Creates a new empty rule.
+// -----------------------------------------------------------------------------
+void CSIGrammarDB::CreateRuleL( TUid aClientUid, TSIGrammarID aGrammarID, 
+                                TSIRuleID& aRuleID )
+    {
+    RUBY_DEBUG_BLOCK( "CSIGrammarDB::CreateRuleL" );
+
+    //__UHEAP_MARK;
+    VerifyOwnershipL( aClientUid, KGrammarIdTable, KGrammarIndex, aGrammarID );
+    // find the grammar from the database 
+    CSICompiledGrammar* aGrammar = (CSICompiledGrammar*) GrammarL( aGrammarID );
+    CleanupStack::PushL( aGrammar );
+    
+    TInt aID = 0;
+    TInt Count=aGrammar->Count();
+    
+    // existing myRuleVariantID
+    RArray<TSIRuleID> myIDs;
+    myIDs.Reset();
+    for(TInt i = 0; i < Count; i++ )
+        {
+        CSIRule* aRule = &( aGrammar->AtL( i ) );
+        myIDs.Append( aRule->RuleID() );
+        } 
+    
+    // Find a uniq new id 
+    aID=GetNewID( myIDs );
+    myIDs.Close();
+    aRuleID=aID;
+    
+    // add the rule to the grammar	
+    CSIRule* rule = CSIRule::NewL( aRuleID );
+    CleanupStack::PushL( rule );	
+    aGrammar->AddL( rule );
+    CleanupStack::Pop( rule );
+    
+    UpdateGrammarL( aClientUid, aGrammar );
+    CleanupStack::PopAndDestroy( aGrammar );
+    //__UHEAP_MARKEND;
+    } 
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::AddRuleVariantL
+// Add Rule Variant to the array that hold the grammar array
+// -----------------------------------------------------------------------------
+void CSIGrammarDB::AddRuleVariantL(TUid aClientUid,
+								   TSIGrammarID aGrammarID, 								 
+								   TSILexiconID aLexiconID,
+								   const RArray<TSIPronunciationID>& aPronunciationIDs, 								     
+								   TSIRuleID aRuleID,
+								   TSIRuleVariantID& aRuleVariantID) 
+    {
+    VerifyOwnershipL(aClientUid, KGrammarIdTable, KGrammarIndex, aGrammarID);
+    
+    CSICompiledGrammar* aGrammar=(CSICompiledGrammar*)GrammarL(aGrammarID);
+    CleanupStack::PushL(aGrammar);
+    
+    CSIRule* aRule=&(aGrammar->RuleL(aRuleID));
+    // existing myRuleVariantID
+    RArray<TSIRuleID> myID;
+    myID.Reset();
+    for( TInt i = 0; i < aRule->Count(); i++ )
+        {
+        CSIRuleVariant* aRuleVariant=&(aRule->AtL(i));
+        myID.Append(aRuleVariant->RuleVariantID());
+        }
+    
+    // Find a uniq new id 
+    aRuleVariantID=STATIC_CAST(TSIRuleVariantID,GetNewID(myID));
+    myID.Close();	
+    
+    // add the rule variant to the rule
+    CSIRuleVariant* ruleVariant = CSIRuleVariant::NewL( aRuleVariantID, aLexiconID );
+    CleanupStack::PushL( ruleVariant );	
+    ruleVariant->SetPronunciationIDsL(aPronunciationIDs);
+    aRule->AddL( ruleVariant );
+    CleanupStack::Pop( ruleVariant );
+    UpdateGrammarL( aClientUid, aGrammar );
+    CleanupStack::PopAndDestroy( aGrammar );	  
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::LoadGrammarL
+// Loads all rules within the specified grammar into a grammar object, which
+// is loaded into recognizer during recognition session.
+// Note : Will leave if already loaded
+// -----------------------------------------------------------------------------
+//
+const CSICompiledGrammar* CSIGrammarDB::LoadGrammarL( TSIGrammarID aGrammarID )
+    {
+    // Construct the table name using the provided grammar ID
+    // Construct the table name using the provided grammar ID
+    // Declare a literal string to hold the SQL statement
+    // SELECT KBinaryGrammarColumn , KBinaryGrammarColumn FROM  KGrammarName
+    TBuf<40> KGrammarName(KSIGrammarTable);
+    KGrammarName.AppendNumUC(aGrammarID);
+    
+    // Create newGrammar object	
+    CSICompiledGrammar* grammar = CSICompiledGrammar::NewLC( aGrammarID );	
+    _LIT(KSQLSelect1,"select  ");	
+    _LIT(KSQLSelect2," from  ");
+    TBuf<120> KSQLStatement;		
+    KSQLStatement.Append(KSQLSelect1  );		
+    KSQLStatement.Append(KBinaryGrammarColumn );
+    KSQLStatement.Append(KNext);
+    KSQLStatement.Append(KBinaryGrammarColumnSize );
+    KSQLStatement.Append(KSQLSelect2  );
+    KSQLStatement.Append(KGrammarName); 
+    
+    // create a view on the database
+    RDbView view;
+    CleanupClosePushL( view );
+    
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(KSQLStatement,EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get the structure of the rowset 
+    CDbColSet* colSet = view.ColSetL();
+    CleanupStack::PushL( colSet );
+    
+    // iterate across the row set, one row only
+    for (view.FirstL();view.AtRow();view.NextL())
+        {
+        
+        // retrieve the row
+        view.GetL();		
+        
+        // first retrieve the size of binary package 
+        TDbColNo col = colSet->ColNo(KBinaryGrammarColumnSize); // Ordinal position of long column 
+        TInt32 size = view.ColUint32( col);
+        
+        TUint8* buf = new (ELeave) TUint8[size];		
+        CleanupStack::PushL( buf);			
+        TPtr8 readBuf( buf, size, size);
+        CBufFlat* dataCopyBuffer = CBufFlat::NewL( 100 ); // 100 = expand 100 bytes
+        CleanupStack::PushL(dataCopyBuffer);              // when the buffer is full
+        
+        RBufReadStream stream;
+        CleanupClosePushL( stream );
+        stream.Open(*dataCopyBuffer);
+        
+        // and a stream for long columns
+        RDbColReadStream in;
+        CleanupClosePushL( in );
+        col = colSet->ColNo(KBinaryGrammarColumn); // Ordinal position of long column 
+        
+        
+        in.OpenLC(view, col);
+        in.ReadL( readBuf, view.ColLength(col));
+        dataCopyBuffer->InsertL(0,readBuf);
+        grammar->InternalizeL( stream );
+        
+        CleanupStack::PopAndDestroy( col );
+        CleanupStack::PopAndDestroy( &in );
+        CleanupStack::PopAndDestroy( &stream ); 
+        CleanupStack::PopAndDestroy( dataCopyBuffer );
+        CleanupStack::PopAndDestroy( buf );
+        } 
+        
+    CleanupStack::PopAndDestroy( colSet );
+    CleanupStack::PopAndDestroy( &view );
+    
+    // Keep the reference of the grammar object
+    User::LeaveIfError(iGrammarArray.Append(grammar));
+    // Cleanup grammar
+    CleanupStack::Pop(grammar );
+    return grammar;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::GrammarL
+// Loads all rules within the specified grammar into a grammar object, which
+// is loaded into recognizer during recognition session.
+// Note : Will leave if already loaded
+// -----------------------------------------------------------------------------
+//
+const CSICompiledGrammar* CSIGrammarDB::GrammarL( TSIGrammarID aGrammarID )
+    {
+ 	  
+    // Construct the table name using the provided grammar ID
+    // Construct the table name using the provided grammar ID
+    // Declare a literal string to hold the SQL statement
+    // SELECT KBinaryGrammarColumn , KBinaryGrammarColumn FROM  KGrammarName
+    TBuf<40> KGrammarName(KSIGrammarTable);
+    KGrammarName.AppendNumUC(aGrammarID);
+    // Create newGrammar object	 
+    CSICompiledGrammar* aGrammar = CSICompiledGrammar::NewLC( aGrammarID );
+    _LIT(KSQLSelect1,"select  ");
+    _LIT(KSQLSelect2," from  ");
+    
+    TBuf<120> KSQLStatement;		
+    KSQLStatement.Append(KSQLSelect1  );		
+    KSQLStatement.Append(KBinaryGrammarColumn );
+    KSQLStatement.Append(KNext);
+    KSQLStatement.Append(KBinaryGrammarColumnSize );
+    KSQLStatement.Append(KSQLSelect2  );
+    KSQLStatement.Append(KGrammarName); 
+    
+    // create a view on the database
+    RDbView view;
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(KSQLStatement,EDbCompareNormal)));
+    
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get the structure of the rowset 
+    CDbColSet* colSet = view.ColSetL();
+    
+    // iterate across the row set, one row only
+    for (view.FirstL();view.AtRow();view.NextL())
+        {
+        
+        // retrieve the row
+        view.GetL();
+        
+        // first retrieve the size of binary package 
+        TDbColNo col = colSet->ColNo(KBinaryGrammarColumnSize); // Ordinal position of long column 
+        TInt32 Size = view.ColUint32( col);
+        
+        TUint8* aBuf = new (ELeave) TUint8[Size];		
+        CleanupStack::PushL(aBuf);			
+        TPtr8 aReadBuf(aBuf, Size, Size);
+        CBufFlat* dataCopyBuffer = CBufFlat::NewL( 100 ); // 100 = expand 100 bytes
+        CleanupStack::PushL(dataCopyBuffer);              // when the buffer is full
+        
+        RBufReadStream stream;
+        stream.Open(*dataCopyBuffer);
+        
+        // and a stream for long columns
+        RDbColReadStream in;
+        col = colSet->ColNo(KBinaryGrammarColumn); // Ordinal position of long column 
+        
+        
+        in.OpenLC(view, col);
+        in.ReadL(aReadBuf, view.ColLength(col));
+        dataCopyBuffer->InsertL(0,aReadBuf);
+        aGrammar->InternalizeL( stream );
+        
+        in.Close(); 		
+        CleanupStack::PopAndDestroy(3); // in dataCopyBuffer aBuf
+        }
+    //! clean the memory
+    delete colSet;
+    view.Close();  
+    
+    // Keep the reference of the grammar object
+    // Cleanup grammar
+    CleanupStack::Pop( aGrammar );
+    
+    return aGrammar;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::CreateIDTableL
+// Creates a new grammar ID table in the database.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::CreateIDTableL()
+    {
+    // Invoke function in the base class CSICommonDB.
+    CSICommonDB::CreateIDTableL(KGrammarIdTable, KGrammarIdColumn, KGrammarIndex);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::GetAllClientGrammarIDsL
+// This function returns all grammar IDs owned by the specified client.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::GetAllClientGrammarIDsL( TUid aClientUid,
+                                            RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    RArray<TUint32> ix; 
+    ix.Reset();	
+    GetAllClientIDsL(KGrammarIdTable, KGrammarIdColumn, aClientUid, ix);
+    for(TInt i=0;i<ix.Count();i++) {
+        aGrammarIDs.Append(STATIC_CAST(TSIGrammarID,ix[i]));
+        }
+    ix.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::GetAllGrammarIDsL
+// This function returns all grammar IDs in the database.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::GetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs )
+    {
+    // This is a hack to get the id aligned to 4-byte boundary,
+    // for some reason this does not happen in winscw build if 
+    // TSIGrammarID is taken from stack.
+    TSIGrammarID* id = new (ELeave) TSIGrammarID;
+    
+    CleanupStack::PushL( id );
+    
+    RArray<TUint32> ix;
+    //! Reset
+    ix.Reset(); 
+    GetAllIDsL(KGrammarIdTable, KGrammarIdColumn,  ix);
+    for(TInt i=0;i<ix.Count();i++) 
+        {
+        *id = STATIC_CAST( TSIGrammarID, ix[i] );
+        aGrammarIDs.Append( *id );
+        }
+    ix.Close();
+    CleanupStack::PopAndDestroy( id );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::GetAllRuleIDsL
+// This function returns all rule IDs within the specified grammar.
+// grammar have to be loaded 
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::GetAllRuleIDsL( TSIGrammarID aGrammarID,
+                                   RArray<TSIRuleID>& aRuleIDs )
+    {
+	CleanupClosePushL( aRuleIDs );
+	
+    // Construct the table name using the provided grammar ID
+    TBuf<40> KGrammarName(KSIGrammarTable);
+    KGrammarName.AppendNumUC(aGrammarID);
+    
+    CSICompiledGrammar* newgrammar =( CSICompiledGrammar* )GrammarL( aGrammarID) ;// Load the grammar from database	
+    CleanupStack::PushL(newgrammar);
+    TSIRuleID	RuleId;
+    
+    for (TInt  i=0;i<newgrammar->Count();i++) {
+        CSIRule* aRule=&(newgrammar->AtL(i));
+        RuleId=aRule->RuleID();		
+        User::LeaveIfError(aRuleIDs.Append(RuleId));
+        } 
+    CleanupStack::PopAndDestroy(newgrammar);
+    CleanupStack::Pop();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::RemoveGrammarL
+// Deletes a grammar table from the database.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::RemoveGrammarL( TUid aClientUid,
+                                   TSIGrammarID aGrammarID )
+    {
+    VerifyOwnershipL(aClientUid, KGrammarIdTable, KGrammarIndex, aGrammarID);
+    
+    TInt diskSpace = ( RuleCountL(aGrammarID) * sizeof( CSIRule) ) 
+        + sizeof( CSIGrammar );
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, diskSpace ) );
+    
+    // Construct the table name using the provided grammar ID
+    TBuf<40> KGrammarName(KSIGrammarTable);
+    KGrammarName.AppendNumUC(aGrammarID);
+    
+    TBuf<50> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // DROP TABLE KGrammarName
+    _LIT(KSQLDelete1, "DROP TABLE ");
+    
+    KSQLStatement = KSQLDelete1;
+    KSQLStatement.Append(KGrammarName);
+    
+    User::LeaveIfError(iDb.Execute(KSQLStatement));
+    
+    // Release the grammar ID
+    ReleaseIdL(KGrammarIdTable, KGrammarIdColumn, aGrammarID);
+    
+    // Cancel free disk space request
+    iDbSession.FreeReservedSpace( iDrive );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::RuleCountL
+// Returns the number of rules in the specified grammar.
+// Grammar have to be loaded
+// -----------------------------------------------------------------------------
+//
+TInt CSIGrammarDB::RuleCountL( TSIGrammarID aGrammarID )
+    {
+    // Load a grammar
+    CSICompiledGrammar* aGrammar=(CSICompiledGrammar*)GrammarL(aGrammarID);
+    CleanupStack::PushL(aGrammar);  
+    // Count the number of the rules inside the grammar
+    TInt RuleCount=aGrammar->Count();	 
+    CleanupStack::PopAndDestroy(aGrammar);
+    return RuleCount;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::RemoveRuleL
+// Deletes Rule from the database.
+// Grammar have to be loaded
+// -----------------------------------------------------------------------------
+//  
+void CSIGrammarDB::RemoveRuleL( TUid aClientUid, 
+                                TSIGrammarID aGrammarID,
+                                TSIRuleID aRuleID )
+    {
+    VerifyOwnershipL(aClientUid, KGrammarIdTable, KGrammarIndex, aGrammarID);
+    CSICompiledGrammar* aGrammar=(CSICompiledGrammar*)GrammarL(aGrammarID);	 
+    
+    CleanupStack::PushL(aGrammar);  
+    if (aGrammar->Find(aRuleID)==KErrNotFound)
+        {
+        User::Leave(KErrNotFound);
+        }
+    else
+        {
+        aGrammar->DeleteL(aRuleID);
+        }
+    UpdateGrammarL(aClientUid,aGrammar);
+    CleanupStack::PopAndDestroy(aGrammar);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::IsGrammarLoaded
+// Checks to see if a valid grammar is loaded into the recognizer.  This is
+// useful to check if any rules are still loaded after performing UnloadRule().
+// -----------------------------------------------------------------------------
+//
+TBool CSIGrammarDB::IsGrammarLoaded()
+    {
+    for ( TInt i = 0; i < iGrammarArray.Count(); i++ )
+        {
+        if ( iGrammarArray[i]->Count() > 0 )
+            {
+            // As long as there is still a rule.
+            return ETrue;
+            }
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::IsRuleValidL
+// Checks if the rule is valid or not.
+// -----------------------------------------------------------------------------
+//
+TBool CSIGrammarDB::IsRuleValidL( TSIGrammarID aGrammarID, TSIRuleID aRuleID )
+    {
+    CSICompiledGrammar* aGrammar=(CSICompiledGrammar*)GrammarL(aGrammarID);
+    CleanupStack::PushL(aGrammar);  
+    if (aGrammar->Find(aRuleID)==KErrNotFound)
+        {
+        CleanupStack::PopAndDestroy(aGrammar);
+        return EFalse; 
+        }
+    else {
+        CleanupStack::PopAndDestroy(aGrammar);
+        return ETrue;	
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::ResetAndDestroy
+// Deallocates the temporary memory containing the grammar object created with
+// AllRulesL.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::ResetAndDestroy()
+    {
+    iGrammarArray.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::UnloadRule
+// Unloads the specified rule from the specified grammar in temporary memory,
+// previously loaded with AllRulesL.  The rule in the database remains intact.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::UnloadRuleL( TSIGrammarID aGrammarID,
+                                TSIRuleID aRuleID )
+    {
+    CSIGrammar* grammar;
+    
+    for( TInt i = 0; i < iGrammarArray.Count(); i++ )
+        {
+        grammar = iGrammarArray[i];
+        if ( grammar->GrammarID() == aGrammarID )
+            {
+            grammar->DeleteL(aRuleID);
+            return;
+            }
+        }
+    User::Leave(KErrNotFound);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::UnloadGrammar
+// Unloads  the specified grammar in temporary memory,
+// previously loaded with AllRulesL.  The grammar in the database remains intact.
+// -----------------------------------------------------------------------------
+//
+void CSIGrammarDB::UnloadGrammarL( TSIGrammarID aGrammarID)
+    {
+    CSIGrammar* grammar;
+    
+    for( TInt i = 0; i < iGrammarArray.Count(); i++ )
+        {
+        grammar = iGrammarArray[i];
+        if ( grammar->GrammarID() == aGrammarID )
+            {
+            //! delete the object 
+            delete iGrammarArray[i];
+            // remove the pointer
+            iGrammarArray.Remove(i);
+            return;
+            }
+        }
+    User::Leave(KErrNotFound);
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sigrammardb.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,261 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the storage and access of speaker independent
+*               grammars.  It is also responsible for allocating memory when
+*               loading grammars into the recognizer.
+*
+*/
+
+
+#ifndef SIGRAMMARDB_H
+#define SIGRAMMARDB_H
+
+//  INCLUDES 
+#include <nsssispeechrecognitiondatadevasr.h>
+#include "sicommondb.h"
+
+// CLASS DECLARATION
+/**
+*  This class implements Speaker Independent Grammar Database.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.0
+*/
+class CSIGrammarDB : public CSICommonDB
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CSIGrammarDB* NewL( RDbNamedDatabase& aDatabase, 
+                                   RDbs& aDbSession,
+                                   TInt aDrive );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSIGrammarDB();
+
+    public: // New functions
+
+        /**
+        * Adds a new rule variant into the specified grammar.
+        * @since 2.0
+		* @param	aClientUid			client's Uid for data ownership
+        * @param	aGrammarID			grammar Id
+		* @param	aLexiconID			lexicon Id
+		* @param	aPronunciationID	pronunciation Id
+        * @return	-
+        */         
+		void AddRuleVariantL(TUid aClientUid,
+			TSIGrammarID aGrammarID, 										 
+			TSILexiconID aLexiconID,
+			const RArray<TSIPronunciationID>& aPronunciationIDs,
+			TSIRuleID aRuleID,
+			TSIRuleVariantID& aRuleVariantID) ;
+
+		/**
+		* Returns a grammar object containing all speaker independent rules of the specified grammar.
+		* The grammar is added to iGrammarArray
+		* @since 2.0
+		* @param	aGrammarID			grammar Id
+		* @return	pointer to a grammar object
+        */
+        const CSICompiledGrammar* LoadGrammarL(TSIGrammarID aGrammarID );
+		
+		/**
+        * Creates a new rule in the database.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+		* @param	aGrammarID			grammar Id        
+		* @param	aRuleID		        rule Id of the created rule        
+        * @return	 -
+        */        
+		void CreateRuleL(TUid aClientUid,TSIGrammarID aGrammarID, TSIRuleID& aRuleID) ;
+		
+		/**
+        * Creates a new grammar in the database.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @return	a new grammar Id
+        */
+        TSIGrammarID CreateGrammarL( TUid aClientUid );
+
+        /**
+        * Creates a new grammar ID table in the database.
+        * @since 2.0
+        * @param	-
+        * @return	-
+        */
+        void CreateIDTableL();
+
+        /**
+        * Returns all grammar IDs that belong to the specified client.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+		* @param	aGrammarIDs			reference where grammar Ids are stored
+        * @return	-
+        */
+	 	void  GetAllClientGrammarIDsL(
+										   TUid aClientUid,
+										   RArray<TSIGrammarID>& aGrammarIDs );
+        /**
+        * Returns all grammar Ids in the database.
+        * @since 2.0
+		* @param	aGrammarIDs			reference where grammar Ids are stored
+        * @return	-
+        */
+		void GetAllGrammarIDsL( RArray<TSIGrammarID>& aGrammarIDs );
+
+	 
+        /**
+        * Returns all rule Ids that exist in the specified grammar.
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleIDs			reference where rule Ids are stored
+        * @return	-
+        */
+        void GetAllRuleIDsL( TSIGrammarID aGrammarID, RArray<TSIRuleID>& aRuleIDs );
+
+        /**
+        * Checks if a valid grammar is loaded.
+        * @since 2.0
+        * @param	-
+        * @return	ETrue if a valid grammar is loaded
+        */
+		TBool IsGrammarLoaded();
+
+		/**
+        * Checks if the rule is valid or not.
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	ETrue if the rule is valid
+        */
+        TBool IsRuleValidL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+		/**
+        * Removes the specified grammar from the database.
+		* Removing a grammar will remove all rules within the grammar.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @param	aGrammarID			grammar Id
+        * @return	-
+        */
+        void RemoveGrammarL( TUid aClientUid, TSIGrammarID aGrammarID );
+
+		/**
+        * Removes the specified rule from the database.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+		* @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	-
+        */
+        void RemoveRuleL(TUid aClientUid,TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+
+		/**
+        * Deallocates the temporary memory containing the grammar object created with AllRulesL.
+        * @since 2.0
+        * @param	-
+        * @return	-
+        */
+        void ResetAndDestroy();
+
+		/**
+        * Unloads the specified rule from the specified grammar in temporary memory, previously
+		* loaded with AllRulesL.  The rule in the database remains intact.
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+		* @param	aRuleID				rule Id
+        * @return	-
+        */
+        void UnloadRuleL( TSIGrammarID aGrammarID, TSIRuleID aRuleID );
+		
+		/**
+        * Unloads the specified grammar from the temporary memory, previously
+		* loaded with AllRulesL.  The grammar in the database remains intact.
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+        * @return	-
+        */
+		void UnloadGrammarL( TSIGrammarID aGrammarID);
+
+		/**
+        * Update the specified grammar  in the database
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @param	aSICompiledGrammar  pointer to a updated grammar object
+ 		* @return	-
+        */
+		void UpdateGrammarL(TUid aClientUid,CSICompiledGrammar* aSICompiledGrammar);
+		
+		/**
+        * Returns a grammar object containing all speaker independent rules of the specified grammar.
+		* The pointer to the object is not put in the iGrammarArray
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+        * @param	
+ 		* @return	Pointer to a compiled grammar object
+        */
+		const CSICompiledGrammar* GrammarL(TSIGrammarID aGrammarID );
+		
+		/**
+        * Find a grammar from loaded grammar array
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+        * @param	
+ 		* @return	Pointer to a compiled grammar object
+        */
+		CSICompiledGrammar*  FindGrammarL(TSIGrammarID aGrammarID) ;
+ 		
+		 
+		/**
+        * Get a new uniq ID
+        * @since 2.0
+        * @param	Rule ID array
+        * @param	
+ 		* @return	Created ID
+        */
+		TInt GetNewID( RArray<TSIRuleID>& aMyIds );
+		
+		/**
+        * Returns the number of rules in the specified grammar.
+        * @since 2.0
+        * @param	aGrammarID			grammar Id
+        * @return	Number of rules
+        */
+		TInt RuleCountL( TSIGrammarID aGrammarID );
+
+     private:
+
+        /**
+        * C++ default constructor.
+        */
+        CSIGrammarDB( RDbNamedDatabase& aDatabase, RDbs& aDbSession, TInt aDrive );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+     private:    // Data
+		// Temporary memory where loaded grammars are held during recognition session
+		RPointerArray<CSICompiledGrammar> iGrammarArray;
+    };
+
+#endif // SIGRAMMARDB_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/silexicondb.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,598 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the storage and access of speaker independent
+*               lexicons.  It is also responsible for allocating memory when
+*               loading lexicons into the recognizer.
+*
+*/
+
+
+// INCLUDE FILES
+#include "silexicondb.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::CSILexiconDB
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSILexiconDB::CSILexiconDB( RDbNamedDatabase& aDatabase, 
+                            RDbs& aDbSession,
+                            TInt aDrive )
+:	CSICommonDB(aDatabase, aDbSession, aDrive )
+{
+}
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSILexiconDB::ConstructL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSILexiconDB* CSILexiconDB::NewL( RDbNamedDatabase& aDatabase, 
+                                  RDbs& aDbSession,
+                                  TInt aDrive )
+    {
+    RUBY_DEBUG_BLOCK( "CSILexiconDB::NewL" );
+    CSILexiconDB* self 
+        = new( ELeave ) CSILexiconDB( aDatabase, aDbSession, aDrive );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );	
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::~CSILexiconDB
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSILexiconDB::~CSILexiconDB()
+    {
+    // Delete all elements of the array before deleting the array
+    //	iLexiconArray.ResetAndDestroy();
+    //	iLexiconArray.Close();
+    RUBY_DEBUG0( "CSILexiconDB::~CSILexiconDB" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::CreateLexiconL
+// Creates a new lexicon table in the database.
+// -----------------------------------------------------------------------------
+//
+TSILexiconID CSILexiconDB::CreateLexiconL( TUid aClientUid )
+    {
+    RUBY_DEBUG_BLOCK( "CSILexiconDB::CreateLexiconL" );
+    
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, sizeof( CSILexicon ) ) );
+    
+    // Generate a new Lexicon ID
+    TSILexiconID lexiconID = STATIC_CAST(TSILexiconID,CreateNewIDL(KLexiconIdTable, KLexiconIdColumn, aClientUid ));
+    
+    // Construct the table name using the new lexicon ID
+    TBuf<40> KLexiconName( KSILexiconTable );
+    KLexiconName.AppendNumUC( lexiconID );
+    RUBY_DEBUG1( "CSILexiconDB::CreateLexiconL lexicon ID: %i", lexiconID );
+	
+    
+    // Create a table definition
+    CDbColSet* columns = CDbColSet::NewLC();
+    
+    // add the columns  
+    // 1) Binary data, 2) binary data size
+    columns->AddL( TDbCol( KBinaryLexiconColumn, EDbColLongBinary ) );
+    columns->AddL( TDbCol( KBinaryLexiconColumnSize, EDbColUint32 ) );
+    
+    // Create a table
+    TInt err =iDb.CreateTable( KLexiconName, *columns );
+    
+    if ( err != KErrNone )
+        {
+        // Failed to create the table.
+        // Need to release the new Lexicon ID and leave.
+        ReleaseIdL( KLexiconIdTable, KLexiconIdColumn, lexiconID );
+        User::Leave( err );
+        }
+    
+    // cleanup the column set
+    CleanupStack::PopAndDestroy( columns );
+    // Construct the table name using the provided grammar ID
+    // Declare a literal string to hold the SQL statement
+    // SELECT KBinaryLexiconColumn , KBinaryLexiconColumn FROM  KLexiconName
+    _LIT(KSQLSelect1,"select  ");	
+    _LIT(KSQLSelect2," from  ");		
+    TBuf<120> KSQLStatement;		
+    KSQLStatement.Append(KSQLSelect1  );	
+    KSQLStatement.Append(KBinaryLexiconColumn );
+    KSQLStatement.Append(KNext);
+    KSQLStatement.Append(KBinaryLexiconColumnSize );	
+    KSQLStatement.Append(KSQLSelect2  );
+    KSQLStatement.Append(KLexiconName); 
+    
+    // create a view on the database
+    RDbView view;
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(KSQLStatement,EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get the structure of rowset
+    CDbColSet* colSet = view.ColSetL(); 
+    view.InsertL();
+    view.PutL();
+    
+    
+    // close the view
+    view.Close();
+    delete colSet; 
+    
+    // add an empty lexicon
+    CSILexicon *aLexicon=CSILexicon::NewL(lexiconID);	
+    CleanupStack::PushL(aLexicon);
+    UpdateLexiconL(aClientUid,aLexicon);
+    CleanupStack::PopAndDestroy(aLexicon);	
+    
+    iDbSession.FreeReservedSpace( iDrive );
+    
+    return lexiconID;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::UpdateLexiconL
+// Inserts the externalized SI Lexicon into the specified grammar table.
+// Save the Lexicon into the database
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::UpdateLexiconL( TUid aClientUid, 
+								   CSILexicon *aSILexicon )
+    {
+    
+    //	__UHEAP_MARK;
+    TSILexiconID aLexiconID=aSILexicon->LexiconID();
+    VerifyOwnershipL(aClientUid, KLexiconIdTable, KLexiconIndex, aLexiconID);
+    
+    // Construct the table name using the provided grammar ID
+    // Declare a literal string to hold the SQL statement
+    // SELECT KBinaryLexiconColumn , KBinaryLexiconColumn FROM  KLexiconName
+    TBuf<40> KLexiconName(KSILexiconTable);
+    KLexiconName.AppendNumUC(aLexiconID);	
+    _LIT(KSQLSelect1,"select  ");	
+    _LIT(KSQLSelect2," from  ");		
+    TBuf<120> KSQLStatement;		
+    KSQLStatement.Append(KSQLSelect1  );	
+    KSQLStatement.Append(KBinaryLexiconColumn );
+    KSQLStatement.Append(KNext);
+    KSQLStatement.Append(KBinaryLexiconColumnSize );	
+    KSQLStatement.Append(KSQLSelect2  );
+    KSQLStatement.Append(KLexiconName); 
+    
+    // create a view on the database
+    RDbView view;
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(KSQLStatement,EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get the structure of rowset
+    CDbColSet* colSet = view.ColSetL(); 
+    
+    view.FirstL(); 
+    view.UpdateL();
+    
+    
+    // Externalize grammar
+    CBufFlat* dataCopyBuffer = CBufFlat::NewL( 100 ); // 100 = expand 100 bytes
+    CleanupStack::PushL(dataCopyBuffer);              // when the buffer is full
+    //TPtr8 Buft((TUint8*) abuf,3,3);
+    //dataCopyBuffer->InsertL(0,Buft);
+    RBufWriteStream stream;
+    stream.Open(*dataCopyBuffer);
+    CleanupClosePushL(stream);
+    aSILexicon->ExternalizeL(stream);
+    CleanupStack::PopAndDestroy( &stream );
+    
+    TPtr8 aWriteBuf(dataCopyBuffer->Ptr(0));
+    TInt BufSize =aWriteBuf.Size();
+    
+    // add binary buffer by Using the stream  
+    RDbColWriteStream out;
+    TDbColNo col = colSet->ColNo(KBinaryLexiconColumn); // Ordinal position of long column	
+    out.OpenLC(view, col);
+    out.WriteL(aWriteBuf);	
+    out.Close();	
+    CleanupStack::PopAndDestroy(); // out
+    // add  size of the buffer
+    col = colSet->ColNo(KBinaryLexiconColumnSize); // Ordinal position of  size	
+    view.SetColL( col,BufSize); 
+    
+    view.PutL();
+    
+    // close the view
+    view.Close();
+    
+    
+    delete colSet; 
+    CleanupStack::PopAndDestroy( dataCopyBuffer ); 
+    //	__UHEAP_MARKEND;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIGrammarDB::GetNewID
+// Get a new uniq ID 
+// -----------------------------------------------------------------------------
+TInt CSILexiconDB::GetNewID( RArray<TSIRuleID>& aMyIds ) 
+    {
+    RArray<TSIRuleID> myIDs = aMyIds;
+    TInt Count = myIDs.Count();
+    TInt id = 0;
+    if ( Count == 0 ) 
+        {
+        id = 1; // empty ,first id will be 1
+        }
+    else
+        { 
+        // Find a unique Rulevariant ID
+        myIDs.SortUnsigned();
+        id = myIDs[myIDs.Count() - 1] + 1; //by default , the last one 
+        for ( TInt i = 0; i < myIDs.Count(); i++ ) 
+            {
+            TInt index = i + 1; 
+            TInt s = myIDs[i];
+            if ( s > index ) 
+                {
+                id = index;
+                break;
+                }
+            }
+        }
+    return id;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::CreateIDTableL
+// Creates a new lexicon ID table in the database.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::CreateIDTableL()
+    {
+    // Invoke function in the base class CSICommonDB.
+    CSICommonDB::CreateIDTableL(KLexiconIdTable, KLexiconIdColumn, KLexiconIndex);
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::GetAllClientLexiconIDsL
+// This function returns all Lexicon IDs owned by the specified client.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::GetAllClientLexiconIDsL( TUid aClientUid,
+										    RArray<TSILexiconID>& aLexiconIDs )
+    {
+    //	GetAllClientIDsL(KLexiconIdTable, KLexiconIdColumn, aClientUid, aLexiconIDs);
+    RArray<TUint32> ix;
+    ix.Reset();
+    GetAllClientIDsL(KLexiconIdTable, KLexiconIdColumn, aClientUid, ix);
+    for(TInt i=0;i<ix.Count();i++) 
+        aLexiconIDs.Append(STATIC_CAST(TSILexiconID,ix[i]));
+    ix.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::GetAllLexiconIDsL
+// This function returns all Lexicon IDs in the database.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::GetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs )
+    {
+    // This is a hack to get the id aligned to 4-byte boundary,
+    // for some reason this does not happen in winscw build if 
+    // TSILexiconID is taken from stack.
+    TSILexiconID* id = new (ELeave) TSILexiconID;
+    CleanupStack::PushL( id );
+    
+    //	GetAllIDsL(KLexiconIdTable, KLexiconIdColumn, aLexiconIDs);
+    RArray<TUint32> ix;
+    ix.Reset();
+    GetAllIDsL(KLexiconIdTable, KLexiconIdColumn, ix);
+    for(TInt i=0;i<ix.Count();i++) 
+        {
+        *id = STATIC_CAST( TSILexiconID, ix[i] );
+        aLexiconIDs.Append( *id );
+        }
+    ix.Close();
+    CleanupStack::PopAndDestroy( id );
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::GetAllPronunciationIDsL
+// This function returns all Pronunciation IDs within the specified Lexicon.
+// Lexicon have to be loaded 
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::GetAllPronunciationIDsL( TSILexiconID aLexiconID, RArray<TSIPronunciationID>& aPronunciationIDs )
+    {
+	CleanupClosePushL( aPronunciationIDs ); 
+	
+    // Construct the table name using the provided Lexicon ID
+    TBuf<40> KLexiconName(KSILexiconTable);
+    KLexiconName.AppendNumUC(aLexiconID);
+    
+    CSILexicon* newLexicon = LexiconL( aLexiconID) ;// Load the Lexicon from database	
+    CleanupStack::PushL(newLexicon);
+    
+    TSIPronunciationID	aPronunciationID;
+    for (TInt  i=0;i<newLexicon->Count();i++) {
+        CSIPronunciation* aPronunciation=&(newLexicon->AtL(i));
+        aPronunciationID=aPronunciation->PronunciationID();		
+        User::LeaveIfError(aPronunciationIDs.Append(aPronunciationID));
+        } 
+    
+    CleanupStack::PopAndDestroy(newLexicon); // newLexicon
+    //	GetAllIDsL(KLexiconName, KPronunciationIDColumn, aPronunciationIDs);
+    CleanupStack::Pop(); 
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::RemoveLexiconL
+// Deletes a Lexicon table from the database.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::RemoveLexiconL( TUid aClientUid,
+								   TSILexiconID aLexiconID )
+    {
+    
+    VerifyOwnershipL(aClientUid, KLexiconIdTable, KLexiconIndex, aLexiconID);
+    
+    
+    /* Some times removing of corrupted lexicon fails because of this:
+    TInt diskSpace = ( PronunciationCountL(aLexiconID) * sizeof( CSIPronunciation ) )
+        + sizeof( CSILexicon );
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, diskSpace ) );
+    */
+    
+    // Construct the table name using the provided Lexicon ID
+    TBuf<40> KLexiconName(KSILexiconTable);
+    KLexiconName.AppendNumUC(aLexiconID);
+    
+    TBuf<50> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // DROP TABLE KLexiconName
+    _LIT(KSQLDelete1, "DROP TABLE ");
+    
+    KSQLStatement = KSQLDelete1;
+    KSQLStatement.Append(KLexiconName);
+    
+    User::LeaveIfError(iDb.Execute(KSQLStatement));
+    
+    // Release the Lexicon ID
+    ReleaseIdL(KLexiconIdTable, KLexiconIdColumn, aLexiconID);
+    
+    // Cancel free disk space request
+    //iDbSession.FreeReservedSpace( iDrive );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::PronunciationCountL
+// Returns the number of Pronunciations in the specified Lexicon.
+// -----------------------------------------------------------------------------
+TInt CSILexiconDB::PronunciationCountL( TSILexiconID aLexiconID )
+    {
+    
+    CSILexicon* newLexicon = LexiconL( aLexiconID) ;	
+    CleanupStack::PushL(newLexicon);
+    
+    TInt PronunciationCount=newLexicon->Count();	 
+    CleanupStack::PopAndDestroy(newLexicon); 	
+    return PronunciationCount;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::IsPronunciationValidL
+// Checks if the specified pronunciation exists in the specified loaded	.
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CSILexiconDB::IsPronunciationValidL( TSILexiconID aLexiconID,
+                                           TSIPronunciationID aPronunciationID )
+    {
+    CSILexicon* newLexicon = LexiconL( aLexiconID) ;		 
+    CleanupStack::PushL(newLexicon);
+    
+    if (newLexicon->Find(aPronunciationID)==KErrNotFound) {
+        CleanupStack::PopAndDestroy(newLexicon); // newLexicon
+        return EFalse; 
+        }
+    else {
+        CleanupStack::PopAndDestroy(newLexicon); // newLexicon
+        return ETrue;	
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::ResetAndDestroy
+// Deallocates the temporary memory containing the Lexicon object created with
+// AllPronunciationsL.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::ResetAndDestroy()
+    {
+    //	iLexiconArray.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::RemovePronunciationL
+// Deletes Pronunciation from the database.
+// -----------------------------------------------------------------------------
+//
+void CSILexiconDB::RemovePronunciationL(  TUid aClientUid, 
+                                        TSILexiconID aLexiconID,
+                                        TSIPronunciationID aPronunciationID
+                                        )
+    {
+    // Check the ownership first
+    VerifyOwnershipL(aClientUid, KLexiconIdTable, KLexiconIndex, aLexiconID);
+    
+    CSILexicon* newLexicon = LexiconL( aLexiconID);		 
+    CleanupStack::PushL(newLexicon);
+    
+    if (newLexicon->Find(aPronunciationID)==KErrNotFound)
+        User::Leave(KErrNotFound);				 
+    else  
+        newLexicon->DeleteL(aPronunciationID);
+    UpdateLexiconL(aClientUid  , newLexicon);
+    CleanupStack::PopAndDestroy(newLexicon); // newLexicon
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::AddPronunciationL
+// Add Pronunciation to the database.
+// -----------------------------------------------------------------------------
+//
+TSIPronunciationID CSILexiconDB::AddPronunciationL( TUid aClientUid, 
+                                                   TSILexiconID aLexiconID,
+                                                   TDesC8& aPronunciationPr,
+                                                   TSIModelBankID aModelBankID)
+    {
+    // Check the ownership first
+    VerifyOwnershipL( aClientUid, KLexiconIdTable, KLexiconIndex, aLexiconID );
+    
+    CSILexicon* aLexicon = LexiconL( aLexiconID );
+    CleanupStack::PushL( aLexicon );
+    
+    // existing myPronunciationID
+    RArray<TSIPronunciationID> myPronunciationID;
+    myPronunciationID.Reset();
+    for( TInt i = 0; i < aLexicon->Count(); i++ )
+        {
+        CSIPronunciation* aPronunciation = &( aLexicon->AtL( i ) );
+        myPronunciationID.Append( aPronunciation->PronunciationID() );
+        }
+    
+    // Find a uniq new id 
+    TSIPronunciationID aPronunciationID = GetNewID( myPronunciationID );
+    myPronunciationID.Close();
+    
+    // add the  phoneme sequence  to the Pronunciation
+    CSIPronunciation* pronunciation = CSIPronunciation::NewL( aPronunciationID, aModelBankID );
+    CleanupStack::PushL( pronunciation );	
+    pronunciation->SetPhonemeSequenceL( aPronunciationPr );
+    aLexicon->AddL( pronunciation );
+    CleanupStack::Pop( pronunciation ); // aPronunciation
+    UpdateLexiconL( aClientUid,aLexicon );
+    CleanupStack::PopAndDestroy( aLexicon ); // aLexicon
+    return aPronunciationID;
+    }
+
+// -----------------------------------------------------------------------------
+// CSILexiconDB::LexiconL
+// Loads all pronunciations within the specified lexicon into a lexicon object
+// -----------------------------------------------------------------------------
+//
+CSILexicon* CSILexiconDB::LexiconL( TSILexiconID aLexiconID )
+    {
+    
+    // Construct the table name using the provided grammar ID
+    // Construct the table name using the provided grammar ID
+    // Declare a literal string to hold the SQL statement
+    // SELECT KBinaryLexiconColumn , KBinaryLexiconColumn FROM  KLexiconName
+    TBuf<40> KLexiconName(KSILexiconTable);
+    KLexiconName.AppendNumUC(aLexiconID);
+    // Create newLexicon object	
+    CSILexicon* lexicon = CSILexicon::NewLC( aLexiconID );	
+    _LIT(KSQLSelect1,"select  ");	
+    _LIT(KSQLSelect2," from  ");
+    TBuf<120> KSQLStatement;		
+    KSQLStatement.Append(KSQLSelect1  );		
+    KSQLStatement.Append(KBinaryLexiconColumn );
+    KSQLStatement.Append(KNext);
+    KSQLStatement.Append(KBinaryLexiconColumnSize );
+    KSQLStatement.Append(KSQLSelect2  );
+    KSQLStatement.Append(KLexiconName); 
+    
+    // create a view on the database
+    RDbView view;
+    CleanupClosePushL( view );
+    
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(KSQLStatement,EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get the structure of the rowset 
+    CDbColSet* colSet = view.ColSetL();
+    CleanupStack::PushL( colSet );
+    
+    // iterate across the row set, one row only
+    for (view.FirstL();view.AtRow();view.NextL())
+        {
+        
+        // retrieve the row
+        view.GetL();
+        
+        // first retrieve the size of binary package 
+        TDbColNo col = colSet->ColNo(KBinaryLexiconColumnSize); // Ordinal position of long column 
+        TInt32 size = view.ColUint32( col);
+        
+        TUint8* buf = new (ELeave) TUint8[size];		
+        CleanupStack::PushL( buf);			
+        TPtr8 readBuf( buf, size, size);
+        CBufFlat* dataCopyBuffer = CBufFlat::NewL( 100 ); // 100 = expand 100 bytes
+        CleanupStack::PushL( dataCopyBuffer );              // when the buffer is full
+        
+        RBufReadStream stream;
+        CleanupClosePushL( stream );
+        stream.Open(*dataCopyBuffer);
+        
+        // and a stream for long columns
+        RDbColReadStream in;
+        CleanupClosePushL( in );
+        col = colSet->ColNo(KBinaryLexiconColumn); // Ordinal position of long column 
+        
+        
+        in.OpenLC(view, col);
+        in.ReadL(readBuf, view.ColLength(col));
+        dataCopyBuffer->InsertL(0,readBuf);
+        lexicon->InternalizeL( stream );
+        
+        CleanupStack::PopAndDestroy( col );
+        CleanupStack::PopAndDestroy( &in );
+        CleanupStack::PopAndDestroy( &stream ); 
+        CleanupStack::PopAndDestroy( dataCopyBuffer );
+        CleanupStack::PopAndDestroy( buf );
+        }
+    
+    CleanupStack::PopAndDestroy( colSet );
+    CleanupStack::PopAndDestroy( &view );
+    
+
+ 
+    // Cleanup lexicon
+    CleanupStack::Pop( lexicon );
+    return lexicon;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/silexicondb.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the storage and access of speaker independent
+*               lexicons.  It is also responsible for allocating memory when
+*               loading lexicons into the recognizer.
+*
+*/
+
+
+
+#ifndef SILEXICONDB_H
+#define SILEXICONDB_H
+
+//  INCLUDES
+#include <nsssispeechrecognitiondatadevasr.h>
+#include "sicommondb.h"
+
+// CLASS DECLARATION
+/**
+*  This class implements Speaker Inependent Lexicon Database.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.0
+*/
+class CSILexiconDB : public CSICommonDB
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CSILexiconDB* NewL( RDbNamedDatabase& aDatabase, 
+                                   RDbs& aDbSession,
+                                   TInt aDrive );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CSILexiconDB();
+        
+    public:  
+        
+        /**
+        * Adds a new pronunciation into the specified lexicon.
+        * @since 2.0
+        * @param    aClientUid            client's Uid for data ownership
+        * @param    aLexiconID            lexicon Id
+        * @param    aModelBankID        model bank Id
+        * @param    aPhonemeID            phoneme Id
+        * @return    new pronunciation Id
+        */
+        TSIPronunciationID AddPronunciationL( TUid aClientUid, TSILexiconID aLexiconID,
+                                              TDesC8& aPronunciation, TSIModelBankID aModelBankID );
+     
+        /**
+        * Inserts the externalized SI Lexicon into the specified grammar table.
+        * @since 2.0
+        * @param    aClientUid            client's Uid for data ownership
+        * @param    aSILexicon            lexicon to be updated
+        */
+        void  UpdateLexiconL( TUid aClientUid, CSILexicon* aSILexicon );
+                
+        /**
+        * Creates a new lexicon ID table in the database.
+        * @since 2.0
+        */
+        void CreateIDTableL();
+        
+        /**
+        * Creates a new lexicon in the database.
+        * @since 2.0
+        * @param    aClientUid            client's Uid for data ownership
+        * @return    new lexicon Id
+        */
+        TSILexiconID CreateLexiconL( TUid aClientUid );
+        
+            
+        /**
+        * Returns all lexicon Ids that belong to the specified client.
+        * @since 2.0
+        * @param    aClientUid            client's Uid for data ownership
+        * @param    aLexiconIDs            reference where lexicon Ids are stored
+        */
+        void GetAllClientLexiconIDsL( TUid aClientUid, RArray<TSILexiconID>& aLexiconIDs );
+        
+        /**
+        * Returns all lexicon Ids in the database.
+        * @since 2.0
+        * @param    aLexiconIDs            reference where lexicon Ids are stored
+        */
+        void GetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs );
+        
+        /**
+        * Returns all pronunciation Ids that exist in the specified lexicon.
+        * @since 2.0
+        * @param    aLexiconID            lexicon Id
+        * @param    aPronunciationIDs    reference where pronunciation Ids are stored
+        */
+        void GetAllPronunciationIDsL( TSILexiconID aLexiconID, RArray<TSIPronunciationID>& aPronunciationIDs );
+    
+        /**
+        * Returns the number of pronunciations in the specified lexicon.
+        * @since 2.0
+        * @param    aLexiconID            lexicon Id
+        * @return    Number of pronunciations
+        */
+        TInt PronunciationCountL( TSILexiconID aLexiconID );
+    
+        /**
+        * Checks if the pronunciation is valid or not.
+        * @since 2.0
+        * @param    aLexiconID            lexicon Id
+        * @param    aPronunciationID    pronunciation Id
+        * @return    ETrue if the pronunciation is valid
+        */
+        TBool IsPronunciationValidL( TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID );
+        
+        /**
+        * Removes the specified lexicon from the database.
+        * Removing a lexicon will remove all pronunciations within the lexicon.
+        * @since 2.0
+        * @param    aClientUid            client's Uid for data ownership
+        * @param    aLexiconID            lexicon Id
+        */
+        void RemoveLexiconL( TUid aClientUid, TSILexiconID aLexiconID );
+        
+        /**
+        * Removes the specified pronunciation from the database.
+        * @since 2.0
+        * @param    aClientUid            client's Uid for data ownership
+        * @param    aLexiconID            lexicon Id
+        * @param    aPronunciationID    pronunciation Id
+        */ 
+        void RemovePronunciationL(  TUid aClientUid,  TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID );
+        
+        /**
+        * Deallocates the temporary memory containing the lexicon object created with AllPronunciationsL.
+        * @since 2.0
+        */
+        void ResetAndDestroy();
+            
+        /**
+        * Get a new uniq ID
+        * @since 2.0
+        * @param    Rule ID array
+        * @param    
+        * @return   Error code
+        */
+        TInt GetNewID( RArray<TSIRuleID>& aMyIds ) ;
+    
+        /**
+        * This function returns lexicon based on given id
+        * @since 2.0
+        * @param    aLexiconID            lexicon Id
+        * @return Lexicon containing all pronunciations
+        */
+        CSILexicon* LexiconL( TSILexiconID aLexiconID );
+    
+    private:
+            
+        /**
+        * C++ default constructor.
+        */
+        CSILexiconDB( RDbNamedDatabase& aDatabase, RDbs& aDbSession, TInt aDrive );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+            
+    private:    // Data
+            
+        // Temporary memory where loaded lexicons are held during recognition session
+        RPointerArray<CSILexicon> iLexiconArray;
+        CSILexicon* iLexicon;
+    };
+    
+#endif // SILEXICONDB_H
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/simodelbankdb.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,875 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the storage and access of user trained models
+*               and utterances into a database.  It performs checksum verification
+*               for the stored data.  It is also responsible for allocating memory
+*               when loading the models into the recognizer.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include "siresourcehandler.h"
+#include "asrplugindataloader.h"
+#include "simodelbankdb.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+const TInt KModelBankPackageType=3;
+const TInt KModelBankLanguageType=0;
+const TInt KModelBankStartPos=0;
+
+// _LIT(KModelFileName,"c:\\system\\Apps\\model_data\\qhmms_fxp"); // Commented out to remove "not referenced" warning
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::CSIModelBankDB
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIModelBankDB::CSIModelBankDB( RDbNamedDatabase& aDatabase, 
+                                RDbs& aDbSession,
+                                TInt aDrive )
+                               : CSICommonDB(aDatabase, aDbSession, aDrive ),
+                                 iAcousticModelPtr(0,0,0)
+    {
+    }
+
+ // -----------------------------------------------------------------------------
+// CSIModelBankDB::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSIModelBankDB::ConstructL" );
+
+    // Resource handler 
+    CSIResourceHandler* resourceHandler = CSIResourceHandler::NewL();
+    CleanupStack::PushL(resourceHandler);
+    //  Data loader
+    iDataLoader = CDataLoader::NewL( 
+        *(resourceHandler->iDataFilenamePrefix), 
+        *(resourceHandler->iDataFilenameSeperator),
+        *(resourceHandler->iDataFilenamePostfix) );
+    CleanupStack::PopAndDestroy(1); //resourceHandler
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIModelBankDB* CSIModelBankDB::NewL( RDbNamedDatabase& aDatabase, 
+                                      RDbs& aDbSession,
+                                      TInt aDrive )
+    {
+    RUBY_DEBUG_BLOCK( "CSIModelBankDB::NewL" );
+    
+    CSIModelBankDB* self 
+        = new( ELeave ) CSIModelBankDB( aDatabase, aDbSession, aDrive );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();	
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::~CSIModelBankDB
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSIModelBankDB::~CSIModelBankDB()
+{
+	// Delete all elements of the array before deleting the array
+	iModelBankArray.ResetAndDestroy();
+	iModelBankArray.Close();
+	
+ 	delete iDataLoader;
+}
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::GetAllAcousticModelsL
+// 
+// -----------------------------------------------------------------------------
+//
+const CSIModelBank* CSIModelBankDB::GetAllAcousticModelsL( TSIModelBankID aModelBankID ) 
+    {
+    
+    // Construct the table name using the provided model bank ID
+    TBuf<40> KModelBankName(KSIModelBankTable);
+    KModelBankName.AppendNumUC(aModelBankID);
+    
+    TBuf<100> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // SELECT  KHmmColumn, KHmmChecksumColumn FROM KModelBankName
+    _LIT(KSQLSelect1, "SELECT ");
+    _LIT(KSQLSelect2, " FROM ");
+    
+    KSQLStatement = KSQLSelect1;
+    KSQLStatement.Append(KHmmColumn);
+    KSQLStatement.Append(KNext);
+    KSQLStatement.Append(KHmmChecksumColumn);
+    KSQLStatement.Append(KSQLSelect2);
+    KSQLStatement.Append(KModelBankName);
+    
+    RDbView view;
+    CleanupClosePushL(view);
+    User::LeaveIfError(view.Prepare(iDb, TDbQuery(KSQLStatement, EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get column set for column ordinals
+    CDbColSet* columns = view.ColSetL();
+    TDbColNo hmm_col = columns->ColNo(KHmmColumn);
+    TDbColNo hmmchecksum_col = columns->ColNo(KHmmChecksumColumn);
+    delete columns;
+    
+    // Create a model bank object
+    CSIModelBank* modelBank = CSIModelBank::NewLC(aModelBankID);
+    
+    TSIModelID modelID=KModelID;
+    TInt length;
+    TInt32 checksum;
+    // After evaluation, the first call to NextL() is equivalent to FirstL()
+    while ( view.NextL() )
+        {
+        // Retrieve the current row
+        view.GetL();
+        length = view.ColLength(hmm_col);
+        checksum = view.ColUint32(hmmchecksum_col);
+        
+        // Read the acoustic model into a buffer
+        TUint8* hmmBuf = new (ELeave) TUint8[length];
+        CleanupStack::PushL(hmmBuf);
+        TPtr8 hmmPtr(hmmBuf, 0, length);
+        RDbColReadStream colReadStrm;
+       	colReadStrm.OpenLC(view, hmm_col);
+       	colReadStrm.ReadL(hmmPtr, length);
+        // Cleanup colReadStrm
+        CleanupStack::PopAndDestroy();
+        
+        if ( VerifyChecksum( hmmPtr, checksum) )
+            {
+            CSIModel* model = CSIModel::NewLC(modelID);
+            HBufC8* aAcousticModel=HBufC8::NewL(length); 
+            *aAcousticModel=hmmPtr;
+            model->SetAcousticModel(aAcousticModel);
+            modelBank->AddL((CSIModel*)model);
+            //!
+            // Cleanup aAcousticModel and hmmBuf
+            CleanupStack::Pop();
+            CleanupStack::PopAndDestroy();
+            
+            }
+        else
+            {
+            User::Leave( KErrCorrupt );
+            }
+        }
+    
+    // Keep the reference of the modelBank
+    //User::LeaveIfError(iModelBankArray.Append(modelBank));
+    // Cleanup modelBank
+    CleanupStack::Pop();
+    
+    // Cleanup view
+    CleanupStack::PopAndDestroy();
+    
+    return modelBank;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::AllAcousticModelsL
+// Loads all acoustic models within the specified model bank into a model bank
+// object, which is loaded into recognizer during recognition session.
+// -----------------------------------------------------------------------------
+//
+const CSIModelBank* CSIModelBankDB::AllAcousticModelsL( TSIModelBankID aModelBankID )
+    {
+    // Construct the table name using the provided model bank ID
+    TBuf<40> KModelBankName(KSIModelBankTable);
+    KModelBankName.AppendNumUC(aModelBankID);
+    
+    TBuf<100> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // SELECT  KHmmColumn, KHmmChecksumColumn FROM KModelBankName
+    _LIT(KSQLSelect1, "SELECT * ");
+    _LIT(KSQLSelect2, " FROM ");
+    
+    KSQLStatement = KSQLSelect1;
+    //	KSQLStatement.Append(KHmmColumn);
+    //	KSQLStatement.Append(KNext);
+    //	KSQLStatement.Append(KHmmChecksumColumn);
+    KSQLStatement.Append(KSQLSelect2);
+    KSQLStatement.Append(KModelBankName);
+    RDbView view;
+    CleanupClosePushL(view);
+    User::LeaveIfError(view.Prepare(iDb, TDbQuery(KSQLStatement, EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get column set for column ordinals
+    CDbColSet* columns = view.ColSetL();
+    TDbColNo hmm_col = columns->ColNo(KHmmColumn);
+    TDbColNo hmmchecksum_col = columns->ColNo(KHmmChecksumColumn);
+    delete columns;
+    
+    // Create a model bank object
+    CSIModelBank* modelBank = CSIModelBank::NewLC(aModelBankID);
+    
+    TSIModelID modelID=KModelID;
+    TInt length;
+    TInt32 checksum;
+    // After evaluation, the first call to NextL() is equivalent to FirstL()
+    while ( view.NextL() )
+        {
+        // Retrieve the current row
+        view.GetL();
+        length = view.ColLength(hmm_col);
+        checksum = view.ColUint32(hmmchecksum_col);
+        
+        // Read the acoustic model into a buffer
+        TUint8* hmmBuf = new (ELeave) TUint8[length];
+        CleanupStack::PushL(hmmBuf);
+        TPtr8 hmmPtr(hmmBuf, 0, length);
+        RDbColReadStream colReadStrm;
+       	colReadStrm.OpenLC(view, hmm_col);
+       	colReadStrm.ReadL(hmmPtr, length);
+        // Cleanup colReadStrm
+        CleanupStack::PopAndDestroy();
+
+#ifdef __SIND_HMMS_TO_FILE
+        {
+        TInt error( KErrNone );
+        RFile sampleFile; 
+        RFs fileSession; 
+        User::LeaveIfError( fileSession.Connect() );
+
+        _LIT( KCDrive,"c:\\" ); 
+        _LIT( KFileName, "data\\rec\\hmm_%08d.raw" ); 
+        _LIT( KStartOfYear, "20060101:000000.000000" ); 
+        TTime startOfYear( KStartOfYear ); 
+        TTimeIntervalSeconds secondsSince; 
+        TTime nowtime; 
+        nowtime.UniversalTime(); 
+        nowtime.SecondsFrom( startOfYear, secondsSince );
+
+        TFileName fileName; 
+        fileName.Append( KCDrive ); 
+        fileName.AppendFormat( KFileName, secondsSince.Int() ); 
+        error = sampleFile.Replace( fileSession, fileName, EFileWrite );
+        if ( !error ) 
+            {
+            TPtr8 ptr( hmmBuf, length ); 
+            ptr.SetLength( length ); 
+            sampleFile.Write( ptr );
+            sampleFile.Close();
+            }   
+        fileSession.Close();
+        }
+#endif
+        
+        if ( VerifyChecksum( hmmPtr, checksum) )
+            {
+            CSIModel* model = CSIModel::NewLC(modelID);
+            HBufC8* aAcousticModel=HBufC8::NewL(length); 
+            *aAcousticModel=hmmPtr;
+            SetAcousticModelL(aAcousticModel->Des());
+            model->SetAcousticModel(aAcousticModel);
+            modelBank->AddL((CSIModel*)model);
+            //!
+            // Cleanup aAcousticModel and hmmBuf
+            CleanupStack::Pop();
+            CleanupStack::PopAndDestroy();
+            }
+        else
+            {
+            User::Leave( KErrCorrupt );
+            }
+        }
+    
+    // Keep the reference of the modelBank
+    User::LeaveIfError(iModelBankArray.Append(modelBank));
+    // Cleanup modelBank
+    CleanupStack::Pop();
+    // Cleanup view
+    CleanupStack::PopAndDestroy();
+    
+    return modelBank;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::AllModelCountL
+// Returns the total number of models in the system (all model banks).
+// -----------------------------------------------------------------------------
+//
+TInt CSIModelBankDB::AllModelCountL()
+    {
+    TBuf<100> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // SELECT KCounterColumn FROM KModelBankIdTable WHERE KUsedColumn = KUsed
+    _LIT(KSQLSelect1, "SELECT ");
+    _LIT(KSQLSelect2, " FROM ");
+    _LIT(KSQLSelect3, " WHERE ");
+    
+    KSQLStatement = KSQLSelect1;
+    KSQLStatement.Append(KCounterColumn);
+    KSQLStatement.Append(KSQLSelect2);
+    KSQLStatement.Append(KModelBankIdTable);
+    KSQLStatement.Append(KSQLSelect3);
+    KSQLStatement.Append(KUsedColumn);
+    KSQLStatement.Append(KEqual);
+    KSQLStatement.AppendNum(KUsed);
+    
+    RDbView view;
+    CleanupClosePushL(view);
+    User::LeaveIfError(view.Prepare(iDb, TDbQuery(KSQLStatement, EDbCompareNormal)));
+    User::LeaveIfError(view.EvaluateAll());
+    
+    // Get column set for column ordinals
+    CDbColSet* columns = view.ColSetL();
+    
+    delete columns;
+    
+    TInt counter = 0;
+    // After evaluation, the first call to NextL() is equivalent to FirstL()
+    while ( view.NextL() )
+        {
+        // Retrieve the current row
+        view.GetL();
+        //counter += view.ColInt(counter_col);
+        //!
+        counter ++;//=view.ColInt(used_col); 
+        }
+    
+    // Cleanup view
+    CleanupStack::PopAndDestroy();
+    
+    return counter;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::CreateIDTableL
+// Creates a new model bank ID table in the database.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::CreateIDTableL()
+    {
+    // Invoke function in the base class CSICommonDB.
+    CSICommonDB::CreateIDTableL(KModelBankIdTable, KModelBankIdColumn, KModelBankIndex);
+    };
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::CreateModelBankL
+// Creates a new model bank table in the database.
+// -----------------------------------------------------------------------------
+//
+TSIModelBankID CSIModelBankDB::CreateModelBankL( TUid aClientUid )
+    {
+    RUBY_DEBUG_BLOCK( "CSIModelBankDB::CreateModelBankL" );
+    
+    // Model bank is already exist in the 
+    RArray<TSIModelBankID> aExistModelBankIDs;
+    CleanupClosePushL( aExistModelBankIDs );
+    GetAllClientModelBankIDsL(aClientUid,aExistModelBankIDs);
+    
+    
+    if(aExistModelBankIDs.Count()>0) {
+        TSIModelBankID aExistModelBankID=aExistModelBankIDs[0];	
+        CleanupStack::PopAndDestroy( &aExistModelBankIDs );
+        return aExistModelBankID;
+        }
+    CleanupStack::PopAndDestroy( &aExistModelBankIDs );
+    
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, sizeof( CSIModelBank ) ) );
+    
+    // Generate a new model bank ID
+    TSIModelBankID modelBankID = STATIC_CAST(TSIModelBankID,CreateNewIDL(KModelBankIdTable, KModelBankIdColumn, aClientUid));
+    // Construct the table name using the new model bank ID
+    TBuf<40> KModelBankName(KSIModelBankTable);
+    KModelBankName.AppendNumUC(modelBankID);
+    // Create a table definition
+    CDbColSet* columns=CDbColSet::NewLC();
+    
+    // add the columns  
+    // 1) Binary data, 2) binary data size
+    columns->AddL(TDbCol(KHmmColumn,EDbColLongBinary));
+    columns->AddL(TDbCol(KHmmChecksumColumn,EDbColUint32));
+    
+    // Create a table
+    TInt err =iDb.CreateTable(KModelBankName,*columns);
+    
+    if ( err != KErrNone )
+        {
+        // Failed to create the table.
+        // Need to release the new ModelBank ID and leave.
+        ReleaseIdL(KModelBankIdTable, KModelBankIdColumn, modelBankID);
+        User::Leave(err);
+        }
+    
+    // cleanup the column set
+    CleanupStack::PopAndDestroy();
+    
+    // Put and empty Modelbank inside
+        {
+        //!!! Use the default model file to construct	
+        //!
+        HBufC8 *bf=NULL;		
+        bf= iDataLoader->LoadData( KModelBankPackageType,KModelBankLanguageType,KModelBankStartPos,KMaxTUint32);
+        // Modelbank file does not exist;
+        if(bf==NULL)
+            User::Leave(KErrNotFound);
+        CleanupStack::PushL(bf);
+        
+        iAcousticModelPtr.Set(bf->Des());
+        //.Set(_L8("empty"));
+        //iAcousticModelPtr=(_L8("empty"));
+        // Always 1 for each model bank
+        //TSIModelID modelID=KModelID; 
+        
+        TInt32 hmmChecksum = CalculateChecksum(iAcousticModelPtr);
+        
+        // Open model bank table
+        RDbTable dbTable;		// Provides access to table data as a rowset
+        User::LeaveIfError(dbTable.Open(iDb, KModelBankName, RDbTable::EUpdatable));
+        CleanupClosePushL(dbTable);
+        
+        // Get column set for column ordinals
+        columns = dbTable.ColSetL();
+        TDbColNo hmm_col = columns->ColNo(KHmmColumn);
+        TDbColNo hmmchecksum_col = columns->ColNo(KHmmChecksumColumn);
+        delete columns;
+        
+        // 		 No, insert new row
+        dbTable.InsertL();
+        dbTable.SetColL(hmm_col, iAcousticModelPtr);
+        
+        dbTable.SetColL(hmmchecksum_col, hmmChecksum);
+        
+        // Write the updated row
+        TRAPD(err, dbTable.PutL());
+        if( err != KErrNone )
+            {
+            // Error: cancel update
+            dbTable.Cancel();
+            dbTable.Reset();
+            User::Leave(err);
+            }
+        
+        // Cleanup bf dbTable 
+        CleanupStack::PopAndDestroy(2);
+        // Free up resources
+        Reset();
+        }
+        
+    iDbSession.FreeReservedSpace( iDrive );
+        
+    //AllAcousticModelsL(modelBankID);
+    return modelBankID;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::GetAllClientModelBankIDsL
+// This function returns all model bank IDs owned by the specified client.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::GetAllClientModelBankIDsL( TUid aClientUid,
+                                                RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    // This is a hack to get the id aligned to 4-byte boundary,
+    // for some reason this does not happen in winscw build if 
+    // TSIModelBankID is taken from stack.
+    TSIModelBankID* id = new (ELeave) TSIModelBankID;
+    CleanupStack::PushL( id );
+    
+    RArray<TUint32> ix;
+    ix.Reset();
+    GetAllClientIDsL(KModelBankIdTable, KModelBankIdColumn, aClientUid, ix);
+    for(TInt i=0;i<ix.Count();i++) 
+        {
+        *id = STATIC_CAST( TSIModelBankID, ix[i] );
+        aModelBankIDs.Append( *id );
+        }
+    ix.Close();
+    CleanupStack::PopAndDestroy( id );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::GetAllModelBankIDsL
+// This function returns all model bank IDs in the database.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::GetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs )
+    {
+    // This is a hack to get the id aligned to 4-byte boundary,
+    // for some reason this does not happen in winscw build if 
+    // TSIModelBankID is taken from stack.
+    TSIModelBankID* id = new ( ELeave ) TSIModelBankID;
+    CleanupStack::PushL( id );
+    
+    RArray<TUint32> ix;
+    ix.Reset();
+    GetAllIDsL( KModelBankIdTable, KModelBankIdColumn, ix );
+    for ( TInt i = 0; i < ix.Count(); i++ ) 
+        { 
+        *id = STATIC_CAST( TSIModelBankID, ix[i] );
+        aModelBankIDs.Append( *id );
+        }
+    ix.Close();
+    CleanupStack::PopAndDestroy( id );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::GetAllModelIDsL
+// This function returns all model IDs within the specified model bank. It's
+// expected that the client has already done allocation on aModelIDs array object.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::GetAllModelIDsL( TSIModelBankID /*aModelBankID*/,
+                                     RArray<TSIModelID>& aModelIDs )
+    {
+    // Only one id , and it is KModelID
+    aModelIDs.Append(KModelID);	
+    }
+	
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::IsModelBankValidL
+// Checks if the specified model bank table exists in the database and also verify
+// ownership.
+// -----------------------------------------------------------------------------
+//
+TBool CSIModelBankDB::IsModelBankValidL( TUid aClientUid,
+                                         TSIModelBankID aModelBankID )
+    {
+    VerifyOwnershipL(aClientUid, KModelBankIdTable, KModelBankIndex, aModelBankID);
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::IsModelValidL
+// Checks if the specified model exists in the specified model bank table.
+// -----------------------------------------------------------------------------
+//
+TBool CSIModelBankDB::IsModelValidL( TSIModelBankID /*aModelBankID*/,
+                                     TSIModelID aModelID )
+    {
+    // Assume that ModelBankd ID is valid
+    if (aModelID==KModelID)
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::UpdateModelBankIfInvalidL
+// Validate the adapted model bank against ROM version and update if not valid.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::UpdateModelBankIfInvalidL( TSIModelBankID aModelBankID )
+    {    
+    RUBY_DEBUG_BLOCK( "CSIModelBankDB::UpdateModelBankIfInvalidL" );
+    
+    const TUint KModelBankHeaderSize(20);
+    
+    HBufC8 *bf = iDataLoader->LoadData( KModelBankPackageType,
+                                        KModelBankLanguageType,
+                                        KModelBankStartPos,
+                                        KMaxTUint32 );
+    
+    if( bf == NULL )
+        {
+        // Modelbank file does not exist;
+        User::Leave( KErrNotFound );
+        }
+        
+    CleanupStack::PushL( bf );
+    
+    TPtr8 origModelPtr( bf->Des() );
+
+    // Compare phoneme definitions
+    TBool areEqual( EFalse );
+    
+    TRAPD( error, 
+        const CSIModelBank* adaptedModelBank = GetAllAcousticModelsL( aModelBankID );
+        CleanupStack::PushL( (CSIModelBank*)adaptedModelBank );
+
+        TPtrC8 adaptedModelPtr = adaptedModelBank->AtL(0).AcousticModel();
+        
+        // 1. Compare size of phoneme definition
+        TInt adaptedSize = adaptedModelPtr[18];
+        adaptedSize |= adaptedModelPtr[19] << 8;
+            
+        TInt origSize = origModelPtr[18];
+        origSize |= origModelPtr[19] << 8;
+        
+        if ( adaptedSize == origSize )
+            {
+            // 2. compare content of phoneme definitions
+            TInt size = origSize + KModelBankHeaderSize;
+            if ( Mem::Compare( origModelPtr.Ptr(), size, adaptedModelPtr.Ptr(), size ) == 0 )
+                {
+                areEqual = ETrue;
+                }
+            }
+
+        CleanupStack::PopAndDestroy( (CSIModelBank*)adaptedModelBank );
+    );
+    
+    // GetAllAcousticModelsL will leave with KErrCorrupt if checksum doesn't match
+    // This case should be handled by updating model bank
+    if ( error != KErrNone && error != KErrCorrupt )
+        {
+        User::Leave( error );
+        }
+    
+    if ( !areEqual )
+        {
+        // replace the adapted model bank with the original model bank
+        RUBY_DEBUG0("phoneme definitions changed or model bank corrupted, update models" );
+        
+        SetAcousticModelL( origModelPtr );
+        SaveModelL( aModelBankID );
+        }
+
+    CleanupStack::PopAndDestroy( bf );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::GetUtteranceDurationL
+//
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::GetUtteranceDurationL( TSIModelBankID /*aModelBankID*/, 
+                                            TSIModelID /*aModelID*/,
+                                            TTimeIntervalMicroSeconds32& /*aDuration*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::ModelCountL
+// Returns the number of models in the specified model bank.
+// -----------------------------------------------------------------------------
+//
+TInt CSIModelBankDB::ModelCountL( TSIModelBankID /*aModelBankID*/ )
+    {
+    
+    //User::Leave(KErrNotSupported);
+    return 1;
+    // one model per modelbank by defination
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::RemoveModelBankL
+// Deletes a model bank table from the database.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::RemoveModelBankL( TUid aClientUid,
+                                       TSIModelBankID aModelBankID )
+    {
+    VerifyOwnershipL(aClientUid, KModelBankIdTable, KModelBankIndex, aModelBankID);
+    
+    TInt diskSpace = ( ModelCountL(aModelBankID) * sizeof( CSIModel ) )
+        + sizeof( CSIModelBank );
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, diskSpace ) );
+    
+    // Construct the table name using the provided model bank ID
+    TBuf<40> KModelBankName(KSIModelBankTable);
+    KModelBankName.AppendNumUC(aModelBankID);
+    
+    TBuf<50> KSQLStatement;
+    // Declare a literal string to hold the SQL statement
+    // DROP TABLE KModelBankName
+    _LIT(KSQLDelete1, "DROP TABLE ");
+    
+    KSQLStatement = KSQLDelete1;
+    KSQLStatement.Append(KModelBankName);
+    
+    User::LeaveIfError(iDb.Execute(KSQLStatement));
+    
+    // Release the ModelBank ID
+    ReleaseIdL(KModelBankIdTable, KModelBankIdColumn, aModelBankID);
+    
+    // Cancel free disk space request
+    iDbSession.FreeReservedSpace( iDrive );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::RemoveModelL
+// Removes a model from the model bank table by marking it as "not used".
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::RemoveModelL( TUid /*aClientUid*/,
+                                   TSIModelBankID /*aModelBankID*/,
+                                   TSIModelID /*aModelID*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::Reset
+// Deallocates the temporary memory allocated during training.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::Reset()
+    {
+    iAcousticModelPtr.Set(0,0,0);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::Reset
+// Deallocates the temporary memory allocated during recognition.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::ResetAndDestroy()
+    {
+    iModelBankArray.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::SaveModelL
+// Saves the trained model in the temporary memory into the database.
+// -----------------------------------------------------------------------------
+//
+TSIModelID CSIModelBankDB::SaveModelL( TSIModelBankID aModelBankID )
+    {
+    if ( iAcousticModelPtr.Length() <= 0 )
+        {
+        User::Leave(KErrNotReady);
+        }
+
+    User::LeaveIfError( iDbSession.ReserveDriveSpace( iDrive, sizeof( CSIModel ) ) );
+    
+    // Always 1 for each model bank
+    TSIModelID modelID=KModelID; 
+    // Construct the table name using the provided model bank ID
+    TBuf<40> KModelBankName(KSIModelBankTable);
+    KModelBankName.AppendNumUC(aModelBankID);
+    
+    TInt32 hmmChecksum = CalculateChecksum(iAcousticModelPtr);
+    
+    // Open model bank table
+    RDbTable dbTable;		// Provides access to table data as a rowset
+    User::LeaveIfError(dbTable.Open(iDb, KModelBankName, RDbTable::EUpdatable));
+    CleanupClosePushL(dbTable);
+    
+    // Get column set for column ordinals
+    CDbColSet* columns = dbTable.ColSetL();
+    TDbColNo hmm_col = columns->ColNo(KHmmColumn);
+    TDbColNo hmmchecksum_col = columns->ColNo(KHmmChecksumColumn);
+    delete columns;
+    
+    // 		Update it
+    dbTable.FirstL(); 	
+    dbTable.UpdateL();
+    
+    dbTable.SetColL(hmm_col, iAcousticModelPtr);
+    dbTable.SetColL(hmmchecksum_col, hmmChecksum);
+    
+    // Write the updated row
+    TRAPD(err, dbTable.PutL());
+    if( err != KErrNone )
+        {
+        // Error: cancel update
+        dbTable.Cancel();
+        dbTable.Reset();
+        User::Leave(err);
+        }
+    iDbSession.FreeReservedSpace( iDrive );
+    // Cleanup dbTable
+    CleanupStack::PopAndDestroy();
+    // Free up resources
+    Reset();
+    
+    return modelID;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::SetAcousticModelL
+// Saves the acoustic model into a temporary memory during training.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::SetAcousticModelL( const TPtr8& aAcousticModelBuf )
+    {
+    if ( aAcousticModelBuf.Length() <= 0 )
+        {
+        User::Leave(KErrNotReady);
+        }
+    
+    iAcousticModelPtr.Set(aAcousticModelBuf);
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::SetUtteranceDurationL
+// Saves the utterance duration of a trained model in temporary memory during
+// training.
+// -----------------------------------------------------------------------------
+//
+void CSIModelBankDB::SetUtteranceDurationL( TInt /*aUtteranceDuration*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::CalculateChecksum
+// Calculates a checksum value for the given buffer.
+// -----------------------------------------------------------------------------
+//
+TInt32 CSIModelBankDB::CalculateChecksum( const TPtr8& aBuf )
+    {
+    TInt32 checksum = 0;
+    TInt length = aBuf.Length();
+    
+    for( TInt i = 0; i < length; i++ )
+        {
+        checksum += aBuf[i];
+        }
+    return checksum;
+    }
+
+// -----------------------------------------------------------------------------
+// CSIModelBankDB::VerifyChecksum
+// Verifies the checksum value for the given buffer by comparing it with the
+// provided aChecksum value.
+// -----------------------------------------------------------------------------
+//
+TBool CSIModelBankDB::VerifyChecksum( const TPtr8& aBuf,
+                                      TInt32 aChecksum )
+    {
+    TInt32 checksum = CalculateChecksum(aBuf);
+    return (checksum == aChecksum);
+    }
+
+
+// -----------------------------------------------------------------------------
+// Unit Test only
+// -----------------------------------------------------------------------------
+//
+#ifdef __CONSOLETEST__
+// Returns array of loaded model banks
+RPointerArray<CSIModelBank>& CSIModelBankDB::ModelBankArray()
+    {
+    return iModelBankArray;
+    }
+
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/simodelbankdb.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,291 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the storage and access of user trained models
+*				 and utterances into a database.  It performs checksum verification
+*				 for the stored data.  It is also responsible for allocating memory
+*				 when loading the models into the recognizer.
+*
+*/
+
+
+#ifndef CSIMODELBANKDB_H
+#define CSIMODELBANKDB_H
+
+//  INCLUDES
+#include <nsssispeechrecognitiondatadevasr.h>
+
+#include "asrplugindataloader.h"
+#include "sicommondb.h"
+
+// CLASS DECLARATION
+
+/**
+*  This class implements Speaker Independent Model Database.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.0
+*/
+class CSIModelBankDB : public CSICommonDB
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CSIModelBankDB* NewL( RDbNamedDatabase& aDatabase, 
+                                     RDbs& aDbSession,
+                                     TInt aDrive );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSIModelBankDB();
+
+    public: // New functions
+
+        /**
+		* Returns a model bank object containing all speaker independent models of
+		* the specified model bank.
+		* @since 2.0
+		* @param	aModelBankID		model bank Id
+		* @return	pointer to a bank bank object
+        */
+        const CSIModelBank* AllAcousticModelsL( TSIModelBankID aModelBankID ); //*
+
+		/**
+        * Returns the total number of models in the system (all model banks).
+        * @since	2.0
+        * @param	-
+        * @return	Number of models in all model banks.
+        */
+		TInt AllModelCountL(); 
+
+        /**
+        * Creates a new model bank ID table in the database.
+        * @since 2.0
+        * @param	-
+        * @return	-
+        */
+        void CreateIDTableL(); 
+
+        /**
+        * Creates a new model bank in the database.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @return	new model bank Id
+        */
+        TSIModelBankID CreateModelBankL( TUid aClientUid ); 
+
+        /**
+        * Returns all model bank Ids that belong to the specified client.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+		* @param	aModelBankIDs		reference where model bank Ids are stored
+        * @return	-
+        */
+		void GetAllClientModelBankIDsL( TUid aClientUid, RArray<TSIModelBankID>& aModelBankIDs ); //*
+
+        /**
+        * Returns all model bank Ids in the database.
+        * @since 2.0
+		* @param	aLexiconIDs			reference where model bank Ids are stored
+        * @return	-
+        */
+		void GetAllModelBankIDsL( RArray<TSIModelBankID>& aModelBankIDs ); //*
+
+        /**
+        * Returns all model Ids that exist in the specified model bank.
+        * @since 2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelIDs			reference where model Ids are stored
+        * @return	-
+        */
+        void GetAllModelIDsL( TSIModelBankID aModelBankID, RArray<TSIModelID>& aModelIDs ); //*
+
+		/**
+        * Returns the duration of the utterance for the specified model.
+        * @since 2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+		* @param	aDuration			reference where the duration of utterance is set
+        * @return	-
+        */
+		void GetUtteranceDurationL( TSIModelBankID aModelBankID, TSIModelID aModelID,
+					TTimeIntervalMicroSeconds32& aDuration ); //*
+
+		/**
+        * Checks if the model bank is valid or not and also verify ownership.
+		* Leaves with KErrAsrDataRightViolation if not owned by the client.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @param	aModelBankID		model bank Id
+        * @return	ETrue if the model bank is valid
+        */
+        TBool IsModelBankValidL( TUid aClientUid, TSIModelBankID aModelBankID ); //*
+
+		/**
+        * Checks if the model is valid or not.
+        * @since 2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+        * @return	ETrue if the model is valid
+        */
+		TBool IsModelValidL( TSIModelBankID aModelBankID, TSIModelID aModelID ); //*
+
+		/**
+        * Checks if the model bank is valid and update if necessary.
+        * @since 3.1
+        * @param	aModelBankID		model bank Id
+        */
+        void UpdateModelBankIfInvalidL( TSIModelBankID aModelBankID );
+		/**
+        * Returns the number of models in the specified model bank.
+        * @since 2.0
+        * @param	aModelBankID		model bank Id
+        * @return	Number of models
+        */
+        TInt ModelCountL( TSIModelBankID aModelBankID ); //*
+
+		/**
+        * Removes the specified model bank from the database.
+		* Removing a model bank will remove all models within the model bank.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @param	aModelBankID		model bank Id
+        * @return	-
+        */
+        void RemoveModelBankL( TUid aClientUid, TSIModelBankID aModelBankID ); //*
+
+		/**
+        * Removes the specified model from the database.
+        * @since 2.0
+        * @param	aClientUid			client's Uid for data ownership
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+        * @return	-
+        */
+        void RemoveModelL( TUid aClientUid, TSIModelBankID aModelBankID, TSIModelID aModelID ); //*
+
+		/**
+        * Deallocates the temporary memory allocated during training.
+        * @since 2.0
+        * @param	-
+        * @return	-
+        */
+        void Reset(); //*
+
+		/**
+        * Deallocates the temporary memory allocated during recognition.
+        * @since 2.0
+        * @param	-
+        * @return	-
+        */
+		void ResetAndDestroy(); //*
+
+		/**
+        * Saves the trained model in the temporary memory into the database.
+        * @since 2.0
+        * @param	aModelBankID		model bank Id
+        * @return	A new model ID
+        */
+        TSIModelID SaveModelL( TSIModelBankID aModelBankID ); //*
+
+		/**
+        * Saves the acoustic model into a temporary memory during training.
+        * @since 2.0
+        * @param	aAcousticModelBuf	buffer containing the acoustic model
+        * @return	-
+        */
+        void SetAcousticModelL( const TPtr8& aAcousticModelBuf ); //*
+
+		/**
+        * Saves the utterance duration of a trained model in temporary memory during training.
+        * @since 2.0
+        * @param	aUtteranceDuration	utterace duration in microseconds
+        * @return	-
+        */
+        void SetUtteranceDurationL( TInt aUtteranceDuration ); //*
+
+		/**
+        * Returns a reference to a pointer descriptor with the specified length where the
+		* utterance will be stored.
+        * @since 2.0
+        * @param	aLength				length of the requested descriptor
+        * @return	Reference to a pointer descriptor
+        */
+		// TPtr8& UtteranceBufferL( TInt aLength ); //*
+
+		/**
+        * Returns a reference to a previously trained user utterance of the specified model.
+        * @since 2.0
+        * @param	aModelBankID		model bank Id
+		* @param	aModelID			model Id
+        * @return	Reference to a user utterance pointer descriptor
+        */
+        // TPtr8& UtteranceL( TSIModelBankID aModelBankID, TSIModelID aModelID ); //*
+
+  		// test
+		RPointerArray<CSIModelBank>& ModelBankArray();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CSIModelBankDB( RDbNamedDatabase& aDatabase, RDbs& aDbSession, TInt aDrive );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Calculates a checksum value for the given buffer.
+        * @since 2.0
+        * @param	aBuf				reference to a pointer descriptor containing binary data
+        * @return	Checksum value
+        */
+        TInt32 CalculateChecksum( const TPtr8& aBuf );
+
+        /**
+        * Verifies the checksum value for the given buffer.
+        * @since 2.0
+        * @param	aBuf				reference to a pointer descriptor containing binary data
+		* @param	aChecksum			checksum value to compare to
+        * @return	ETrue if the checksum of aBuf is equal to aChecksum
+        */
+        TBool VerifyChecksum( const TPtr8& aBuf, TInt32 aChecksum );
+		const CSIModelBank* GetAllAcousticModelsL( TSIModelBankID aModelBankID );
+
+    private:    // Data
+
+		// Temporary memory where loaded model banks are held during recognition session
+		RPointerArray<CSIModelBank> iModelBankArray;
+
+		// Pointer to acoustic model - used during training
+		TPtr8 iAcousticModelPtr;
+ 		// Pointer to the user utterance
+	//	TPtr8 iUtterancePtr;
+		 
+		CDataLoader* iDataLoader;
+
+		// Temporary memory where loaded SI model banks are held during recognition session
+		//RPointerArray<CSIModelBank> iSIModelBankArray;
+		HBufC8 *iFileBuffer;
+		RFs iFs;
+    };
+
+#endif      // CSIModelBankDB_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sindetraining.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,505 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation for CSindeTrainer
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <badesca.h>
+#include <numberconversion.h>
+#include "sindetraining.h"
+#include "rubydebug.h"
+#include "sidatabase.h"
+#include "sigrammardb.h"
+#include "silexicondb.h"
+
+// CONSTANTS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::CSindeTrainer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSindeTrainer::CSindeTrainer( CDevASR& aDevAsr,
+                              CSIControllerPluginInterface& aControllerIf,
+                              CSIControllerPlugin& aPlugin,
+                              CSIDatabase& aDatabase,
+                              CSIGrammarDB& aGrammarDatabase,
+                              CSILexiconDB& aLexiconDatabase ) :
+                              CActive( EPriorityStandard ), 
+                              iState( ESindeTrainerIdle ),
+                              iDevAsr( aDevAsr ),
+                              iControllerIf( aControllerIf ),
+                              iPlugin( aPlugin ),
+						      iDatabase( aDatabase ),
+                              iGrammarDatabase( aGrammarDatabase ),
+                              iLexiconDatabase( aLexiconDatabase )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSindeTrainer::ConstructL" );
+    
+    // Add active object to active scheduler
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSindeTrainer* CSindeTrainer::NewL( CDevASR& aDevAsr,
+                                    CSIControllerPluginInterface& aControllerIf,
+                                    CSIControllerPlugin& aPlugin,
+                                    CSIDatabase& aDatabase,
+                                    CSIGrammarDB& aGrammarDatabase,
+                                    CSILexiconDB& aLexiconDatabase )
+    {
+    RUBY_DEBUG_BLOCK( "CSindeTrainer::NewL" );
+    CSindeTrainer* self = new( ELeave ) CSindeTrainer( aDevAsr, aControllerIf, aPlugin,
+     										           aDatabase, aGrammarDatabase,
+     										           aLexiconDatabase );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );	
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::~CSindeTrainer
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CSindeTrainer::~CSindeTrainer()
+    {
+    RUBY_DEBUG0( "CSindeTrainer::~CSindeTrainer" );
+    
+    Cancel();
+
+    delete iTtpWordList;
+    iMaxPronunsForWord.Close();
+    
+    iTtpDataArray.ResetAndDestroy();
+    iTtpDataArray.Close();
+    
+    if ( iTrainArrays != NULL )
+        {
+        iTrainArrays->ResetAndDestroy();
+        iTrainArrays->Close();
+        delete iTrainArrays;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::SetReady
+// Sets the object active and signals active scheduler to run it.
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::SetReady()
+    {
+    TRequestStatus* pRS = &iStatus;
+    User::RequestComplete( pRS, KErrNone );
+    SetActive();
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::RunL
+// RunL of CActive
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::RunL()
+    {
+    RUBY_DEBUG0( "CSindeTrainer::RunL" );
+    
+    switch ( iState )
+        {
+        case ESindeTrainerTraining:
+            {
+            TRAPD( error, DoOneTrainingStepL() );
+            if ( error != KErrNone )
+                {
+                // Move to next state
+                iState = ESindeTrainerDbUpdate;
+                SetReady();
+                }
+            break;
+            }
+        
+        case ESindeTrainerDbUpdate:
+            {
+            TRAPD( error, DoDatabaseUpdateL() );
+            iError = error;
+            iState = ESindeGrammarCompilation;
+            SetReady();
+            break;
+            }
+        
+        case ESindeGrammarCompilation:
+            {
+            TRAPD( error, DoGrammarCompilationL() );
+            iError = error;
+            if ( error != KErrNone )
+                {
+                // Move to next state
+                iState = ESindeTrainerFinished;
+                SetReady();                
+                }
+            break;
+            }
+        
+        case ESindeTrainerFinished:
+            {
+            RUBY_DEBUG1( "CSindeTrainer::RunL sending KUidAsrEventAddVoiceTags callback with error: %d", iError );
+            // All done, do callback to client thread     
+            iControllerIf.SendSrsEvent( KUidAsrEventAddVoiceTags, iError );
+            iState = ESindeTrainerIdle;            
+            break;   
+            }
+        
+        default:
+            RUBY_ERROR0( "CSindeTrainer::RunL unexpected state" );
+            break;
+       
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::DoCancel
+// DoCancel of CActive
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::DoCancel()
+    {
+    RUBY_DEBUG0( "CSindeTrainer::DoCancel" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::HandleEvent
+// Handles event originated from DevASR
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::HandleEvent( TDevASREvent aEvent, TDevASRError aError )
+    {
+    RUBY_DEBUG2( "CSindeTrainer::HandleEvent event: %d error: %d", aEvent, aError );
+    
+    if ( aError == KErrNone )
+        {
+        if ( aEvent == EDevASRTrainFromText )
+            {
+            // Store the data
+            iTtpDataArray.Append( iTtpWordList );
+            // Ownership transferred to array
+            iTtpWordList = NULL;
+            }
+        else if ( aEvent == EDevASRGrammarCompile )
+            {
+            StoreCompiledGrammar();
+            iState = ESindeTrainerFinished;
+            }
+        }
+    
+    // Do the next step in RunL
+    SetReady();
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::AddSindeVoiceTagsL
+// Starts training of SINDE voice tags
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::AddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArrays,
+	                                    RArray<RLanguageArray>& aLanguageArray, 
+                                        TSILexiconID aLexiconId,
+                                        TSIGrammarID aGrammarId,
+                                        TSIModelBankID aModelBankId,
+                                        TUid aClientUid,
+                                        RArray<TSIRuleID>& aRuleIds )
+    {
+    RUBY_DEBUG_BLOCK( "CSindeTrainer::AddSindeVoiceTagsL" );
+    
+    if ( IsActive() )
+        {
+        User::Leave( KErrInUse );
+        }
+        
+    // Start reading the input arrays from zero index
+    iLanguageIndex = 1;
+    iTextIndex = 0;
+    
+    // Destruct previous input if it still exists
+    if ( iTrainArrays != NULL )
+        {
+        iTrainArrays->ResetAndDestroy();
+        iTrainArrays->Close();
+        delete iTrainArrays;
+        iTrainArrays = NULL;
+        }
+    
+    // Store parameters for asynchronous processing
+    iTrainArrays = aTrainArrays;
+    iLanguageArray = &aLanguageArray;
+    iLexiconId = aLexiconId;
+    iGrammarId = aGrammarId;
+    iClientUid = aClientUid;
+    iModelBankId = aModelBankId;
+    iRuleIds = &aRuleIds;
+    
+    iState = ESindeTrainerTraining;
+    SetReady();
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::DoOneTrainingStep
+// Starts one step of training using DevASR
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::DoOneTrainingStepL()
+    {
+    RUBY_DEBUG_BLOCK( "CSindeTrainer::DoOneTrainingStepL" );
+    
+    // Delete the previous DevASR input data
+    delete iTtpWordList;
+    iTtpWordList = NULL;
+    iTtpWordList = CSITtpWordList::NewL();
+    
+    for ( TInt i = 0; i < iTrainArrays->Count(); i++ )
+        {
+        MDesCArray* originalText = (*iTrainArrays)[i];
+            
+        CDesC16ArrayFlat* wordArray = new ( ELeave ) CDesC16ArrayFlat( 1 );
+        CleanupStack::PushL( wordArray );
+            
+        // Loop through all descriptors that are needed for this group and
+        // add them to new wordArray
+        for ( TInt j = 0; j < originalText->MdcaCount(); j++ )
+            {
+            TInt textLength = originalText->MdcaPoint( j ).Length();
+            if ( textLength > 0 )
+                {
+                TPtrC firstChar( originalText->MdcaPoint( j ).Left( 1 ) );
+                TInt length( 0 );
+                TInt result( 0 );
+                TDigitType type;
+                result = NumberConversion::ConvertFirstNumber( firstChar, length, type );
+                
+                if ( result == iLanguageIndex )
+                    {
+                    // Take off the first character
+                    TPtrC text( originalText->MdcaPoint( j ).Right( textLength - 1 ) );
+                    wordArray->AppendL( text ); 
+                    }
+                }
+            }
+            
+            // Append empty descriptor if nothing else was found
+            if ( wordArray->Count() == 0 )
+                {
+                wordArray->AppendL( KNullDesC ); 
+                }
+                
+        iTtpWordList->AddL( wordArray );
+        // Ownership transferred to iTtpWordList
+        CleanupStack::Pop( wordArray );
+        }
+        
+    // Decrease 1 to get the current index, iLanguageIndex starts from 1
+    TInt currentLanguageIndex( iLanguageIndex - 1 );
+        
+     // Check that there is legal index for languageArray available
+    if ( ( currentLanguageIndex < 0 ) || ( currentLanguageIndex >= iLanguageArray->Count() ) )
+        {
+        RUBY_ERROR0( "CSindeTrainer::DoOneTrainingStep language array index out of bounds" );
+        User::Leave( KErrNotFound );
+        }
+        
+    iMaxPronunsForWord.Reset();	
+    iMaxPronunsForWord.Append( (*iLanguageArray)[currentLanguageIndex].Count() );
+        
+    // Do the training call to DevASR
+    iDevAsr.StartTrainingFromTextL( *iTtpWordList, (*iLanguageArray)[currentLanguageIndex], iMaxPronunsForWord );
+
+    // Move to next group          
+    iLanguageIndex++;
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::DoDatabaseUpdateL
+// Stores the training results into grammar and lexicon and updates the DB
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::DoDatabaseUpdateL()
+    {
+    RUBY_DEBUG_BLOCK( "CSindeTrainer::DoDatabaseUpdateL" );
+   
+    iRuleIds->Reset();
+   
+    iDatabase.BeginTransactionL();
+    
+    // Get the grammar
+    iGrammarDatabase.VerifyOwnershipL( iClientUid, KGrammarIdTable, KGrammarIndex, iGrammarId ); 
+    CSICompiledGrammar* grammar = ( CSICompiledGrammar* ) iGrammarDatabase.GrammarL( iGrammarId );
+    CleanupStack::PushL( grammar );	
+    
+    // Get the lexicon
+    iLexiconDatabase.VerifyOwnershipL( iClientUid, KLexiconIdTable, KLexiconIndex, iLexiconId );		   
+    CSILexicon* lexicon = iLexiconDatabase.LexiconL( iLexiconId );
+    CleanupStack::PushL( lexicon );	
+    
+    iDatabase.CommitChangesL( EFalse ); 
+    
+    // There should be at least one element in ttp data array
+    if ( iTtpDataArray.Count() > 0 )
+    	{
+    	// Take the first word list
+        CSITtpWordList* ttpWordList = iTtpDataArray[0];
+        
+        for ( TInt i = 0; i < ttpWordList->Count(); i++ )
+            {
+            RPointerArray<CSIPronunciationInfo> pronunciations;
+            RArray<TSIPronunciationID> pronunciationIDs;
+            CleanupClosePushL( pronunciationIDs );
+            CleanupClosePushL( pronunciations );
+            // Take the pronunciations from ttp output
+            ttpWordList->GetPronunciationsL( i, pronunciations );
+
+            CSIRule* rule = iPlugin.CreateNewRuleL( grammar );
+            CleanupStack::PushL( rule );	
+            
+            // if pronunciation generation failed, skip that word.
+            if ( pronunciations.Count() == 0 )
+                {
+                User::LeaveIfError( iRuleIds->Append( KInvalidRuleID ) );
+                CleanupStack::PopAndDestroy( rule );
+                }
+            else
+                {
+            	for ( TInt k = 0; k < pronunciations.Count(); k++ ) 
+                	{
+               		pronunciationIDs.Reset();
+            
+                    for ( TInt n = 0; n < pronunciations[k]->Count(); n++ ) 
+                        {
+                    	// Add Pronunciation into lexicon
+                        TDesC8& pronunciation = pronunciations[k]->PronunciationL( n );
+                        TSIPronunciationID pronunId = iPlugin.CreateNewPronunciationL( lexicon, pronunciation, iModelBankId );
+                        User::LeaveIfError( pronunciationIDs.Append( pronunId ) );
+                	    }
+
+                    AppendPronunciationsL( i, *lexicon, pronunciationIDs );
+            
+            	    // Add RuleVariant into grammar
+            	    iPlugin.AddNewRuleVariantL( *rule, iLexiconId, pronunciationIDs, *pronunciations[k] );
+            	    }
+        
+        	    grammar->AddL( rule );
+        	    CleanupStack::Pop( rule );
+            
+                // Add rule to client side array      
+                User::LeaveIfError( iRuleIds->Append( rule->RuleID() ) );
+                }
+                   
+        	// Close the arrays
+        	CleanupStack::PopAndDestroy( &pronunciations ); 
+        	CleanupStack::PopAndDestroy( &pronunciationIDs );
+
+            } // for ( TInt i = 0; i < ttpWordList->Count(); i++ )
+
+        // Do the updates into the database
+        iDatabase.BeginTransactionL();
+        iGrammarDatabase.UpdateGrammarL( iClientUid, grammar );
+        iLexiconDatabase.UpdateLexiconL( iClientUid, lexicon );
+        // Commit changes to db with compact
+        iDatabase.CommitChangesL( ETrue );  
+        } // if ( iTtpDataArray.Count() > 0 )
+
+    CleanupStack::PopAndDestroy( lexicon );
+    CleanupStack::PopAndDestroy( grammar );	
+        
+    // All data has been stored elsewhere
+    iTtpDataArray.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::DoGrammarCompilationL
+// Does grammar compilation using DevASR
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::DoGrammarCompilationL()
+    {
+    iDatabase.BeginTransactionL();
+    iCompiledGrammar = ( CSICompiledGrammar* )iGrammarDatabase.LoadGrammarL( iGrammarId );
+    iDatabase.CommitChangesL( EFalse );
+            
+    iDevAsr.CompileGrammarL( *iCompiledGrammar );
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::StoreCompiledGrammar
+// Stores compiled grammar to plugin database
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::StoreCompiledGrammar()
+    {
+    TRAP_IGNORE( 
+        iDatabase.BeginTransactionL();
+        // save the compiled grammar
+        iGrammarDatabase.UpdateGrammarL( iClientUid, iCompiledGrammar );
+        iDatabase.CommitChangesL( ETrue );
+        ); // TRAP_IGNORE
+    }
+
+// -----------------------------------------------------------------------------
+// CSindeTrainer::AppendPronunciationsL
+// Appends pronunciations from other ttp word lists than the first one
+// -----------------------------------------------------------------------------
+//
+void CSindeTrainer::AppendPronunciationsL( TInt aIndex, CSILexicon& aLexicon, 
+                                           RArray<TSIPronunciationID>& aPronunIds )
+    {
+    // Append pronunciations also from other word lists
+    for ( TInt counter = 1; counter < iTtpDataArray.Count(); counter++ )
+        {
+        CSITtpWordList* ttpWordList = iTtpDataArray[counter];
+        RPointerArray<CSIPronunciationInfo> pronunciations;
+        CleanupClosePushL( pronunciations );
+        // Take the same index as from first word list
+        ttpWordList->GetPronunciationsL( aIndex, pronunciations );
+                        
+        for ( TInt pronunArrayCounter = 0; pronunArrayCounter < pronunciations.Count(); pronunArrayCounter++ )
+            {
+            for ( TInt pronunCounter = 0; pronunCounter < pronunciations[pronunArrayCounter]->Count(); pronunCounter++ )
+                {
+                TDesC8& pronun = pronunciations[pronunArrayCounter]->PronunciationL( pronunCounter );
+                TSIPronunciationID pronunId = iPlugin.CreateNewPronunciationL( &aLexicon, pronun, iModelBankId );
+                User::LeaveIfError( aPronunIds.Append( pronunId ) );
+                }
+            }
+            CleanupStack::PopAndDestroy( &pronunciations ); 
+        }
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sindetraining.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,240 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class which takes care of SINDE voice tag training.
+*
+*/
+
+
+#ifndef SINDETRAINING_H
+#define SINDETRAINING_H
+
+// ============================================================================
+// Uncomment the following directive for Bit Exact Testing.
+// ============================================================================
+//
+ 
+// INCLUDES
+#include "srsfbldvariant.hrh"
+#include "sicontrollerplugininterface.h"
+#include "sicontrollerplugin.h"
+#include <e32base.h>
+#include <bamdesca.h>
+#include <nsssispeechrecognitiondatacommon.h>
+#include <nssdevasr.h>
+
+// FORWARD DECLARATIONS
+
+
+// CLASS DECLARATION
+
+/**
+* Class which takes care of SIND with Extensions training.
+* Training is done in several batches to get optimal
+* number of pronunciations for each type of word.
+*
+* @lib nsssicontrollerplugin.lib
+* @since 3.1
+*/
+class CSindeTrainer : public CActive
+    {
+    public: // Constructors and destructor
+    
+	    /**
+        * Two-phased constructor.
+        * 
+        * @param aDevAsr DevASR reference
+        * @param aControllerIf Controller Interface to send callbacks to client
+        * @param aPlugin Plugin reference
+        * @param aDatabase SI Database
+        * @param aGrammarDatabase Grammar Database
+        * @param aLexiconDatabase Lexicon Database
+	    */
+	    static CSindeTrainer* NewL( CDevASR& aDevAsr, 
+	                                CSIControllerPluginInterface& aControllerIf,
+	                                CSIControllerPlugin& aPlugin,
+	                                CSIDatabase& aDatabase,
+                                    CSIGrammarDB& aGrammarDatabase,
+                                    CSILexiconDB& aLexiconDatabase );
+	
+	    /**
+	    * Destructor.
+	    */
+	    virtual ~CSindeTrainer();
+	    
+	public: // New functions
+	
+	    /**
+	    * Starts the process of SINDE voice tag addition.
+	    * Client thread is called is signalled directly when training completes.
+	    *
+	    * @param aTrainArrays Training texts
+	    * @param aLanguageArray Languages which are used when training
+	    * @param aLexiconId Lexicon ID where to add new pronunciations
+	    * @param aGrammarId Grammar ID where to add new rules
+	    * @param aModelBankId Model bank ID which is used in training process
+	    * @param aClientUid UID of the client which is doing the update (to verify ownership)
+	    * @param aRuleIds Output parameter, will contain the list IDs of the added rules
+	    */
+	    void AddSindeVoiceTagsL( RPointerArray<MDesCArray>* aTrainArrays,
+	                             RArray<RLanguageArray>& aLanguageArray, 
+                                 TSILexiconID aLexiconId,
+                                 TSIGrammarID aGrammarId,
+                                 TSIModelBankID aModelBankId,
+                                 TUid aClientUid,
+                                 RArray<TSIRuleID>& aRuleIds );
+                                 
+                                 
+        /**
+        * Handles an event originating from DevASR.
+        *
+        * @param aEvent Event code
+        * @param aError Error code
+        */
+        void HandleEvent( TDevASREvent aEvent, TDevASRError aError );
+	
+	protected: // From CActive
+	
+        /**
+        * RunL from CActive class.
+        */
+		void RunL();
+		
+        /**
+        * Cancel handle from CActive class.
+        */
+		void DoCancel();
+
+	private:
+
+        /**
+        * C++ default constructor.
+        *
+        * @param aDevAsr DevASR reference
+        * @param aControllerIf Controller Interface to send callbacks to client
+        * @param aPlugin Plugin reference
+        * @param aDatabase SI Database
+        * @param aGrammarDatabase Grammar Database
+        * @param aLexiconDatabase Lexicon Database
+        */
+        CSindeTrainer( CDevASR& aDevAsr,
+                       CSIControllerPluginInterface& aControllerIf,
+                       CSIControllerPlugin& aPlugin,
+                       CSIDatabase& aDatabase,
+                       CSIGrammarDB& aGrammarDatabase,
+                       CSILexiconDB& aLexiconDatabase );
+		
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+		
+		/**
+		* Sets the active object as active and ready to run.
+		*/
+		void SetReady();
+		
+		/**
+		* Does one step of training.
+		*/
+		void DoOneTrainingStepL();
+		
+		/**
+		* Does the updates to lexicon and grammar database.
+		*/
+		void DoDatabaseUpdateL();
+
+        /**
+        * Does the grammar compilation using DevASR.
+        */		
+		void DoGrammarCompilationL();
+		
+		/**
+		* Saves compiled grammar into database.
+		*/
+		void StoreCompiledGrammar();
+
+		/**
+		* Utility function to add pronunciations from other batches than first one
+		* to lexicon and grammar.
+		*
+		* @param aIndex Index within TTP word lists
+		* @param aLexicon Lexicon where additions are done
+		* @param aPronunIds Pronunciation id array where new ids are appended
+		*/
+		void AppendPronunciationsL( TInt aIndex, 
+		                            CSILexicon& aLexicon, 
+		                            RArray<TSIPronunciationID>& aPronunIds );
+
+    private: // Data
+    
+        // States for this object
+        enum TSindeTrainerState
+            {
+            ESindeTrainerIdle,
+            ESindeTrainerTraining,
+            ESindeTrainerDbUpdate,
+            ESindeGrammarCompilation,
+            ESindeTrainerFinished
+            };
+            
+        // Current object state
+        TSindeTrainerState iState;
+        
+        // Input for TTP via DevASR
+        CSITtpWordList* iTtpWordList;
+        
+        // Position of language array processing
+        TInt iLanguageIndex;
+        
+        // Position of text array processing
+        TInt iTextIndex; 
+	
+	    // Stored parameters
+    	RPointerArray<MDesCArray>* iTrainArrays;
+    	RArray<RLanguageArray>* iLanguageArray;
+    	RArray<TSIRuleID>* iRuleIds;
+    	TSIGrammarID iGrammarId;
+    	TSILexiconID iLexiconId;
+    	TSIModelBankID iModelBankId;
+        CSICompiledGrammar* iCompiledGrammar;
+    	    	
+    	// Reference to DevASR module
+    	CDevASR& iDevAsr;
+	
+    	RArray<TUint32> iMaxPronunsForWord;
+    	
+    	// Array which contains collected set of TTP data structures
+    	RPointerArray<CSITtpWordList> iTtpDataArray;
+	    
+	    // Asynchronous processing result, will be sent within callback
+	    TInt iError;
+	    
+	    // To do callbacks to client side
+	    CSIControllerPluginInterface& iControllerIf;
+	    
+	    // Controller plugin
+	    CSIControllerPlugin& iPlugin;
+	    
+	    // Plugin database classes
+		CSIDatabase& iDatabase;
+        CSIGrammarDB& iGrammarDatabase;
+        CSILexiconDB& iLexiconDatabase;
+        
+        // UID of the client
+        TUid iClientUid;        
+    };
+	
+#endif // SINDETRAINING_H
+	
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sipluginimplementationuids.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constant declaration for resource file.
+*
+*/
+
+
+#ifndef SDPLUGINIMPLEMENTATIONUIDS_HRH
+#define SDPLUGINIMPLEMENTATIONUIDS_HRH
+
+// Dll Uid
+#define KSDDllUidController			0x101F8C9C
+#define KSIDllUidController         	0x101FF930
+
+
+// Implementation UIDs for Controller plugin
+#define KSDUidController 	   		0x101F8C9D
+#define KSIUidController            	0x101FF931
+
+// Implementation UIDs for AMR plugin
+#define KUidCodecPCM16ToAMR 	   		0x101FAF68	// AMR Encoder
+#define KUidCodecAMRToPCM16 	   		0x101FAF67	// AMR Decoder
+
+// Implementation UIDs for GSM 6.10 FR plugin
+#define KUidCodecPCM16ToGSM610			0x101F504D	// GSM Encoder
+#define KUidCodecGSM610ToPCM16			0x101F504C	// GSM Decoder
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/siresourcehandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads the resource file and provides access to the
+*               information read from the resource file to the controller.
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <barsread.h>
+#include "siresourcehandler.h"
+#include <nsssisrscontrollerplugin.rsg>
+//*#include	"SDConsoleTest.h"		// Unit Test
+#include "nsssispeechrecognitiondatacommon.h"
+#include "nsssispeechrecognitiondatadevasr.h"
+#include "rubydebug.h"
+
+// LOCAL CONSTANTS AND MACROS
+_LIT( KResourceFileName, "\\nsssisrscontrollerplugin.rsc" );
+_LIT( KResourceDir, "\\resource" );
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSIResourceHandler::CSIResourceHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSIResourceHandler::CSIResourceHandler()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSIResourceHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSIResourceHandler::ConstructL()
+	{
+    RUBY_DEBUG_BLOCK( "CSIResourceHandler::ConstructL" );
+	ReadResourceFileL();
+	}
+
+// -----------------------------------------------------------------------------
+// CSIResourceHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSIResourceHandler* CSIResourceHandler::NewL()
+	{
+    RUBY_DEBUG_BLOCK( "CSIResourceHandler::NewL" );
+	CSIResourceHandler* self = new(ELeave) CSIResourceHandler();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(); // self
+	return self;
+	}
+
+// Destructor
+// -----------------------------------------------------------------------------
+// CSIResourceHandler::CSIResourceHandler
+// Destructor 
+// -----------------------------------------------------------------------------
+//
+CSIResourceHandler::~CSIResourceHandler()
+	{
+	delete iDbFileName;
+	delete iDataFilenamePrefix;
+	delete iDataFilenamePostfix;
+	delete iDataFilenameSeperator;
+	}
+
+// -----------------------------------------------------------------------------
+// CSIResourceHandler::ReadResourceFileL
+// Reads the data from the resource file.
+// -----------------------------------------------------------------------------
+//
+void CSIResourceHandler::ReadResourceFileL()
+	{
+    // letters for drives in search order
+    const TBuf<2> KResourceDrivers = _L("cz"); 
+
+    // load resources
+	RResourceFile resourceFile;
+	RFs fs;
+	User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+    TFileName name;
+    TInt i( 0 );
+    // try to find from the first driver
+    name.Append( KResourceDrivers[i] );
+    name.Append( ':' );
+    name.Append( KResourceDir );
+    name.Append( KResourceFileName );
+
+    TBool found( EFalse );
+    
+    while ( !found && i < KResourceDrivers.Length() )
+        {
+        name[0] = KResourceDrivers[i++];
+       
+        if ( BaflUtils::FileExists(fs, name) )
+            {
+            // open resource
+            resourceFile.OpenL( fs, name );
+            CleanupClosePushL( resourceFile );
+            found = ETrue;
+            }
+        }
+            
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+	
+	// Read Resource file according to it's structure defination
+	HBufC8* res = resourceFile.AllocReadLC(SICONTROLLERINFO);
+
+	TResourceReader reader;
+	reader.SetBuffer(res);
+
+    iMaxModelsPerBank = reader.ReadInt16();
+	iMaxModelsSystem = reader.ReadInt16();
+
+	// Plugin database file name
+	iDbFileName = reader.ReadHBufCL();	
+	
+	// Language package data file path and prefix
+	iDataFilenamePrefix = reader.ReadHBufCL();
+	
+	// Language package data file postfix		
+	iDataFilenamePostfix  = reader.ReadHBufCL();
+	
+	// Language package data file name seperator	
+	iDataFilenameSeperator = reader.ReadHBufCL();
+
+	// Cleanup reader, resourceFile, and fs
+	CleanupStack::PopAndDestroy(3);
+	} 
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/siresourcehandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads the resource file and provides access to the
+*				 information read from the resource file to the controller.
+*
+*/
+
+
+
+#ifndef CSIRESOURCEHANDLER_H
+#define CSIRESOURCEHANDLER_H
+
+// CLASS DECLARATION
+/**
+*  This class implements resource file handling functions.
+*
+*  @lib SIControllerPlugin.lib
+*  @since 2.8
+*/
+class CSIResourceHandler : public CBase
+	{
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CSIResourceHandler* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSIResourceHandler();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CSIResourceHandler();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Reads the data from the resource file.
+        * @since 2.8
+        * @param	-
+        * @return	-
+        */
+		void ReadResourceFileL();
+
+	public:    // Data
+ 
+		// Maximum number of models per bank
+		TInt iMaxModelsPerBank;
+
+		// Maximum number of models in system
+		TInt iMaxModelsSystem;
+
+		// Plugin database file name 
+		HBufC* iDbFileName;
+		// Language package data file name information
+
+		// Language package data file path and prefix
+		HBufC* iDataFilenamePrefix;	  
+
+		// Language package data file postfix
+		HBufC* iDataFilenamePostfix;	  
+
+		// Language package data file name seperator
+		HBufC* iDataFilenameSeperator; 
+	}; 
+#endif      // CSIRESOURCEHANDLER_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/sisrscontrollerplugin/src/sysconfigprovider.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface to provide system configuration information.
+*
+*/
+
+
+#ifndef SYSCONFIGPROVIDER_H
+#define SYSCONFIGPROVIDER_H
+
+// FORWARD DECLARATIONS
+
+class CArrayFixFlat<TInt>;
+class RFs;
+
+
+class MSysConfigProvider {
+public:
+	virtual TInt GetInstalledLanguages( CArrayFixFlat<TInt>*& aLanguages, RFs* aFileServerSession = NULL ) = 0;
+};
+
+#endif
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/siutility/bwins/nsssispeechrecognitionutilityu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,57 @@
+EXPORTS
+	?CreateInstanceL@CSISpeechRecognitionUtility@@SAPAXXZ @ 1 NONAME ; void * CSISpeechRecognitionUtility::CreateInstanceL(void)
+	??1CSISpeechRecognitionUtility@@UAE@XZ @ 2 NONAME ; CSISpeechRecognitionUtility::~CSISpeechRecognitionUtility(void)
+	?ActivateGrammar@CSISpeechRecognitionUtility@@UAEHG@Z @ 3 NONAME ; int CSISpeechRecognitionUtility::ActivateGrammar(unsigned short)
+	?Adapt@CSISpeechRecognitionUtility@@UAEHABVCSIClientResultSet@@H@Z @ 4 NONAME ; int CSISpeechRecognitionUtility::Adapt(class CSIClientResultSet const &, int)
+	?AddPronunciation@CSISpeechRecognitionUtility@@UAEHGABVTDesC16@@W4TLanguage@@AAK@Z @ 5 NONAME ; int CSISpeechRecognitionUtility::AddPronunciation(unsigned short, class TDesC16 const &, enum TLanguage, unsigned long &)
+	?AddRule@CSISpeechRecognitionUtility@@UAEHGGKAAK@Z @ 6 NONAME ; int CSISpeechRecognitionUtility::AddRule(unsigned short, unsigned short, unsigned long, unsigned long &)
+	?AddRuleVariant@CSISpeechRecognitionUtility@@UAEHGGAAV?$RArray@K@@KAAE@Z @ 7 NONAME ; int CSISpeechRecognitionUtility::AddRuleVariant(unsigned short, unsigned short, class RArray<unsigned long> &, unsigned long, unsigned char &)
+	?AddVoiceTag@CSISpeechRecognitionUtility@@UAEHAAVMDesC16Array@@ABV?$RArray@V?$RArray@W4TLanguage@@@@@@GGAAK@Z @ 8 NONAME ; int CSISpeechRecognitionUtility::AddVoiceTag(class MDesC16Array &, class RArray<class RArray<enum TLanguage> > const &, unsigned short, unsigned short, unsigned long &)
+	?AddVoiceTag@CSISpeechRecognitionUtility@@UAEHAAVMDesC16Array@@ABV?$RArray@W4TLanguage@@@@GGAAK@Z @ 9 NONAME ; int CSISpeechRecognitionUtility::AddVoiceTag(class MDesC16Array &, class RArray<enum TLanguage> const &, unsigned short, unsigned short, unsigned long &)
+	?AddVoiceTags@CSISpeechRecognitionUtility@@UAEHABV?$RPointerArray@VMDesC16Array@@@@ABV?$RArray@V?$RArray@W4TLanguage@@@@@@GGAAV?$RArray@K@@@Z @ 10 NONAME ; int CSISpeechRecognitionUtility::AddVoiceTags(class RPointerArray<class MDesC16Array> const &, class RArray<class RArray<enum TLanguage> > const &, unsigned short, unsigned short, class RArray<unsigned long> &)
+	?AddVoiceTags@CSISpeechRecognitionUtility@@UAEHABV?$RPointerArray@VMDesC16Array@@@@ABV?$RArray@W4TLanguage@@@@GGAAV?$RArray@K@@@Z @ 11 NONAME ; int CSISpeechRecognitionUtility::AddVoiceTags(class RPointerArray<class MDesC16Array> const &, class RArray<enum TLanguage> const &, unsigned short, unsigned short, class RArray<unsigned long> &)
+	?Cancel@CSISpeechRecognitionUtility@@UAEXXZ @ 12 NONAME ; void CSISpeechRecognitionUtility::Cancel(void)
+	?CommitChanges@CSISpeechRecognitionUtility@@UAEHXZ @ 13 NONAME ; int CSISpeechRecognitionUtility::CommitChanges(void)
+	?CreateGrammar@CSISpeechRecognitionUtility@@UAEHAAG@Z @ 14 NONAME ; int CSISpeechRecognitionUtility::CreateGrammar(unsigned short &)
+	?CreateInstanceSecondPhaseL@CSISpeechRecognitionUtility@@UAEXVTUid@@0AAVMSISpeechRecognitionUtilityObserver@@@Z @ 15 NONAME ; void CSISpeechRecognitionUtility::CreateInstanceSecondPhaseL(class TUid, class TUid, class MSISpeechRecognitionUtilityObserver &)
+	?CreateLexicon@CSISpeechRecognitionUtility@@UAEHAAG@Z @ 16 NONAME ; int CSISpeechRecognitionUtility::CreateLexicon(unsigned short &)
+	?CreateModelBank@CSISpeechRecognitionUtility@@UAEHAAG@Z @ 17 NONAME ; int CSISpeechRecognitionUtility::CreateModelBank(unsigned short &)
+	?CreateRule@CSISpeechRecognitionUtility@@UAEHGAAK@Z @ 18 NONAME ; int CSISpeechRecognitionUtility::CreateRule(unsigned short, unsigned long &)
+	?DeactivateGrammar@CSISpeechRecognitionUtility@@UAEHG@Z @ 19 NONAME ; int CSISpeechRecognitionUtility::DeactivateGrammar(unsigned short)
+	?EndRecSession@CSISpeechRecognitionUtility@@UAEHXZ @ 20 NONAME ; int CSISpeechRecognitionUtility::EndRecSession(void)
+	?EndRecord@CSISpeechRecognitionUtility@@UAEHXZ @ 21 NONAME ; int CSISpeechRecognitionUtility::EndRecord(void)
+	?GetAllClientGrammarIDs@CSISpeechRecognitionUtility@@UAEHAAV?$RArray@G@@@Z @ 22 NONAME ; int CSISpeechRecognitionUtility::GetAllClientGrammarIDs(class RArray<unsigned short> &)
+	?GetAllClientLexiconIDs@CSISpeechRecognitionUtility@@UAEHAAV?$RArray@G@@@Z @ 23 NONAME ; int CSISpeechRecognitionUtility::GetAllClientLexiconIDs(class RArray<unsigned short> &)
+	?GetAllClientModelBankIDs@CSISpeechRecognitionUtility@@UAEHAAV?$RArray@G@@@Z @ 24 NONAME ; int CSISpeechRecognitionUtility::GetAllClientModelBankIDs(class RArray<unsigned short> &)
+	?GetAllGrammarIDs@CSISpeechRecognitionUtility@@UAEHAAV?$RArray@G@@@Z @ 25 NONAME ; int CSISpeechRecognitionUtility::GetAllGrammarIDs(class RArray<unsigned short> &)
+	?GetAllLexiconIDs@CSISpeechRecognitionUtility@@UAEHAAV?$RArray@G@@@Z @ 26 NONAME ; int CSISpeechRecognitionUtility::GetAllLexiconIDs(class RArray<unsigned short> &)
+	?GetAllModelBankIDs@CSISpeechRecognitionUtility@@UAEHAAV?$RArray@G@@@Z @ 27 NONAME ; int CSISpeechRecognitionUtility::GetAllModelBankIDs(class RArray<unsigned short> &)
+	?GetAllModelIDs@CSISpeechRecognitionUtility@@UAEHGAAV?$RArray@G@@@Z @ 28 NONAME ; int CSISpeechRecognitionUtility::GetAllModelIDs(unsigned short, class RArray<unsigned short> &)
+	?GetAllPronunciationIDs@CSISpeechRecognitionUtility@@UAEHGAAV?$RArray@K@@@Z @ 29 NONAME ; int CSISpeechRecognitionUtility::GetAllPronunciationIDs(unsigned short, class RArray<unsigned long> &)
+	?GetAllRuleIDs@CSISpeechRecognitionUtility@@UAEHGAAV?$RArray@K@@@Z @ 30 NONAME ; int CSISpeechRecognitionUtility::GetAllRuleIDs(unsigned short, class RArray<unsigned long> &)
+	?GetEngineProperties@CSISpeechRecognitionUtility@@UAEHABV?$RArray@H@@AAV2@@Z @ 31 NONAME ; int CSISpeechRecognitionUtility::GetEngineProperties(class RArray<int> const &, class RArray<int> &)
+	?GetModelCount@CSISpeechRecognitionUtility@@UAEHGAAH@Z @ 32 NONAME ; int CSISpeechRecognitionUtility::GetModelCount(unsigned short, int &)
+	?GetRuleValidity@CSISpeechRecognitionUtility@@UAEHGKAAH@Z @ 33 NONAME ; int CSISpeechRecognitionUtility::GetRuleValidity(unsigned short, unsigned long, int &)
+	?LoadEngineParameters@CSISpeechRecognitionUtility@@UAEHABV?$RArray@H@@0@Z @ 34 NONAME ; int CSISpeechRecognitionUtility::LoadEngineParameters(class RArray<int> const &, class RArray<int> const &)
+	?LoadGrammar@CSISpeechRecognitionUtility@@UAEHG@Z @ 35 NONAME ; int CSISpeechRecognitionUtility::LoadGrammar(unsigned short)
+	?LoadLexicon@CSISpeechRecognitionUtility@@UAEHG@Z @ 36 NONAME ; int CSISpeechRecognitionUtility::LoadLexicon(unsigned short)
+	?LoadModels@CSISpeechRecognitionUtility@@UAEHG@Z @ 37 NONAME ; int CSISpeechRecognitionUtility::LoadModels(unsigned short)
+	?NewL@CSISpeechRecognitionUtility@@SAPAV1@AAVMSISpeechRecognitionUtilityObserver@@VTUid@@1@Z @ 38 NONAME ; class CSISpeechRecognitionUtility * CSISpeechRecognitionUtility::NewL(class MSISpeechRecognitionUtilityObserver &, class TUid, class TUid)
+	?NewL@CSISpeechRecognitionUtility@@SAPAV1@AAVMSISpeechRecognitionUtilityObserver@@VTUid@@@Z @ 39 NONAME ; class CSISpeechRecognitionUtility * CSISpeechRecognitionUtility::NewL(class MSISpeechRecognitionUtilityObserver &, class TUid)
+	?NewLC@CSISpeechRecognitionUtility@@SAPAV1@AAVMSISpeechRecognitionUtilityObserver@@VTUid@@@Z @ 40 NONAME ; class CSISpeechRecognitionUtility * CSISpeechRecognitionUtility::NewLC(class MSISpeechRecognitionUtilityObserver &, class TUid)
+	?Recognize@CSISpeechRecognitionUtility@@UAEHAAVCSIClientResultSet@@@Z @ 41 NONAME ; int CSISpeechRecognitionUtility::Recognize(class CSIClientResultSet &)
+	?Record@CSISpeechRecognitionUtility@@UAEHVTTimeIntervalMicroSeconds32@@@Z @ 42 NONAME ; int CSISpeechRecognitionUtility::Record(class TTimeIntervalMicroSeconds32)
+	?RemoveGrammar@CSISpeechRecognitionUtility@@UAEHG@Z @ 43 NONAME ; int CSISpeechRecognitionUtility::RemoveGrammar(unsigned short)
+	?RemoveLexicon@CSISpeechRecognitionUtility@@UAEHG@Z @ 44 NONAME ; int CSISpeechRecognitionUtility::RemoveLexicon(unsigned short)
+	?RemoveModel@CSISpeechRecognitionUtility@@UAEHGG@Z @ 45 NONAME ; int CSISpeechRecognitionUtility::RemoveModel(unsigned short, unsigned short)
+	?RemoveModelBank@CSISpeechRecognitionUtility@@UAEHG@Z @ 46 NONAME ; int CSISpeechRecognitionUtility::RemoveModelBank(unsigned short)
+	?RemovePronunciation@CSISpeechRecognitionUtility@@UAEHGK@Z @ 47 NONAME ; int CSISpeechRecognitionUtility::RemovePronunciation(unsigned short, unsigned long)
+	?RemoveRule@CSISpeechRecognitionUtility@@UAEHGK@Z @ 48 NONAME ; int CSISpeechRecognitionUtility::RemoveRule(unsigned short, unsigned long)
+	?RemoveRules@CSISpeechRecognitionUtility@@UAEHGAAV?$RArray@K@@@Z @ 49 NONAME ; int CSISpeechRecognitionUtility::RemoveRules(unsigned short, class RArray<unsigned long> &)
+	?SetAudioPriority@CSISpeechRecognitionUtility@@UAEHHHHH@Z @ 50 NONAME ; int CSISpeechRecognitionUtility::SetAudioPriority(int, int, int, int)
+	?SetEventHandler@CSISpeechRecognitionUtility@@UAEXPAVMSISpeechRecognitionUtilityObserver@@@Z @ 51 NONAME ; void CSISpeechRecognitionUtility::SetEventHandler(class MSISpeechRecognitionUtilityObserver *)
+	?StartRecSession@CSISpeechRecognitionUtility@@UAEHW4TNSSRecognitionMode@@@Z @ 52 NONAME ; int CSISpeechRecognitionUtility::StartRecSession(enum TNSSRecognitionMode)
+	?UnloadGrammar@CSISpeechRecognitionUtility@@UAEHG@Z @ 53 NONAME ; int CSISpeechRecognitionUtility::UnloadGrammar(unsigned short)
+	?UnloadRule@CSISpeechRecognitionUtility@@UAEHGK@Z @ 54 NONAME ; int CSISpeechRecognitionUtility::UnloadRule(unsigned short, unsigned long)
+	?PreStartSampling@CSISpeechRecognitionUtility@@UAEHXZ @ 55 NONAME ; int CSISpeechRecognitionUtility::PreStartSampling(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/siutility/eabi/nsssispeechrecognitionutilityu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,113 @@
+EXPORTS
+	_ZN27CSISpeechRecognitionUtility15CreateInstanceLEv @ 1 NONAME
+	_ZN27CSISpeechRecognitionUtility10CreateRuleEtRm @ 2 NONAME
+	_ZN27CSISpeechRecognitionUtility10LoadModelsEt @ 3 NONAME
+	_ZN27CSISpeechRecognitionUtility10RemoveRuleEtm @ 4 NONAME
+	_ZN27CSISpeechRecognitionUtility10UnloadRuleEtm @ 5 NONAME
+	_ZN27CSISpeechRecognitionUtility11AddVoiceTagER12MDesC16ArrayRK6RArrayI9TLanguageEttRm @ 6 NONAME
+	_ZN27CSISpeechRecognitionUtility11AddVoiceTagER12MDesC16ArrayRK6RArrayIS2_I9TLanguageEEttRm @ 7 NONAME
+	_ZN27CSISpeechRecognitionUtility11LoadGrammarEt @ 8 NONAME
+	_ZN27CSISpeechRecognitionUtility11LoadLexiconEt @ 9 NONAME
+	_ZN27CSISpeechRecognitionUtility11RemoveModelEtt @ 10 NONAME
+	_ZN27CSISpeechRecognitionUtility11RemoveRulesEtR6RArrayImE @ 11 NONAME
+	_ZN27CSISpeechRecognitionUtility12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayI9TLanguageEttRS5_ImE @ 12 NONAME
+	_ZN27CSISpeechRecognitionUtility12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayIS5_I9TLanguageEEttRS5_ImE @ 13 NONAME
+	_ZN27CSISpeechRecognitionUtility13CommitChangesEv @ 14 NONAME
+	_ZN27CSISpeechRecognitionUtility13CreateGrammarERt @ 15 NONAME
+	_ZN27CSISpeechRecognitionUtility13CreateLexiconERt @ 16 NONAME
+	_ZN27CSISpeechRecognitionUtility13EndRecSessionEv @ 17 NONAME
+	_ZN27CSISpeechRecognitionUtility13GetAllRuleIDsEtR6RArrayImE @ 18 NONAME
+	_ZN27CSISpeechRecognitionUtility13GetModelCountEtRi @ 19 NONAME
+	_ZN27CSISpeechRecognitionUtility13RemoveGrammarEt @ 20 NONAME
+	_ZN27CSISpeechRecognitionUtility13RemoveLexiconEt @ 21 NONAME
+	_ZN27CSISpeechRecognitionUtility13UnloadGrammarEt @ 22 NONAME
+	_ZN27CSISpeechRecognitionUtility14AddRuleVariantEttR6RArrayImEmRh @ 23 NONAME
+	_ZN27CSISpeechRecognitionUtility14GetAllModelIDsEtR6RArrayItE @ 24 NONAME
+	_ZN27CSISpeechRecognitionUtility15ActivateGrammarEt @ 25 NONAME
+	_ZN27CSISpeechRecognitionUtility15CreateModelBankERt @ 26 NONAME
+	_ZN27CSISpeechRecognitionUtility15GetRuleValidityEtmRi @ 27 NONAME
+	_ZN27CSISpeechRecognitionUtility15RemoveModelBankEt @ 28 NONAME
+	_ZN27CSISpeechRecognitionUtility15SetEventHandlerEP35MSISpeechRecognitionUtilityObserver @ 29 NONAME
+	_ZN27CSISpeechRecognitionUtility15StartRecSessionE19TNSSRecognitionMode @ 30 NONAME
+	_ZN27CSISpeechRecognitionUtility16AddPronunciationEtRK7TDesC169TLanguageRm @ 31 NONAME
+	_ZN27CSISpeechRecognitionUtility16GetAllGrammarIDsER6RArrayItE @ 32 NONAME
+	_ZN27CSISpeechRecognitionUtility16GetAllLexiconIDsER6RArrayItE @ 33 NONAME
+	_ZN27CSISpeechRecognitionUtility16SetAudioPriorityEiiii @ 34 NONAME
+	_ZN27CSISpeechRecognitionUtility17DeactivateGrammarEt @ 35 NONAME
+	_ZN27CSISpeechRecognitionUtility18GetAllModelBankIDsER6RArrayItE @ 36 NONAME
+	_ZN27CSISpeechRecognitionUtility19GetEnginePropertiesERK6RArrayIiERS1_ @ 37 NONAME
+	_ZN27CSISpeechRecognitionUtility19RemovePronunciationEtm @ 38 NONAME
+	_ZN27CSISpeechRecognitionUtility20LoadEngineParametersERK6RArrayIiES3_ @ 39 NONAME
+	_ZN27CSISpeechRecognitionUtility22GetAllClientGrammarIDsER6RArrayItE @ 40 NONAME
+	_ZN27CSISpeechRecognitionUtility22GetAllClientLexiconIDsER6RArrayItE @ 41 NONAME
+	_ZN27CSISpeechRecognitionUtility22GetAllPronunciationIDsEtR6RArrayImE @ 42 NONAME
+	_ZN27CSISpeechRecognitionUtility24GetAllClientModelBankIDsER6RArrayItE @ 43 NONAME
+	_ZN27CSISpeechRecognitionUtility26CreateInstanceSecondPhaseLE4TUidS0_R35MSISpeechRecognitionUtilityObserver @ 44 NONAME
+	_ZN27CSISpeechRecognitionUtility4NewLER35MSISpeechRecognitionUtilityObserver4TUid @ 45 NONAME
+	_ZN27CSISpeechRecognitionUtility4NewLER35MSISpeechRecognitionUtilityObserver4TUidS2_ @ 46 NONAME
+	_ZN27CSISpeechRecognitionUtility5AdaptERK18CSIClientResultSeti @ 47 NONAME
+	_ZN27CSISpeechRecognitionUtility5NewLCER35MSISpeechRecognitionUtilityObserver4TUid @ 48 NONAME
+	_ZN27CSISpeechRecognitionUtility6CancelEv @ 49 NONAME
+	_ZN27CSISpeechRecognitionUtility6RecordE27TTimeIntervalMicroSeconds32 @ 50 NONAME
+	_ZN27CSISpeechRecognitionUtility7AddRuleEttmRm @ 51 NONAME
+	_ZN27CSISpeechRecognitionUtility9EndRecordEv @ 52 NONAME
+	_ZN27CSISpeechRecognitionUtility9RecognizeER18CSIClientResultSet @ 53 NONAME
+	_ZN27CSISpeechRecognitionUtilityD0Ev @ 54 NONAME
+	_ZN27CSISpeechRecognitionUtilityD1Ev @ 55 NONAME
+	_ZN27CSISpeechRecognitionUtilityD2Ev @ 56 NONAME
+	_ZTI27CSISpeechRecognitionUtility @ 57 NONAME ; #<TI>#
+	_ZTV27CSISpeechRecognitionUtility @ 58 NONAME ; #<VT>#
+	_ZThn4_N27CSISpeechRecognitionUtility10CreateRuleEtRm @ 59 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility10LoadModelsEt @ 60 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility10RemoveRuleEtm @ 61 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility10UnloadRuleEtm @ 62 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility11AddVoiceTagER12MDesC16ArrayRK6RArrayI9TLanguageEttRm @ 63 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility11AddVoiceTagER12MDesC16ArrayRK6RArrayIS2_I9TLanguageEEttRm @ 64 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility11LoadGrammarEt @ 65 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility11LoadLexiconEt @ 66 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility11RemoveModelEtt @ 67 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility11RemoveRulesEtR6RArrayImE @ 68 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayI9TLanguageEttRS5_ImE @ 69 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility12AddVoiceTagsERK13RPointerArrayI12MDesC16ArrayERK6RArrayIS5_I9TLanguageEEttRS5_ImE @ 70 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13CommitChangesEv @ 71 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13CreateGrammarERt @ 72 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13CreateLexiconERt @ 73 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13EndRecSessionEv @ 74 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13GetAllRuleIDsEtR6RArrayImE @ 75 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13GetModelCountEtRi @ 76 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13RemoveGrammarEt @ 77 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13RemoveLexiconEt @ 78 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility13UnloadGrammarEt @ 79 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility14AddRuleVariantEttR6RArrayImEmRh @ 80 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility14GetAllModelIDsEtR6RArrayItE @ 81 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility15ActivateGrammarEt @ 82 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility15CreateModelBankERt @ 83 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility15GetRuleValidityEtmRi @ 84 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility15RemoveModelBankEt @ 85 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility15SetEventHandlerEP35MSISpeechRecognitionUtilityObserver @ 86 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility15StartRecSessionE19TNSSRecognitionMode @ 87 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility16AddPronunciationEtRK7TDesC169TLanguageRm @ 88 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility16GetAllGrammarIDsER6RArrayItE @ 89 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility16GetAllLexiconIDsER6RArrayItE @ 90 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility16SetAudioPriorityEiiii @ 91 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility17DeactivateGrammarEt @ 92 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility18GetAllModelBankIDsER6RArrayItE @ 93 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility19GetEnginePropertiesERK6RArrayIiERS1_ @ 94 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility19RemovePronunciationEtm @ 95 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility20LoadEngineParametersERK6RArrayIiES3_ @ 96 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility22GetAllClientGrammarIDsER6RArrayItE @ 97 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility22GetAllClientLexiconIDsER6RArrayItE @ 98 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility22GetAllPronunciationIDsEtR6RArrayImE @ 99 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility24GetAllClientModelBankIDsER6RArrayItE @ 100 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility26CreateInstanceSecondPhaseLE4TUidS0_R35MSISpeechRecognitionUtilityObserver @ 101 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility5AdaptERK18CSIClientResultSeti @ 102 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility6CancelEv @ 103 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility6RecordE27TTimeIntervalMicroSeconds32 @ 104 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility7AddRuleEttmRm @ 105 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility9EndRecordEv @ 106 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtility9RecognizeER18CSIClientResultSet @ 107 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtilityD0Ev @ 108 NONAME ; #<thunk>#
+	_ZThn4_N27CSISpeechRecognitionUtilityD1Ev @ 109 NONAME ; #<thunk>#
+	_ZN27CSISpeechRecognitionUtility16PreStartSamplingEv @ 110 NONAME
+	_ZThn4_N27CSISpeechRecognitionUtility16PreStartSamplingEv @ 111 NONAME ; #<thunk>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/siutility/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the bld.inf file which is required by Symbian OS
+*               as part of the standard build procedure.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+
+nsssispeechrecognitionutility.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/siutility/group/nsssispeechrecognitionutility.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for Speech Recognition Utility
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+TARGET          nsssispeechrecognitionutility.dll
+TARGETTYPE      dll
+UID             0x1000008d 0x101FF92D // UID: 270530861
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+SOURCEPATH      ../src
+
+USERINCLUDE     ../inc  ../src
+USERINCLUDE     ../../group // for srsfbldvariant.hrh
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+SOURCE          nsssispeechrecognitionutility.cpp
+
+USERINCLUDE     ../../rubydebug
+
+
+LIBRARY         euser.lib  
+LIBRARY         nsssispeechrecognitioncustomcommands.lib
+LIBRARY         mmfcontrollerframework.lib
+LIBRARY         ecom.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/siutility/src/nsssispeechrecognitionutility.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1286 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the implementation of the speech recognition utility.
+*
+*/
+
+
+// INCLUDE FILES
+#include "rubydebug.h"
+#include "srsfbldvariant.hrh"
+#include "nsssispeechrecognitionutility.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CSISpeechRecognitionUtility
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CSISpeechRecognitionUtility::CSISpeechRecognitionUtility(
+	MSISpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver ) : 
+	iSrCustomCommands(iMMFController)
+	{	
+
+	iSpeechRecognitionUtilityObserver = &aSpeechRecognitionUtilityObserver;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CreateInstanceL
+// Creates instance of CSISpeechRecognitionUtility
+// Needed when dynamically loading nsssispeechrecognitionutility.dll
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TAny* CSISpeechRecognitionUtility::CreateInstanceL()
+    {
+    CSISpeechRecognitionUtility* utility = new (ELeave) CSISpeechRecognitionUtility();
+    return static_cast<MSISpeechRecognitionUtilityBase*>( utility );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CreateInstanceSecondPhaseL
+// Does second phase construction after CreateInstanceL
+// Needed when dynamically loading nsssispeechrecognitionutility.dll
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSISpeechRecognitionUtility::CreateInstanceSecondPhaseL( TUid aClientUid, 
+                                                                       TUid aPluginUid, 
+                                                                       MSISpeechRecognitionUtilityObserver& aObserver )
+    {
+    ConstructL( aClientUid, aPluginUid, aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CSISpeechRecognitionUtility
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CSISpeechRecognitionUtility::CSISpeechRecognitionUtility(): iSrCustomCommands( iMMFController )
+    {	
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// FindSpeechPluginL
+// Searches for SI Controller Plugin.
+// -----------------------------------------------------------------------------
+//
+TUid FindSpeechPluginL()
+    {
+    RUBY_DEBUG_BLOCK( "CSISpeechRecognitionUtility::FindSpeechPluginL" );
+
+	RMMFControllerImplInfoArray controllers;
+	CleanupResetAndDestroyPushL(controllers);
+
+	CMMFControllerPluginSelectionParameters* selectionParams = 
+					CMMFControllerPluginSelectionParameters::NewLC();
+
+	// Select the media IDs to allow
+	RArray<TUid> mediaIds;
+	CleanupClosePushL(mediaIds);
+	User::LeaveIfError(mediaIds.Append(KUidMediaTypeSI));
+	selectionParams->SetMediaIdsL(mediaIds,
+			CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds);
+	CleanupStack::PopAndDestroy(&mediaIds);
+
+	selectionParams->ListImplementationsL(controllers);	
+	
+	// make sure at least on controller has been found
+	if( ! controllers.Count() )
+	    {
+        RUBY_DEBUG1( "No controllers found using media type %x", KUidMediaTypeSI );
+		User::Leave( KErrNotFound );
+    	}
+
+    TUid result = controllers[0]->Uid();
+
+    CleanupStack::PopAndDestroy( 2 );
+    return( result );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionUtility::ConstructL( TUid aClientUid, 
+                                              TUid aPluginUid, 
+                                              MSISpeechRecognitionUtilityObserver& aObserver )
+    {
+    RUBY_DEBUG_BLOCK( "CSISpeechRecognitionUtility::ConstructL" );
+    
+    iSpeechRecognitionUtilityObserver = &aObserver;
+    
+    // dummy priority settings, they are set for real when record, recognize 
+    // and playback are called
+    TMMFPrioritySettings prioritySettings;
+    prioritySettings.iPriority = 0;
+    prioritySettings.iPref = (TMdaPriorityPreference) 0;
+    prioritySettings.iState = EMMFStateIdle; // idle
+    
+    if ( aPluginUid.iUid == 0 )
+        {
+        aPluginUid = FindSpeechPluginL();
+        }
+    
+    // load the controller
+    // coded this way for debugging
+    TInt err;
+    if ((err = iMMFController.Open(aPluginUid, prioritySettings))
+        == KErrNone) 
+        {
+        // start the event monitor
+        iControllerEventMonitor = 
+            CMMFControllerEventMonitor::NewL(*this, iMMFController);
+        iControllerEventMonitor->Start();
+        }
+    else
+        {
+        RUBY_DEBUG2( "Unable to load controller plugin, error = %d, UID = %x", err, aPluginUid.iUid );
+        User::Leave(err);
+        }
+    
+    User::LeaveIfError(iSrCustomCommands.SetClientUid(aClientUid));
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSISpeechRecognitionUtility* CSISpeechRecognitionUtility::NewL(
+	MSISpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
+	{
+
+	CSISpeechRecognitionUtility* self = NewLC(aSpeechRecognitionUtilityObserver, aClientUid);
+	// remove the pointer from the cleanup stack
+	CleanupStack::Pop( self );	
+    return self;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::NewLC
+// Two-phased constructor, leaves a pointer to the object on the stack.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSISpeechRecognitionUtility* CSISpeechRecognitionUtility::NewLC(
+	MSISpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver, TUid aClientUid)
+	{
+
+	CSISpeechRecognitionUtility* self = new (ELeave)  
+		CSISpeechRecognitionUtility(aSpeechRecognitionUtilityObserver);
+    // push onto cleanup stack 
+    // (in case self->ConstructL leaves)
+    CleanupStack::PushL(self);
+	// use two-stage construct
+    // Plugin UID == 0 -> List all plugins and pick any suitable
+    self->ConstructL( aClientUid, KNullUid, aSpeechRecognitionUtilityObserver );
+    return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSISpeechRecognitionUtility* CSISpeechRecognitionUtility::NewL(
+	MSISpeechRecognitionUtilityObserver& aSpeechRecognitionUtilityObserver,
+    TUid aClientUid,
+    TUid aMmfPluginUid )
+    {
+	CSISpeechRecognitionUtility* self = new (ELeave)  
+		CSISpeechRecognitionUtility(aSpeechRecognitionUtilityObserver);
+    // push onto cleanup stack 
+    // (in case self->ConstructL leaves)
+    CleanupStack::PushL( self );
+	// use two-stage construct
+    self->ConstructL(aClientUid, aMmfPluginUid, aSpeechRecognitionUtilityObserver);      
+    CleanupStack::Pop( self );
+    return( NULL );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::~CSISpeechRecognitionUtility
+// The destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CSISpeechRecognitionUtility::~CSISpeechRecognitionUtility()
+	{
+
+	// indicate we don't want any callbacks
+	SetEventHandler(NULL);
+	// cancel any pending requests
+	if ( iControllerEventMonitor )	// make sure we have a valid pointer
+	{
+		iControllerEventMonitor->Cancel();
+	}
+
+	delete iControllerEventMonitor;
+	iMMFController.Close();
+
+    REComSession::FinalClose();
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::GetEngineProperties
+// Retreive the properties of the underlying speech recognition engine. Returns
+// an object containing the engine properties in the aProperties variable.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetEngineProperties(
+	const RArray<TInt>& aPropertyId, 
+	RArray<TInt>& aPropertyValue)
+	{
+	return iSrCustomCommands.GetEngineProperties(aPropertyId, 
+									aPropertyValue);
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::Adapt
+// Performs adaptation for acoustic models based on correct result.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::Adapt(
+    const CSIClientResultSet& aResultSet,
+    TInt aCorrect )
+    {
+    return iSrCustomCommands.Adapt( aResultSet, aCorrect );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddPronunciation
+// Adds a new pronunciation into the Lexicon. Returns an the ID of the 
+// pronunciation in the aPronunciationID variable.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::AddPronunciation(
+    TSILexiconID aLexiconID,
+    const TDesC& aTextForTraining,
+    TLanguage aLanguage,
+    TSIPronunciationID& aPronunciationID)
+    {
+    return iSrCustomCommands.AddPronunciation( aLexiconID, aTextForTraining,
+                                               aLanguage, aPronunciationID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddRule
+// Adds a new rule into the Grammar. Returns an the ID of the pronunciation 
+// in the aPronunciationID variable.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::AddRule(
+	TSIGrammarID aGrammarID, 
+	TSILexiconID aLexiconID, 
+	TSIPronunciationID aPronunciationID, 
+	TSIRuleID& aRuleID)
+	{
+
+	// async
+	return iSrCustomCommands.AddRule(aGrammarID, aLexiconID, 
+				aPronunciationID, aRuleID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddRuleVariant
+// Adds a new rule variant for the given pronunciation into the 
+// specified grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::AddRuleVariant(
+    TSIGrammarID aGrammarID,
+    TSILexiconID aLexiconID,
+    RArray<TSIPronunciationID>& aPronunciationIDs,
+    TSIRuleID aRuleID,
+    TSIRuleVariantID& aRuleVariantID )
+    {
+    return iSrCustomCommands.AddRuleVariant( aGrammarID, aLexiconID, aPronunciationIDs, aRuleID, aRuleVariantID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddVoiceTag
+// Adds a new rule for the given phrase into the 
+// specified grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::AddVoiceTag( MDesCArray& aTextArray,
+                                                        const RArray<TLanguage>& aLanguageArray,
+                                                        TSILexiconID aLexiconID,
+                                                        TSIGrammarID aGrammarID,
+                                                        TSIRuleID& aRuleID )
+    {
+    return iSrCustomCommands.AddVoiceTag( aTextArray, aLanguageArray,
+                                          aLexiconID, aGrammarID, aRuleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddVoiceTag
+// Adds a new rule for the given phrase into the 
+// specified grammar.
+// -----------------------------------------------------------------------------
+//
+#ifdef __SINDE_TRAINING
+EXPORT_C TInt CSISpeechRecognitionUtility::AddVoiceTag( MDesCArray& aTextArray,
+                                                        const RArray<RLanguageArray>& aLanguageArray,
+                                                        TSILexiconID aLexiconID,
+                                                        TSIGrammarID aGrammarID,
+                                                        TSIRuleID& aRuleID )
+    {
+    return iSrCustomCommands.AddVoiceTag( aTextArray, aLanguageArray,
+                                          aLexiconID, aGrammarID, aRuleID );
+    }
+#else
+EXPORT_C TInt CSISpeechRecognitionUtility::AddVoiceTag( MDesCArray& /*aTextArray*/,
+                                                        const RArray<RLanguageArray>& /*aLanguageArray*/,
+                                                        TSILexiconID /*aLexiconID*/,
+                                                        TSIGrammarID /*aGrammarID*/,
+                                                        TSIRuleID& /*aRuleID*/ )
+    {
+    return KErrNotSupported;
+    }
+#endif // __SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddVoiceTags
+// Adds a new rules for the given phrases into the 
+// specified grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                                         const RArray<TLanguage>& aLanguageArray,
+                                                         TSILexiconID aLexiconID,
+                                                         TSIGrammarID aGrammarID, 
+                                                         RArray<TSIRuleID>& aRuleIDArray )
+    {
+    if ( iRuleIDs != 0 )
+        {
+        return( KErrInUse );
+        }
+    iRuleIDs = &aRuleIDArray;
+
+    return iSrCustomCommands.AddVoiceTags( aTextArrayArray, aLanguageArray,
+                                           aLexiconID, aGrammarID, aRuleIDArray);
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::AddVoiceTags
+// Adds a new rules for the given phrases into the 
+// specified grammar.
+// -----------------------------------------------------------------------------
+//
+#ifdef __SINDE_TRAINING
+EXPORT_C TInt CSISpeechRecognitionUtility::AddVoiceTags( const RPointerArray<MDesCArray>& aTextArrayArray,
+                                                         const RArray<RLanguageArray>& aLanguageArray,
+                                                         TSILexiconID aLexiconID,
+                                                         TSIGrammarID aGrammarID, 
+                                                         RArray<TSIRuleID>& aRuleIDArray )
+    {
+    if ( iRuleIDs != 0 )
+        {
+        return( KErrInUse );
+        }
+    iRuleIDs = &aRuleIDArray;
+
+    return iSrCustomCommands.AddVoiceTags( aTextArrayArray, aLanguageArray,
+                                           aLexiconID, aGrammarID, aRuleIDArray );
+    }
+#else
+EXPORT_C TInt CSISpeechRecognitionUtility::AddVoiceTags( const RPointerArray<MDesCArray>& /*aTextArrayArray*/,
+                                                         const RArray<RLanguageArray>& /*aLanguageArray*/,
+                                                         TSILexiconID /*aLexiconID*/,
+                                                         TSIGrammarID /*aGrammarID*/, 
+                                                         RArray<TSIRuleID>& /*aRuleIDArray*/ )
+    {
+    return KErrNotSupported;
+    }
+#endif // __SINDE_TRAINING
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::Cancel
+// Cancel the current asynchronous operation.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSISpeechRecognitionUtility::Cancel()
+	{
+
+	iSrCustomCommands.Cancel();
+
+	// Now cancel has been called, so we can get rid of pointers
+	iPronunciationIDs = NULL;
+	iRuleIDs = NULL;
+	iModelIDs = NULL;
+	iResultSet = NULL;
+	iGrammarIDs = NULL;
+	iLexiconIDs = NULL;
+	iModelBankIDs = NULL;
+
+    iSIResultSet = NULL;
+    iResultSet = NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::CommitChanges
+// Commit the current changes to permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::CommitChanges()
+	{
+
+	// async
+	return iSrCustomCommands.CommitChanges();
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CreateGrammar
+// Create a new grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::CreateGrammar(
+	TSIGrammarID& aGrammarID)
+	{
+
+	// async
+	return iSrCustomCommands.CreateGrammar(aGrammarID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CreateLexicon
+// Create a new lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::CreateLexicon(
+	TSILexiconID& aLexiconID)
+	{
+
+	// async
+	return iSrCustomCommands.CreateLexicon(aLexiconID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CreateRule
+// Creates a new rule.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::CreateRule(
+    TSIGrammarID aGrammarID,
+    TSIRuleID& aRuleID )
+    {
+    return iSrCustomCommands.CreateRule( aGrammarID, aRuleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::LoadModels
+// Loads the model specified by aModelBankID into the recognizer.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::LoadModels(
+	TSIModelBankID aModelBankID)
+	{
+
+	// async
+	return iSrCustomCommands.LoadModels(aModelBankID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::LoadGrammar
+// Loads the grammar specified by aGrammarID into the recognizer.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::LoadGrammar(
+	TSIGrammarID aGrammarID)
+	{
+
+	// async
+	return iSrCustomCommands.LoadGrammar(aGrammarID);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::ActivateGrammar
+// Activates the grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::ActivateGrammar(
+	TSIGrammarID aGrammarID)
+	{
+
+	// async
+	return iSrCustomCommands.ActivateGrammar(aGrammarID);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::DeactivateGrammar
+// Deactivates the grammar.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::DeactivateGrammar(
+	TSIGrammarID aGrammarID)
+	{
+
+	// async
+	return iSrCustomCommands.DeactivateGrammar(aGrammarID);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::LoadLexicon
+// Loads the lexicon specified by aLexiconID into the recognizer.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::LoadLexicon(
+	TSILexiconID aLexiconID)
+	{
+
+	// async
+	return iSrCustomCommands.LoadLexicon(aLexiconID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::GetModelCount
+// Returns the number of models in the model bank specified by aModelBankID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetModelCount(
+	TSIModelBankID aModelBankID, 
+	TInt& aModelCount)
+	{
+
+	// async
+	return iSrCustomCommands.GetModelCount(aModelBankID, aModelCount);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::EndRecSession
+// Ends the current recognition session and frees the associated resources.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::EndRecSession()
+	{
+
+	return iSrCustomCommands.EndRecSession();
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::EndRecSession
+// Start a recognition session and and allocate the required resources.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::StartRecSession(
+	TNSSRecognitionMode aMode)
+	{
+
+	return iSrCustomCommands.StartRecSession(aMode);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::Recognize
+// Initiates recognition.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::Recognize(
+	CSIClientResultSet& aResultSet)
+	{
+    if ( iSIResultSet != NULL || iResultSet != NULL )
+        {
+        return( KErrInUse );
+        }
+	TInt err = iSrCustomCommands.Recognize( aResultSet );
+
+    if ( err == KErrNone )
+        {
+        iSIResultSet = &aResultSet;
+        }
+
+    return( err );
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::Record
+// Begins recording the utterance for aRecordTime microseconds.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::Record(
+	TTimeIntervalMicroSeconds32 aRecordTime)
+	{
+    // setup the priority for recognition
+	TMMFPrioritySettings prioritySettings;
+	prioritySettings.iPriority = iAudioPriority;
+	prioritySettings.iPref = (TMdaPriorityPreference) iRecognitionPreference;
+	prioritySettings.iState = EMMFStateIdle; // idle
+	iMMFController.SetPrioritySettings(prioritySettings);
+
+	// async
+	return iSrCustomCommands.Record(aRecordTime);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::EndRecord
+// Begins recording the utterance for aRecordTime microseconds.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::EndRecord()
+	{
+    return iSrCustomCommands.EndRecord();
+	}
+	
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::PreStartSampling
+// Begins sampling before the actual recognition.
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TInt CSISpeechRecognitionUtility::PreStartSampling()
+    {
+    return iSrCustomCommands.PreStartSampling();
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemoveGrammar
+// Removes the grammer specified by aGrammarID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemoveGrammar(
+	TSIGrammarID aGrammarID)
+	{
+
+	// async
+	return iSrCustomCommands.RemoveGrammar(aGrammarID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemovePronunciation
+// Removes the pronunciation specified by aPronunciationID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemovePronunciation(
+	TSILexiconID aLexiconID, 
+	TSIPronunciationID aPronunciationID)
+	{
+
+	// async
+	return iSrCustomCommands.RemovePronunciation(aLexiconID, aPronunciationID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemoveLexicon
+// Removes the lexicon specified by aLexiconID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemoveLexicon(
+	TSILexiconID aLexiconID)
+	{
+
+	// async
+	return iSrCustomCommands.RemoveLexicon(aLexiconID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemoveModel
+// Removes the model specified by aModelID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemoveModel(
+	TSIModelBankID aModelBankID, 
+	TSIModelID aModelID)
+	{
+
+	// async
+	return iSrCustomCommands.RemoveModel(aModelBankID, aModelID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemoveRule
+// Removes the rule specified by aRuleID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemoveRule(
+	TSIGrammarID aGrammarID, 
+	TSIRuleID aRuleID)
+	{
+
+	// async
+	return iSrCustomCommands.RemoveRule(aGrammarID, aRuleID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemoveRules
+// Removes the rule specified by aRuleID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemoveRules(
+	TSIGrammarID aGrammarID, 
+	RArray<TSIRuleID>& aRuleIDs)
+	{
+
+	// async
+	return iSrCustomCommands.RemoveRules(aGrammarID, aRuleIDs);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::UnloadRule
+// Unloads a rule temporary memory. The rule in the permanent storage is not 
+// removed.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::UnloadRule(
+	TSIGrammarID aGrammarID, 
+	TSIRuleID aRuleID)
+	{
+
+	// async
+	return iSrCustomCommands.UnloadRule(aGrammarID, aRuleID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::UnloadGrammar
+// Unloads the specified grammar from the list of grammars
+// in temporary memory, previously loaded with LoadGrammarL.  
+// The grammar in the permanent storage remains intact.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::UnloadGrammar(
+    TSIGrammarID aGrammarID )
+    {
+    return iSrCustomCommands.UnloadGrammar( aGrammarID );
+    }
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::SetEventHandler
+// Sets the callback address for asynchronous functions.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CSISpeechRecognitionUtility::SetEventHandler(
+	MSISpeechRecognitionUtilityObserver* aSpeechRecognitionUtilityObserver)
+	{
+
+	// save the new event handler callback address
+	iSpeechRecognitionUtilityObserver = aSpeechRecognitionUtilityObserver;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::GetAllPronunciationIDs
+// Returns all pronunciation IDs that exist in the aLexiconID lexicon.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllPronunciationIDs(
+	TSILexiconID aLexiconID, 
+	RArray <TSIPronunciationID>& aPronunciationIDs)
+	{
+
+	if (iPronunciationIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllPronunciationIDs(aLexiconID);
+	
+	
+	if (err == KErrNone)
+	{
+		iPronunciationIDs = &aPronunciationIDs;
+	}
+	
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::GetAllClientGrammarIDs
+// Returns all client grammar IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllClientGrammarIDs( 
+	RArray <TSIGrammarID>& aGrammarIDs )
+	{
+
+
+	if (iGrammarIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllClientGrammarIDs();
+	
+	if (err == KErrNone)
+	{
+		iGrammarIDs = &aGrammarIDs;
+	}
+	
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::GetAllClientLexiconIDs
+// Returns all client lexicon IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllClientLexiconIDs( 
+	RArray <TSILexiconID>& aLexiconIDs )
+	{
+
+	if (iLexiconIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllClientLexiconIDs();
+	
+	if (err == KErrNone)
+	{
+		iLexiconIDs = &aLexiconIDs;
+	}
+	
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::GetAllClientModelBankIDs
+// Returns all client model bank IDs.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllClientModelBankIDs( 
+	RArray <TSIModelBankID>& aModelBankIDs )
+	{
+
+	if (iModelBankIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllClientModelBankIDs();
+	
+	if (err == KErrNone)
+	{
+		iModelBankIDs = &aModelBankIDs;
+	}
+	
+	return err;
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::GetAllGrammarIDs
+// Returns all grammar IDs for all clients.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllGrammarIDs( 
+	RArray <TSIGrammarID>& aGrammarIDs )
+	{
+
+	if (iGrammarIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllGrammarIDs();
+	
+	if (err == KErrNone)
+	{
+		iGrammarIDs = &aGrammarIDs;
+	}
+	
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::GetAllLexiconIDs
+// Returns all lexicon IDs for all clients.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllLexiconIDs( 
+	RArray <TSILexiconID>& aLexiconIDs )
+	{
+
+	if (iLexiconIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllLexiconIDs();
+	
+	if (err == KErrNone)
+	{
+		iLexiconIDs = &aLexiconIDs;
+	}
+	
+	return err;
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSpeechRecognitionCustomCommandParser::GetAllModelBankIDs
+// Returns all model bank IDs for all clients.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllModelBankIDs( 
+	RArray <TSIModelBankID>& aModelBankIDs )
+	{
+
+	if (iModelBankIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllModelBankIDs();
+	
+	if (err == KErrNone)
+	{
+		iModelBankIDs = &aModelBankIDs;
+	}
+
+	return err;
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::GetAllModelIDs
+// Returns all model IDs that exist in the aModelBankID bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllModelIDs(
+	TSIModelBankID aModelBankID, 
+	RArray <TSIModelID>& aModelIDs)
+	{
+
+	if (iModelIDs != NULL)
+	{
+		return KErrInUse;
+	}
+
+	TInt err = iSrCustomCommands.GetAllModelIDs(aModelBankID);
+	
+	if (err == KErrNone)
+	{
+		iModelIDs = &aModelIDs;
+	}
+
+	return err;
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::GetRuleValidity
+// Returns whether the specified rule is valid in the aValid variable.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetRuleValidity(
+	TSIGrammarID aGrammarID, 
+	TSIRuleID aRuleID, 
+	TBool& aValid)
+	{
+
+	// async
+	return iSrCustomCommands.GetRuleValidity(aGrammarID, aRuleID, aValid);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::GetAllRuleIDs
+// Returns all grammar IDs that exist in the aGrammarID bank.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::GetAllRuleIDs(
+	TSIGrammarID aGrammarID, 
+	RArray <TSIRuleID>& aRuleIDs)
+	{
+
+	if (iRuleIDs != NULL)
+	{
+		return KErrInUse;
+	}
+		
+	TInt err = iSrCustomCommands.GetAllRuleIDs(aGrammarID);
+	
+	if (err == KErrNone)	
+	{
+		iRuleIDs = &aRuleIDs;
+	}
+		
+	return err;
+	
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::CreateModelBank
+// Creates a model bank and returns ID of the new model bank in aModelBankID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::CreateModelBank(
+	TSIModelBankID& aModelBankID)
+	{
+
+	// async
+	return iSrCustomCommands.CreateModelBank(aModelBankID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::RemoveModelBank
+// Removes the model bank specified by aModelBankID from permanent storage.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::RemoveModelBank(
+	TSIModelBankID aModelBankID)
+	{
+
+	// async
+	return iSrCustomCommands.RemoveModelBank(aModelBankID);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::LoadEngineParameters
+// Sends a command to the controller to load the parameters into
+// the engine.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::LoadEngineParameters(
+	const RArray<TInt>& aParameterId, 
+	const RArray<TInt>& aParameterValue)
+	{
+
+	return iSrCustomCommands.LoadEngineParameters(aParameterId, aParameterValue);
+
+	}
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::SetAudioPriority
+// Set the audio priority and preference for training, recognition and
+// playback.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CSISpeechRecognitionUtility::SetAudioPriority(
+	TInt aPriority, 
+	TInt aTrainPreference, 
+	TInt aPlaybackPreference, 
+	TInt aRecognitionPreference)
+	{
+	
+	iAudioPriority = aPriority;
+	iTrainPreference = aTrainPreference;
+	iPlaybackPreference = aPlaybackPreference;
+	iRecognitionPreference = aRecognitionPreference;
+
+	return KErrNone;
+
+	}
+
+
+// -----------------------------------------------------------------------------
+// CSISpeechRecognitionUtility::HandleEvent
+// Callback function for asynchrounus events. Settting the address to NULL
+// insures no unexpected callback will occur.
+// -----------------------------------------------------------------------------
+//
+void CSISpeechRecognitionUtility::HandleEvent( const TMMFEvent& aEvent )
+	{
+
+	TBool cancelled = EFalse;
+
+	TInt event = (TInt)aEvent.iEventType.iUid;
+	TInt result = (TInt)aEvent.iErrorCode;
+
+    RUBY_DEBUG2( "CSISpeechRecognitionUtility::HandleEvent() - Event Type = %d, Event Result = %d", event, result );
+
+	switch (event)
+	    {
+		case KUidAsrEventGetAllPronunciationIDsVal:
+			if (iPronunciationIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, 
+						iSrCustomCommands.GetPronunciationIDArrayL(*iPronunciationIDs));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iPronunciationIDs = NULL;
+			}
+			else 
+			{
+				cancelled = ETrue;
+			}
+			break;
+		
+
+		case KUidAsrEventGetAllRuleIDsVal:
+			if (iRuleIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, iSrCustomCommands.GetRuleIDArrayL(*iRuleIDs));		
+				}
+				// async operation complete, so no need to store pointer anymore	
+				iRuleIDs = NULL;
+			}
+			else
+			{
+				cancelled = ETrue;
+			}
+			break;
+
+		case KUidAsrEventGetAllModelIDsVal:
+			if (iModelIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, iSrCustomCommands.GetModelIDArrayL(*iModelIDs));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iModelIDs = NULL;
+			}
+			else
+			{
+				cancelled = ETrue;
+			}
+			break;
+
+		case KUidAsrEventRecordVal:
+			// if the record function has an error during recognition 
+			// then clear iResultSet pointer.
+			if ( (iResultSet) && (result != KErrNone) )
+			{
+				// async operation complete, so no need to store pointer anymore
+				iResultSet = NULL;
+			}
+			break;
+
+		// both of these conditions can use the same functionality
+		case KUidAsrEventGetAllClientGrammarIDsVal:
+		case KUidAsrEventGetAllGrammarIDsVal:
+			if (iGrammarIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, iSrCustomCommands.GetGrammarIDArrayL(*iGrammarIDs));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iGrammarIDs = NULL;
+			}
+			else
+			{
+				cancelled = ETrue;
+			}
+			break;
+
+		// both of these conditions can use the same functionality
+		case KUidAsrEventGetAllClientLexiconIDsVal:
+		case KUidAsrEventGetAllLexiconIDsVal:
+			if (iLexiconIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, iSrCustomCommands.GetLexiconIDArrayL(*iLexiconIDs));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iLexiconIDs = NULL;
+			}
+			else
+			{
+				cancelled = ETrue;
+			}
+			break;
+
+		// both of these conditions can use the same functionality
+		case KUidAsrEventGetAllClientModelBankIDsVal:
+		case KUidAsrEventGetAllModelBankIDsVal:
+
+			if (iModelBankIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, iSrCustomCommands.GetModelBankIDArrayL(*iModelBankIDs));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iModelBankIDs = NULL;
+			}
+			else
+			{
+				cancelled = ETrue;
+			}
+			break;
+
+        // SI functions, which require postprocessing
+        case KUidAsrEventAddVoiceTagsVal:
+
+			if (iRuleIDs)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, 
+						iSrCustomCommands.GetRuleIDArrayL(*iRuleIDs));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iRuleIDs = NULL;
+			}
+			else 
+			{
+				cancelled = ETrue;
+			}
+            break;
+
+        case KUidAsrEventRecognitionVal:
+
+			if (iSIResultSet)
+			{
+				if ( result == KErrNone )
+				{
+					TRAP(result, iSrCustomCommands.GetSIResultSetL(*iSIResultSet));
+				}
+				// async operation complete, so no need to store pointer anymore
+				iSIResultSet = NULL;
+			}
+			else
+			{
+				cancelled = ETrue;
+			}
+			break;
+          
+		default:
+			break;
+	
+	    }
+
+	if ( iSpeechRecognitionUtilityObserver && !cancelled )
+        {
+        iSpeechRecognitionUtilityObserver->MsruoEvent( aEvent.iEventType, result );
+        }
+	}
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/client/bwins/speechsynthesisu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+EXPORTS
+	??0RSpeechSynthesis@@QAE@XZ @ 1 NONAME ; RSpeechSynthesis::RSpeechSynthesis(void)
+	?Close@RSpeechSynthesis@@QAEXXZ @ 2 NONAME ; void RSpeechSynthesis::Close(void)
+	?CustomCommandL@RSpeechSynthesis@@QAEXHH@Z @ 3 NONAME ; void RSpeechSynthesis::CustomCommandL(int, int)
+	?DurationL@RSpeechSynthesis@@QAE?AVTTimeIntervalMicroSeconds@@XZ @ 4 NONAME ; class TTimeIntervalMicroSeconds RSpeechSynthesis::DurationL(void)
+	?GetLanguagesL@RSpeechSynthesis@@QAEXAAV?$RArray@W4TLanguage@@@@@Z @ 5 NONAME ; void RSpeechSynthesis::GetLanguagesL(class RArray<enum TLanguage> &)
+	?GetVoicesL@RSpeechSynthesis@@QAEXAAV?$RArray@VTVoice@@@@W4TLanguage@@@Z @ 6 NONAME ; void RSpeechSynthesis::GetVoicesL(class RArray<class TVoice> &, enum TLanguage)
+	?InitialiseSynthesis@RSpeechSynthesis@@QAEXABVTDesC16@@AAVTRequestStatus@@@Z @ 7 NONAME ; void RSpeechSynthesis::InitialiseSynthesis(class TDesC16 const &, class TRequestStatus &)
+	?InitialiseSynthesis@RSpeechSynthesis@@QAEXABVTDesC16@@ABV?$TBuf@$0BAA@@@AAVTRequestStatus@@@Z @ 8 NONAME ; void RSpeechSynthesis::InitialiseSynthesis(class TDesC16 const &, class TBuf<256> const &, class TRequestStatus &)
+	?MaxSpeakingRateL@RSpeechSynthesis@@QAEHXZ @ 9 NONAME ; int RSpeechSynthesis::MaxSpeakingRateL(void)
+	?MaxVolumeL@RSpeechSynthesis@@QAEHXZ @ 10 NONAME ; int RSpeechSynthesis::MaxVolumeL(void)
+	?Open@RSpeechSynthesis@@QAEHXZ @ 11 NONAME ; int RSpeechSynthesis::Open(void)
+	?PauseL@RSpeechSynthesis@@QAEXXZ @ 12 NONAME ; void RSpeechSynthesis::PauseL(void)
+	?SetAudioPriorityL@RSpeechSynthesis@@QAEXHH@Z @ 13 NONAME ; void RSpeechSynthesis::SetAudioPriorityL(int, int)
+	?SetSpeakingRateL@RSpeechSynthesis@@QAEXH@Z @ 14 NONAME ; void RSpeechSynthesis::SetSpeakingRateL(int)
+	?SetVoiceL@RSpeechSynthesis@@QAEXABVTVoice@@@Z @ 15 NONAME ; void RSpeechSynthesis::SetVoiceL(class TVoice const &)
+	?SetVolumeL@RSpeechSynthesis@@QAEXH@Z @ 16 NONAME ; void RSpeechSynthesis::SetVolumeL(int)
+	?SpeakingRateL@RSpeechSynthesis@@QAEHXZ @ 17 NONAME ; int RSpeechSynthesis::SpeakingRateL(void)
+	?StopL@RSpeechSynthesis@@QAEXXZ @ 18 NONAME ; void RSpeechSynthesis::StopL(void)
+	?Synthesise@RSpeechSynthesis@@QAEXAAVTRequestStatus@@@Z @ 19 NONAME ; void RSpeechSynthesis::Synthesise(class TRequestStatus &)
+	?VoiceL@RSpeechSynthesis@@QAE?AVTVoice@@XZ @ 20 NONAME ; class TVoice RSpeechSynthesis::VoiceL(void)
+	?VolumeL@RSpeechSynthesis@@QAEHXZ @ 21 NONAME ; int RSpeechSynthesis::VolumeL(void)
+	?SetAudioOutputL@RSpeechSynthesis@@QAEXW4TTtsAudioOutput@1@@Z @ 22 NONAME ; void RSpeechSynthesis::SetAudioOutputL(enum RSpeechSynthesis::TTtsAudioOutput)
+	?InitialiseSynthesis@RSpeechSynthesis@@QAEXABVTDesC16@@AAVTDes8@@AAVTRequestStatus@@@Z @ 23 NONAME ; void RSpeechSynthesis::InitialiseSynthesis(class TDesC16 const &, class TDes8 &, class TRequestStatus &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/client/eabi/speechsynthesisu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+EXPORTS
+	_ZN16RSpeechSynthesis10GetVoicesLER6RArrayI6TVoiceE9TLanguage @ 1 NONAME
+	_ZN16RSpeechSynthesis10MaxVolumeLEv @ 2 NONAME
+	_ZN16RSpeechSynthesis10SetVolumeLEi @ 3 NONAME
+	_ZN16RSpeechSynthesis10SynthesiseER14TRequestStatus @ 4 NONAME
+	_ZN16RSpeechSynthesis13GetLanguagesLER6RArrayI9TLanguageE @ 5 NONAME
+	_ZN16RSpeechSynthesis13SpeakingRateLEv @ 6 NONAME
+	_ZN16RSpeechSynthesis14CustomCommandLEii @ 7 NONAME
+	_ZN16RSpeechSynthesis16MaxSpeakingRateLEv @ 8 NONAME
+	_ZN16RSpeechSynthesis16SetSpeakingRateLEi @ 9 NONAME
+	_ZN16RSpeechSynthesis17SetAudioPriorityLEii @ 10 NONAME
+	_ZN16RSpeechSynthesis19InitialiseSynthesisERK7TDesC16R14TRequestStatus @ 11 NONAME
+	_ZN16RSpeechSynthesis19InitialiseSynthesisERK7TDesC16RK4TBufILi256EER14TRequestStatus @ 12 NONAME
+	_ZN16RSpeechSynthesis4OpenEv @ 13 NONAME
+	_ZN16RSpeechSynthesis5CloseEv @ 14 NONAME
+	_ZN16RSpeechSynthesis5StopLEv @ 15 NONAME
+	_ZN16RSpeechSynthesis6PauseLEv @ 16 NONAME
+	_ZN16RSpeechSynthesis6VoiceLEv @ 17 NONAME
+	_ZN16RSpeechSynthesis7VolumeLEv @ 18 NONAME
+	_ZN16RSpeechSynthesis9DurationLEv @ 19 NONAME
+	_ZN16RSpeechSynthesis9SetVoiceLERK6TVoice @ 20 NONAME
+	_ZN16RSpeechSynthesisC1Ev @ 21 NONAME
+	_ZN16RSpeechSynthesisC2Ev @ 22 NONAME
+	_ZN16RSpeechSynthesis15SetAudioOutputLENS_15TTtsAudioOutputE @ 23 NONAME
+	_ZN16RSpeechSynthesis19InitialiseSynthesisERK7TDesC16R5TDes8R14TRequestStatus @ 24 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/client/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for Speech synthesis server clien side
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+
+speechsynthesis.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/client/group/speechsynthesis.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          speechsynthesis.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10281A70
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+SOURCEPATH      ../src
+SOURCE          speechsynthesis.cpp
+
+USERINCLUDE     ../../server/inc
+
+APP_LAYER_SYSTEMINCLUDE 
+
+LIBRARY         efsrv.lib 
+LIBRARY         estor.lib 
+LIBRARY         euser.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/client/src/speechsynthesis.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,578 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Speech synthesis server, client side code
+*
+*/
+
+
+// @todo Add better file write support to Klatt and HQ plugins
+// @todo Add support for lipsync information
+
+#include <e32svr.h>
+#include <f32file.h> 
+#include <s32mem.h>
+#include <speechsynthesis.h>
+
+#include "speechsynthesisclientserver.h"
+
+// CONSTANTS
+
+const TInt KMajorVersion = 1;
+const TInt KMinorVersion = 0;
+const TInt KBuildNumber  = 1;
+
+// ----------------------------------------------------------------------------
+// StartServer
+// Server startup code
+// ----------------------------------------------------------------------------
+// 
+static TInt StartServer()
+    {
+    RProcess server;
+
+    TInt error = server.Create( KSpeechSynthesisServerImg, KNullDesC );
+
+    if ( !error )
+        {
+        // Server started
+        TRequestStatus status;
+        server.Rendezvous( status );
+        
+        if ( status != KRequestPending )
+            {
+            server.Kill( KErrGeneral ); // Abort startup
+            }
+        else
+            {
+            server.Resume();            // Logon OK - start the server
+            }
+            
+        User::WaitForRequest( status ); // Wait for start or death
+        
+        error = ( server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int();
+        
+        // Close handle
+        server.Close();
+        }
+        
+    return error;
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::RSpeechSynthesis
+// Constructor
+// ----------------------------------------------------------------------------
+//
+EXPORT_C RSpeechSynthesis::RSpeechSynthesis()
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::Open
+// Creates a session to server
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSpeechSynthesis::Open()
+    {
+    const TInt KMessageSlots( 4 );  // 1 async, 1 sync, 1 cancel, 1 kernel
+    
+    const TVersion requiredServerVersion( KMajorVersion, 
+                                          KMinorVersion, 
+                                          KBuildNumber );
+
+    // Try to create session with following parameters:
+    // 1) Name of the server
+    // 2) The lowest version of the server with which this client is compatible
+    // 3) The number of message slots 
+    TInt error = CreateSession( KSpeechSynthesisServerName, 
+                                requiredServerVersion, KMessageSlots );
+    
+    if ( error == KErrNotFound || error == KErrServerTerminated )
+        {
+        // Server not running -> try to start it
+        error = StartServer();
+        
+        if ( error == KErrNone || error == KErrAlreadyExists )
+            {
+            // Server startup succeeded -> try to create session to it
+            error = CreateSession( KSpeechSynthesisServerName, 
+                                   requiredServerVersion, KMessageSlots );
+
+            }
+        }
+
+    return error;
+    }
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::Close
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::Close()
+    {
+    RSessionBase::Close();  
+    }
+   
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::InitialiseSynthesis
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::InitialiseSynthesis( const TDesC& aText, 
+                                                     TRequestStatus& aStatus )
+    {
+    if ( Handle() )
+        {
+        SendReceive( EPrime, TIpcArgs( &aText ), aStatus ); 
+        }
+    else
+        {
+        TRequestStatus *statusPointer = &aStatus;
+        User::RequestComplete( statusPointer, KErrBadHandle );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::InitialiseSynthesis
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::InitialiseSynthesis( const TDesC& aText, 
+                                                     const TFileName& aFileName,
+                                                     TRequestStatus& aStatus )
+    {
+    TRAPD( error, DoInitialiseSynthesisL( aText, aFileName, aStatus ) );
+    if ( error )
+        {
+        TRequestStatus *statusPointer = &aStatus;
+        User::RequestComplete( statusPointer, error );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::InitialiseSynthesis
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::InitialiseSynthesis( const TDesC& aText,
+                                                     TDes8& aDataBuffer, 
+                                                     TRequestStatus& aStatus )
+    {
+    if ( Handle() )
+        {
+        SendReceive( EPrimeStreamOutput, TIpcArgs( &aText, &aDataBuffer ), aStatus ); 
+        }
+    else
+        {
+        TRequestStatus *statusPointer = &aStatus;
+        User::RequestComplete( statusPointer, KErrBadHandle );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::Synthesise
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::Synthesise( TRequestStatus& aStatus )
+    {
+    if ( Handle() )
+        {
+        SendReceive( ESynthesise, aStatus );
+        }
+    else
+        {
+        TRequestStatus *statusPointer = &aStatus;
+        User::RequestComplete( statusPointer, KErrBadHandle );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::StopL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::StopL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( EStopSynthesis ) ); 
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::PauseL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::PauseL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( EPauseSynthesis ) );
+    }     
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::DurationL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TTimeIntervalMicroSeconds RSpeechSynthesis::DurationL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TTimeIntervalMicroSeconds> pckg;
+    
+    User::LeaveIfError( SendReceive( EGetDuration, TIpcArgs( &pckg ) ) ); 
+    
+    return pckg();
+    }
+    
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::GetLanguagesL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::GetLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+	CleanupClosePushL( aLanguages ); 
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TInt> pckg;
+    
+    User::LeaveIfError( SendReceive( EGetLanguageCount, TIpcArgs( &pckg ) ) );
+    
+    const TInt languageCount( pckg() );
+
+    if ( languageCount > 0 )    
+        {
+        const TInt tlanguageSize( sizeof(TLanguage) );
+    
+        HBufC8* data = HBufC8::NewLC( languageCount * tlanguageSize );
+        TPtr8 data_ptr( data->Des() );
+    
+        User::LeaveIfError( SendReceive( EGetLanguages, TIpcArgs( &data_ptr ) ) );
+        
+        for ( TInt i( 0 ); i < languageCount; i++ )
+            {
+            TPtr8 tmp = data_ptr.MidTPtr( i * tlanguageSize, tlanguageSize );
+            
+            const TLanguage* lang = (TLanguage*)tmp.Ptr();
+            
+            aLanguages.AppendL( *lang );
+            }
+
+        CleanupStack::PopAndDestroy( data );
+        }
+    CleanupStack::Pop(); 
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::GetVoicesL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::GetVoicesL( RArray<TVoice>& aVoices,
+                                            TLanguage aLanguage )
+    {
+	CleanupClosePushL( aVoices ); 
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TInt> pckg;
+    
+    User::LeaveIfError( SendReceive( EGetVoiceCount, 
+                                     TIpcArgs( &pckg, aLanguage ) ) );
+    
+    const TInt voiceCount( pckg() );
+    
+    if ( voiceCount > 0 ) 
+        {
+        const TInt tvoiceSize( sizeof(TVoice) );
+        
+        HBufC8* data = HBufC8::NewLC( voiceCount * tvoiceSize );
+        TPtr8 data_ptr( data->Des() );
+    
+        User::LeaveIfError( SendReceive( EGetVoices, TIpcArgs( &data_ptr ) ) );
+        
+        for ( TInt i( 0 ); i < voiceCount; i++ )
+            {
+            TPtr8 tmp = data_ptr.MidTPtr( i * tvoiceSize, tvoiceSize );
+            
+            const TVoice* voice = (TVoice*)tmp.Ptr();
+            
+            aVoices.AppendL( *voice );
+            }
+        
+        CleanupStack::PopAndDestroy( data );   
+        }
+    CleanupStack::Pop(); 
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::VoiceL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TVoice RSpeechSynthesis::VoiceL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TVoice> pckg;
+    
+    User::LeaveIfError( SendReceive( EVoice, TIpcArgs( &pckg ) ) );
+    
+    return pckg();
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::SetVoiceL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::SetVoiceL( const TVoice& aVoice )
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TVoice> pckg = aVoice;
+    
+    User::LeaveIfError( SendReceive( ESetVoice, TIpcArgs( &pckg ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::MaxSpeakingRateL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSpeechSynthesis::MaxSpeakingRateL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TInt> pckg;
+    
+    User::LeaveIfError( SendReceive( EMaxSpeakingRate, TIpcArgs( &pckg ) ) );
+    
+    return pckg();
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::SpeakingRateL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSpeechSynthesis::SpeakingRateL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TInt> pckg;
+    
+    User::LeaveIfError( SendReceive( ESpeakingRate, TIpcArgs( &pckg ) ) );
+    
+    return pckg();
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::SetSpeakingRateL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::SetSpeakingRateL( TInt aSpeakingRate )
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( ESetSpeakingRate, 
+                                     TIpcArgs( aSpeakingRate ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::MaxVolumeL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSpeechSynthesis::MaxVolumeL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TInt> pckg;
+    
+    User::LeaveIfError( SendReceive( EMaxVolume, TIpcArgs( &pckg ) ) );
+    
+    return pckg();
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::VolumeL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt RSpeechSynthesis::VolumeL()
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    TPckgBuf<TInt> pckg;
+    
+    User::LeaveIfError( SendReceive( EVolume, TIpcArgs( &pckg ) ) );
+    
+    return pckg();
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::SetVolumeL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::SetVolumeL( TInt aVolume )
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( ESetVolume, TIpcArgs( aVolume ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::SetAudioPriorityL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::SetAudioPriorityL( TInt aPriority, 
+                                                   TInt aPreference )
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( ESetAudioPriority, 
+                                     TIpcArgs( aPriority, aPreference ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::SetAudioOutputL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::SetAudioOutputL( TTtsAudioOutput aAudioOutput )
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( ESetAudioOutput, TIpcArgs( aAudioOutput ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::CustomCommandL
+// 
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void RSpeechSynthesis::CustomCommandL( TInt aCommand, TInt aValue )
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    
+    User::LeaveIfError( SendReceive( ECustomCommand, 
+                                     TIpcArgs( aCommand, aValue ) ) );
+    }
+
+// ----------------------------------------------------------------------------
+// RSpeechSynthesis::DoInitialiseSynthesisL
+// 
+// ----------------------------------------------------------------------------
+//
+void RSpeechSynthesis::DoInitialiseSynthesisL( const TDesC& aText, 
+                                               const TFileName& aFileName, 
+                                               TRequestStatus& aStatus ) 
+    {
+    if ( Handle() == 0 )
+        {
+        User::Leave( KErrBadHandle );
+        }
+        
+    // @todo Add support for all supported audio formats 
+    TFileName tmpName( aFileName );
+    tmpName.LowerCase();
+            
+    TParse parser;
+    User::LeaveIfError( parser.Set( tmpName, NULL, NULL ) );
+    
+    TPtrC extension = parser.Ext(); 
+    
+    if ( extension != _L(".raw") ) 
+        {
+        User::Leave( KErrArgument );
+        }
+
+    RFs fs;
+    RFile file;
+
+    User::LeaveIfError( fs.Connect() ); 
+    CleanupClosePushL( fs );    
+    User::LeaveIfError( fs.ShareProtected() ); 
+    
+    User::LeaveIfError( file.Replace( fs, aFileName, EFileWrite ) ); 
+    CleanupClosePushL( file );
+    
+    TIpcArgs ipcArgs;
+    User::LeaveIfError( file.TransferToServer( ipcArgs, KFsHandleIndex, KFileHandleIndex ) ); 
+    User::LeaveIfError( SendReceive( ETransferFileHandle, ipcArgs ) );
+    
+    CleanupStack::PopAndDestroy( &file ); 
+    CleanupStack::PopAndDestroy( &fs ); 
+    
+    SendReceive( EPrimeFileOutput, TIpcArgs( &aText ), aStatus ); 
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for Speech synthesis server
+*
+*/
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+
+PRJ_MMPFILES
+
+speechsynthesisserver.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/group/speechsynthesisserver.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for Speech synthesis server executable
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          speechsynthesisserver.exe
+TARGETTYPE      exe
+UID             0x100039CE 0x10281A71
+VENDORID        VID_DEFAULT
+
+// MultiMediaDD needed for changing audio priority and preference
+// ReadDeviceData needed for reading central repository settings in plugins
+// WriteDeviceData needed for prioprefs and setting audio output to All.
+// ProtServ needed for '!' prefix in server name
+CAPABILITY      MultiMediaDD ReadDeviceData WriteDeviceData ProtServ  
+
+SOURCEPATH      ../src
+SOURCE          speechsynthesisserver.cpp
+SOURCE          speechsynthesisserverutilities.cpp
+SOURCE          speechsynthesissession.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../rubydebug
+
+APP_LAYER_SYSTEMINCLUDE 
+//SYSTEMINCLUDE   /epoc32/include/swi
+
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib 
+LIBRARY         euser.lib 
+LIBRARY         mmfcontrollerframework.lib
+LIBRARY         nssttscommon.lib
+LIBRARY         nssttsutility.lib 
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/inc/speechsynthesisclientserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Commom definitions for client and server side
+*
+*/
+
+
+#ifndef SPEECHSYNTHESISCLIENTSERVER_H
+#define SPEECHSYNTHESISCLIENTSERVER_H
+
+#include <e32std.h>
+
+
+_LIT( KSpeechSynthesisServerName, "!speechsynthesisserver" );
+_LIT( KSpeechSynthesisServerImg, "speechsynthesisserver" );  // DLL/EXE name
+
+
+// Definition of messages send from client to server via session
+// Do NOT change order, add new messagwe ids to the end!
+enum TSynthesisMessages
+    {
+    EPrime = 0,
+    EPrimeFileOutput,
+    EPrimeStreamOutput,
+    ETransferFileHandle,
+    ESynthesise,
+    EStopSynthesis,     // 5
+    EPauseSynthesis,
+    EGetDuration, 
+    EGetLanguages,
+    EGetLanguageCount,
+    EGetVoices,         // 10
+    EGetVoiceCount,
+    EVoice,
+    ESetVoice,
+    EMaxSpeakingRate,
+    ESpeakingRate,      // 15
+    ESetSpeakingRate,
+    EMaxVolume,
+    EVolume,
+    ESetVolume,
+    ESetAudioPriority,  // 20
+    ESetAudioOutput,
+    ECustomCommand
+    };
+    
+const TInt KFsHandleIndex = 0;
+const TInt KFileHandleIndex = 1;
+
+#endif // SPEECHSYNTHESISCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/inc/speechsynthesisserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,336 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Speech synthesis server
+*
+*/
+
+
+#ifndef SPEECHSYNTHESISSERVER_H
+#define SPEECHSYNTHESISSERVER_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <nssttsutility.h>
+#include <speechsynthesis.h>
+
+#include "speechsynthesisclientserver.h"
+#include "speechsynthesisserverutilities.h"
+
+
+// DEFINITION OF SERVER POLICY 
+
+// Total number of ranges
+const TUint KSpeechSynthesisRangeCount = 4;
+
+// Definition of the ranges of IPC numbers
+const TInt KSpeechSynthesisRanges[KSpeechSynthesisRangeCount] = 
+        {
+        0,                  // Messages 0..19
+        ESetAudioPriority,  // Message 20
+        ESetAudioOutput,    // Message 21
+        ESetAudioOutput+1   // Messages 22..
+        }; 
+
+// Policy to implement for the above range        
+const TUint8 KSpeechSynthesisElementsIndex[KSpeechSynthesisRangeCount] = 
+        {
+        CPolicyServer::EAlwaysPass,     // Applies to 0th range
+        0,                              // Applies to 1st range 
+        CPolicyServer::ECustomCheck,    // Applies to 2nd range
+        CPolicyServer::EAlwaysPass,     // Applies to 3rd range
+        };
+
+// Specific capability checks
+const CPolicyServer::TPolicyElement KSpeechSynthesisElements[] = 
+        {
+        // Only clients having Nokia VID capability passes this policy element. 
+        { _INIT_SECURITY_POLICY_V0( VID_DEFAULT ), CPolicyServer::EFailClient },
+        };
+
+// Package all the above together into a policy
+const CPolicyServer::TPolicy KSpeechSynthesisPolicy =
+        {
+        CPolicyServer::EAlwaysPass,     // Specifies all connect attempts should pass
+        KSpeechSynthesisRangeCount,     // Number of ranges                                   
+        KSpeechSynthesisRanges,         // Ranges array
+        KSpeechSynthesisElementsIndex,  // Elements<->ranges index
+        KSpeechSynthesisElements,       // Array of elements
+        };
+    
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer
+// Server implementation
+// ----------------------------------------------------------------------------
+class CSpeechSynthesisServer : public CPolicyServer, 
+                               public MConfigurationObserver,
+                               public MTtsClientUtilityObserver
+    {
+    
+    public: // New functions
+    
+        /**
+        * 2nd phase constructor
+        */
+        static CServer2* NewLC();
+        
+        /**
+        * Destructor
+        */        
+        virtual ~CSpeechSynthesisServer();
+                
+        /**
+        * Add new sessios
+        */
+        void AddSession();
+        
+        /**
+        * Remove session
+        */
+        void DropSession();
+
+        /**
+        * Reserve server for aSession
+        */
+        void ReserveL( MSpeechSynthesisServerObserver* aSession );
+        void ReserveL( MSpeechSynthesisServerObserver* aSession, TInt aPriority );
+        
+        /**
+        * Release server to be used by other sessions
+        */
+        void Release( const MSpeechSynthesisServerObserver* aSession );
+        
+        /**
+        * Used to ask server's default settings
+        */
+        void GetDefaultSettingsL( TVoice& aVoice, 
+                                  TInt& aSpeakingRate, TInt& aMaxSpeakingRate,
+                                  TInt& aVolume, TInt& aMaxVolume, 
+                                  TInt& aAudioPriority, TInt& aAudioPreference,
+                                  TInt& aAudioOutput );
+        
+        /**
+        * Used to ask server's default voice
+        */
+        void GetDefaultVoiceL( TVoice& aVoice );
+
+        /**
+        * Prime the synthesizer
+        *
+        * @param aText Text to be synthesized
+        *
+        */
+        void PrimeL( const TDesC& aText );
+    
+        /**
+        * Prime the synthesizer
+        *
+        * @param aText Text to be synthesized
+        * @param aFile Open handle to file
+        *
+        */     
+        void PrimeL( const TDesC& aText, const RFile& aFile );
+         
+        /**
+        * Synthesize text
+        */     
+        void Synthesize();
+         
+        /**
+        * Stop synthesis
+        */
+        void Stop();
+         
+        /**
+        * Pause synthesis
+        */
+        void Pause();
+              
+        /**
+        * Get available languages
+        *
+        * @param aLanguages Contains supported languages after function call
+        */
+        void GetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+
+        /**
+        * Get available voices
+        *
+        * @param aLanguage Language
+        * @param aVoices Contains voices after the function call
+        */
+        void GetSupportedVoicesL( TLanguage aLanguage, RArray<TVoice>& aVoices );
+        
+        /**
+        * Change voice. 
+        *
+        * @param aVoice New voice
+        * @param aSpeakingRate Speaking rate to be used
+        */
+        void SetVoiceL( const TVoice aVoice, TInt aSpeakingRate );
+
+        /**
+        * Change volume. 
+        *
+        * @param aVolume New volume
+        */
+        void SetVolume( TInt aVolume );
+
+        /**
+        * Set audio priority
+        * 
+        * @param aPriority New priority
+        * @param aPreference New preference
+        */ 
+        void SetAudioPriorityL( TInt aPriority, TInt aPreference );
+        
+        /**
+        * Set audio output
+        */        
+        void SetAudioOutputL( TInt aAudioOutput );
+        
+        /**
+        * Custom command
+        *
+        * @param aCommand A custom command
+        * @param aValue Value
+        * @return Error code
+        */
+        TInt CustomCommand( TInt aCommand, TInt aValue );
+        
+        /**
+        * Checks if given voice exists
+        * 
+        * @param aVoice Voice to be checked
+        * @return ETrue if voice exists, EFalse otherwise
+        */
+        TBool IsVoiceValidL( const TVoice& aVoice );
+        
+        /*
+         * Returns pointer to the previous session. Plugin is closed if it doesn't 
+         * match new session in order to avoid using settings from other session. 
+         */
+        const MSpeechSynthesisServerObserver* PreviousSession(); 
+        
+        /*
+         * Closes open plugin 
+         */
+        void ClosePlugin();
+
+    public: // From base class MConfigurationObserver
+         
+        /**
+        * This is called when installation or removal of SIS package is detected 
+        */
+        void McoConfigurationChanged();
+         
+    public: // From base class MTtsClientUtilityObserver
+
+        /**
+        * Called when asynchronous custom command finishes.
+        */
+        void MapcCustomCommandEvent( TInt aEvent, TInt aError );
+        
+        /**
+        * Callback when initialized
+        */
+        void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration );
+
+        /**
+        * Callback when playback finished
+        */
+        void MapcPlayComplete( TInt aError );
+        
+    public:
+    
+        /**
+        * Callback function called when server has been idle certain time. 
+        */
+        static TInt ClosePlugin( TAny* aAny );
+        
+    private:
+
+        // Constructor
+        CSpeechSynthesisServer();
+        
+        // 2nd phase constructor
+        void ConstructL();
+        
+        // Create new session
+        CSession2* NewSessionL( const TVersion& aVersion, 
+                                const RMessage2& aMessage ) const;
+        
+        // Custom access policy check
+        TCustomResult CustomSecurityCheckL( const RMessage2& aMsg, 
+                                            TInt& aAction, 
+                                            TSecurityInfo& aMissing );
+        
+        // Updates configuration if needed
+        void UpdateSynthesisConfigurationIfNeededL();
+
+        // Updates configuration 
+        void UpdateSynthesisConfigurationL();
+        
+    private:
+
+        // Pointer to active session observer, not owned. 
+        MSpeechSynthesisServerObserver* iSession;
+        
+        // Pointer to previous session observer, not owned. 
+        MSpeechSynthesisServerObserver* iPreviousSession;
+        
+        // Pointer to tts, owned. 
+        CTtsUtility*                    iTtsUtility; 
+        
+        // Object used to stop the server when it has been idle for a while. 
+        // Owned
+        CShutdown*                      iShutdown; 
+        
+        // Object for closing tts plugin when server has been idle some time.
+        // Frees memory and lets tts components to be removed. 
+        CPeriodic*                      iPluginCloser;
+        
+        // SIS package installer listener, owned. 
+        CConfigurationListener*         iConfigurationListener;
+        
+        // MMC status listener, owned. 
+        CMMCListener*                   iMMCListener;
+        
+        // Supported voice configurations
+        RArray<TVoiceConfiguration>     iTtsVoiceConfigs;
+
+        // Uid of open tts plugin
+        TUid                            iOpenTtsPlugin;
+                
+        // Number of sessions using this server
+        TInt                            iSessionCount;
+        
+        // 
+        TInt                            iSessionPriority;
+        
+        // Default settings
+        TVoice                          iDefaultVoice;
+        TInt                            iDefaultSpeakingRate;
+        TInt                            iDefaultVolume;
+        TInt                            iDefaultMaxVolume;
+        TInt                            iDefaultAudioPriority;
+        TInt                            iDefaultAudioPreference;
+        
+        // If ETrue updates to voice configuration and 
+        // default settings are needed. 
+        TBool                           iUpdateNeeded;
+    };
+
+#endif // SPEECHSYNTHESISSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/inc/speechsynthesisserverutilities.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,213 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility classes for speech synthesis server
+*
+*/
+
+
+#ifndef SPEECHSYNTHESISSERVERUTILITIES_H
+#define SPEECHSYNTHESISSERVERUTILITIES_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <e32property.h>
+#include <speechsynthesis.h>
+
+
+// CONSTANTS
+
+_LIT( KPanic, "SpeechSynthesisServer" );
+
+// Time after server is closed if nobody is connected to it
+const TTimeIntervalMicroSeconds32 KSpeechSynthesisShutdownDelay = 0x200000; // 2 seconds
+
+
+// ----------------------------------------------------------------------------
+// TSpeechSynthesisPanic
+// Server's panic codes 
+// ----------------------------------------------------------------------------
+//
+enum TSpeechSynthesisPanic
+    {
+    EPanicGeneral,
+    EPanicIllegalFunction
+    };
+
+// ----------------------------------------------------------------------------
+// PanicClient
+//
+// ----------------------------------------------------------------------------
+//
+void PanicClient( const RMessagePtr2& aMessage, TSpeechSynthesisPanic aPanic );
+
+
+// ----------------------------------------------------------------------------
+// MSpeechSynthesisServerObserver
+// Observer to receive callbacks from server
+// ----------------------------------------------------------------------------
+//
+class MSpeechSynthesisServerObserver
+	{
+    
+    public:
+
+        /**
+        * Initialisation has finished
+        * @param aError KErrNone if initialisation succeeded
+        * @param aDuration Estimated duration of synthesis
+        */
+    	virtual void MsssInitComplete( TInt aError, 
+	                                   const TTimeIntervalMicroSeconds& aDuration ) = 0;
+
+        /**
+        * Synthesis complete
+        * @param aError KErrNone synthesis has finalised without errors
+        */
+	    virtual void MsssPlayComplete( TInt aError ) = 0;
+	    
+	    /**
+	    * Initialisation or synthesis has been aborted. 
+	    */
+	    virtual void MsssOperationAborted() = 0; 
+	
+	};
+
+
+// ----------------------------------------------------------------------------
+// MConfigurationObserver
+// Observer to receive callbacks from CConfigurationListener
+// ----------------------------------------------------------------------------
+//
+class MConfigurationObserver
+    {
+        
+    public:
+    
+        /**
+        * Change in configuration detected
+        */ 
+        virtual void McoConfigurationChanged() = 0;
+        
+    };
+    
+
+// ----------------------------------------------------------------------------
+// TVoiceConfiguration 
+// 
+// ----------------------------------------------------------------------------
+//
+class TVoiceConfiguration : public TVoice
+    {
+    public:
+    
+        TUid        iPluginUid; 
+        
+        TVoiceConfiguration():
+            TVoice(),
+            iPluginUid( KNullUid ) {};
+    };
+    
+
+
+// ----------------------------------------------------------------------------
+// Auto shutdown class 
+//
+// ----------------------------------------------------------------------------
+//
+class CShutdown : public CTimer
+    {
+    
+    public:
+        
+        static CShutdown* NewL(); 
+        
+        void Start();
+    
+    private:
+    
+        inline CShutdown();
+        
+        inline void ConstructL();
+        
+        void RunL();
+        
+    };
+
+
+// ----------------------------------------------------------------------------
+// Class used to detect installation and removal of SIS package
+//
+// ----------------------------------------------------------------------------
+// 
+class CConfigurationListener : public CActive
+    {
+    
+    public:
+        
+        static CConfigurationListener* NewL( MConfigurationObserver& aHost );
+        
+        virtual ~CConfigurationListener();
+        
+    private:
+        
+        CConfigurationListener( MConfigurationObserver& aHost );
+        
+        void ConstructL();
+        
+        void RunL();
+        
+        void DoCancel();
+        
+    private:
+        
+        RProperty               iProperty;
+        
+        MConfigurationObserver& iHost; 
+    };
+
+// ----------------------------------------------------------------------------
+// Class used to detect insertion and removal of MMC card
+// @todo Changes needed due to multiple drive support? 
+// ----------------------------------------------------------------------------
+// 
+class CMMCListener : public CActive
+    {
+    
+    public:
+        
+        static CMMCListener* NewL( MConfigurationObserver& aHost );
+        
+        virtual ~CMMCListener();
+        
+    private:
+        
+        CMMCListener( MConfigurationObserver& aHost );
+        
+        void ConstructL();
+        
+        void RunL();
+        
+        void DoCancel();
+        
+    private:
+        
+        RProperty                   iProperty;
+        
+        TInt                        iPrevValue;
+        
+        MConfigurationObserver&     iHost; 
+    };
+
+#endif // SPEECHSYNTHESISSERVERUTILITIES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/inc/speechsynthesissession.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Speech synthesis session
+*
+*/
+
+
+#ifndef SPEECHSYNTHESISSESSION_H
+#define SPEECHSYNTHESISSESSION_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <f32file.h> 
+
+#include "speechsynthesisserverutilities.h"
+
+
+// FORWARD DECLARATIONS
+
+class CSpeechSynthesisServer;
+
+// Structure for saving custom command - value pairs 
+class TCustomCommand
+    {
+    public:
+        TInt iCommand;
+        TInt iValue;
+    };
+
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession
+// Provides synthesis session functionality
+// ----------------------------------------------------------------------------
+class CSpeechSynthesisSession : public CSession2, 
+                                public MSpeechSynthesisServerObserver
+    {
+
+    public:
+        
+        /**
+        * Constructor
+        */
+        CSpeechSynthesisSession();
+
+        /**
+        * Destructor
+        */
+        virtual ~CSpeechSynthesisSession();
+        
+        /**
+        * 2nd phase construct for sessions - called by the CServer framework
+        */    
+        void CreateL();
+    
+    public: // From base class MSpeechSynthesisServerObserver
+
+        /**
+        * Callback when initialized
+        */
+        void MsssInitComplete( TInt aError, 
+                               const TTimeIntervalMicroSeconds& aDuration );
+
+        /**
+        * Callback when playback finished
+        */        
+        void MsssPlayComplete( TInt aError );
+        
+        /**
+        * Callback when operation aborted.
+        */
+        void MsssOperationAborted(); 
+
+    private:
+ 
+        // Leaves if access is denied
+        void CheckAccessL( TInt aMessageType );
+        
+        // Returns reference to the server
+        inline CSpeechSynthesisServer& Server();
+        
+        // Provides services
+        void ServiceL( const RMessage2& aMessage );
+        
+        // Handles asynchronous services
+        void DoAsyncServiceL( const RMessage2& aMessage );
+        
+        // Handles synchronous services
+        void DoSyncServiceL( const RMessage2& aMessage );
+        
+        // Fuctions to provide actual services
+        void DoStopSynthesisL();
+        void DoPauseSynthesisL();
+        void DoGetDurationL(      const RMessage2& aMessage );
+        void DoGetLanguagesL(     const RMessage2& aMessage );
+        void DoGetLanguageCountL( const RMessage2& aMessage );
+        void DoGetVoicesL(        const RMessage2& aMessage );
+        void DoGetVoiceCountL(    const RMessage2& aMessage );
+        void DoVoiceL(            const RMessage2& aMessage );
+        void DoSetVoiceL(         const RMessage2& aMessage );
+        void DoMaxSpeakingRateL(  const RMessage2& aMessage );
+        void DoSpeakingRateL(     const RMessage2& aMessage );
+        void DoSetSpeakingRateL(  const RMessage2& aMessage );
+        void DoMaxVolumeL(        const RMessage2& aMessage );
+        void DoVolumeL(           const RMessage2& aMessage );
+        void DoSetVolumeL(        const RMessage2& aMessage );
+        void DoSetAudioPriority(  const RMessage2& aMessage );
+        void DoSetAudioOutputL(   const RMessage2& aMessage );
+        void DoCustomCommandL(    const RMessage2& aMessage );
+        
+        // Handles leave happened in ServiceL()
+        void ServiceError( const RMessage2& aMessage, TInt aError );
+ 
+    private:
+
+        // Session state information values
+        enum TSessionState
+            {
+            ESessionIdle,
+            ESessionPrimed
+            };
+
+        // Asynchronous messages has to be kept in mind
+        RMessage2                   iStoredMessage;
+        
+        // Duration information filled in MsssInitComplete()
+        TTimeIntervalMicroSeconds   iDuration;
+        
+        // Current voice in use
+        TVoice                      iCurrentVoice;
+
+        // Current speking rate
+        TInt                        iSpeakingRate;
+
+        // Maximum value of speaking rate
+        TInt                        iMaxSpeakingRate;
+        
+        // Current volume
+        TInt                        iVolume;
+        TInt                        iTmpVolume;
+        
+        // Maximum value of volume setting
+        TInt                        iMaxVolume;
+        
+        // Current audio priority
+        TInt                        iAudioPriority;
+        
+        // Current audio preference
+        TInt                        iAudioPreference;
+        
+        // Current audio output
+        TInt                        iAudioOutput;
+        TInt                        iTmpAudioOutput;
+        
+        // Session state information
+        TSessionState               iSessionState;
+        
+        // Used when client is asking supported languages. 
+        RArray<TLanguage>           iLanguages; 
+        
+        // Used when client is asking supported voices. 
+        RArray<TVoice>              iVoices;
+        
+        // Array for custom commands
+        RArray<TCustomCommand>     iCustomCommands;
+        
+        // File handle used for saving output to file. 
+        RFile iFile;
+        
+        // ETrue when file output is activated 
+        TBool                       iFileOutputActivated;
+        
+        // ETrue when closing of a plugin has been requested
+        TBool                       iClosePlugin;
+        
+    };
+
+#endif // SPEECHSYNTHESISSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/src/speechsynthesisserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,979 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Speech synthesis server
+*
+*/
+
+
+// INCLUDES
+
+#include <AudioOutput.h>
+#include <nssttscommon.h>
+
+#include "speechsynthesisserver.h"
+
+#include "speechsynthesisclientserver.h"
+#include "speechsynthesisserverutilities.h"
+#include "speechsynthesissession.h"
+
+#include "rubydebug.h"
+
+
+// CONSTANTS
+
+// Time to wait before tts plugin is closed if no activity detected. 
+const TTimeIntervalMicroSeconds32 KTtsPluginCloseWait = 30000000; // 30 sec.
+
+// ----------------------------------------------------------------------------
+// RunServerL
+// Server startup code
+// Perform all server initialisation, in particular creation of the
+// scheduler and server and then run the scheduler
+// ----------------------------------------------------------------------------
+//  
+static void RunServerL()
+    {
+    RUBY_DEBUG_BLOCK( "SpeechSynthesisServer: RunServerL" );
+    
+    // Naming the server thread after the server helps to debug panics
+    User::LeaveIfError( User::RenameThread( KSpeechSynthesisServerName ) );
+
+    // Create and install the active scheduler we need
+    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+    
+    // Create the server (leave it on the cleanup stack)
+    CServer2* server = CSpeechSynthesisServer::NewLC();
+    
+    // Initialisation complete, now signal the client
+    RProcess::Rendezvous( KErrNone );
+
+    RUBY_DEBUG0( "SpeechSynthesisServer: server fully running." );
+    
+    // Ready to run
+    CActiveScheduler::Start();
+    
+    RUBY_DEBUG0( "SpeechSynthesisServer: server closing." );
+    
+    // Cleanup the server and scheduler
+    CleanupStack::PopAndDestroy( server );
+    CleanupStack::PopAndDestroy( scheduler );
+    }
+
+// ----------------------------------------------------------------------------
+// E32Main
+// Server process entry-point
+// ----------------------------------------------------------------------------
+//
+TInt E32Main()
+    {
+    __UHEAP_MARK;
+    
+    RUBY_DEBUG0( "SpeechSynthesisServer: E32Main" );
+    
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    
+    TInt error( KErrNoMemory );
+    
+    if ( cleanup )
+        {
+        TRAP( error, RunServerL() );
+        delete cleanup;
+        }
+        
+    __UHEAP_MARKEND;
+    
+    return error;
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// LanguageOrder
+// Used in CSpeechSynthesisServer::GetSupportedLanguagesL()
+// ----------------------------------------------------------------------------
+// 
+static TInt LanguageOrder( const TLanguage& a, const TLanguage& b )
+    {
+    TInt result( 0 );
+    
+    if ( a < b )
+        {
+        result = -1;
+        }
+    else if ( a > b )
+        {
+        result = 1;
+        }
+
+    return result;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::CSpeechSynthesisServer
+// Constructor
+// ----------------------------------------------------------------------------
+inline CSpeechSynthesisServer::CSpeechSynthesisServer() :
+    CPolicyServer( CActive::EPriorityStandard, 
+                   KSpeechSynthesisPolicy, 
+                   ESharableSessions ),
+    iOpenTtsPlugin( KNullUid ),
+    iSessionPriority( EMdaPriorityMin ), 
+    iDefaultSpeakingRate( KTtsMaxSpeakingRate / 2 ),
+    iDefaultAudioPriority( EMdaPriorityNormal ),
+    iDefaultAudioPreference( EMdaPriorityPreferenceTimeAndQuality )
+    {
+    // Nothing
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::~CSpeechSynthesisServer
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CSpeechSynthesisServer::~CSpeechSynthesisServer()
+    {    
+    delete iTtsUtility;
+    delete iShutdown;
+    delete iConfigurationListener;
+    delete iMMCListener; 
+    
+    iTtsVoiceConfigs.Close();
+    
+    if ( iPluginCloser )
+        {
+        iPluginCloser->Cancel();
+        delete iPluginCloser;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::NewLC
+// 
+// ----------------------------------------------------------------------------
+//
+CServer2* CSpeechSynthesisServer::NewLC()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::NewLC" );
+    
+    CSpeechSynthesisServer* self = new(ELeave) CSpeechSynthesisServer();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::ConstructL
+// 2nd phase construction - ensure the timer and server objects are running
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::ConstructL" );
+    
+    StartL( KSpeechSynthesisServerName );
+    
+    iTtsUtility = CTtsUtility::NewL( *this );
+    iTtsUtility->SetPriority( iDefaultAudioPriority, 
+                              (TMdaPriorityPreference)iDefaultAudioPreference );
+    
+    // Create object for closing tts plugin when server has been idle for a while. 
+    iPluginCloser = CPeriodic::NewL( CActive::EPriorityIdle );
+     
+    // Listens for changes in SIS installations
+    iConfigurationListener = CConfigurationListener::NewL( *this );
+    
+    // Listens insertions and removals of MMC. 
+    iMMCListener = CMMCListener::NewL( *this );
+    
+    UpdateSynthesisConfigurationL();
+    
+    // Ensure that the server still exits even if the 1st client fails to connect
+    iShutdown = CShutdown::NewL();
+    iShutdown->Cancel();
+    iShutdown->Start();
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::AddSession
+// A new session is being created
+// Cancel the shutdown timer if it was running
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::AddSession()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::AddSession" );
+    
+    iSessionCount++;
+    
+    iShutdown->Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::DropSession
+// A session is being destroyed
+// Start the shutdown timer if it is the last session.
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::DropSession()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::DropSession" );
+    
+    iSessionCount--;
+    
+    if ( iSessionCount == 0 )
+        {
+        iShutdown->Cancel();
+        iShutdown->Start();
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::ReserveL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::ReserveL( MSpeechSynthesisServerObserver* aSession )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::ReserveL" );
+    
+    iPluginCloser->Cancel();
+    
+    if ( !iSession || iSession == aSession )
+        {
+        // Session is not in use or it's reserved already for this session
+        iSession = aSession;
+        }
+    else
+        {
+        User::Leave( KErrInUse );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::ReserveL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::ReserveL( MSpeechSynthesisServerObserver* aSession,
+                                       TInt aPriority )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::ReserveL" );
+    
+    iPluginCloser->Cancel();
+    
+    if ( !iSession || iSession == aSession )
+        {
+        // Session is not in use or it's reserved already for this session
+        iSession = aSession;
+        
+        iSessionPriority = aPriority;
+        }
+    else if ( aPriority > iSessionPriority )
+        {
+        Stop();
+        
+        iSession->MsssOperationAborted();
+        
+        iPreviousSession = iSession;
+        iSession = aSession; 
+        iSessionPriority = aPriority; 
+        }
+    else 
+        {
+        User::Leave( KErrInUse ); 
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::Release
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::Release( const MSpeechSynthesisServerObserver* aSession )
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::Release" );
+    
+    if ( iSession == aSession )
+        {
+        iPreviousSession = iSession;
+        iSession = NULL; 
+        iSessionPriority = EMdaPriorityMin;
+        
+        TRAP_IGNORE( UpdateSynthesisConfigurationIfNeededL() );
+        
+        iPluginCloser->Cancel();
+        iPluginCloser->Start( KTtsPluginCloseWait, KTtsPluginCloseWait,
+                              TCallBack( ClosePlugin, this ) );
+        
+        RUBY_DEBUG0( "iPluginCloser started" );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::GetDefaultSettingsL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::GetDefaultSettingsL( TVoice& aVoice, 
+                                  TInt& aSpeakingRate, TInt& aMaxSpeakingRate,
+                                  TInt& aVolume, TInt& aMaxVolume, 
+                                  TInt& aAudioPriority, TInt& aAudioPreference,
+                                  TInt& aAudioOutput )
+    {
+    UpdateSynthesisConfigurationIfNeededL();
+    
+    aVoice           = iDefaultVoice;
+    aSpeakingRate    = iDefaultSpeakingRate;
+    aMaxSpeakingRate = KTtsMaxSpeakingRate;
+    aVolume          = iDefaultVolume;
+    aMaxVolume       = iDefaultMaxVolume;
+    aAudioPriority   = iDefaultAudioPriority;
+    aAudioPreference = iDefaultAudioPreference;
+    aAudioOutput     = RSpeechSynthesis::ETtsOutputDefault;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::GetDefaultVoiceL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::GetDefaultVoiceL( TVoice& aVoice )
+    {
+    UpdateSynthesisConfigurationIfNeededL();
+    
+    aVoice = iDefaultVoice;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::PrimeL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::PrimeL( const TDesC& aText )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::PrimeL" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+    
+    iTtsUtility->OpenDesL( aText );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::PrimeL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::PrimeL( const TDesC& aText, const RFile& aFile )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::PrimeL" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+
+    iTtsUtility->SetOutputFileL( aFile ); 
+    iTtsUtility->OpenDesL( aText ); 
+    } 
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::Synthesize
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::Synthesize()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::Synthesize" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+    
+    iTtsUtility->Play();
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::Stop
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::Stop()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::Stop" );
+
+    if ( iOpenTtsPlugin != KNullUid )
+        {
+        iTtsUtility->Stop();
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::Pause
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::Pause()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::Pause" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+    
+    iTtsUtility->Pause(); 
+    }  
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::GetSupportedLanguagesL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::GetSupportedLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::GetSupportedLanguagesL" );
+    
+    UpdateSynthesisConfigurationIfNeededL();
+    
+    TInt error( KErrNone );    
+    TLinearOrder<TLanguage> order( LanguageOrder );
+    
+    for( TInt i( 0 ); i < iTtsVoiceConfigs.Count(); i++ )
+        {
+        // Add every language only once 
+        error = aLanguages.InsertInOrder( iTtsVoiceConfigs[i].iLanguage, order );
+        if ( error && error != KErrAlreadyExists )
+            {
+            User::Leave( error );
+            }
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::GetSupportedVoicesL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::GetSupportedVoicesL( TLanguage aLanguage, 
+                                                  RArray<TVoice>& aVoices )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::GetSupportedVoicesL" );
+    CleanupClosePushL( aVoices );
+    
+    UpdateSynthesisConfigurationIfNeededL();
+    
+    TVoice voice;
+    
+    for( TInt i( 0 ); i < iTtsVoiceConfigs.Count(); i++ )
+        {
+        if ( iTtsVoiceConfigs[i].iLanguage == aLanguage )
+            {
+            voice.iLanguage     = iTtsVoiceConfigs[i].iLanguage;
+            voice.iVoiceName    = iTtsVoiceConfigs[i].iVoiceName;
+            voice.iSamplingRate = iTtsVoiceConfigs[i].iSamplingRate;
+            
+            aVoices.AppendL( voice );
+            }
+        }
+    CleanupStack::Pop(); 
+    }
+ 
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::SetVoiceL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::SetVoiceL( TVoice aVoice, TInt aSpeakingRate )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::SetVoiceL" );
+    
+    UpdateSynthesisConfigurationIfNeededL();
+    
+    TTtsStyle newStyle;
+    newStyle.iLanguage = aVoice.iLanguage;
+    newStyle.iVoice    = aVoice.iVoiceName;
+    newStyle.iRate     = aSpeakingRate;
+    newStyle.iNlp      = ETrue;  // Turn NLP flag on, only Klatt will use it. 
+            
+    TInt voiceIndex( KErrNotFound );
+    const TInt count ( 
+    iTtsVoiceConfigs.Count() );
+    TInt i( 0 );
+    
+    while ( i < count && voiceIndex < 0 )
+        {        
+        if ( iTtsVoiceConfigs[i].iLanguage == aVoice.iLanguage )
+            {
+            if ( aVoice.iVoiceName.Length() > 0 )
+                {
+                if ( iTtsVoiceConfigs[i].iVoiceName == aVoice.iVoiceName )
+                    {
+                    voiceIndex = i;
+                    }
+                }
+            else
+                {
+                voiceIndex = i;
+                }
+            }
+        
+        i++;
+        }
+
+    if ( voiceIndex >= 0 )
+        {
+        if ( iOpenTtsPlugin != iTtsVoiceConfigs[voiceIndex].iPluginUid )
+            {
+            iTtsUtility->Close();
+            iOpenTtsPlugin = KNullUid;
+        
+            iTtsUtility->OpenPluginL( iTtsVoiceConfigs[voiceIndex].iPluginUid );
+            iOpenTtsPlugin = iTtsVoiceConfigs[voiceIndex].iPluginUid;
+            }
+        
+        iTtsUtility->SetDefaultStyleL( newStyle );
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::SetVolume
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::SetVolume( TInt aVolume )
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::SetVolumeL" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+    
+    iTtsUtility->SetVolume( aVolume );
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::SetAudioPriorityL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::SetAudioPriorityL( TInt aPriority, 
+                                                TInt aPreference )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::SetAudioPriorityL" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+    
+    iTtsUtility->SetPriority( aPriority, (TMdaPriorityPreference)aPreference );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::SetAudioOutputL
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::SetAudioOutputL( TInt aAudioOutput )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::SetAudioOutput" );
+    RUBY_ASSERT_DEBUG( iOpenTtsPlugin != KNullUid, User::Panic( KPanic, __LINE__ ) );
+    
+    TMMFMessageDestinationPckg destination( iOpenTtsPlugin );
+    CAudioOutput::TAudioOutputPreference output;
+    
+    switch ( aAudioOutput )
+        {        
+        case RSpeechSynthesis::ETtsOutputAll: 
+            
+            output = CAudioOutput::EAll;
+            
+            break;
+
+        case RSpeechSynthesis::ETtsOutputNoOutput: 
+            
+            output = CAudioOutput::ENoOutput;
+            
+            break;
+
+        case RSpeechSynthesis::ETtsOutputPrivate: 
+            
+            output = CAudioOutput::EPrivate;
+            
+            break;
+
+        case RSpeechSynthesis::ETtsOutputPublic: 
+            
+            output = CAudioOutput::EPublic;
+            
+            break;
+            
+        default:
+            
+            output = CAudioOutput::ENoPreference;
+        }
+            
+    TBuf8<2> data;
+    data.AppendNum( output );    
+
+    User::LeaveIfError( iTtsUtility->CustomCommandSync( destination, 
+                                                        ETtsCustomCommandSetAudioOutput, 
+                                                        data, KNullDesC8 ) );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::CustomCommand
+//
+// ----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisServer::CustomCommand( TInt aCommand, TInt aValue )
+    {
+    RUBY_DEBUG0( "" );
+    
+    TInt result( KErrNotReady );
+    
+    if ( iOpenTtsPlugin != KNullUid )
+        {
+        TMMFMessageDestinationPckg destination( iOpenTtsPlugin );
+        
+        TBuf8<16> command;
+        command.AppendNum( aCommand );
+        
+        TBuf8<16> value;
+        value.AppendNum( aValue );
+    
+        result = iTtsUtility->CustomCommandSync( destination, ETtsCustomCommandSetPluginParameter, 
+                                                 command, value );
+        }
+    
+    return result;
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::IsVoiceValidL
+//
+// ----------------------------------------------------------------------------
+//
+TBool CSpeechSynthesisServer::IsVoiceValidL( const TVoice& aVoice )
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::IsVoiceValid" );
+    
+    UpdateSynthesisConfigurationIfNeededL();
+    
+    TBool found( EFalse );
+    TInt index( 0 );
+    TInt count( iTtsVoiceConfigs.Count() );
+    
+    while ( !found  && index < count )
+        {        
+        if ( iTtsVoiceConfigs[index].iLanguage == aVoice.iLanguage )
+            {
+            found = ETrue;
+            
+            if ( aVoice.iVoiceName.Length() > 0 &&
+                 aVoice.iVoiceName != iTtsVoiceConfigs[index].iVoiceName )
+                {
+                // Voice name does not match
+                found = EFalse;
+                }
+                
+            if ( aVoice.iSamplingRate != KErrNotFound && 
+                 aVoice.iSamplingRate != iTtsVoiceConfigs[index].iSamplingRate )
+                {
+                // Sampling rate does not match
+                found = EFalse;
+                }
+            }
+        
+        index++;
+        }
+
+    return found;
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::McoConfigurationChanged
+// Some SIS package has been installed or removed
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::McoConfigurationChanged()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisServer::McoConfigurationChanged" );
+    
+    iUpdateNeeded = ETrue;
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::MapcCustomCommandEvent
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::MapcCustomCommandEvent( TInt /*aEvent*/, 
+                                                     TInt /*aError*/ )
+    {
+    RUBY_ERROR0( "CSpeechSynthesisServer::MapcCustomCommandEvent" );
+    
+    // Not used
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::MapcInitComplete
+//
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::MapcInitComplete( TInt aError, 
+        const TTimeIntervalMicroSeconds& aDuration )
+    {
+    RUBY_DEBUG1( "CSpeechSynthesisServer::MapcInitComplete [%x]", iSession );
+    
+    if ( iSession )
+        {
+        iSession->MsssInitComplete( aError, aDuration );
+        }
+    else
+        {
+        RUBY_ERROR1( "CSpeechSynthesisServer::MapcInitComplete - No session [%d]",
+                     aError );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::MapcPlayComplete
+//
+// ----------------------------------------------------------------------------
+//      
+void CSpeechSynthesisServer::MapcPlayComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "CSpeechSynthesisServer::MapcPlayComplete [%x]", iSession );
+    
+    if ( iSession )
+        {
+        iSession->MsssPlayComplete( aError );
+        }
+    else
+        {
+        RUBY_ERROR1( "CSpeechSynthesisServer::MapcPlayComplete - No session [%d]",
+                     aError );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::ClosePlugin
+// 
+// ----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisServer::ClosePlugin( TAny* aAny )
+    {
+    CSpeechSynthesisServer* self = reinterpret_cast<CSpeechSynthesisServer*>( aAny );
+
+    RUBY_DEBUG1( "Closing plugin %x", self->iOpenTtsPlugin );
+    
+    self->iPluginCloser->Cancel();
+    
+    self->iTtsUtility->Close();
+    self->iOpenTtsPlugin = KNullUid;
+    
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::PreviousSession
+// 
+// ----------------------------------------------------------------------------
+//
+const MSpeechSynthesisServerObserver* CSpeechSynthesisServer::PreviousSession()
+    {
+    RUBY_DEBUG1( "iPreviousSession = %x", iPreviousSession );
+    
+    return iPreviousSession;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::ClosePlugin
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::ClosePlugin()
+    {
+    RUBY_DEBUG0( "" );
+    
+    iPluginCloser->Cancel();
+    
+    iTtsUtility->Close();
+    iOpenTtsPlugin = KNullUid;
+    }
+        
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::NewSessionL
+// Create a new client session.
+// ----------------------------------------------------------------------------
+//
+CSession2* CSpeechSynthesisServer::NewSessionL( const TVersion& /*aVersion*/, 
+                                                const RMessage2& /*aMessage*/ ) const
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::NewSessionL" );
+    
+    return new( ELeave ) CSpeechSynthesisSession();
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::CustomSecurityCheckL
+// Custom access policy check
+// ----------------------------------------------------------------------------
+//
+CPolicyServer::TCustomResult CSpeechSynthesisServer::CustomSecurityCheckL( 
+    const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& aMissing )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    CPolicyServer::TCustomResult result( CPolicyServer::EFail ); 
+    
+    if ( aMsg.Function() == ESetAudioOutput )
+        {
+        if ( aMsg.Int0() == RSpeechSynthesis::ETtsOutputAll && 
+             !aMsg.HasCapability( ECapabilityWriteDeviceData, 
+                                  __PLATSEC_DIAGNOSTIC_STRING("Missing WriteDeviceData") ) )
+            {
+            result = CPolicyServer::EFail;
+            
+            aMissing.iCaps = ECapabilityWriteDeviceData;
+            }
+        else
+            {
+            result = CPolicyServer::EPass;
+            }
+        }
+    
+    return result;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::UpdateSynthesisConfigurationIfNeededL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::UpdateSynthesisConfigurationIfNeededL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::UpdateSynthesisConfigurationIfNeededL" );
+    
+    if ( iUpdateNeeded )
+        {
+        RUBY_DEBUG0( "Update needed!" );
+        
+        if ( iSession )
+            {
+            RUBY_DEBUG0( "Cannot update - iSession not NULL" );
+            }
+        else            
+            {
+            UpdateSynthesisConfigurationL();
+            
+            iUpdateNeeded = EFalse;
+            }
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisServer::UpdateSynthesisConfigurationL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisServer::UpdateSynthesisConfigurationL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisServer::UpdateSynthesisConfigurationL" );
+    
+    iPluginCloser->Cancel();
+    
+    RArray<TLanguage> languages;
+    CleanupClosePushL( languages );
+    
+    RArray<TTtsStyle> ttsVoices;
+    CleanupClosePushL( ttsVoices );
+    
+    TVoiceConfiguration cnfg;
+    
+    TBool defaultsVoiceSet( EFalse );
+    
+    // UI language is selected as a default language if it is supported 
+    TLanguage defaultLanguage( User::Language() ); 
+
+    RArray<TUid> ttsPlugins;
+    CleanupClosePushL( ttsPlugins ); 
+    
+    // Plugins are listed in priority order (highest first)
+    iTtsUtility->ListPluginsL( ttsPlugins );    
+    iTtsVoiceConfigs.Reset();
+    
+    // Loop all plugins
+    for ( TInt i( 0 ); i < ttsPlugins.Count(); i++  )
+        {
+        cnfg.iPluginUid = ttsPlugins[i];
+        
+        iTtsUtility->Close();
+        iOpenTtsPlugin = KNullUid;
+        
+        iTtsUtility->OpenPluginL( ttsPlugins[i] );
+        iOpenTtsPlugin = ttsPlugins[i];
+        
+        iTtsUtility->GetSupportedLanguagesL( languages );
+
+        if ( i == 0 )
+            {
+            // Maximum volume is same for all plugins. 
+            iDefaultMaxVolume = iTtsUtility->MaxVolume();
+            iDefaultVolume = iDefaultMaxVolume / 2;
+            }
+
+        // Loop supported languages
+        for ( TInt j( 0 ); j < languages.Count(); j++ )
+            {
+            cnfg.iLanguage = languages[j];
+
+            iTtsUtility->GetSupportedVoicesL( languages[j], ttsVoices ); 
+            
+            // Loop supported voices
+            for ( TInt k( 0 ); k < ttsVoices.Count(); k++ )
+                {
+                cnfg.iVoiceName    = ttsVoices[k].iVoice;
+                cnfg.iSamplingRate = ttsVoices[k].iSamplingRate;
+                
+                iTtsVoiceConfigs.AppendL( cnfg );
+
+                if ( !defaultsVoiceSet && cnfg.iLanguage == defaultLanguage )
+                    {
+                    // Default voice is not set yet -> set it now
+                    defaultsVoiceSet = ETrue;
+                    
+                    iDefaultVoice.iLanguage     = cnfg.iLanguage;
+                    iDefaultVoice.iVoiceName    = cnfg.iVoiceName;
+                    iDefaultVoice.iSamplingRate = cnfg.iSamplingRate;
+                    }
+                }
+            
+            ttsVoices.Reset();
+            }
+        
+        languages.Reset();
+        }
+    
+    CleanupStack::PopAndDestroy( &ttsPlugins );
+    CleanupStack::PopAndDestroy( &ttsVoices );
+    CleanupStack::PopAndDestroy( &languages );
+    
+    if ( !defaultsVoiceSet && iTtsVoiceConfigs.Count() > 0 )
+        {
+        iDefaultVoice.iLanguage     = iTtsVoiceConfigs[0].iLanguage;
+        iDefaultVoice.iVoiceName    = iTtsVoiceConfigs[0].iVoiceName;
+        iDefaultVoice.iSamplingRate = iTtsVoiceConfigs[0].iSamplingRate;
+        } 
+    
+    if ( !iSession )
+        {
+        iPluginCloser->Start( KTtsPluginCloseWait, KTtsPluginCloseWait,
+                              TCallBack( ClosePlugin, this ) );
+        
+        RUBY_DEBUG0( "iPluginCloser started" );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/src/speechsynthesisserverutilities.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,302 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Speech synthesis server utility classes
+*
+*/
+
+
+// INCLUDES
+
+#include <swi/swispubsubdefs.h>         // For listening sw installer's actions
+#include <UikonInternalPSKeys.h>    // For listening memory card insertion/removal
+
+#include "speechsynthesisserverutilities.h"
+#include "rubydebug.h"
+
+
+// ----------------------------------------------------------------------------
+// PanicClient
+//
+// ----------------------------------------------------------------------------
+//
+void PanicClient( const RMessagePtr2& aMessage, TSpeechSynthesisPanic aPanic )
+    {
+    aMessage.Panic( KPanic, aPanic );
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CShutdown::NewL
+// 
+// ----------------------------------------------------------------------------
+CShutdown* CShutdown::NewL()
+    {
+    CShutdown* self = new(ELeave) CShutdown();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CShutdown::CShutdown
+// 
+// ----------------------------------------------------------------------------
+inline CShutdown::CShutdown():
+    CTimer( EPriorityIdle ) 
+    {
+    CActiveScheduler::Add( this );
+    }
+    
+// ----------------------------------------------------------------------------
+// CShutdown::ConstructL
+// 
+// ----------------------------------------------------------------------------
+//
+inline void CShutdown::ConstructL()
+    {
+    CTimer::ConstructL();
+    }
+
+// ----------------------------------------------------------------------------
+// CShutdown::Start
+// 
+// ----------------------------------------------------------------------------
+//
+void CShutdown::Start()
+    {
+    RUBY_DEBUG0( "SpeechSynthesisServer: starting shutdown timeout" );
+    
+    After( KSpeechSynthesisShutdownDelay );
+    }
+
+// ----------------------------------------------------------------------------
+// CShutdown::RunL
+//
+// ----------------------------------------------------------------------------
+//
+void CShutdown::RunL()
+    {
+    RUBY_DEBUG0( "SpeechSynthesisServer: server timeout ... closing" );
+    
+    CActiveScheduler::Stop();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CConfigurationListener::NewL
+//
+// ----------------------------------------------------------------------------
+//
+CConfigurationListener* CConfigurationListener::NewL( MConfigurationObserver& aHost )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    CConfigurationListener* self = new(ELeave) CConfigurationListener( aHost );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self);
+    
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CConfigurationListener::CConfigurationListener
+//
+// ----------------------------------------------------------------------------
+//
+CConfigurationListener::CConfigurationListener(  MConfigurationObserver& aHost ) :
+    CActive( CActive::EPriorityLow ),
+    iHost( aHost )
+    {
+    // Nothing 
+    }
+
+// ----------------------------------------------------------------------------
+// CConfigurationListener::ConstructL
+//
+// ----------------------------------------------------------------------------
+//
+void CConfigurationListener::ConstructL()
+    {
+    User::LeaveIfError( iProperty.Attach( KUidSystemCategory, 
+                                          Swi::KUidSoftwareInstallKey ) );
+    
+    CActiveScheduler::Add( this );
+    
+    // Initial subscription
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// CConfigurationListener::~CConfigurationListener
+//
+// ----------------------------------------------------------------------------
+//
+CConfigurationListener::~CConfigurationListener()
+    {
+    RUBY_DEBUG0( "Destructing.." );
+    Cancel();
+    iProperty.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CConfigurationListener::DoCancel
+//
+// ----------------------------------------------------------------------------
+//
+void CConfigurationListener::DoCancel()
+    {
+    RUBY_DEBUG0( "DoCancel" )
+    iProperty.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// CConfigurationListener::RunL
+//
+// ----------------------------------------------------------------------------
+//
+void CConfigurationListener::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // Resubscribe before processing new value to prevent missing updates
+    iProperty.Subscribe( iStatus );
+    SetActive();
+
+    // Property updated, get new value
+    TInt value( 0 );
+    if ( iProperty.Get( value ) == KErrNone )
+        {
+        TInt operation( value & Swi::KSwisOperationMask );
+        TInt operationStatus( value & Swi::KSwisOperationStatusMask );
+        
+        RUBY_DEBUG1( "value = %d", value );
+        RUBY_DEBUG2( "operation %d, status %d", operation, operationStatus );
+        
+        if ( operationStatus == Swi::ESwisStatusSuccess &&
+                ( operation == Swi::ESwisInstall ||
+                  operation == Swi::ESwisUninstall ||
+                  operation == Swi::ESwisRestore ) )
+            {
+            RUBY_DEBUG0( "Update needed!" );
+            iHost.McoConfigurationChanged();
+            }
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CMMCListener::NewL
+//
+// ----------------------------------------------------------------------------
+//
+CMMCListener* CMMCListener::NewL( MConfigurationObserver& aHost )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    CMMCListener* self = new(ELeave) CMMCListener( aHost );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self);
+    
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CMMCListener::CMMCListener
+//
+// ----------------------------------------------------------------------------
+//
+CMMCListener::CMMCListener(  MConfigurationObserver& aHost ) :
+    CActive( CActive::EPriorityLow ),
+    iPrevValue( -1 ),
+    iHost( aHost )
+    {
+    // Nothing 
+    }
+
+// ----------------------------------------------------------------------------
+// CMMCListener::ConstructL
+//
+// ----------------------------------------------------------------------------
+//
+void CMMCListener::ConstructL()
+    {
+    User::LeaveIfError( iProperty.Attach( KPSUidUikon, KUikMMCInserted ) );
+    
+    CActiveScheduler::Add( this );
+    
+    // Initial subscription
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// CMMCListener::~CMMCListener
+//
+// ----------------------------------------------------------------------------
+//
+CMMCListener::~CMMCListener()
+    {
+    RUBY_DEBUG0( "Destructing.." );
+    Cancel();
+    iProperty.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CMMCListener::DoCancel
+//
+// ----------------------------------------------------------------------------
+//
+void CMMCListener::DoCancel()
+    {
+    RUBY_DEBUG0( "DoCancel" )
+    iProperty.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// CMMCListener::RunL
+//
+// ----------------------------------------------------------------------------
+//
+void CMMCListener::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // Resubscribe before processing new value to prevent missing updates
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    
+    TInt value( 0 );
+    if ( iProperty.Get( value ) == KErrNone )
+        {        
+        RUBY_DEBUG1( "value = %d", value );
+        
+        // Extra calls coming -> check if status is changed
+        if ( iPrevValue != value )
+            {
+            iPrevValue = value; 
+            
+            iHost.McoConfigurationChanged();
+            }
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/server/src/speechsynthesissession.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,859 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Speech synthesis session
+*
+*/
+
+
+// INCLUDES
+
+#include "speechsynthesissession.h"
+#include "speechsynthesisserver.h"
+#include "speechsynthesisclientserver.h"
+#include "rubydebug.h"
+
+
+// CONSTANTS
+
+const TInt KMinVolume = 0;
+const TInt KMinSpeakingRate = 1;
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::CSpeechSynthesisSession
+// Constructor 
+// ----------------------------------------------------------------------------
+//
+CSpeechSynthesisSession::CSpeechSynthesisSession():
+    iSessionState( ESessionIdle )
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisSession::CSpeechSynthesisSession" );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::CreateL
+// 2nd phase construct for sessions - called by the CServer framework
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::CreateL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::CreateL" );
+ 
+    Server().GetDefaultSettingsL( iCurrentVoice, 
+                                  iSpeakingRate, iMaxSpeakingRate,
+                                  iVolume, iMaxVolume, 
+                                  iAudioPriority, iAudioPreference,
+                                  iAudioOutput );
+    
+    iTmpAudioOutput = iAudioOutput;
+    iTmpVolume = iVolume;
+    
+    Server().AddSession();
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::~CSpeechSynthesisSession
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CSpeechSynthesisSession::~CSpeechSynthesisSession()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisSession::~CSpeechSynthesisSession" );
+    
+    iLanguages.Close();
+    iVoices.Close();
+    iCustomCommands.Close();
+    
+    Server().Release( this );
+    Server().DropSession();
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::MsssInitComplete
+// Callback from server
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::MsssInitComplete( TInt aError, 
+                                                const TTimeIntervalMicroSeconds& aDuration )
+    {
+    RUBY_DEBUG1( "CSpeechSynthesisSession::MsssInitComplete [%d]", aError );
+    
+    if ( aError )
+        {
+        iSessionState = ESessionIdle;
+        iFileOutputActivated = EFalse; 
+    
+        iDuration = 0;
+        iFile.Close();
+        
+        Server().Release( this );
+        }
+    else
+        {
+        iSessionState = ESessionPrimed;
+        
+        iDuration = aDuration;
+        }
+    
+    if ( iStoredMessage.IsNull() )
+        {
+        RUBY_ERROR0( "iStoredMessage.IsNull() == ETrue" );
+        }
+    else
+        {
+        iStoredMessage.Complete( aError );
+        RUBY_DEBUG0( "Message completed" );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::MsssPlayComplete
+// Callback from server
+// ----------------------------------------------------------------------------
+//      
+void CSpeechSynthesisSession::MsssPlayComplete( TInt aError )
+    {
+    RUBY_DEBUG1( "CSpeechSynthesisSession::MsssPlayComplete [%d]", aError );
+    
+    iSessionState = ESessionIdle;
+    iFileOutputActivated = EFalse; 
+    
+    iDuration = 0;
+    iFile.Close();
+    
+    Server().Release( this );
+
+    if ( iStoredMessage.IsNull() )
+        {
+        RUBY_ERROR0( "iStoredMessage.IsNull() == ETrue" );
+        }
+    else
+        {
+        iStoredMessage.Complete( aError );
+        RUBY_DEBUG0( "Message completed" );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::MsssOperationAborted
+// Callback from server
+// ----------------------------------------------------------------------------
+//      
+void CSpeechSynthesisSession::MsssOperationAborted()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisSession::MsssOperationAborted" );
+    
+    iSessionState = ESessionIdle;
+    iFileOutputActivated = EFalse; 
+    
+    iDuration = 0;
+    iFile.Close();
+
+    if ( !iStoredMessage.IsNull() )
+        {
+        RUBY_DEBUG0( "Completing message with KErrDied" );
+        iStoredMessage.Complete( KErrDied );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::Server
+//
+// ----------------------------------------------------------------------------
+//
+inline CSpeechSynthesisServer& CSpeechSynthesisSession::Server()
+    {
+    return *static_cast<CSpeechSynthesisServer*>(
+                const_cast<CServer2*>( CSession2::Server() ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::ServiceL
+// Handle a client request.
+// Leaving is handled by CSpeechSynthesisSession::ServiceError() which reports
+// the error code to the client
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::ServiceL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::ServiceL" );
+    RUBY_DEBUG1( "aMessage.Function(): %d", aMessage.Function() );
+    
+    TInt message( aMessage.Function() );
+    
+    if ( message == EPrime || message == EPrimeFileOutput || 
+         message == EPrimeStreamOutput || message == ESynthesise )
+        {
+        Server().ReserveL( this, iAudioPriority );
+
+        TRAPD( error, DoAsyncServiceL( aMessage ) );
+        if( error ) 
+            {
+            Server().Release( this );
+            User::Leave( error );
+            }
+        }
+    else
+        {
+        DoSyncServiceL( aMessage );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoAsyncServiceL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoAsyncServiceL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::DoAsyncServiceL" );
+    
+    TInt function( aMessage.Function() );
+    
+    if ( function == ESynthesise )
+        {
+        if ( iSessionState == ESessionPrimed )
+            {
+            if ( !iFileOutputActivated )
+                { // Values may be changed when synthesis is paused. 
+                if ( iTmpVolume != iVolume )
+                    {
+                    Server().SetVolume( iVolume );
+                    iTmpVolume = iVolume;
+                    }
+                
+                if ( iTmpAudioOutput != iAudioOutput )
+                    {
+                    Server().SetAudioOutputL( iAudioOutput );
+                    iTmpAudioOutput = iAudioOutput;
+                    }
+                }
+                
+            Server().Synthesize();
+            }
+        else
+            {
+            User::Leave( KErrNotReady );
+            }
+        }
+    else if ( function == EPrimeStreamOutput )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    else  // Prime or EPrimeFileOutput
+        {
+        iSessionState = ESessionIdle;
+        Server().Stop();
+        
+        if ( iClosePlugin || Server().PreviousSession() != this )
+            {
+            iClosePlugin = EFalse; 
+            
+            Server().ClosePlugin();
+            Server().SetVoiceL( iCurrentVoice, iSpeakingRate );
+            
+            // Set custom commands, plugin ingnores commands if the state
+            // is incorrect for some command
+            for ( TInt i( 0 ); i < iCustomCommands.Count(); i++ )
+                {
+                Server().CustomCommand( iCustomCommands[i].iCommand, iCustomCommands[i].iValue );
+                }
+            }
+        else
+            {
+            Server().SetVoiceL( iCurrentVoice, iSpeakingRate );
+            }
+            
+        // Fetch text to be synthesised
+        HBufC* text = HBufC::NewLC( aMessage.GetDesLengthL( 0 ) );
+        TPtr ptr = text->Des();
+        aMessage.ReadL( 0, ptr );
+    
+        if ( function == EPrime )
+            {
+            Server().SetAudioPriorityL( iAudioPriority, iAudioPreference );
+            
+            Server().SetVolume( iVolume );
+            iTmpVolume = iVolume;
+            
+            Server().SetAudioOutputL( iAudioOutput );
+            iTmpAudioOutput = iAudioOutput;
+            
+            Server().PrimeL( ptr );
+            
+            // Set custom commands, plugin ingnores commands if the state
+            // is incorrect for some command
+            for ( TInt i( 0 ); i < iCustomCommands.Count(); i++ )
+                { 
+                Server().CustomCommand( iCustomCommands[i].iCommand, iCustomCommands[i].iValue );
+                }
+            
+            iFileOutputActivated = EFalse; 
+            }
+        else
+            {
+            Server().PrimeL( ptr, iFile ); 
+            
+            iFileOutputActivated = ETrue;
+            }
+
+        CleanupStack::PopAndDestroy( text );
+        }
+
+    iStoredMessage = aMessage;
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSyncServiceL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSyncServiceL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::DoSyncServiceL" );
+    
+    switch ( aMessage.Function() ) 
+        {
+        case ETransferFileHandle:
+            
+            User::LeaveIfError( iFile.AdoptFromClient( aMessage, 
+                                                       KFsHandleIndex, 
+                                                       KFileHandleIndex ) ); 
+            
+            break;
+            
+        case EStopSynthesis:
+            
+            DoStopSynthesisL();
+            
+            break;
+            
+        case EPauseSynthesis:
+            
+            DoPauseSynthesisL();
+            
+            break;
+
+        case EGetDuration: 
+        
+            DoGetDurationL( aMessage );
+        
+            break;
+
+        case EGetLanguages:
+            
+            DoGetLanguagesL( aMessage );
+
+            break;
+            
+        case EGetLanguageCount:
+            
+            DoGetLanguageCountL( aMessage );
+            
+            break;
+            
+        case EGetVoices:
+            
+            DoGetVoicesL( aMessage );
+            
+            break;
+        
+        case EGetVoiceCount:
+            
+            DoGetVoiceCountL( aMessage );
+            
+            break;            
+
+        case EVoice:
+            
+            DoVoiceL( aMessage );
+            
+            break;
+
+        case ESetVoice:
+            
+            DoSetVoiceL( aMessage );
+            
+            break;
+
+        case EMaxSpeakingRate:
+           
+            DoMaxSpeakingRateL( aMessage );
+            
+            break;
+        
+        case ESpeakingRate:
+            
+            DoSpeakingRateL( aMessage );
+            
+            break;
+
+        case ESetSpeakingRate:
+            
+            DoSetSpeakingRateL( aMessage );
+            
+            break;
+            
+        case EMaxVolume:
+            
+            DoMaxVolumeL( aMessage );
+            
+            break;
+
+        case EVolume:
+            
+            DoVolumeL( aMessage );
+            
+            break;
+
+        case ESetVolume:
+            
+            DoSetVolumeL( aMessage );
+            
+            break;
+
+        case ESetAudioPriority:
+            
+            DoSetAudioPriority( aMessage );
+            
+            break;
+
+        case ESetAudioOutput:
+            
+            DoSetAudioOutputL( aMessage );
+            
+            break;
+
+        case ECustomCommand:
+            
+            DoCustomCommandL( aMessage );
+            
+            break;
+            
+        default:
+            
+            RUBY_ERROR1( "CSpeechSynthesisSession::ServiceL - %d",
+                         aMessage.Function() );
+                         
+            PanicClient( aMessage, EPanicIllegalFunction );
+            
+            break;
+        }
+    
+    aMessage.Complete( KErrNone ); 
+    }
+
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoStopSynthesisL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoStopSynthesisL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // Check we have permission to use server. 
+    Server().ReserveL( this );
+    
+    // Synthesis is ongoing
+    Server().Stop();
+    
+    iSessionState = ESessionIdle;
+    
+    iDuration = 0;
+    iFile.Close();
+    
+    // Release server and complete the previous message
+    Server().Release( this );
+    
+    if ( !iStoredMessage.IsNull() )
+        {
+        iStoredMessage.Complete( KErrAbort );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoPauseSynthesisL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoPauseSynthesisL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    if ( iSessionState == ESessionPrimed && !iStoredMessage.IsNull() )
+        {
+        if ( iFileOutputActivated )
+            {
+            User::Leave( KErrNotSupported );
+            }
+        
+        // Check we have permission to use server. 
+        Server().ReserveL( this );
+        
+        // Synthesis is ongoing
+        Server().Pause();
+        
+        iStoredMessage.Complete( KErrCancel );
+        }
+    else
+        {
+        User::Leave( KErrNotReady );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoGetDurationL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoGetDurationL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    if ( iSessionState != ESessionPrimed )
+        {
+        User::Leave( KErrNotReady ); 
+        }
+    else if ( iDuration.Int64() == 0 )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    
+    TPckgBuf<TTimeIntervalMicroSeconds> pkg( iDuration );
+    aMessage.WriteL( 0, pkg );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoGetLanguagesL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoGetLanguagesL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // DoGetLanguagesL is called immediately after EGetLanguageCount
+    if ( iLanguages.Count() > 0 ) 
+        { 
+        const TInt dataSize( iLanguages.Count() * sizeof(TLanguage) );
+        
+        HBufC8* tmp = HBufC8::NewLC( dataSize );
+        TPtr8 tmp_ptr( tmp->Des() );
+        
+        tmp_ptr.Append( (TUint8*)&iLanguages[0], dataSize );
+
+        aMessage.WriteL( 0, tmp_ptr );
+        
+        CleanupStack::PopAndDestroy( tmp );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoGetLanguageCountL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoGetLanguageCountL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    iLanguages.Reset();
+    
+    Server().GetSupportedLanguagesL( iLanguages );
+    
+    TPckgBuf<TInt> pkg_int( iLanguages.Count() ); 
+    aMessage.WriteL( 0, pkg_int );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoGetVoicesL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoGetVoicesL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // DoGetVoicesL is called immediately after EGetVoiceCount
+    if ( iVoices.Count() > 0 ) 
+        {
+        TInt dataSize( iVoices.Count() * sizeof(TVoice) );
+        
+        HBufC8* tmp = HBufC8::NewLC( dataSize );
+        TPtr8 tmp_ptr( tmp->Des() );
+        
+        tmp_ptr.Append( (TUint8*)&iVoices[0], dataSize );
+
+        aMessage.WriteL( 0, tmp_ptr );
+        
+        CleanupStack::PopAndDestroy( tmp );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoGetVoiceCountL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoGetVoiceCountL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    iVoices.Reset();
+    TLanguage language( static_cast<TLanguage> ( aMessage.Int1() ) );
+    
+    Server().GetSupportedVoicesL( language, iVoices );
+    
+    TPckgBuf<TInt> pkg_int( iVoices.Count() ); 
+    aMessage.WriteL( 0, pkg_int );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoVoiceL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoVoiceL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    if ( !Server().IsVoiceValidL( iCurrentVoice ) )
+        {
+        Server().GetDefaultVoiceL( iCurrentVoice );
+        }
+        
+    TPckgBuf<TVoice> pkg_voice( iCurrentVoice );
+    aMessage.WriteL( 0, pkg_voice );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSetVoiceL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSetVoiceL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TPckgBuf<TVoice> pkg_voice;
+    aMessage.ReadL( 0, pkg_voice );
+    
+    TVoice voice( pkg_voice() );
+    
+    if ( Server().IsVoiceValidL( voice ) )
+        {
+        iCurrentVoice = voice;
+        
+        // Custom commands are valid until new voice is set
+        iCustomCommands.Close();
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoMaxSpeakingRateL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoMaxSpeakingRateL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TPckgBuf<TInt> pkg_int( iMaxSpeakingRate );
+    aMessage.WriteL( 0, pkg_int );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSpeakingRateL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSpeakingRateL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TPckgBuf<TInt> pkg_int( iSpeakingRate ); 
+    aMessage.WriteL( 0, pkg_int );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSetSpeakingRateL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSetSpeakingRateL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TInt newValue( aMessage.Int0() );
+    
+    if ( newValue < KMinSpeakingRate || newValue > iMaxSpeakingRate )
+        {
+        User::Leave( KErrArgument );
+        }
+    else
+        {
+        iSpeakingRate = newValue;
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoMaxVolumeL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoMaxVolumeL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TPckgBuf<TInt> pkg_int( iMaxVolume ); 
+    aMessage.WriteL( 0, pkg_int );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoVolumeL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoVolumeL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TPckgBuf<TInt> pkg_int( iVolume ); 
+    aMessage.WriteL( 0, pkg_int );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSetVolumeL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSetVolumeL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    TInt newValue( aMessage.Int0() );
+    
+    if ( newValue < KMinVolume || newValue > iMaxVolume )
+        {
+        User::Leave( KErrArgument );
+        }
+    else
+        {
+        iVolume = newValue;
+        
+        if ( !iStoredMessage.IsNull() )
+            {
+            // Check first we have permission to use server. 
+            TRAP_IGNORE(
+                Server().ReserveL( this );
+                Server().SetVolume( iVolume );
+                iTmpVolume = iVolume;
+                );
+            }
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSetAudioPriority
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSetAudioPriority( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG0( "" );
+    
+    iAudioPriority = aMessage.Int0();
+    iAudioPreference = aMessage.Int1();
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoSetAudioOutputL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoSetAudioOutputL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    iAudioOutput = aMessage.Int0();
+    
+    if ( !iStoredMessage.IsNull() )
+        {
+        // Check first we have permission to use server. 
+        TRAPD( error, Server().ReserveL( this ) );
+        if ( error == KErrNone )
+            {
+            Server().SetAudioOutputL( iAudioOutput );
+            iTmpAudioOutput = iAudioOutput;
+            }
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::DoCustomCommandL
+// 
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::DoCustomCommandL( const RMessage2& aMessage )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    iClosePlugin = ETrue;
+    
+    TInt command( aMessage.Int0() );
+    TInt value( aMessage.Int1() );
+    
+    TBool found( EFalse );
+    TInt count( iCustomCommands.Count() );
+    
+    for ( TInt i( 0 ); i < count; i++ )
+        {
+        if ( iCustomCommands[i].iCommand == command )
+            {
+            iCustomCommands[i].iValue = value;
+            found = ETrue;
+            break;
+            }
+        }
+    
+    if ( !found )
+        {
+        TCustomCommand newItem;
+        newItem.iCommand = command;
+        newItem.iValue = value;
+        
+        iCustomCommands.AppendL( newItem );
+        }
+    
+    Server().CustomCommand( command, value );
+    }
+    
+// ----------------------------------------------------------------------------
+// CSpeechSynthesisSession::ServiceError
+// Handle an error from CSpeechSynthesisSession::ServiceL()
+// ----------------------------------------------------------------------------
+//
+void CSpeechSynthesisSession::ServiceError( const RMessage2& aMessage, 
+                                            TInt aError )
+    {
+    RUBY_DEBUG1( "CSpeechSynthesisSession::ServiceError %d", aError );
+    
+    CSession2::ServiceError( aMessage, aError );
+    } 
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/bwins/speechsynthesistestu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/data/speechsynthesistest.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,275 @@
+[Define]
+KErrNone 0
+KErrCancel -3
+KErrNotSupported -5
+KErrArgument -6
+KErrNotReady -18
+KErrAbort -39
+[Enddefine]
+
+[Test] // 1
+title Basic functionality
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test GetSupportedLangs KErrNone
+test GetSupportedVoices KErrNone 1
+test Voice KErrNone
+test SetVoice KErrNotSupported // Test is not implemented yet
+test MaxVolume KErrNone
+test SetVolume KErrNone 8 // Scale is 0..10 * MaxVolume
+test Volume KErrNone
+test MaxSpeakingRate KErrNone
+test SetSpeakingRate KErrNone 80 // Scale is 1..100
+test SpeakingRate KErrNone
+test SetAudioPriority KErrNone 0 0 
+test CustomCommand KErrNone
+test Stop KErrNone
+test Pause KErrNotReady
+test InitialiseSynthesis KErrNone Short sentence.
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrNone Short sentence. filename: C:\test.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 2
+title Basic synthesis
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test Synthesise KErrNotReady
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone U shouldn't hear this..
+wait SynthesisInitComplete
+test InitialiseSynthesis KErrNone The Open C libraries are part of S60 3.2 SDK -- a set of standard or otherwise useful libraries. 
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone Las Vegas, USA - Nokia today introduced a trimmer fold model to its Nokia Nseries line up, the Nokia N76, a new smartphone that brings the complete Nokia Nseries experience to a sleeker body, with little compromise. Using premium materials to enclose world-class Nokia Nseries features and experiences, Nokia has created a very eye-catching device. We did not want to compromise any of the key Nokia Nseries experiences when we designed the stylish Nokia N76 multimedia computer, said Pekka Pohjakallio, vice-president, Multimedia, Nokia. He continued, Nokia Nseries consumers are bleeding edge technology users and with them in mind we want to offer intelligent and entertaining multimedia functionality in an easy to use, ultra slim package. 
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 3
+title Synthesise short inputs
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesis KErrNone a
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone .
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone :)
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 4
+title Synthesise to file
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesisFile KErrNone Text to be saved to the file filename: C:\test1.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrArgument Text to be saved to the file filename: C:\test.wav
+wait SynthesisInitComplete
+// STIF has AllFiles capability
+test InitialiseSynthesisFile KErrNone Text to be saved to the file filename: C:\private\test.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrNone a filename: C:\test2.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrNone To provide mobile developers with a structured online setting for creating and maintaining valuable information, Nokia is about to launch the Forum Nokia Wiki as a resource for application developers and content creators. filename: C:\test3.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 5
+title Pause and resume
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesis KErrNone Software Platforms (a Technology Platforms unit) starts consultations with employee representatives :( Software Platforms is starting a consultations process with employee representatives concerning a maximum of 100 employees in Finland. 
+wait SynthesisInitComplete
+test Synthesise KErrCancel
+test Pause KErrNone
+wait SynthesisComplete
+test Synthesise KErrCancel
+test Pause KErrNone
+wait SynthesisComplete
+pause 500
+test Synthesise KErrCancel
+pause 1000
+test Pause KErrNone
+wait SynthesisComplete
+pause 1000
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone To provide mobile developers with a structured online setting for creating and maintaining valuable information, Nokia is about to launch the Forum Nokia Wiki as a resource for application developers and content creators.
+wait SynthesisInitComplete
+test Synthesise KErrCancel
+pause 2000
+test Pause KErrNone
+wait SynthesisComplete
+pause 1000
+test Synthesise KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone Networks and Bharti, one of India's leading private sector providers of telecommunications services, chose a hybrid solar wind -solution for Dharkola site in Orissa after a cost- benefit analysis in late 2005. 
+wait SynthesisInitComplete
+test Synthesise KErrCancel
+pause 3000
+test Pause KErrNone
+wait SynthesisComplete
+pause 500
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 6
+title Pause and resume file output
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesisFile KErrNone Software Platforms (a Technology Platforms unit) starts consultations with employee representatives :( Software Platforms is starting a consultations process with employee representatives concerning a maximum of 100 employees in Finland. filename: C:\pauseresume.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+test Pause KErrNotSupported
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 7
+title Stop
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesis KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. 
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. 
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+pause 100
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. 
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+pause 1000
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. 
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+pause 3000
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesis KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. 
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 8
+title Stop output to file
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesisFile KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. filename: C:\stop1.raw
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. filename: C:\stop2.raw
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+pause 50
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. filename: C:\stop3.raw
+wait SynthesisInitComplete
+test Synthesise KErrAbort
+pause 200
+test Stop KErrNone
+wait SynthesisComplete
+test InitialiseSynthesisFile KErrNone The relocation of these groups affects approximately 45 employees, and approximately 50 positions will cease to exist. filename: C:\stop4.raw
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
+
+[Test] // 9
+title Cancel initialisation 
+timeout 120000  // 2 minutes
+create SpeechSynthesisTest test
+request SynthesisInitComplete
+request SynthesisComplete
+test Open KErrNone
+test InitialiseSynthesis KErrNone Networks and Bharti, one of India's leading private sector providers of telecommunications services, chose a hybrid solar wind -solution for Dharkola site in Orissa after a cost- benefit analysis in late 2005. 
+test Pause KErrNotReady
+test Stop KErrNone
+wait SynthesisInitComplete
+test InitialiseSynthesis KErrNone Networks and Bharti, one of India's leading private sector providers of telecommunications services, chose a hybrid solar wind -solution for Dharkola site in Orissa after a cost- benefit analysis in late 2005. 
+pause 100
+test Stop KErrNone
+wait SynthesisInitComplete
+test InitialiseSynthesis KErrNone Networks and Bharti, one of India's leading private sector providers of telecommunications services, chose a hybrid solar wind -solution for Dharkola site in Orissa after a cost- benefit analysis in late 2005. 
+wait SynthesisInitComplete
+test Synthesise KErrNone
+wait SynthesisComplete
+test Close KErrNone
+delete test
+[Endtest] 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/data/testframework.ini	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,168 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if 
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module. 
+
+[Engine_Defaults]
+
+TestReportMode= FullReport		# Possible values are: 'Empty', 'Summary', 'Environment',
+                                                               'TestCases' or 'FullReport'
+
+CreateTestReport= YES			# Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT			# Possible values: TXT or HTML
+TestReportOutput= FILE			# Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE	# Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= c:\TestFramework\speechsynthesistest.cfg
+[End_Module]
+
+
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIFTestFramework logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number 
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' 
+
+#CreateLogDirectories= YES		# Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+EmulatorFormat= txt			# Possible values: TXT or HTML
+EmulatorOutput= FILE			# Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML			# Possible values: TXT or HTML
+#HardwareOutput= FILE			# Possible values: FILE or RDEBUG
+
+FileCreationMode= OVERWRITE		# Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES			# Possible values: YES or NO
+WithTimeStamp= YES			# Possible values: YES or NO
+WithLineBreak= YES			# Possible values: YES or NO
+WithEventRanking= YES			# Possible values: YES or NO
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/eabi/speechsynthesistestu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+#include "export.inc"
+
+../data/testframework.ini /epoc32/wins/c/testframework/testframework.ini
+../data/testframework.ini /epoc32/winscw/c/testframework/testframework.ini
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+speechsynthesistest.mmp
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/group/create_signed_sis.bat	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@echo off
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo ! Creates signed sis package for installation of speechsynthesis STIF Test !
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+call makesis speechsynthesistest.pkg
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo Starting to sign the SIS package
+call signsis.exe speechsynthesistest.sis speechsynthesistest_signed.sis \s60_RnD\RD_RootCA\rd.cer \s60_RnD\RD_RootCA\rd-key.pem
+echo Done!
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo Deleting tmp files
+call del speechsynthesistest.sis
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo That's all!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/group/export.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1 @@
+..\data\speechsynthesistest.cfg \epoc32\winscw\c\testframework\speechsynthesistest.cfg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/group/speechsynthesistest.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          speechsynthesistest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      ALL -TCB
+DEFFILE         speechsynthesistest.def
+
+SOURCEPATH      ../src
+SOURCE          speechsynthesistest.cpp
+SOURCE          speechsynthesistestblocks.cpp
+SOURCE          speechsynthesistester.cpp
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../../rubydebug
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         speechsynthesis.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/group/speechsynthesistest.pkg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,44 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+;
+; Installation package creation file for speechsynthesis STIF test module.
+;
+
+; Languages
+&EN
+
+; Package header
+#{"NSS speechsynthesis STIF"},(0x1001ABAA),0,1,0,TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia/TP/SP/SWD/UIG/MUI"
+
+; Dependency to indicate compatibility with S60 3.1
+[0x102752AE],0,0,0,{"S60ProductID"}
+
+; Start of Package body
+
+; Test itself
+"\epoc32\release\armv5\urel\speechsynthesistest.dll" - "c:\sys\bin\speechsynthesistest.dll"
+
+; Config and data files
+"..\data\testframework.ini"          - "C:\TestFramework\testframework.ini"
+"..\data\speechsynthesistest.cfg"    - "C:\TestFramework\speechsynthesistest.cfg"
+
+; End of Package body
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/inc/speechsynthesistest.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef SPEECHSYNTHESISTEST_H
+#define SPEECHSYNTHESISTEST_H
+
+//  INCLUDES
+#include <stiflogger.h>
+#include <testscripterinternal.h>
+#include <stiftestmodule.h>
+
+#include "speechsynthesistester.h"
+
+// MACROS
+
+// Logging path
+_LIT( KSpeechSynthesisTestLogPath, "\\logs\\testframework\\SpeechSynthesisTest\\" ); 
+// Log file
+_LIT( KSpeechSynthesisTestLogFile, "SpeechSynthesisTest.txt" ); 
+
+
+
+/**
+*  CSpeechSynthesisTest test class for STIF Test Framework TestScripter.
+*/
+NONSHARABLE_CLASS( CSpeechSynthesisTest ) : public CScriptBase, 
+                                            public MTesterObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CSpeechSynthesisTest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSpeechSynthesisTest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+
+    protected:
+    
+        // Callbacks from iTester
+        void SynthesisInitComplete( TInt aError );    
+        void SynthesisComplete( TInt aError );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CSpeechSynthesisTest( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Frees all resources allocated from test methods.
+        */
+        void Delete();
+
+        /**
+        * Test methods 
+        * @param aItem Script line containing parameters.
+        * @return Symbian OS error code.
+        */
+        virtual TInt OpenL( CStifItemParser& aItem );
+        virtual TInt CloseL( CStifItemParser& aItem );
+        
+        virtual TInt SynthesisInitL( CStifItemParser& aItem );
+        virtual TInt SynthesisInitFileL( CStifItemParser& aItem );
+        virtual TInt SynthesiseL( CStifItemParser& aItem );
+        virtual TInt StopL( CStifItemParser& aItem );
+        virtual TInt PauseL( CStifItemParser& aItem );
+        
+        virtual TInt GetSupportedLanguagesL( CStifItemParser& aItem );
+        
+        virtual TInt GetSupportedVoicesL( CStifItemParser& aItem );
+        virtual TInt VoiceL( CStifItemParser& aItem );
+        virtual TInt SetVoiceL( CStifItemParser& aItem );
+        
+        virtual TInt MaxVolumeL( CStifItemParser& aItem );
+        virtual TInt VolumeL( CStifItemParser& aItem );
+        virtual TInt SetVolumeL( CStifItemParser& aItem );
+        
+        virtual TInt MaxSpeakingRateL( CStifItemParser& aItem );
+        virtual TInt SpeakingRateL( CStifItemParser& aItem );
+        virtual TInt SetSpeakingRateL( CStifItemParser& aItem );
+
+        virtual TInt SetAudioPriorityL( CStifItemParser& aItem );
+        virtual TInt CustomCommandL( CStifItemParser& aItem );
+        
+        TInt ReadExpectedResultL( CStifItemParser& aItem );
+        void CheckResultL( TInt aExpectedResult, TInt aResult );
+
+    private:
+        
+        CSpeechSynthesisTester* iTester;
+        
+        TBuf<2048> iText; 
+        
+        TInt iExpectedResult;
+    };
+
+#endif      // SPEECHSYNTHESISTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/inc/speechsynthesistester.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef SPEECHSYNTHESISTESTER_H
+#define SPEECHSYNTHESISTESTER_H
+
+#include <e32base.h>
+#include <speechsynthesis.h>
+
+// CLASS DECLARATIONS
+
+NONSHARABLE_CLASS( MTesterObserver )
+    {
+    
+    public:
+    
+        virtual void SynthesisInitComplete( TInt aError ) = 0;
+        virtual void SynthesisComplete( TInt aError ) = 0;
+        
+    };
+
+
+/**
+*  This class encapsulates resource file handling functions
+*/
+NONSHARABLE_CLASS( CSpeechSynthesisTester ) : public CActive
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CSpeechSynthesisTester* NewL( MTesterObserver& aObserver );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSpeechSynthesisTester();
+
+    public:
+    
+        TInt Open();
+        void Close();
+        
+        void SynthesisInit(  TDesC& aText, const TDesC& aFileName = KNullDesC );
+        void Synthesise();
+        void StopL();
+        void PauseL();
+        
+        void GetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+        
+        void GetSupportedVoicesL( RArray<TVoice>& aVoices, TLanguage aLanguage );
+        TVoice VoiceL( );
+        void SetVoiceL( TVoice& aVoice );
+
+        TInt MaxSpeakingRateL();
+        TInt SpeakingRateL();
+        void SetSpeakingRateL( TInt aRate );
+        
+        TInt MaxVolumeL();
+        TInt VolumeL();
+        void SetVolumeL( TInt aVolume );
+
+        void SetAudioPriorityL( TInt aPriority, TInt aPreference );
+        
+        void CustomCommandL( TInt aCommand, TInt aValue );
+    
+    protected: // From CActive
+    
+        /**
+        * CActive::RunL
+        */
+        void RunL();
+
+        /**
+        * CActive::DoCancel()
+        */
+        void DoCancel();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CSpeechSynthesisTester( MTesterObserver& aObserver );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+
+    private: // Data
+
+        RSpeechSynthesis            iSpeechSynthesis;
+        
+        enum TTestStatus
+            {
+            EIdle,
+            EPriming,
+            EPlaying
+            };
+
+        TTestStatus                 iTestStatus;
+        
+        MTesterObserver&            iObserver;
+    };
+
+#endif // SPEECHSYNTHESISTESTER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/src/speechsynthesistest.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <stiftestinterface.h>
+
+#include "speechsynthesistest.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::CSpeechSynthesisTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSpeechSynthesisTest::CSpeechSynthesisTest( CTestModuleIf& aTestModuleIf ):
+    CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTest::ConstructL()
+    {
+    iLog = CStifLogger::NewL( KSpeechSynthesisTestLogPath, 
+                          KSpeechSynthesisTestLogFile,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    
+    iTester = CSpeechSynthesisTester::NewL( *this );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSpeechSynthesisTest* CSpeechSynthesisTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CSpeechSynthesisTest* self = new (ELeave) CSpeechSynthesisTest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// Destructor
+CSpeechSynthesisTest::~CSpeechSynthesisTest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+
+    return ( CScriptBase* ) CSpeechSynthesisTest::NewL( aTestModuleIf );
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/src/speechsynthesistestblocks.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,539 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <stifparser.h>
+#include <stiftestinterface.h>
+#include <StifTestEventInterface.h>
+
+#include "speechsynthesistest.h"
+
+#include "rubydebug.h"
+
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTest::Delete() 
+    {
+    delete iTester;
+    iTester = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::RunMethodL( CStifItemParser& aItem ) 
+    {
+    TStifFunctionInfo const KFunctions[] =
+        {
+        ENTRY( "Open",                      CSpeechSynthesisTest::OpenL ),
+        ENTRY( "Close",                     CSpeechSynthesisTest::CloseL ),
+        
+        ENTRY( "InitialiseSynthesis",       CSpeechSynthesisTest::SynthesisInitL ),
+        ENTRY( "InitialiseSynthesisFile",   CSpeechSynthesisTest::SynthesisInitFileL ),
+        ENTRY( "Synthesise",                CSpeechSynthesisTest::SynthesiseL ),
+        ENTRY( "Stop",                      CSpeechSynthesisTest::StopL ),
+        ENTRY( "Pause",                     CSpeechSynthesisTest::PauseL ),
+
+        ENTRY( "GetSupportedLangs",         CSpeechSynthesisTest::GetSupportedLanguagesL ),    
+        
+        ENTRY( "GetSupportedVoices",        CSpeechSynthesisTest::GetSupportedVoicesL ),
+        ENTRY( "Voice",                     CSpeechSynthesisTest::VoiceL ),
+        ENTRY( "SetVoice",                  CSpeechSynthesisTest::SetVoiceL ),
+        
+        ENTRY( "MaxVolume",                 CSpeechSynthesisTest::MaxVolumeL ),
+        ENTRY( "Volume",                    CSpeechSynthesisTest::VolumeL ),
+        ENTRY( "SetVolume",                 CSpeechSynthesisTest::SetVolumeL ),
+        
+        ENTRY( "MaxSpeakingRate",           CSpeechSynthesisTest::MaxSpeakingRateL ),
+        ENTRY( "SpeakingRate",              CSpeechSynthesisTest::SpeakingRateL ),
+        ENTRY( "SetSpeakingRate",           CSpeechSynthesisTest::SetSpeakingRateL ),
+        
+        ENTRY( "SetAudioPriority",          CSpeechSynthesisTest::SetAudioPriorityL ),
+        ENTRY( "CustomCommand",             CSpeechSynthesisTest::CustomCommandL ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::OpenL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::OpenL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt result = iTester->Open();
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::CloseL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::CloseL( CStifItemParser& aItem )
+    {
+    // Expected result not used. 
+    ReadExpectedResultL( aItem ); 
+    
+    iTester->Close();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SynthesisInitL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SynthesisInitL( CStifItemParser& aItem )
+    {
+    iExpectedResult = ReadExpectedResultL( aItem ); 
+    
+    TPtrC tmp;
+    
+    iText.Delete( 0, iText.MaxLength() );
+    
+    while ( aItem.GetNextString( tmp ) == KErrNone )
+        {
+        iText.Append( tmp );
+        iText.Append( _L(" ") );
+        }
+
+    iTester->SynthesisInit( iText );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SynthesisInitFileL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SynthesisInitFileL( CStifItemParser& aItem )
+    {
+    iExpectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt result( KErrArgument );
+    
+    TPtrC tmp;
+    TFileName fileName;
+    
+    iText.Delete( 0, iText.MaxLength() );
+    
+    while ( aItem.GetNextString( tmp ) == KErrNone )
+        {
+        if ( tmp != _L("filename:") )
+            {
+            iText.Append( tmp );
+            iText.Append( _L(" ") );
+            }
+        else
+            {
+            break;
+            }
+        }
+
+    if ( aItem.GetNextString( tmp ) == KErrNone )
+        {
+        fileName.Append( tmp );
+        
+        iTester->SynthesisInit( iText, fileName );
+        
+        result = KErrNone;
+        }
+    
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SynthesiseL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SynthesiseL( CStifItemParser& aItem )
+    {
+    iExpectedResult = ReadExpectedResultL( aItem ); 
+    
+    iTester->Synthesise();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::StopL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::StopL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TRAPD( result, iTester->StopL() );
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::PauseL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::PauseL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TRAPD( result, iTester->PauseL() );
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::GetSupportedLanguagesL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::GetSupportedLanguagesL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    RArray<TLanguage> languages;
+    CleanupClosePushL( languages );
+    
+    TRAPD( result, iTester->GetSupportedLanguagesL( languages ) );
+    
+    CleanupStack::PopAndDestroy( &languages );
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::GetSupportedVoicesL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::GetSupportedVoicesL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    RArray<TVoice> voices;
+    CleanupClosePushL( voices );
+    
+    TInt tmp;
+    User::LeaveIfError( aItem.GetNextInt( tmp ) );
+    TLanguage language( (TLanguage)tmp );
+    
+    TRAPD( result, iTester->GetSupportedVoicesL( voices, language ) ); 
+    
+    CleanupStack::PopAndDestroy( &voices );
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::VoiceL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::VoiceL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TVoice voice;
+    
+    TRAPD( result, voice = iTester->VoiceL() );
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SetVoiceL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SetVoiceL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    // @todo Implement this!
+    TInt result = KErrNotSupported;
+    
+    CheckResultL( expectedResult, result );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::MaxVolumeL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::MaxVolumeL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt maxVolume( -1 );
+    
+    TRAPD( result, maxVolume = iTester->MaxVolumeL() );
+    
+    CheckResultL( expectedResult, result );
+    
+    TestModuleIf().Printf( 0, _L("MaxVolume:"), _L("%d"), maxVolume );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::VolumeL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::VolumeL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt volume( -1 );
+    
+    TRAPD( result, volume = iTester->VolumeL() );
+    
+    CheckResultL( expectedResult, result );
+    
+    TestModuleIf().Printf( 1, _L("Volume:"), _L("%d"), volume );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SetVolumeL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SetVolumeL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt newVolume;
+    aItem.GetNextInt( newVolume );
+    
+    TRAPD( result, iTester->SetVolumeL( newVolume * iTester->MaxVolumeL() / 10 ) );
+    
+    CheckResultL( expectedResult, result ); 
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::MaxSpeakingRateL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::MaxSpeakingRateL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt maxSpeakingRate( -1 ); 
+    
+    TRAPD( result, maxSpeakingRate = iTester->MaxSpeakingRateL() ); 
+    
+    CheckResultL( expectedResult, result ); 
+    
+    TestModuleIf().Printf( 2, _L("maxSpeakingRate:"), _L("%d"), maxSpeakingRate );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SpeakingRateL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SpeakingRateL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt rate( -1 );
+    
+    TRAPD( result, rate = iTester->SpeakingRateL() );
+    
+    CheckResultL( expectedResult, result ); 
+    
+    TestModuleIf().Printf( 3, _L("SpeakingRate:"), _L("%d"), rate );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SetSpeakingRateL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SetSpeakingRateL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt newRate;
+    aItem.GetNextInt( newRate );
+    
+    TRAPD( result, iTester->SetSpeakingRateL( newRate ) );
+    
+    CheckResultL( expectedResult, result ); 
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SetAudioPriorityL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::SetAudioPriorityL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TInt priority( -1 );
+    aItem.GetNextInt( priority );
+    
+    TInt preference( -1 );
+    aItem.GetNextInt( preference );
+    
+    TRAPD( result, iTester->SetAudioPriorityL( priority, preference ) );
+    
+    CheckResultL( expectedResult, result ); 
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::CustomCommandL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::CustomCommandL( CStifItemParser& aItem )
+    {
+    TInt expectedResult = ReadExpectedResultL( aItem ); 
+    
+    TRAPD( result, iTester->CustomCommandL( 0, 0 ) );
+    
+    CheckResultL( expectedResult, result );
+        
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SynthesisInitComplete
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTest::SynthesisInitComplete( TInt aError )
+    {
+    RUBY_DEBUG0( "SynthesisInitComplete - START" );
+    
+    if ( iExpectedResult != aError )
+        {
+        RUBY_ERROR2( "CSpeechSynthesisTest::SynthesisInitComplete -- %d != %d", 
+                     iExpectedResult, aError );
+        User::Panic( _L("InitComplete"), aError );
+        }
+    
+    TEventIf stifEvent( TEventIf::ESetEvent,  _L( "SynthesisInitComplete" ) );
+    
+    TestModuleIf().Event( stifEvent );
+    
+    RUBY_DEBUG0( "SynthesisInitComplete - EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::SynthesisComplete
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTest::SynthesisComplete( TInt aError )
+    {
+    RUBY_DEBUG0( "SynthesisComplete - START" );
+    
+    if ( iExpectedResult != aError )
+        {
+        RUBY_ERROR2( "CSpeechSynthesisTest::SynthesisComplete -- %d != %d", 
+                     iExpectedResult, aError );
+        User::Panic( _L("Complete"), aError );
+        }
+
+    TEventIf stifEvent( TEventIf::ESetEvent,  _L( "SynthesisComplete" ) );
+    
+    TestModuleIf().Event( stifEvent );
+    
+    RUBY_DEBUG0( "SynthesisComplete - EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::ReadExpectedResultL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTest::ReadExpectedResultL( CStifItemParser& aItem )
+    {
+    TInt expectedResult( -1 );
+    
+    User::LeaveIfError( aItem.GetNextInt( expectedResult ) );
+
+    return expectedResult;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTest::CheckResultL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTest::CheckResultL( TInt aExpectedResult, TInt aResult )
+    {
+    RUBY_DEBUG_BLOCKL( "" );
+    
+    if ( aExpectedResult != aResult )
+        {
+        RUBY_ERROR2( "aExpectedResult = %d - aResult = %d", aExpectedResult, aResult );
+        
+        User::Leave( KErrCompletion );
+        }
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/speechsynthesistest/src/speechsynthesistester.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,362 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "speechsynthesistester.h"
+#include "rubydebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSpeechSynthesisTester* CSpeechSynthesisTester::NewL( MTesterObserver& aObserver )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::NewL" );
+    
+    CSpeechSynthesisTester* self =
+        new ( ELeave ) CSpeechSynthesisTester( aObserver );
+        
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); 
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::CSpeechSynthesisTester
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CSpeechSynthesisTester::CSpeechSynthesisTester( MTesterObserver& aObserver ):
+    CActive( EPriorityStandard ),
+    iTestStatus( EIdle ),
+    iObserver( aObserver )
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::CSpeechSynthesisTester" );
+    
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CSpeechSynthesisTester::ConstructL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::~CSpeechSynthesisTester
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CSpeechSynthesisTester::~CSpeechSynthesisTester()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::~CSpeechSynthesisTester" );
+    
+    Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::Open
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTester::Open()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::Open" );
+    
+    return iSpeechSynthesis.Open();
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::Close
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::Close()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::Close" );
+    
+    iSpeechSynthesis.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::SynthesisInit
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::SynthesisInit( TDesC& aText, const TDesC& aFileName )
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::SynthesisInit" );
+    
+    Cancel();
+    SetActive();
+    
+    iTestStatus = EPriming;
+    
+    if ( aFileName.Length() > 0 )
+        {
+        iSpeechSynthesis.InitialiseSynthesis( aText, aFileName, iStatus );
+        }
+    else
+        {
+        iSpeechSynthesis.InitialiseSynthesis( aText, iStatus );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::Synthesise
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::Synthesise()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::Synthesise" );
+    
+    Cancel();
+    SetActive();
+        
+    iTestStatus = EPlaying;
+    
+    iSpeechSynthesis.Synthesise( iStatus );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::StopL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::StopL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::StopL" );
+    
+    iSpeechSynthesis.StopL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::PauseL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::PauseL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::PauseL" );
+    
+    iSpeechSynthesis.PauseL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::GetSupportedLanguagesL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::GetSupportedLanguagesL(  RArray<TLanguage>& aLanguages )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::GetSupportedLanguagesL" );
+    
+    iSpeechSynthesis.GetLanguagesL( aLanguages );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::GetSupportedVoicesL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::GetSupportedVoicesL( RArray<TVoice>& aVoices, 
+                                                  TLanguage aLanguage )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::GetSupportedVoicesL" );
+    
+    iSpeechSynthesis.GetVoicesL( aVoices, aLanguage );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::VoiceL
+// 
+// -----------------------------------------------------------------------------
+//
+TVoice CSpeechSynthesisTester::VoiceL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::VoiceL" );
+    
+    return iSpeechSynthesis.VoiceL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::SetVoiceL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::SetVoiceL( TVoice& aVoice )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::SetVoiceL" );
+    
+    iSpeechSynthesis.SetVoiceL( aVoice );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::MaxVolumeL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTester::MaxVolumeL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::MaxVolumeL" );
+    
+    return iSpeechSynthesis.MaxVolumeL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::VolumeL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTester::VolumeL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::VolumeL" );
+    
+    return iSpeechSynthesis.VolumeL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::SetVolumeL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::SetVolumeL( TInt aVolume )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::SetVolumeL" );
+    
+    iSpeechSynthesis.SetVolumeL( aVolume );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::MaxSpeakingRateL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTester::MaxSpeakingRateL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::MaxSpeakingRateL" );
+    
+    return iSpeechSynthesis.MaxSpeakingRateL();
+    }
+        
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::SpeakingRateL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CSpeechSynthesisTester::SpeakingRateL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::SpeakingRateL" );
+    
+    return iSpeechSynthesis.SpeakingRateL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::SetSpeakingRateL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::SetSpeakingRateL( TInt aRate )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::SetSpeakingRateL" );
+    
+    iSpeechSynthesis.SetSpeakingRateL( aRate );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::SetAudioPriorityL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::SetAudioPriorityL( TInt aPriority, TInt aPreference )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::SetAudioPriorityL" );
+    
+    iSpeechSynthesis.SetAudioPriorityL( aPriority, aPreference );
+    }
+
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::CustomCommandL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::CustomCommandL( TInt aCommand, TInt aValue )
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::CustomCommandL" );
+    
+    iSpeechSynthesis.CustomCommandL( aCommand, aValue );
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::RunL
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CSpeechSynthesisTester::RunL" );
+    
+    switch( iTestStatus )
+        {
+        case EPriming:
+        
+            iObserver.SynthesisInitComplete( iStatus.Int() ); 
+         
+            break;
+            
+        case EPlaying:
+        
+            iObserver.SynthesisComplete( iStatus.Int() ); 
+            
+            break;
+        
+        default:
+        
+            RUBY_ERROR0( "CSpeechSynthesisTester::RunL - In default!" );
+             
+        }
+
+    iTestStatus = EIdle;
+    }
+    
+// -----------------------------------------------------------------------------
+// CSpeechSynthesisTester::DoCancel
+// 
+// -----------------------------------------------------------------------------
+//
+void CSpeechSynthesisTester::DoCancel()
+    {
+    RUBY_DEBUG0( "CSpeechSynthesisTester::DoCancel" );
+    
+    iTestStatus = EIdle;
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/data/testapplication.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    AWIZ // 4 letter ID
+
+//  INCLUDES
+
+#include <appinfo.rh>
+#include <avkon.loc>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <data_caging_paths_strings.hrh>
+#include <eikon.rh>
+#include <eikon.rsg>
+
+#include "TestApp.hrh"
+
+//  RESOURCE DEFINITIONS 
+
+// ---------------------------------------------------------
+//   
+//    Define the resource file signature 
+//    This resource should be empty.
+//
+// ---------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE 
+{
+}
+
+// ---------------------------------------------------------
+//   
+//    Default Document Name
+//
+// ---------------------------------------------------------
+//
+RESOURCE TBUF r_default_document_name
+{
+    buf="TTS API test";
+}
+
+// ---------------------------------------------------------
+//   
+//    Define default menu and CBA key.
+//
+// ---------------------------------------------------------
+//
+RESOURCE EIK_APP_INFO
+{
+    menubar = r_test_application_menubar_mainview;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+}
+
+//----------------------------------------------------
+//   
+//    r_test_application_localisable_app_info
+//    menu captions and application icon
+//
+//----------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_test_application_localisable_app_info
+{
+
+    short_caption = TTS API test;
+    
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO 
+    {   
+        caption = TTS API test;
+        number_of_icons = 1;
+
+    };
+}
+
+// ---------------------------------------------------------
+//   
+//    r_test_application_mainview
+//    Define the main view
+//
+// ---------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_test_application_mainview
+{
+    menubar = r_test_application_menubar_mainview;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+}
+
+
+//----------------------------------------------------
+//   
+//    r_test_application_menubar_mainview
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_test_application_menubar_mainview
+{
+    titles =
+    {
+        MENU_TITLE
+        {
+            menu_pane = r_test_application_menu;
+        }
+    };
+}
+
+//----------------------------------------------------
+//   
+//    r_test_application_menu
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_test_application_menu
+    {
+    items=
+        {
+        MENU_ITEM { command = EAknCmdExit;                 txt = "Exit"; },
+        MENU_ITEM { command = ETestAppCmdAppConnect;       txt = "Connect to server"; },
+        MENU_ITEM { command = ETestAppCmdAppDisconnect;    txt = "Disconnect server"; },
+        MENU_ITEM { command = ETestAppCmdAppSayText;       txt = "Say text"; },
+        MENU_ITEM { command = ETestAppCmdAppSayTextToFile; txt = "Say text to file"; },
+        MENU_ITEM { command = ETestAppCmdAppChangeVoice;   txt = "Change voice"; },
+        MENU_ITEM { command = ETestAppCmdAppVolumeDown;    txt = "Volume down"; },
+        MENU_ITEM { command = ETestAppCmdAppVolumeUp;      txt = "Volume up"; }
+        };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/data/testapplication_reg.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <appinfo.rh>
+#include <testapplication.rsg>
+#include <data_caging_paths_strings.hrh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x043ECF25
+
+RESOURCE APP_REGISTRATION_INFO
+{
+    app_file = "testapplication";
+    localisable_resource_file = APP_RESOURCE_DIR"\\testapplication";
+    localisable_resource_id = R_TEST_APPLICATION_LOCALISABLE_APP_INFO;
+}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS ARMI ARM4 THUMB so you can ignore this if you just build these
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example: 
+/*
+/agnmodel/inc/AGMCOMON.H
+*/
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables. Note that you should specify any .mmp files for test
+// programs further down the file.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released to the rest of the company
+// specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+/agnmodel/group/agnmodel.mmp
+#if defined(MARM)
+/agnmodel/group/agsvexe.mmp
+#endif
+*/
+
+TestApp.mmp
+
+PRJ_TESTMMPFILES
+// specify the .mmp files required for building any test programs here
+//
+// You can specify "manual" to denote that a test should be listed in a
+// generated batch file for running a group of tests
+// which require user input during testing.
+// You can specify "support" to denote that a file is a test support file
+// and shouldn't be listed in a batch file for running a group of tests
+// By default, each test will be listed in a batch file for running a group
+// of tests which can be left to run without requiring watching over
+// by the person running the tests, i.e. tests where no user
+// input is required.  The default will apply if neither "manual"
+// or "support" is specified.
+// Example:
+/*
+/agnmodel/agtest/T_ATTEND.MMP    manual
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/group/create_signed_sis.bat	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+@echo off
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo ! Creates signed sis package for installation of speechsynthesis test application !
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+call makesis testapplication.pkg
+echo .
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo Starting to sign the SIS package
+call signsis.exe testapplication.sis testapplication_signed.sis \s60_RnD\RD_RootCA\rd.cer \s60_RnD\RD_RootCA\rd-key.pem
+echo Done!
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo Deleting tmp files
+call del testapplication.sis
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo That's all!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/group/testapp.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          testapplication.exe
+TARGETTYPE      exe
+UID             0x100039CE 0x043ECF25
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_APPLICATION
+
+SOURCEPATH      ../src
+SOURCE          testappapp.cpp 
+SOURCE          testappappui.cpp
+SOURCE          testappdocument.cpp
+SOURCE          testappcontainer.cpp
+SOURCE          testappengine.cpp
+
+START RESOURCE  ../data/testapplication.rss
+HEADER
+TARGETPATH      APP_RESOURCE_DIR
+LANG     SC
+END 
+
+START RESOURCE  ../data/testapplication_reg.rss
+DEPENDS testapplication.rsg
+TARGETPATH      /private/10003a3f/apps
+END 
+
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../../rubydebug
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib 
+LIBRARY         apparc.lib 
+LIBRARY         cone.lib 
+LIBRARY         eikcore.lib 
+LIBRARY         eikcoctl.lib 
+LIBRARY         avkon.lib
+LIBRARY         speechsynthesis.lib 
+LIBRARY         efsrv.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/group/testapplication.pkg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+;
+; Installation package creation file for speechsynthesis test application.
+;
+
+; Languages
+&EN
+
+; Package header
+#{"TTS API test"},(0x1001ABAB),1,0,0,TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia/TP/SP/SWD/UIG/MUI"
+
+; Dependency to indicate compatibility with S60 3.1
+[0x102752AE],0,0,0,{"S60ProductID"}
+
+"\epoc32\release\armv5\udeb\testapplication.exe"                - "c:\sys\bin\testapplication.exe"
+"\epoc32\data\Z\resource\apps\testapplication.rsc"              - "c:\resource\apps\testapplication.rsc"
+"\epoc32\data\Z\private\10003a3f\apps\testapplication_reg.rsc"  - "c:\private\10003a3f\import\apps\testapplication_reg.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/inc/testapp.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     This file contains declarations for constants of TestApp.
+*     The file can be included in C++ or resource file.
+*     Initial content was generated by Nokia Series 60 AppWizard.
+*
+*/
+
+
+#ifndef TESTAPP_HRH
+#define TESTAPP_HRH
+
+enum TTestAppCommandIds
+    {
+    ETestAppCmdAppConnect = 1,
+    ETestAppCmdAppDisconnect,
+    ETestAppCmdAppSayText,
+    ETestAppCmdAppSayTextToFile,
+    ETestAppCmdAppChangeVoice,
+    ETestAppCmdAppVolumeDown,
+    ETestAppCmdAppVolumeUp,
+    ETestAppCmdAppChangeRate,
+    ETestAppCmdAppPause,
+    ETestAppCmdAppPlay,
+    ETestAppCmdAppStop,
+    ETestAppCmdAppChangeAudioOutput
+    };
+
+#endif      // TESTAPP_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/inc/testappapp.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Declares main application class.
+*
+*/
+
+
+#ifndef TESTAPPAPP_H
+#define TESTAPPAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidTestApp = { 0x043ECF25 };
+
+// CLASS DECLARATION
+
+/**
+* CTestAppApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CTestAppApp : public CAknApplication
+    {
+    
+    public: // Functions from base classes
+    private:
+
+        /**
+        * From CApaApplication, creates CTestAppDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID (KUidTestApp).
+        * @return The value of KUidTestApp.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/inc/testappappui.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Declares UI class for application.
+*
+*/
+
+
+#ifndef TESTAPPAPPUI_H
+#define TESTAPPAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknappui.h>
+#include <f32file.h>
+
+// FORWARD DECLARATIONS
+class CTestAppContainer;
+class CTestAppEngine;
+
+// CLASS DECLARATION
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+* 
+*/
+class CTestAppAppUi : public CAknAppUi
+    {
+    public: // // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        ~CTestAppAppUi();
+        
+        void ChangeTextL( TInt aIndex,  TPtrC aText, TInt aNumber = -1 );
+        
+        void ShowNoteL( TPtrC aText, TInt aNumber = -1 );
+        
+    private:
+    
+        // From MEikMenuObserver
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+    private:
+    
+        /**
+        * From CEikAppUi, takes care of command handling.
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL(TInt aCommand);
+
+        /**
+        * From CEikAppUi, handles key events.
+        * @param aKeyEvent Event to handled.
+        * @param aType Type of the key event. 
+        * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed). 
+        */
+        virtual TKeyResponse HandleKeyEventL(
+            const TKeyEvent& aKeyEvent,TEventCode aType);       
+        
+    private: //Data
+        
+        CTestAppContainer*  iAppContainer; 
+        
+        CTestAppEngine*     iAppEngine;
+        
+        TBool               iServerConnected;
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/inc/testappcontainer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Declares container control for application.
+*
+*/
+
+
+#ifndef TESTAPPCONTAINER_H
+#define TESTAPPCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+   
+// FORWARD DECLARATIONS
+class CEikLabel; 
+
+// CLASS DECLARATION
+
+/**
+*  CTestAppContainer  container control class.
+*  
+*/
+class CTestAppContainer : public CCoeControl, MCoeControlObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * EPOC default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL( const TRect& aRect );
+
+        /**
+        * Destructor.
+        */
+        ~CTestAppContainer();
+        
+        void ChangeTextL( TInt aIndex, const TDesC& aText );
+
+    private: // Functions from base classes
+
+       /**
+        * From CoeControl,SizeChanged.
+        */
+        void SizeChanged();
+
+       /**
+        * From CoeControl,CountComponentControls.
+        */
+        TInt CountComponentControls() const;
+
+       /**
+        * From CCoeControl,ComponentControl.
+        */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+
+       /**
+        * From CCoeControl,Draw.
+        */
+        void Draw(const TRect& aRect) const;
+
+       /**
+        * 
+        */
+        void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
+        
+    private: //data
+        
+        CEikLabel* iLabelStatus;
+        CEikLabel* iLabelVoice;
+        CEikLabel* iLabelVolume;
+        CEikLabel* iLabelSpekingRate;
+        CEikLabel* iLabelDuration;
+        CEikLabel* iLabelGeneral;
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/inc/testappdocument.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Declares document for application.
+*
+*/
+
+
+#ifndef TESTAPPDOCUMENT_H
+#define TESTAPPDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CTestAppDocument application class.
+*/
+class CTestAppDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CTestAppDocument* NewL(CEikApplication& aApp);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTestAppDocument();
+
+    public: // New functions
+
+    protected:  // New functions
+
+    protected:  // Functions from base classes
+
+    private:
+
+        /**
+        * EPOC default constructor.
+        */
+        CTestAppDocument(CEikApplication& aApp);
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, create CTestAppAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/inc/testappengine.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef TESTAPPENGINE_H
+#define TESTAPPENGINE_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <speechsynthesis.h>
+
+#include "TestAppAppUi.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+* 
+*/
+class CTestAppEngine : public CActive
+    {
+    public: // Constructors and destructor
+
+        static CTestAppEngine* NewL( CTestAppAppUi& aAppUi );
+
+        virtual ~CTestAppEngine();
+
+        void ConnectL();
+        void DisconnectL();
+        
+        void InitTextL();
+        void InitTextToFileL();
+        
+        void PlayL();
+        void PauseL();
+        void StopL();
+        
+        TVoice ChangeVoiceL();
+        
+        TInt VolumeDownL();
+        TInt VolumeUpL();
+        
+        TInt RateUpL();
+        
+        void ChangeAudioOutputL();
+
+    protected: // From CActive
+    
+       /**
+        * CActive::RunL
+        */
+        void RunL();
+
+        /**
+        * CActive::DoCancel()
+        */
+        void DoCancel();
+                
+    private:    
+    
+        CTestAppEngine( CTestAppAppUi& aAppUi );
+
+        void ConstructL();
+                
+        void FetchSupportedLanguagesAndVoicesL();
+                
+    private: // Data
+
+        enum TState
+            {
+            EIdle,
+            EPriming,
+            ESpeaking
+            };
+
+        CTestAppAppUi&              iAppUi;
+        
+        RSpeechSynthesis            iServer;
+        TState                      iState; 
+        
+        TVoice                      iVoice;
+        
+        RArray<TVoice>              iVoices;
+        TInt                        iVoiceIndex;
+        
+        TInt                        iRate; 
+        TInt                        iVolume;
+        
+        TFileName                   iFileName;
+        
+        TInt                        iCurrentAudioOutput;
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/src/testappapp.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+
+#include    "TestAppApp.h"
+#include    "TestAppDocument.h"
+
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CTestAppApp;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+    
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTestAppApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CTestAppApp::AppDllUid() const
+    {
+    return KUidTestApp;
+    }
+   
+// ---------------------------------------------------------
+// CTestAppApp::CreateDocumentL()
+// Creates CTestAppDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CTestAppApp::CreateDocumentL()
+    {
+    return CTestAppDocument::NewL( *this );
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/src/testappappui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,348 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+// INCLUDE FILES
+#include "TestAppAppUi.h"
+#include "TestAppContainer.h"
+#include <TestApplication.rsg>
+#include "TestApp.hrh"
+#include <aknNoteDialog.h>
+#include <aknNoteWrappers.h>
+#include <eikmenup.h>
+#include <avkon.hrh>
+
+#include "testappengine.h"
+
+#include "rubydebug.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CTestAppAppUi::ConstructL()
+// 
+// ----------------------------------------------------------
+//
+void CTestAppAppUi::ConstructL() 
+    {
+    BaseConstructL();
+    
+    iAppContainer = new (ELeave) CTestAppContainer;
+    iAppContainer->SetMopParent(this);
+    iAppContainer->ConstructL( ClientRect() );
+    
+    iAppEngine = CTestAppEngine::NewL( *this );
+    
+    AddToStackL( iAppContainer );
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::~CTestAppAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CTestAppAppUi::~CTestAppAppUi()
+    {
+    if ( iAppContainer )
+        {
+        RemoveFromStack( iAppContainer );
+        delete iAppContainer;
+        }
+        
+    if ( iAppEngine )
+        {
+        TRAP_IGNORE( iAppEngine->DisconnectL() );
+        delete iAppEngine;
+        }
+    }
+
+// ------------------------------------------------------------------------------
+// CTestAppAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
+//  This function is called by the EIKON framework just before it displays
+//  a menu pane. Its default implementation is empty, and by overriding it,
+//  the application can set the state of menu items dynamically according
+//  to the state of application data.
+// ------------------------------------------------------------------------------
+//
+void CTestAppAppUi::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    if ( aResourceId==R_TEST_APPLICATION_MENU )
+        {         
+        if (iServerConnected)
+            {      
+            aMenuPane->SetItemDimmed( ETestAppCmdAppConnect, ETrue );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppDisconnect, EFalse );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppSayText, EFalse );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppSayTextToFile, EFalse );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppChangeVoice, EFalse );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppVolumeDown, EFalse );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppVolumeUp, EFalse );
+            }
+        else
+            { 
+            aMenuPane->SetItemDimmed( ETestAppCmdAppConnect, EFalse );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppDisconnect, ETrue );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppSayText, ETrue );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppSayTextToFile, ETrue );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppChangeVoice, ETrue );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppVolumeDown, ETrue );
+            aMenuPane->SetItemDimmed( ETestAppCmdAppVolumeUp, ETrue );
+            }
+        }
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::HandleKeyEventL(
+//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+// ----------------------------------------------------
+//
+TKeyResponse CTestAppAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,
+                                             TEventCode aType )
+    {
+    TKeyResponse response( EKeyWasNotConsumed );
+    
+    if ( aType == EEventKey && iServerConnected )
+        {
+        response = EKeyWasConsumed;
+        
+        switch ( aKeyEvent.iCode )
+            {
+            case EKeyOK: 
+            
+                HandleCommandL( ETestAppCmdAppSayText );
+                break;
+
+            case EKeyDownArrow: 
+            
+                HandleCommandL( ETestAppCmdAppChangeVoice );
+                break;
+
+            case EKeyUpArrow: 
+            
+                HandleCommandL( ETestAppCmdAppChangeRate );
+                break;
+
+            case EKeyLeftArrow: 
+            
+                HandleCommandL( ETestAppCmdAppVolumeDown );
+                break;
+
+            case EKeyRightArrow: 
+            
+                HandleCommandL( ETestAppCmdAppVolumeUp );
+                break;
+
+            case 50: // a
+                
+                HandleCommandL( ETestAppCmdAppChangeAudioOutput );
+                break;
+                
+            case 55: // p
+            
+                HandleCommandL( ETestAppCmdAppPause );
+                break;
+                
+            case 56: // t
+            
+                HandleCommandL( ETestAppCmdAppPlay );
+                break;
+                
+            case 57: // w
+            
+                HandleCommandL( ETestAppCmdAppStop );
+                break;
+                
+            default:
+            
+                response = EKeyWasNotConsumed;
+                
+            }
+        }
+    
+    return response;
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::HandleCommandL
+// 
+// ----------------------------------------------------
+//
+void CTestAppAppUi::HandleCommandL(TInt aCommand)
+    {
+    TInt value( -1 );
+    TVoice voice;
+    
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+        case EEikCmdExit:
+        case EKeyPhoneEnd:
+        case EKeyEscape: 
+            Exit();
+            break;
+            
+        case ETestAppCmdAppConnect:
+            
+            ShowNoteL( _L("Connect") );
+            
+            iAppEngine->ConnectL();
+            iServerConnected = ETrue;            
+            
+            ChangeTextL( 0, _L("Server: Connected") );
+            
+            break;
+
+        case ETestAppCmdAppDisconnect:
+            
+            ShowNoteL( _L("Disconnect") );
+            
+            iAppEngine->DisconnectL();
+            iServerConnected = EFalse; 
+            
+            ChangeTextL( 0, _L("Server: Disconnected") ); 
+            
+            break;
+            
+        case ETestAppCmdAppSayText:
+            
+            ShowNoteL( _L("Say text") );
+            
+            iAppEngine->InitTextL();
+            
+            break;
+            
+        case ETestAppCmdAppSayTextToFile:
+            
+            ShowNoteL( _L("Say text to file") );
+            
+            iAppEngine->InitTextToFileL();
+            
+            break;
+
+        case ETestAppCmdAppChangeVoice:
+            
+            voice = iAppEngine->ChangeVoiceL();
+            
+            ShowNoteL( voice.iVoiceName, voice.iLanguage );
+            ChangeTextL( 1, voice.iVoiceName, voice.iLanguage );
+            
+            break;
+            
+        case ETestAppCmdAppVolumeDown:
+            
+            value = iAppEngine->VolumeDownL();
+            
+            ShowNoteL( _L("Volume"), value );
+            ChangeTextL( 2, _L("Volume"), value );
+            
+            break;
+            
+        case ETestAppCmdAppVolumeUp:
+            
+            value = iAppEngine->VolumeUpL();
+            
+            ShowNoteL( _L("Volume"), value );
+            ChangeTextL( 2, _L("Volume"), value );
+            
+            break;
+            
+        case ETestAppCmdAppChangeRate:
+            
+            value = iAppEngine->RateUpL();
+            
+            ShowNoteL( _L("Speaking rate"), value );
+            ChangeTextL( 3, _L("Speking Rate"), value );
+            break;
+            
+        case ETestAppCmdAppChangeAudioOutput:
+            
+            iAppEngine->ChangeAudioOutputL();
+            
+            ShowNoteL( _L("Audio output changed") );
+            break;
+            
+        case ETestAppCmdAppPause:
+            
+            ShowNoteL( _L("Paused") );
+            iAppEngine->PauseL();
+            
+            break;
+            
+        case ETestAppCmdAppPlay:
+            
+            ShowNoteL( _L("Play") );
+            iAppEngine->PlayL();
+            
+            break;
+
+        case ETestAppCmdAppStop:
+            
+            ShowNoteL( _L("Stopped") );
+            
+            iAppEngine->StopL();
+            
+            break;
+            
+        default:
+            
+            break;      
+        }
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::ShowNoteL
+// 
+// ----------------------------------------------------
+//
+void CTestAppAppUi::ShowNoteL( TPtrC aText, TInt aNumber )
+    {
+    TBuf<64> buf( aText );
+    
+    if ( aNumber > -1 )
+        {
+        buf.Append( _L(": ") );
+        buf.AppendNum( aNumber );
+        }
+        
+    iEikonEnv->InfoMsg( buf );
+    
+    ChangeTextL( 5, buf.PtrZ() ); 
+    }
+    
+// ----------------------------------------------------
+// CTestAppAppUi::ChangeTextL
+// 
+// ----------------------------------------------------
+//
+void CTestAppAppUi::ChangeTextL( TInt aIndex, 
+                                 TPtrC aText, 
+                                 TInt aNumber )
+    {
+    TBuf<64> buf( aText );
+
+    if ( aNumber != -1 )
+        {
+        buf.Append( _L(": ") );
+        buf.AppendNum( aNumber );
+        }
+    
+    iAppContainer->ChangeTextL( aIndex, buf );
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/src/testappcontainer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,184 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+// INCLUDE FILES
+#include "TestAppContainer.h"
+
+#include <eiklabel.h>  // for example label control
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTestAppContainer::ConstructL(const TRect& aRect)
+// EPOC two phased constructor
+// ---------------------------------------------------------
+//
+void CTestAppContainer::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL();
+
+    iLabelStatus = new (ELeave) CEikLabel;
+    iLabelStatus->SetContainerWindowL( *this );
+    iLabelStatus->SetTextL( _L("Open menu to connect!") );
+
+    iLabelVoice = new (ELeave) CEikLabel;
+    iLabelVoice->SetContainerWindowL( *this );
+    iLabelVoice->SetTextL( _L(" ") );
+    
+    iLabelVolume = new (ELeave) CEikLabel;
+    iLabelVolume->SetContainerWindowL( *this );
+    iLabelVolume->SetTextL( _L(" ") );
+    
+    iLabelSpekingRate = new (ELeave) CEikLabel;
+    iLabelSpekingRate->SetContainerWindowL( *this );
+    iLabelSpekingRate->SetTextL( _L(" ") );
+    
+    iLabelDuration = new (ELeave) CEikLabel;
+    iLabelDuration->SetContainerWindowL( *this );
+    iLabelDuration->SetTextL( _L(" ") );
+
+    iLabelGeneral = new (ELeave) CEikLabel;
+    iLabelGeneral->SetContainerWindowL( *this );
+    iLabelGeneral->SetTextL( _L(" ") );
+    
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// Destructor
+CTestAppContainer::~CTestAppContainer()
+    {
+    delete iLabelStatus;
+    delete iLabelVoice;
+    delete iLabelVolume;
+    delete iLabelSpekingRate;
+    delete iLabelDuration;
+    delete iLabelGeneral;
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::ChangeTextL()
+// 
+// ---------------------------------------------------------
+//
+void CTestAppContainer::ChangeTextL( TInt aIndex, const TDesC& aText )
+    {
+    if ( aIndex == 0 )
+        {
+        iLabelStatus->SetTextL( aText );
+        }
+    else if (aIndex == 1 )
+        {
+        iLabelVoice->SetTextL( aText );
+        }
+    else if (aIndex == 2 )
+        {
+        iLabelVolume->SetTextL( aText );
+        }
+    else if (aIndex == 3 )
+        {
+        iLabelSpekingRate->SetTextL( aText );
+        }
+    else if (aIndex == 4 )
+        {
+        iLabelDuration->SetTextL( aText );
+        }        
+    else if (aIndex == 5 )
+        {
+        iLabelGeneral->SetTextL( aText );
+        }        
+        
+    SizeChanged();
+    DrawNow();
+    }
+    
+// ---------------------------------------------------------
+// CTestAppContainer::SizeChanged()
+// Called by framework when the view size is changed
+// ---------------------------------------------------------
+//
+void CTestAppContainer::SizeChanged()
+    {
+    iLabelStatus->SetExtent( TPoint(10,10), iLabelStatus->MinimumSize() );
+    iLabelVoice->SetExtent( TPoint(10,30), iLabelVoice->MinimumSize() );
+    iLabelVolume->SetExtent( TPoint(10,50), iLabelVolume->MinimumSize() );
+    iLabelSpekingRate->SetExtent( TPoint(10,70), iLabelSpekingRate->MinimumSize() );
+    iLabelDuration->SetExtent( TPoint(10,90), iLabelDuration->MinimumSize() );
+    iLabelGeneral->SetExtent( TPoint(10,130), iLabelGeneral->MinimumSize() );
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::CountComponentControls() const
+// ---------------------------------------------------------
+//
+TInt CTestAppContainer::CountComponentControls() const
+    {
+    return 6; // return nbr of controls inside this container
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::ComponentControl(TInt aIndex) const
+// ---------------------------------------------------------
+//
+CCoeControl* CTestAppContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+        case 0:
+            return iLabelStatus;
+        case 1:
+            return iLabelVoice;
+        case 2:
+            return iLabelVolume;
+        case 3:
+            return iLabelSpekingRate;
+        case 4:
+            return iLabelDuration;
+        case 5:
+            return iLabelGeneral;           
+        default:
+            return NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::Draw(const TRect& aRect) const
+// ---------------------------------------------------------
+//
+void CTestAppContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    
+    gc.SetPenStyle(CGraphicsContext::ENullPen);
+    gc.SetBrushColor(KRgbGray);
+    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+    gc.DrawRect(aRect);
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::HandleControlEventL(
+//     CCoeControl* aControl,TCoeEvent aEventType)
+// ---------------------------------------------------------
+//
+void CTestAppContainer::HandleControlEventL(
+    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    // Nothing
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/src/testappdocument.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+// INCLUDE FILES
+#include "TestAppDocument.h"
+#include "TestAppAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CTestAppDocument::CTestAppDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// destructor
+CTestAppDocument::~CTestAppDocument()
+    {
+    }
+
+// EPOC default constructor can leave.
+void CTestAppDocument::ConstructL()
+    {
+    }
+
+// Two-phased constructor.
+CTestAppDocument* CTestAppDocument::NewL(
+        CEikApplication& aApp)     // CTestAppApp reference
+    {
+    CTestAppDocument* self = new (ELeave) CTestAppDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CTestAppDocument::CreateAppUiL()
+// constructs CTestAppAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CTestAppDocument::CreateAppUiL()
+    {
+    return new (ELeave) CTestAppAppUi;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/testapplication/src/testappengine.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,397 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "testappengine.h"
+
+#include "rubydebug.h"
+
+
+_LIT( KText, "This is a text sample for TTS test. 1 2 3 45 End :) :-) :-(");
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------
+// CTestAppEngine::NewL()
+// 
+// ----------------------------------------------------------
+//
+CTestAppEngine* CTestAppEngine::NewL( CTestAppAppUi& aAppUi )
+    {
+    RUBY_DEBUG_BLOCK( "CTestAppEngine::NewL" );
+    
+    CTestAppEngine* self = new( ELeave ) CTestAppEngine( aAppUi );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;    
+    }
+    
+// ----------------------------------------------------------
+// CTestAppEngine::ConstructL()
+// 
+// ----------------------------------------------------------
+//
+void CTestAppEngine::ConstructL() 
+    {
+    // Add ourselves to active scheduler
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::CTestAppEngine()
+// 
+// ----------------------------------------------------
+//
+CTestAppEngine::CTestAppEngine( CTestAppAppUi& aAppUi ) :
+    CActive( EPriorityStandard ),
+    iAppUi( aAppUi ),
+    iVoiceIndex( -1 ),
+    iRate( -1 )
+    {
+    }
+    
+// ----------------------------------------------------
+// CTestAppEngine::~CTestAppEngine()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CTestAppEngine::~CTestAppEngine()
+    {
+    Cancel();
+    
+    iServer.Close();    
+    iVoices.Close();
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::RunL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CTestAppEngine::RunL" );
+    
+    switch ( iState )
+        {
+        case EPriming:
+        
+            if ( iStatus == KErrNone ) 
+                {
+                TRAP_IGNORE(
+                    TTimeIntervalMicroSeconds duration = iServer.DurationL();
+                    iAppUi.ChangeTextL( 4, _L("Duration (ms)"), 
+                                        duration.Int64() / 1000 );
+                     );
+                
+                PlayL();
+                }
+            else
+                {
+                User::Leave( iStatus.Int() );
+                }
+                
+            break;
+        
+        case ESpeaking:
+        
+            if ( iStatus == KErrNone )
+                {
+                iAppUi.ChangeTextL( 0, _L("Server: Connected") );
+                iAppUi.ChangeTextL( 4, _L("Duration (ms)"), 0 );
+                }
+            else if ( iStatus == KErrCancel )
+                {
+                iAppUi.ChangeTextL( 0, _L("Server: Paused") );
+                }
+            else if ( iStatus == KErrAbort )
+                {
+                iAppUi.ChangeTextL( 0, _L("Server: Stopped") );
+                }
+            else
+                {
+                User::Leave( iStatus.Int() );
+                }
+            
+            iState = EIdle;
+            
+            break;
+            
+        default:
+            
+            break;
+            
+        }
+    }
+    
+// ----------------------------------------------------
+// CTestAppEngine::DoCancel
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::DoCancel()
+    {
+    RUBY_DEBUG0( "CTestAppEngine::DoCancel" );
+    
+    TRAP_IGNORE( iServer.StopL() );
+    }
+
+// ----------------------------------------------------
+// Connect to the server
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::ConnectL()
+    {
+    User::LeaveIfError( iServer.Open() );
+
+    iVoice = iServer.VoiceL();
+    iVolume = iServer.VolumeL();
+    iRate = iServer.SpeakingRateL();
+    
+    iAppUi.ChangeTextL( 1, iVoice.iVoiceName, iVoice.iLanguage );
+    iAppUi.ChangeTextL( 2, _L("Volume"), iVolume );
+    iAppUi.ChangeTextL( 3, _L("Speking Rate"), iRate );
+    }
+
+// ----------------------------------------------------
+// Disconnect from server    
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::DisconnectL()
+    {
+    Cancel();
+    
+    iServer.Close();
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::InitTextL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::InitTextL()
+    {
+    iAppUi.ChangeTextL( 0, _L("Server: Initializing") ); 
+    
+    iServer.SetVolumeL( iVolume );
+    
+    if ( iRate > 0 && iRate <= 100 )
+        {
+        iServer.SetSpeakingRateL( iRate );
+        }
+        
+    Cancel();
+    SetActive();
+    iState = EPriming;
+    
+    iServer.InitialiseSynthesis( KText, iStatus );
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::InitToTextFileL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::InitTextToFileL()
+    {
+    iFileName = _L("C:\\test.raw");
+    
+    iAppUi.ChangeTextL( 0, _L("Server: Initializing") ); 
+        
+    iServer.SetVolumeL( iVolume );
+    iServer.SetSpeakingRateL( iRate );
+    
+    Cancel();
+    SetActive();
+    iState = EPriming;
+    
+    iServer.InitialiseSynthesis( KText, iFileName, iStatus );
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::PauseL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::PauseL()
+    {
+    iAppUi.ChangeTextL( 0, _L("Server: Paused") );
+    iServer.PauseL();
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::PlayL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::PlayL()
+    {
+    iAppUi.ChangeTextL( 0, _L("Server: Speaking") );
+    
+    Cancel();
+    SetActive();
+    iState = ESpeaking;
+        
+    iServer.Synthesise( iStatus );
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::StopL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::StopL()
+    {
+    iAppUi.ChangeTextL( 0, _L("Server: Stopped") );
+    iServer.StopL();
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::ChangeVoiceL
+// 
+// ----------------------------------------------------
+//
+TVoice CTestAppEngine::ChangeVoiceL()
+    {
+    if ( iVoiceIndex < 0 )
+        {
+        FetchSupportedLanguagesAndVoicesL();
+        }
+    
+    iVoiceIndex++;
+    
+    if ( iVoiceIndex >= iVoices.Count() )
+        {
+        iVoiceIndex = 0;
+        }
+    
+    iVoice = iVoices[iVoiceIndex];
+    
+    iServer.SetVoiceL( iVoice );
+    
+    return iVoice;
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::VolumeDownL
+// 
+// ----------------------------------------------------
+//
+TInt CTestAppEngine::VolumeDownL()
+    {
+    TInt volumeStep = iServer.MaxVolumeL() / 10;
+    
+    iServer.SetVolumeL( iVolume - volumeStep );
+    iVolume = iServer.VolumeL();
+
+    return iVolume;
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::VolumeUpL  
+// 
+// ----------------------------------------------------
+//
+TInt CTestAppEngine::VolumeUpL()
+    {
+    TInt volumeStep = iServer.MaxVolumeL() / 10;
+    
+    iServer.SetVolumeL( iVolume + volumeStep );
+    iVolume = iServer.VolumeL();
+
+    return iVolume;
+    }
+
+// ----------------------------------------------------
+// CTestAppEngine::RateUpL  
+// 
+// ----------------------------------------------------
+//
+TInt CTestAppEngine::RateUpL()
+    {
+    TInt newRate = iRate + 10;
+    
+    if ( newRate > iServer.MaxSpeakingRateL() )
+        {
+        newRate = 10;
+        }
+    
+    iRate = newRate;
+    
+    return iRate;
+    }
+    
+// ----------------------------------------------------
+// CTestAppEngine::ChangeAudioOutputL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::ChangeAudioOutputL()    
+    {
+    iCurrentAudioOutput++;
+    
+    if ( iCurrentAudioOutput > RSpeechSynthesis::ETtsOutputPublic )
+        {
+        iCurrentAudioOutput = 0;
+        }
+    
+    iServer.SetAudioOutputL( (RSpeechSynthesis::TTtsAudioOutput) iCurrentAudioOutput );
+    }
+    
+// ----------------------------------------------------
+// CTestAppEngine::FetchSupportedLanguagesAndVoicesL
+// 
+// ----------------------------------------------------
+//
+void CTestAppEngine::FetchSupportedLanguagesAndVoicesL()
+    {
+    RArray<TLanguage> languages;
+    RArray<TVoice> voices;
+
+    iServer.GetLanguagesL( languages );
+    
+    for ( TInt i( 0 ); i < languages.Count(); i++ )
+        {
+        if ( languages[i] > 0 )
+            {
+            RUBY_DEBUG1( "%d", languages[i] );
+
+            voices.Reset();
+            iServer.GetVoicesL( voices, languages[i] );
+    
+            for ( TInt j( 0 ); j < voices.Count(); j++ )
+                {            
+                RUBY_DEBUG1( "%S", &voices[j].iVoiceName );
+
+                iVoices.AppendL( voices[j] );
+                }        
+            }
+        }
+        
+    voices.Close();
+    languages.Close();
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/data/texttospeech.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#define STR_TextToSpeechApplication_1 "TextToSpeech"
+#define STR_TextToSpeechApplication_2 "Text2Speech"
+
+#define STR_TextToSpeechSettingItemListView_4 "Change"
+#define STR_TextToSpeechSettingItemListView_1 "Settings"
+#define STR_TextToSpeechSettingItemListView_2 "TextToSpeech"
+#define STR_TextToSpeechSettingItemListView_5 "Text sample"
+#define STR_TextToSpeechSettingItemListView_6 "Input text"
+#define STR_TextToSpeechSettingItemListView_7 "Language id"
+#define STR_TextToSpeechSettingItemListView_8 "Voice"
+#define STR_TextToSpeechSettingItemListView_9 "min"
+#define STR_TextToSpeechSettingItemListView_10 "max"
+#define STR_TextToSpeechSettingItemListView_11 "Speaking Rate"
+#define STR_TextToSpeechSettingItemListView_24 "(None)"
+#define STR_TextToSpeechSettingItemListView_17 "(None)"
+#define STR_TextToSpeechSettingItemListView_45 "Synthesise"
+#define STR_TextToSpeechSettingItemListView_46 "Exit"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/data/texttospeech.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,254 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+NAME TTSD
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <eikon.rh>
+#include <appinfo.rh>
+#include <avkon.loc>
+#include <data_caging_paths_strings.hrh>
+
+#include "texttospeech.hrh"
+#include "texttospeech.loc"
+
+
+RESOURCE RSS_SIGNATURE
+    {
+    }
+    
+RESOURCE TBUF r_default_document_name
+    {
+    buf = "TextToSpeech";
+    }
+    
+RESOURCE EIK_APP_INFO
+    {
+    }
+
+RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
+    {
+    short_caption = STR_TextToSpeechApplication_2;
+    caption_and_icon = CAPTION_AND_ICON_INFO
+        {
+        caption = STR_TextToSpeechApplication_1;
+        number_of_icons = 1;
+        icon_file = APP_BITMAP_DIR"\\texttospeech_aif.mif";
+        };
+    }
+
+RESOURCE AVKON_VIEW r_text_to_speech_setting_item_list_text_to_speech_setting_item_list_view
+    {
+    cba = r_text_to_speech_softkeys;
+    menubar = r_text_to_speech_setting_item_list_options_menu;
+    }
+
+RESOURCE CBA r_text_to_speech_softkeys
+    {
+		buttons =
+				{
+        CBA_BUTTON {id = EAknSoftkeyOptions; txt = text_softkey_option; },
+        CBA_BUTTON {id = EAknSoftkeyExit;  txt = text_softkey_exit; },
+        CBA_BUTTON {id = EAknSoftkeyChange; txt = qtn_msk_change; }
+        };
+     }
+    
+RESOURCE MENU_BAR r_text_to_speech_setting_item_list_options_menu
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_text_to_speech_setting_item_list_menu_pane1_menu_pane;
+            }
+        };
+    }
+    
+RESOURCE MENU_PANE r_text_to_speech_setting_item_list_menu_pane1_menu_pane
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = ETextToSpeechSettingItemListViewMenuItem1Command;
+            txt = STR_TextToSpeechSettingItemListView_4;
+            },
+        MENU_ITEM
+            {
+            command = ETextToSpeechSettingItemListViewSynthesiseMenuItemCommand;
+            txt = STR_TextToSpeechSettingItemListView_45;
+            },
+        MENU_ITEM
+            {
+            command = ETextToSpeechSettingItemListViewExitMenuItemCommand;
+            txt = STR_TextToSpeechSettingItemListView_46;
+            }
+        };
+    }
+    
+RESOURCE STATUS_PANE_APP_MODEL r_text_to_speech_setting_item_list_status_pane
+    {
+    panes =
+        {
+        SPANE_PANE
+            {
+            id = EEikStatusPaneUidTitle;
+            type = EAknCtTitlePane;
+            resource = r_text_to_speech_setting_item_list_title_resource;
+            }
+        };
+    }
+    
+RESOURCE TITLE_PANE r_text_to_speech_setting_item_list_title_resource
+    {
+    txt = STR_TextToSpeechSettingItemListView_2;
+    }
+    
+RESOURCE AVKON_SETTING_ITEM_LIST r_text_to_speech_setting_item_list_text_to_speech_setting_item_list
+    {
+    items =
+        {
+        AVKON_SETTING_ITEM
+            {
+            name = STR_TextToSpeechSettingItemListView_6;
+            identifier = ETextToSpeechSettingItemListViewEdit1;
+            setting_page_resource = r_text_to_speech_setting_item_list_edit1_setting_page_resource;
+            },
+        AVKON_SETTING_ITEM
+            {
+            name = STR_TextToSpeechSettingItemListView_7;
+            identifier = ETextToSpeechSettingItemListViewEnumeratedTextPopup1;
+            setting_page_resource = r_text_to_speech_setting_item_list_enumerated_text_popup1_setting_page_resource;
+            associated_resource = r_text_to_speech_setting_item_list_enumerated_text_popup1;
+            },
+        AVKON_SETTING_ITEM
+            {
+            name = STR_TextToSpeechSettingItemListView_8;
+            identifier = ETextToSpeechSettingItemListViewEnumeratedTextPopup2;
+            setting_page_resource = r_text_to_speech_setting_item_list_enumerated_text_popup2_setting_page_resource;
+            associated_resource = r_text_to_speech_setting_item_list_enumerated_text_popup2;
+            },
+        AVKON_SETTING_ITEM
+            {
+            name = STR_TextToSpeechSettingItemListView_11;
+            identifier = ETextToSpeechSettingItemListViewSlider1;
+            setting_page_resource = r_text_to_speech_setting_item_list_slider1_setting_page_resource;
+            }
+        };
+    }
+    
+RESOURCE AVKON_SETTING_PAGE r_text_to_speech_setting_item_list_edit1_setting_page_resource
+    {
+    number = -16380;
+    label = STR_TextToSpeechSettingItemListView_6;
+    type = EEikCtEdwin;
+    editor_resource_id = r_text_to_speech_setting_item_list_edit1_editor_resource_id;
+    }
+    
+RESOURCE EDWIN r_text_to_speech_setting_item_list_edit1_editor_resource_id
+    {
+//    default_case = EAknEditorTextCase;
+//    allowed_case_modes = EAknEditorAllCaseModes;
+//    numeric_keymap = EAknEditorStandardNumberModeKeymap;
+//    default_input_mode = EAknEditorTextInputMode;
+//    allowed_input_modes = EAknEditorAllInputModes;
+    special_character_table = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
+//    avkon_flags = EAknEditorFlagDefault;
+    maxlength = 255; 
+    }
+    
+RESOURCE AVKON_SETTING_PAGE r_text_to_speech_setting_item_list_enumerated_text_popup1_setting_page_resource
+    {
+    number = -16380;
+    label = STR_TextToSpeechSettingItemListView_7;
+    type = EAknCtPopupSettingList;
+    editor_resource_id = r_text_to_speech_setting_item_list_enumerated_text_popup1_editor_resource_id;
+    }
+    
+RESOURCE POPUP_SETTING_LIST r_text_to_speech_setting_item_list_enumerated_text_popup1_editor_resource_id
+    {
+    }
+    
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_text_to_speech_setting_item_list_enumerated_text_popup1
+    {
+    setting_texts_resource = r_text_to_speech_setting_item_list_enumerated_text_popup1_setting_texts_resource;
+    }
+    
+RESOURCE ARRAY r_text_to_speech_setting_item_list_enumerated_text_popup1_setting_texts_resource
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            text = STR_TextToSpeechSettingItemListView_17;
+            }
+        };
+    }
+
+RESOURCE AVKON_SETTING_PAGE r_text_to_speech_setting_item_list_enumerated_text_popup2_setting_page_resource
+    {
+    number = -16380;
+    label = STR_TextToSpeechSettingItemListView_8;
+    type = EAknCtPopupSettingList;
+    editor_resource_id = r_text_to_speech_setting_item_list_enumerated_text_popup2_editor_resource_id;
+    }
+    
+RESOURCE POPUP_SETTING_LIST r_text_to_speech_setting_item_list_enumerated_text_popup2_editor_resource_id
+    {
+    }
+    
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_text_to_speech_setting_item_list_enumerated_text_popup2
+    {
+    setting_texts_resource = r_text_to_speech_setting_item_list_enumerated_text_popup2_setting_texts_resource;
+    }
+    
+RESOURCE ARRAY r_text_to_speech_setting_item_list_enumerated_text_popup2_setting_texts_resource
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            text = STR_TextToSpeechSettingItemListView_24;
+            }
+        };
+     }
+     
+RESOURCE AVKON_SETTING_PAGE r_text_to_speech_setting_item_list_slider1_setting_page_resource
+    {
+    number = -16380;
+    label = STR_TextToSpeechSettingItemListView_11;
+    type = EAknCtSlider;
+    editor_resource_id = r_text_to_speech_setting_item_list_slider1_editor_resource_id;
+    }
+    
+RESOURCE SLIDER r_text_to_speech_setting_item_list_slider1_editor_resource_id
+    {
+    layout = EAknSettingsItemSliderLayout;
+    minvalue  = 10;
+    maxvalue  = 100;
+    step      = 10;
+    valuetype = EAknSliderValueBareFigure; 
+    minlabel  = STR_TextToSpeechSettingItemListView_9;
+    maxlabel  = STR_TextToSpeechSettingItemListView_10;
+    }
+    
+RESOURCE TBUF r_text_to_speech_setting_item_list_edit1
+    {
+    buf = STR_TextToSpeechSettingItemListView_5;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/data/texttospeech_reg.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <appinfo.rh>
+#include <texttospeech.rsg>
+
+#include "texttospeechuid.hrh"
+
+UID2 KUidAppRegistrationResourceFile
+UID3 KUidTextToSpeechApplication
+
+RESOURCE APP_REGISTRATION_INFO
+  {
+  app_file="texttospeech";
+  localisable_resource_file =  "\\resource\\apps\\texttospeech";
+  localisable_resource_id = R_LOCALISABLE_APP_INFO;
+  }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/gfx/qgn_menu_texttospeech.svg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 87.999">
+<g>
+<g>
+<g>
+<g>
+<rect fill="none" width="88" height="87.999"/>
+</g>
+</g>
+<g>
+<linearGradient id="XMLID_7_" gradientUnits="userSpaceOnUse" x1="12.3042" y1="18.3799" x2="63.4113" y2="79.287">
+<stop offset="0" style="stop-color:#B3DDFF"/>
+<stop offset="0.8146" style="stop-color:#084296"/>
+<stop offset="1" style="stop-color:#084296"/>
+</linearGradient>
+<path fill="url(#XMLID_7_)" d="M32.135,7.415L14.363,17.432v23.167c0,0,8.926,15.351,10.468,18.001       c-2.386,1.704-15.44,11.03-15.44,11.03l21.613,12.652c0,0,12.907-9.85,14.71-11.226c1.979,1.109,16.231,9.101,16.231,9.101       l16.664-15.132c0,0-14.066-6.929-16.888-8.318c1.467-3.01,10.531-21.604,10.531-21.604l-22.298-9.59       c0,0-1.486,3.173-2.093,4.467c-2.046-0.88-6.573-2.826-6.573-2.826s-3.713,2.463-5.696,3.778       c-0.327-0.744-0.542-1.233-0.657-1.495c0.007-0.824,0.213-23.72,0.213-23.72L32.135,7.415z"/>
+<linearGradient id="XMLID_8_" gradientUnits="userSpaceOnUse" x1="40.8276" y1="52.1914" x2="16.1997" y2="21.1353">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_8_)" points="59.051,57.621 69.536,36.111 50.944,28.115 48.852,32.581 41.493,29.418 34.719,33.911        32.932,29.849 33.117,9.157 16.363,18.601 16.363,40.06 27.476,59.169 13.064,69.463 30.856,79.879 45.546,68.669        61.667,77.708 75.089,65.521 "/>
+<linearGradient id="XMLID_9_" gradientUnits="userSpaceOnUse" x1="60.585" y1="31.876" x2="53.8582" y2="45.1125">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_9_)" points="41.26,48.783 50.944,28.115 69.536,36.111 59.051,57.621 "/>
+<polygon fill="#0046B7" points="16.363,40.06 27.476,59.169 41.26,48.783 32.932,29.849 "/>
+<polygon fill="#3366CC" points="16.363,40.06 16.363,18.601 33.117,9.157 32.932,29.849 "/>
+<polygon fill="#CFECFF" points="26.696,39.23 41.493,29.418 59.523,37.168 45.546,47.954 "/>
+<path fill="#5AA7E0" d="M41.954,55.286"/>
+<polygon fill="#3366CC" points="26.696,39.23 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#5AA7E0" points="13.064,69.463 27.476,59.169 45.546,68.669 30.856,79.879 "/>
+<linearGradient id="XMLID_10_" gradientUnits="userSpaceOnUse" x1="29.2085" y1="63.6836" x2="48.7102" y2="56.1976">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.0056" style="stop-color:#5AA7E0"/>
+<stop offset="0.85" style="stop-color:#3366CC"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_10_)" points="43.423,46.971 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#0046B7" points="45.546,47.954 45.546,68.669 59.051,57.621 59.523,37.168 "/>
+<linearGradient id="XMLID_11_" gradientUnits="userSpaceOnUse" x1="45.3936" y1="59.5186" x2="59.0508" y2="59.5186">
+<stop offset="0" style="stop-color:#0046B7"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_11_)" points="45.394,50.368 45.546,68.669 59.051,57.621 "/>
+<linearGradient id="XMLID_12_" gradientUnits="userSpaceOnUse" x1="60.8945" y1="68.6807" x2="57.2953" y2="58.792">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.4101" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_12_)" points="61.667,77.708 45.546,68.669 59.051,57.621 75.089,65.521 "/>
+</g>
+</g>
+</g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+// gnumakefile icons_scalable_dc.mk
+texttospeech.mmp
+
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE texttospeech_aif.mif
+OPTION SOURCEDIR ../gfx
+OPTION SOURCES -c32 qgn_menu_texttospeech
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/group/icons_scalable_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  This is file for creating .mif file (scalable icon)
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=$(EPOCROOT)epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\texttospeech_aif.mif
+
+ICONDIR=..\gfx
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE :	
+	mifconv $(ICONTARGETFILENAME) \
+		/c32 $(ICONDIR)\qgn_menu_texttospeech.svg
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/group/texttospeech.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+#include "../inc/texttospeechuid.hrh"
+
+TARGET      texttospeech.exe
+TARGETTYPE  exe
+UID         0x100039CE KUidTextToSpeechApplication
+
+VENDORID    0
+CAPABILITY  CAP_APPLICATION
+
+
+SOURCEPATH  ../src
+
+SOURCE      texttospeechapplication.cpp
+SOURCE      texttospeechappui.cpp
+SOURCE      texttospeechdocument.cpp 
+SOURCE      texttospeechengine.cpp
+SOURCE      texttospeechsettingitemlist.cpp
+SOURCE      texttospeechsettingitemlistview.cpp
+SOURCE      texttospeechsettingitemlistsettings.cpp 
+
+
+SOURCEPATH ../data
+
+START RESOURCE texttospeech.rss
+TARGETPATH resource/apps
+HEADER
+LANG SC
+END
+
+START RESOURCE texttospeech_reg.rss
+DEPENDS texttospeech.rsg
+TARGETPATH private/10003a3f/apps
+END
+
+
+USERINCLUDE ../inc 
+USERINCLUDE ../data
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY     euser.lib 
+LIBRARY     apparc.lib 
+LIBRARY     cone.lib 
+LIBRARY     eikcore.lib 
+LIBRARY     avkon.lib 
+LIBRARY     commonengine.lib
+LIBRARY     eikcoctl.lib 
+LIBRARY     speechsynthesis.lib 
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeech.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+enum TTextToSpeechViewUids
+    {
+    ETextToSpeechSettingItemListViewId = 1
+    };
+
+enum TTextToSpeechSettingItemListViewCommands
+    {
+    ETextToSpeechSettingItemListViewMenuItem1Command = 0x6000,
+    ETextToSpeechSettingItemListViewSynthesiseMenuItemCommand,
+    ETextToSpeechSettingItemListViewExitMenuItemCommand
+    };
+    
+enum TTextToSpeechSettingItemListViewItems
+    {
+    ETextToSpeechSettingItemListViewEdit1 = 1,
+    ETextToSpeechSettingItemListViewEnumeratedTextPopup1,
+    ETextToSpeechSettingItemListViewEnumeratedTextPopup2,
+    ETextToSpeechSettingItemListViewSlider1
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechapplication.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHAPPLICATION_H
+#define TEXTTOSPEECHAPPLICATION_H
+
+#include <aknapp.h>
+
+/**
+ * A CAknApplication-derived class is required by the S60 application 
+ * framework. It is subclassed to create the application's document 
+ * object.
+ */
+class CTextToSpeechApplication : public CAknApplication
+    {
+    
+    private:
+    
+        TUid AppDllUid() const;
+        
+        CApaDocument* CreateDocumentL();
+    
+    };
+            
+#endif // TEXTTOSPEECHAPPLICATION_H        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechappui.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHAPPUI_H
+#define TEXTTOSPEECHAPPUI_H
+
+#include <aknviewappui.h>
+
+class CTextToSpeechSettingItemListView;
+class CTextToSpeechEngine;
+
+/**
+ * The AppUi class handles application-wide aspects of the user interface, including
+ * view management and the default menu, control pane, and status pane.
+ */
+class CTextToSpeechAppUi : public CAknViewAppUi
+    {
+
+    public: 
+        
+        // constructor and destructor
+        CTextToSpeechAppUi();
+        virtual ~CTextToSpeechAppUi();
+        
+        // from CCoeAppUi
+        virtual TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, 
+                                              TEventCode aType );
+
+        // from CEikAppUi
+        void HandleCommandL( TInt aCommand );
+        void HandleResourceChangeL( TInt aType );
+
+        // from CAknAppUi
+        void HandleViewDeactivation( const TVwsViewId& aViewIdToBeDeactivated, 
+                                     const TVwsViewId &aNewlyActivatedViewId );
+        
+        // Return pointer to application engine
+        CTextToSpeechEngine* AppEngine();
+
+    private:
+        
+        void ConstructL();
+        
+        void InitializeContainersL();
+    
+    private: 
+    
+        CTextToSpeechSettingItemListView*   iTextToSpeechSettingItemListView;
+        
+        CTextToSpeechEngine*                iTextToSpeechEngine; 
+    
+    };
+
+#endif // TEXTTOSPEECHAPPUI_H            
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechdocument.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHDOCUMENT_H
+#define TEXTTOSPEECHDOCUMENT_H
+
+#include <akndoc.h>
+        
+class CEikAppUi;
+
+/**
+* A CAknDocument-derived class is required by the S60 application 
+* framework. It is responsible for creating the AppUi object. 
+*/
+class CTextToSpeechDocument : public CAknDocument
+    {
+
+    public: 
+    
+        // constructor
+        static CTextToSpeechDocument* NewL( CEikApplication& aApp );
+        
+        // destructor.
+        virtual ~CTextToSpeechDocument();
+        
+    private: 
+    
+        // constructors
+        CTextToSpeechDocument( CEikApplication& aApp );
+        void ConstructL();
+    
+    public: 
+    
+        // from base class CEikDocument
+        CEikAppUi* CreateAppUiL();
+        
+    };
+
+#endif // TEXTTOSPEECHDOCUMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechengine.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHENGINE_H
+#define TEXTTOSPEECHENGINE_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <speechsynthesis.h>
+
+/**
+* Application engine 
+*/
+class CTextToSpeechEngine : public CActive
+    {
+    public: // Constructors and destructor
+
+        static CTextToSpeechEngine* NewL();
+
+        virtual ~CTextToSpeechEngine();
+
+        void InitAndPlayText( const TDesC& aText );
+        void InitAndPlayTextToFile( const TDesC& aText,
+                                     const TFileName& aFileName );
+        
+        void Play( );
+        void PauseL();
+        void StopL();
+        
+        TInt VolumeL();
+        void SetVolumeL( TInt aVolume );
+        TInt MaxVolumeL();
+        
+        TInt SpeakingRateL();
+        void SetSpeakingRateL( TInt aRate );
+        TInt MaxSpeakingRateL();
+        
+        TVoice VoiceL();
+        void SetVoiceL( const TVoice& aVoice ); 
+        void GetLanguagesL( RArray<TLanguage>& aLanguages );
+        void GetVoicesL( RArray<TVoice>& aVoices, TLanguage aLanguage );
+        
+    protected: // From CActive
+    
+       /**
+        * CActive::RunL
+        */
+        void RunL();
+
+        /**
+        * CActive::DoCancel()
+        */
+        void DoCancel();
+                
+    private:    
+    
+        CTextToSpeechEngine();
+
+        void ConstructL();
+
+    private: // Data
+
+        enum TState
+            {
+            EIdle,
+            EPriming,
+            ESpeaking
+            };
+
+        RSpeechSynthesis            iServer;
+        
+        TState                      iState; 
+
+        TFileName                   iFileName;        
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechsettingitemlist.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHSETTINGITEMLIST_H
+#define TEXTTOSPEECHSETTINGITEMLIST_H
+
+#include <aknsettingitemlist.h>
+
+class MEikCommandObserver;
+class CTextToSpeechSettingItemListSettings;
+
+/**
+ * CTextToSpeechSettingItemList 
+ */
+class CTextToSpeechSettingItemList : public CAknSettingItemList
+    {
+
+    public: 
+    
+        CTextToSpeechSettingItemList( CTextToSpeechSettingItemListSettings& settings, 
+                                      MEikCommandObserver* aCommandObserver );
+                                      
+        virtual ~CTextToSpeechSettingItemList();
+
+        // overrides of CAknSettingItemList
+        CAknSettingItem* CreateSettingItemL( TInt id );
+        void EditItemL ( TInt aIndex, TBool aCalledFromMenu );
+        virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+                                             TEventCode aType );
+
+        // utility function for menu
+        void ChangeSelectedItemL();
+
+        void LoadSettingValuesL();
+        
+    private:
+    
+        // override of CAknSettingItemList
+        void SizeChanged();
+        
+        void LoadLanguagesL();
+        void LoadVoicesL( TBool aResetSelection );
+        
+        void HandleSliderVisibility();
+
+    private:
+
+        // current settings values
+        CTextToSpeechSettingItemListSettings&   iSettings;
+        
+        CTextToSpeechEngine*                    iEngine;
+        MEikCommandObserver*                    iCommandObserver;
+    
+    };
+    
+#endif // TEXTTOSPEECHSETTINGITEMLIST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechsettingitemlistsettings.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHSETTINGITEMLISTSETTINGS_H
+#define TEXTTOSPEECHSETTINGITEMLISTSETTINGS_H
+
+
+#include <speechsynthesis.h>
+
+const int KEdit1MaxLength = 255;
+
+/**
+ * Setting item list settings 
+ */
+class CTextToSpeechSettingItemListSettings : CBase
+    {
+
+    public:
+    
+        // construct and destroy
+        static CTextToSpeechSettingItemListSettings* NewL();
+        
+        virtual ~CTextToSpeechSettingItemListSettings();
+        
+        TDes& Edit1();
+        void SetEdit1(const TDesC& aValue);
+        
+        TInt& EnumeratedTextPopup1();
+        void SetEnumeratedTextPopup1(const TInt& aValue);
+        
+        TInt& EnumeratedTextPopup2();
+        void SetEnumeratedTextPopup2(const TInt& aValue);
+        
+        TInt& Slider1();
+        void SetSlider1(const TInt& aValue);
+
+    private:
+    
+        // constructors
+        void ConstructL();
+        CTextToSpeechSettingItemListSettings();
+    
+    public:
+    
+        TInt                    iVolume;
+        TInt                    iMaxVolume;
+    
+        TVoice                  iVoice;
+        
+        RArray<TLanguage>       iLanguages;
+        RArray<TVoice>          iVoices;
+        
+        
+    protected:
+    
+        TBuf<KEdit1MaxLength>   iEdit1;                 // Text to be synthesised
+        TInt                    iEnumeratedTextPopup1;  // Language       
+        TInt                    iEnumeratedTextPopup2;  // Voice
+        TInt                    iSlider1;               // Speaking rate
+            
+    };
+    
+#endif // TEXTTOSPEECHSETTINGITEMLISTSETTINGS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechsettingitemlistview.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef TEXTTOSPEECHSETTINGITEMLISTVIEW_H
+#define TEXTTOSPEECHSETTINGITEMLISTVIEW_H
+
+#include <aknview.h>
+#include <aknnavidecoratorobserver.h> 
+
+class CAknNavigationDecorator;
+class CTextToSpeechSettingItemList;
+class CTextToSpeechEngine;
+class CTextToSpeechSettingItemListSettings;
+
+/**
+ * Avkon view class for TextToSpeechSettingItemListView. It is register with the view server
+ * by the AppUi. It owns the container control.
+ */
+class CTextToSpeechSettingItemListView : public CAknView,
+                                         public MAknNaviDecoratorObserver
+    {
+
+    public:
+    
+        // constructors and destructor
+        CTextToSpeechSettingItemListView();
+        static CTextToSpeechSettingItemListView* NewL();
+        static CTextToSpeechSettingItemListView* NewLC();        
+        void ConstructL();
+        virtual ~CTextToSpeechSettingItemListView();
+
+        // from base class CAknView
+        TUid Id() const;
+        void HandleCommandL( TInt aCommand );
+        
+        // from base class MAknNaviDecoratorObserver
+        void HandleNaviDecoratorEventL( TInt aEventID );
+        
+    protected:
+    
+        // from base class CAknView
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage);
+        void DoDeactivate();
+        void HandleStatusPaneSizeChange();
+
+    private:
+    
+        void SetupStatusPaneL();
+        void CleanupStatusPane();
+    
+    
+    private: 
+    
+        CTextToSpeechSettingItemList*           iTextToSpeechSettingItemList;
+        CTextToSpeechEngine*                    iEngine;
+        CTextToSpeechSettingItemListSettings*   iSettings;
+        
+        CAknNavigationDecorator*                iVolumeControl;
+        
+    };
+
+#endif // TEXTTOSPEECHSETTINGITEMLISTVIEW_H            
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/inc/texttospeechuid.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// @todo Change?
+#define KUidTextToSpeechApplication 0x043ECF26
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/sis/texttospeech.pkg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+;
+; Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+; @todo Change UID?
+#{"TextToSpeech"}, (0x1001ABAB), 1, 0, 0, TYPE=SA 
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+; Dependency to indicate compatibility with S60 3.1
+[0x102752AE], 0, 0, 0, {"S60ProductID"}
+
+;Files to install
+"\epoc32\release\armv5\udeb\texttospeech.exe"               - "!:\sys\bin\texttospeech.exe"
+"\epoc32\data\z\resource\apps\texttospeech.rsc"             - "!:\resource\apps\texttospeech.rsc"
+"\epoc32\data\z\resource\apps\texttospeech_aif.mif"         - "!:\resource\apps\texttospeech_aif.mif"
+"\epoc32\data\z\private\10003a3f\apps\texttospeech_reg.rsc" - "!:\private\10003a3f\import\apps\texttospeech_reg.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechapplication.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <eikstart.h>
+
+#include "texttospeechapplication.h"
+#include "texttospeechdocument.h"
+#include "texttospeechuid.hrh"
+
+static const TUid KAppUid = { KUidTextToSpeechApplication };
+
+/**
+ *  Called by the application framework to construct the application object
+ *  @return The application (CTextToSpeechApplication)
+ */    
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CTextToSpeechApplication;
+    }
+
+/**
+ * This standard export is the entry point for all Series 60 applications
+ * @return error code
+ */    
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+/**
+ * Returns the application's UID (override from CApaApplication::AppDllUid())
+ * @return UID for this application (KUidTextToSpeechApplication)
+ */
+TUid CTextToSpeechApplication::AppDllUid() const
+    {
+    return KAppUid;
+    }
+
+/**
+ * Creates the application's document (override from CApaApplication::CreateDocumentL())
+ * @return Pointer to the created document object (CTextToSpeechDocument)
+ */
+CApaDocument* CTextToSpeechApplication::CreateDocumentL()
+    {
+    return CTextToSpeechDocument::NewL( *this );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechappui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "texttospeechappui.h"
+#include "texttospeechengine.h"
+#include "texttospeechsettingitemlistview.h"
+
+
+/**
+ * Construct the CTextToSpeechAppUi instance
+ */ 
+CTextToSpeechAppUi::CTextToSpeechAppUi()
+    {
+    }
+
+/** 
+ * The appui's destructor removes the container from the control
+ * stack and destroys it.
+ */
+CTextToSpeechAppUi::~CTextToSpeechAppUi()
+    {
+    delete iTextToSpeechEngine;
+    }
+
+/**
+ * Initialise container
+ */
+void CTextToSpeechAppUi::InitializeContainersL()
+    {
+    iTextToSpeechSettingItemListView = CTextToSpeechSettingItemListView::NewL();
+    AddViewL( iTextToSpeechSettingItemListView );
+    SetDefaultViewL( *iTextToSpeechSettingItemListView );
+    }
+
+/**
+ * Handle a command for this appui (override)
+ * @param aCommand command id to be handled
+ */
+void CTextToSpeechAppUi::HandleCommandL( TInt aCommand )
+    {
+    TBool commandHandled( EFalse );
+    
+    if ( !commandHandled ) 
+        {
+        if ( aCommand == EAknSoftkeyExit || aCommand == EEikCmdExit)
+            {
+            Exit();
+            }
+        }
+    }
+
+/** 
+ * Override of the HandleResourceChangeL virtual function
+ */
+void CTextToSpeechAppUi::HandleResourceChangeL( TInt aType )
+    {
+    CAknViewAppUi::HandleResourceChangeL( aType );
+    }
+                
+/** 
+ * Override of the HandleKeyEventL virtual function
+ * @return EKeyWasConsumed if event was handled, EKeyWasNotConsumed if not
+ * @param aKeyEvent 
+ * @param aType 
+ */
+TKeyResponse CTextToSpeechAppUi::HandleKeyEventL( const TKeyEvent& /*aKeyEvent*/,
+                                                  TEventCode /*aType*/ )
+    {
+    return EKeyWasNotConsumed;
+    }
+
+/** 
+ * Override of the HandleViewDeactivation virtual function
+ *
+ * @param aViewIdToBeDeactivated 
+ * @param aNewlyActivatedViewId 
+ */
+void CTextToSpeechAppUi::HandleViewDeactivation( const TVwsViewId& aViewIdToBeDeactivated, 
+                                                 const TVwsViewId &aNewlyActivatedViewId )
+    {
+    CAknViewAppUi::HandleViewDeactivation( aViewIdToBeDeactivated, 
+                                           aNewlyActivatedViewId );
+    }
+
+/**
+ * Completes the second phase of Symbian object construction. 
+ */ 
+void CTextToSpeechAppUi::ConstructL()
+    {
+    BaseConstructL( EAknEnableSkin | EAknEnableMSK );
+    
+    InitializeContainersL();
+    
+    iTextToSpeechEngine = CTextToSpeechEngine::NewL();
+    }
+
+/**
+* Returns pointer to application engine
+*/
+CTextToSpeechEngine* CTextToSpeechAppUi::AppEngine()
+    {
+    return iTextToSpeechEngine;
+    }
+
+// Enf of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechdocument.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include "texttospeechdocument.h"
+#include "texttospeechappui.h"
+
+/**
+ * Constructs the document class for the application.
+ * @param aApplication the application instance
+ */
+CTextToSpeechDocument::CTextToSpeechDocument( CEikApplication& aApplication ) :
+    CAknDocument( aApplication )
+    {
+    }
+
+/**
+ * Destructor
+ */
+CTextToSpeechDocument::~CTextToSpeechDocument()
+    {
+    }
+
+/**
+ * Completes the second phase of Symbian object construction. 
+ * Put initialization code that could leave here.  
+ */ 
+void CTextToSpeechDocument::ConstructL()
+    {
+    }
+    
+/**
+ * Symbian OS two-phase constructor.
+ *
+ * Creates an instance of CTextToSpeechDocument, constructs it, and
+ * returns it.
+ *
+ * @param aApp the application instance
+ * @return the new CTextToSpeechDocument
+ */
+CTextToSpeechDocument* CTextToSpeechDocument::NewL( CEikApplication& aApp )
+    {
+    CTextToSpeechDocument* self = new (ELeave) CTextToSpeechDocument( aApp );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+/**
+ * Creates the application UI object for this document.
+ * @return the new instance
+ */    
+CEikAppUi* CTextToSpeechDocument::CreateAppUiL()
+    {
+    return new (ELeave) CTextToSpeechAppUi();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechengine.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,294 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "texttospeechengine.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::NewL()
+// 
+// ----------------------------------------------------------
+//
+CTextToSpeechEngine* CTextToSpeechEngine::NewL()
+    {
+    CTextToSpeechEngine* self = new( ELeave ) CTextToSpeechEngine();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;    
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::ConstructL()
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::ConstructL() 
+    {
+    // Add ourselves to active scheduler
+    CActiveScheduler::Add( this );
+    
+    User::LeaveIfError( iServer.Open() );
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::CTextToSpeechEngine()
+// 
+// ----------------------------------------------------------
+//
+CTextToSpeechEngine::CTextToSpeechEngine() :
+    CActive( EPriorityStandard )
+    {
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::~CTextToSpeechEngine()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------------
+//
+CTextToSpeechEngine::~CTextToSpeechEngine()
+    {
+    Cancel();
+    
+    iServer.Close();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::InitAndPlayText
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::InitAndPlayText( const TDesC& aText )
+    {
+    Cancel();
+    SetActive();
+    iState = EPriming;
+    
+    iServer.InitialiseSynthesis( aText, iStatus );
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::InitAndPlayTextToFile
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::InitAndPlayTextToFile( const TDesC& aText,
+                                                 const TFileName& aFileName )
+    {
+    iFileName = aFileName;
+    
+    Cancel();
+    SetActive();
+    iState = EPriming;
+    
+    iServer.InitialiseSynthesis( aText, iFileName, iStatus );
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::PauseL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::PauseL()
+    {
+    iServer.PauseL();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::Play
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::Play()
+    {
+    Cancel();
+    SetActive();
+    iState = ESpeaking;
+        
+    iServer.Synthesise( iStatus );
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::StopL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::StopL()
+    {
+    iServer.StopL();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::VolumeL
+// 
+// ----------------------------------------------------------
+//
+TInt CTextToSpeechEngine::VolumeL()
+    {
+    return iServer.VolumeL();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::SetVolumeL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::SetVolumeL( TInt aVolume )
+    {
+    iServer.SetVolumeL( aVolume );
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::MaxVolumeL
+// 
+// ----------------------------------------------------------
+//
+TInt CTextToSpeechEngine::MaxVolumeL()
+    {
+    return iServer.MaxVolumeL();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::SpeakingRateL
+// 
+// ----------------------------------------------------------
+//
+TInt CTextToSpeechEngine::SpeakingRateL()
+    {
+    return iServer.SpeakingRateL();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::SetSpeakingRateL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::SetSpeakingRateL( TInt aRate )
+    {
+    iServer.SetSpeakingRateL( aRate );
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::MaxSpeakingRateL
+// 
+// ----------------------------------------------------------
+//
+TInt CTextToSpeechEngine::MaxSpeakingRateL()
+    {
+    return iServer.MaxSpeakingRateL();
+    }
+
+// ----------------------------------------------------------
+// CTextToSpeechEngine::VoiceL
+// 
+// ----------------------------------------------------------
+//
+TVoice CTextToSpeechEngine::VoiceL()
+    {
+    return iServer.VoiceL();
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::SetVoiceL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::SetVoiceL( const TVoice& aVoice )
+    {
+    iServer.SetVoiceL( aVoice );
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::GetLanguagesL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::GetLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    iServer.GetLanguagesL( aLanguages );
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::GetVoicesL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::GetVoicesL( RArray<TVoice>& aVoices, 
+                                      TLanguage aLanguage )
+    {
+    iServer.GetVoicesL( aVoices, aLanguage );
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::RunL
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::RunL()
+    {
+    switch ( iState )
+        {
+        case EPriming:
+        
+            if ( iStatus == KErrNone ) 
+                {
+                Play();
+                }
+            else
+                {
+                User::Leave( iStatus.Int() );
+                }
+                
+            break;
+        
+        case ESpeaking:
+        
+            if ( iStatus != KErrNone && iStatus != KErrCancel )
+                {
+                User::Leave( iStatus.Int() );
+                }
+            
+            iState = EIdle;
+            
+            break;
+            
+        default:
+            
+            break;
+            
+        }
+    }
+    
+// ----------------------------------------------------------
+// CTextToSpeechEngine::DoCancel
+// 
+// ----------------------------------------------------------
+//
+void CTextToSpeechEngine::DoCancel()
+    {
+    TRAP_IGNORE( iServer.StopL() );
+    }
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechsettingitemlist.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,349 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "texttospeechappui.h"
+#include "texttospeechengine.h"
+#include "texttospeechsettingitemlist.h"
+#include "texttospeechsettingitemlistsettings.h"
+#include "texttospeech.hrh"
+
+/**
+ * Construct the CTextToSpeechSettingItemList instance
+ * @param aCommandObserver command observer
+ */ 
+CTextToSpeechSettingItemList::CTextToSpeechSettingItemList( 
+    CTextToSpeechSettingItemListSettings& aSettings, 
+    MEikCommandObserver* aCommandObserver ) :
+    iSettings( aSettings ), 
+    iCommandObserver( aCommandObserver )
+    {
+    }
+    
+/** 
+ * Destroy any instance variables
+ */
+CTextToSpeechSettingItemList::~CTextToSpeechSettingItemList()
+    {
+    }
+
+/**
+ * Handle system notification that the container's size has changed.
+ */
+void CTextToSpeechSettingItemList::SizeChanged()
+    {
+    if ( ListBox() ) 
+        {
+        ListBox()->SetRect( Rect() );
+        }
+    }
+
+/**
+ * Create one setting item at a time, identified by id.
+ * CAknSettingItemList calls this method and takes ownership
+ * of the returned value.  The CAknSettingItem object owns
+ * a reference to the underlying data, which EditItemL() uses
+ * to edit and store the value.
+ */
+CAknSettingItem* CTextToSpeechSettingItemList::CreateSettingItemL( TInt aId )
+    {
+    CAknSettingItem* item( NULL );    
+    
+    switch ( aId )
+        {
+        case ETextToSpeechSettingItemListViewEdit1:
+            {            
+            item = new (ELeave) CAknTextSettingItem( aId, iSettings.Edit1() );
+            
+            break;
+            }
+        case ETextToSpeechSettingItemListViewEnumeratedTextPopup1:
+            {            
+            item = new (ELeave) CAknEnumeratedTextPopupSettingItem( 
+                aId, iSettings.EnumeratedTextPopup1() );
+                    
+            break;
+            }
+        case ETextToSpeechSettingItemListViewEnumeratedTextPopup2:
+            {            
+            item = new (ELeave) CAknEnumeratedTextPopupSettingItem( 
+                aId, iSettings.EnumeratedTextPopup2() );
+                    
+            break;
+            }
+        case ETextToSpeechSettingItemListViewSlider1:
+            {            
+            item = new (ELeave) CAknSliderSettingItem( 
+                aId, iSettings.Slider1() );
+            
+            break;
+            }
+        }
+        
+    return item;
+    }
+    
+/**
+ * Edit the setting item identified by the given id and store
+ * the changes into the store.
+ * @param aIndex the index of the setting item in SettingItemArray()
+ * @param aCalledFromMenu true: a menu item invoked editing, thus
+ *    always show the edit page and interactively edit the item;
+ *    false: change the item in place if possible, else show the edit page
+ */
+void CTextToSpeechSettingItemList::EditItemL ( TInt aIndex, TBool aCalledFromMenu )
+    {
+    CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
+
+    CAknSettingItem* item = ( *SettingItemArray() )[aIndex];
+    
+    TInt tmp1;
+    TInt tmp2;
+    
+    switch ( item->Identifier() )
+        {
+        case ETextToSpeechSettingItemListViewEnumeratedTextPopup1:
+            
+            tmp1 = iSettings.EnumeratedTextPopup1();
+            item->StoreL();
+            tmp2 = iSettings.EnumeratedTextPopup1();
+
+            if ( tmp1 != tmp2 )
+                {
+                TLanguage lang = 
+                    iSettings.iLanguages[iSettings.EnumeratedTextPopup1()];
+
+                iSettings.iVoices.Reset();
+                iEngine->GetVoicesL( iSettings.iVoices, lang );
+            
+                LoadVoicesL( ETrue ); 
+                
+                iSettings.iVoice = 
+                    iSettings.iVoices[iSettings.EnumeratedTextPopup2()];
+
+                HandleSliderVisibility();
+                HandleChangeInItemArrayOrVisibilityL();
+                }
+            
+            break;
+
+        case ETextToSpeechSettingItemListViewEnumeratedTextPopup2:
+            
+            tmp1 = iSettings.EnumeratedTextPopup2();
+            item->StoreL();
+            tmp2 = iSettings.EnumeratedTextPopup2();
+
+            if ( tmp1 != tmp2 )
+                {
+                iSettings.iVoice = 
+                    iSettings.iVoices[iSettings.EnumeratedTextPopup2()];
+                }
+            
+            HandleSliderVisibility(); 
+            HandleChangeInItemArrayOrVisibilityL();
+                
+            break;
+        
+        default:
+        
+            break;
+                
+        }
+        
+    item->StoreL();
+    }
+    
+/**
+ *    Handle the "Change" option on the Options menu.  This is an
+ *    alternative to the Selection key that forces the settings page
+ *    to come up rather than changing the value in place (if possible).
+ */
+void CTextToSpeechSettingItemList::ChangeSelectedItemL()
+    {
+    if ( ListBox()->CurrentItemIndex() >= 0 )
+        {
+        EditItemL( ListBox()->CurrentItemIndex(), ETrue );
+        }
+    }
+
+/**
+ *    Load the initial contents of the setting items.  By default,
+ *    the setting items are populated with the default values from
+ *     the design.  You can override those values here.
+ *    <p>
+ *    Note: this call alone does not update the UI.  
+ *    LoadSettingsL() must be called afterwards.
+ */
+void CTextToSpeechSettingItemList::LoadSettingValuesL()
+    {
+
+    iEngine = (((CTextToSpeechAppUi*)iEikonEnv->AppUi())->AppEngine());
+
+    iSettings.iVolume    = iEngine->VolumeL();
+    iSettings.iMaxVolume = iEngine->MaxVolumeL();
+    iSettings.iVoice     = iEngine->VoiceL();
+    
+    iSettings.iLanguages.Reset();
+    iEngine->GetLanguagesL( iSettings.iLanguages );
+    
+    iSettings.iVoices.Reset();
+    iEngine->GetVoicesL( iSettings.iVoices, iSettings.iVoice.iLanguage );
+    
+    LoadLanguagesL();
+    LoadVoicesL( EFalse );
+    
+    iSettings.SetSlider1( iEngine->SpeakingRateL() );
+    CAknSettingItem* sliderItem = ( *SettingItemArray() )[3];
+    sliderItem->LoadL();
+
+    HandleSliderVisibility();
+        
+    // Required when there is only one setting item.
+    SettingItemArray()->RecalculateVisibleIndicesL();
+
+    HandleChangeInItemArrayOrVisibilityL();		
+    }
+    
+/**
+ * Add correct languages to popup list
+ */
+void CTextToSpeechSettingItemList::LoadLanguagesL()
+    {
+    CAknSettingItemArray* itemArray = SettingItemArray();
+    CAknEnumeratedTextPopupSettingItem* item = 
+        (CAknEnumeratedTextPopupSettingItem*) (*itemArray)[1];
+    
+	// Load texts dynamically.
+	CArrayPtr<CAknEnumeratedText>* texts = item->EnumeratedTextArray();
+	texts->ResetAndDestroy();
+    
+	CAknEnumeratedText* enumText( NULL );
+	
+	TInt selectedItem( 0 );
+	
+	for ( TInt i( 0 ); i < iSettings.iLanguages.Count(); i++ ) 
+	    {
+	    TLanguage lang( iSettings.iLanguages[i] );
+	    
+	    TBuf<8> tmp;	    
+	    tmp.Num( (TInt)lang );
+	    
+	    HBufC* text = tmp.AllocLC();
+	    
+        enumText = new (ELeave) CAknEnumeratedText( i, text );
+        
+    	CleanupStack::PushL( enumText );
+	    texts->AppendL( enumText );
+	    CleanupStack::Pop( enumText );
+	    
+	    CleanupStack::Pop( text );
+	    
+	    if ( lang == iSettings.iVoice.iLanguage )
+	        {
+	        selectedItem = i;
+	        }
+	    }
+	
+	iSettings.SetEnumeratedTextPopup1( selectedItem );
+	item->LoadL();
+    }
+
+/**
+ * Add correct voice names to popup list
+ */    
+void CTextToSpeechSettingItemList::LoadVoicesL( TBool aResetSelection )
+    {
+    CAknSettingItemArray* itemArray = SettingItemArray();
+    CAknEnumeratedTextPopupSettingItem* item = 
+        (CAknEnumeratedTextPopupSettingItem*) (*itemArray)[2];
+
+	// Load texts dynamically.
+	CArrayPtr<CAknEnumeratedText>* texts = item->EnumeratedTextArray();
+	texts->ResetAndDestroy();
+
+	CAknEnumeratedText* enumText( NULL );
+	
+	TInt selectedItem( 0 );
+	
+	for ( TInt i( 0 ); i < iSettings.iVoices.Count(); i++ ) 
+	    {
+	    HBufC* text = iSettings.iVoices[i].iVoiceName.AllocLC();	    
+        enumText = new (ELeave) CAknEnumeratedText( i, text );
+        CleanupStack::Pop( text );
+
+    	CleanupStack::PushL( enumText );
+	    texts->AppendL( enumText );
+	    CleanupStack::Pop( enumText );
+	    
+	    if ( !aResetSelection && 
+	         iSettings.iVoices[i].iVoiceName == iSettings.iVoice.iVoiceName  )
+	        {
+	        selectedItem = i;
+	        }
+	    }
+	
+	iSettings.SetEnumeratedTextPopup2( selectedItem );
+	item->LoadL();
+    }
+
+/**
+ * Hide slider if current voice doesn't support speaking rate, 
+ * otherwise show it. 
+ */
+void CTextToSpeechSettingItemList::HandleSliderVisibility()
+    {
+    CAknSettingItem* sliderItem = ( *SettingItemArray() )[3];
+    
+    if ( iSettings.iVoice.iVoiceName == _L("DefaultMale") || 
+         iSettings.iVoice.iVoiceName == _L("DefaultFemale") )
+        {
+        sliderItem->SetHidden( ETrue );
+        }
+    else
+        {
+        sliderItem->SetHidden( EFalse );
+        }
+    }
+
+/** 
+ * Handle key event (override)
+ * @param aKeyEvent key event
+ * @param aType event code
+ * @return EKeyWasConsumed if the event was handled, else EKeyWasNotConsumed
+ */
+TKeyResponse CTextToSpeechSettingItemList::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+                                                           TEventCode aType )
+    {
+    TKeyResponse response( EKeyWasConsumed );
+    
+    if ( aKeyEvent.iCode == EKeyLeftArrow )
+        {
+        iCommandObserver->ProcessCommandL( EKeyDecVolume );
+        }
+    else if ( aKeyEvent.iCode == EKeyRightArrow )
+        {
+        iCommandObserver->ProcessCommandL( EKeyIncVolume );
+        }
+    else
+        {
+        response = CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType );
+        }
+    
+    return response;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechsettingitemlistsettings.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+/**
+ * Generated helper class which manages the settings contained 
+ * in 'TextToSpeechSettingItemList'.  Each CAknSettingItem maintains
+ * a reference to data in this class so that changes in the setting
+ * item list can be synchronized with this storage.
+ */
+
+#include <stringloader.h>
+#include <texttospeech.rsg>
+
+#include "texttospeechsettingitemlistsettings.h"
+
+const TInt KMinSliderValue = 10;
+
+/**
+ * C/C++ constructor for settings data, cannot throw
+ */
+CTextToSpeechSettingItemListSettings::CTextToSpeechSettingItemListSettings()
+    {
+    }
+
+/**
+ * Two-phase constructor for settings data
+ */
+CTextToSpeechSettingItemListSettings* CTextToSpeechSettingItemListSettings::NewL()
+    {
+    CTextToSpeechSettingItemListSettings* data = 
+        new( ELeave ) CTextToSpeechSettingItemListSettings();
+    
+    CleanupStack::PushL( data );
+    data->ConstructL();
+    CleanupStack::Pop( data );
+    
+    return data;
+    }
+    
+/**
+ * Second phase for initializing settings data
+ */
+void CTextToSpeechSettingItemListSettings::ConstructL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_TEXT_TO_SPEECH_SETTING_ITEM_LIST_EDIT1 );
+    SetEdit1( text->Des() );
+    CleanupStack::PopAndDestroy( text );
+
+    SetEnumeratedTextPopup1( 0 );
+    SetEnumeratedTextPopup2( 0 );
+    SetSlider1( KMinSliderValue );
+    }
+
+/**
+ * Destructor
+ */
+CTextToSpeechSettingItemListSettings::~CTextToSpeechSettingItemListSettings()
+    {
+    iLanguages.Close();
+    iVoices.Close();
+    }
+    
+/**
+ * Return reference to text
+ */
+TDes& CTextToSpeechSettingItemListSettings::Edit1()
+    {
+    return iEdit1;
+    }
+
+/**
+ * Set text and limit it to maximum length if necessary
+ */
+void CTextToSpeechSettingItemListSettings::SetEdit1( const TDesC& aValue )
+    {
+    if ( aValue.Length() < KEdit1MaxLength )
+        {
+        iEdit1.Copy( aValue );
+        }
+    else
+        {
+        iEdit1.Copy( aValue.Ptr(), KEdit1MaxLength );
+        }
+    }
+
+/**
+ * Return index of selected language
+ */
+TInt& CTextToSpeechSettingItemListSettings::EnumeratedTextPopup1()
+    {
+    return iEnumeratedTextPopup1;
+    }
+
+/**
+ * Set index of selected language
+ */
+void CTextToSpeechSettingItemListSettings::SetEnumeratedTextPopup1( const TInt& aValue )
+    {
+    iEnumeratedTextPopup1 = aValue;
+    }
+
+/**
+ * Return index of selected voice name
+ */
+TInt& CTextToSpeechSettingItemListSettings::EnumeratedTextPopup2()
+    {
+    return iEnumeratedTextPopup2;
+    }
+
+/**
+ * Set index of selected voice name
+ */
+void CTextToSpeechSettingItemListSettings::SetEnumeratedTextPopup2( const TInt& aValue )
+    {
+    iEnumeratedTextPopup2 = aValue;
+    }
+
+/**
+ * Return speaking rate value 
+ */
+TInt& CTextToSpeechSettingItemListSettings::Slider1()
+    {
+    return iSlider1;
+    }
+
+/**
+ * Set speaking rate value 
+ */
+void CTextToSpeechSettingItemListSettings::SetSlider1( const TInt& aValue )
+    {
+    iSlider1 = aValue;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/speechsynthesis/tsrc/texttospeech/src/texttospeechsettingitemlistview.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,335 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <aknnavide.h> 
+#include <texttospeech.rsg>
+
+#include "texttospeechappui.h"
+#include "texttospeechengine.h"
+#include "texttospeechsettingitemlistview.h"
+#include "texttospeechsettingitemlist.h"
+#include "texttospeechsettingitemlistsettings.h"
+
+#include "texttospeech.hrh"
+
+const TInt KMaxVolumeInUI = 10;
+
+/**
+ * First phase of Symbian two-phase construction. Should not contain any
+ * code that could leave.
+ */
+CTextToSpeechSettingItemListView::CTextToSpeechSettingItemListView()
+    {
+    }
+    
+/** 
+ * The view's destructor removes the container from the control
+ * stack and destroys it.
+ */
+CTextToSpeechSettingItemListView::~CTextToSpeechSettingItemListView()
+    {
+    }
+
+/**
+ * Symbian two-phase constructor.
+ * This creates an instance then calls the second-phase constructor
+ * without leaving the instance on the cleanup stack.
+ * @return new instance of CTextToSpeechSettingItemListView
+ */
+CTextToSpeechSettingItemListView* CTextToSpeechSettingItemListView::NewL()
+    {
+    CTextToSpeechSettingItemListView* self = 
+        CTextToSpeechSettingItemListView::NewLC();
+        
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+/**
+ * Symbian two-phase constructor.
+ * This creates an instance, pushes it on the cleanup stack,
+ * then calls the second-phase constructor.
+ * @return new instance of CTextToSpeechSettingItemListView
+ */
+CTextToSpeechSettingItemListView* CTextToSpeechSettingItemListView::NewLC()
+    {
+    CTextToSpeechSettingItemListView* self = 
+        new (ELeave) CTextToSpeechSettingItemListView();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    }
+
+/**
+ * Second-phase constructor for view.  
+ * Initialize contents from resource.
+ */ 
+void CTextToSpeechSettingItemListView::ConstructL()
+    {
+    BaseConstructL( 
+        R_TEXT_TO_SPEECH_SETTING_ITEM_LIST_TEXT_TO_SPEECH_SETTING_ITEM_LIST_VIEW );        
+    }
+    
+/**
+ * @return The UID for this view
+ */
+TUid CTextToSpeechSettingItemListView::Id() const
+    {
+    return TUid::Uid( ETextToSpeechSettingItemListViewId );
+    }
+
+/**
+ * Handle a command for this view (override)
+ * @param aCommand command id to be handled
+ */
+void CTextToSpeechSettingItemListView::HandleCommandL( TInt aCommand )
+    {   
+    TBool commandHandled( ETrue );
+    CAknVolumeControl* control( NULL );
+    
+    switch ( aCommand )
+        { // code to dispatch to the AknView's menu and CBA commands is generated here
+        
+        case ETextToSpeechSettingItemListViewMenuItem1Command:
+        case EAknSoftkeyChange:
+        
+            iTextToSpeechSettingItemList->ChangeSelectedItemL();
+        
+            break;
+        
+        case ETextToSpeechSettingItemListViewSynthesiseMenuItemCommand:
+            
+            iEngine->SetSpeakingRateL( iSettings->Slider1() );
+            iEngine->SetVoiceL( iSettings->iVoice ); 
+            iEngine->InitAndPlayText( iSettings->Edit1() ); 
+            
+            break;
+            
+        case ETextToSpeechSettingItemListViewExitMenuItemCommand:
+        
+            AppUi()->HandleCommandL( EEikCmdExit );
+            
+            break;
+        
+        case EKeyIncVolume:
+            
+            iEngine->SetVolumeL( iSettings->iVolume + 
+                                 iSettings->iMaxVolume / KMaxVolumeInUI );
+            
+            iSettings->iVolume = iSettings->iVolume + 
+                                 iSettings->iMaxVolume / KMaxVolumeInUI;
+            
+            control = static_cast< CAknVolumeControl* >( 
+                        iVolumeControl->DecoratedControl() );
+            
+            control->SetValue( KMaxVolumeInUI * 
+                               iSettings->iVolume / iSettings->iMaxVolume );
+            
+            break;
+            
+        case EKeyDecVolume:
+            
+            iEngine->SetVolumeL( iSettings->iVolume - 
+                                 iSettings->iMaxVolume / KMaxVolumeInUI );
+            
+            iSettings->iVolume = iSettings->iVolume - 
+                                 iSettings->iMaxVolume / KMaxVolumeInUI;
+            
+            control = static_cast< CAknVolumeControl* >( 
+                        iVolumeControl->DecoratedControl() );
+                        
+            control->SetValue( KMaxVolumeInUI * 
+                               iSettings->iVolume / iSettings->iMaxVolume );
+            
+            break;
+            
+        default:
+            
+            commandHandled = EFalse;
+            
+            break;
+            
+        }
+        
+    if ( !commandHandled && aCommand == EAknSoftkeyExit )
+        {
+        AppUi()->HandleCommandL( EEikCmdExit );
+        }
+    }
+
+/**
+ * Handles Navidecorator events (Arrow left and arrow right)
+ * @param aEventID ID of event to be handled
+ */
+void CTextToSpeechSettingItemListView::HandleNaviDecoratorEventL( TInt aEventID )
+    {
+    CAknVolumeControl* control( NULL );
+    
+    switch ( aEventID )
+        {
+        case EAknNaviDecoratorEventRightTabArrow: 
+            
+            HandleCommandL( EKeyIncVolume );
+            
+            break;
+            
+        case EAknNaviDecoratorEventLeftTabArrow:
+            
+            HandleCommandL( EKeyDecVolume );
+            
+            break;
+            
+        case EAknNaviDecoratorEventNaviLabel:
+            
+            control = static_cast< CAknVolumeControl* >( 
+                        iVolumeControl->DecoratedControl() );
+    
+            if ( control )
+                {
+                TInt value = control->Value();
+
+                iEngine->SetVolumeL( value * 
+                                     iSettings->iMaxVolume / KMaxVolumeInUI );
+                
+                iSettings->iVolume = value * 
+                                     iSettings->iMaxVolume / KMaxVolumeInUI ;
+                }
+                
+            break;
+
+        }
+    }
+    
+/**
+ * Activate view
+ * @param aPrevViewId 
+ * @param aCustomMessageId 
+ * @param aCustomMessage
+ */
+void CTextToSpeechSettingItemListView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
+                                                    TUid /*aCustomMessageId*/,
+                                                    const TDesC8& /*aCustomMessage*/ )
+    {
+    CEikButtonGroupContainer *cba = AppUi()->Cba();
+    if ( cba ) 
+        {
+        cba->MakeVisible( EFalse );
+        }
+    
+    if ( !iTextToSpeechSettingItemList )
+        {
+        iEngine = (((CTextToSpeechAppUi*)AppUi())->AppEngine());
+        
+        iSettings = CTextToSpeechSettingItemListSettings::NewL();
+
+        iTextToSpeechSettingItemList = 
+            new (ELeave) CTextToSpeechSettingItemList( *iSettings, this );
+        
+        iTextToSpeechSettingItemList->SetMopParent( this );
+        iTextToSpeechSettingItemList->ConstructFromResourceL( 
+            R_TEXT_TO_SPEECH_SETTING_ITEM_LIST_TEXT_TO_SPEECH_SETTING_ITEM_LIST );
+        
+        iTextToSpeechSettingItemList->ActivateL();
+        iTextToSpeechSettingItemList->LoadSettingValuesL();
+        iTextToSpeechSettingItemList->LoadSettingsL();
+        
+        AppUi()->AddToStackL( *this, iTextToSpeechSettingItemList );
+        
+        SetupStatusPaneL(); 
+        }
+    }
+
+/**
+ * Deactivate view
+ */
+void CTextToSpeechSettingItemListView::DoDeactivate()
+    {
+    CleanupStatusPane();
+    
+    CEikButtonGroupContainer *cba = AppUi()->Cba();
+    if ( cba ) 
+        {
+        cba->MakeVisible( ETrue );
+        cba->DrawDeferred();
+        }
+    
+    if ( iTextToSpeechSettingItemList )
+        {
+        AppUi()->RemoveFromStack( iTextToSpeechSettingItemList );
+        
+        delete iTextToSpeechSettingItemList;
+        iTextToSpeechSettingItemList = NULL;
+        
+        delete iSettings;
+        iSettings = NULL;
+        }    
+    }
+
+/**
+ * Show volume indicator in status pane
+ */
+void CTextToSpeechSettingItemListView::SetupStatusPaneL()
+    {
+    if ( !iVolumeControl )
+        {
+        CAknNavigationControlContainer* naviPane = 
+            static_cast< CAknNavigationControlContainer* >( 
+                iEikonEnv->AppUiFactory()->StatusPane()->ControlL( 
+                    TUid::Uid( EEikStatusPaneUidNavi ) ) );
+
+        iVolumeControl = 
+            naviPane->CreateVolumeIndicatorL( R_AVKON_NAVI_PANE_VOLUME_INDICATOR );
+        
+        // Subscribe for changes in volume indicator 
+        iVolumeControl->SetNaviDecoratorObserver( this );
+        iVolumeControl->SetControlType( CAknNavigationDecorator::ENaviLabel );
+        
+        CAknVolumeControl* control = 
+            static_cast< CAknVolumeControl* >( iVolumeControl->DecoratedControl() );
+        
+        control->SetValue( KMaxVolumeInUI * 
+                           iSettings->iVolume / iSettings->iMaxVolume );
+
+        naviPane->PushL( *iVolumeControl );
+        } 
+    }
+
+/**
+ * Delete volume indicator
+ */
+void CTextToSpeechSettingItemListView::CleanupStatusPane()
+    {
+    delete iVolumeControl;
+    iVolumeControl = NULL;
+    }
+
+/** 
+ * Handle status pane size change for this view (override)
+ */
+void CTextToSpeechSettingItemListView::HandleStatusPaneSizeChange()
+    {
+    CAknView::HandleStatusPaneSizeChange();
+    
+    // this may fail, but we're not able to propagate exceptions here
+    TRAP_IGNORE( SetupStatusPaneL() ); 
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/conf/ttscontrollerplugintest.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+
+[Test]
+// Test 1
+title Play text file (OpenFileL)
+timeout 120000  // 2 minutes
+create ttscontrollerplugintest test
+request MapcInitComplete
+request MapcPlayComplete
+test Create
+test OpenFile c:\Testframework\ttscontrollerplugintestdata.txt
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test OpenFileHandle c:\Testframework\ttscontrollerplugintestdata.txt
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test Destroy
+delete test
+[Endtest] 
+
+[Test]
+// Test 2
+title Test volume ramp
+timeout 120000  // 2 minutes
+create ttscontrollerplugintest test
+request MapcInitComplete
+request MapcPlayComplete
+test Create
+test OpenFile c:\Testframework\ttscontrollerplugintestdata.txt
+wait MapcInitComplete
+test SetVolumeAndRamp
+test Play
+wait MapcPlayComplete
+test Destroy
+delete test
+[Endtest] 
+
+[Test]
+// Test 3
+title Play text file (NewFilePlayerL)
+timeout 120000  // 2 minutes
+create ttscontrollerplugintest test
+request MapcInitComplete
+request MapcPlayComplete
+test CreateFilePlayer c:\Testframework\ttscontrollerplugintestdata.txt
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test Destroy
+delete test
+[Endtest] 
+
+[Test]
+// Test 4 - plugin is selected using header data '(tts)'
+title Play from descriptor
+timeout 120000  // 2 minutes
+create ttscontrollerplugintest test
+request MapcInitComplete
+request MapcPlayComplete
+test Create
+test OpenDes (tts)Descriptor1
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test Destroy
+test CreateDesPlayer (tts)Descriptor2 
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test Destroy
+delete test
+[Endtest] 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/conf/ttsutilitytest.cfg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,125 @@
+
+[Test]
+// Test 1
+title TtsUtility style settings
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+test CreateTtsUtility
+test StyleSettings
+test DestroyTtsUtility
+delete test
+[Endtest] 
+
+[Test]
+// Test 2
+title TtsUtility playback properties
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+request MapcInitComplete
+request MapcPlayComplete
+test CreateTtsUtility
+test PlaybackProperties
+test DestroyTtsUtility
+delete test
+[Endtest] 
+
+[Test]
+// Test 3
+title TtsUtility playback 1
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+request MapcInitComplete
+request MapcPlayComplete
+test CreateTtsUtility
+test OpenDes Descriptor1
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test OpenDes8 Descriptor2
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test OpenFile c:\Testframework\ttsutilitytestdata.txt
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test OpenParsedText Descriptor3
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test DestroyTtsUtility
+delete test
+[Endtest] 
+
+[Test]
+// Test 4
+title TtsUtility playback 2
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+request MapcPlayComplete
+test CreateTtsUtility
+test OpenAndPlayDes Descriptor4
+wait MapcPlayComplete
+test OpenAndPlayDes8 Descriptor5
+wait MapcPlayComplete
+test OpenAndPlayFile c:\Testframework\ttsutilitytestdata.txt
+wait MapcPlayComplete
+test OpenAndPlayParsedText Descriptor6
+wait MapcPlayComplete
+test DestroyTtsUtility
+delete test
+[Endtest] 
+
+[Test]
+// Test 5
+title TtsUtility playback 3
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+request MapcInitComplete
+request MapcPlayComplete
+test CreateTtsUtility
+test OpenDes 1234567890
+wait MapcInitComplete
+test Play
+pause 500
+test Pause
+pause 1000
+test Play
+pause 500
+test Stop
+test OpenDes 1234567890
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test DestroyTtsUtility
+delete test
+[Endtest] 
+
+[Test]
+// Test 6
+title TtsUtility synthesis to file
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+request MapcInitComplete
+request MapcPlayComplete
+test CreateTtsUtility
+test SynthesisToFile c:\Testframework\ttsutility.raw
+test OpenDes Descriptor7
+wait MapcInitComplete
+test Play
+wait MapcPlayComplete
+test DestroyTtsUtility
+delete test
+[Endtest] 
+
+[Test]
+// Test 7
+title TtsUtility custom commands
+timeout 120000  // 2 minutes
+create ttsutilitytest test
+test CreateTtsUtility
+test CustomCommands
+test CustomCommands2
+test DestroyTtsUtility
+delete test
+[Endtest] 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/data/ttscontrollerplugintestdata.txt	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1 @@
+(tts)Text input for text-to-speech plugin tests :) 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/data/ttsutilitytestdata.txt	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1 @@
+Text input for tts tests :) 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+#include "../ttscontrollerplugintest/group/bld.inf"
+#include "../ttsutilitytest/group/bld.inf"
+
+
+PRJ_TESTEXPORTS
+
+
+PRJ_EXPORTS
+
+
+PRJ_TESTMMPFILES
+
+
+PRJ_MMPFILES
+
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/group/test.pkg	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,44 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+&EN
+
+; Header
+#{"FOO"}, (FOO), 1, 0, 0, TYPE=SA
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+
+;Copying ordinary file (not language dependent) to fixed drive drive.
+
+"..\init\test.ini"-"c:\Testframework\test.ini"
+"..\conf\ttscontrollerplugintest.cfg"-"c:\Testframework\ttscontrollerplugintest.cfg"
+"..\conf\ttsutilitytest.cfg"-"c:\Testframework\ttsutilitytest.cfg"
+"\epoc32\release\armv5\urel\ttscontrollerplugintest.dll"-"c:\sys\bin\ttscontrollerplugintest.dll"
+"\epoc32\release\armv5\urel\ttsutilitytest.dll"-"c:\sys\bin\ttsutilitytest.dll"
+"..\data\ttscontrollerplugintestdata.txt"-"c:\Testframework\ttscontrollerplugintestdata.txt"
+"..\data\ttsutilitytestdata.txt"-"c:\Testframework\ttsutilitytestdata.txt"
+
+
+
+
+; Trim For Mms
+; ------------
+; to be added later
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/init/test.ini	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,169 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if 
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module. 
+
+[Engine_Defaults]
+
+TestReportMode= FullReport		# Possible values are: 'Empty', 'Summary', 'Environment',
+                                                               'TestCases' or 'FullReport'
+
+CreateTestReport= YES			# Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT			# Possible values: TXT or HTML
+TestReportOutput= FILE			# Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE	# Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= c:\TestFramework\ttsutilitytest.cfg
+TestCaseFile= c:\TestFramework\ttscontrollerplugintest.cfg
+[End_Module]
+
+
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIFTestFramework logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number 
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' 
+
+#CreateLogDirectories= YES		# Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+EmulatorFormat= txt			# Possible values: TXT or HTML
+EmulatorOutput= FILE			# Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML			# Possible values: TXT or HTML
+#HardwareOutput= FILE			# Possible values: FILE or RDEBUG
+
+FileCreationMode= OVERWRITE		# Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES			# Possible values: YES or NO
+WithTimeStamp= YES			# Possible values: YES or NO
+WithLineBreak= YES			# Possible values: YES or NO
+WithEventRanking= YES			# Possible values: YES or NO
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/bwins/ttscontrollerplugintestu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/eabi/ttscontrollerplugintestu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+
+PRJ_TESTEXPORTS
+
+#include "export.inc"
+ttscontrollerplugintest.ini /epoc32/winscw/c/testframework/ttscontrollerplugintest.ini
+
+
+PRJ_EXPORTS
+
+
+PRJ_TESTMMPFILES
+ttscontrollerplugintest.mmp
+
+
+PRJ_MMPFILES
+
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/group/export.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,2 @@
+..\..\data\ttscontrollerplugintestdata.txt \epoc32\winscw\c\testframework\ttscontrollerplugintestdata.txt
+..\..\conf\ttscontrollerplugintest.cfg     \epoc32\winscw\c\testframework\ttscontrollerplugintest.cfg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/group/ttscontrollerplugintest.ini	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,168 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if 
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module. 
+
+[Engine_Defaults]
+
+TestReportMode= FullReport		# Possible values are: 'Empty', 'Summary', 'Environment',
+                                                               'TestCases' or 'FullReport'
+
+CreateTestReport= YES			# Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT			# Possible values: TXT or HTML
+TestReportOutput= FILE			# Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE	# Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= c:\TestFramework\ttscontrollerplugintest.cfg
+[End_Module]
+
+
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIFTestFramework logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number 
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' 
+
+#CreateLogDirectories= YES		# Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+EmulatorFormat= txt			# Possible values: TXT or HTML
+EmulatorOutput= FILE			# Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML			# Possible values: TXT or HTML
+#HardwareOutput= FILE			# Possible values: FILE or RDEBUG
+
+FileCreationMode= OVERWRITE		# Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES			# Possible values: YES or NO
+WithTimeStamp= YES			# Possible values: YES or NO
+WithLineBreak= YES			# Possible values: YES or NO
+WithEventRanking= YES			# Possible values: YES or NO
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/group/ttscontrollerplugintest.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          ttscontrollerplugintest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2000F84B
+
+CAPABILITY      CAP_GENERAL_DLL
+DEFFILE         ttscontrollerplugintest.def
+
+SOURCEPATH      ../src
+SOURCE          ttscontrollerplugintest.cpp
+SOURCE          ttscontrollerplugintestblocks.cpp
+
+USERINCLUDE     ../inc 
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+
+LIBRARY         charconv.lib 
+LIBRARY         efsrv.lib 
+LIBRARY         mediaclientaudio.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/inc/ttscontrollerplugintest.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef TTSCONTROLLERPLUGINTEST_H
+#define TTSCONTROLLERPLUGINTEST_H
+
+//  INCLUDES
+#include <stiflogger.h>
+#include <testscripterinternal.h>
+#include <stiftestmodule.h>
+
+#include <mdaaudiosampleplayer.h>
+
+
+// MACROS
+
+// Logging path
+_LIT( KttscontrollerplugintestLogPath, "\\logs\\testframework\\ttscontrollerplugintest\\" ); 
+// Log file
+_LIT( KttscontrollerplugintestLogFile, "ttscontrollerplugintest.txt" ); 
+_LIT( KttscontrollerplugintestLogFileWithTitle, "ttscontrollerplugintest_[%S].txt" );
+
+
+// FORWARD DECLARATIONS
+class Cttscontrollerplugintest;
+
+
+// CLASS DECLARATION
+
+/**
+*
+*/
+NONSHARABLE_CLASS(Cttscontrollerplugintest) : public CScriptBase, 
+                                              public MMdaAudioPlayerCallback
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static Cttscontrollerplugintest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~Cttscontrollerplugintest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+
+    private: 
+    
+        void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds &aDuration );
+        
+        void MapcPlayComplete( TInt aError );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        Cttscontrollerplugintest( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Frees all resources allocated from test methods.
+        * @since ?Series60_version
+        */
+        void Delete();
+
+        /**
+        * Test methods are listed below. 
+        */
+        virtual TInt CreateL();
+        virtual TInt CreateFilePlayerL      ( CStifItemParser& aItem );
+        virtual TInt CreateDesPlayerL       ( CStifItemParser& aItem );
+        virtual TInt OpenFileL              ( CStifItemParser& aItem );
+        virtual TInt OpenFileHandleL        ( CStifItemParser& aItem );
+        virtual TInt OpenDesL               ( CStifItemParser& aItem );
+        virtual TInt Play();
+        virtual TInt SetVolumeAndRampL();
+        virtual TInt Destroy();
+
+    private:
+        
+        CMdaAudioPlayerUtility*     iAudioPlayer;
+        
+        RFs                         iFs;
+        RFile                       iFile;
+        
+        HBufC8*                     iInputText;
+        
+    };
+
+#endif      // TTSCONTROLLERPLUGINTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/src/ttscontrollerplugintest.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <stiftestinterface.h>
+#include "ttscontrollerplugintest.h"
+#include <settingserverclient.h>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::Cttscontrollerplugintest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Cttscontrollerplugintest::Cttscontrollerplugintest( CTestModuleIf& aTestModuleIf ) :
+    CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Cttscontrollerplugintest::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+
+    TFileName logFileName;
+    
+    if(loggerSettings.iAddTestCaseTitle)
+        {
+        TName title;
+        TestModuleIf().GetTestCaseTitleL(title);
+        logFileName.Format(KttscontrollerplugintestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KttscontrollerplugintestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KttscontrollerplugintestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Cttscontrollerplugintest* Cttscontrollerplugintest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    Cttscontrollerplugintest* self = new (ELeave) Cttscontrollerplugintest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+Cttscontrollerplugintest::~Cttscontrollerplugintest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+
+    return ( CScriptBase* ) Cttscontrollerplugintest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttscontrollerplugintest/src/ttscontrollerplugintestblocks.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,303 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <stifparser.h>
+#include <stiftestinterface.h>
+#include <stiftesteventinterface.h>
+
+#include <utf.h>
+
+#include "ttscontrollerplugintest.h"
+
+_LIT( Kttscontrollerplugintest, "ttscontrollerplugintest" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void Cttscontrollerplugintest::Delete() 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+    TStifFunctionInfo const KFunctions[] =
+        {  
+        // Copy this line for every implemented function.
+        // First string is the function name used in TestScripter script file.
+        // Second is the actual implementation member function. 
+        ENTRY( "Create",                Cttscontrollerplugintest::CreateL ),
+        ENTRY( "CreateFilePlayer",      Cttscontrollerplugintest::CreateFilePlayerL ),
+        ENTRY( "CreateDesPlayer",       Cttscontrollerplugintest::CreateDesPlayerL ),
+        ENTRY( "OpenFile",              Cttscontrollerplugintest::OpenFileL ),
+        ENTRY( "OpenFileHandle",        Cttscontrollerplugintest::OpenFileHandleL ),
+        ENTRY( "OpenDes",               Cttscontrollerplugintest::OpenDesL ),
+        ENTRY( "Play",                  Cttscontrollerplugintest::Play ),
+        ENTRY( "SetVolumeAndRamp",      Cttscontrollerplugintest::SetVolumeAndRampL ),
+        ENTRY( "Destroy",               Cttscontrollerplugintest::Destroy ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::CreateL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::CreateL()
+    {
+    // Print to UI
+    _LIT( KFunction, "In CreateL" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+
+    iAudioPlayer = CMdaAudioPlayerUtility::NewL( *this );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::CreateFilePlayerL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::CreateFilePlayerL( CStifItemParser& aItem )
+    {
+    // Print to UI
+    _LIT( KFunction, "In CreateFilePlayerL" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    TPtrC file;
+    User::LeaveIfError( aItem.GetNextString ( file ) );
+    TFileName fileName( file );
+    
+    iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL( fileName, *this );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::CreateDesPlayerL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::CreateDesPlayerL( CStifItemParser& aItem )
+    {
+    // Print to UI
+    _LIT( KFunction, "In CreateDesPlayerL" );
+    
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    // Allow asynchronous request to leak handle 
+    TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles  ); 
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    iInputText = HBufC8::NewL( 4 * input.Length() );
+    TPtr8 refText = iInputText->Des();
+    
+    User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) );
+        
+    iAudioPlayer = CMdaAudioPlayerUtility::NewDesPlayerL( *iInputText, *this );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::OpenFileL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::OpenFileL( CStifItemParser& aItem )
+    {
+    // Print to UI
+    _LIT( KFunction, "In OpenFileL" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    iAudioPlayer->Close();
+    
+    TPtrC file;
+    User::LeaveIfError( aItem.GetNextString ( file ) );
+    TFileName fileName( file );
+    
+    iAudioPlayer->OpenFileL( fileName );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::OpenFileHandleL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::OpenFileHandleL( CStifItemParser& aItem )
+    {
+    // Print to UI
+    _LIT( KFunction, "In OpenFileHandleL" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    iFile.Close();
+    iFs.Close();
+    iAudioPlayer->Close();
+
+    TPtrC file;
+    User::LeaveIfError( aItem.GetNextString ( file ) );
+    TFileName fileName( file );
+
+    User::LeaveIfError( iFs.Connect() );
+    User::LeaveIfError( iFile.Open( iFs, fileName, EFileRead|EFileStreamText ) );
+    
+    iAudioPlayer->OpenFileL( iFile );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::OpenDesL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::OpenDesL( CStifItemParser& aItem )
+    {
+    // Print to UI
+    _LIT( KFunction, "In OpenFileL" );
+    
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    iAudioPlayer->Close();
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    iInputText = HBufC8::NewL( 4 * input.Length() );
+    TPtr8 refText = iInputText->Des();
+    
+    User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) );
+    
+    iAudioPlayer->OpenDesL( *iInputText );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::Play
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::Play()
+    {
+    // Print to UI
+    _LIT( KFunction, "In Play" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    iAudioPlayer->Play();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::SetVolumeAndRampL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::SetVolumeAndRampL()
+    {
+    // Print to UI
+    _LIT( KFunction, "In SetVolumeAndRampL" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    iAudioPlayer->SetVolume( iAudioPlayer->MaxVolume() );
+    iAudioPlayer->SetVolumeRamp( 100000 );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::Destroy
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttscontrollerplugintest::Destroy()
+    {
+    // Print to UI
+    _LIT( KFunction, "In Destroy" );
+    TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction );
+    
+    iFile.Close();
+    iFs.Close();
+    
+    delete iAudioPlayer;
+    iAudioPlayer = NULL;
+    
+    delete iInputText;
+    iInputText = NULL;
+    
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::MapcInitComplete
+//
+// -----------------------------------------------------------------------------
+// 
+void Cttscontrollerplugintest::MapcInitComplete( TInt aError, 
+                                                 const TTimeIntervalMicroSeconds& /*aDuration*/ )
+    {
+    if ( aError )
+        {
+        User::Panic( Kttscontrollerplugintest, aError );
+        }
+    
+    TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcInitComplete" ) );
+    TestModuleIf().Event( stifEvent );    
+    }
+    
+// -----------------------------------------------------------------------------
+// Cttscontrollerplugintest::MapcPlayComplete
+//
+// -----------------------------------------------------------------------------
+// 
+void Cttscontrollerplugintest::MapcPlayComplete( TInt aError )
+    {
+    if ( aError )
+        {
+        User::Panic( Kttscontrollerplugintest, aError );
+        }
+    
+    TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcPlayComplete" ) );
+    TestModuleIf().Event( stifEvent );
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/bwins/ttsutilitytestu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/eabi/ttsutilitytestu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+
+PRJ_TESTEXPORTS
+
+#include "export.inc"
+ttsutilitytest.ini /epoc32/winscw/c/testframework/ttsutilitytest.ini
+
+
+PRJ_EXPORTS
+
+
+PRJ_TESTMMPFILES
+ttsutilitytest.mmp
+
+
+PRJ_MMPFILES
+
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/group/export.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,2 @@
+..\..\data\ttsutilitytestdata.txt \epoc32\winscw\c\testframework\ttsutilitytestdata.txt
+..\..\conf\ttsutilitytest.cfg     \epoc32\winscw\c\testframework\ttsutilitytest.cfg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/group/ttsutilitytest.ini	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,168 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if 
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module. 
+
+[Engine_Defaults]
+
+TestReportMode= FullReport		# Possible values are: 'Empty', 'Summary', 'Environment',
+                                                               'TestCases' or 'FullReport'
+
+CreateTestReport= YES			# Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT			# Possible values: TXT or HTML
+TestReportOutput= FILE			# Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE	# Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= c:\TestFramework\ttsutilitytest.cfg
+[End_Module]
+
+
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIFTestFramework logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number 
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' 
+
+#CreateLogDirectories= YES		# Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+EmulatorFormat= txt			# Possible values: TXT or HTML
+EmulatorOutput= FILE			# Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML			# Possible values: TXT or HTML
+#HardwareOutput= FILE			# Possible values: FILE or RDEBUG
+
+FileCreationMode= OVERWRITE		# Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES			# Possible values: YES or NO
+WithTimeStamp= YES			# Possible values: YES or NO
+WithLineBreak= YES			# Possible values: YES or NO
+WithEventRanking= YES			# Possible values: YES or NO
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/group/ttsutilitytest.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          ttsutilitytest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2000F84A 
+
+CAPABILITY      CAP_GENERAL_DLL
+DEFFILE         ttsutilitytest.def
+
+SOURCEPATH      ../src
+SOURCE          ttsutilitytest.cpp
+SOURCE          ttsutilitytestblocks.cpp
+
+USERINCLUDE     ../inc 
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/mmf/common\
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+
+LIBRARY         nssttscommon.lib
+LIBRARY         nssttsutility.lib
+
+LIBRARY         charconv.lib 
+LIBRARY         efsrv.lib 
+LIBRARY         nssttscustomcommands.lib
+LIBRARY         mmfcontrollerframework.lib
+
+LANG            SC
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/inc/ttsutilitytest.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef TTSUTILITYTEST_H
+#define TTSUTILITYTEST_h
+
+//  INCLUDES
+#include <stiflogger.h>
+#include <testscripterinternal.h>
+#include <stiftestmodule.h>
+
+#include <nssttsutility.h>
+
+
+// MACROS
+
+// Logging path
+_LIT( KttsutilitytestLogPath, "\\logs\\testframework\\ttsutilitytest\\" ); 
+// Log file
+_LIT( KttsutilitytestLogFile, "ttsutilitytest.txt" ); 
+_LIT( KttsutilitytestLogFileWithTitle, "ttsutilitytest_[%S].txt" );
+
+
+// FORWARD DECLARATIONS
+class Cttsutilitytest;
+
+
+// CLASS DECLARATION
+
+/**
+*
+*/
+NONSHARABLE_CLASS(Cttsutilitytest) : public CScriptBase, 
+                                              public MTtsClientUtilityObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static Cttsutilitytest* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~Cttsutilitytest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+
+    private: 
+    
+        void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds &aDuration );
+        
+        void MapcPlayComplete( TInt aError );
+        
+        void MapcCustomCommandEvent( TInt /*aEvent*/, TInt /*aError*/ ) {};
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        Cttsutilitytest( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Frees all resources allocated from test methods.
+        */
+        void Delete();
+
+        /**
+        * Test methods are listed below. 
+        */
+        virtual TInt CreateTtsUtilityL();
+        virtual TInt DestroyTtsUtilityL();
+        
+        virtual TInt StyleSettingsL();
+        virtual TInt PlaybackPropertiesL();
+        
+        virtual TInt Play();
+        virtual TInt Pause();
+        virtual TInt Stop();
+        
+        virtual TInt OpenDesL       ( CStifItemParser& aItem );
+        virtual TInt OpenDes8L      ( CStifItemParser& aItem );
+        virtual TInt OpenFileL      ( CStifItemParser& aItem );
+        virtual TInt OpenParsedTextL( CStifItemParser& aItem );
+        
+        virtual TInt OpenAndPlayDesL       ( CStifItemParser& aItem );
+        virtual TInt OpenAndPlayDes8L      ( CStifItemParser& aItem );
+        virtual TInt OpenAndPlayFileL      ( CStifItemParser& aItem );
+        virtual TInt OpenAndPlayParsedTextL( CStifItemParser& aItem );
+        
+        virtual TInt SynthesisToFileL( CStifItemParser& aItem );
+        
+        virtual TInt CustomCommandsL();
+        virtual TInt CustomCommands2L();
+        
+        /*
+        * Other functions
+        */ 
+        TUid OpenPluginL();
+
+    private:
+        
+        CTtsUtility*                iTtsUtility;
+        CTtsParsedText*             iParsedText;
+        TTtsSegment                 iSegment; 
+        TTtsStyle                   iStyle;
+        
+        RFs                         iFs;
+        RFile                       iFile;
+
+    };
+
+#endif      // TTSUTILITYTEST_h
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/src/ttsutilitytest.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <stiftestinterface.h>
+#include "ttsutilitytest.h"
+#include <settingserverclient.h>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::Cttsutilitytest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Cttsutilitytest::Cttsutilitytest( CTestModuleIf& aTestModuleIf ) :
+    CScriptBase( aTestModuleIf ), 
+    iSegment( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Cttsutilitytest::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+
+    TFileName logFileName;
+    
+    if(loggerSettings.iAddTestCaseTitle)
+        {
+        TName title;
+        TestModuleIf().GetTestCaseTitleL(title);
+        logFileName.Format(KttsutilitytestLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KttsutilitytestLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KttsutilitytestLogPath, 
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Cttsutilitytest* Cttsutilitytest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    Cttsutilitytest* self = new (ELeave) Cttsutilitytest( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+Cttsutilitytest::~Cttsutilitytest()
+    { 
+
+    // Delete resources allocated from test methods
+    Delete();
+
+    // Delete logger
+    delete iLog; 
+
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+
+    return ( CScriptBase* ) Cttsutilitytest::NewL( aTestModuleIf );
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/tsrc/public/basic/ttsutilitytest/src/ttsutilitytestblocks.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,649 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <stifparser.h>
+#include <stiftestinterface.h>
+#include <stiftesteventinterface.h>
+
+#include <audiopreference.h>
+#include <nssttscustomcommands.h>
+#include <utf.h>
+
+#include "ttsutilitytest.h"
+
+_LIT( Kttsutilitytest, "ttsutilitytest" );
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void Cttsutilitytest::Delete() 
+    {
+    iFs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+    TStifFunctionInfo const KFunctions[] =
+        {  
+        ENTRY( "CreateTtsUtility",      Cttsutilitytest::CreateTtsUtilityL ),
+        ENTRY( "DestroyTtsUtility",     Cttsutilitytest::DestroyTtsUtilityL ),
+        ENTRY( "StyleSettings",         Cttsutilitytest::StyleSettingsL ),
+        ENTRY( "PlaybackProperties",    Cttsutilitytest::PlaybackPropertiesL ),
+        ENTRY( "Play",                  Cttsutilitytest::Play ),
+        ENTRY( "Pause",                 Cttsutilitytest::Pause ),
+        ENTRY( "Stop",                  Cttsutilitytest::Stop ),
+        ENTRY( "OpenDes",               Cttsutilitytest::OpenDesL ),
+        ENTRY( "OpenDes8",              Cttsutilitytest::OpenDes8L ),
+        ENTRY( "OpenFile",              Cttsutilitytest::OpenFileL ),
+        ENTRY( "OpenParsedText",        Cttsutilitytest::OpenParsedTextL ),
+        ENTRY( "OpenAndPlayDes",        Cttsutilitytest::OpenAndPlayDesL ),
+        ENTRY( "OpenAndPlayDes8",       Cttsutilitytest::OpenAndPlayDes8L ),
+        ENTRY( "OpenAndPlayFile",       Cttsutilitytest::OpenAndPlayFileL ),
+        ENTRY( "OpenAndPlayParsedText", Cttsutilitytest::OpenAndPlayParsedTextL ),
+        ENTRY( "SynthesisToFile",       Cttsutilitytest::SynthesisToFileL ),
+        ENTRY( "CustomCommands",        Cttsutilitytest::CustomCommandsL ),
+        ENTRY( "CustomCommands2",       Cttsutilitytest::CustomCommands2L ),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::CreateTtsUtilityL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::CreateTtsUtilityL()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In CreateTtsUtilityL") );
+    
+    if ( iTtsUtility )
+        {
+        User::LeaveIfError( KErrAlreadyExists );
+        }
+    
+    iTtsUtility = CTtsUtility::NewL( *this );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::DestroyTtsUtilityL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::DestroyTtsUtilityL()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In DestroyTtsUtilityL") );
+    
+    delete iParsedText;
+    iParsedText = NULL;
+    
+    iTtsUtility->Close();
+    
+    delete iTtsUtility;
+    iTtsUtility = NULL; 
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::StyleSettingsL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::StyleSettingsL()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In StyleSettingsL") );
+    
+    OpenPluginL();
+    
+    iStyle.iLanguage = ELangEnglish;
+    iStyle.iVoice    = KDefaultVoiceNameMale;
+    iStyle.iQuality  = ETtsQualityLowPreferred;
+    
+    iTtsUtility->SetDefaultStyleL( iStyle );
+    
+    TTtsStyle defaultStyle = iTtsUtility->DefaultStyleL();
+    if ( iStyle.iLanguage != defaultStyle.iLanguage || 
+         iStyle.iVoice    != defaultStyle.iVoice || 
+         iStyle.iQuality  != defaultStyle.iQuality )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    TTtsStyleID styleId = iTtsUtility->AddStyleL( iStyle ); 
+    
+    TTtsStyle style = iTtsUtility->StyleL( styleId ); 
+    
+    if ( iStyle.iLanguage != style.iLanguage || 
+         iStyle.iVoice    != style.iVoice || 
+         iStyle.iQuality  != style.iQuality )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    // There should be only one style
+    TUint16 index = 1;
+    TRAPD( error, style = iTtsUtility->StyleL( index ) );
+    if ( error != KErrNotFound )
+        {
+        User::Leave( KErrGeneral );
+        }
+        
+    if ( iTtsUtility->NumberOfStyles() == 1 )
+        {
+        iTtsUtility->DeleteStyle( styleId );
+        }
+    
+    RArray<TLanguage> languages;
+    CleanupClosePushL( languages );
+    
+    iTtsUtility->GetSupportedLanguagesL( languages );
+    
+    if ( languages.Count() > 0 )
+        {
+        RArray<TTtsStyle> voices;
+        
+        iTtsUtility->GetSupportedVoicesL( languages[0], voices );
+        
+        if ( voices.Count() == 0 )
+            {
+            User::Leave( KErrNotFound );
+            }
+            
+        voices.Close();
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    CleanupStack::PopAndDestroy( &languages );
+    
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::PlaybackPropertiesL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::PlaybackPropertiesL()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In PlaybackPropertiesL") );
+    
+    OpenPluginL();
+    
+    TInt maxVolume( iTtsUtility->MaxVolume() );
+    iTtsUtility->SetVolume( maxVolume );
+    
+    TInt volume;
+    iTtsUtility->GetVolume( volume );
+    
+    if ( volume != maxVolume )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    TRAP_IGNORE( TInt speakingRate = iTtsUtility->SpeakingRateL() );
+    TRAP_IGNORE( iTtsUtility->SetSpeakingRateL( KTtsMaxSpeakingRate ) );
+    
+    iTtsUtility->SetRepeats( 1, 1000 );
+    
+    TInt balance;
+    iTtsUtility->GetBalance( balance );
+    iTtsUtility->SetBalance( balance );
+    
+    TTimeIntervalMicroSeconds duration = iTtsUtility->Duration();
+    
+    iTtsUtility->SetPriority( KAudioPriorityVoiceDial, 
+                              (TMdaPriorityPreference)KAudioPrefVocosPlayback );
+    
+    iTtsUtility->GetPosition( duration );
+    iTtsUtility->SetPosition( duration );
+    
+    TInt wordIndex( KErrNotFound );
+    iTtsUtility->GetPosition( wordIndex );
+    iTtsUtility->SetPosition( wordIndex );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::Play
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::Play()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In Play") );
+    
+    iTtsUtility->Play();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::Pause
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::Pause()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In Pause") );
+    
+    iTtsUtility->Pause();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::Stop
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::Stop()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In Stop") );
+    
+    iTtsUtility->Stop();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenDesL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenDesL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenDesL") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    iTtsUtility->OpenDesL( input );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenDes8L
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenDes8L( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenDes8L") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    HBufC8* input8 = HBufC8::NewLC( 4 * input.Length() );
+    TPtr8 refText = input8->Des();
+    
+    User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) );
+
+    iTtsUtility->OpenDesL( *input8 );
+    
+    CleanupStack::PopAndDestroy( input8 );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenFileL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenFileL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenFileL") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+        
+    iTtsUtility->OpenFileL( input );
+    
+    return KErrNone;
+    }
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenParsedTextL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenParsedTextL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenParsedTextL") );
+    
+    TInt result( KErrGeneral );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    if ( iParsedText )
+        {
+        delete iParsedText;
+        iParsedText = NULL;
+        }
+        
+    iStyle.iLanguage = User::Language();
+    iStyle.iVoice    = KDefaultVoiceNameFemale;
+    iStyle.iQuality  = ETtsQualityLowOnly;
+    
+    iParsedText = CTtsParsedText::NewL();
+    iParsedText->SetPhonemeNotationL( KNullDesC );
+    iParsedText->SetTextL( input );
+    
+    iSegment.SetStyle( iStyle );
+    iStyle = iSegment.StyleL();
+    iSegment.ResetStyle();
+    
+    iSegment.SetTrailingSilenceL( iSegment.TrailingSilence() );
+    
+    iSegment.SetStyleID( iTtsUtility->AddStyleL( iStyle ) );
+    iSegment.SetTextPtr( iParsedText->Text() );
+    iParsedText->AddSegmentL( iSegment );   
+    
+    if ( iParsedText->IsValid() )
+        {
+        result = KErrNone;
+        iTtsUtility->OpenParsedTextL( *iParsedText );
+        }
+        
+    return result;
+    }
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenAndPlayDesL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenAndPlayDesL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayDesL") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    iTtsUtility->OpenAndPlayDesL( input );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenAndPlayDes8L
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenAndPlayDes8L( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayDes8L") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    HBufC8* input8 = HBufC8::NewLC( 4 * input.Length() );
+    TPtr8 refText = input8->Des();
+    
+    User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) );
+
+    iTtsUtility->OpenAndPlayDesL( *input8 );
+    
+    CleanupStack::PopAndDestroy( input8 );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenAndPlayFileL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenAndPlayFileL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayFileL") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+        
+    iTtsUtility->OpenAndPlayFileL( input );
+    
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenAndPlayParsedTextL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::OpenAndPlayParsedTextL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayParsedTextL") );
+    
+    TPtrC input;
+    User::LeaveIfError( aItem.GetNextString ( input ) );
+    
+    if ( iParsedText == NULL )
+        {
+        iStyle.iLanguage = User::Language();
+        iStyle.iVoice    = KDefaultVoiceNameFemale;
+        iStyle.iQuality  = ETtsQualityLowOnly;
+        
+        iParsedText = CTtsParsedText::NewL();
+        iParsedText->SetTextL( input );
+    
+        iSegment.SetStyleID( iTtsUtility->AddStyleL( iStyle ) );
+        iSegment.SetTextPtr( iParsedText->Text() );
+        iParsedText->AddSegmentL( iSegment );   
+        }
+        
+    iTtsUtility->OpenAndPlayParsedTextL( *iParsedText );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::SynthesisToFileL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::SynthesisToFileL( CStifItemParser& aItem )
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In SynthesisToFileL") );
+    
+    TPtrC fileName;
+    User::LeaveIfError( aItem.GetNextString ( fileName ) );
+    
+    User::LeaveIfError( iFs.Connect() );
+    User::LeaveIfError( iFs.ShareProtected() ); 
+    iFs.MkDirAll( fileName ); // Ignore error (KErrAlreadyExists comes quite often)
+    
+    User::LeaveIfError( iFile.Replace( iFs, fileName, EFileWrite ) ); 
+    
+    iTtsUtility->SetOutputFileL( iFile );
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::CustomCommandsL
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::CustomCommandsL()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In CustomCommandsL") );
+    
+    TUid openPlugin = OpenPluginL();
+    TMMFMessageDestinationPckg destination( openPlugin );
+    
+    TBuf8<2> dataTo;
+    dataTo.AppendNum( 1 );    
+
+    TInt err1 = iTtsUtility->CustomCommandSync( destination, ETtsCustomCommandSetAudioOutput, 
+                                                dataTo, KNullDesC8 );
+    
+    TBuf8<16> dataFrom;
+    TInt err2 = iTtsUtility->CustomCommandSync( destination, ETtsCustomCommandSetAudioOutput, 
+                                                dataTo, KNullDesC8, dataFrom );
+
+    TRequestStatus status1( KRequestPending );
+    iTtsUtility->CustomCommandAsync( destination, ETtsCustomCommandSetAudioOutput, 
+                                     dataTo, KNullDesC8, status1 );
+    User::WaitForRequest( status1 );
+    
+    TRequestStatus status2( KRequestPending );
+    iTtsUtility->CustomCommandAsync( destination, ETtsCustomCommandSetAudioOutput, 
+                                    dataTo, KNullDesC8, dataFrom, status2 );
+    
+    User::WaitForRequest( status2 );
+    
+    TInt result( KErrNone );
+    
+    if ( err1 || err2 || status1.Int() || status2.Int() )
+        {
+        result = KErrGeneral;
+        }
+    
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::CustomCommands2L
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Cttsutilitytest::CustomCommands2L()
+    {
+    TestModuleIf().Printf( 0, Kttsutilitytest, _L("In CustomCommands2L") );
+    
+    const TUid KUidTtsPlugin = { 0x101FF934 };
+    
+    RMMFController controller;
+    RTtsCustomCommands ttsCustomCommands( controller );
+    TMMFPrioritySettings prioritySettings;
+    
+    User::LeaveIfError( controller.Open( KUidTtsPlugin, prioritySettings ) );
+    
+    TUint16 count;
+    User::LeaveIfError( ttsCustomCommands.NumberOfStyles( count ) );
+    
+    if ( count > 0 )
+        {
+        TTtsStyleID styleId( 0 );
+        User::LeaveIfError( ttsCustomCommands.Style( styleId, iStyle ) );
+        
+        TUint16 styleId16( 0 );
+        User::LeaveIfError( ttsCustomCommands.Style( styleId16, iStyle ) );
+        }
+        
+    controller.Close();
+    
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::OpenPluginL
+// 
+// -----------------------------------------------------------------------------
+//
+TUid Cttsutilitytest::OpenPluginL()
+    {
+    const TUid KUidTtsPlugin = { 0x101FF934 };
+    
+    RArray<TUid> uids;
+    CleanupClosePushL( uids );    
+    iTtsUtility->ListPluginsL( uids );
+    
+    TInt index = uids.Find( KUidTtsPlugin );
+    TUid openUid( KNullUid );
+    
+    if ( index >= 0 )
+        {
+        openUid = uids[index];
+        }
+    else if ( uids.Count() > 0 )
+        {
+        openUid = uids[0];
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    iTtsUtility->OpenPluginL( openUid );
+    
+    CleanupStack::PopAndDestroy( &uids );
+    
+    return openUid;
+    }
+
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::MapcInitComplete
+//
+// -----------------------------------------------------------------------------
+// 
+void Cttsutilitytest::MapcInitComplete( TInt aError, 
+                                        const TTimeIntervalMicroSeconds& /*aDuration*/ )
+    {
+    if ( aError )
+        {
+        User::Panic( Kttsutilitytest, aError );
+        }
+    
+    TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcInitComplete" ) );
+    TestModuleIf().Event( stifEvent );    
+    }
+    
+// -----------------------------------------------------------------------------
+// Cttsutilitytest::MapcPlayComplete
+//
+// -----------------------------------------------------------------------------
+// 
+void Cttsutilitytest::MapcPlayComplete( TInt aError )
+    {
+    if ( aError )
+        {
+        User::Panic( Kttsutilitytest, aError );
+        }
+    
+    TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcPlayComplete" ) );
+    TestModuleIf().Event( stifEvent );
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/bwins/nssttscommonu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,28 @@
+EXPORTS
+	??0TTtsSegment@@QAE@KABVTDesC16@@ABVTDesC8@@ABVTTimeIntervalMicroSeconds32@@@Z @ 1 NONAME ; TTtsSegment::TTtsSegment(unsigned long, class TDesC16 const &, class TDesC8 const &, class TTimeIntervalMicroSeconds32 const &)
+	??0TTtsStyle@@QAE@XZ @ 2 NONAME ; TTtsStyle::TTtsStyle(void)
+	??1CTtsParsedText@@UAE@XZ @ 3 NONAME ; CTtsParsedText::~CTtsParsedText(void)
+	?AddSegmentL@CTtsParsedText@@QAEXABVTTtsSegment@@H@Z @ 4 NONAME ; void CTtsParsedText::AddSegmentL(class TTtsSegment const &, int)
+	?DeleteSegmentL@CTtsParsedText@@QAEXH@Z @ 5 NONAME ; void CTtsParsedText::DeleteSegmentL(int)
+	?IsValid@CTtsParsedText@@QBEHXZ @ 6 NONAME ; int CTtsParsedText::IsValid(void) const
+	?NewL@CTtsParsedText@@SAPAV1@ABVTDesC16@@ABVTDesC8@@0@Z @ 7 NONAME ; class CTtsParsedText * CTtsParsedText::NewL(class TDesC16 const &, class TDesC8 const &, class TDesC16 const &)
+	?NumberOfSegments@CTtsParsedText@@QBEHXZ @ 8 NONAME ; int CTtsParsedText::NumberOfSegments(void) const
+	?PhonemeNotation@CTtsParsedText@@QBEABVTDesC16@@XZ @ 9 NONAME ; class TDesC16 const & CTtsParsedText::PhonemeNotation(void) const
+	?PhonemeSequence@CTtsParsedText@@QBEABVTDesC8@@XZ @ 10 NONAME ; class TDesC8 const & CTtsParsedText::PhonemeSequence(void) const
+	?PhonemeSequencePtr@TTtsSegment@@QBEABVTDesC8@@XZ @ 11 NONAME ; class TDesC8 const & TTtsSegment::PhonemeSequencePtr(void) const
+	?SegmentL@CTtsParsedText@@QBEABVTTtsSegment@@H@Z @ 12 NONAME ; class TTtsSegment const & CTtsParsedText::SegmentL(int) const
+	?SetPhonemeNotationL@CTtsParsedText@@QAEXABVTDesC16@@@Z @ 13 NONAME ; void CTtsParsedText::SetPhonemeNotationL(class TDesC16 const &)
+	?SetPhonemeSequenceL@CTtsParsedText@@QAEXABVTDesC8@@@Z @ 14 NONAME ; void CTtsParsedText::SetPhonemeSequenceL(class TDesC8 const &)
+	?SetPhonemeSequencePtr@TTtsSegment@@QAEXABVTDesC8@@@Z @ 15 NONAME ; void TTtsSegment::SetPhonemeSequencePtr(class TDesC8 const &)
+	?SetStyleID@TTtsSegment@@QAEXK@Z @ 16 NONAME ; void TTtsSegment::SetStyleID(unsigned long)
+	?SetTextL@CTtsParsedText@@QAEXABVTDesC16@@@Z @ 17 NONAME ; void CTtsParsedText::SetTextL(class TDesC16 const &)
+	?SetTextPtr@TTtsSegment@@QAEXABVTDesC16@@@Z @ 18 NONAME ; void TTtsSegment::SetTextPtr(class TDesC16 const &)
+	?SetTrailingSilenceL@TTtsSegment@@QAEXABVTTimeIntervalMicroSeconds32@@@Z @ 19 NONAME ; void TTtsSegment::SetTrailingSilenceL(class TTimeIntervalMicroSeconds32 const &)
+	?StyleID@TTtsSegment@@QBEKXZ @ 20 NONAME ; unsigned long TTtsSegment::StyleID(void) const
+	?Text@CTtsParsedText@@QBEABVTDesC16@@XZ @ 21 NONAME ; class TDesC16 const & CTtsParsedText::Text(void) const
+	?TextPtr@TTtsSegment@@QBEABVTDesC16@@XZ @ 22 NONAME ; class TDesC16 const & TTtsSegment::TextPtr(void) const
+	?TrailingSilence@TTtsSegment@@QBEABVTTimeIntervalMicroSeconds32@@XZ @ 23 NONAME ; class TTimeIntervalMicroSeconds32 const & TTtsSegment::TrailingSilence(void) const
+	?ResetStyle@TTtsSegment@@QAEXXZ @ 24 NONAME ; void TTtsSegment::ResetStyle(void)
+	?SetStyle@TTtsSegment@@QAEXAAVTTtsStyle@@@Z @ 25 NONAME ; void TTtsSegment::SetStyle(class TTtsStyle &)
+	?StyleL@TTtsSegment@@QAEAAVTTtsStyle@@XZ @ 26 NONAME ; class TTtsStyle & TTtsSegment::StyleL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/eabi/nssttscommonu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,36 @@
+EXPORTS
+	_ZN11TTtsSegment10SetStyleIDEm @ 1 NONAME
+	_ZN11TTtsSegment10SetTextPtrERK7TDesC16 @ 2 NONAME
+	_ZN11TTtsSegment19SetTrailingSilenceLERK27TTimeIntervalMicroSeconds32 @ 3 NONAME
+	_ZN11TTtsSegment21SetPhonemeSequencePtrERK6TDesC8 @ 4 NONAME
+	_ZN11TTtsSegmentC1EmRK7TDesC16RK6TDesC8RK27TTimeIntervalMicroSeconds32 @ 5 NONAME
+	_ZN11TTtsSegmentC2EmRK7TDesC16RK6TDesC8RK27TTimeIntervalMicroSeconds32 @ 6 NONAME
+	_ZN14CTtsParsedText11AddSegmentLERK11TTtsSegmenti @ 7 NONAME
+	_ZN14CTtsParsedText14DeleteSegmentLEi @ 8 NONAME
+	_ZN14CTtsParsedText19SetPhonemeNotationLERK7TDesC16 @ 9 NONAME
+	_ZN14CTtsParsedText19SetPhonemeSequenceLERK6TDesC8 @ 10 NONAME
+	_ZN14CTtsParsedText4NewLERK7TDesC16RK6TDesC8S2_ @ 11 NONAME
+	_ZN14CTtsParsedText8SetTextLERK7TDesC16 @ 12 NONAME
+	_ZN14CTtsParsedTextD0Ev @ 13 NONAME
+	_ZN14CTtsParsedTextD1Ev @ 14 NONAME
+	_ZN14CTtsParsedTextD2Ev @ 15 NONAME
+	_ZN9TTtsStyleC1Ev @ 16 NONAME
+	_ZN9TTtsStyleC2Ev @ 17 NONAME
+	_ZNK11TTtsSegment15TrailingSilenceEv @ 18 NONAME
+	_ZNK11TTtsSegment18PhonemeSequencePtrEv @ 19 NONAME
+	_ZNK11TTtsSegment7StyleIDEv @ 20 NONAME
+	_ZNK11TTtsSegment7TextPtrEv @ 21 NONAME
+	_ZNK14CTtsParsedText15PhonemeNotationEv @ 22 NONAME
+	_ZNK14CTtsParsedText15PhonemeSequenceEv @ 23 NONAME
+	_ZNK14CTtsParsedText16NumberOfSegmentsEv @ 24 NONAME
+	_ZNK14CTtsParsedText4TextEv @ 25 NONAME
+	_ZNK14CTtsParsedText7IsValidEv @ 26 NONAME
+	_ZNK14CTtsParsedText8SegmentLEi @ 27 NONAME
+	_ZTI14CTtsParsedText @ 28 NONAME ; #<TI>#
+	_ZTI18CTtsParsedTextBody @ 29 NONAME ; #<TI>#
+	_ZTV14CTtsParsedText @ 30 NONAME ; #<VT>#
+	_ZTV18CTtsParsedTextBody @ 31 NONAME ; #<VT>#
+	_ZN11TTtsSegment10ResetStyleEv @ 32 NONAME
+	_ZN11TTtsSegment6StyleLEv @ 33 NONAME
+	_ZN11TTtsSegment8SetStyleER9TTtsStyle @ 34 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for TtsCommon.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "../../group/srsfbldvariant.hrh"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nssttscommon.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/group/nssttscommon.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for TtsCommon.
+*
+*/
+
+
+#include "../../group/srsfbldvariant.hrh"
+#include <platform_paths.hrh>
+
+TARGET            nssttscommon.dll
+TARGETTYPE        DLL
+UID               0x1000008D 0x101FF927 // UID: 270530855
+
+VENDORID          VID_DEFAULT
+
+CAPABILITY        CAP_GENERAL_DLL
+
+SOURCEPATH        ../src
+SOURCE            nssttscommon.cpp
+SOURCE            ttscommonbody.cpp
+
+USERINCLUDE       ../inc ../src ../../group
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE     ../inc 
+
+LIBRARY           euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/group/std.lnt	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,6 @@
+//  Standard lint options
+-i..\inc
+-i..\ptssrc
+env-vc6.lnt                     //  Microsoft's Visual C++ 6.0
+au-sm.lnt                       //  Scott Meyers (Effective C++)
+epoc32.lnt                      //  EPOC32 options
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/src/nssttscommon.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,387 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common data types for TTS
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "srsfbldvariant.hrh"
+#include "ttscommonbody.h"
+#include "nssttscommon.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+// ----------------------------   TTtsStyle      -------------------------------
+
+// -----------------------------------------------------------------------------
+// TTtsStyle::TTtsStyle
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle::TTtsStyle() :
+    iLanguage( KTtsUndefinedLanguage ),
+	iVoice( KNullDesC ),
+    iRate( KTtsRateUndefined ),
+    iVolume( KTtsDefaultVolume ),
+    iSamplingRate( KTtsRateUndefined ),
+	iQuality( ETtsQualityUndefined ), 
+    iDuration( KTtsUndefinedDuration ),
+	iNlp( EFalse )
+    {
+    // nothing
+    }
+
+
+// ----------------------------   TTtsSegment    -------------------------------
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::TTtsSegment
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsSegment::TTtsSegment( 
+    const TTtsStyleID aStyleID, 
+	const TDesC& aText, 
+	const TDesC8& aPhonemeSequence, 
+    const TTimeIntervalMicroSeconds32& aTrailingSilenceDuration ) :
+    iStyleID( aStyleID ),
+    iText( aText ),
+    iPhonemeSequence( aPhonemeSequence ),
+    iTrailingSilenceDuration( aTrailingSilenceDuration ),
+    iIncludesStyle( EFalse )
+    {
+    // nothing
+    }
+        
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::SetTrailingSilenceL
+// Sets the duration of trailing silence
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TTtsSegment::SetTrailingSilenceL( 
+    const TTimeIntervalMicroSeconds32& aDuration )
+    {
+    iTrailingSilenceDuration = aDuration;
+    }
+
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::SetPhonemeSequencePtr
+// Sets phoneme sequence pointer
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TTtsSegment::SetPhonemeSequencePtr( 
+    const TDesC8& aPhonemeSequence )
+    {
+    iPhonemeSequence.Set( aPhonemeSequence );
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::PhonemeSequencePtr
+// Returns phoneme sequence pointer
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& TTtsSegment::PhonemeSequencePtr() const
+    {
+    return iPhonemeSequence;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::SetTextPtr
+// Sets text pointer
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TTtsSegment::SetTextPtr( 
+    const TDesC& aText )
+    {
+    iText.Set( aText );
+    }
+// -----------------------------------------------------------------------------
+// TTtsSegment::TrailingSilence
+// Gets duration of trailing silence
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTimeIntervalMicroSeconds32& TTtsSegment::TrailingSilence() const
+    {
+    return iTrailingSilenceDuration;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::TextPtr
+// Returns text pointer
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& TTtsSegment::TextPtr() const
+    {
+    return iText;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::SetStyleID
+// Sets style identifier
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TTtsSegment::SetStyleID( 
+    TTtsStyleID aStyleID )
+    {
+    iStyleID = aStyleID;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::StyleID
+// Returns style identifier
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyleID TTtsSegment::StyleID() const
+    {
+    return iStyleID;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::SetStyle
+// Sets the style object for this segment.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TTtsSegment::SetStyle( TTtsStyle& aStyle )
+    {
+    iStyle = aStyle;
+    iIncludesStyle = ETrue;
+    }
+        
+// -----------------------------------------------------------------------------
+// TTtsSegment::StyleL
+// Returns style object assigned to this segment.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle& TTtsSegment::StyleL()
+    {
+    if ( !iIncludesStyle )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return iStyle;
+    }
+
+// -----------------------------------------------------------------------------
+// TTtsSegment::ResetStyle
+// Resets style object, style id will be used instead.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TTtsSegment::ResetStyle()
+    {
+    iIncludesStyle = EFalse;
+    }
+
+// ----------------------------  CTtsParsedText  -------------------------------
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::CTtsParsedText
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsParsedText::CTtsParsedText() :
+    iBody( NULL ),
+    iReserved( NULL )
+    {
+    // nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedText::ConstructL(
+    const TDesC& aText, 
+    const TDesC8& aPhonemeSequence, 
+    const TDesC& aPhonemeNotation )
+    {
+    iBody = CTtsParsedTextBody::NewL( aText, 
+                                      aPhonemeSequence, 
+                                      aPhonemeNotation );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTtsParsedText* CTtsParsedText::NewL(
+    const TDesC& aText, 
+    const TDesC8& aPhonemeSequence, 
+    const TDesC& aPhonemeNotation )
+    {
+    CTtsParsedText* self = new( ELeave ) CTtsParsedText;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aText, 
+                      aPhonemeSequence, 
+                      aPhonemeNotation );
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+EXPORT_C CTtsParsedText::~CTtsParsedText()
+    {
+    delete iBody;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::AddSegmentL
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsParsedText::AddSegmentL( 
+    const TTtsSegment& aSegment,
+    TInt aIndex )
+    {
+    iBody->AddSegmentL( aSegment, aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::DeleteSegment
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsParsedText::DeleteSegmentL( 
+    TInt aIndex )
+    {
+    iBody->DeleteSegmentL( aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::IsValid
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsParsedText::IsValid() const
+    {
+    return iBody->IsValid();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::NumberOfSegments
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsParsedText::NumberOfSegments() const
+    {
+    return iBody->NumberOfSegments();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::PhonemeNotation
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CTtsParsedText::PhonemeNotation() const
+    {
+    return iBody->PhonemeNotation();
+    }
+	
+// -----------------------------------------------------------------------------
+// CTtsParsedText::PhonemeSequence
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CTtsParsedText::PhonemeSequence() const
+    {
+    return iBody->PhonemeSequence();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::SegmentL
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTtsSegment& CTtsParsedText::SegmentL( 
+    TInt aIndex ) const
+    {
+    return iBody->SegmentL( aIndex );
+    }
+	
+// -----------------------------------------------------------------------------
+// CTtsParsedText::SetPhonemeNotationL
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsParsedText::SetPhonemeNotationL( 
+    const TDesC& aPhonemeNotation )
+    {
+    iBody->SetPhonemeNotationL( aPhonemeNotation );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::SetPhonemeSequenceL
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsParsedText::SetPhonemeSequenceL( 
+    const TDesC8& aPhonemeSequence )
+    {
+    iBody->SetPhonemeSequenceL( aPhonemeSequence );
+    }
+	
+// -----------------------------------------------------------------------------
+// CTtsParsedText::SetTextL
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsParsedText::SetTextL( 
+    const TDesC& aText )
+    {
+    iBody->SetTextL( aText );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsParsedText::Text
+// Call corresponding function of CTtsParsedTextBody
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CTtsParsedText::Text() const
+    {
+    return iBody->Text();
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/src/ttscommonbody.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,424 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of TtsCommon 
+*
+*/
+
+
+// INCLUDE FILES
+#include "srsfbldvariant.hrh"
+#include "ttscommonbody.h"
+#include "nssttscommon.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::CTtsParsedTextBody
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsParsedTextBody::CTtsParsedTextBody() :
+    iText( NULL ),
+    iPhonemeSequence( NULL ),
+    iPhonemeNotation( NULL )
+    {
+    // nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedTextBody::ConstructL(
+    const TDesC& aText, 
+    const TDesC8& aPhonemeSequence, 
+    const TDesC& aPhonemeNotation )
+    {
+    
+    if ( aText != KNullDesC )
+        {
+        // copy text 
+        iText = HBufC::NewL( aText.Length() );
+        TPtr tempPtr( iText->Des() );
+        tempPtr = aText;
+        }
+    
+    if ( aPhonemeSequence != KNullDesC8 )
+        {
+        // copy phoneme sequence
+        iPhonemeSequence = HBufC8::NewL( aPhonemeSequence.Length() );
+        TPtr8 tempPtr8( iPhonemeSequence->Des() );
+        tempPtr8 = aPhonemeSequence;
+        }
+    
+    if ( aPhonemeNotation != KNullDesC )
+        {
+        // copy phoneme notation 
+        iPhonemeNotation = HBufC::NewL( aPhonemeNotation.Length() );
+        TPtr tempPtr( iPhonemeNotation->Des() );
+        tempPtr = aPhonemeNotation;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTtsParsedTextBody* CTtsParsedTextBody::NewL(
+    const TDesC& aText, 
+    const TDesC8& aPhonemeSequence, 
+    const TDesC& aPhonemeNotation )
+    {
+    CTtsParsedTextBody* self = new( ELeave ) CTtsParsedTextBody;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aText, 
+                      aPhonemeSequence, 
+                      aPhonemeNotation );
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CTtsParsedTextBody::~CTtsParsedTextBody()
+    {
+    delete iText;
+    delete iPhonemeSequence;
+    delete iPhonemeNotation;
+    iSegmentArray.Reset();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::AddSegmentL
+// Add new segment to array
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedTextBody::AddSegmentL( 
+    const TTtsSegment& aSegment,
+    TInt aIndex )
+    {
+    if ( aIndex < 0  )
+        {
+        User::Leave( KErrArgument ); // The index is negative
+        }
+    else if ( aIndex >= iSegmentArray.Count() )
+        {
+        // added to end
+        User::LeaveIfError( iSegmentArray.Append( aSegment ) );
+        }
+    else
+        {
+        // added into middle
+        User::LeaveIfError( iSegmentArray.Insert( aSegment, aIndex ) );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::DeleteSegment
+// Delete segment
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedTextBody::DeleteSegmentL( 
+    TInt aIndex )
+    {
+    if ( aIndex < 0 || aIndex >= iSegmentArray.Count() )
+        {
+        User::Leave( KErrArgument ); // The index is out of bounds.
+        }
+
+    iSegmentArray.Remove( aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::IsValid
+// Checks that segments do not overlap or pointer outside.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CTtsParsedTextBody::IsValid() const
+    {
+    TInt index( 0 );
+    
+    if ( iPhonemeSequence == NULL &&
+        iText == NULL &&
+        iSegmentArray.Count() > 0 )
+        {
+        // no phoneme sequence and no text but segments still exist
+        return EFalse;
+        }
+    
+    // check phoneme sequence part 
+    if ( iPhonemeSequence )
+        {
+        const TUint8* beginPhSeqPtr = iPhonemeSequence->Ptr();
+        const TUint8* endPhSeqPtr = iPhonemeSequence->Ptr() 
+            + iPhonemeSequence->Length() - 1;   
+        
+        for ( index = 0; index < iSegmentArray.Count(); index++ )
+            {
+            // check that pointers do not point outside
+            const TTtsSegment& segment = iSegmentArray[index];
+            const TDesC8& phSeq = segment.PhonemeSequencePtr();
+            if ( phSeq != KNullDesC8 )
+                {
+                const TUint8* phSeqPtr = phSeq.Ptr();
+                if ( phSeqPtr < beginPhSeqPtr || 
+                    phSeqPtr > endPhSeqPtr ||
+                    phSeqPtr + phSeq.Length() - 1 > endPhSeqPtr )
+                    {
+                    return EFalse;
+                    }
+                
+                
+                // check order and overlapping
+                if ( index > 0 )
+                    {
+                    const TDesC8& prevPhSeq
+                        = iSegmentArray[index - 1].PhonemeSequencePtr();
+                    if ( prevPhSeq == KNullDesC8 )
+                        {
+                        // all pointer must point to either null or valid data
+                        return EFalse;
+                        }
+                    
+                    const TUint8* prevEndPhSeqPtr 
+                        = prevPhSeq.Ptr() + prevPhSeq.Length() - 1;    
+                    if ( prevEndPhSeqPtr >= phSeqPtr )
+                        {
+                        return EFalse;
+                        }
+                    }
+                }
+            }
+        }
+    
+    // check phoneme sequence part 
+    if ( iText )
+        {
+        const TUint16* beginTextPtr = iText->Ptr();
+        const TUint16* endTextPtr = iText->Ptr() + iText->Length() - 1;
+        
+        for ( index = 0; index < iSegmentArray.Count(); index++ )
+            {
+            // check that pointers do not point outside
+            const TTtsSegment& segment = iSegmentArray[index];
+            const TDesC& text = segment.TextPtr();
+            if ( text != KNullDesC )
+                {
+                const TUint16* textPtr = text.Ptr();
+                if ( textPtr < beginTextPtr || 
+                    textPtr > endTextPtr ||
+                    textPtr + text.Length() - 1 > endTextPtr )
+                    {
+                    return EFalse;
+                    }
+                
+                // check order and overlapping
+                if ( index > 0 )
+                    {
+                    const TDesC& prevText = iSegmentArray[index - 1].TextPtr();
+                    if ( prevText == KNullDesC )
+                        {
+                        // all pointer must point to either null or valid data
+                        return EFalse;
+                        }
+                    const TUint16* prevEndTextPtr 
+                        = prevText.Ptr() + prevText.Length() - 1;    
+                    if ( prevEndTextPtr >= textPtr )
+                        {
+                        return EFalse;
+                        }
+                    }
+                }
+            }
+        }
+    
+    // all checks passed
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::NumberOfSegments
+// Return number of segments
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CTtsParsedTextBody::NumberOfSegments() const
+    {
+    return iSegmentArray.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::PhonemeNotation
+// Returns phoneme notation
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+const TDesC& CTtsParsedTextBody::PhonemeNotation() const
+    {
+    if ( iPhonemeNotation )
+        {
+        // Phoneme sequence has been set
+        return *iPhonemeNotation;
+        }
+    return KNullDesC;   
+    }
+	
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::PhonemeSequence
+// Returns phoneme sequence
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CTtsParsedTextBody::PhonemeSequence() const
+    {
+    if ( iPhonemeSequence )
+        {
+        // Phoneme sequence has been set
+        return *iPhonemeSequence;
+        }
+    return KNullDesC8;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::SegmentL
+// Returns segment of given index
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+const TTtsSegment& CTtsParsedTextBody::SegmentL( 
+    TInt aIndex ) const
+    {
+    if ( aIndex < 0 || aIndex >= iSegmentArray.Count() )
+        {
+        User::Leave( KErrArgument );
+        }
+    return iSegmentArray[aIndex];
+    }
+	
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::SetPhonemeNotationL
+// Sets phoneme notation
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedTextBody::SetPhonemeNotationL( 
+    const TDesC& aPhonemeNotation )
+    {
+    if ( !iPhonemeNotation )
+        {
+        // copy phoneme notation 
+        iPhonemeNotation = HBufC::NewL( aPhonemeNotation.Length() );
+        TPtr tempPtr( iPhonemeNotation->Des() );
+        tempPtr = aPhonemeNotation;
+        }   
+    else
+        {
+        TPtr bufferPtr( iPhonemeNotation->Des() );
+        if ( aPhonemeNotation.Length() > bufferPtr.MaxLength() )
+            {
+            // new buffer does not fit into old one
+            iPhonemeNotation->ReAllocL( aPhonemeNotation.Length() );   
+            bufferPtr.Set( iPhonemeNotation->Des() );
+            }
+        bufferPtr = aPhonemeNotation;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::SetPhonemeSequenceL
+// Sets phoneme sequence
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedTextBody::SetPhonemeSequenceL( 
+    const TDesC8& aPhonemeSequence )
+    {
+    
+    if ( !iPhonemeSequence )
+        {
+        // create new phoneme sequence
+        iPhonemeSequence = HBufC8::NewL( aPhonemeSequence.Length() );
+        TPtr8 tempPtr8( iPhonemeSequence->Des() );
+        tempPtr8 = aPhonemeSequence;
+        }
+    else
+        {
+        TPtr8 bufferPtr( iPhonemeSequence->Des() );
+        if ( aPhonemeSequence.Length() > bufferPtr.MaxLength() )
+            {
+            // new buffer does not fit into old one
+            iPhonemeSequence = iPhonemeSequence->ReAllocL( aPhonemeSequence.Length() );
+            bufferPtr.Set( iPhonemeSequence->Des() );
+            }
+        bufferPtr = aPhonemeSequence;
+        }
+     
+    }
+	
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::SetTextL
+// Sets text
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CTtsParsedTextBody::SetTextL( 
+    const TDesC& aText )
+    {
+    if ( !iText )
+        {
+        // create new text 
+        iText = HBufC::NewL( aText.Length() );
+        TPtr tempPtr( iText->Des() );
+        tempPtr = aText;
+        }
+    else 
+        {
+        TPtr bufferPtr( iText->Des() );
+        if ( aText.Length() > bufferPtr.MaxLength() )
+            {
+            // new buffer does not fit into old one
+            iText = iText->ReAllocL( aText.Length() ); 
+            bufferPtr.Set( iText->Des() );
+            }
+        bufferPtr = aText;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsParsedTextBody::Text
+// Returns text
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+const TDesC& CTtsParsedTextBody::Text() const
+    {
+    if ( iText )
+        {
+        // text has been set
+        return *iText;
+        }
+    return KNullDesC;
+    }
+
+//  End of File 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscommon/src/ttscommonbody.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Internal interface for TtsCommon
+*
+*/
+
+
+
+#ifndef TTSCOMMONBODY_H
+#define TTSCOMMONBODY_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32std.h>
+#include "srsfbldvariant.hrh"
+#include "ttscommonbody.h"
+#include "nssttscommon.h"
+
+// CLASS DECLARATION
+
+/**
+*  Class to store parsed text for TTS.
+*
+*  @lib ttscommon.lib
+*  @since 2.8
+*/
+class CTtsParsedTextBody : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+		* @param aText Text to be parsed.
+		* @param aPhonemeSequence Corresponding phoneme sequence. 
+		*        If the sequence is not given, it will be determined automatically.
+		* @param aPhonemeNotation Identifier of phoneme notation. 
+		*		 If the descriptor is empty, the TTS engine will use default notation.
+        */
+		static CTtsParsedTextBody* NewL( const TDesC& aText, 
+									     const TDesC8& aPhonemeSequence, 
+									     const TDesC& aPhonemeNotation);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTtsParsedTextBody();
+
+    public: // New functions
+
+        /**
+        * Adds new segment and takes its ownership.
+        * @since 2.8
+        * @param aSegment A new segment.aIndex Index where to add segment. 
+		*        If index is equal or larger than NumberOfSegments(), the segment will be added into end.
+        * @return None
+        */
+		void AddSegmentL( const TTtsSegment& aSegment, TInt aIndex );
+
+        /**
+        * Deletes a segment
+        * @since 2.8
+        * @param aIndex The index of segment to be deleted. The index must be 0..NumberOfSegments()-1.
+        * @return None
+        */
+		void DeleteSegmentL( TInt aIndex );
+
+        /**
+        * Checks that the internal structure is valid.
+        * @since 2.8
+        * @param None
+        * @return ETrue if valid and EFalse if invalid.
+        */
+        TBool IsValid() const;
+
+        /**
+        * Returns the number of segments.
+        * @since 2.8
+        * @param None
+        * @return The number of segments
+        */
+		TInt NumberOfSegments() const;
+
+        /**
+        * Returns phoneme notation definition.
+        * @since 2.8
+        * @param None
+        * @return Notation descriptor. KNullDesC8 if none.
+        */
+		const TDesC& PhonemeNotation() const;
+	
+        /**
+        * Returns phoneme sequence.
+        * @since 2.8
+        * @param None
+        * @return Phoneme sequence. KNullDesC8 if none.
+        */
+		const TDesC8& PhonemeSequence() const;
+
+        /**
+        * Returns segment from given index
+        * @since 2.8
+        * @param aIndex The index of segment to be deleted. The index must be 0..NumberOfSegments()-1.
+        * @return Requested segment.
+        */
+		const TTtsSegment& SegmentL( TInt aIndex ) const;
+	
+        /**
+        * Sets a phoneme notation. The descriptor is copied and can be released after the function call.
+        * @since 2.8
+        * @param aPhonemeNotation Phoneme notation.
+        * @return None
+        */
+		void SetPhonemeNotationL( const TDesC& aPhonemeNotation );
+
+        /**
+        * Sets a phoneme sequence. The descriptor is copied and can be released after the function call.
+        * @since 2.8
+        * @param aPhonemeSequence Phoneme sequence.
+        * @return None
+        */
+		void SetPhonemeSequenceL( const TDesC8& aPhonemeSequence );
+	
+        /**
+        * Sets a text. The descriptor is copied and can be released after the function call.
+        * @since 2.8
+        * @param aText Text.
+        * @return None
+        */
+		void SetTextL( const TDesC& aText );
+
+        /**
+        * Returns text.
+        * @since 2.8
+        * @param None
+        * @return Text. KNullDesC8 if none.
+        */
+		const TDesC& Text() const;
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTtsParsedTextBody();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( const TDesC& aText, 
+					     const TDesC8& aPhonemeSequence, 
+						 const TDesC& aPhonemeNotation );
+
+
+    private:    // Data
+        // Buffer containing text
+        HBufC* iText;
+
+        // Buffer containing phoneme sequence
+        HBufC8* iPhonemeSequence;
+
+        // Buffer containing phoneme notation
+        HBufC* iPhonemeNotation;
+
+        // Array containing segments
+        RArray<TTtsSegment> iSegmentArray;
+
+    };
+
+#endif      // TTSCOMMONBODY_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for TtsPlugin.
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+PRJ_MMPFILES
+nssttscontrollerplugin.mmp
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/group/nssttscontrollerplugin.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for TtsPlugin.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          nssttscontrollerplugin.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101FF933 // UID: 270530867
+
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          ttsplugin.cpp
+SOURCE          ttspluginbody.cpp
+SOURCE          ttsplugindataloader.cpp
+SOURCE          ttspluginresourcehandler.cpp
+
+START RESOURCE  ttspluginsettings.rss
+HEADER
+TARGET          ttspluginsettings.rsc
+TARGETPATH      resource
+END
+
+START RESOURCE  101ff933.rss
+TARGET          nssttscontrollerplugin.rsc
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../src
+USERINCLUDE	    ../../group  // for srsfbldvariant.hrh
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/mmf
+SYSTEMINCLUDE   /epoc32/include/mmf/server
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+// For RUBY_DEBUG
+USERINCLUDE     ../../rubydebug
+
+
+LIBRARY         euser.lib
+LIBRARY         mmfstandardcustomcommands.lib
+LIBRARY         mmfcontrollerframework.lib
+LIBRARY         mmfserverbaseclasses.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib  // Resource file
+LIBRARY         nssttscommon.lib
+LIBRARY         nssdevtts.lib
+LIBRARY         nssttscustomcommands.lib
+LIBRARY         charconv.lib
+LIBRARY         estlib.lib
+LIBRARY         sysutil.lib // SysUtil
+#ifdef EABI
+LIBRARY         ecom.lib
+#endif
+
+LANG            SC
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/101ff933.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM registration information of TTS Controller Plugin.
+*
+*/
+
+
+//  INCLUDES
+#include <registryinfo.rh>
+#include <mmfplugininterfaceuids.hrh>
+#include "ttspluginimplementationuids.hrh"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// theInfo
+// TTS Controller Plugin ECOM registration information.
+//
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = KTtsDllUidController;
+    interfaces = 
+        {
+        INTERFACE_INFO // Information for the controller plugin
+            {
+            // Basic controller interface
+            interface_uid = KMmfUidPluginInterfaceController;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KTtsImplementationUid;
+                    version_no = 1;
+                    display_name = "TTS Controller Plugin";
+                    default_data = "?";
+                    opaque_data = "<s>Nokia<i>0x101F5D07<p>0x101FF935<a>0x200000";
+                    // SUPPLIER = Nokia
+                    // MEDIA ID = ID for TTS text 0x101F5D07 ( = audio media type )
+                    // PLAY FORMATS = see KTtsInterfaceUidPlay 
+                    }
+                };
+            },
+        INTERFACE_INFO // TTS Play format
+            {
+            interface_uid = KTtsPlayInterfaceUid;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KTtsPlayImplementationUid;
+                    version_no = 1;
+                    display_name = "TTS Controller Plugin play";
+                    default_data = "?";
+                    opaque_data = "<s>Nokia<i>0x101F5D07<e>.txt<h>(tts)<m>text/plain";
+                    // SUPPLIER = Nokia
+                    // MEDIA ID = ID for TTS text 0x101F5D07 ( = audio media type )
+                    // FILE EXTENSION = .txt
+                    // HEADER DATA = .tts
+                    // MIME TYPE = text/plain
+                    }
+                };
+            }
+        };
+    }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/nssttscontrollerplugin.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Structure definition for resource file.
+*
+*/
+
+
+// STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// TTSPLUGIN_INFO
+// Structure definition for Tts Plugin resource file.
+// -----------------------------------------------------------------------------
+//
+STRUCT TTSPLUGIN_INFO
+    {
+    LTEXT ttp_general_filename;
+    LTEXT ttp_language_filename;
+    LTEXT ttp_filename_postfix;
+	LTEXT tts_filename;
+	LTEXT tts_filename_postfix;
+    WORD parameter1; // For future purposes
+    WORD parameter2; // For future purposes
+    WORD parameter3; // For future purposes
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttsplugin.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,867 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementations for CTtsControllerPlugin methods.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <implementationproxy.h>
+#include <mmfcontrollerframeworkbase.h>
+#include <nssttscustomcommandparser.h>
+#include <mmfaudio.h>
+#include "ttsplugin.h"
+#include "ttspluginbody.h"
+#include "ttspluginimplementationuids.hrh"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::CTtsControllerPlugin
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsControllerPlugin::CTtsControllerPlugin() : iBody( NULL )
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::ConstructL()
+    {
+    // Implementation body
+    iBody = CTtsControllerPluginBody::NewL( this );
+
+    CMMFAudioControllerCustomCommandParser* audConParser = CMMFAudioControllerCustomCommandParser::NewL( *this );
+    CleanupStack::PushL( audConParser );
+    // Parser now owned by controller framework
+    AddCustomCommandParserL( *audConParser ); 
+    CleanupStack::Pop( audConParser );
+
+    CMMFAudioPlayDeviceCustomCommandParser* audPlayDevParser = CMMFAudioPlayDeviceCustomCommandParser::NewL( *this );
+    CleanupStack::PushL( audPlayDevParser );
+    // Parser now owned by controller framework
+    AddCustomCommandParserL( *audPlayDevParser );
+    CleanupStack::Pop();//audPlayDevParser
+
+    CTtsCustomCommandParser* ttsParser = CTtsCustomCommandParser::NewL( *this );
+    CleanupStack::PushL( ttsParser );
+    // Parser now owned by controller framework
+    AddCustomCommandParserL( *ttsParser );
+    CleanupStack::Pop();//ttsParser
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTtsControllerPlugin* CTtsControllerPlugin::NewL()
+    {
+    CTtsControllerPlugin* self = new( ELeave ) CTtsControllerPlugin;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::~CTtsControllerPlugin
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTtsControllerPlugin::~CTtsControllerPlugin()
+    {
+    if ( iBody != NULL )
+        {
+        delete iBody;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::InitializationReady
+//
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::InitializationReady( TInt aError )
+    {
+    TMMFEvent event;
+    event.iEventType = KMMFEventCategoryAudioLoadingComplete;
+    event.iErrorCode = aError;
+
+    DoSendEventToClient( event );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::SynthesisReady
+//
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::SynthesisReady( TInt aError )
+    {
+    TMMFEvent event;
+    event.iEventType = KMMFEventCategoryPlaybackComplete;
+    event.iErrorCode = aError;
+
+    DoSendEventToClient( event );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::AddDataSourceL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::AddDataSourceL( MDataSource& aDataSource )
+    {
+    iBody->AddDataSourceL( aDataSource );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::AddDataSinkL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::AddDataSinkL( MDataSink& aDataSink )
+    {
+    iBody->AddDataSinkL( aDataSink );
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::RemoveDataSourceL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::RemoveDataSourceL( MDataSource& aDataSource )
+    {
+    iBody->RemoveDataSourceL( aDataSource );
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::RemoveDataSinkLn
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::RemoveDataSinkL( MDataSink& aDataSink )
+    {
+    iBody->RemoveDataSinkL( aDataSink );
+    }
+  
+      
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::ResetL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::ResetL()
+    {
+    iBody->ResetL();
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::PrimeL
+// ?Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::PrimeL()
+    {
+    iBody->PrimeL();
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::PlayL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::PlayL()
+    {
+    iBody->PlayL();
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::PauseL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::PauseL()
+    {
+    iBody->PauseL();
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::StopL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::StopL()
+    {
+    iBody->StopL();
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::PositionL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CTtsControllerPlugin::PositionL() const
+    {
+    return iBody->PositionL();
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::SetPositionL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::SetPositionL( const TTimeIntervalMicroSeconds& aPosition )
+    {
+    iBody->SetPositionL( aPosition );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::DurationL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CTtsControllerPlugin::DurationL() const
+    {
+    return iBody->DurationL();
+    }
+       
+ 
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::SetPrioritySettings
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings )
+    {
+    iBody->SetPrioritySettings( aPrioritySettings );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::CustomCommand
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::CustomCommand( TMMFMessage& aMessage )
+    {
+    iBody->CustomCommand( aMessage );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::GetNumberOfMetaDataEntriesL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::GetNumberOfMetaDataEntriesL( TInt& aNumberOfEntries )
+    {
+    iBody->GetNumberOfMetaDataEntriesL( aNumberOfEntries );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::GetMetaDataEntryL
+// Forwards call to implementation object.
+// -----------------------------------------------------------------------------
+//
+CMMFMetaDataEntry* CTtsControllerPlugin::GetMetaDataEntryL( TInt aIndex )
+    {
+    return iBody->GetMetaDataEntryL( aIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSourceSampleRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSourceSampleRateL( TUint aSampleRate )
+    {
+    iBody->MacSetSourceSampleRateL( aSampleRate );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSourceBitRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSourceBitRateL( TUint aBitRate )
+    {
+    iBody->MacSetSourceBitRateL( aBitRate );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSourceNumChannelsL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSourceNumChannelsL( TUint aNumChannels )
+    {
+    iBody->MacSetSourceNumChannelsL( aNumChannels );
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSourceFormatL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSourceFormatL( TUid aFormatUid )
+    {
+    iBody->MacSetSourceFormatL( aFormatUid );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSourceDataTypeL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSourceDataTypeL( TFourCC aDataType )
+    {
+    iBody->MacSetSourceDataTypeL( aDataType );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSinkSampleRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSinkSampleRateL( TUint aSampleRate )
+    {
+    iBody->MacSetSinkSampleRateL( aSampleRate );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSinkBitRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSinkBitRateL( TUint aRate )
+    {
+    iBody->MacSetSinkBitRateL( aRate );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSinkNumChannelsL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSinkNumChannelsL( TUint aNumChannels )
+    {
+    iBody->MacSetSinkNumChannelsL( aNumChannels );
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSinkFormatL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSinkFormatL( TUid aFormatUid )
+    {
+    iBody->MacSetSinkFormatL( aFormatUid );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetSinkDataTypeL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetSinkDataTypeL(  TFourCC aDataType )
+    {
+    iBody->MacSetSinkDataTypeL( aDataType );
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacSetCodecL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacSetCodecL( TFourCC aSourceDataType,
+                                         TFourCC aSinkDataType )
+    {
+    iBody->MacSetCodecL( aSourceDataType, aSinkDataType );
+    }
+        
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSourceSampleRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSourceSampleRateL( TUint& aRate )
+    {
+    iBody->MacGetSourceSampleRateL( aRate );
+    }
+       
+ 
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSourceBitRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSourceBitRateL( TUint& aRate )
+    {
+    iBody->MacGetSourceBitRateL( aRate );
+    }
+      
+  
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSourceNumChannelsL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSourceNumChannelsL( TUint& aNumChannels )
+    {
+    iBody->MacGetSourceNumChannelsL( aNumChannels );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSourceFormatL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+// 
+void CTtsControllerPlugin::MacGetSourceFormatL( TUid& aFormat )
+    {
+    iBody->MacGetSourceFormatL( aFormat );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSourceDataTypeL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSourceDataTypeL( TFourCC& aDataType )
+    {
+    iBody->MacGetSourceDataTypeL( aDataType );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSinkSampleRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSinkSampleRateL( TUint& aRate )
+    {
+    iBody->MacGetSinkSampleRateL( aRate );
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSinkBitRateL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSinkBitRateL( TUint& aRate )
+    {
+    iBody->MacGetSinkBitRateL( aRate );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSinkNumChannelsL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSinkNumChannelsL( TUint& aNumChannels )
+    {
+    iBody->MacGetSinkNumChannelsL( aNumChannels );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSinkFormatL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSinkFormatL( TUid& aFormat )
+    {
+    iBody->MacGetSinkFormatL( aFormat );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSinkDataTypeL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSinkDataTypeL( TFourCC& aDataType )
+    {
+    iBody->MacGetSinkDataTypeL( aDataType );
+    }
+       
+ 
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSourceSampleRatesL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSourceSampleRatesL( RArray<TUint>& aSupportedRates )
+    {
+    iBody->MacGetSupportedSourceSampleRatesL( aSupportedRates );
+    }
+     
+   
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSourceBitRatesL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSourceBitRatesL( RArray<TUint>& aSupportedRates )
+    {
+    iBody->MacGetSupportedSourceBitRatesL( aSupportedRates );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSourceNumChannelsL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSourceNumChannelsL( RArray<TUint>& aSupportedChannels )
+    {
+    iBody->MacGetSupportedSourceNumChannelsL( aSupportedChannels );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSourceDataTypesL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSourceDataTypesL( RArray<TFourCC>& aSupportedDataTypes )
+    {
+    iBody->MacGetSupportedSourceDataTypesL( aSupportedDataTypes );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSinkSampleRatesL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSinkSampleRatesL( RArray<TUint>& aSupportedRates )
+    {
+    iBody->MacGetSupportedSinkSampleRatesL( aSupportedRates );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSinkBitRatesL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSinkBitRatesL( RArray<TUint>& aSupportedRates )
+    {
+    iBody->MacGetSupportedSinkBitRatesL( aSupportedRates );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSinkNumChannelsL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSinkNumChannelsL( RArray<TUint>& aSupportedChannels )
+    {
+    iBody->MacGetSupportedSinkNumChannelsL( aSupportedChannels );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MacGetSupportedSinkDataTypesL
+// Not supported by TTS controller plugin.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MacGetSupportedSinkDataTypesL( RArray<TFourCC>& aSupportedDataTypes )
+    {
+    iBody->MacGetSupportedSinkDataTypesL( aSupportedDataTypes );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MapdSetVolumeL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MapdSetVolumeL( TInt aVolume ) 
+    {
+    iBody->MapdSetVolumeL( aVolume );
+    }
+       
+ 
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MapdGetMaxVolumeL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MapdGetMaxVolumeL( TInt& aMaxVolume )
+    {
+    iBody->MapdGetMaxVolumeL( aMaxVolume );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MapdGetVolumeL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MapdGetVolumeL( TInt& aVolume )
+    {
+    iBody->MapdGetVolumeL( aVolume );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MapdSetVolumeRampL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MapdSetVolumeRampL( const TTimeIntervalMicroSeconds& aRampDuration )
+    {
+    iBody->MapdSetVolumeRampL( aRampDuration );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MapdSetBalanceL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MapdSetBalanceL( TInt aBalance )
+    {
+    iBody->MapdSetBalanceL( aBalance );
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MapdGetBalanceL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MapdGetBalanceL( TInt& aBalance )
+    {
+    iBody->MapdGetBalanceL( aBalance );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscAddStyleL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TTtsStyleID CTtsControllerPlugin::MttscAddStyleL( const TTtsStyle& aStyle )
+    {
+    return iBody->MttscAddStyleL( aStyle );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscDeleteStyle
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsControllerPlugin::MttscDeleteStyle( TTtsStyleID aID )
+    {
+    return iBody->MttscDeleteStyle( aID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscGetPositionL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscGetPositionL( TInt& aWordIndex )
+    {
+    iBody->MttscGetPositionL( aWordIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscNumberOfStyles
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TUint16 CTtsControllerPlugin::MttscNumberOfStyles()
+    {
+    return iBody->MttscNumberOfStyles();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscOpenParsedTextL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscOpenParsedTextL( CTtsParsedText& aText )
+    {
+    iBody->MttscOpenParsedTextL( aText );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscSetPositionL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscSetPositionL( TInt aWordIndex )
+    {
+    iBody->MttscSetPositionL( aWordIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscAddStyleL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsControllerPlugin::MttscStyleL( TTtsStyleID aStyleID )
+    {
+    return iBody->MttscStyleL( aStyleID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscStyleL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsControllerPlugin::MttscStyleL( TUint16 aIndex )
+    {
+    return iBody->MttscStyleL( aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscSetDefaultStyleL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscSetDefaultStyleL( const TTtsStyle& aStyle )
+    {
+    iBody->MttscSetDefaultStyleL( aStyle );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscDefaultStyleL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsControllerPlugin::MttscDefaultStyleL()
+    {
+    return iBody->MttscDefaultStyleL();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscSetSpeakingRateL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscSetSpeakingRateL( TInt aRate )
+    {
+    iBody->MttscSetSpeakingRateL( aRate );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscSpeakingRateL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsControllerPlugin::MttscSpeakingRateL()
+    {
+    return iBody->MttscSpeakingRateL();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscGetSupportedLanguagesL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscGetSupportedLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    return iBody->MttscGetSupportedLanguagesL( aLanguages );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPlugin::MttscGetSupportedVoicesL
+// Forward call to the implementation object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPlugin::MttscGetSupportedVoicesL( TLanguage aLanguage, 
+                                                     RArray<TTtsStyle>& aVoices )
+    {
+    iBody->MttscGetSupportedVoicesL( aLanguage, aVoices );
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+/**
+* ImplementationTable
+*/
+const TImplementationProxy ImplementationTable[] =
+    {
+        {{ KTtsImplementationUid }, ( TProxyNewLPtr ) CTtsControllerPlugin::NewL }
+    };
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Needed for MMF Controller Plugin goodness.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+	{
+	aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+	return ImplementationTable;
+	}
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttsplugin.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,819 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface towards Tts Controller Plugin
+*
+*/
+
+
+
+#ifndef TTSPLUGIN_H
+#define TTSPLUGIN_H
+
+//  INCLUDES
+#include <mmfcontroller.h>
+#include <mmfstandardcustomcommands.h>
+#include <nssttscustomcommandimplementor.h>
+
+// FORWARD DECLARATIONS
+class CTtsControllerPluginBody;
+
+// CLASS DECLARATION
+
+/**
+* TTS controller plugin implementation
+*
+* @lib nssttsplugin.lib
+* @since 2.8
+*/
+class CTtsControllerPlugin : public CMMFController, 
+                             public MMMFAudioControllerCustomCommandImplementor,
+                             public MMMFAudioPlayDeviceCustomCommandImplementor,
+                             public MTtsCustomCommandImplementor
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CTtsControllerPlugin* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTtsControllerPlugin();
+        
+    public: // New functions
+        /**
+        * Called when initializations are ready
+        */
+        void InitializationReady( TInt aError );
+
+        /**
+        * Called when synthesis is ready
+        */
+        void SynthesisReady( TInt aError );
+
+    public: // MMMFAudioControllerCustomCommandImplementor
+        
+        /**
+        * Set the sample rate of the data source in samples per second.
+        *
+        * @param "aSampleRate" "The sample rate, in samples per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSourceSampleRateL(TUint aSampleRate);
+        
+        /**
+        * Set the bit rate of the data source in bits per second.
+        *
+        * @param "aSampleRate" "The bit rate, in bits per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSourceBitRateL(TUint aBitRate);
+        
+        /**
+        * Set the number of channels in the data source.
+        * For example, one channel for mono, two channels for stereo etc.
+        *
+        * @param "aNumChannels" "The number of channels."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSourceNumChannelsL(TUint aNumChannels);
+        
+        /**
+        * Set the format of the data source.
+        *
+        * The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin to be used.
+        * @param "aFormatUid" "The format plugin to be used."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSourceFormatL(TUid aFormatUid);
+        
+        /**
+        * Set the fourCC code of the source.
+        *
+        * @param "aDataType" "The fourCC code."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be 
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSourceDataTypeL(TFourCC aDataType);
+        
+        /**
+        * Set the sample rate of the data sink in samples per second.
+        *
+        * @param "aSampleRate" "The sample rate, in samples per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSinkSampleRateL(TUint aSampleRate);
+        
+        /**
+        * Set the bit rate of the data sink in bits per second.
+        *
+        * @param "aSampleRate" "The bit rate, in bits per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSinkBitRateL(TUint aRate);
+        
+        /**
+        * Set the number of channels in the data sink.
+        *
+        * For example, one channel for mono, two channels for stereo etc.
+        * @param "aNumChannels" "The number of channels."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSinkNumChannelsL(TUint aNumChannels);
+        
+        /**
+        * Set the format of the data sink. 
+        *
+        * The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin to be used.
+        * @param "aFormatUid" "The format plugin to be used."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSinkFormatL(TUid aFormatUid);
+        
+        /**
+        * Set the fourCC code of the sink.
+        *
+        * @param "aDataType" "The fourCC code."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetSinkDataTypeL(TFourCC aDataType);
+        
+        /**
+        * Set the codec to be used.  Useful when recording data.
+        * 
+        * @param "aSourceDataType" "The data type of the source of the codec."
+        * @param "aSinkDataType" "The data type of the sink of the codec."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacSetCodecL(TFourCC aSourceDataType, TFourCC aSinkDataType);
+        
+        
+        /**
+        * Get the sample rate of the data source in samples per second.
+        *
+        * @param "aRate" "The sample rate, in samples per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSourceSampleRateL(TUint& aRate);
+        
+        /**
+        * Get the bit rate of the data source in bits per second.
+        *
+        * @param "aRate" "The bit rate, in bits per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSourceBitRateL(TUint& aRate);
+        
+        /**
+        * Get the number of channels in the data source.
+        *
+        * For example, one channel for mono, two channels for stereo etc.
+        * @param "aNumChannels" "The number of channels."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * since 2.8
+        */
+        void MacGetSourceNumChannelsL(TUint& aNumChannels);
+        
+        /**
+        * Get the format of the data source.  
+        * 
+        * The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin being used.
+        * @param "aFormatUid" "The format plugin being used."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSourceFormatL(TUid& aFormat);
+        
+        /**
+        * Get the fourCC code of the source.
+        *
+        * @param "aDataType" "The fourCC code."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSourceDataTypeL(TFourCC& aDataType);
+        
+        /**
+        * Get the sample rate of the data sink in samples per second.
+        *
+        * @param "aRate" "The sample rate, in samples per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSinkSampleRateL(TUint& aRate);
+        
+        /**
+        * Get the bit rate of the data sink in bits per second.
+        *
+        * @param "aRate" "The bit rate, in bits per second."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSinkBitRateL(TUint& aRate);
+        
+        /**
+        * Get the number of channels in the data sink.
+        *
+        * For example, one channel for mono, two channels for stereo etc.
+        * @param "aNumChannels" "The number of channels."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSinkNumChannelsL(TUint& aNumChannels);
+        
+        /**
+        * Get the format of the data sink.  
+        *
+        * The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin being used.
+        * @param "aFormatUid" "The format plugin being used."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSinkFormatL(TUid& aFormat);
+        
+        /**
+        * Get the fourCC code of the sink.
+        *
+        * @param "aDataType" "The fourCC code."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSinkDataTypeL(TFourCC& aDataType);
+        
+        
+        /**
+        * Get the list of sample rates supported by the data source.
+        * 
+        * @param "aSupportedRates" "The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSourceSampleRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        * Get the list of bit rates supported by the data source.
+        *
+        * @param "aSupportedRates" "The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSourceBitRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        * Get the list of channels supported by the data source L(ie mono, stereo etc).
+        *
+        * @param "aSupportedChannels" "The supported channels.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSourceNumChannelsL(RArray<TUint>& aSupportedChannels);
+        
+        /**
+        * Get the list of fourCC codes supported by the data source.
+        *
+        * @param "aSupportedDataTypes" "The supported data types.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSourceDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
+        
+        /**
+        * Get the list of sample rates supported by the data sink.
+        *
+        * @param "aSupportedRates" "The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSinkSampleRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        * Get the list of bit rates supported by the data sink.
+        *
+        * @param "aSupportedRates" "The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSinkBitRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        * Get the list of channels supported by the data sink L(ie mono, stereo etc).
+        *
+        * @param "aSupportedChannels" "The supported channels.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSinkNumChannelsL(RArray<TUint>& aSupportedChannels);
+        
+        /**
+        * Get the list of fourCC codes supported by the data sink.
+        * @param "aSupportedDataTypes" "The supported data types.  Warning: Existing objects in this array will be removed by this method."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MacGetSupportedSinkDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
+
+
+    public: // From MMMFAudioPlayDeviceCustomCommandImplementor
+
+        /**
+        * Set the volume of the sound device.
+        *
+        * @param "aVolume" "The new volume"
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MapdSetVolumeL(TInt aVolume);
+        
+        /**
+        * Get the maximum volume supported by the sound device.
+        * @param "aMaxVolume" "The maximum volume, to be filled in by the controller plugin."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MapdGetMaxVolumeL(TInt& aMaxVolume);
+        
+        /**
+        * Get the current playback volume.
+        * @param "aVolume" "The volume, to be filled in by the controller."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MapdGetVolumeL(TInt& aVolume);
+        
+        /**
+        * Set a volume ramp.
+        *
+        * This will cause the sound device to start playing with zero volume,
+        * increasing the volume over aRampDuration microseconds.
+        *
+        * The volume ramp can be removed by setting the ramp duration to zero.
+        *
+        * @param "aRampDuration" "The duration over which the volume is to be 
+        *                        increased, in microseconds."
+        * @leave "This function can leave with one of the system-wide error codes. 
+        *        The request will be completed with the leave code."
+        */
+        void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
+        
+        /**
+        * Set the balance between the left and right stereo audio channels.
+        *
+        * @param "aBalance" "Use a value between <code>KMMFBalanceMaxLeft<\code> and 
+        * <code>KMMFBalanceMaxRight<\code>. Centre balance can be restored by using
+        * <code>KMMFBalanceCenter<\code>."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MapdSetBalanceL(TInt aBalance);
+        
+        /**
+        * Retrieve the balance between the left and right stereo audio channels.
+        *
+        * @param "aBalance""The current balance, filled in by the controller."
+        * @leave "This function can leave with one of the system-wide error codes. The request will be
+        * completed with the leave code."
+        * @since 2.8
+        */
+        void MapdGetBalanceL(TInt& aBalance);
+
+
+    public: // MTtsCustomCommandImplementor
+        
+        /**
+        * Adds a new style.
+        *
+        * @param "TTtsStyle& aStyle" Style to add.
+        * @since 2.8
+        */
+        TTtsStyleID MttscAddStyleL( const TTtsStyle& aStyle );
+
+        /**
+        * Deletes a style based on style ID.
+        *
+        * @param "TTtsStyleID aID" Style ID to be deleted.
+        * @since 2.8
+        */
+        TInt MttscDeleteStyle( TTtsStyleID aID );
+
+        /**
+        * Gets the synthesis position.
+        *
+        * @retval "TInt& aWordIndex" Returned position of synthesis.
+        * @since 2.8
+        */
+        void MttscGetPositionL( TInt& aWordIndex );
+
+        /**
+        * Returns the number of registered styles.
+        *
+        * @return Number of styles.
+        * @since 2.8
+        */
+        TUint16 MttscNumberOfStyles();
+
+        /**
+        * Opens parsed text as source.
+        *
+        * @param "CTtsParsedText& aText" Reference to parsed text.
+        * @since 2.8
+        */
+        void MttscOpenParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Sets the synthesis position based on word index.
+        *
+        * @param "TInt aWordIndex" Word index.
+        * @since 2.8
+        */
+        void MttscSetPositionL( TInt aWordIndex );
+
+        /**
+        * Returns the style based on ID.
+        *
+        * @param "TTtsStyleID aStyleID" Style ID.
+        * @return Reference to style object.
+        * @since 2.8
+        */
+        TTtsStyle& MttscStyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Returns the style based on index.
+        *
+        * @param "TUint16 aIndex" Style index.
+        * @return Reference to style object.
+        * @since 2.8
+        */
+        TTtsStyle& MttscStyleL( TUint16 aIndex );
+
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        * @since 3.2        
+        */        
+        void MttscSetDefaultStyleL( const TTtsStyle& aStyle );
+        
+        /**
+        * Returns the registered default style
+        *
+        * @return Style reference
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2             
+        */
+        TTtsStyle& MttscDefaultStyleL();
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @param TInt aRate Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @since 3.2        
+        */        
+        void MttscSetSpeakingRateL( TInt aRate );
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        TInt MttscSpeakingRateL();
+      
+        /**
+        * Returns the list of supported languages.
+        * 
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which contains 
+        *        the languages
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2        
+        */
+        void MttscGetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+        
+        /**
+        * Returns the list of supported voices for a certain language.
+        * 
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TTtsStyle>& aVoices" Output parameter which contains the voices
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        * @since 3.2
+        */        
+        void MttscGetSupportedVoicesL( TLanguage aLanguage, RArray<TTtsStyle>& aVoices );
+
+    protected:  // Functions from CMMFController
+        
+        /**
+        * Add a data source to the controller plugin.
+        *
+        *  @param "aDataSource"	"A reference to the data source to be added.
+        *         The controller plugin may call <code>aDataSource.DataSourceType()
+        *         <\code> to find out exactly what type of source it is."
+        * @leave "" "The controller plugin may leave during this method.  
+        *        If the controller plugin does not support the data source, it 
+        *         should leave with <code>KErrNotSupported<\code>.
+        * @since 2.8
+        */
+        void AddDataSourceL( MDataSource& aDataSource );
+        
+        /**
+        * Add a data sink to the controller plugin.
+        *
+        * @param "aDatasink" "A reference to the data sink to be added.
+        *        The controller plugin may call <code>aDatasink.DatasinkType()
+        *        <\code> to find out exactly what type of sink it is."
+        * @leave "" "The controller plugin may leave during this method.
+        *        If the controller plugin does not support the data sink, it 
+        * should leave with <code>KErrNotSupported<\code>.
+        * @since 2.8
+        */
+        void AddDataSinkL( MDataSink& aDataSink );
+        
+        /**
+        * Remove a data source from the controller plugin.
+        *
+        * @param "aDataSource" A reference to the data source to be removed.
+        * @leave "" "The controller plugin may leave during this method.
+        *        If the controller plugin does not support the removal of data 
+        *        sources, it should leave with <code>KErrNotSupported<\code>.
+        *        If the controller plugin leaves, the data source will not be 
+        *        destroyed by the controller framework.  If it does not leave, 
+        *        the data source will be destroyed.
+        * @since 2.8
+        */
+        void RemoveDataSourceL( MDataSource& aDataSource );
+        
+        /**
+        * Remove a data sink from the controller plugin.
+        *
+        * @param "aDatasink" A reference to the data sink to be removed.
+        * @leave "" "The controller plugin may leave during this method.
+        * If the controller plugin does not support the removal of data sinks, 
+        * it should leave with <code>KErrNotSupported<\code>. If the 
+        * controller plugin leaves, the data sink will not be destroyed by 
+        * the controller framework.  If it does not leave, the data sink
+        * will be destroyed.
+        * @since 2.8
+        */
+        void RemoveDataSinkL( MDataSink& aDataSink );
+        
+        /**
+        * Reset the controller plugin.
+        *
+        * The controller should revert back to its newly constructed state. If 
+        * the Reset is successful (i.e. it doesn't leave), the controller 
+        * framework will delete all objects added to the MMFObjectManager 
+        * including any sources and sinks.
+        *
+        * @leave "" "The controller plugin may leave during this method.
+        *        If the controller plugin does not support being reset, 
+        *        it should leave with <code>KErrNotSupported<\code>."
+        * @since 2.8
+        */
+        void ResetL();
+        
+        /**
+        * Prime the controller plugin.
+        *
+        * The controller must prepare to start playing, by initialising its 
+        * sources, sinks and buffers. This moves the controller from the 
+        * STOPPED to the PRIMED state.
+        *
+        * @leave "" "The controller plugin may leave during this method with
+        * any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        void PrimeL();
+        
+        /**
+        * Commence playback.
+        *
+        * The controller must now begin transferring data from its source(s) 
+        * to its sink(s). This moves the controller from the PRIMED to the 
+        * PLAYING state.
+        *
+        * Note: this method must return once playing has commenced, and not 
+        * wait until playing is complete.
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        void PlayL();
+        
+        /**
+        * Pause the controller plugin.
+        *
+        * The controller must now cease transferring data from its source(s) 
+        * to its sink(s). This moves the controller from the PLAYING back to 
+        * the PRIMED state.
+        *
+        * A subsequent call to <code>Play()<\code> will cause the controller 
+        * plugin to resume playback from the point it was paused (unless 
+        * there has been a call to <code>SetPosition()<\code> in the meantime.
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        void PauseL();
+        
+        /**
+        * Stop the controller plugin.
+        *
+        * The controller must now undo anything that occurred during the call 
+        * to <code>Prime()<\code>. This moves the controller from the PRIMED 
+        * back to the STOPPED state.
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        void StopL();
+        
+        /**
+        * Get the current position.
+        *
+        * The controller plugin should calculate the current position in microseconds.
+        *
+        * @return "The current position in microseconds."
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        TTimeIntervalMicroSeconds PositionL() const;
+        
+        /**
+        * Set the current position.
+        *
+        * The controller plugin should reposition itself to the position provided.
+        *
+        * @param "The desired position in microseconds."
+        * @leave "" "The controller plugin may leave during this method with
+        *         any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        void SetPositionL( const TTimeIntervalMicroSeconds& aPosition );
+        
+        /**
+        * Get the duration of the clip.
+        *
+        * The controller plugin should calculate the clip duration in microseconds.
+        *
+        * @return "The clip duration in microseconds."
+        * @leave "" "The controller plugin may leave during this method with
+        *         any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        TTimeIntervalMicroSeconds DurationL() const;
+        
+        /**
+        * Set the priority settings.
+        *
+        * The new priority settings must be applied to any resource being used 
+        * by the controller plugin that requires priority settings (for example 
+        * the sound device).
+        *
+        * @param "aPrioritySettings" "The new priority settings"
+        * @since 2.8
+        */
+        void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings );
+        
+        /**
+        * Handle a custom command.
+        *
+        * Custom commands allow a controller plugin to define its own API.
+        * If the controller framework does not understand a message from the 
+        * client, it is assumed this is a custom command for the plugin and 
+        * passed into this interface.
+        *
+        * The more common custom commands can be handled by Custom Command 
+        * Parsers on behalf of the controller plugin.  This allows the 
+        * controller plugin to implement a concrete interface (defined by 
+        * mixin classes) rather than having to decode the command itself.
+        * For more information, @see CMMFCustomCommandParserBase.
+        *
+        * The controller plugin must always complete the message passed 
+        * into this method, even if it does not support the interface 
+        * required by the message.
+        *
+        * @param "aMessage" "The message to be handled by the controller plugin."
+        * @since 2.8
+        */
+        void CustomCommand( TMMFMessage& aMessage );
+        
+        /**
+        * Retrieve the number of meta data entries in the clip.
+        *
+        * @param "aNumberOfEntries" "The controller plugin must set this to 
+        * the number of meta data entries in the clip."
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        void GetNumberOfMetaDataEntriesL( TInt& aNumberOfEntries );
+        
+        /**
+        * Retrieve a meta data entry from the clip.
+        *
+        * @param "aIndex" "The index of the meta data entry to retrieve."
+        * @return "A pointer to a newly created CMMFMetaDataEntry object 
+        *         containing the meta information. The controller framework 
+        *         will take ownership of the object when this method returns."
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        * @since 2.8
+        */
+        CMMFMetaDataEntry* GetMetaDataEntryL( TInt aIndex );
+
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CTtsControllerPlugin();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor.
+        CTtsControllerPlugin( const CTtsControllerPlugin& );
+        // Prohibit assigment operator.
+        CTtsControllerPlugin& operator=( const CTtsControllerPlugin& );
+        
+    private: // Data
+
+        // Implementation class
+        CTtsControllerPluginBody* iBody;
+        
+        // Reserved pointer for future extension
+        TAny* iReserved;
+        
+    };
+
+#endif // TTSPLUGIN_H   
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttspluginbody.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1442 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementations for CTtsControllerPluginBody methods.
+*
+*/
+
+
+// INCLUDE FILES
+#include <AudioPreference.h>
+#include <e32base.h>
+#include <mmfdes.h>
+#include <mmffile.h>
+#include <reent.h>
+#include <sysutil.h>
+#include <utf.h>
+
+#include "ttsplugin.h"
+#include "ttspluginbody.h"
+#include "ttsplugindataloader.h"
+#include "ttspluginresourcehandler.h"
+#include "rubydebug.h"
+#include "srsfbldvariant.hrh"
+
+// CONSTANTS
+// Playback state
+const TInt KPlay = 1; 
+
+// Package types for general & language specific TTP data
+// const TUint32 KTtpGeneralDataPackageType = 1;
+const TUint32 KTtpLanguageDataPackageType = 0;
+const TUint32 KTtsDataPackageType = 2;
+
+// Header used to direct input to us from CMdaAudioPlayerUtility
+_LIT8( KTtsContentHeader, "(tts)" );
+
+// TTS language can be set by adding "(l:lang_id)" to the beginning of descriptor
+// or file input. 
+_LIT8( KTtsLanguageStartTag, "(l:" );
+_LIT8( KTtsLanguageEndTag, ")" );
+
+_LIT( KTextFileExtension, ".txt" );
+
+const TInt KSamplingRate = 16000; // Hz
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::CTtsControllerPluginBody
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsControllerPluginBody::CTtsControllerPluginBody( CTtsControllerPlugin* aObserver ) : 
+    CActive( CActive::EPriorityStandard ),
+    iObserver( aObserver ),
+    iTtsOutputMode( EDevTTSSoundDeviceMode ) 
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::ConstructL()
+    {
+    RUBY_DEBUG1( "CTtsControllerPluginBody::ConstructL [%x]", this );
+
+    User::LeaveIfError( iFs.Connect() );
+
+    // Loads resource file
+    CTtsPluginResourceHandler* resourceHandler = 
+        CTtsPluginResourceHandler::NewL( iFs );
+
+    TFileName generalTTPFileName( *resourceHandler->iTtpGeneralFilename );
+    TFileName languageTTPFileName( *resourceHandler->iTtpLanguangeFilename );
+    TFileName postfixOfTTPFileName( *resourceHandler->iTtpFilenamePostfix );
+    TFileName TTSFileName( *resourceHandler->iTtsFilename );
+    TFileName postfixOfTTSFileName( *resourceHandler->iTtsFilenamePostfix );
+
+    delete resourceHandler; 
+    resourceHandler = NULL;
+    
+    // TTP Data loader
+    iTtsLoader = CTTSDataLoader::NewL( iFs,
+                                       generalTTPFileName, 
+                                       languageTTPFileName, 
+                                       postfixOfTTPFileName,
+                                       TTSFileName,
+                                       postfixOfTTSFileName );
+
+    // DevTTS
+    iDevTts = CDevTTS::NewL( *this );
+
+    // Add default style to DevTTS
+    iDefaultStyleID = iDevTts->AddStyleL( iDefaultStyle );
+
+    // Add ourselves to active scheduler
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTtsControllerPluginBody* CTtsControllerPluginBody::NewL( CTtsControllerPlugin* aObserver )
+    {
+    CTtsControllerPluginBody* self = new( ELeave ) CTtsControllerPluginBody( aObserver );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::~CTtsControllerPluginBody
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTtsControllerPluginBody::~CTtsControllerPluginBody()
+    {
+    delete iParsedTextPointer;
+    delete iDevTts;
+    delete iTtsLoader;
+    
+    iFs.Close();
+    
+    CloseSTDLIB();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::AddDataSourceL
+// Adds data suorce.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::AddDataSourceL( MDataSource& aDataSource )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::AddDataSourceL" );
+
+    iEarlyPrimingDone = EFalse;
+
+    // Check the source type
+    if ( aDataSource.DataSourceType() == KUidMmfDescriptorSource )
+        {
+        CMMFDescriptor* des = STATIC_CAST( CMMFDescriptor*, &aDataSource );
+
+        RUBY_DEBUG1( "Descriptor source detected, size: %x bytes", des->Size() );
+
+        // Copy data to CMMFDescriptorBuffer
+        CMMFDescriptorBuffer* desBuf = CMMFDescriptorBuffer::NewL( des->Size() );
+        CleanupStack::PushL( desBuf );
+        des->ReadBufferL( desBuf, 0 );
+      
+        // To 'normal' descriptor
+        TDes8& descriptor = desBuf->Data();
+
+        RUBY_DEBUG1( "Created descriptor, size: %x", descriptor.Size() );
+
+        ConstructParsedTextL( descriptor );
+
+        CleanupStack::PopAndDestroy( desBuf );
+          
+        DoEarlyPrimingL();
+        }
+    else if ( aDataSource.DataSourceType() == KUidMmfFileSource )
+        {
+        RUBY_DEBUG0( "File source detected" );
+        
+        CMMFFile* mmfFile = STATIC_CAST( CMMFFile*, &aDataSource );
+        
+        RUBY_DEBUG1( "Filename: %s", mmfFile->FullName().Ptr() );
+        
+        // Check that correct filename extension is used
+        if ( mmfFile->FullName().Find( KTextFileExtension ) == KErrNotFound )
+            {
+            User::Leave( KErrNotSupported );
+            }
+        
+        // Open file first if not yet open
+        mmfFile->SourcePrimeL();
+        RFile file( mmfFile->FileL() );
+        
+        // Find the size of tts input file
+        TInt fileSize( 0 );
+        User::LeaveIfError( file.Size( fileSize ) );
+        
+        // Create buffer for data
+        HBufC8* fileBuffer = HBufC8::NewLC( fileSize );
+                
+        // Make sure we are in the beginnig of the file
+        TInt tmp( 0 );
+        file.Seek( ESeekStart, tmp );
+        
+        // Read data
+        TPtr8 bufferPtr( fileBuffer->Des() );
+        User::LeaveIfError( file.Read( bufferPtr ) );
+        
+        ConstructParsedTextL( bufferPtr );
+        
+        // No need to store the 8-bit text
+        CleanupStack::PopAndDestroy( fileBuffer );
+        
+        DoEarlyPrimingL();    
+        }
+    else
+        {
+        RUBY_ERROR0( "Unknown source!" );
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::AddDataSinkL
+// Adds data sink.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::AddDataSinkL( MDataSink& aDataSink )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::AddDataSinkL" );
+    
+    if ( aDataSink.DataSinkType() == KUidMmfAudioOutput )
+        {
+        iTtsOutputMode = EDevTTSSoundDeviceMode;
+        }
+    else if ( aDataSink.DataSinkType() == KUidMmfFileSink )
+        {
+        iTtsOutputMode = EDevTTSClientMode;
+        
+        CMMFFile* mmfFile = STATIC_CAST( CMMFFile*, &aDataSink );
+
+        mmfFile->SinkPrimeL(); 
+        iOutputFile = &mmfFile->FileL(); 
+
+        TDriveInfo driveInfo;    
+        User::LeaveIfError( iOutputFile->Drive( iOutFileDriveNumber, driveInfo ) );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::RemoveDataSourceL
+// Removes data source.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::RemoveDataSourceL( MDataSource& /*aDataSource*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::RemoveDataSourceL" );
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::RemoveDataSinkL
+// Removes data sink.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::RemoveDataSinkL( MDataSink& /*aDataSink*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::RemoveDataSinkL" );
+    
+    if ( iOutputFile )
+        {
+        iOutputFile->Close(); 
+        iOutputFile = NULL; 
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::ResetL
+// Resets plugin & DevTTS to starting state.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::ResetL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::ResetL" );
+
+    iDevTts->Stop();
+    delete iDevTts;
+    iDevTts = NULL;
+    iDevTts = CDevTTS::NewL( *this );
+    
+    // Add default style to DevTTS
+    iDefaultStyleID = iDevTts->AddStyleL( iDefaultStyle );
+
+    delete iParsedTextPointer;
+    iParsedTextPointer = NULL;
+    iEarlyPrimingDone = EFalse;
+    
+    if ( iOutputFile )
+        {
+        iOutputFile->Close(); 
+        iOutputFile = NULL; 
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::PrimeL
+// Initializes synthesis. 
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::PrimeL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::PrimeL" );
+    TInt error( KErrNone );
+
+    if ( iEarlyPrimingDone )
+        {
+        iEarlyPrimingDone = EFalse;
+        }
+    else
+        {
+        // Make sure that parsed text contains at least something to synthesize
+        if ( iParsedTextPointer->Text() != KNullDesC  || 
+             iParsedTextPointer->PhonemeSequence() != KNullDesC8 ) 
+            {
+            TRAP( error, iDevTts->PrimeSynthesisL( *iParsedTextPointer ) );
+            }
+        }
+    iObserver->InitializationReady( error );        
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::DoEarlyPrimingL
+// Initializes synthesis. 
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::DoEarlyPrimingL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::DoEarlyPrimingL" );
+
+    // Make sure that parsed text contains at least something to synthesize
+    if ( iParsedTextPointer->Text() != KNullDesC  || 
+         iParsedTextPointer->PhonemeSequence() != KNullDesC8 )
+        {
+        iDevTts->PrimeSynthesisL( *iParsedTextPointer );
+        }
+    iEarlyPrimingDone = ETrue;    
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::PlayL
+// Starts playback.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::PlayL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::PlayL" );
+
+    if ( IsActive() )
+		{
+		User::Leave( KErrServerBusy );
+		}
+
+	iRequestFunction = KPlay;
+    Ready();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::HandlePlay
+// Async handler for play
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::HandlePlay()
+    {
+    // Make sure that parsed text contains at least something to synthesize
+    if ( iParsedTextPointer->Text() != KNullDesC || 
+         iParsedTextPointer->PhonemeSequence() != KNullDesC8 )
+        {
+        
+        TRAPD( error, iDevTts->SynthesizeL( iTtsOutputMode ) );
+        // Do client callback now if leave happens, otherwise wait for the callback 
+        // from DevTTS
+        if ( error != KErrNone )
+            {
+            // Try if we can get rid of the problem by first doing initialization
+            TRAP( error, iDevTts->PrimeSynthesisL( *iParsedTextPointer ) );
+            if ( error != KErrNone )
+                {
+                iObserver->SynthesisReady( error );
+                }
+            // Then try to start synthesis again
+            TRAP( error, iDevTts->SynthesizeL( iTtsOutputMode ) );
+            if ( error != KErrNone )
+                {
+                iDevTts->Stop();
+                iObserver->SynthesisReady( error );
+                }
+            }
+        }
+    else
+        {
+        iObserver->SynthesisReady( KErrNone );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::PauseL
+// Pauses playback & synthesis.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::PauseL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::PauseL" );
+
+    iDevTts->Pause();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::StopL
+// Stops playback & synthesis.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::StopL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::StopL" );
+    iEarlyPrimingDone = EFalse;
+    iDevTts->Stop();
+    
+    if ( iOutputFile )
+        {
+        iOutputFile->Close();
+        iOutputFile = NULL; 
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::PositionL
+// Returns the current playback position in microseconds.
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CTtsControllerPluginBody::PositionL() const
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::PositionL" );
+
+    TTimeIntervalMicroSeconds time( 0 );
+
+    iDevTts->GetPositionL( time );
+
+    return time;
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::SetPositionL
+// Sets the playback position.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::SetPositionL( const TTimeIntervalMicroSeconds& /*aPosition*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::SetPositionL" );
+    // @todo Remove from comments when DevTTS does not anymore return 
+    // KErrNotSupported
+    // iDevTts->SetPositionL( aPosition );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::DurationL
+// Returns duration of synthesized output.
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalMicroSeconds CTtsControllerPluginBody::DurationL() const
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::DurationL" );
+
+    TTimeIntervalMicroSeconds duration( 0 );
+
+    if ( iParsedTextPointer )
+        {
+        // Count overall duration
+        for ( TInt i = 0; i < iParsedTextPointer->NumberOfSegments(); i++ )
+            {
+            TTtsSegment segment = iParsedTextPointer->SegmentL( i );
+            TTtsStyleID styleID = segment.StyleID();
+            TTtsStyle style = iDevTts->StyleL( styleID );
+            duration = duration.Int64() + style.iDuration.Int();
+            }
+        }
+
+    return duration;
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::SetPrioritySettings
+// Sets the playback priority.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings )
+    {
+    RUBY_DEBUG0( "CTtsControllerPluginBody::SetPrioritySettings" );
+
+    iDevTts->SetAudioPriority( aPrioritySettings.iPriority, 
+                               (TDevTTSAudioPreference)aPrioritySettings.iPref );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::CustomCommand
+// One supported custom command at the moment.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::CustomCommand( TMMFMessage& aMessage )
+    {
+    RUBY_DEBUG0( "CTtsControllerPluginBody::CustomCommand" );
+    
+    TInt result( KErrNone );
+
+    if ( aMessage.Function() == ETtsCustomCommandSetAudioOutput )
+        {
+        TBuf8<2> data;
+        
+        if ( aMessage.SizeOfData1FromClient() <= 2  && 
+             aMessage.ReadData1FromClient( data ) == KErrNone )
+            {
+            TLex8 parser( data );
+
+            TInt newOutput;
+            result = parser.Val( newOutput );
+            
+            if ( result == KErrNone )
+                {
+                TRAP( result, iDevTts->SetAudioOutputL( newOutput) );
+                }
+            }
+        else
+            {
+            result = KErrArgument;
+            }
+        }
+    else
+        {
+        result = KErrNotSupported; 
+        }
+        
+    aMessage.Complete( result );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::GetNumberOfMetaDataEntriesL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::GetNumberOfMetaDataEntriesL( TInt& /*aNumberOfEntries*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::GetNumberOfMetaDataEntriesL" );
+ 
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::GetMetaDataEntryL
+// Not supported.
+// -----------------------------------------------------------------------------
+//
+CMMFMetaDataEntry* CTtsControllerPluginBody::GetMetaDataEntryL( TInt /*aIndex*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::GetMetaDataEntryL" );
+
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSourceSampleRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSourceSampleRateL( TUint /*aSampleRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSourceBitRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSourceBitRateL( TUint /*aBitRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSourceNumChannelsL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSourceNumChannelsL( TUint /*aNumChannels*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSourceFormatL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSourceFormatL( TUid /*aFormatUid*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSourceDataTypeL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSourceDataTypeL( TFourCC /*aDataType*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSinkSampleRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSinkSampleRateL( TUint /*aSampleRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSinkBitRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSinkBitRateL( TUint /*aRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSinkNumChannelsL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSinkNumChannelsL( TUint /*aNumChannels*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSinkFormatL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSinkFormatL( TUid /*aFormatUid*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetSinkDataTypeL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetSinkDataTypeL( TFourCC /*aDataType*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacSetCodecL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacSetCodecL( TFourCC /*aSourceDataType*/, TFourCC /*aSinkDataType*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSourceSampleRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSourceSampleRateL( TUint& /*aRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSourceBitRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSourceBitRateL( TUint& /*aRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSourceNumChannelsL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSourceNumChannelsL( TUint& /*aNumChannels*/ )
+    { 
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSourceFormatL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+// 
+void CTtsControllerPluginBody::MacGetSourceFormatL( TUid& /*aFormat*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSourceDataTypeL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSourceDataTypeL( TFourCC& /*aDataType*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSinkSampleRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSinkSampleRateL( TUint& /*aRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSinkBitRateL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSinkBitRateL( TUint& /*aRate*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSinkNumChannelsL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSinkNumChannelsL( TUint& /*aNumChannels*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSinkFormatL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSinkFormatL( TUid& /*aFormat*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSinkDataTypeL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSinkDataTypeL( TFourCC& /*aDataType*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSourceSampleRatesL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSourceSampleRatesL( RArray<TUint>& /*aSupportedRates*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSourceBitRatesL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSourceBitRatesL( RArray<TUint>& /*aSupportedRates*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSourceNumChannelsL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSourceNumChannelsL( RArray<TUint>& /*aSupportedChannels*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSourceDataTypesL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSourceDataTypesL( RArray<TFourCC>& /*aSupportedDataTypes*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSinkSampleRatesL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSinkSampleRatesL( RArray<TUint>& /*aSupportedRates*/)
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSinkBitRatesL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSinkBitRatesL( RArray<TUint>& /*aSupportedRates*/)
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSinkNumChannelsL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSinkNumChannelsL( RArray<TUint>& /*aSupportedChannels*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MacGetSupportedSinkDataTypesL
+// Leaves with value KErrNotSupported.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MacGetSupportedSinkDataTypesL( RArray<TFourCC>& /*aSupportedDataTypes*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MapdSetVolumeL
+// Sets playback volume.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MapdSetVolumeL( TInt aVolume ) 
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MapdSetVolumeL" );
+
+    iDevTts->SetVolume( aVolume );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MapdGetMaxVolumeL
+// Returns the maximum volume setting.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MapdGetMaxVolumeL( TInt& aMaxVolume )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MapdGetMaxVolumeL" );
+
+    aMaxVolume = iDevTts->MaxVolume();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MapdGetVolumeL
+// Returns the current volume.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MapdGetVolumeL( TInt& aVolume )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MapdGetVolumeL" );
+
+    aVolume = iDevTts->Volume();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MapdSetVolumeRampL
+// Sets volume ramp time.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MapdSetVolumeRampL( const TTimeIntervalMicroSeconds& aRampDuration )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MapdSetVolumeRampL" );
+
+    iDevTts->SetVolumeRamp( aRampDuration );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MapdSetBalanceL
+// Sets playback balance.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MapdSetBalanceL( TInt aBalance )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MapdSetBalanceL" );
+
+    iDevTts->SetBalance( aBalance );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MapdGetBalanceL
+// Returns current balance setting.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MapdGetBalanceL( TInt& aBalance )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MapdGetBalanceL" );
+
+    aBalance = iDevTts->Balance();
+    }
+
+// ================= FUNCTIONS FROM MDevTTSObserver start ======================
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MdtoConfigurationData
+// Called when DevTTS needs data.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CTtsControllerPluginBody::MdtoConfigurationData( TUint32 aPackageType, 
+                                                         TUint32 aPackageID,
+                                                         TUint32 aStartPosition, 
+                                                         TUint32 aEndPosition )
+    {
+    RUBY_DEBUG2( "CTtsControllerPluginBody::MdtoConfigurationData [%d][%d]", aPackageType, aPackageID );
+
+    if ( aPackageType == KTtpLanguageDataPackageType )
+        {
+        return iTtsLoader->LoadLanguageData( aPackageType, (TLanguage)aPackageID,
+                                             aStartPosition, aEndPosition );
+        }
+    else if ( aPackageType == KTtsDataPackageType )
+        {
+        return iTtsLoader->LoadTtsData( aPackageType, aPackageID, 
+                                        aStartPosition, aEndPosition );
+        }
+    else
+        {
+        return iTtsLoader->LoadGeneralData( aPackageType, aPackageID, 
+                                            aStartPosition, aEndPosition );
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MdtoEvent
+// Called when synthesis has ended.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MdtoEvent( TDevTTSEvent aEvent, TInt aStatus )
+    {
+    RUBY_DEBUG2( "CTtsControllerPluginBody::MdtoEvent [%d][%d]", aEvent, aStatus );
+
+    switch ( aEvent )
+        {
+        case EDevTTSEventComplete:
+        
+            if ( iOutputFile )
+                {
+                iOutputFile->Close(); 
+                iOutputFile = NULL; 
+                }
+                
+            // Call the upper level
+            iObserver->SynthesisReady( aStatus );
+            break;
+
+        default:
+            break;
+        }
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MdtoProcessBuffer
+// Called when synthesis is directed to file and the next output buffer is ready.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MdtoProcessBuffer( const TDesC8& aBuffer )
+    {
+    RUBY_DEBUG0( "CTtsControllerPluginBody::MdtoProcessBuffer" );
+    
+    TInt error( KErrCorrupt ); 
+    
+    if ( iOutputFile )
+        {
+        TBool diskFull( EFalse );
+        
+        TRAP( error, diskFull = 
+            SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aBuffer.Size(), 
+                                                   iOutFileDriveNumber ) );
+        if ( !error )
+            {
+            if ( diskFull )
+                {
+                error = KErrDiskFull; 
+                }
+            else
+                {
+                error = iOutputFile->Write( aBuffer );
+                }
+            }
+        }
+    
+    if ( error )
+        {
+        RUBY_ERROR1( "CTtsControllerPluginBody::MdtoProcessBuffer - Write failed with %d",
+                      error );
+        
+        // Stop synthesis
+        TRAP_IGNORE( StopL() );
+        
+        // Inform observer we don't continue
+        iObserver->SynthesisReady( error );
+        }
+
+    // We are ready to receive the next buffer. 
+    iDevTts->BufferProcessed( aBuffer ); 
+    }
+        
+// ================== FUNCTIONS FROM MDevTTSObserver end =======================
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscAddStyleL
+// Adds a new style to style collection.
+// -----------------------------------------------------------------------------
+//
+TTtsStyleID CTtsControllerPluginBody::MttscAddStyleL( const TTtsStyle& aStyle )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscAddStyleL" );
+
+    return iDevTts->AddStyleL( aStyle );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscDeleteStyle
+// Removes style from style collection.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsControllerPluginBody::MttscDeleteStyle( TTtsStyleID aID )
+    {
+    RUBY_DEBUG0( "CTtsControllerPluginBody::MttscDeleteStyle" );
+
+    TRAPD( error, iDevTts->DeleteStyleL( aID ) );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscGetPositionL
+// Returns current synthesis position in words.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscGetPositionL( TInt& /*aWordIndex*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscGetPositionL" );
+
+    // @todo DevTTS wants this starting from the beginning of segment
+    // iDevTts->GetPositionL( aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscNumberOfStyles
+// Returns number of registered styles.
+// -----------------------------------------------------------------------------
+//
+TUint16 CTtsControllerPluginBody::MttscNumberOfStyles()
+    {
+    RUBY_DEBUG0( "CTtsControllerPluginBody::MttscNumberOfStyles" );
+
+    return iDevTts->NumberOfStyles();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscOpenParsedTextL
+// Opens parsed text object as source.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscOpenParsedTextL( CTtsParsedText& aText )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscOpenParsedTextL" );
+
+    // Go through styles inside the parsed text
+    for ( TInt i = 0; i < aText.NumberOfSegments(); i++ )
+        {
+        TTtsSegment segment = aText.SegmentL( i );
+        TTtsStyleID styleID = segment.StyleID();
+        TTtsStyle& style = iDevTts->StyleL( styleID );
+        }
+
+    CopyParsedTextL( aText );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscSetPositionL
+// Sets the synthesis position in words.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscSetPositionL( TInt /*aWordIndex*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscSetPositionL" );
+
+    // @todo DevTTS returns this from starting of certain segment
+    // iDevTts->SetPositionL( aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscStyleL
+// Returns reference to registered style based on ID.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsControllerPluginBody::MttscStyleL( TTtsStyleID aStyleID )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscStyleL(aStyleID)" );
+
+    return iDevTts->StyleL( aStyleID );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscStyleL
+// Returns reference to registered style based in index.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsControllerPluginBody::MttscStyleL( TUint16 aIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscStyleL(aIndex)" );
+
+    return iDevTts->StyleL( aIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscSetDefaultStyleL
+// Sets the default style
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscSetDefaultStyleL( const TTtsStyle& aStyle )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscSetDefaultStyleL" ); 
+
+    // Remove old default style from devTts
+    iDevTts->DeleteStyleL( iDefaultStyleID );
+    
+    // Copy new default style 
+    iDefaultStyle = aStyle;
+    
+    // Add new default style to devTTS
+    iDefaultStyleID = iDevTts->AddStyleL( iDefaultStyle );
+    
+    iUserSpecifiedDefaultStyle = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscDefaultStyleL
+// Returns reference to the default style
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsControllerPluginBody::MttscDefaultStyleL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscDefaultStyleL" );
+    
+    return iDefaultStyle;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscSetSpeakingRateL
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscSetSpeakingRateL( TInt /*aRate*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscSetSpeakingRateL" );
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscSpeakingRateL
+// Not supported
+// -----------------------------------------------------------------------------
+//
+TInt CTtsControllerPluginBody::MttscSpeakingRateL()
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscSpeakingRateL" );
+    
+    User::Leave( KErrNotSupported );
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscGetSupportedLanguagesL
+// Appends supported languages to aLanguages 
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscGetSupportedLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscGetSupportedLanguagesL" );
+    
+    iTtsLoader->GetSupportedLanguagesL( aLanguages );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::MttscGetSupportedVoicesL
+// Appends supported voices of given language to aVoices
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::MttscGetSupportedVoicesL( TLanguage aLanguage, 
+                                                         RArray<TTtsStyle>& aVoices )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsControllerPluginBody::MttscGetSupportedVoicesL" );
+    
+    if ( iDevTts->IsLanguageSupported( aLanguage ) )
+        {
+        TTtsStyle style;
+        style.iLanguage     = aLanguage;
+        style.iSamplingRate = KSamplingRate;
+        style.iRate         = KErrNotSupported;
+        style.iVolume       = KTtsDefaultVolume;
+        
+        style.iVoice = KDefaultVoiceNameMale;
+        aVoices.AppendL( style );
+        
+        style.iVoice = KDefaultVoiceNameFemale;
+        aVoices.AppendL( style );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::DoCancel
+// Cancel handle from CActive class.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::DoCancel()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::RunL
+// RunL from CActive class.  Check which message got saved and call the
+// appropriate handle function.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::RunL()
+	{
+	switch ( iRequestFunction )
+        {
+        case KPlay:
+            HandlePlay();
+            break;
+        default:
+            // No action
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::Ready
+// Activates the active object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::Ready()
+	{
+	TRequestStatus* pRS = &iStatus;
+    User::RequestComplete( pRS, KErrNone );
+	SetActive();
+	}
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::ConstructParsedTextL
+// Converts the descriptor to unicode & puts it to parsed text object.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::ConstructParsedTextL( TDes8& aBufferPtr )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // Check if header is there and strip it out if needed
+    TInt index = aBufferPtr.Find( KTtsContentHeader );
+    if ( index != KErrNotFound )
+        {
+        aBufferPtr.Replace( index, KTtsContentHeader().Length(), KNullDesC8 );
+        }
+
+    TInt languageId( KErrNotFound );
+    index = aBufferPtr.Find( KTtsLanguageStartTag );
+    if ( index != KErrNotFound )
+        {
+        RUBY_DEBUG1( "KTtsLanguageStartTag found, index %d", index );
+        
+        TInt relativeEndIndex( aBufferPtr.Mid( index ).Find( KTtsLanguageEndTag ) );
+        
+        if ( relativeEndIndex != KErrNotFound )
+            {
+            const TInt tagLength( KTtsLanguageStartTag().Length() );
+            
+            TPtrC8 lang( aBufferPtr.Mid( index + tagLength, relativeEndIndex - tagLength ) );
+            
+            TInt64 tmp;
+            TLex8 parser( lang );
+
+            if ( parser.Val( tmp, EDecimal ) == KErrNone )
+                {
+                languageId = tmp;
+                RUBY_DEBUG1( "Detected language selection %d", languageId );
+                }
+        
+            aBufferPtr.Replace( index, relativeEndIndex + 1, KNullDesC8 );
+            }
+        }
+
+    // Convert text to 16-bit unicode
+    HBufC16* unicode = HBufC16::NewL( aBufferPtr.Size() );
+    CleanupStack::PushL( unicode );
+    TPtr16 bufferPtr16( unicode->Des() );
+    User::LeaveIfError( CnvUtfConverter::ConvertToUnicodeFromUtf8( bufferPtr16, aBufferPtr ) );
+    
+    // Create new parsed text which will be filled with input data
+    delete iParsedTextPointer;
+    iParsedTextPointer = NULL;
+    iParsedTextPointer = CTtsParsedText::NewL( bufferPtr16 );
+    
+    // CTtsParsedText makes a copy of data
+    CleanupStack::PopAndDestroy( unicode );
+    
+    // Construct segment & add it to the parsed text
+    TTtsSegment iSegment( iDefaultStyleID );
+    iSegment.SetTextPtr( iParsedTextPointer->Text() );
+    iParsedTextPointer->AddSegmentL( iSegment );
+
+    if ( !iUserSpecifiedDefaultStyle )
+        {
+        // Reset style language so that UI language will be used if
+        // default default style in use 
+        TTtsStyle& style = iDevTts->StyleL( iDefaultStyleID );
+        
+        if ( languageId == KErrNotFound )
+            {
+            style.iLanguage = User::Language();
+            }
+        else
+            {
+            style.iLanguage = (TLanguage)languageId;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsControllerPluginBody::CopyParsedTextL
+// Copies parsed text.
+// -----------------------------------------------------------------------------
+//
+void CTtsControllerPluginBody::CopyParsedTextL( CTtsParsedText& aText )
+    {
+    // Delete previous object if exists
+    delete iParsedTextPointer;
+    iParsedTextPointer = NULL;
+
+    // New instance
+    iParsedTextPointer = CTtsParsedText::NewL( aText.Text(), aText.PhonemeSequence(),
+                                               aText.PhonemeNotation() );
+                                               
+    // Segments:
+    
+    // Indexes for starting points for segment's text and phoneme part in
+    // CTtsParsedText object's text and phoneme sequence    
+    TInt textIndex( 0 );
+    TInt phonemeIndex( 0 );
+        
+    for ( TInt i = 0; i < aText.NumberOfSegments(); i++ )
+        {
+        TTtsSegment segment = aText.SegmentL( i );
+        
+        segment.SetStyleID( aText.SegmentL( i ).StyleID() );
+        
+        TInt segTextLength = aText.SegmentL( i ).TextPtr().Length();
+        TInt segPhonemeSeqLength = aText.SegmentL( i )
+                                      .PhonemeSequencePtr().Length();
+        
+        // Text
+        if ( textIndex + segTextLength
+             <= iParsedTextPointer->Text().Length() )
+            {
+            segment.SetTextPtr( iParsedTextPointer->Text()
+                                .Mid( textIndex, segTextLength ) );
+            
+            textIndex += segTextLength;
+            }
+        // Segments are somehow constructed illegally. Copy the whole text.
+        else
+            {
+            segment.SetTextPtr( iParsedTextPointer->Text() );
+            }
+        
+        // Phoneme sequence
+        if ( phonemeIndex + segPhonemeSeqLength
+             <= iParsedTextPointer->PhonemeSequence().Length() )
+            {
+            segment.SetPhonemeSequencePtr(
+                iParsedTextPointer->
+                PhonemeSequence().Mid( phonemeIndex, segPhonemeSeqLength ) );
+            
+            phonemeIndex += segPhonemeSeqLength;
+            }
+        else
+            {
+            segment.SetPhonemeSequencePtr(
+                iParsedTextPointer->PhonemeSequence() );
+            }
+
+        // Add segment to the new instance of CTtsParsedText
+        iParsedTextPointer->AddSegmentL( segment );
+        }    
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttspluginbody.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,857 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class CTtsControllerPluginBody
+*
+*/
+
+
+
+#ifndef TTSPLUGINBODY_H
+#define TTSPLUGINBODY_H
+
+// INCLUDES
+#include <mmfcontroller.h>
+#include <nssdevtts.h>
+
+// FORWARD DECLARATIONS
+class CTtsControllerPlugin;
+class CTTSDataLoader;
+
+// CLASS DECLARATION
+
+/**
+* Implementation class for Tts controller plugin.
+*
+* @lib TtsPlugin.lib
+* @since 2.8
+*/
+class CTtsControllerPluginBody : public CActive, public MDevTTSObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CTtsControllerPluginBody* NewL( CTtsControllerPlugin* aObserver );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTtsControllerPluginBody();
+        
+    public: // New functions
+        
+        /**
+        * Add a data source to the controller plugin.
+        *
+        *  @param "aDataSource"	"A reference to the data source to be added.
+        *         The controller plugin may call <code>aDataSource.DataSourceType()
+        *         <\code> to find out exactly what type of source it is."
+        * @leave "" "The controller plugin may leave during this method.  
+        *        If the controller plugin does not support the data source, it 
+        *         should leave with <code>KErrNotSupported<\code>.
+        */
+        void AddDataSourceL( MDataSource& aDataSource );
+        
+        /**
+        * Add a data sink to the controller plugin.
+        *
+        * @param "aDatasink" "A reference to the data sink to be added.
+        *        The controller plugin may call <code>aDatasink.DatasinkType()
+        *        <\code> to find out exactly what type of sink it is."
+        * @leave "" "The controller plugin may leave during this method.
+        *        If the controller plugin does not support the data sink, it 
+        * should leave with <code>KErrNotSupported<\code>.
+        */
+        void AddDataSinkL( MDataSink& aDataSink );
+        
+        /**
+        * Remove a data source from the controller plugin.
+        *
+        * @param "aDataSource" A reference to the data source to be removed.
+        * @leave "" "The controller plugin may leave during this method.
+        *        If the controller plugin does not support the removal of data 
+        *        sources, it should leave with <code>KErrNotSupported<\code>.
+        *        If the controller plugin leaves, the data source will not be 
+        *        destroyed by the controller framework.  If it does not leave, 
+        *        the data source will be destroyed.
+        */
+        void RemoveDataSourceL( MDataSource& aDataSource );
+        
+        /**
+        * Remove a data sink from the controller plugin.
+        *
+        * @param "aDatasink" A reference to the data sink to be removed.
+        * @leave "" "The controller plugin may leave during this method.
+        * If the controller plugin does not support the removal of data sinks, 
+        * it should leave with <code>KErrNotSupported<\code>. If the 
+        * controller plugin leaves, the data sink will not be destroyed by 
+        * the controller framework.  If it does not leave, the data sink
+        * will be destroyed.
+        */
+        void RemoveDataSinkL( MDataSink& aDataSink );
+        
+        /**
+        * Reset the controller plugin.
+        *
+        * The controller should revert back to its newly constructed state. If 
+        * the Reset is successful (i.e. it doesn't leave), the controller 
+        * framework will delete all objects added to the MMFObjectManager 
+        * including any sources and sinks.
+        *
+        * @leave "" "The controller plugin may leave during this method.
+        *        If the controller plugin does not support being reset, 
+        *        it should leave with <code>KErrNotSupported<\code>."
+        */
+        void ResetL();
+        
+        /**
+        * Prime the controller plugin.
+        *
+        * The controller must prepare to start playing, by initialising its 
+        * sources, sinks and buffers. This moves the controller from the 
+        * STOPPED to the PRIMED state.
+        *
+        * @leave "" "The controller plugin may leave during this method with
+        * any of the standard system-wide error codes."
+        */
+        void PrimeL();
+        
+        /**
+        * Commence playback.
+        *
+        * The controller must now begin transferring data from its source(s) 
+        * to its sink(s). This moves the controller from the PRIMED to the 
+        * PLAYING state.
+        *
+        * Note: this method must return once playing has commenced, and not 
+        * wait until playing is complete.
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        */
+        void PlayL();
+        
+        /**
+        * Pause the controller plugin.
+        *
+        * The controller must now cease transferring data from its source(s) 
+        * to its sink(s). This moves the controller from the PLAYING back to 
+        * the PRIMED state.
+        *
+        * A subsequent call to <code>Play()<\code> will cause the controller 
+        * plugin to resume playback from the point it was paused (unless 
+        * there has been a call to <code>SetPosition()<\code> in the meantime.
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        */
+        void PauseL();
+        
+        /**
+        * Stop the controller plugin.
+        *
+        * The controller must now undo anything that occurred during the call 
+        * to <code>Prime()<\code>. This moves the controller from the PRIMED 
+        * back to the STOPPED state.
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        */
+        void StopL();
+        
+        /**
+        * Get the current position.
+        *
+        * The controller plugin should calculate the current position in microseconds.
+        *
+        * @return "The current position in microseconds."
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        */
+        TTimeIntervalMicroSeconds PositionL() const;
+        
+        /**
+        * Set the current position.
+        *
+        * The controller plugin should reposition itself to the position provided.
+        *
+        * @param "The desired position in microseconds."
+        * @leave "" "The controller plugin may leave during this method with
+        *         any of the standard system-wide error codes."
+        */
+        void SetPositionL( const TTimeIntervalMicroSeconds& aPosition );
+        
+        /**
+        * Get the duration of the clip.
+        *
+        * The controller plugin should calculate the clip duration in microseconds.
+        *
+        * @return "The clip duration in microseconds."
+        * @leave "" "The controller plugin may leave during this method with
+        *         any of the standard system-wide error codes."
+        */
+        TTimeIntervalMicroSeconds DurationL() const;
+        
+        /**
+        * Set the priority settings.
+        *
+        * The new priority settings must be applied to any resource being used 
+        * by the controller plugin that requires priority settings (for example 
+        * the sound device).
+        *
+        * @param "aPrioritySettings" "The new priority settings"
+        */
+        void SetPrioritySettings( const TMMFPrioritySettings& aPrioritySettings );
+        
+        /**
+        * Handle a custom command.
+        *
+        * Custom commands allow a controller plugin to define its own API.
+        * If the controller framework does not understand a message from the 
+        * client, it is assumed this is a custom command for the plugin and 
+        * passed into this interface.
+        *
+        * The more common custom commands can be handled by Custom Command 
+        * Parsers on behalf of the controller plugin.  This allows the 
+        * controller plugin to implement a concrete interface (defined by 
+        * mixin classes) rather than having to decode the command itself.
+        * For more information, @see CMMFCustomCommandParserBase.
+        *
+        * The controller plugin must always complete the message passed 
+        * into this method, even if it does not support the interface 
+        * required by the message.
+        *
+        * @param "aMessage" "The message to be handled by the controller plugin."
+        */
+        void CustomCommand( TMMFMessage& aMessage );
+        
+        /**
+        * Retrieve the number of meta data entries in the clip.
+        *
+        * @param "aNumberOfEntries" "The controller plugin must set this to 
+        * the number of meta data entries in the clip."
+        *
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        */
+        void GetNumberOfMetaDataEntriesL( TInt& aNumberOfEntries );
+        
+        /**
+        * Retrieve a meta data entry from the clip.
+        *
+        * @param "aIndex" "The index of the meta data entry to retrieve."
+        * @return "A pointer to a newly created CMMFMetaDataEntry object 
+        *         containing the meta information. The controller framework 
+        *         will take ownership of the object when this method returns."
+        * @leave "" "The controller plugin may leave during this method with 
+        *        any of the standard system-wide error codes."
+        */
+        CMMFMetaDataEntry* GetMetaDataEntryL( TInt aIndex );
+
+       
+    public: // MMMFAudioControllerCustomCommandImplementor
+        
+        /**
+        Set the sample rate of the data source in samples per second.
+        @param	"aSampleRate"	"The sample rate, in samples per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSourceSampleRateL(TUint aSampleRate);
+        
+        /**
+        Set the bit rate of the data source in bits per second.
+        @param	"aSampleRate"	"The bit rate, in bits per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSourceBitRateL(TUint aBitRate);
+        
+        /**
+        Set the number of channels in the data source.
+        For example, one channel for mono, two channels for stereo etc.
+        @param	"aNumChannels"	"The number of channels."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSourceNumChannelsL(TUint aNumChannels);
+        
+        /**
+        Set the format of the data source.  
+        The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin to be used.
+        @param	"aFormatUid"	"The format plugin to be used."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSourceFormatL(TUid aFormatUid);
+        
+        /**
+        Set the fourCC code of the source.
+        @param	"aDataType"	"The fourCC code."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSourceDataTypeL(TFourCC aDataType);
+        
+        /**
+        Set the sample rate of the data sink in samples per second.
+        @param	"aSampleRate"	"The sample rate, in samples per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSinkSampleRateL(TUint aSampleRate);
+        
+        /**
+        Set the bit rate of the data sink in bits per second.
+        @param	"aSampleRate"	"The bit rate, in bits per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSinkBitRateL(TUint aRate);
+        
+        /**
+        Set the number of channels in the data sink.
+        For example, one channel for mono, two channels for stereo etc.
+        @param	"aNumChannels"	"The number of channels."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSinkNumChannelsL(TUint aNumChannels);
+        
+        /**
+        Set the format of the data sink.  
+        The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin to be used.
+        @param	"aFormatUid"	"The format plugin to be used."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSinkFormatL(TUid aFormatUid);
+        
+        /**
+        Set the fourCC code of the sink.
+        @param	"aDataType"	"The fourCC code."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetSinkDataTypeL(TFourCC aDataType);
+        
+        /**
+        Set the codec to be used.  Useful when recording data.
+        @param	"aSourceDataType"	"The data type of the source of the codec."
+        @param	"aSinkDataType"		"The data type of the sink of the codec."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacSetCodecL(TFourCC aSourceDataType, TFourCC aSinkDataType);
+        
+        
+        /**
+        Get the sample rate of the data source in samples per second.
+        @param	"aRate"	"The sample rate, in samples per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSourceSampleRateL(TUint& aRate);
+        
+        /**
+        Get the bit rate of the data source in bits per second.
+        @param	"aRate"	"The bit rate, in bits per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSourceBitRateL(TUint& aRate);
+        
+        /**
+        Get the number of channels in the data source.
+        For example, one channel for mono, two channels for stereo etc.
+        @param	"aNumChannels"	"The number of channels."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSourceNumChannelsL(TUint& aNumChannels);
+        
+        /**
+        Get the format of the data source.  
+        The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin being used.
+        @param	"aFormatUid"	"The format plugin being used."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSourceFormatL(TUid& aFormat);
+        
+        /**
+        Get the fourCC code of the source.
+        @param	"aDataType"	"The fourCC code."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSourceDataTypeL(TFourCC& aDataType);
+        
+        /**
+        Get the sample rate of the data sink in samples per second.
+        @param	"aRate"	"The sample rate, in samples per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSinkSampleRateL(TUint& aRate);
+        
+        /**
+        Get the bit rate of the data sink in bits per second.
+        @param	"aRate"	"The bit rate, in bits per second."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSinkBitRateL(TUint& aRate);
+        
+        /**
+        Get the number of channels in the data sink.
+        For example, one channel for mono, two channels for stereo etc.
+        @param	"aNumChannels"	"The number of channels."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSinkNumChannelsL(TUint& aNumChannels);
+        
+        /**
+        Get the format of the data sink.  
+        The UID corresponds to the uid of the CMMFFormat-derived ECOM plugin being used.
+        @param	"aFormatUid"	"The format plugin being used."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSinkFormatL(TUid& aFormat);
+        
+        /**
+        Get the fourCC code of the sink.
+        @param	"aDataType"	"The fourCC code."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSinkDataTypeL(TFourCC& aDataType);
+        
+        
+        /**
+        Get the list of sample rates supported by the data source.
+        @param	"aSupportedRates"	"The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSourceSampleRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        Get the list of bit rates supported by the data source.
+        @param	"aSupportedRates"	"The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSourceBitRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        Get the list of channels supported by the data source L(ie mono, stereo etc).
+        @param	"aSupportedChannels"	"The supported channels.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSourceNumChannelsL(RArray<TUint>& aSupportedChannels);
+        
+        /**
+        Get the list of fourCC codes supported by the data source.
+        @param	"aSupportedDataTypes"	"The supported data types.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSourceDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
+        
+        /**
+        Get the list of sample rates supported by the data sink.
+        @param	"aSupportedRates"	"The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSinkSampleRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        Get the list of bit rates supported by the data sink.
+        @param	"aSupportedRates"	"The supported rates.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSinkBitRatesL(RArray<TUint>& aSupportedRates);
+        
+        /**
+        Get the list of channels supported by the data sink L(ie mono, stereo etc).
+        @param	"aSupportedChannels"	"The supported channels.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSinkNumChannelsL(RArray<TUint>& aSupportedChannels);
+        
+        /**
+        Get the list of fourCC codes supported by the data sink.
+        @param	"aSupportedDataTypes"	"The supported data types.  Warning: Existing objects in this array will be removed by this method."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MacGetSupportedSinkDataTypesL(RArray<TFourCC>& aSupportedDataTypes);
+
+
+    public: // From MMMFAudioPlayDeviceCustomCommandImplementor
+
+        /**
+        Set the volume of the sound device.
+        @param	"aVolume"	"The new volume"
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MapdSetVolumeL(TInt aVolume);
+        
+        /**
+        Get the maximum volume supported by the sound device.
+        @param	"aMaxVolume"	"The maximum volume, to be filled in by the controller plugin."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MapdGetMaxVolumeL(TInt& aMaxVolume);
+        
+        /**
+        Get the current playback volume.
+        @param	"aVolume"	"The volume, to be filled in by the controller."
+        @leave	"This function can leave with one of the system-wide error codes. The request will be
+        completed with the leave code."
+        @since 7.0s
+        */
+        virtual void MapdGetVolumeL(TInt& aVolume);
+        
+        /**
+        * Set a volume ramp.
+        *
+        * This will cause the sound device to start playing with zero volume,
+        * increasing the volume over aRampDuration microseconds.
+        *
+        * The volume ramp can be removed by setting the ramp duration to zero.
+        *
+        * @param "aRampDuration" "The duration over which the volume is to be 
+        *                        increased, in microseconds."
+        * @leave "This function can leave with one of the system-wide error codes. 
+        *        The request will be completed with the leave code."
+        */
+        virtual void MapdSetVolumeRampL( const TTimeIntervalMicroSeconds& aRampDuration );
+        
+        /**
+        Set the balance between the left and right stereo audio channels.
+        
+          @param	"aBalance"	"Use a value between <code>KMMFBalanceMaxLeft<\code> and 
+          <code>KMMFBalanceMaxRight<\code>. Centre balance can be restored by using
+          <code>KMMFBalanceCenter<\code>."
+          @leave	"This function can leave with one of the system-wide error codes. The request will be
+          completed with the leave code."
+          @since 7.0s
+        */
+        virtual void MapdSetBalanceL(TInt aBalance);
+        
+        /**
+        Retrieve the balance between the left and right stereo audio channels.
+        
+          @param	"aBalance"	"The current balance, filled in by the controller."
+          @leave	"This function can leave with one of the system-wide error codes. The request will be
+          completed with the leave code."
+          @since 7.0s
+        */
+        virtual void MapdGetBalanceL(TInt& aBalance);
+
+    public: // Functions from MTtsCustomCommandImplementor
+
+        /**
+        * Adds a new style.
+        *
+        * @param "TTtsStyle& aStyle" Style to add.
+        * @return Style identifier.
+        */
+        TTtsStyleID MttscAddStyleL( const TTtsStyle& aStyle );
+
+        /**
+        * Deletes a style based on style ID.
+        *
+        * @param "TTtsStyleID aID" Style ID to be deleted.
+        * @return Error code.
+        */
+        TInt MttscDeleteStyle( TTtsStyleID aID );
+
+        /**
+        * Gets the synthesis position.
+        *
+        * @retval "TInt& aWordIndex" Returned position of synthesis.
+        */
+        void MttscGetPositionL( TInt& aWordIndex );
+
+        /**
+        * Returns the number of registered styles.
+        *
+        * @return Number of styles.
+        */
+        TUint16 MttscNumberOfStyles();
+
+        /**
+        * Opens parsed text as source.
+        *
+        * @param "CTtsParsedText& aText" Reference to parsed text.
+        */
+        void MttscOpenParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Sets the synthesis position based on word index.
+        *
+        * @param "TInt aWordIndex" Word index.
+        */
+        void MttscSetPositionL( TInt aWordIndex );
+
+        /**
+        * Returns the style based on ID.
+        *
+        * @param "TTtsStyleID aStyleID" Style ID.
+        * @return Reference to style object.
+        */
+        TTtsStyle& MttscStyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Returns the style based on index.
+        *
+        * @param "TUint16 aIndex" Style index.
+        * @return Reference to style object.
+        */
+        TTtsStyle& MttscStyleL( TUint16 aIndex );
+        
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        */        
+        void MttscSetDefaultStyleL( const TTtsStyle& aStyle );
+        
+        /**
+        * Returns the registered default style
+        *
+        * @return Style reference
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        TTtsStyle& MttscDefaultStyleL();
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @param TInt aRate Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        */        
+        void MttscSetSpeakingRateL( TInt aRate );
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        TInt MttscSpeakingRateL();
+      
+        /**
+        * Returns the list of supported languages.
+        * 
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which contains 
+        *        the languages
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        void MttscGetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+        
+        /**
+        * Returns the list of supported voices for a certain language.
+        * 
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TTtsStyle>& aVoices" Output parameter which contains the voices
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */        
+        void MttscGetSupportedVoicesL( TLanguage aLanguage, RArray<TTtsStyle>& aVoices );
+
+    public: // Functions from MDevTTSObserver
+
+        /**
+        * Invoked by DevTTS when it needs a configuration data package.
+        * TODO: Add start and endpoint parameters.
+        *
+        * @param "TUint32 aPackageType"
+        *         Packege type identifier
+        * @param "TUint32 aPackageID"
+        *         Package identifier
+        *
+        * @return Pointer to created data buffer. NULL if failure. User must 
+        *         take care of the buffer deletion after usage.
+        */
+        HBufC8* MdtoConfigurationData( TUint32 aPackageType, 
+                                       TUint32 aPackageID, 
+                                       TUint32 aStartPosition, 
+                                       TUint32 aEndPosition );
+        
+        /**
+        * Called by DevTTS when an event occured. EDevTTSEventComplete is the only
+        * event that can happen currently.
+        *
+        * @param "TDevTTSEvent aEvent"
+        *         Event code
+        * @param "TInt aStatus"
+        *         Error code. KErrNone if success, one of the system level
+        *         error codes otherwise.
+        */
+        void MdtoEvent( TDevTTSEvent aEvent, TInt aStatus );
+        
+        /**
+        * Called by DevTTS device when output mode is EDevTTSClientMode and a 
+        * new audio buffer has been filled by the synthesizer. 
+        *
+        * @param "TDesC8& aBuffer"
+        *         Synthesized audio buffer.
+        */
+        void MdtoProcessBuffer( const TDesC8& aBuffer );
+        
+    protected:
+        /**
+        * CActive::RunL
+        */
+        void RunL();
+
+        /**
+        * CActive::DoCancel()
+        */
+        void DoCancel();
+
+        /**
+        * Handles play asynchrnously
+        */
+        void HandlePlay();
+
+        /**
+        * Activates this active object.
+        */ 
+        void Ready();
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CTtsControllerPluginBody( CTtsControllerPlugin* aObserver );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor.
+        CTtsControllerPluginBody( const CTtsControllerPluginBody& );
+        // Prohibit assigment operator.
+        CTtsControllerPluginBody& operator=( const CTtsControllerPluginBody& );
+
+        /**
+        * Copies descriptor to parsed text with default style.
+        */
+        void ConstructParsedTextL( TDes8& aBufferPtr );
+
+        /**
+        * Copies parsed text structure to iParsedTextPointer.
+        * Deletes previous if exists
+        */
+        void CopyParsedTextL( CTtsParsedText& aText );
+        
+        /**
+        * Does priming from AddDataSource
+        */
+        void DoEarlyPrimingL();
+
+    private:    // Data
+
+        // TTP data loader, owned
+        CTTSDataLoader*         iTtsLoader;
+
+        // Pointer to the DevTTS, owned
+        CDevTTS*                iDevTts;
+
+        // Pointer to 'opened' parsed text object, owned
+        CTtsParsedText*         iParsedTextPointer;
+
+        // Observer, not owned.
+        CTtsControllerPlugin*   iObserver;
+
+        // Requested asynchronous function.
+        TInt                    iRequestFunction;
+
+        // Default style which will be used if no OpenParsedText is used
+        TTtsStyle               iDefaultStyle;
+
+        // Style ID of default style
+        TTtsStyleID             iDefaultStyleID;
+        
+        // Tells if priming has been done already in AddDataSource
+        TBool                   iEarlyPrimingDone;
+        
+        // ETrue if MttscSetDefaultStyleL() called
+        TBool                   iUserSpecifiedDefaultStyle;
+        
+        // Output is currently either file or loudspeaker
+        TDevTTSOutputMode       iTtsOutputMode;
+        
+        // File server session
+        RFs                     iFs;
+        
+        // Handle to the output file, not owned. 
+        RFile*                  iOutputFile;
+        
+        // Drive number (according TDriveNumber) where file handle is pointing
+        TInt                    iOutFileDriveNumber;
+        
+        };
+
+#endif // TTSPLUGINBODY_H   
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttsplugindataloader.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,483 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Data buffer loader for TTPHwDevice test executable
+*
+*/
+
+
+// INCLUDE FILES
+#include    "ttsplugindataloader.h"
+
+
+
+
+// CONSTANTS
+
+_LIT( KDriveZ, "z:" );
+
+// Assuming language data file name is something like SRSF_2_x[y|yz].bin
+const TInt KBeginningOfLanguageId = 7;
+#ifdef __SIND_AUTOCONF_LID
+const TUint32 KTtpAutoConfLidPackageType = 1;
+const TUint32 KTtpAutoConfLidPackageID   = 1;
+const TInt KLidBufGranularity = 1000;
+#endif  // __SIND_AUTOCONF_LID
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoaderLoader::CTTSDataLoader
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTTSDataLoader::CTTSDataLoader( RFs& aFs,
+                                TFileName& aGeneralFileName,
+                                TFileName& aPrefixOfTTPFileName,
+                                TFileName& aPostfixOfTTPFileName, 
+                                TFileName& aTTSFilename,
+                                TFileName& aPostfixOfTTSFilename ) :
+    iGeneralFileName( aGeneralFileName ),
+    iPrefixOfTTPFileName( aPrefixOfTTPFileName ),
+    iPostfixOfTTPFileName( aPostfixOfTTPFileName ),
+    iTTSFileName( aTTSFilename ),
+    iPostfixOfTTSFileName( aPostfixOfTTSFilename ),
+    iFs( aFs )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTTSDataLoader::ConstructL()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTTSDataLoader* CTTSDataLoader::NewL( RFs& aFs,
+                                      TFileName& aGeneralFileName,
+                                      TFileName& aPrefixOfTTPFileName,
+                                      TFileName& aPostfixOfTTPFileName,
+                                      TFileName& aTTSFilename,
+                                      TFileName& aPostfixOfTTSFilename )
+    {
+    CTTSDataLoader* self = new ( ELeave ) CTTSDataLoader( aFs,
+                                                          aGeneralFileName,
+                                                          aPrefixOfTTPFileName,
+                                                          aPostfixOfTTPFileName,
+                                                          aTTSFilename,
+                                                          aPostfixOfTTSFilename );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::~CTTSDataLoader
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTTSDataLoader::~CTTSDataLoader()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::LoadGeneralData
+// Load general TTP data
+// -----------------------------------------------------------------------------
+//
+HBufC8* CTTSDataLoader::LoadGeneralData( const TInt aPackageType,
+                                         const TInt aDataID,
+                                         TUint32 aStartPosition, 
+                                         TUint32 aEndPosition )
+    {
+    TFileName fileName( iGeneralFileName );
+    fileName.AppendNum( aPackageType );
+    fileName.Append( _L( "_" ) );
+    fileName.AppendNum( aDataID );
+    fileName.Append( iPostfixOfTTPFileName );
+
+    HBufC8* buffer( NULL );
+#ifdef __SIND_AUTOCONF_LID
+
+	// If LID data is requested, construct it from installed LID binary files
+	// Otherwise run normal data loading
+
+	if( aPackageType == KTtpAutoConfLidPackageType &&
+		aDataID   == KTtpAutoConfLidPackageID )
+	    {
+		TRAPD( err, buffer = ConstructLidDataL() );
+		if ( !err )
+		    {
+		    return buffer;
+		    }
+	    }
+	    
+#endif  // __SIND_AUTOCONF_LID    
+    TRAPD( error, buffer = DoLoadL( fileName, aStartPosition, aEndPosition ) );
+    if ( error == KErrNone )
+        {
+        return buffer;
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::LoadLanguageData
+// Load TTP language data
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CTTSDataLoader::LoadLanguageData( const TInt aPackageType, 
+                                          TLanguage aLanguage,
+                                          TUint32 aStartPosition, 
+                                          TUint32 aEndPosition )
+    {
+    TFileName fileName( iPrefixOfTTPFileName );
+    fileName.AppendNum( aPackageType );
+    fileName.Append( _L( "_" ) );
+    fileName.AppendNum( ( TInt ) aLanguage );
+    fileName.Append( iPostfixOfTTPFileName );
+    
+    HBufC8* buffer( NULL );
+    TRAPD( error, buffer = DoLoadL( fileName, aStartPosition, aEndPosition ) );
+    if ( error == KErrNone )
+        {
+        return buffer;
+        }
+    else
+        {
+        return NULL;
+        }    
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::LoadTtsData
+// Load TTS general/language data
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CTTSDataLoader::LoadTtsData( const TInt aPackageType, 
+                                     const TInt aDataID,
+                                     TUint32 aStartPosition, 
+                                     TUint32 aEndPosition )
+    {
+    TFileName fileName( iTTSFileName );
+    fileName.AppendNum( aPackageType );
+    fileName.Append( _L( "_" ) );
+    fileName.AppendNum( aDataID );
+    fileName.Append( iPostfixOfTTSFileName );
+    
+    HBufC8* buffer( NULL );
+    
+#ifdef __SIND_AUTOCONF_LID
+
+	// If LID data is requested, construct it from installed LID binary files
+	// Otherwise run normal data loading
+	if( aPackageType == KTtpAutoConfLidPackageType &&
+		aDataID   == KTtpAutoConfLidPackageID )
+	    {
+		TRAPD( err, buffer = ConstructLidDataL() );
+		if ( !err )
+		    {
+		    return buffer;
+		    }
+	    }
+#endif  // __SIND_AUTOCONF_LID
+
+    
+    TRAPD( error, buffer = DoLoadL( fileName, aStartPosition, aEndPosition ) );
+    if ( error == KErrNone )
+        {
+        return buffer;
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::GetSupportedLanguagesL
+// Fill aLanguages with supported language ids
+// -----------------------------------------------------------------------------
+//	
+void CTTSDataLoader::GetSupportedLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    // Get pts languages    
+    TFileName mask;
+    mask.Append( KDriveZ );
+    mask.Append( iTTSFileName );
+    mask.Append( _L( "2_*" ) );
+    
+    DoGetSupportedLanguagesL( aLanguages, mask);
+    
+    // Get ttp languages
+    RArray<TLanguage> ttpLanguages;
+    CleanupClosePushL( ttpLanguages );
+    
+    mask.Zero();
+    mask.Append( KDriveZ );
+    mask.Append( iTTSFileName );
+    mask.Append( _L( "0_*" ) );
+    
+    DoGetSupportedLanguagesL( ttpLanguages, mask);
+    
+    // remove languages which are not supported in ttp
+    for ( TInt i(0); i < aLanguages.Count(); i++ )
+        {
+        if ( ttpLanguages.Find( aLanguages[i] ) == KErrNotFound )
+            {
+            aLanguages.Remove( i );
+            }
+        }
+    CleanupStack::PopAndDestroy( &ttpLanguages );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::DoLoadL
+// Loads the given file.
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CTTSDataLoader::DoLoadL( TFileName& iFile,
+                                 TUint32 aStartPosition, 
+                                 TUint32 aEndPosition )
+    {
+    TInt fileSize( 0 );
+    RFile dataFile;
+    TInt readLength;
+    
+    TFileName completeFile;
+    completeFile.Append( KDriveZ );
+    completeFile.Append( iFile );
+    
+    
+    // Try to open file from Z drive
+    TInt err = dataFile.Open( iFs, completeFile, EFileRead );
+
+    if ( err != KErrNone )
+        {
+        return NULL;
+        }
+
+
+    // Try to resolve how much should be read
+    readLength = aEndPosition - aStartPosition;
+    if ( dataFile.Size( fileSize ) != KErrNone )
+        {
+        dataFile.Close();
+        return NULL;
+        }
+    if ( fileSize == 0 )
+        {
+        dataFile.Close();
+        return NULL;
+        }
+
+    if ( aEndPosition != KMaxTUint32 )
+        {
+        // Cannot read more than filesize
+        if ( ( readLength > fileSize ) || ( readLength < 0 ) )
+            {
+            readLength = fileSize;
+            }
+        }
+    else
+        {
+        readLength = fileSize;
+        }
+    
+    // Seek the starting point
+    // Casting needed to convert from uint to int which is needed by Seek()
+    TInt startPosition = (TInt)aStartPosition;
+    dataFile.Seek( ESeekStart, startPosition );
+
+    // Reserve enough memory for the data
+    HBufC8* fileBuffer = HBufC8::NewL( readLength );
+
+    TPtr8 bufferPtr( fileBuffer->Des() );
+    
+    err = dataFile.Read( bufferPtr );
+    
+    dataFile.Close();
+    
+    if ( err != KErrNone )
+        {
+        delete fileBuffer;
+        return NULL;
+        }
+    
+    return fileBuffer;
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::DoGetSupportedLanguagesL
+// Fill aLanguages with supported language ids 
+// -----------------------------------------------------------------------------
+//	
+void CTTSDataLoader::DoGetSupportedLanguagesL( RArray<TLanguage>& aLanguages,
+                                               TFileName& aMask )
+    {
+    CDir *directoryList( NULL );
+    TInt error = iFs.GetDir( aMask, KEntryAttDir, ESortByName, directoryList );
+    CleanupStack::PushL( directoryList );
+
+    if ( !error )
+        {
+        TInt count = directoryList->Count();
+        
+        for ( TInt i( 0 ); i < count; i++ )
+            {
+            TPtrC tmp = (*directoryList)[i].iName;
+            
+            TInt64 id;
+            TLex parser( tmp.Mid( KBeginningOfLanguageId , 
+                                  tmp.Find( _L(".") ) - KBeginningOfLanguageId  ) );
+
+            User::LeaveIfError( parser.Val( id) );
+            
+            TLanguage lang( (TLanguage)id );
+            
+            if ( aLanguages.Find( lang ) == KErrNotFound )
+                {
+                aLanguages.AppendL( lang );
+                }
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( directoryList );
+    }
+    
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::PackageName
+// Construct filename for requested package
+// -----------------------------------------------------------------------------
+//	
+void CTTSDataLoader::PackageName (TFileName &aFileName, TUint32 aPackageType, TUint32 aPackageID) 
+{
+	// Resolve the name of the file
+	// filename is <iPrefixOfTTPFileName>_<PackageType>_<aPackageID><iPostfixOfFileName>
+
+	aFileName.Copy( iPrefixOfTTPFileName );          //  path/SRSF_
+	aFileName.AppendNumUC( aPackageType );           //  path/SRSF_1
+	aFileName.Append( _L( "_" ) );                   //  path/SRSF_1_
+	aFileName.AppendNumUC( aPackageID );             //  path/SRSF_1_326
+	aFileName.Append( iPostfixOfTTPFileName );       //  path/SRSF_1_326.bin
+}
+    
+#ifdef __SIND_AUTOCONF_LID
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::AppendLoadL
+// Load language package file to the end of buffer
+// -----------------------------------------------------------------------------
+//	
+void CTTSDataLoader::AppendLoadL( CBufBase *aBuffer,
+								TUint32 aPackageType, 
+								TUint32 aPackageID ) 
+{
+	// Resolve filename
+	TFileName fileName;
+	PackageName (fileName, aPackageType, aPackageID);
+
+	// Load data
+	HBufC8* buffer = NULL;
+	
+	TRAPD( err, buffer = DoLoadL( fileName, 0, KMaxTUint32 ));  // IMPLICIT: LID packages are loaded completely
+
+ 	if( err == KErrNone && buffer ) 
+ 	{
+		CleanupStack::PushL( buffer );                    // ResizeL may leave below
+
+		TInt prevSize = aBuffer->Size();                  // size before resize
+		TInt newSize  = aBuffer->Size() + buffer->Size(); // new size for lid data buffer
+
+		aBuffer->ResizeL( newSize );                      // resize lid data buffer
+		aBuffer->Write( prevSize, *buffer );              // append data from read buffer
+
+		CleanupStack::PopAndDestroy(buffer);              // buffer copied -> free
+	}
+}
+
+
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::LoadSysLangPackagesL
+// Load LID language data to a buffer according to installed system languages
+// -----------------------------------------------------------------------------
+//	
+void CTTSDataLoader::SysLangPackagesToBufferL( CBufBase *aBuffer ) 
+    {        
+
+	// Get installed languages
+	RArray<TLanguage> languages;
+    CleanupClosePushL( languages );
+	
+	TFileName mask;
+    mask.Append( KDriveZ );
+    mask.Append( iTTSFileName );
+    mask.Append( _L( "1_*" ) );
+    DoGetSupportedLanguagesL( languages, mask);
+	
+	// Loop over installed languages
+	for ( TInt i = 0 ; i < languages.Count(); i++ )
+	    {
+		AppendLoadL(aBuffer, KTtpAutoConfLidPackageType, languages[i] );
+	    }// next language
+	
+	CleanupStack::PopAndDestroy( &languages );
+    }
+
+// -----------------------------------------------------------------------------
+// CTTSDataLoader::ConstructLidDataL
+// Load LID language data to a buffer according to installed system languages
+// -----------------------------------------------------------------------------
+//	
+HBufC8* CTTSDataLoader::ConstructLidDataL()
+    {
+	CBufBase* lidDataBuffer = CBufSeg::NewL( KLidBufGranularity ) ; // accumulates the binary data from lid model files
+	CleanupStack::PushL( lidDataBuffer ) ;
+
+	SysLangPackagesToBufferL (lidDataBuffer);
+
+	// Prepare returnable data
+	HBufC8* dataBuffer = NULL;
+	
+	if( lidDataBuffer->Size() > 0 ) 
+	    {
+		// If any data was loaded, create a buffer for it
+		dataBuffer = HBufC8::NewL( lidDataBuffer->Size() );     // create a returnable buffer
+
+		TPtr8 dataBufferPtr = dataBuffer->Des();                        // get a modifiable pointer to it
+		lidDataBuffer->Read( 0, dataBufferPtr, lidDataBuffer->Size() ); // put the lid data into it
+    	}
+
+	CleanupStack::PopAndDestroy( lidDataBuffer ) ;  
+
+	return dataBuffer;
+    }
+#endif  // __SIND_AUTOCONF_LID
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttsplugindataloader.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for TTS Plugin Body to read TTP data from file.
+*
+*/
+
+
+#ifndef TTSPLUGINDATALOADER_H
+#define TTSPLUGINDATALOADER_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include "srsfbldvariant.hrh"
+
+// CLASS DECLARATION
+
+/**
+* Class to load TTP Data
+*
+* @lib TTSAlgorithm.lib
+*/
+class CTTSDataLoader : public CBase
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CTTSDataLoader* NewL( RFs& iFs, 
+                                     TFileName& aGeneralFileName,
+                                     TFileName& aPrefixOfTTPFileName,
+                                     TFileName& aPostfixOfTTPFilename,
+                                     TFileName& aTTSFilename,
+                                     TFileName& aPostfixOfTTSFilename );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTTSDataLoader();
+        
+    public: // New functions
+        
+        /**
+        * Function to load general configuration data.
+        *
+        * @param "TInt aDataID" Identifier of data package.
+        * @return Pointer to created buffer, NULL if not found.
+        */	
+        HBufC8* LoadGeneralData( const TInt aPackageType, 
+                                 const TInt aDataID,
+                                 TUint32 aStartPosition, 
+                                 TUint32 aEndPosition );
+        
+        /**
+        * Function to load configuration data of TTP method .
+        * 
+        * @param "TLanguage aLanguage" Language specifying which data will be loaded
+        * @return Pointer to created buffer, NULL if not found.
+        */	
+        HBufC8* LoadLanguageData( const TInt aPackageType, 
+                                  TLanguage aLanguage,
+                                  TUint32 aStartPosition, 
+                                  TUint32 aEndPosition );
+
+        /**
+        * Function to load TTS configuration data
+        */
+        HBufC8* LoadTtsData( const TInt aPackageType, 
+                             const TInt aDataID,
+                             TUint32 aStartPosition, 
+                             TUint32 aEndPosition );
+        
+        /**
+        * Function to add supported languages to aLanguages
+        */
+        void GetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+        
+    protected:
+
+        /**
+        * Accesses the file.
+        */
+        HBufC8* DoLoadL( TFileName& iFile,
+                         TUint32 aStartPosition, 
+                         TUint32 aEndPosition );
+
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CTTSDataLoader( RFs& iFs, 
+                        TFileName& aGeneralFileName,
+                        TFileName& aPrefixOfTTPFileName,
+                        TFileName& aPostfixOfTTPFilename,
+                        TFileName& aTTSFilename,
+                        TFileName& aPostfixOfTTSFilename );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Helper function to add supported languages to aLanguages
+        */
+        void DoGetSupportedLanguagesL( RArray<TLanguage>& aLanguages,
+                                       TFileName& aMask );
+                                       
+        /**
+        * Helper function to create file name
+        */        
+        void PackageName (TFileName &aFileName, TUint32 aPackageType, TUint32 aPackageID);                                       
+
+#ifdef __SIND_AUTOCONF_LID
+		/**
+		* Special loader for language identification data
+		* @return Pointer to the loaded data
+		*         NULL if error occurs during loading
+		*/ 
+		HBufC8* ConstructLidDataL();
+
+
+		/**
+		* Loads a file to the end of a buffer
+		* @param  aBuffer         The buffer where to load the data
+		* @param  aPackageType    Type identifier.
+		* @param  aPackageID      Identifier of package.
+		*/
+		void AppendLoadL( CBufBase *aBuffer, TUint32 aPackageType, TUint32 aPackageID );
+
+
+		/**
+		* Obtains the list of installed languages in the system and loads the corresponding data files
+		* to the buffer.
+		* @param  aBuffer         The buffer where to load the data
+		*/
+		void SysLangPackagesToBufferL( CBufBase *aBuffer );
+
+#endif  // __SIND_AUTOCONF_LID
+        
+    private: // Data
+        
+        // File name for general data
+        TFileName iGeneralFileName;
+        
+        // Prefix of file name for ttp method data
+        TFileName iPrefixOfTTPFileName;
+        
+        // Postfix of file name for ttp method data
+        TFileName iPostfixOfTTPFileName;
+        
+        // TTS filename
+        TFileName iTTSFileName;
+
+        // Postfix of file name for tts data
+        TFileName iPostfixOfTTSFileName;
+
+        // File session
+        RFs& iFs;
+
+    };
+    
+#endif // TTSPLUGINDATALOADER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttspluginimplementationuids.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constant declarations for Tts Plugin ECOM resource file.
+*
+*/
+
+
+#ifndef TTSPLUGINIMPLEMENTATIONUIDS_HRH
+#define TTSPLUGINIMPLEMENTATIONUIDS_HRH
+
+
+// Dll Uid
+#define KTtsDllUidController              0x101FF933
+
+// Implementation UID for TTS Controller plugin
+#define KTtsImplementationUid             0x101FF934
+
+// Interface UID for TTS playback
+#define KTtsPlayInterfaceUid              0x101FF935
+
+// Implementation UID for TTS playback
+#define KTtsPlayImplementationUid         0x101FF936
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttspluginresourcehandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads the resource file and provides access to the
+*                information read from the resource file.
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <bautils.h>
+#include <barsc.h>
+#include <barsread.h>
+#include "ttspluginresourcehandler.h"
+#include <ttspluginsettings.rsg>
+
+// LOCAL CONSTANTS AND MACROS
+_LIT( KResourceFileName, "\\ttspluginsettings.rsc" );
+_LIT( KResourceDir, "\\resource" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsPluginResourceHandler::CTtsPluginResourceHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsPluginResourceHandler::CTtsPluginResourceHandler()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsPluginResourceHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsPluginResourceHandler::ConstructL( RFs& aFs )
+    {
+    ReadResourceFileL( aFs );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsPluginResourceHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTtsPluginResourceHandler* CTtsPluginResourceHandler::NewL( RFs& aFs )
+    {
+    CTtsPluginResourceHandler* self = new ( ELeave ) CTtsPluginResourceHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFs );
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsPluginResourceHandler::~CTtsPluginResourceHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTtsPluginResourceHandler::~CTtsPluginResourceHandler()
+    {
+    delete iTtpGeneralFilename;
+    delete iTtpLanguangeFilename;
+    delete iTtpFilenamePostfix;
+    delete iTtsFilename;
+    delete iTtsFilenamePostfix;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsPluginResourceHandler::ReadResourceFileL
+// Reads the data from the resource file.
+// -----------------------------------------------------------------------------
+//
+void CTtsPluginResourceHandler::ReadResourceFileL( RFs& aFs )
+    {
+    // letters for drives in search order
+    const TBuf<2> KResourceDrivers = _L("cz"); 
+    
+    // load resources
+    RResourceFile resourceFile;
+    
+    TFileName name;
+    TInt i( 0 );
+    // try to find from the first driver
+    name.Append( KResourceDrivers[i] );
+    name.Append( ':' );
+    name.Append( KResourceDir );
+    name.Append( KResourceFileName );
+    TBool found( EFalse );
+    
+    while ( !found && i < KResourceDrivers.Length() )
+        {
+        name[0] = KResourceDrivers[i++];
+       
+        if ( BaflUtils::FileExists( aFs, name ) )
+            {
+            // open resource
+            resourceFile.OpenL( aFs, name );
+            CleanupClosePushL( resourceFile );
+            found = ETrue;
+            }
+        }
+            
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+        
+	HBufC8* res = resourceFile.AllocReadLC( TTSPLUGININFO );
+
+    TResourceReader theReader;
+    theReader.SetBuffer( res );
+
+    iTtpGeneralFilename = theReader.ReadHBufCL();
+    iTtpLanguangeFilename = theReader.ReadHBufCL();
+    iTtpFilenamePostfix = theReader.ReadHBufCL();
+    iTtsFilename = theReader.ReadHBufCL();
+    iTtsFilenamePostfix = theReader.ReadHBufCL();
+
+    CleanupStack::PopAndDestroy( res );
+    CleanupStack::PopAndDestroy( &resourceFile );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttspluginresourcehandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class reads the resource file and provides access to the
+*				 information read from the resource file.
+*
+*/
+
+
+#ifndef CTTSPLUGINRESOURCEHANDLER_H
+#define CTTSPLUGINRESOURCEHANDLER_H
+
+// CLASS DECLARATION
+
+/**
+*  This class encapsulates resource file handling functions
+*
+*  @lib TtsPlugin.lib
+*  @since 2.8
+*/
+class CTtsPluginResourceHandler : public CBase
+	{
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CTtsPluginResourceHandler* NewL( RFs& aFs );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTtsPluginResourceHandler();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTtsPluginResourceHandler();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( RFs& aFs );
+
+        /**
+        * Reads the data from the resource file.
+        */
+		void ReadResourceFileL( RFs& aFs );
+
+	public: // Data
+
+        // General TTP filename
+        HBufC* iTtpGeneralFilename;
+
+        // Language TTP filename
+        HBufC* iTtpLanguangeFilename;
+
+        // Postfix of TTP files
+        HBufC* iTtpFilenamePostfix;
+
+        // Name of TTS files
+        HBufC* iTtsFilename;
+
+        // Postfix of TTS files
+        HBufC* iTtsFilenamePostfix;
+	};
+
+#endif // CTTSPLUGINRESOURCEHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscontrollerplugin/src/ttspluginsettings.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Tts Controller Plugin resource file.
+*
+*/
+
+
+// INCLUDES
+#include "nssttscontrollerplugin.rh"
+
+// RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+// TtsPluginInfo
+// Tts Controller Plugin resouce file.
+// -----------------------------------------------------------------------------
+//
+RESOURCE TTSPLUGIN_INFO TtsPluginInfo
+    {
+    // Filename of general TTP data, 
+    ttp_general_filename = "\\system\\data\\srsf_"; 
+    
+    // Filename of language specific data, 
+    ttp_language_filename = "\\system\\data\\srsf_"; 
+    
+    // Extension for TTP data files.
+    ttp_filename_postfix = ".bin";
+
+	// Filename of TTS data files.
+	tts_filename = "\\system\\data\\srsf_";
+
+	// Extension for TTS data files.
+	tts_filename_postfix = ".bin";
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/bwins/nssttscustomcommandsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,19 @@
+EXPORTS
+	??0RTtsCustomCommands@@QAE@AAVRMMFController@@@Z @ 1 NONAME ; RTtsCustomCommands::RTtsCustomCommands(class RMMFController &)
+	??1CTtsCustomCommandParser@@UAE@XZ @ 2 NONAME ; CTtsCustomCommandParser::~CTtsCustomCommandParser(void)
+	?AddStyle@RTtsCustomCommands@@QAEHABVTTtsStyle@@AAK@Z @ 3 NONAME ; int RTtsCustomCommands::AddStyle(class TTtsStyle const &, unsigned long &)
+	?DeleteStyle@RTtsCustomCommands@@QAEHK@Z @ 4 NONAME ; int RTtsCustomCommands::DeleteStyle(unsigned long)
+	?GetDefaultStyle@RTtsCustomCommands@@QAEHAAVTTtsStyle@@@Z @ 5 NONAME ; int RTtsCustomCommands::GetDefaultStyle(class TTtsStyle &)
+	?GetPosition@RTtsCustomCommands@@QAEHAAH@Z @ 6 NONAME ; int RTtsCustomCommands::GetPosition(int &)
+	?GetSpeakingRate@RTtsCustomCommands@@QAEHAAH@Z @ 7 NONAME ; int RTtsCustomCommands::GetSpeakingRate(int &)
+	?GetSupportedLanguages@RTtsCustomCommands@@QAEHAAV?$RArray@W4TLanguage@@@@@Z @ 8 NONAME ; int RTtsCustomCommands::GetSupportedLanguages(class RArray<enum TLanguage> &)
+	?GetSupportedVoices@RTtsCustomCommands@@QAEHW4TLanguage@@AAV?$RArray@VTTtsStyle@@@@@Z @ 9 NONAME ; int RTtsCustomCommands::GetSupportedVoices(enum TLanguage, class RArray<class TTtsStyle> &)
+	?NewL@CTtsCustomCommandParser@@SAPAV1@AAVMTtsCustomCommandImplementor@@@Z @ 10 NONAME ; class CTtsCustomCommandParser * CTtsCustomCommandParser::NewL(class MTtsCustomCommandImplementor &)
+	?NumberOfStyles@RTtsCustomCommands@@QAEHAAG@Z @ 11 NONAME ; int RTtsCustomCommands::NumberOfStyles(unsigned short &)
+	?OpenParsedText@RTtsCustomCommands@@QAEHAAVCTtsParsedText@@@Z @ 12 NONAME ; int RTtsCustomCommands::OpenParsedText(class CTtsParsedText &)
+	?SetDefaultStyle@RTtsCustomCommands@@QAEHABVTTtsStyle@@@Z @ 13 NONAME ; int RTtsCustomCommands::SetDefaultStyle(class TTtsStyle const &)
+	?SetPosition@RTtsCustomCommands@@QAEHH@Z @ 14 NONAME ; int RTtsCustomCommands::SetPosition(int)
+	?SetSpeakingRate@RTtsCustomCommands@@QAEHH@Z @ 15 NONAME ; int RTtsCustomCommands::SetSpeakingRate(int)
+	?Style@RTtsCustomCommands@@QAEHGAAVTTtsStyle@@@Z @ 16 NONAME ; int RTtsCustomCommands::Style(unsigned short, class TTtsStyle &)
+	?Style@RTtsCustomCommands@@QAEHKAAVTTtsStyle@@@Z @ 17 NONAME ; int RTtsCustomCommands::Style(unsigned long, class TTtsStyle &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/eabi/nssttscustomcommandsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,24 @@
+EXPORTS
+	_ZN18RTtsCustomCommands11DeleteStyleEm @ 1 NONAME
+	_ZN18RTtsCustomCommands11GetPositionERi @ 2 NONAME
+	_ZN18RTtsCustomCommands11SetPositionEi @ 3 NONAME
+	_ZN18RTtsCustomCommands14NumberOfStylesERt @ 4 NONAME
+	_ZN18RTtsCustomCommands14OpenParsedTextER14CTtsParsedText @ 5 NONAME
+	_ZN18RTtsCustomCommands15GetDefaultStyleER9TTtsStyle @ 6 NONAME
+	_ZN18RTtsCustomCommands15GetSpeakingRateERi @ 7 NONAME
+	_ZN18RTtsCustomCommands15SetDefaultStyleERK9TTtsStyle @ 8 NONAME
+	_ZN18RTtsCustomCommands15SetSpeakingRateEi @ 9 NONAME
+	_ZN18RTtsCustomCommands18GetSupportedVoicesE9TLanguageR6RArrayI9TTtsStyleE @ 10 NONAME
+	_ZN18RTtsCustomCommands21GetSupportedLanguagesER6RArrayI9TLanguageE @ 11 NONAME
+	_ZN18RTtsCustomCommands5StyleEmR9TTtsStyle @ 12 NONAME
+	_ZN18RTtsCustomCommands5StyleEtR9TTtsStyle @ 13 NONAME
+	_ZN18RTtsCustomCommands8AddStyleERK9TTtsStyleRm @ 14 NONAME
+	_ZN18RTtsCustomCommandsC1ER14RMMFController @ 15 NONAME
+	_ZN18RTtsCustomCommandsC2ER14RMMFController @ 16 NONAME
+	_ZN23CTtsCustomCommandParser4NewLER28MTtsCustomCommandImplementor @ 17 NONAME
+	_ZN23CTtsCustomCommandParserD0Ev @ 18 NONAME
+	_ZN23CTtsCustomCommandParserD1Ev @ 19 NONAME
+	_ZN23CTtsCustomCommandParserD2Ev @ 20 NONAME
+	_ZTI23CTtsCustomCommandParser @ 21 NONAME ; #<TI>#
+	_ZTV23CTtsCustomCommandParser @ 22 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for TtsCustomCommand.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nssttscustomcommands.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/group/nssttscustomcommands.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for TtsCustomCommands
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          nssttscustomcommands.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101FF939 // UID: 270530873
+
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          nssttscustomcommands.cpp
+SOURCE          nssttscustomcommandparser.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../src
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/mmf
+SYSTEMINCLUDE   /epoc32/include/mmf/server
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+// For RUBY_DEBUG
+USERINCLUDE     ../../rubydebug
+
+LIBRARY         euser.lib
+LIBRARY         mmfcontrollerframework.lib
+LIBRARY         nssttscommon.lib
+
+LANG            SC
+
+CAPABILITY      CAP_GENERAL_DLL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/src/nssttscustomcommandcommon.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common header file for TTS custom commands, both client &
+*                server side need this
+*
+*/
+
+
+#ifndef NSSTTSCUSTOMCOMMANDCOMMON_H
+#define NSSTTSCUSTOMCOMMANDCOMMON_H
+
+// INCLUDE FILES
+#include <nssttscommon.h>
+
+// FORWARD DECLARATIONS
+class TTtsParsedText;
+
+// CONSTANTS
+
+const TUid KUidInterfaceTts = { 0x101FF939 };
+
+// DATA TYPES
+
+// Custom command messages
+enum TTtsCustomCommandMessages
+    {
+    ETtsAddStyle,
+    ETtsDeleteStyle,
+    ETtsGetPosition,
+    ETtsNumberOfStyles,
+    ETtsOpenParsedText,
+    ETtsSetPosition,
+    ETtsStyleID, // Style query based on ID
+    ETtsStyleIndex, // Style query based on index
+    ETtsSetDefaultStyle,
+    ETtsGetDefaultStyle,
+    ETtsSetSpeakingRate,
+    ETtsGetSpeakingRate,
+    ETtsSupportedLanguages,
+    ETtsSupportedLanguagesCount,
+    ETtsSupportedVoices,
+    ETtsSupportedVoicesCount
+    };
+
+// Packages
+typedef TPckgBuf<TTtsStyleID> TTtsStyleIDPckg;
+typedef TPckgBuf<TTtsStyleID*> TTtsStyleIDPtrPckg;
+typedef TPckgBuf<TInt> TTtsIntPckg;
+typedef TPckgBuf<TInt*> TTtsIntPtrPckg;
+typedef TPckgBuf<TUint16> TTtsUintPckg;
+typedef TPckgBuf<TUint16*> TTtsUintPtrPckg;
+typedef TPckgBuf<TTtsStyle*> TTtsStylePtrPckg;
+typedef TPckgBuf<TTtsParsedText> TTtsParsedTextPckg;
+typedef TPckgBuf<RArray<TLanguage>*> TTtsRArrayLanguagePtrPckg;
+typedef TPckgBuf<TLanguage> TTtsLanguagePckg;
+typedef TPckgBuf<RArray<TTtsStyle>*> TTtsRArrayTtsStylePtrPckg;
+
+// CLASS DECLARATION
+
+/**
+* Container for CTtsParsedText.
+*
+* @lib TtsCustomCommands.lib
+* @since 2.8
+*/
+class TTtsParsedText
+    {
+    public:
+        
+        /**
+        * C++ default constructor.
+        */
+        TTtsParsedText() {}
+        
+        /**
+        * C++ constructor for this class.
+        *
+        * @since 2.8
+        * @param "CtsParsedText* aParsedText" Pointer to parsed text.
+        */
+        TTtsParsedText( CTtsParsedText* aParsedText ) : 
+                        iParsedText( aParsedText ) {}
+         
+        // Pointer to parsed text
+        CTtsParsedText* iParsedText;
+    };
+
+#endif // NSSTTSCUSTOMCOMMANDCOMMON_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/src/nssttscustomcommandparser.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,494 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "nssttscustomcommandparser.h"
+#include "nssttscustomcommandcommon.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::CTtsCustomCommandParser
+// C++ constructor.
+// -----------------------------------------------------------------------------
+//
+CTtsCustomCommandParser::CTtsCustomCommandParser( MTtsCustomCommandImplementor& aImplementor ) :
+        CMMFCustomCommandParserBase( KUidInterfaceTts ),
+        iImplementor( aImplementor )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTtsCustomCommandParser* CTtsCustomCommandParser::NewL( 
+        MTtsCustomCommandImplementor& aImplementor )
+    {
+    return new ( ELeave ) CTtsCustomCommandParser(aImplementor);
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::~CTtsCustomCommandParser
+// Destructor for CTtsCustomCommandParser class
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTtsCustomCommandParser::~CTtsCustomCommandParser()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::HandleRequest
+// Handles the client side request.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::HandleRequest( TMMFMessage& aMessage )
+    {
+    ASSERT( aMessage.Destination().InterfaceId() == KUidInterfaceTts );
+    TRAPD( error, DoHandleRequestL( aMessage ) );
+    if ( error )
+        {
+        aMessage.Complete( error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoHandleRequestL
+// Decodes aMessage and calls the correct function. This function is trapped by
+// HandleRequest() and the leave code, if any, sent to the client.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoHandleRequestL( TMMFMessage& aMessage )
+    {
+    
+    // Call required function to do the requested operation
+    switch( aMessage.Function() )
+        {
+        case ETtsAddStyle:
+            DoAddStyleL( aMessage );
+            break;
+
+        case ETtsDeleteStyle:
+            DoDeleteStyleL( aMessage );
+            break;
+
+        case ETtsGetPosition:
+            DoGetPositionL( aMessage );
+            break;
+
+        case ETtsNumberOfStyles:
+            DoNumberOfStylesL( aMessage );
+            break;
+
+        case ETtsOpenParsedText:
+            DoOpenParsedTextL( aMessage );
+            break;
+
+        case ETtsSetPosition:
+            DoSetPositionL( aMessage );
+            break;
+
+        case ETtsStyleID:
+            DoStyleIDL( aMessage );
+            break;
+
+        case ETtsStyleIndex:
+            DoStyleIndexL( aMessage );
+            break;
+
+        case ETtsSetDefaultStyle:
+            DoSetDefaultStyleL( aMessage );
+            break;
+
+        case ETtsGetDefaultStyle:
+            DoGetDefaultStyleL( aMessage );
+            break;
+
+        case ETtsSetSpeakingRate:
+            DoSetSpeakingRateL( aMessage );
+            break;
+
+        case ETtsGetSpeakingRate:
+            DoGetSpeakingRateL( aMessage );
+            break;
+
+        case ETtsSupportedLanguages:
+            DoGetSupportedLanguagesL( aMessage );
+            break;
+
+        case ETtsSupportedLanguagesCount:
+            DoGetSupportedLanguagesCountL( aMessage );
+            break;
+
+        case ETtsSupportedVoices:
+            DoGetSupportedVoicesL( aMessage );
+            break;
+
+        case ETtsSupportedVoicesCount:
+            DoGetSupportedVoicesCountL( aMessage );
+            break;
+
+        default:
+            User::Leave( KErrNotSupported );
+            
+        } // End of switch
+    
+    aMessage.Complete( KErrNone );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoAddStyleL
+// Calls the controller plugin to add a style.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoAddStyleL( TMMFMessage& aMessage )
+    {
+    TTtsStylePtrPckg stylePtrPckg;
+    TTtsStyleIDPtrPckg styleIDPtrPckg;
+
+	aMessage.ReadData1FromClientL( stylePtrPckg );
+	aMessage.ReadData2FromClientL( styleIDPtrPckg );
+
+    TTtsStyle* style = stylePtrPckg();
+    TTtsStyleID* ID = styleIDPtrPckg();
+
+    *ID = iImplementor.MttscAddStyleL( *style );
+
+    RUBY_DEBUG2( "CTtsCustomCommandParser::DoAddStyleL: %d, %x", *ID, style );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoDeleteStyleL
+// Calls the controller plugin to delete a style.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoDeleteStyleL( TMMFMessage& aMessage )
+    {
+    TTtsStyleIDPckg styleIDPckg;
+
+	aMessage.ReadData1FromClientL( styleIDPckg );
+
+    TTtsStyleID ID = styleIDPckg();
+
+    User::LeaveIfError( iImplementor.MttscDeleteStyle( ID ) );
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoDeleteStyleL: %d", ID );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetPositionL
+// Calls the controller plugin to get the synthesis position.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetPositionL( TMMFMessage& aMessage )
+    {
+    TTtsIntPtrPckg intPtrPckg;
+
+    aMessage.ReadData1FromClientL( intPtrPckg );
+
+    TInt* wordIndex = intPtrPckg();
+
+    iImplementor.MttscGetPositionL( *wordIndex );
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetPositionL: %d", *wordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoNumberOfStylesL
+// Calls the controller plugin to get the number of styles.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoNumberOfStylesL( TMMFMessage& aMessage )
+    {
+    TTtsUintPtrPckg uintPtrPckg;
+
+    aMessage.ReadData1FromClientL( uintPtrPckg );
+
+    TUint16* count = uintPtrPckg();
+
+    *count = iImplementor.MttscNumberOfStyles();
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoNumberOfStylesL: %d", *count );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoOpenParsedTextL
+// Calls the controller plugin to open a parsed text source.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoOpenParsedTextL( TMMFMessage& aMessage )
+    {
+    TTtsParsedTextPckg parsedTextPckg;
+
+    aMessage.ReadData1FromClientL( parsedTextPckg );
+
+    CTtsParsedText* parsedText = parsedTextPckg().iParsedText;
+
+    iImplementor.MttscOpenParsedTextL( *parsedText );
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoOpenParsedTextL: %x", parsedText );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoSetPositionL
+// Calls the controller plugin to set the synthesis position.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoSetPositionL( TMMFMessage& aMessage )
+    {
+    TTtsIntPckg intPckg;
+
+    aMessage.ReadData1FromClientL( intPckg );
+
+    TInt index = intPckg();
+
+    iImplementor.MttscSetPositionL( index );
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoSetPositionL: %d", index );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoStyleIDL
+// Calls the controller plugin to get the style based on ID.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoStyleIDL( TMMFMessage& aMessage )
+    {
+    TTtsStyleIDPckg styleIDPckg;
+    TTtsStylePtrPckg stylePckg;
+
+	aMessage.ReadData1FromClientL( styleIDPckg );
+	aMessage.ReadData2FromClientL( stylePckg );
+
+    TTtsStyleID ID = styleIDPckg();
+    TTtsStyle* style = stylePckg();
+
+    style = &( iImplementor.MttscStyleL( ID ) );
+
+    RUBY_DEBUG2( "CTtsCustomCommandParser::DoStyleIDL: %d, %x", ID, style );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoStyleIndexL
+// Calls the controller plugin to get the style based on ID.
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoStyleIndexL( TMMFMessage& aMessage )
+    {
+    TTtsUintPckg uintPckg;
+    TTtsStylePtrPckg stylePckg;
+
+	aMessage.ReadData1FromClientL( uintPckg );
+	aMessage.ReadData2FromClientL( stylePckg );
+
+    TUint16 index = uintPckg();
+    TTtsStyle* style = stylePckg();
+    
+    style = &( iImplementor.MttscStyleL( index ) );
+
+    RUBY_DEBUG2( "CTtsCustomCommandParser::DoStyleIndexL: %d, %x", index, style );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoSetDefaultStyleL
+// Calls the controller plugin to set the default style
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoSetDefaultStyleL( TMMFMessage& aMessage )
+    {
+    TTtsStylePtrPckg stylePtrPckg;
+
+	aMessage.ReadData1FromClientL( stylePtrPckg );
+
+    TTtsStyle* style = stylePtrPckg();
+
+    iImplementor.MttscSetDefaultStyleL( *style );
+
+    RUBY_DEBUG0( "CTtsCustomCommandParser::DoSetDefaultStyleL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetDefaultStyleL
+// Calls the controller plugin to get the default style
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetDefaultStyleL( TMMFMessage& aMessage )
+    {
+    TTtsStylePtrPckg stylePtrPckg;
+    
+    aMessage.ReadData1FromClientL( stylePtrPckg );
+    
+    TTtsStyle* style = stylePtrPckg();
+    
+    *style = iImplementor.MttscDefaultStyleL();
+    
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetDefaultStyleL: %x", style );
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoSetSpeakingRateL
+// Calls the controller plugin to set the speaking rate
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoSetSpeakingRateL( TMMFMessage& aMessage )
+    {
+    TTtsIntPckg intPckg;
+
+    aMessage.ReadData1FromClientL( intPckg );
+
+    TInt rate = intPckg();
+
+    iImplementor.MttscSetSpeakingRateL( rate );
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoSetSpeakingRateL: %d", rate );
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetSpeakingRateL
+// Calls the controller plugin to get the current speaking rate setting
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetSpeakingRateL( TMMFMessage& aMessage )
+    {
+    TTtsIntPtrPckg intPtrPckg;
+
+    aMessage.ReadData1FromClientL( intPtrPckg );
+
+    TInt* rate = intPtrPckg();
+
+    *rate = iImplementor.MttscSpeakingRateL();
+
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetSpeakingRateL: %d", *rate );
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetSupportedLanguagesL
+// Calls the controller plugin to get the supported languages
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetSupportedLanguagesL( TMMFMessage& aMessage )
+    {
+    TTtsRArrayLanguagePtrPckg rArrayLanguagePtrPckg;
+    
+    aMessage.ReadData1FromClientL( rArrayLanguagePtrPckg );
+    
+    RArray<TLanguage> languages = *rArrayLanguagePtrPckg();
+    
+    RArray<TLanguage> tmp;
+    CleanupClosePushL( tmp );
+    
+    iImplementor.MttscGetSupportedLanguagesL( tmp );
+    
+    if ( languages.Count() == tmp.Count() )
+        {
+        for ( TInt i( 0 ); i < languages.Count(); i++ )
+            {
+            languages[i] = tmp[i];
+            }
+        }
+    CleanupStack::PopAndDestroy( &tmp );
+    
+    RUBY_DEBUG1( "CTtsCustomCommandParser::DoGetSupportedLanguagesL: Number of languages %d", 
+                 languages.Count() );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetSupportedLanguagesCountL
+// Calls the controller plugin to get the number of supported languages
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetSupportedLanguagesCountL( TMMFMessage& aMessage )
+    {
+    TTtsIntPtrPckg intPtrPckg;
+
+    aMessage.ReadData1FromClientL( intPtrPckg );
+
+    TInt* languageCount = intPtrPckg();
+    
+    RArray<TLanguage> languages;
+    CleanupClosePushL( languages ); 
+    iImplementor.MttscGetSupportedLanguagesL( languages );
+    *languageCount = languages.Count();
+
+    CleanupStack::PopAndDestroy();
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetSupportedVoicesL
+// Calls the controller plugin to get the voices of specified language
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetSupportedVoicesL( TMMFMessage& aMessage )
+    {
+    TTtsLanguagePckg languagePckg;
+    TTtsRArrayTtsStylePtrPckg rArrayTtsStylePtrPckg;
+    
+    aMessage.ReadData1FromClientL( languagePckg );
+    aMessage.ReadData2FromClientL( rArrayTtsStylePtrPckg );
+    
+    TLanguage language = languagePckg();
+    RArray<TTtsStyle> voices = *rArrayTtsStylePtrPckg();
+    
+    RArray<TTtsStyle> tmp;
+    CleanupClosePushL( tmp );
+    
+    iImplementor.MttscGetSupportedVoicesL( language, tmp );
+    
+    if ( voices.Count() == tmp.Count() )
+        {
+        for ( TInt i( 0 ); i < voices.Count(); i++ )
+            {
+            voices[i] = tmp[i];
+            }
+        }
+    CleanupStack::PopAndDestroy( &tmp );
+    
+    RUBY_DEBUG2( "CTtsCustomCommandParser::DoGetSupportedVoicesL: %d voices for language %d", 
+                 voices.Count(), (TInt)language );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsCustomCommandParser::DoGetSupportedVoicesCountL
+// Calls the controller plugin to get the number of voices of specified language
+// -----------------------------------------------------------------------------
+//
+void CTtsCustomCommandParser::DoGetSupportedVoicesCountL( TMMFMessage& aMessage )
+    {
+    TTtsLanguagePckg languagePckg;
+    TTtsIntPtrPckg intPtrPckg;
+
+    aMessage.ReadData1FromClientL( languagePckg );
+    aMessage.ReadData2FromClientL( intPtrPckg );
+
+    TLanguage language = languagePckg();
+    TInt* voiceCount = intPtrPckg();
+    
+    RArray<TTtsStyle> voices;
+    CleanupClosePushL( voices ); 
+    iImplementor.MttscGetSupportedVoicesL( language, voices );
+    *voiceCount = voices.Count();
+
+    CleanupStack::PopAndDestroy( );
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttscustomcommands/src/nssttscustomcommands.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,272 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the implementation of the client interface for the
+*               TTS custom commands.
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssttscustomcommands.h"
+#include "nssttscustomcommandcommon.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::RTtsCustomCommands
+// C++ constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RTtsCustomCommands::RTtsCustomCommands( RMMFController& aController) :
+                             RMMFCustomCommandsBase( aController, 
+                             KUidInterfaceTts )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::AddStyleL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::AddStyle( const TTtsStyle& aStyle, 
+                                            TTtsStyleID& aID )
+    {
+    TTtsStylePtrPckg stylePtrPckg = ( TTtsStyle* ) &aStyle;
+    TTtsStyleIDPtrPckg styleIDPtrPckg = &aID;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsAddStyle,
+                                          stylePtrPckg, styleIDPtrPckg );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::DeleteStyle
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::DeleteStyle( TTtsStyleID aID )
+    {
+    TTtsStyleIDPckg styleIDPckg = aID;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsDeleteStyle, 
+                                          styleIDPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::GetPosition
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::GetPosition( TInt& aWordIndex )
+    {
+    TTtsIntPtrPckg intPtrPckg = &aWordIndex;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsGetPosition,
+                                          intPtrPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::NumberOfStyles
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::NumberOfStyles( TUint16& aNumber )
+    {
+	TTtsUintPtrPckg uintPtrPckg = &aNumber;
+	return iController.CustomCommandSync( iDestinationPckg, ETtsNumberOfStyles,
+									      uintPtrPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::OpenParsedTextL
+// 
+// -----------------------------------------------------------------------------
+//       
+EXPORT_C TInt RTtsCustomCommands::OpenParsedText( CTtsParsedText& aText )
+    {
+    TTtsParsedTextPckg parsedTextPckg( &aText );
+	return iController.CustomCommandSync( iDestinationPckg, ETtsOpenParsedText,
+									      parsedTextPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::SetPositionL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::SetPosition( TInt aWordIndex )
+    {
+    TTtsIntPckg intPckg = aWordIndex;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsSetPosition,
+                                          intPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::Style
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::Style( TTtsStyleID aStyleID, 
+                                         TTtsStyle& aStyle )
+    {
+    TTtsStyleIDPckg styleIDPckg = aStyleID;
+    TTtsStylePtrPckg stylePckg = &aStyle;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsStyleID,
+                                          styleIDPckg, stylePckg );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::StyleL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::Style( TUint16 aIndex, TTtsStyle& aStyle )
+    {
+    TTtsUintPckg uintPckg = aIndex;
+    TTtsStylePtrPckg stylePckg = &aStyle;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsStyleIndex,
+                                          uintPckg, stylePckg );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::SetDefaultStyle
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::SetDefaultStyle( const TTtsStyle& aStyle )
+    {
+    TTtsStylePtrPckg stylePtrPckg = ( TTtsStyle* ) &aStyle;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsSetDefaultStyle,
+                                          stylePtrPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::GetDefaultStyle
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::GetDefaultStyle( TTtsStyle& aStyle )
+    {
+    TTtsStylePtrPckg stylePtrPckg = &aStyle;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsGetDefaultStyle,
+                                          stylePtrPckg, KNullDesC8 );
+
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::SetSpeakingRate
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::SetSpeakingRate( TInt aRate )
+    {
+    TTtsIntPckg intPckg = aRate;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsSetSpeakingRate,
+                                          intPckg, KNullDesC8 );
+
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::GetSpeakingRate
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::GetSpeakingRate( TInt& aRate )
+    {
+    TTtsIntPtrPckg intPtrPckg = &aRate;
+    return iController.CustomCommandSync( iDestinationPckg, ETtsGetSpeakingRate,
+                                          intPtrPckg, KNullDesC8 );
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::GetSupportedLanguages
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::GetSupportedLanguages( RArray<TLanguage>& aLanguages )
+    {
+    TInt numberOfLanguages( -1 );
+    
+    TTtsIntPtrPckg intPtrPckg = &numberOfLanguages;
+    TInt error =
+        iController.CustomCommandSync( iDestinationPckg, ETtsSupportedLanguagesCount,
+                                       intPtrPckg, KNullDesC8 );
+    TInt i( 0 );
+        
+    while ( !error && i < numberOfLanguages )
+        {
+        i++;
+
+        error = aLanguages.Append( ELangNone );
+        }
+        
+    if ( error )
+        {
+        aLanguages.Reset();
+        }
+    else
+        {
+        TTtsRArrayLanguagePtrPckg rArrayLanguagePtrPckg = &aLanguages;
+    
+        error = iController.CustomCommandSync( iDestinationPckg, 
+                                               ETtsSupportedLanguages,
+                                               rArrayLanguagePtrPckg, 
+                                               KNullDesC8 );
+        }
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RTtsCustomCommands::GetSupportedVoices
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RTtsCustomCommands::GetSupportedVoices( TLanguage aLanguage, 
+                                                      RArray<TTtsStyle>& aVoices )
+    {
+    TInt numberOfVoices( -1 );
+    
+    TTtsLanguagePckg languagePckg = aLanguage;
+    TTtsIntPtrPckg intPtrPckg = &numberOfVoices;
+    
+    TInt error =
+        iController.CustomCommandSync( iDestinationPckg, ETtsSupportedVoicesCount,
+                                       languagePckg, intPtrPckg );
+                                       
+    TTtsStyle tmp;
+    TInt i( 0 );
+        
+    while ( !error && i < numberOfVoices )
+        {
+        i++;
+
+        error = aVoices.Append( tmp );
+        }
+    
+    if ( error )
+        {
+        aVoices.Reset();
+        }
+    else
+        {
+        TTtsRArrayTtsStylePtrPckg rArrayTtsStylePtrPckg = &aVoices;
+    
+        error = iController.CustomCommandSync( iDestinationPckg, 
+                                               ETtsSupportedVoices,
+                                               languagePckg, 
+                                               rArrayTtsStylePtrPckg );
+        }
+    
+    return error;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/bwins/nssttsutilityu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,48 @@
+EXPORTS	
+	?CreateInstanceL@CTtsUtility@@SAPAXXZ @ 1 NONAME ; void * CTtsUtility::CreateInstanceL(void)
+	??1CTtsUtility@@UAE@XZ @ 2 NONAME ; CTtsUtility::~CTtsUtility(void)
+	?AddStyleL@CTtsUtility@@UAEKABVTTtsStyle@@@Z @ 3 NONAME ; unsigned long CTtsUtility::AddStyleL(class TTtsStyle const &)
+	?Close@CTtsUtility@@UAEXXZ @ 4 NONAME ; void CTtsUtility::Close(void)
+	?CreateInstanceSecondPhaseL@CTtsUtility@@UAEXAAVMTtsClientUtilityObserver@@@Z @ 5 NONAME ; void CTtsUtility::CreateInstanceSecondPhaseL(class MTtsClientUtilityObserver &)
+	?CustomCommandAsync@CTtsUtility@@UAEXABV?$TPckgBuf@VTMMFMessageDestination@@@@HABVTDesC8@@1AAVTDes8@@AAVTRequestStatus@@@Z @ 6 NONAME ; void CTtsUtility::CustomCommandAsync(class TPckgBuf<class TMMFMessageDestination> const &, int, class TDesC8 const &, class TDesC8 const &, class TDes8 &, class TRequestStatus &)
+	?CustomCommandAsync@CTtsUtility@@UAEXABV?$TPckgBuf@VTMMFMessageDestination@@@@HABVTDesC8@@1AAVTRequestStatus@@@Z @ 7 NONAME ; void CTtsUtility::CustomCommandAsync(class TPckgBuf<class TMMFMessageDestination> const &, int, class TDesC8 const &, class TDesC8 const &, class TRequestStatus &)
+	?CustomCommandSync@CTtsUtility@@UAEHABV?$TPckgBuf@VTMMFMessageDestination@@@@HABVTDesC8@@1@Z @ 8 NONAME ; int CTtsUtility::CustomCommandSync(class TPckgBuf<class TMMFMessageDestination> const &, int, class TDesC8 const &, class TDesC8 const &)
+	?CustomCommandSync@CTtsUtility@@UAEHABV?$TPckgBuf@VTMMFMessageDestination@@@@HABVTDesC8@@1AAVTDes8@@@Z @ 9 NONAME ; int CTtsUtility::CustomCommandSync(class TPckgBuf<class TMMFMessageDestination> const &, int, class TDesC8 const &, class TDesC8 const &, class TDes8 &)
+	?DefaultStyleL@CTtsUtility@@UAEAAVTTtsStyle@@XZ @ 10 NONAME ; class TTtsStyle & CTtsUtility::DefaultStyleL(void)
+	?DeleteStyle@CTtsUtility@@UAEHK@Z @ 11 NONAME ; int CTtsUtility::DeleteStyle(unsigned long)
+	?Duration@CTtsUtility@@UAEABVTTimeIntervalMicroSeconds@@XZ @ 12 NONAME ; class TTimeIntervalMicroSeconds const & CTtsUtility::Duration(void)
+	?GetBalance@CTtsUtility@@UAEHAAH@Z @ 13 NONAME ; int CTtsUtility::GetBalance(int &)
+	?GetPosition@CTtsUtility@@UAEHAAH@Z @ 14 NONAME ; int CTtsUtility::GetPosition(int &)
+	?GetPosition@CTtsUtility@@UAEHAAVTTimeIntervalMicroSeconds@@@Z @ 15 NONAME ; int CTtsUtility::GetPosition(class TTimeIntervalMicroSeconds &)
+	?GetSupportedLanguagesL@CTtsUtility@@UAEXAAV?$RArray@W4TLanguage@@@@@Z @ 16 NONAME ; void CTtsUtility::GetSupportedLanguagesL(class RArray<enum TLanguage> &)
+	?GetSupportedVoicesL@CTtsUtility@@UAEXW4TLanguage@@AAV?$RArray@VTTtsStyle@@@@@Z @ 17 NONAME ; void CTtsUtility::GetSupportedVoicesL(enum TLanguage, class RArray<class TTtsStyle> &)
+	?GetVolume@CTtsUtility@@UAEHAAH@Z @ 18 NONAME ; int CTtsUtility::GetVolume(int &)
+	?ListPluginsL@CTtsUtility@@UAEXAAV?$RArray@VTUid@@@@@Z @ 19 NONAME ; void CTtsUtility::ListPluginsL(class RArray<class TUid> &)
+	?MaxVolume@CTtsUtility@@UAEHXZ @ 20 NONAME ; int CTtsUtility::MaxVolume(void)
+	?NewL@CTtsUtility@@SAPAV1@AAVMTtsClientUtilityObserver@@@Z @ 21 NONAME ; class CTtsUtility * CTtsUtility::NewL(class MTtsClientUtilityObserver &)
+	?NumberOfStyles@CTtsUtility@@UAEGXZ @ 22 NONAME ; unsigned short CTtsUtility::NumberOfStyles(void)
+	?OpenAndPlayDesL@CTtsUtility@@UAEXABVTDesC16@@@Z @ 23 NONAME ; void CTtsUtility::OpenAndPlayDesL(class TDesC16 const &)
+	?OpenAndPlayDesL@CTtsUtility@@UAEXABVTDesC8@@@Z @ 24 NONAME ; void CTtsUtility::OpenAndPlayDesL(class TDesC8 const &)
+	?OpenAndPlayFileL@CTtsUtility@@UAEXABVTDesC16@@@Z @ 25 NONAME ; void CTtsUtility::OpenAndPlayFileL(class TDesC16 const &)
+	?OpenAndPlayParsedTextL@CTtsUtility@@UAEXAAVCTtsParsedText@@@Z @ 26 NONAME ; void CTtsUtility::OpenAndPlayParsedTextL(class CTtsParsedText &)
+	?OpenDesL@CTtsUtility@@UAEXABVTDesC16@@@Z @ 27 NONAME ; void CTtsUtility::OpenDesL(class TDesC16 const &)
+	?OpenDesL@CTtsUtility@@UAEXABVTDesC8@@@Z @ 28 NONAME ; void CTtsUtility::OpenDesL(class TDesC8 const &)
+	?OpenFileL@CTtsUtility@@UAEXABVTDesC16@@@Z @ 29 NONAME ; void CTtsUtility::OpenFileL(class TDesC16 const &)
+	?OpenParsedTextL@CTtsUtility@@UAEXAAVCTtsParsedText@@@Z @ 30 NONAME ; void CTtsUtility::OpenParsedTextL(class CTtsParsedText &)
+	?OpenPluginL@CTtsUtility@@UAEXVTUid@@@Z @ 31 NONAME ; void CTtsUtility::OpenPluginL(class TUid)
+	?Pause@CTtsUtility@@UAEHXZ @ 32 NONAME ; int CTtsUtility::Pause(void)
+	?Play@CTtsUtility@@UAEXXZ @ 33 NONAME ; void CTtsUtility::Play(void)
+	?SetBalance@CTtsUtility@@UAEHH@Z @ 34 NONAME ; int CTtsUtility::SetBalance(int)
+	?SetDefaultStyleL@CTtsUtility@@UAEXABVTTtsStyle@@@Z @ 35 NONAME ; void CTtsUtility::SetDefaultStyleL(class TTtsStyle const &)
+	?SetOutputFileL@CTtsUtility@@UAEXABVRFile@@@Z @ 36 NONAME ; void CTtsUtility::SetOutputFileL(class RFile const &)
+	?SetPosition@CTtsUtility@@UAEXABVTTimeIntervalMicroSeconds@@@Z @ 37 NONAME ; void CTtsUtility::SetPosition(class TTimeIntervalMicroSeconds const &)
+	?SetPosition@CTtsUtility@@UAEXH@Z @ 38 NONAME ; void CTtsUtility::SetPosition(int)
+	?SetPriority@CTtsUtility@@UAEHHW4TMdaPriorityPreference@@@Z @ 39 NONAME ; int CTtsUtility::SetPriority(int, enum TMdaPriorityPreference)
+	?SetRepeats@CTtsUtility@@UAEXHABVTTimeIntervalMicroSeconds@@@Z @ 40 NONAME ; void CTtsUtility::SetRepeats(int, class TTimeIntervalMicroSeconds const &)
+	?SetSpeakingRateL@CTtsUtility@@UAEXH@Z @ 41 NONAME ; void CTtsUtility::SetSpeakingRateL(int)
+	?SetVolume@CTtsUtility@@UAEXH@Z @ 42 NONAME ; void CTtsUtility::SetVolume(int)
+	?SpeakingRateL@CTtsUtility@@UAEHXZ @ 43 NONAME ; int CTtsUtility::SpeakingRateL(void)
+	?Stop@CTtsUtility@@UAEXXZ @ 44 NONAME ; void CTtsUtility::Stop(void)
+	?StyleL@CTtsUtility@@UAEAAVTTtsStyle@@G@Z @ 45 NONAME ; class TTtsStyle & CTtsUtility::StyleL(unsigned short)
+	?StyleL@CTtsUtility@@UAEAAVTTtsStyle@@K@Z @ 46 NONAME ; class TTtsStyle & CTtsUtility::StyleL(unsigned long)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/eabi/nssttsutilityu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,97 @@
+EXPORTS	
+	_ZN11CTtsUtility15CreateInstanceLEv @ 1 NONAME
+	_ZN11CTtsUtility10GetBalanceERi @ 2 NONAME
+	_ZN11CTtsUtility10SetBalanceEi @ 3 NONAME
+	_ZN11CTtsUtility10SetRepeatsEiRK25TTimeIntervalMicroSeconds @ 4 NONAME
+	_ZN11CTtsUtility11DeleteStyleEm @ 5 NONAME
+	_ZN11CTtsUtility11GetPositionER25TTimeIntervalMicroSeconds @ 6 NONAME
+	_ZN11CTtsUtility11GetPositionERi @ 7 NONAME
+	_ZN11CTtsUtility11OpenPluginLE4TUid @ 8 NONAME
+	_ZN11CTtsUtility11SetPositionERK25TTimeIntervalMicroSeconds @ 9 NONAME
+	_ZN11CTtsUtility11SetPositionEi @ 10 NONAME
+	_ZN11CTtsUtility11SetPriorityEi22TMdaPriorityPreference @ 11 NONAME
+	_ZN11CTtsUtility12ListPluginsLER6RArrayI4TUidE @ 12 NONAME
+	_ZN11CTtsUtility13DefaultStyleLEv @ 13 NONAME
+	_ZN11CTtsUtility13SpeakingRateLEv @ 14 NONAME
+	_ZN11CTtsUtility14NumberOfStylesEv @ 15 NONAME
+	_ZN11CTtsUtility14SetOutputFileLERK5RFile @ 16 NONAME
+	_ZN11CTtsUtility15OpenAndPlayDesLERK6TDesC8 @ 17 NONAME
+	_ZN11CTtsUtility15OpenAndPlayDesLERK7TDesC16 @ 18 NONAME
+	_ZN11CTtsUtility15OpenParsedTextLER14CTtsParsedText @ 19 NONAME
+	_ZN11CTtsUtility16OpenAndPlayFileLERK7TDesC16 @ 20 NONAME
+	_ZN11CTtsUtility16SetDefaultStyleLERK9TTtsStyle @ 21 NONAME
+	_ZN11CTtsUtility16SetSpeakingRateLEi @ 22 NONAME
+	_ZN11CTtsUtility17CustomCommandSyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_ @ 23 NONAME
+	_ZN11CTtsUtility17CustomCommandSyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_R5TDes8 @ 24 NONAME
+	_ZN11CTtsUtility18CustomCommandAsyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_R14TRequestStatus @ 25 NONAME
+	_ZN11CTtsUtility18CustomCommandAsyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_R5TDes8R14TRequestStatus @ 26 NONAME
+	_ZN11CTtsUtility19GetSupportedVoicesLE9TLanguageR6RArrayI9TTtsStyleE @ 27 NONAME
+	_ZN11CTtsUtility22GetSupportedLanguagesLER6RArrayI9TLanguageE @ 28 NONAME
+	_ZN11CTtsUtility22OpenAndPlayParsedTextLER14CTtsParsedText @ 29 NONAME
+	_ZN11CTtsUtility26CreateInstanceSecondPhaseLER25MTtsClientUtilityObserver @ 30 NONAME
+	_ZN11CTtsUtility4NewLER25MTtsClientUtilityObserver @ 31 NONAME
+	_ZN11CTtsUtility4PlayEv @ 32 NONAME
+	_ZN11CTtsUtility4StopEv @ 33 NONAME
+	_ZN11CTtsUtility5CloseEv @ 34 NONAME
+	_ZN11CTtsUtility5PauseEv @ 35 NONAME
+	_ZN11CTtsUtility6StyleLEm @ 36 NONAME
+	_ZN11CTtsUtility6StyleLEt @ 37 NONAME
+	_ZN11CTtsUtility8DurationEv @ 38 NONAME
+	_ZN11CTtsUtility8OpenDesLERK6TDesC8 @ 39 NONAME
+	_ZN11CTtsUtility8OpenDesLERK7TDesC16 @ 40 NONAME
+	_ZN11CTtsUtility9AddStyleLERK9TTtsStyle @ 41 NONAME
+	_ZN11CTtsUtility9GetVolumeERi @ 42 NONAME
+	_ZN11CTtsUtility9MaxVolumeEv @ 43 NONAME
+	_ZN11CTtsUtility9OpenFileLERK7TDesC16 @ 44 NONAME
+	_ZN11CTtsUtility9SetVolumeEi @ 45 NONAME
+	_ZN11CTtsUtilityD0Ev @ 46 NONAME
+	_ZN11CTtsUtilityD1Ev @ 47 NONAME
+	_ZN11CTtsUtilityD2Ev @ 48 NONAME
+	_ZTI11CTtsUtility @ 49 NONAME ; #<TI>#
+	_ZTV11CTtsUtility @ 50 NONAME ; #<VT>#
+	_ZThn4_N11CTtsUtility10GetBalanceERi @ 51 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility10SetBalanceEi @ 52 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility10SetRepeatsEiRK25TTimeIntervalMicroSeconds @ 53 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11DeleteStyleEm @ 54 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11GetPositionER25TTimeIntervalMicroSeconds @ 55 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11GetPositionERi @ 56 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11OpenPluginLE4TUid @ 57 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11SetPositionERK25TTimeIntervalMicroSeconds @ 58 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11SetPositionEi @ 59 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility11SetPriorityEi22TMdaPriorityPreference @ 60 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility12ListPluginsLER6RArrayI4TUidE @ 61 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility13DefaultStyleLEv @ 62 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility13SpeakingRateLEv @ 63 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility14NumberOfStylesEv @ 64 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility14SetOutputFileLERK5RFile @ 65 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility15OpenAndPlayDesLERK6TDesC8 @ 66 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility15OpenAndPlayDesLERK7TDesC16 @ 67 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility15OpenParsedTextLER14CTtsParsedText @ 68 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility16OpenAndPlayFileLERK7TDesC16 @ 69 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility16SetDefaultStyleLERK9TTtsStyle @ 70 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility16SetSpeakingRateLEi @ 71 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility17CustomCommandSyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_ @ 72 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility17CustomCommandSyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_R5TDes8 @ 73 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility18CustomCommandAsyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_R14TRequestStatus @ 74 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility18CustomCommandAsyncERK8TPckgBufI22TMMFMessageDestinationEiRK6TDesC8S7_R5TDes8R14TRequestStatus @ 75 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility19GetSupportedVoicesLE9TLanguageR6RArrayI9TTtsStyleE @ 76 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility22GetSupportedLanguagesLER6RArrayI9TLanguageE @ 77 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility22OpenAndPlayParsedTextLER14CTtsParsedText @ 78 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility26CreateInstanceSecondPhaseLER25MTtsClientUtilityObserver @ 79 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility4PlayEv @ 80 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility4StopEv @ 81 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility5CloseEv @ 82 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility5PauseEv @ 83 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility6StyleLEm @ 84 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility6StyleLEt @ 85 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility8DurationEv @ 86 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility8OpenDesLERK6TDesC8 @ 87 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility8OpenDesLERK7TDesC16 @ 88 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility9AddStyleLERK9TTtsStyle @ 89 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility9GetVolumeERi @ 90 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility9MaxVolumeEv @ 91 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility9OpenFileLERK7TDesC16 @ 92 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtility9SetVolumeEi @ 93 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtilityD0Ev @ 94 NONAME ; #<thunk>#
+	_ZThn4_N11CTtsUtilityD1Ev @ 95 NONAME ; #<thunk>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for TtsUtility.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nssttsutility.mmp
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/group/nssttsutility.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for TTS Utility
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          nssttsutility.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101FF93A // UID: 270530874
+
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          nssttsutility.cpp
+SOURCE          ttsutilitybody.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../src
+USERINCLUDE     ../../group
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/mmf
+SYSTEMINCLUDE   /epoc32/include/mmf/server
+SYSTEMINCLUDE   /epoc32/include/mmf/common
+
+// For RUBY_DEBUG
+USERINCLUDE     ../../rubydebug
+
+LIBRARY         mediaclientaudio.lib
+LIBRARY         euser.lib
+LIBRARY         mmfcontrollerframework.lib
+LIBRARY         mmfstandardcustomcommands.lib
+LIBRARY         nssttscommon.lib
+LIBRARY         nssttscustomcommands.lib
+LIBRARY         ecom.lib
+LIBRARY         charconv.lib
+
+LANG            SC
+
+CAPABILITY      CAP_GENERAL_DLL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/src/nssttsutility.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,540 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementations for methods in CTtsUtility
+*
+*/
+
+
+// INCLUDE FILES
+#include "nssttsutility.h"
+#include "ttsutilitybody.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::CTtsUtility
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsUtility::CTtsUtility() 
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::CreateInstanceL
+// Creates CTtsUtility instance
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TAny* CTtsUtility::CreateInstanceL()
+    {
+    CTtsUtility* utility = new (ELeave) CTtsUtility();
+    return static_cast<MTtsUtilityBase*>( utility );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::CreateInstanceSecondPhaseL
+// Second phase construction after CreateInstanceL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::CreateInstanceSecondPhaseL( MTtsClientUtilityObserver& aObserver )
+    {
+    ConstructL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtility::ConstructL( MTtsClientUtilityObserver& aObserver )
+    {
+    iBody = CTtsUtilityBody::NewL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTtsUtility* CTtsUtility::NewL( MTtsClientUtilityObserver& aObserver )
+    {
+    CTtsUtility* self = new( ELeave ) CTtsUtility( );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aObserver );
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::~CTtsUtility
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTtsUtility::~CTtsUtility()
+    {
+    if ( iBody != NULL )
+        {
+        delete iBody;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenPluginL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenPluginL( TUid aUid )
+    {
+    iBody->OpenPluginL( aUid );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::ListPluginsL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::ListPluginsL( RArray<TUid>& aUids )
+    {
+    iBody->ListPluginsL( aUids );
+    }
+                
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetDefaultStyleL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetDefaultStyleL( const TTtsStyle& aStyle )
+    {
+    iBody->SetDefaultStyleL( aStyle );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::DefaultStyleL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle& CTtsUtility::DefaultStyleL()
+    {
+    return iBody->DefaultStyleL();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetSpeakingRateL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetSpeakingRateL( TInt aRate )
+    {
+    iBody->SetSpeakingRateL( aRate );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::SpeakingRateL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::SpeakingRateL()
+    {
+    return iBody->SpeakingRateL();
+    }
+     
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenDesL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenDesL( const TDesC& aDescriptor )
+    {
+    iBody->OpenDesL( aDescriptor );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenAndPlayDesL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenAndPlayDesL( const TDesC& aDescriptor )
+    {
+    iBody->OpenAndPlayDesL( aDescriptor );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::GetSupportedLanguagesL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::GetSupportedLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    iBody->GetSupportedLanguagesL( aLanguages );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::GetSupportedVoicesL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::GetSupportedVoicesL( TLanguage aLanguage, 
+                                                RArray<TTtsStyle>& aVoices )
+    {
+    iBody->GetSupportedVoicesL( aLanguage, aVoices );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetOutputFileL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetOutputFileL( const RFile& aFileName )
+    {
+    iBody->SetOutputFileL( aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::AddStyleL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyleID CTtsUtility::AddStyleL( const TTtsStyle& aStyle )
+    {
+    return iBody->AddStyleL( aStyle );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::DeleteStyle
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::DeleteStyle( TTtsStyleID aID )
+    {
+    return iBody->DeleteStyle( aID );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::NumberOfStyles
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint16 CTtsUtility::NumberOfStyles()
+    {
+    return iBody->NumberOfStyles();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::StyleL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle& CTtsUtility::StyleL( TTtsStyleID aStyleID )
+    {
+    return iBody->StyleL( aStyleID );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::StyleL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TTtsStyle& CTtsUtility::StyleL( TUint16 aIndex )
+    {
+    return iBody->StyleL( aIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::Play
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::Play()
+    {
+    iBody->Play();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::Stop
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::Stop()
+    {
+    iBody->Stop();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetVolume
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetVolume( TInt aVolume )
+    {
+    iBody->SetVolume( aVolume );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetRepeats
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetRepeats( TInt aRepeatNumberOfTimes, 
+                                       const TTimeIntervalMicroSeconds& aTrailingSilence )
+    {
+    iBody->SetRepeats( aRepeatNumberOfTimes, aTrailingSilence );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::Duration
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTimeIntervalMicroSeconds& CTtsUtility::Duration()
+    {
+    return iBody->Duration();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::MaxVolume
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::MaxVolume()
+    {
+    return iBody->MaxVolume();
+    }
+        
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenAndPlayDesL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenAndPlayDesL( const TDesC8& aDescriptor )
+    {
+    iBody->OpenAndPlayDesL( aDescriptor );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenAndPlayFileL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenAndPlayFileL( const TDesC& aFileName )
+    {
+    iBody->OpenAndPlayFileL( aFileName );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenAndPlayParsedTextL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenAndPlayParsedTextL( CTtsParsedText& aText )
+    {
+    iBody->OpenAndPlayParsedTextL( aText );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenFileL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenFileL( const TDesC& aFileName )
+    {
+    iBody->OpenFileL( aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenDesL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenDesL( const TDesC8& aDescriptor )
+    {
+    iBody->OpenDesL( aDescriptor );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::OpenParsedTextL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::OpenParsedTextL( CTtsParsedText& aText )
+    {
+    iBody->OpenParsedTextL( aText );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::Pause
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::Pause()
+    {
+    return iBody->Pause();
+    }   
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::Close
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::Close()
+    {
+    iBody->Close();
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::GetPosition
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::GetPosition( TTimeIntervalMicroSeconds& aPosition )
+    {
+    return iBody->GetPosition( aPosition );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::GetPosition
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::GetPosition( TInt& aWordIndex )
+    {
+    return iBody->GetPosition( aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetPosition
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetPosition( const TTimeIntervalMicroSeconds& aPosition )
+    {
+    iBody->SetPosition( aPosition );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetPosition
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::SetPosition( TInt aWordIndex )
+    {
+    iBody->SetPosition( aWordIndex );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetPriority
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::SetPriority( TInt aPriority, TMdaPriorityPreference aPref )
+    {
+    return iBody->SetPriority( aPriority, aPref );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::GetVolume
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::GetVolume( TInt& aVolume )
+    {
+    return iBody->GetVolume( aVolume );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::SetBalance
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::SetBalance( TInt aBalance )
+    {
+    return iBody->SetBalance( aBalance );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::GetBalance
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::GetBalance( TInt& aBalance )
+    {
+    return iBody->GetBalance( aBalance );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtility::CustomCommandSync
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                              TInt aFunction, 
+                                              const TDesC8& aDataTo1, 
+                                              const TDesC8& aDataTo2, 
+                                              TDes8& aDataFrom )
+    {
+    return iBody->CustomCommandSync( aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::CustomCommandSync
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CTtsUtility::CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                              TInt aFunction, 
+                                              const TDesC8& aDataTo1, 
+                                              const TDesC8& aDataTo2 )
+    {
+    return iBody->CustomCommandSync( aDestination, aFunction, aDataTo1, aDataTo2 );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::CustomCommandAsync
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination,  
+                                               TInt aFunction, 
+                                               const TDesC8& aDataTo1, 
+                                               const TDesC8& aDataTo2, 
+                                               TDes8& aDataFrom, 
+                                               TRequestStatus& aStatus )
+    {
+    iBody->CustomCommandAsync( aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtility::CustomCommandAsync
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CTtsUtility::CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination, 
+                                               TInt aFunction, 
+                                               const TDesC8& aDataTo1, 
+                                               const TDesC8& aDataTo2, 
+                                               TRequestStatus& aStatus )
+    {
+    iBody->CustomCommandAsync( aDestination, aFunction, aDataTo1, aDataTo2, aStatus );
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/src/ttsutilitybody.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1181 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementations for methods in CTtsUtilityBody
+*
+*/
+
+
+// INCLUDE FILES
+#include "ttsutilitybody.h"
+#include <mmf/server/mmffile.h>
+#include <mmf/server/mmfdes.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <ecom/ecom.h>
+#include <AudioPreference.h>
+#include <utf.h>
+#include "rubydebug.h"
+
+// CONSTANTS
+
+// TTS media type equals to audio media type
+const TUid KUidMediaTypeTTS = { 0x101F5D07 };
+
+// Implementation UID of Tts Plugin
+const TUid KUidTtsPlugin = { 0x101FF934 };
+
+// Implementation UID of HQ-TTS Plugin
+const TUid KUidHqTtsPlugin = { 0x10201AF5 };
+
+// Header for TTS input
+_LIT8( KTtsDataHeader, "(tts)" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CTtsUtilityBody
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTtsUtilityBody::CTtsUtilityBody( MTtsClientUtilityObserver& aObserver ) : 
+                                  iAudioPlayDeviceCommands( iController ),
+                                  iAudioPlayControllerCommands( iController ),
+                                  iTtsCustomCommands( iController ),
+                                  iObserver( aObserver ),
+                                  iTime( 0 ),
+                                  iCurrentStyleID( 0 ),
+                                  iTrailingSilence( 0 ),
+                                  iOpenPlugin( KNullUid ),
+                                  iUidOfDataSink( KUidMmfAudioOutput )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::ConstructL()
+    {
+    // Dummy priority settings
+    iPrioritySettings.iPriority = 0;
+    iPrioritySettings.iPref = ( TMdaPriorityPreference ) 0;
+    iPrioritySettings.iState = EMMFStateIdle; // idle
+    
+    // List plugins to make sure that at least one is found
+    RArray<TUid> temp;
+    ListPluginsL( temp );
+    temp.Close();
+
+    // Default audio priority
+    StorePriority( KAudioPriorityVoiceDial, 
+                   static_cast<TMdaPriorityPreference>( KAudioPrefVocosPlayback ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTtsUtilityBody* CTtsUtilityBody::NewL( MTtsClientUtilityObserver& aObserver )
+    {
+    CTtsUtilityBody* self = new( ELeave ) CTtsUtilityBody( aObserver );
+    
+    CleanupStack::PushL( self );
+
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::~CTtsUtilityBody
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CTtsUtilityBody::~CTtsUtilityBody()
+    {
+    // Cancel any pending requests
+    if ( iControllerEventMonitor != NULL )
+        {
+        iControllerEventMonitor->Cancel();
+        }
+
+    delete iControllerEventMonitor;
+    iController.Close();
+ 
+    iStyles.Close();
+    iInternalStyleIDs.Close();
+    iControllerStyleIDs.Close();
+    
+    delete iParsedText;
+    
+    REComSession::FinalClose();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::HandleEvent
+// Handles events from plugin via MMF.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::HandleEvent( const TMMFEvent& aEvent )
+    {
+    TInt result = (TInt)aEvent.iErrorCode;
+
+#ifdef _DEBUG
+    TInt event = (TInt)aEvent.iEventType.iUid;
+    RUBY_DEBUG2( "CTtsUtilityBody::HandleEvent() - Event Type = %d, Event Result = %d", 
+                 event, result );
+#endif
+    
+    if ( aEvent.iEventType == KMMFEventCategoryPlaybackComplete )
+        {
+        if ( result == KErrNone )
+            {
+            iRepeats--;
+            
+            if ( iRepeats > 0 )
+                {
+                // @todo Not too good way to handle waiting, we're blocking
+                // the client thread here... Should be done in plugin side..
+                User::After( iTrailingSilence );
+                Play();
+                // Don't make the callback at this point
+                return;
+                }
+            }
+        else
+            {
+            iRepeats = 0;
+            }
+        
+        iUidOfDataSink = KUidMmfAudioOutput;
+
+        // Remove data sink - otherwise file handle stays open. 
+        // Return value ignored because there is nothing we can do. 
+        iController.RemoveDataSink( iSinkHandle );
+
+        iObserver.MapcPlayComplete( result );
+        
+        }
+    else if ( aEvent.iEventType == KMMFEventCategoryAudioLoadingComplete )
+        {
+        if ( result != KErrNone )
+            {
+            iUidOfDataSink = KUidMmfAudioOutput; 
+            iController.RemoveDataSink( iSinkHandle );
+            }
+            
+        iTime = Duration();
+        iObserver.MapcInitComplete( result, iTime );
+        if ( iPlayImmediately )
+            {
+            iPlayImmediately = EFalse;
+            if ( result == KErrNone )
+                {
+                Play();
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::AddStyleL
+// Adds style to collection, calls TTS custom commands.
+// -----------------------------------------------------------------------------
+//
+TTtsStyleID CTtsUtilityBody::AddStyleL( const TTtsStyle& aStyle )
+    {
+    TTtsStyleID controllerID( 0 );
+    
+    if ( IsPluginOpen() )
+        {
+        User::LeaveIfError( iTtsCustomCommands.AddStyle( aStyle, controllerID ) );
+        }
+
+    // Add style also to our own array
+    iStyles.Append( aStyle );
+    TTtsStyleID internalID( iCurrentStyleID ); 
+    iInternalStyleIDs.Append( internalID );
+
+    // This is zero if no open controller connection, will be updated later
+    iControllerStyleIDs.Append( controllerID ); 
+    iCurrentStyleID++;
+
+    return internalID;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::DeleteStyle
+// Deletes style from collection, calls TTS custom commands.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::DeleteStyle( TTtsStyleID aID )
+    {
+    TTtsStyleID controllerStyleId( 0 );
+
+    // Delete from local storage
+    for ( TInt i = 0; i < iInternalStyleIDs.Count(); i++ )
+        {
+        if ( iInternalStyleIDs[i] == aID )
+            {
+            iInternalStyleIDs.Remove( i );
+            iStyles.Remove( i );
+            // Take note of the controller side style id before removing it
+            controllerStyleId = iControllerStyleIDs[i];
+            iControllerStyleIDs.Remove( i );
+            break;
+            }
+        }
+
+    // Reset style id counter if no styles registered anymore
+    if ( iInternalStyleIDs.Count() == 0 )
+        {
+        iCurrentStyleID = 0;
+        }
+
+    if ( IsPluginOpen() )
+        {
+        // Delete style from controller plugin
+        TInt error = iTtsCustomCommands.DeleteStyle( controllerStyleId );
+        if ( error != KErrNone )
+            {
+            return error;
+            }
+        }
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::NumberOfStyles
+// Returns number of registered styles.
+// -----------------------------------------------------------------------------
+//
+TUint16 CTtsUtilityBody::NumberOfStyles()
+    {
+    return ( TUint16 ) iStyles.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::StyleL
+// Returns reference to registered style based on style ID.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsUtilityBody::StyleL( TTtsStyleID aStyleID )
+    {
+    TInt i( 0 );
+    TInt count( iInternalStyleIDs.Count() );
+    
+    while ( i < count && iInternalStyleIDs[i] != aStyleID )
+        {
+        i++;
+        }
+    
+    if ( i == count )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    return iStyles[i];
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::StyleL
+// Returns reference to registered style based on style index.
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsUtilityBody::StyleL( TUint16 aIndex )
+    {
+    if ( aIndex >= iStyles.Count() )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    return iStyles[aIndex];
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::Play
+// Starts playback.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::Play()
+    {
+    iController.Play();
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::Stop
+// Stops playback.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::Stop()
+    {
+    iRepeats = 0;
+    iController.Stop();
+    iUidOfDataSink = KUidMmfAudioOutput;
+    iController.RemoveDataSink( iSinkHandle );
+    iPlayImmediately = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetVolume
+// Sets playback volume.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetVolume( TInt aVolume )
+    {
+    iAudioPlayDeviceCommands.SetVolume( aVolume );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetRepeats
+// Sets number of repeats.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetRepeats( TInt aRepeatNumberOfTimes, 
+                                  const TTimeIntervalMicroSeconds& aTrailingSilence )
+    {
+    iTrailingSilence = TTimeIntervalMicroSeconds32( I64LOW( aTrailingSilence.Int64() ) );
+    iRepeats = aRepeatNumberOfTimes;
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::Duration
+// Returns duration of TTS 'clip'.
+// -----------------------------------------------------------------------------
+//
+const TTimeIntervalMicroSeconds& CTtsUtilityBody::Duration()
+    {
+    iDuration = 0; 
+    iController.GetDuration( iDuration ); // Ignoring return value 
+    
+    return iDuration; 
+    } 
+    
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::MaxVolume
+// Returns maximum volume.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::MaxVolume()
+    {
+    TInt volume = 0;
+    if ( iAudioPlayDeviceCommands.GetMaxVolume( volume ) != KErrNone )
+        {
+        return 0;
+        }
+    return volume;
+    } 
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenAndPlayDesL
+// Opens descriptor source and plays it immediately.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenAndPlayDesL( const TDesC8& aDescriptor )
+    {
+    iPlayImmediately = ETrue;
+    
+    TRAPD( error, OpenDesL( aDescriptor ) );
+    if ( error != KErrNone )
+        {
+        iPlayImmediately = EFalse;
+        User::Leave( error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenAndPlayFileL
+// Opens file source and plays it immediately.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenAndPlayFileL( const TDesC& aFileName )
+    {
+    iPlayImmediately = ETrue;
+    
+    TRAPD( error, OpenFileL( aFileName ) );
+    if ( error != KErrNone )
+        {
+        iPlayImmediately = EFalse;
+        User::Leave( error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenAndPlayParsedTextL
+// Opens parsed text source and plays it immediately.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenAndPlayParsedTextL( CTtsParsedText& aText )
+    {
+    iPlayImmediately = ETrue;
+    
+    TRAPD( error, OpenParsedTextL( aText ) );
+    if ( error != KErrNone )
+        {
+        iPlayImmediately = EFalse;
+        User::Leave( error );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenDesL
+// Opens descriptor source 
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenDesL( const TDesC8& aDescriptor )
+    {
+    if ( !iPluginOpenedExplicitly )
+        {
+        CheckAndLoadCorrectPluginL( iDefaultStyle.iQuality, 
+                                    iDefaultStyle.iLanguage, 
+                                    iDefaultStyle.iVoice );
+        }
+
+    // Add data descriptor source
+    TMMFDescriptorConfig sourceCfg;
+    sourceCfg().iDes = (TAny*)&aDescriptor;
+    sourceCfg().iDesThreadId = RThread().Id();
+    User::LeaveIfError( iController.AddDataSource( KUidMmfDescriptorSource, 
+                                                   sourceCfg, iSourceHandle ) );
+
+    // Add data sink to file or audio output
+    AddDataSinkL();
+
+    // Prime controller
+    User::LeaveIfError( iController.Prime() );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenFileL
+// Opens file source
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenFileL( const TDesC& aFileName )
+    {
+    if ( !iPluginOpenedExplicitly )
+        {
+        CheckAndLoadCorrectPluginL( iDefaultStyle.iQuality, 
+                                    iDefaultStyle.iLanguage, 
+                                    iDefaultStyle.iVoice );
+        }
+
+    // Add data file source
+    TMMFFileConfig sourceCfg;
+    sourceCfg().iPath = aFileName;
+    User::LeaveIfError( iController.AddDataSource( KUidMmfFileSource, sourceCfg, 
+                                                   iSourceHandle ) );
+    // Add data sink to file or audio output
+    AddDataSinkL();
+        
+    // Prime controller
+    User::LeaveIfError( iController.Prime() );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenParsedTextL
+// Opens parsed text source with the help of TTS custom commands.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenParsedTextL( CTtsParsedText& aText )
+    {
+    if ( !iPluginOpenedExplicitly )
+        {
+        if ( aText.NumberOfSegments() > 0 )
+            {
+            // Take the first segment
+            const TTtsSegment& segment = aText.SegmentL( 0 );
+        
+            TTtsStyleID styleID = segment.StyleID();
+        
+            // Style should have been registered already
+            TTtsStyle& style = StyleL( styleID );
+        
+            CheckAndLoadCorrectPluginL( style.iQuality, style.iLanguage, 
+                                        style.iVoice );
+            }
+         else
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+
+    // Data source is now parsed text
+    CopyParsedTextL( aText );
+    User::LeaveIfError( iTtsCustomCommands.OpenParsedText( *iParsedText ) );
+
+    // Add data sink to file or audio output
+    AddDataSinkL();
+
+    User::LeaveIfError( iController.Prime() );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::Pause
+// Pauses playback.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::Pause()
+    {
+    return iController.Pause();
+    }   
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenPluginL
+// Opens connection to plugin
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenPluginL( TUid aUid )
+    {
+    OpenControllerConnectionL( aUid );
+    
+    iPluginOpenedExplicitly = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::ListPluginsL
+// Lists available plugins
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::ListPluginsL( RArray<TUid>& aUids )
+    {
+    // Empty the list
+    aUids.Reset();
+    
+    RMMFControllerImplInfoArray controllers;
+    CleanupResetAndDestroyPushL( controllers );
+    
+    CMMFControllerPluginSelectionParameters* selectionParams = CMMFControllerPluginSelectionParameters::NewLC();
+    
+    // Select the media IDs to allow
+    RArray<TUid> mediaIds;
+    CleanupClosePushL( mediaIds );
+    User::LeaveIfError( mediaIds.Append( KUidMediaTypeTTS ) );
+
+    selectionParams->SetMediaIdsL( mediaIds, CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds );
+    CleanupStack::PopAndDestroy( &mediaIds );
+    
+    // Check also the allowed data headers
+    // Should be "(tts)"
+    CMMFFormatSelectionParameters* formatSelectParams = CMMFFormatSelectionParameters::NewLC();
+    formatSelectParams->SetMatchToHeaderDataL( KTtsDataHeader );
+    
+    selectionParams->SetRequiredPlayFormatSupportL( *formatSelectParams );
+    
+    CleanupStack::PopAndDestroy( formatSelectParams );
+    
+    // Do the list of implementation
+    selectionParams->ListImplementationsL( controllers );    
+    
+    // Make sure at least one controller has been found
+    if( controllers.Count() == 0 )
+        {
+        RUBY_DEBUG1( "No controllers found using media type %x", KUidMediaTypeTTS );
+        User::Leave( KErrNotFound );
+        }
+
+    for ( TInt c = 0; c < controllers.Count(); c++ )
+        {
+        RUBY_DEBUG1( "UID = %x", controllers[c]->Uid() );
+        aUids.Append( controllers[c]->Uid() );
+        }
+
+    CleanupStack::PopAndDestroy( selectionParams );
+    CleanupStack::PopAndDestroy( &controllers ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetDefaultStyleL
+// Sets deafault style 
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetDefaultStyleL( const TTtsStyle& aStyle )
+    {
+    User::LeaveIfError( iTtsCustomCommands.SetDefaultStyle( aStyle ) );
+    iDefaultStyle = aStyle;
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::DefaultStyleL
+// Returns default style
+// -----------------------------------------------------------------------------
+//
+TTtsStyle& CTtsUtilityBody::DefaultStyleL()
+    {   
+    User::LeaveIfError( iTtsCustomCommands.GetDefaultStyle( iDefaultStyle ) );
+    return iDefaultStyle;
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetSpeakingRateL
+// Sets speaking rate
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetSpeakingRateL( TInt aRate )
+    {
+    User::LeaveIfError( iTtsCustomCommands.SetSpeakingRate( aRate ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SpeakingRateL
+// Returns speaking rate
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::SpeakingRateL()
+    {
+    TInt rate( KErrGeneral );
+    User::LeaveIfError( iTtsCustomCommands.GetSpeakingRate( rate ) );
+    return rate;
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetSupportedLanguagesL
+// Returns list of supported languages
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::GetSupportedLanguagesL( RArray<TLanguage>& aLanguages )
+    {
+    User::LeaveIfError( iTtsCustomCommands.GetSupportedLanguages( aLanguages ) );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetSupportedVoicesL
+// Returns list of supported voices
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::GetSupportedVoicesL( TLanguage aLanguage, 
+                                           RArray<TTtsStyle>& aVoices )
+    {
+    User::LeaveIfError( iTtsCustomCommands.GetSupportedVoices( aLanguage, aVoices ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenDesL
+// Opens unicode descriptor
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenDesL( const TDesC& aDescriptor )
+    {
+    HBufC8* utf8string = ConvertToUtf8LC( aDescriptor );
+    OpenDesL( utf8string->Des() );
+    CleanupStack::PopAndDestroy( utf8string );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetSupportedVoicesL
+// Opens and plays unicode descriptor
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenAndPlayDesL( const TDesC& aDescriptor )
+    {
+    HBufC8* utf8string = ConvertToUtf8LC( aDescriptor );
+    OpenAndPlayDesL( utf8string->Des() );
+    CleanupStack::PopAndDestroy( utf8string );        
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetOutputFileL
+// Sets output to be written to the file handle 
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetOutputFileL( const RFile& aFile )
+    {
+    iUidOfDataSink = KUidMmfFileSink; 
+
+    // iFile has to contain valid file handle when data sink 
+    // is marked to be file sink. 
+    iFile = aFile; 
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::Close
+// Closes current TTS synthesis source.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::Close()
+    {
+    iRepeats = 0;
+    if ( iControllerEventMonitor != NULL )
+        {
+        iControllerEventMonitor->Cancel();
+        }
+    delete iControllerEventMonitor;
+    iControllerEventMonitor = NULL;
+    iController.Close();
+    iPluginOpenedExplicitly = EFalse;
+    iOpenPlugin = KNullUid;
+    iUidOfDataSink = KUidMmfAudioOutput;
+    }        
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetPosition
+// Returns position of synthesis in microseconds.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::GetPosition( TTimeIntervalMicroSeconds& aPosition )
+    {
+    return iController.GetPosition( aPosition );
+    }
+       
+ 
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetPosition
+// Returns position of synthesis in words.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::GetPosition( TInt& aWordIndex )
+    {
+    return iTtsCustomCommands.GetPosition( aWordIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetPosition
+// Sets synthesis position in microseconds.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetPosition( const TTimeIntervalMicroSeconds& aPosition )
+    {
+    iController.SetPosition( aPosition );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetPosition
+// Sets synthesis position in words.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::SetPosition( TInt aWordIndex )
+    {
+    iTtsCustomCommands.SetPosition( aWordIndex );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetPriority
+// Sets playback priority.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::SetPriority( TInt aPriority, TMdaPriorityPreference aPref )
+    {
+    StorePriority( aPriority, aPref );
+
+    if ( IsPluginOpen() )
+        {
+        return iController.SetPrioritySettings( iPrioritySettings );
+        }
+    else
+        {
+        return KErrNone;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetVolume
+// Returns volume value.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::GetVolume( TInt& aVolume )
+    {
+    return iAudioPlayDeviceCommands.GetVolume( aVolume );
+    }
+        
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::SetBalance
+// Sets balance.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::SetBalance( TInt aBalance )
+    {
+    return iAudioPlayDeviceCommands.SetBalance( aBalance );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::GetBalance
+// Returns current balance setting.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::GetBalance( TInt& aBalance )
+    {
+    return iAudioPlayDeviceCommands.GetBalance( aBalance );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CustomCommandSync
+// Sends synchronous custom command via MMF.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2, 
+                                         TDes8& aDataFrom )
+    {
+    return iController.CustomCommandSync( aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CustomCommandSync
+// Sends synchronous custom command via MMF.
+// -----------------------------------------------------------------------------
+//
+TInt CTtsUtilityBody::CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2 )
+    {
+    return iController.CustomCommandSync( aDestination, aFunction, aDataTo1, aDataTo2 );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CustomCommandAsync
+// Sends asynchronous custom command via MMF.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination,  
+                                          TInt aFunction, 
+                                          const TDesC8& aDataTo1, 
+                                          const TDesC8& aDataTo2, 
+                                          TDes8& aDataFrom,
+                                          TRequestStatus& aStatus )
+    {
+    iController.CustomCommandAsync( aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CustomCommandAsync
+// Sends asynchronous custom command via MMF.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination, 
+                                          TInt aFunction, 
+                                          const TDesC8& aDataTo1, 
+                                          const TDesC8& aDataTo2, 
+                                          TRequestStatus& aStatus )
+    {
+    iController.CustomCommandAsync( aDestination, aFunction, aDataTo1, aDataTo2, aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::IsPluginOpen
+// Returns ETrue if connection is established with controller plugin
+// -----------------------------------------------------------------------------
+//
+TBool CTtsUtilityBody::IsPluginOpen()
+    {
+    if ( iOpenPlugin == KNullUid )
+        {
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::OpenControllerConnectionL
+// Opens controller connection if it has been closed
+// Changes plugin if the one requested is not loaded currently
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::OpenControllerConnectionL( TUid aPluginUid )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsUtilityBody::OpenControllerConnectionL(aPluginUid)" );
+    
+    if ( iOpenPlugin != aPluginUid )
+        {
+        // Clear previously loaded plugin if needed
+        if ( IsPluginOpen() )
+            {
+            Close();
+            }
+
+        TInt error = iController.Open( aPluginUid, iPrioritySettings );
+        if ( error ) 
+            {
+            RUBY_DEBUG2( "Unable to load controller plugin, error = %d, UID = %x", 
+                         error, aPluginUid );            
+            User::Leave( error );
+            }
+        else
+            {
+            if ( iControllerEventMonitor == NULL )
+                {
+                // Start the event monitor
+                iControllerEventMonitor = CMMFControllerEventMonitor::NewL( *this, iController );
+                iControllerEventMonitor->Start();
+                }
+            }
+      
+        iOpenPlugin = aPluginUid;
+
+        // Add already registered styles to controller plugin too         
+        for ( TInt i( 0 ); i < iStyles.Count(); i++ )
+            {
+            TTtsStyleID controllerStyleId( 0 );
+            User::LeaveIfError( iTtsCustomCommands.AddStyle( iStyles[i], controllerStyleId ) );
+            iControllerStyleIDs[i] = controllerStyleId;
+            } 
+        
+        // Set priority settings
+        User::LeaveIfError( SetPriority( iPrioritySettings.iPriority, 
+                                         (TMdaPriorityPreference) iPrioritySettings.iPref ) );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CopyParsedTextL
+// Copies parsed text structure and substitutes style ids to corresponding plugin
+// ids.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::CopyParsedTextL( CTtsParsedText& aText )
+    {
+    RUBY_DEBUG_BLOCK( "CTtsUtilityBody::CopyParsedTextL" );
+
+    // Delete previous object if exists
+    delete iParsedText;
+    iParsedText = NULL;
+
+    // New instance
+    iParsedText = CTtsParsedText::NewL( aText.Text(), aText.PhonemeSequence(),
+                                        aText.PhonemeNotation() );
+
+    // Segments
+
+    // Indexes for starting points for segment's text and phoneme part in
+    // CTtsParsedText object's text and phoneme sequence    
+    TInt textIndex( 0 );
+    TInt phonemeIndex( 0 );
+
+    for ( TInt i = 0; i < aText.NumberOfSegments(); i++ )
+        {
+        TTtsSegment segment = aText.SegmentL( i );
+        
+        TInt styleIndex = iInternalStyleIDs.Find( aText.SegmentL( i ).StyleID() );
+        User::LeaveIfError( styleIndex );
+        segment.SetStyleID( iControllerStyleIDs[styleIndex] );
+        
+        TInt segTextLength = aText.SegmentL( i ).TextPtr().Length();
+        TInt segPhonemeSeqLength = aText.SegmentL( i )
+                                      .PhonemeSequencePtr().Length();
+        
+        // Text
+        if ( textIndex + segTextLength
+             <= iParsedText->Text().Length() )
+            {
+            segment.SetTextPtr( iParsedText->Text()
+                                .Mid( textIndex, segTextLength ) );
+            
+            textIndex += segTextLength;
+            }
+        // Segments are somehow constructed illegally. Copy the whole text.
+        else
+            {
+            segment.SetTextPtr( iParsedText->Text() );
+            }
+        
+        // Phoneme sequence
+        if ( phonemeIndex + segPhonemeSeqLength
+             <= iParsedText->PhonemeSequence().Length() )
+            {
+            segment.SetPhonemeSequencePtr(
+                iParsedText->PhonemeSequence().Mid( phonemeIndex, segPhonemeSeqLength ) );
+            
+            phonemeIndex += segPhonemeSeqLength;
+            }
+        else
+            {
+            segment.SetPhonemeSequencePtr(
+                iParsedText->PhonemeSequence() );
+            }
+
+        // Add segment to the new instance of CTtsParsedText
+        iParsedText->AddSegmentL( segment );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::StorePriority
+// Stores priority values locally to be sent to the plugin when connection is
+// opened.
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::StorePriority( TInt aPriority, TMdaPriorityPreference aPref )
+    {
+    iPrioritySettings.iPriority = aPriority;
+    iPrioritySettings.iPref = aPref;
+    iPrioritySettings.iState = EMMFStateIdle;
+    }    
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::ConvertToUtf8LC
+// Converts unicode descriptor to utf-8
+// -----------------------------------------------------------------------------
+//
+HBufC8* CTtsUtilityBody::ConvertToUtf8LC( const TDesC& aDes )
+    {
+    HBufC8* utf8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aDes );
+    CleanupStack::PushL( utf8 );
+    return utf8;
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::AddDataSinkL
+// Adds data sink (file and audio supported)
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::AddDataSinkL()
+    {
+    RUBY_DEBUG_BLOCKL( "CTtsUtilityBody::AddDataSinkL" );
+    
+    if ( iUidOfDataSink == KUidMmfAudioOutput )
+        {
+        User::LeaveIfError( iController.AddDataSink( KUidMmfAudioOutput, 
+                                                     KNullDesC8, iSinkHandle ) ); 
+        }
+    else if ( iUidOfDataSink == KUidMmfFileSink )
+        {
+        TMMFFileHandleConfig destCfg( &iFile );
+
+        TInt error = iController.AddDataSink( KUidMmfFileSink,destCfg, iSinkHandle ); 
+        if ( error )
+            {
+            iUidOfDataSink = KUidMmfAudioOutput; 
+            User::Leave( error ); 
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::CheckAndLoadCorrectPluginL
+// 
+// -----------------------------------------------------------------------------
+//
+void CTtsUtilityBody::CheckAndLoadCorrectPluginL( TTtsQuality aQuality, 
+                                                  TLanguage aLanguage, 
+                                                  const TTtsVoice& aVoice )
+    {
+    RUBY_DEBUG_BLOCKL( "CTtsUtilityBody::CheckAndLoadCorrectPluginL" );
+    
+    TInt error( KErrNone );
+    
+    switch ( aQuality )
+        {
+        case ETtsQualityHighOnly:
+
+            OpenControllerConnectionL( KUidHqTtsPlugin );
+            
+            break;
+            
+        case ETtsQualityLowOnly:
+        case ETtsQualityUndefined:
+        
+            OpenControllerConnectionL( KUidTtsPlugin );
+                
+            break;
+            
+        case ETtsQualityHighPreferred:
+
+            TRAP( error, OpenControllerConnectionL( KUidHqTtsPlugin ) );
+            if ( error || !IsSupportedSpeaker( aLanguage, aVoice ) )
+                {
+                // Try to use Klatt if Hqtts not found or specific language/speaker 
+                // not available
+                OpenControllerConnectionL( KUidTtsPlugin );
+                }
+                
+            break;
+            
+        case ETtsQualityLowPreferred:
+
+            TRAP( error, OpenControllerConnectionL( KUidTtsPlugin ) );
+            if ( error || !IsSupportedSpeaker( aLanguage, aVoice ) )
+                {
+                // Try to use Hqtts if Klatt not found or specific language/speaker 
+                // not available
+                OpenControllerConnectionL( KUidHqTtsPlugin );
+                }
+        
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CTtsUtilityBody::IsSupportedSpeaker
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CTtsUtilityBody::IsSupportedSpeaker( TLanguage aLanguage, 
+                                           const TTtsVoice& aVoice )
+    {
+    TBool answer( EFalse );
+    
+    if ( aLanguage == KTtsUndefinedLanguage )
+        {
+        // Undefined language -> plugin can use default language and voice.
+        answer = ETrue;
+        }
+    else
+        {
+        RArray<TLanguage> languages;
+        iTtsCustomCommands.GetSupportedLanguages( languages );
+
+        if ( languages.Find( aLanguage ) != KErrNotFound )
+            {
+            if ( aVoice == KNullDesC )
+                {
+                // Language found and undefined voice
+                answer = ETrue;
+                }
+            else
+                {
+                RArray<TTtsStyle> voices;
+                iTtsCustomCommands.GetSupportedVoices( aLanguage, voices );
+                
+                TInt counter( 0 );
+
+                while ( answer == EFalse && counter < voices.Count() )
+                    {
+                    if ( voices[counter].iVoice == aVoice )
+                        {
+                        // Both language and voice are supported 
+                        // by currently loaded plugin.
+                        answer = ETrue;
+                        }
+                        
+                    counter++;
+                    }
+                        
+                voices.Close();
+                }
+            }
+            
+        languages.Close();
+        }
+        
+    return answer;
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/ttsutility/src/ttsutilitybody.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,666 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Body behind TTS Utility API
+*
+*/
+
+
+#ifndef TTSUTILITYBODY_H
+#define TTSUTILITYBODY_H
+
+// INCLUDES
+#include <nssttsutility.h>
+#include <mdaaudiosampleplayer.h>
+#include <nssttscustomcommands.h>
+#include "srsfbldvariant.hrh"
+
+// CLASS DECLARATION
+
+/**
+* Implementation for TTS Utility API.
+*
+* @lib TtsUtility.lib
+* @since 2.8
+*/
+NONSHARABLE_CLASS( CTtsUtilityBody ) : public CBase, 
+                                       public MMdaAudioPlayerCallback, 
+                                       public MMMFControllerEventMonitorObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CTtsUtilityBody* NewL( MTtsClientUtilityObserver& aObserver );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTtsUtilityBody();
+        
+    public: // New functions
+        
+        
+        /**
+        * Opens connection to a specific plugin.
+        *
+        * @param "TUid aUid" Plugin UID which will be instantiated
+        */
+        void OpenPluginL( TUid aUid );
+        
+        /**
+        * Lists UIDs of available Text-To-Speech plugins.
+        *
+        * @param "RArray<TUid>& aUids" Output parameter which will contain the
+        *                              list of plugin UIDs after function call.
+        */
+        void ListPluginsL( RArray<TUid>& aUids );        
+       
+        /**
+        * Sets the default style parameters for synthesis.
+        *
+        * @param "const TTtsStyle& aStyle" Style created by the client
+        */
+        void SetDefaultStyleL( const TTtsStyle& aStyle );
+        
+        /**
+        * Returns the registered default style
+        *
+        * @return Style reference
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        TTtsStyle& DefaultStyleL();
+        
+        /**
+        * Sets the speaking rate of synthesizer.
+        *
+        * @param TInt aRate Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        */        
+        void SetSpeakingRateL( TInt aRate );
+        
+        /**
+        * Returns the current speaking rate value.
+        *
+        * @return Speaking rate value
+        * @leave KErrNotSupported if synthesizer does not support speaking rate setting
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        TInt SpeakingRateL();
+       
+        /**
+        * Returns the list of supported languages.
+        * 
+        * @param "RArray<TLanguage>& aLanguages" Output parameter which contains the languages
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        void GetSupportedLanguagesL( RArray<TLanguage>& aLanguages );
+        
+        /**
+        * Returns the list of supported voices for a certain language.
+        * 
+        * @param "TLanguage aLanguage" Language
+        * @param "RArray<TVoice>& aVoices" Output parameter which contains the voices
+        * @leave KErrNotReady if no plugin is loaded to handle the function call
+        */
+        void GetSupportedVoicesL( TLanguage aLanguage, RArray<TTtsStyle>& aVoices );
+        
+        /**
+        * Open a descriptor ready for playback
+        *
+        * @param "const TDesC& aDescriptor" Descriptor containing the text to be synthesized.
+        * @since 3.2        
+        */
+        void OpenDesL( const TDesC& aDescriptor ); 
+
+        /**
+        * Opens a descriptor and plays it.
+        *
+        * @param "const TDesC& aDescriptor" Descriptor to play 
+        * @since 3.2
+        */
+        void OpenAndPlayDesL( const TDesC& aDescriptor );          
+        
+        /**
+        * Directing output of a next synthesis to the specified file
+        *
+        * @param "RFile& aFile" Open file handle to save output of next synthesis.
+        * @since 3.2
+        */
+        void SetOutputFileL( const RFile& aFile );
+        
+        /**
+        * Adds new style to style collection.
+        *
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Assigned style ID.
+        */
+        TTtsStyleID AddStyleL( const TTtsStyle& aStyle );
+
+        /**
+        * Deletes style from the style collection.
+        *
+        * @param "TTtsStyle& aStyle" Reference to style.
+        * @return Error code.
+        */
+        TInt DeleteStyle( TTtsStyleID aID );
+
+        /**
+        * Returns number of styles.
+        *
+        * @return Number of styles.
+        */
+        TUint16 NumberOfStyles();
+
+        /**
+        * Returns style based on style ID
+        *
+        * @param "TTtsStyleID aStyleID" Style identifier.
+        * @return Reference to found style.
+        */
+        TTtsStyle& StyleL( TTtsStyleID aStyleID );
+
+        /**
+        * Returns style based on index.
+        *
+        * @param "TUint16 aIndex" Index.
+        * @return Reference to found style.
+        */
+        TTtsStyle& StyleL( TUint16 aIndex );
+
+        /**
+        * Begins playback of the initialised audio sample at the current volume
+        * and priority levels.
+        *
+        * When playing of the audio sample is complete, successfully or
+        * otherwise, the callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is
+        * called. This function raises a CMdaAudioPlayerUtility 1 panic if the
+        * audio player utility is not initialised.
+        */
+        void Play();
+
+        /**
+        * Stops playback of the audio sample as soon as possible.
+        *
+        * If the audio sample is playing, playback is stopped as soon as
+        * possible. If playback is already complete, nothing further happens as
+        * a result of calling this function. The callback function
+        * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is not
+        * called.The function raises a CMdaAudioPlayerUtility 1 panic if the
+        * audio player utility is not initialised.
+        */
+        void Stop();
+        
+        /**
+        * Changes the current playback volume to a specified value.
+        *
+        * The volume can be changed before or during playback and is effective
+        * immediately. The function raises a CMdaAudioPlayerUtility 1 panic if
+        * the audio player utility is not initialised.
+        *
+        * @param	"TInt aVolume"
+        *          The volume setting. This can be any value from zero to
+        *          the value returned by a call to
+        *          <code>CMdaAudioPlayerUtility::MaxVolume()</code>.
+        *          Setting a zero value mutes the sound. Setting the
+        *          maximum value results in the loudest possible sound.
+        */
+        void SetVolume( TInt aVolume );
+        
+        /**
+        * Sets the number of times the audio sample is to be repeated during the
+        * playback operation.
+        *
+        * A period of silence can follow each playing of the sample. The audio
+        * sample can be repeated indefinitely.
+        *
+        * @param	"TInt aRepeatNumberOfTimes"
+        *          The number of times the audio sample, together with
+        *          the trailing silence, is to be repeated. If this is
+        *          set to <code>KMdaRepeatForever</code>, then the audio
+        *          sample, together with the trailing silence, is
+        *          repeated indefinitely or until <code>Stop()</code> is
+        *          called. If this is set to zero, then the audio sample
+        *          is not repeated.
+        * @param   "const TTimeIntervalMicroSeconds& aTrailingSilence"
+        *          The time interval of the trailing silence.
+        */
+        void SetRepeats( TInt aRepeatNumberOfTimes, 
+                                  const TTimeIntervalMicroSeconds& aTrailingSilence );
+        
+        /**
+        * Returns the duration of the audio sample.
+        *
+        * The function raises a CMdaAudioPlayerUtility 1 panic if the audio
+        * player utility is not initialised.
+        *
+        * @returns "TTimeIntervalMicroSeconds&"
+        *          The duration in microseconds
+        */
+        const TTimeIntervalMicroSeconds& Duration();
+        
+        /**
+        * Returns an integer representing the maximum volume.
+        *
+        * This is the maximum value which can be passed to
+        * <code>CMdaAudioPlayerUtility::SetVolume()</code>. The function raises a
+        * CMdaAudioPlayerUtility 1 panic if the audio player utility is not
+        * initialised.
+        *
+        * @returns "TInt"
+        *          The maximum volume. This value is platform dependent
+        *          but is always greater than or equal to one.
+        */
+        TInt MaxVolume();
+
+        /**
+        * Opens a descriptor source and plays it.
+        *
+        * @param "TDesC8& aDescriptor" Descriptor to play.
+        */
+        void OpenAndPlayDesL( const TDesC8& aDescriptor );
+
+        /**
+        * Opens a file source and plays it.
+        *
+        * @param "TDesC& aFileName" File to play.
+        */
+        void OpenAndPlayFileL( const TDesC& aFileName );
+
+        /**
+        * Opens a parsed text source and plays it.
+        *
+        * @param "CTtsParsedText& aText" Parsed text object to play.
+        */
+        void OpenAndPlayParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Open a clip from a file
+        *
+        * @param	"const TDesC& aFileName" 
+        *			File to open
+        * @leave	Leaves with one of the system wide error codes if a problem is encountered
+        *			opening the file
+        */
+        void OpenFileL( const TDesC& aFileName );
+
+        /**
+        * Open a clip from a descriptor
+        *
+        * @param	"const TDesC8& aDescriptor" 
+        *			Descriptor containing audio clip
+        * @leave	Leaves with one of the system wide error codes if a problem is encountered
+        *			opening the file
+        */
+        void OpenDesL( const TDesC8& aDescriptor );
+
+        /**
+        * Open parsed text source.
+        *
+        * @param "CTtsParsedText& aText" Reference to parsed text object.
+        */
+        void OpenParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Pauses playback of the audio clip
+        * @returns One of the system-wide error codes
+        */
+        TInt Pause();
+        
+        /**
+        * Closes the current audio clip (allowing another clip to be opened)
+        */
+        void Close();
+        
+        /**
+        * Returns the current playback position in microseconds
+        *
+        * @retval "TTimeIntervalMicroSeconds& aPosition"
+        *          The current time position in microseconds from the start of the file
+        * @returns One of the global error codes
+        */
+        TInt GetPosition( TTimeIntervalMicroSeconds& aPosition );
+        
+        /**
+        * Returns the current playback position in word index.
+        *
+        * @retval "TInt& aWordIndex" The current position in words.
+        * @return Error code.
+        */
+        TInt GetPosition( TInt& aWordIndex );
+
+        /**
+        * Set the current playback position in microseconds from the start of the file
+        *
+        * @param "TTimeIntervalMicroSeconds& aPosition"
+        *          The position to move to in microseconds past the start of the file
+        */
+        void SetPosition( const TTimeIntervalMicroSeconds& aPosition );
+        
+        /**
+        * Set the current playback position in word index.
+        *
+        * @param "TInt aWordIndex" Playback position.
+        */
+        void SetPosition( TInt aWordIndex );
+
+        /**
+        *
+        * Set the priority for playback. This is used to arbitrate between multiple 
+        * objects trying to access a single sound device
+        *
+        * @param "TInt aPriority"
+        * @param "TMdaPriorityPreference aPref"
+        *         Quality/time preference tradeoff
+        * 
+        * @returns "TInt" One of the global error codes
+        */
+        TInt SetPriority( TInt aPriority, TMdaPriorityPreference aPref );
+        
+        /**
+        * Returns the current playback volume
+        *
+        * @retval "TInt& aVolume"
+        *          A volume value between 0 and the value returned by <code>MaxVolume()</code>
+        * @returns "TInt" One of the global error codes
+        */
+        TInt GetVolume( TInt& aVolume );
+        
+        /**
+        * Sets the current playback balance
+        *
+        * @param "TInt& aBalance"
+        *        A value between <code>KMMFBalanceMaxLeft</code> 
+        *        and <code>KMMFBalanceMaxRight</code>. The default value is 
+        *        <code>KMMFBalanceCenter</code>
+        * @returns "TInt" One of the global error codes
+        */
+        TInt SetBalance( TInt aBalance = KMMFBalanceCenter );
+        
+        /**
+        * Returns the current playback balance
+        *
+        * @retval "TInt& aBalance"
+        *         A value between <code>KMMFBalanceMaxLeft</code> 
+        *         and <code>KMMFBalanceMaxRight</code>
+        * @returns "TInt" One of the global error codes
+        */
+        TInt GetBalance( TInt& aBalance );
+        
+        /**
+        * Send a synchronous custom command to the controller
+        * @param "aDestination"	"The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataFrom" "A reference to an area of memory to which the controller framework will 
+        *        write any data to be passed back to the client.  Can't be KNullDesC8."
+        * @return "The result of the request. Exact range of values is dependent on the interface."
+        */
+        TInt CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2, 
+                                         TDes8& aDataFrom);
+        /**
+        * Send a synchronous custom command to the controller
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *		 the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *         framework. The exact contents of the data are dependent on the 
+        *         interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *         framework. The exact contents of the data are dependent on the 
+        *         interface being called.  Can be KNullDesC8."
+        * @return "The result of the request. Exact range of values is dependent on the interface."
+        */
+        TInt CustomCommandSync( const TMMFMessageDestinationPckg& aDestination, 
+                                         TInt aFunction, 
+                                         const TDesC8& aDataTo1, 
+                                         const TDesC8& aDataTo2 );
+        /**
+        * Send a asynchronous custom command to the controller
+        * Note: This method will return immediately.  The RunL of the active object owning the 
+        * <code>aStatus<\code> parameter will be called when the command is completed by the 
+        * controller framework.
+        * @param "aDestination" "The destination of the message, consisting of the uid of
+        *        the interface of this message."
+        * @param "aFunction" "The function number to indicate which function is to be called
+        *        on the interface defined in the aDestination parameter."
+        * @param "aDataTo1" "A reference to the first chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataTo2" "A reference to the second chunk of data to be copied to the controller 
+        *        framework. The exact contents of the data are dependent on the 
+        *        interface being called.  Can be KNullDesC8."
+        * @param "aDataFrom" "A reference to an area of memory to which the controller framework will 
+        *        write any data to be passed back to the client.  Can't be KNullDesC8."
+        * @param "aStatus" "The TRequestStatus of an active object.  This will contain the 
+        *        result of the request on completion.  The exact range of 
+        *        result values is dependent on the interface."
+        */
+        void CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination,  
+                                          TInt aFunction, 
+                                          const TDesC8& aDataTo1, 
+                                          const TDesC8& aDataTo2, 
+                                          TDes8& aDataFrom, 
+                                          TRequestStatus& aStatus );
+        /**
+        * Send a asynchronous custom command to the controller
+        * Note: This method will return immediately.  The RunL of the active object owning the 
+        * <code>aStatus<\code> parameter will be called when the command is completed by the 
+        * controller framework.
+        * @param 	"aDestination"	"The destination of the message, consisting of the uid of
+        *							the interface of this message."
+        * @param	"aFunction"		"The function number to indicate which function is to be called
+        *							on the interface defined in the aDestination parameter."
+        * @param	"aDataTo1"		"A reference to the first chunk of data to be copied to the controller 
+        *							framework. The exact contents of the data are dependent on the 
+        *							interface being called.  Can be KNullDesC8."
+        * @param	"aDataTo2"		"A reference to the second chunk of data to be copied to the controller 
+        *							framework. The exact contents of the data are dependent on the 
+        *							interface being called.  Can be KNullDesC8."
+        * @param 	"aStatus"		"The TRequestStatus of an active object.  This will contain the 
+        *							result of the request on completion.  The exact range of 
+        * 							result values is dependent on the interface."
+        * @since					7.0s
+        */
+        void CustomCommandAsync( const TMMFMessageDestinationPckg& aDestination, 
+                                          TInt aFunction, 
+                                          const TDesC8& aDataTo1, 
+                                          const TDesC8& aDataTo2, 
+                                          TRequestStatus& aStatus );
+
+    public: // Functions from MMdaAudioPlayerCallback
+        
+        void MapcInitComplete( TInt /*aError*/, const TTimeIntervalMicroSeconds& /*aDuration*/ ) {}
+        void MapcPlayComplete( TInt /*aError*/ ) {}
+
+
+    public: // Functions from MMMFControllerEventMonitorObserver
+
+        void HandleEvent( const TMMFEvent& aEvent );
+      
+    private:
+        
+        /**
+        * C++ default constructor.
+        *
+        * @param "MTtsClientUtilityObserver& aObserver" Reference to observer.
+        */
+        CTtsUtilityBody( MTtsClientUtilityObserver& aObserver );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        // Prohibit copy constructor if not deriving from CBase.
+        CTtsUtilityBody( const CTtsUtilityBody& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CTtsUtilityBody& operator=( const CTtsUtilityBody& );
+
+        /**
+        * Utility function to open connection to controller plugin.
+        *
+        * @param "TUid aPluginUid" Plugin UID
+        */
+        void OpenControllerConnectionL( TUid aPluginUid );
+
+        /**
+        * Utility function to copy parsed text structure and convert style ids.
+        *
+        * @param "CTtsParsedText& aText" Parsed text which is copied
+        */        
+        void CopyParsedTextL( CTtsParsedText& aText );
+
+        /**
+        * Checks if there is an existing connection to some controller plugin
+        * 
+        * @return ETrue if there is an connection
+        */
+        TBool IsPluginOpen();
+        
+        /**
+        * Stores priority settings but does not send them to the controller
+        * plugin just yet.
+        *
+        * @param "TInt aPriority" Audio priority 
+        * @param "TMdaPriorityPreference aPref" Audio preference
+        */
+        void StorePriority( TInt aPriority, TMdaPriorityPreference aPref );
+        
+        /**
+        * Handles conversion from unicode to utf-8
+        *
+        * @param "const TDesC& aDes" Unicode descriptor
+        * @return Pointer to created buffer, pushed to cleanupstack
+        */
+        HBufC8* ConvertToUtf8LC( const TDesC& aDes );
+        
+        /**
+        * Adds data sink to controller according iUidOfDataSink and iOutputFile. 
+        */
+        void AddDataSinkL();
+        
+        /**
+        * Responds that the correct plugin is loaded 
+        *
+        * @param "TTtsQuality aQuality" Synthesis quality parameter
+        * @param "TLanguage aLanguage" Synthesis language
+        * @param "const TTtsVoice& aVoice" Synthesis voice
+        */
+        void CheckAndLoadCorrectPluginL( TTtsQuality aQuality, TLanguage aLanguage, 
+                                         const TTtsVoice& aVoice );
+        
+        /**
+        * Tells if currently loaded plugin can handle synthesis with given parameters
+        * 
+        * @param "TLanguage aLanguage" Language to be used
+        * @param "const TTtsVoice& aVoice" Voice to be used
+        * @return ETrue if parameters are supported
+        */
+        TBool IsSupportedSpeaker( TLanguage aLanguage, const TTtsVoice& aVoice );
+
+    private: // Data
+
+        // Client side representation of controller plugin in use
+        RMMFController iController;
+
+        // Audio custom commands
+        RMMFAudioPlayDeviceCustomCommands iAudioPlayDeviceCommands;
+        RMMFAudioPlayControllerCustomCommands iAudioPlayControllerCommands;
+        
+        // Tts custom commands
+        RTtsCustomCommands iTtsCustomCommands;
+        
+        // Pointer to controller event monitor
+        CMMFControllerEventMonitor* iControllerEventMonitor;
+        
+        // Reference to observer
+        MTtsClientUtilityObserver& iObserver;
+        
+        // Source and sink handle info
+        TMMFMessageDestination iSourceHandle;
+        TMMFMessageDestination iSinkHandle;
+        
+        // Duration of the current TTS "clip"
+        TTimeIntervalMicroSeconds iDuration;
+        
+        // Latest read position of synthesising
+        TTimeIntervalMicroSeconds iPosition;
+        
+        // Plugin priority settings.
+        TMMFPrioritySettings iPrioritySettings;
+
+        // Duration of current TTS 'clip'
+        TTimeIntervalMicroSeconds iTime;
+
+        // Registered styles, these will be kept in two places: locally
+        // in TtsUtility and in TtsHwDevice in server side.
+        RArray<TTtsStyle> iStyles;
+
+        // Registered style IDs. (internal to TtsUtility)
+        RArray<TTtsStyleID> iInternalStyleIDs;
+
+        // Registered style IDs. (plugin id)
+        RArray<TTtsStyleID> iControllerStyleIDs;
+
+        // Increased numbering for style ids
+        TTtsStyleID iCurrentStyleID;
+
+        // Flag to tell if playback should be started immediately after priming
+        // has finished.
+        TBool iPlayImmediately;
+
+        // Counter to tell how many times playback should be repeated.
+        TInt iRepeats;
+
+        // Trailing silence when repeating the playback
+        TTimeIntervalMicroSeconds32 iTrailingSilence;
+
+        // UID of controller plugin which has been created
+        TUid iOpenPlugin;
+        
+        // Etrue if user has opened plugin by calling function OpenPluginL()
+        TBool iPluginOpenedExplicitly;
+    
+        // Parsed text which is given to the controller plugin
+        CTtsParsedText* iParsedText;
+    
+        // Default style structure
+        TTtsStyle iDefaultStyle;
+        
+        // Uid of data sink to be used 
+        TUid iUidOfDataSink;
+        
+        // Output file handle if data sink is set to file output
+        RFile iFile;
+    };
+
+#endif // TTSUTILITY_H   
+
+// End of File
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/data/vcexecutorapp.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application resource file of VCExecutorApp
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    VCEA
+
+#include <appinfo.rh>
+#include <eikon.rsg>
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <avkon.rh>
+#include <BTUI.rsg>
+#include "appcontroller.hrh"
+
+#include <vcexecutorapp.loc>
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF r_default_document_name { buf="VCExecutorApp"; }
+
+RESOURCE EIK_APP_INFO
+    {
+    status_pane = r_vcexecutor_status_pane;   
+    }
+
+//-----------------------------------------------------------------------------
+// Status pane
+//-----------------------------------------------------------------------------
+//
+RESOURCE STATUS_PANE_APP_MODEL r_vcexecutor_status_pane
+    {
+    layout = R_AVKON_STATUS_PANE_LAYOUT_IDLE;
+    }
+
+//-----------------------------------------------------------------------------
+// Empty title pane for hiding default title
+//-----------------------------------------------------------------------------
+//
+RESOURCE TITLE_PANE r_empty_title_pane   
+    {
+    txt = " ";
+    }
+    
+//-----------------------------------------------------------------------------
+// Empty app info so that the application won't be shown in the app grid
+//-----------------------------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
+    {
+    short_caption = "";
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "";
+        number_of_icons = 0;
+        icon_file = "";
+        };
+    }
+
+//-----------------------------------------------------------------------------
+// Confirmation query
+// Displays a confirmation query on whether Bluetooth is to be activated in 
+// off-line mode
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_bt_activate_in_offline_query
+    {
+    flags   = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_YES_NO__YES;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtQuery;
+            id      = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout    = EConfirmationQueryLayout;
+                label     = qtn_vcexec_bt_activate_in_offline;
+                animation = R_QGN_NOTE_QUERY_ANIM;
+                };
+            }
+        };
+    }
+
+// ----------------------------------------------------------------------------
+// Confirmation query
+// Displays a confirmation query for leaving off-line mode
+// ----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_leave_offline_profile_confirmation_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_YES_NO__YES;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = qtn_leave_offline_mode_query; // avkon.loc
+                };
+            }
+        };
+    } 
+
+RESOURCE TBUF r_bt_offline_disabled   { buf = qtn_vcexec_bt_offline_disabled; }
+
+RESOURCE TBUF	r_bt_general_error      { buf = qtn_vcexec_bt_offline_disabled; }
+
+// from avkon.loc
+RESOURCE TBUF	r_text_insert_sim       { buf = qtn_su_note_insert_sim; }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/data/vcexecutorapp_reg.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+#include <vcexecutorapp.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x10281D15 // Define your application UID here
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "vcexecutorapp";
+    launch = KAppLaunchInBackground;
+    localisable_resource_file = APP_RESOURCE_DIR"\\vcexecutorapp";
+    localisable_resource_id = R_LOCALISABLE_APP_INFO;
+    
+    // We don't want to show the icon in application grid. 
+    hidden = KAppIsHidden; 
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2001 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+#include "exports.inc"
+
+//../AppController/Inc/AppController.h		APP_LAYER_PLATFORM_EXPORT_PATH( AppController.h )
+//../AppController/Inc/AppControllerImpl.h	APP_LAYER_PLATFORM_EXPORT_PATH( AppControllerImpl.h )
+//../AppController/Inc/AppControllerConstants.h	APP_LAYER_PLATFORM_EXPORT_PATH( AppControllerConstants.h )
+//../AppController/Inc/AppController.hrh		APP_LAYER_PLATFORM_EXPORT_PATH( AppController.hrh )
+
+#ifdef __SIND
+//../SINDInc/backup_registration.xml z:/private/101F8555/backup_registration.xml
+#endif
+
+//../SINDInc/VCommandInternalCRKeys.h	APP_LAYER_PLATFORM_EXPORT_PATH( VCommandInternalCRKeys.h )
+
+
+#ifdef __SERIES60_HELP
+//../SDNDInc/vcommand.hlp.hrh /epoc32/include/cshelp/vcommand.hlp.hrh
+#endif
+
+PRJ_MMPFILES
+vcexecutorapp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* ==============================================================================
+*        %name: exports.inc %
+*     %version: 7 %
+*      Part of: VUIPF / vcexecutorapp
+*  Description: VCExecutorApp exports
+*
+*  Copyright © 2007 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+* ==============================================================================
+*/
+
+#include <platform_paths.hrh>
+../loc/vcexecutorapp.loc APP_LAYER_LOC_EXPORT_PATH(vcexecutorapp.loc)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/group/vcexecutorapp.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implements all the VCommands inherted from S60 2.8
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          vcexecutorapp.exe
+
+TARGETTYPE      EXE
+
+// 20K of stack
+EPOCSTACKSIZE   0x5000
+
+UID             0x100039CE 0x10281D15
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_APPLICATION NetworkControl
+
+SOURCEPATH      ../data
+
+START RESOURCE  vcexecutorapp.rss
+DEPENDS btui.rsg
+HEADER
+TARGETPATH      APP_RESOURCE_DIR
+LANGUAGE_IDS
+END
+
+START RESOURCE vcexecutorapp_reg.rss
+DEPENDS vcexecutorapp.rsg
+// Do not change the UID below.
+TARGETPATH /private/10003a3f/apps
+END
+
+SOURCEPATH      ../src
+SOURCE        appcontroller.cpp
+SOURCE        appcontrollerpropertyhandler.cpp
+SOURCE        appcontrolleractiveobject.cpp
+SOURCE        vcexecutorapp.cpp
+SOURCE        vcexecutorappui.cpp
+SOURCE        vcexecutorappdocument.cpp
+
+USERINCLUDE     ../../rubydebug
+USERINCLUDE     ../inc
+
+
+// This is a SYSTEMINCLUDE macro containing the application
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+//APP_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY         euser.lib
+LIBRARY         profileeng.lib
+LIBRARY         vmbx.lib            // RVmbxNumber
+LIBRARY         btengsettings.lib
+LIBRARY         bafl.lib
+LIBRARY         ws32.lib            // RWsSession
+LIBRARY         featmgr.lib
+LIBRARY         apparc.lib          // StartApp
+LIBRARY         apgrfx.lib          // RLsApaSession
+LIBRARY         commonengine.lib    // StringLoader
+LIBRARY         aknnotify.lib
+LIBRARY         centralrepository.lib
+LIBRARY         cone.lib 
+LIBRARY         sendui.lib
+LIBRARY         muiu.lib
+LIBRARY         avkon.lib
+LIBRARY         eikcore.lib 
+LIBRARY         eikcoctl.lib 
+LIBRARY         eikdlg.lib
+LIBRARY         servicehandler.lib
+LIBRARY         aiwdialdata.lib
+LIBRARY         gslauncher.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/appcontroller.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,287 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the implementation class for the
+*                application controller interface 
+*
+*/
+
+
+#ifndef __CVCAPPLICATIONCONTROLLERIMPL_H__
+#define __CVCAPPLICATIONCONTROLLERIMPL_H__
+
+
+//  INCLUDES
+#include "appcontrollerconstants.h"
+#include "appcontroller.hrh"
+#include <e32base.h>
+#include <e32std.h>
+#include <barsread.h>
+#include <apgcli.h>
+#include <eikenv.h>
+#include <coecntrl.h>
+#include <eikappui.h>
+#include <AiwCommon.h>
+
+// Phone
+#include <PhCltTypes.h>
+
+
+// Bluetooth engine API
+#include <btengsettings.h>
+
+
+// Vmbx Engine API
+#include <vmnumber.h>
+#include <w32std.h>
+#include <PbkFields.hrh>
+#include <vmbx.rsg>
+
+#include <e32property.h>        // RProperty
+#include <PSVariables.h>        // Property values
+#include <MProfileEngine.h>
+
+// FORWARD DECLARATIONS
+class CAknPopupList;
+class CAppControllerPropertyHandler;
+class CUidNameArray;
+class CSendUi;
+class CAppControllerActiveObject;
+class CAknGlobalConfirmationQuery;
+
+// CLASS DECLARATION
+
+/**
+* This is the implementation class for launching applications and initiating profiles.
+* @lib AppController.lib
+* @since 2.0
+*/
+
+class CVCApplicationControllerImpl : public CCoeControl,
+                                                      public MAiwNotifyCallback
+    {
+    public:  // Constructors and destructor
+
+    enum TState
+      {
+      EVoiceMail,
+      ENewMessage,
+      EQueryDialog
+      };
+
+        /**
+        * Two-phased constructor.
+        */
+        static CVCApplicationControllerImpl* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVCApplicationControllerImpl();
+
+    public: // New functions
+        
+        /**
+        * Generic function used to execute a voice command
+        * @param aCommandId     ID of command to be executed.
+        * @param aParameters    The name of the application of profile.
+        * @return TInt          KErrNone if OK, else value indicating error situation.
+        */
+        TInt ExecuteCommandL( TUint aCommandId, const TDesC& aParameters );
+        
+        /**
+        * Generic function to be used to execute voice command
+        * @since Averell 2.0
+        * @param aCommandId     ID of command to be executed.
+        * @param aParameters    The name of the application of profile.
+        * @return TInt          KErrNone if OK, else value indicating error situation.
+        */
+        TInt DoExecuteCommandL( TUint aCommandId, const TDesC& aParameters );
+
+    public: // Functions from base classes
+
+        /*
+        * From CCoeControl
+        * @see CCoeControl
+        */
+        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+        
+        /*
+        * From MAiwNotifyCallback
+        * @see MAiwNotifyCallback For more detailed information
+        */
+        TInt HandleNotifyL( TInt aCmdId, TInt aEventId,
+                            CAiwGenericParamList& aEventParamList,
+                            const CAiwGenericParamList& aInParamList );
+        
+    public: // New functions
+
+        /**
+        * Handles the incoming call 
+        * @since 2.8
+        * @return void
+        */
+        void HandleCurrentCallStatusChange();
+
+        /**
+        * Receives active object events and acts according to them
+        * @since 2.8
+        * @param aStatus active object status
+        * @return void
+        */
+        void HandleActiveObjectStatus(TInt aStatus);
+        
+    private: // Constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CVCApplicationControllerImpl();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: // New functions
+
+        /**
+        * Initiates profiles
+        * @since 2.0
+        * @param aCommandId The Profile Id
+        * @return void
+        */
+        void ProfileEngL(TUint aCommandId);
+
+        /**
+        * Call to the Voice mailbox number and if no number is defined
+        * it asks user to enter it and thern makes the call.
+        * @since 2.0
+        * @return TInt Standard Symbian error code
+        */
+        TInt VmbxEngL();
+
+        /**
+        * Activates/deactivates the Bluetooth power mode 
+        * @since 2.0
+        * @return TInt Standard Symbian error code
+        */
+#ifdef __BT
+        TInt BTEngL();
+#endif
+
+        /**
+        * Cancels the NewMessage Dialog
+        * @since 2.0
+        * @return void
+        */
+        void Cancel();
+
+        /**
+        * Gets the flags associated with offline mode.
+        * @param aOfflineModeOff Offline mode flag
+        * @param aBTActivationEnabled BT activation flag
+        * @return None.
+        */
+        void GetOfflineModeFlagsL( TInt& aOfflineModeOff, 
+                                   TInt& aBTActivationEnabled ) const;
+
+        /**
+        * Returns CSendUi object
+        * @since 3.0
+        * @return CSendUi
+        */
+        CSendUi& MHandlesSendAppUi();
+
+        /**
+        * Activates the user selected message editor
+        * @since 2.6
+        * @param aType a message type (sms, mms, email).
+        * @return TInt an error code
+        */
+        TInt ActivateMessageL( TEditorType aType );
+
+        /**
+        * Gets the flags associated with SIM card.
+        * @param aSIMCardMode, SIM card mode flag
+        * @return None.
+        */
+        void GetSIMCardMode( TInt& aSIMCardMode ) const;
+        
+        /**
+        * Connects to RApaLsSession.
+        * @since 3.0
+        * @return void
+        */  
+        void CreateApaConnectionL();
+
+        /* Activates an instance of an application.
+        * @since 3.0
+        * @param aUid Application UID
+        * @param aCommandLine Command line parameters.
+        * @return void
+        */
+        void ActivateAppInstanceL( const TUid aUid );
+    
+        /**
+        * Used to launch applications. Checks whether an instance of the launched
+        * application is already running.
+        * @since 3.0
+        * @param aUid The Uid of the specific application.
+        * @param aCommandLine Command line parameters.
+        * @param aMultipleInstances If true, the application is activated
+        *        in multiple instances.
+        * @return void
+        */
+        void ActivateAppL( const TUid aUid,
+                           TBool aMultipleInstances = EFalse );
+                           
+        /**
+        * Does voice call to voicemailbox number
+        *
+        * @param aNumber Phone number to be called
+        */                   
+        void DialVmbxL( const TDesC& aNumber );
+        
+        /* 
+        * Closes query dialog
+        */
+        void DismissQueryDialog();
+        
+    private:     // Data
+        
+        //for the new message menu
+        CAknPopupList*                       iPopupList; // Not owned
+        RApaLsSession*                       iApaLsSession;    
+        TInt                                 iResourceFileOffset;
+        CAppControllerPropertyHandler*       iPropertyHandler;
+        TBool                                iPSEventCheckStatus;
+        
+        CVCApplicationControllerImpl::TState iState;
+        RVmbxNumber                          iVmbx;
+        TBool                                iCallStatus;
+        // array for supported message types
+        CUidNameArray*                       iMsgTypes;
+        // send ui for launching message editors
+        CSendUi*                             iSendUi;
+        CAppControllerActiveObject*          iActiveObject;
+        CAknGlobalConfirmationQuery*         iGlobalConfQuery;
+        MProfileEngine*                      iProfileEngine;
+        TInt                                 iProfileId;
+        CAknQueryDialog*                     iQueryDialog;
+        CActiveSchedulerWait                 iWait;
+    };
+
+#endif      // CVCAPPLICATIONCONTROLLERIMPL_H   
+            
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/appcontroller.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains declarations for resources of Application Controller.
+*               The file can be included in C++ or resource file.
+*
+*/
+
+
+#ifndef APPCONTROLLER_HRH
+#define APPCONTROLLER_HRH
+
+//  CONSTANTS
+
+/**
+* Application ids used to
+* check which application needs to be started
+*/
+enum TMainAppControlIds
+    {
+    // Core applications
+    EAppVoiceMail = 1,
+#ifdef __BT
+    EAppBluetooth = 2,
+#endif
+    EAppWriteMessage = 3,
+	EAppWriteEmail = 4,
+    EAppWritePostcard = 5,
+    EAppApplicationManagerCPView = 6,
+    EAppVoiceCommandCPView = 7
+    };
+
+enum TSendUiId
+	{
+	EAppSendUi
+	};
+
+
+// Type of message editor object
+enum TEditorType
+    {
+	EEditorTypeNewMessage,
+    EEditorTypeNewEmail,
+    EEditorTypePostcard
+    };
+
+#endif // APPCONTROLLER_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/appcontrolleractiveobject.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Active object to handle global list query results.
+*
+*/
+
+#ifndef CAPPCONTROLLERACTIVEOBJECT_H
+#define CAPPCONTROLLERACTIVEOBJECT_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+
+// FORWARD DECLARATIONS
+class CVCApplicationControllerImpl;
+
+/**
+*  Active object to handle note results.
+*/
+class CAppControllerActiveObject : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor.
+        * 
+        */
+        CAppControllerActiveObject(CVCApplicationControllerImpl& aController);
+     
+        /**
+        * Destructor.
+        */
+        virtual ~CAppControllerActiveObject();
+
+
+    public: // Functions from base classes
+
+        /**
+        * @see CActive::DoCancel.
+        */
+        void DoCancel();
+
+        /**
+        * @see CActive::RunL.
+        */
+        void RunL();
+
+        /**
+        * @see CActive::RunError.
+        */
+        TInt RunError( TInt aError );
+
+        /**
+        * @see CActive::SetActive.
+        */
+        void SetActive();
+
+	private: // Data
+		CVCApplicationControllerImpl& iController;
+    };
+
+#endif      // CAPPCONTROLLERACTIVEOBJECT_H 
+            
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/appcontrollerconstants.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains the UIDs for applications.
+*
+*/
+
+
+
+#ifndef APPCONTROLLERCONSTANTS_H
+#define APPCONTROLLERCONSTANTS_H
+
+// INCLUDES
+#include    <e32base.h>
+
+// CONSTANTS
+
+// Maximum length of user defined bluetooth name length
+const TInt KBTMaxNameLength = 30;
+
+// Profile ids start from 100 so they're separated from the apps
+const TUint KProfileIdsStart    = 100;
+// Value for training an original profile names
+const TInt  KProfileValue = 100;
+
+// These values are used to train SIND voice tags
+// The first row application name has integer value of 0 - 100.
+// The second row application name has integer value of 100 - 200
+const TUint KSecondApplicationValue = 100;
+// Profile ids start from 200
+// The first row profile name has integer value of 200-300
+const TUint	KFirstProfileValue = 200;
+// The second row profile name has integer value of 300 - 400
+const TUint	KSecondProfileValue = 300;
+
+/**
+* APPLICATION UIDS
+*/
+
+// Bluetooth ui UID
+const TUid KUidAppBtUi = { 0x10005951 };
+
+#endif      // APPCONTROLLERCONSTANTS_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/appcontrollerpropertyhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Active object for subscribing to Publish & Suscribe properties
+*
+*/
+
+
+#ifndef CAPPCONTROLLERPROPERTYHANDLER_H
+#define CAPPCONTROLLERPROPERTYHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+// FORWARDS
+class CVCApplicationControllerImpl;
+
+// CLASS DECLARATION
+
+/**
+* Active object for subscribing to Publish & Suscribe properties
+* @since 2.8
+*/
+class CAppControllerPropertyHandler : public CActive
+    {
+    public:  // Constructors and destructor
+        /**
+        * Symbian two-phased constructor.
+        * @since 2.8
+        * @param aCategory Category of the property to watch
+        * @param aKey      Key UID of the property to watch
+        * @param aCallback Callback to get notifications about changes
+        */
+        static CAppControllerPropertyHandler* NewL(
+            TUid aCategory,
+            TUint aKey,
+            CVCApplicationControllerImpl* aController );
+
+        // Destructor
+        virtual ~CAppControllerPropertyHandler();
+
+    public:  // New functions
+        
+		/**
+        * Get current property value.
+        * @since 2.8
+        * @return current (integer) value of this property
+        */
+        TInt Value();
+
+
+    private: // Functions from base classes
+
+        /**
+        * From CActive.
+        * Handle a change event.
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * Cancel the request to receive events.
+        */
+        void DoCancel();
+
+    private: // New functions
+
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL(TUid aCategory,
+						TUint aKey );
+
+        /**
+        * C++ constructor.
+        */
+        CAppControllerPropertyHandler(CVCApplicationControllerImpl* aController);
+
+    private:	// Data
+
+        RProperty					  iProperty;
+        TCallBack					  iCallback;
+        TBool						  iRequestIssued;
+		CVCApplicationControllerImpl* iController;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/vcexecutorapp.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application class
+*
+*/
+
+
+#ifndef VCEXECUTORAPP_H
+#define VCEXECUTORAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+
+// UID of the application
+const TUid KUidVcExecutorApp = { 0x10281D15 };
+
+
+// CLASS DECLARATION
+
+/**
+* CVCExecutorApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CVCExecutorApp : public CAknApplication
+    {
+    
+    private: // Functions from base classes
+
+        /**
+        * From CApaApplication
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID.
+        * @return The value of KUidVcManager.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif // VCEXECUTORAPP_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/vcexecutorappdocument.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Document class
+*
+*/
+
+
+#ifndef VCEXECUTORAPPDOCUMENT_H
+#define VCEXECUTORAPPDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CAiNameDialerDocument application class.
+*/
+class CVCExecutorAppDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+    
+        /**
+        * Two-phased constructor.
+        *
+        * @param "CEikApplication& aApp" Application object
+        */
+        static CVCExecutorAppDocument* NewL( CEikApplication& aApp );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCExecutorAppDocument();
+
+    public: // From CAknDocument
+    
+        /**
+        * Updates window group task name
+        *
+        * @param "CApaWindowGroupName* aWgName" Window group name
+        */
+        void UpdateTaskNameL( CApaWindowGroupName* aWgName );
+
+    private:
+
+        /**
+        * Default constructor.
+        *
+        * @param "CEikApplication& aApp" Application object
+        */
+        CVCExecutorAppDocument( CEikApplication& aApp );
+        
+        /**
+        * Second phase constructor
+        */        
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, creates CAiNameDialerAppUi "App UI" object.
+        *
+        * @return Created AppUi instance
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif // VCEXECUTORAPPDOCUMENT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/inc/vcexecutorappui.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  vcexecutorapp application UI class
+*
+*/
+
+
+#ifndef VCEXECUTORAPPUI_H
+#define VCEXECUTORAPPUI_H
+
+//  INCLUDES
+#include <aknappui.h>
+
+// CLASS DECLARATION
+
+/**
+* This class is a part of the standard application framework.
+*/
+class CVCExecutorAppUi : public CAknAppUi 
+    {
+    public: // Constructors and destructor
+            
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+	
+        /**
+        * Destructor.
+        */
+       virtual ~CVCExecutorAppUi();   
+	    
+    public: // New functions
+    
+        /**
+        * Method to get the CEikonEnv pointer
+        *
+        * @return CEikonEnv
+        */
+        CEikonEnv* EikonEnv() const;
+	    
+        /**
+        * Updates status pane to the idle pane
+        */
+        void UpdateStatusPaneL();
+
+    private: // From CEikAppUi
+
+        /**
+        * Takes care of command handling.
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL( TInt aCommand );
+        
+        /**
+        * Handles command line parameters.
+        * @param aCommandLine CApaCommandLine object
+        */
+        TBool ProcessCommandParametersL( CApaCommandLine& aCommandLine );
+        
+        /**
+        * From CEikAppUi, takes care of screen resolution change
+        */
+        void HandleScreenDeviceChangedL();
+
+    private:
+    
+        // Resource id of the current status pane
+        TInt iInitialStatuspaneResourceId;
+    };
+
+#endif // VCEXECUTORAPPUI_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/loc/vcexecutorapp.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localisation file for vcexecutor application.
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+
+// *** QUERIES ***
+
+// d: Confirmation query when Bluetooth needs to be activated in off-line mode.
+// l: popup_note_window/opt2
+// r: 3.2
+//
+#define qtn_vcexec_bt_activate_in_offline "Do you want to activate bluetooth in off-line mode?"
+
+
+// *** NOTES ***
+
+// d: An information note when Bluetooth needs to be activated and it's disallowed in off-line mode.
+// l: popup_note_window/opt2
+// r: 3.2
+//
+#define qtn_vcexec_bt_offline_disabled "Bluetooth can't activated in off-line mode"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/src/appcontroller.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,963 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is an implementation class for checking which 
+*               application or profile needs to be activated and then
+*               starts it.
+*
+*/
+
+
+// INCLUDE FILES
+#include "appcontroller.h"
+#include <vcexecutorapp.rsg>
+#include "appcontroller.hrh"
+#include "appcontrollerconstants.h"
+#include <aknlists.h>
+#include <aknPopup.h>
+#include <apgtask.h>     //TApaTask, TApaTaskList
+#include <apacmdln.h>    //CApaCommandLine
+#include <w32std.h>      // RWsSession
+#include <e32svr.h>
+#include <StringLoader.h>
+#include <f32file.h>
+#include <badesca.h> 
+#include <bautils.h>
+#include <barsc.h>
+#include <e32def.h>
+
+#include <PSVariables.h>
+#include "appcontrollerpropertyhandler.h"
+#include <ctsydomainpskeys.h>
+
+#include <startupdomainpskeys.h>
+
+#include <centralrepository.h>
+
+
+#include <CoreApplicationUIsSDKCRKeys.h>
+
+#include <aknnotewrappers.h>
+#include <featmgr.h>
+#include <bldvariant.hrh>
+#include <AknQueryDialog.h>
+
+#include <sendui.h>     //CreateAndSendMessageL()
+#include <TSendingCapabilities.h>
+#include <SendUiConsts.h>
+
+#include <MsgArrays.h>
+
+#include <coemain.h>
+
+// Profile Engine API
+#include <Profile.hrh>
+
+#include <AknNotifierController.h>
+#include <AknGlobalConfirmationQuery.h> // Confirmation query.
+#include "appcontrolleractiveobject.h"  // CAppControllerActiveObject.
+#include <AknGlobalNote.h>    // Information note
+#include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
+
+#include "rubydebug.h"
+
+
+#include <aiwdialdata.h>
+#include <AiwDialDataTypes.h>
+#include <AiwServiceHandler.h>
+#include <gslauncher.h>
+
+
+// Cover UI start
+#include "secondarydisplay/appcontrollersecondarydisplayapi.h"
+#include "SecondaryDisplay/SecondaryDisplaySysApAPI.h"
+// Cover UI end
+
+const TUid KAppManagerUid = { 0x10283321 }; // Control Panel Application Manager UID
+const TUid KVoiceCommandUid = { 0x10282C40 }; // Control Panel Voice Command UID
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CVCApplicationControllerImpl::CVCApplicationControllerImpl() : iResourceFileOffset( 0 )
+    {
+    }
+
+// Destructor
+CVCApplicationControllerImpl::~CVCApplicationControllerImpl()
+    {
+    if( iApaLsSession )
+        {
+        iApaLsSession->Close();
+        delete iApaLsSession;
+        }
+ 
+
+    delete iPropertyHandler;
+    delete iMsgTypes;
+    
+    if (iSendUi)
+        {
+        delete iSendUi;    
+        }
+        
+    // Delete active object.
+    if ( iActiveObject )
+        {
+        iActiveObject->Cancel();
+        delete iActiveObject;
+        }
+
+    if (iProfileEngine)
+        {
+        iProfileEngine->Release();
+        iProfileEngine = NULL;
+        }
+
+    delete iGlobalConfQuery;
+    
+    delete iQueryDialog;
+    
+    if ( iCoeEnv && iEikonEnv->EikAppUi() )
+        {
+        iEikonEnv->EikAppUi()->RemoveFromStack( this );
+        }
+    
+    FeatureManager::UnInitializeLib();
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::ConstructL
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------
+//
+void CVCApplicationControllerImpl::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::ConstructL" );
+    
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+
+    iPropertyHandler = CAppControllerPropertyHandler::NewL(
+        KPSUidCtsyCallInformation, KCTsyCallState, this);
+
+    // Create active object to handle note request statuses.
+    iActiveObject = new (ELeave) CAppControllerActiveObject( *this );
+
+    iGlobalConfQuery = CAknGlobalConfirmationQuery::NewL();
+    }
+
+// ----------------------------------------------------------------
+// CVCApplicationControllerImpl* CVCApplicationControllerImpl::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------
+//
+CVCApplicationControllerImpl* CVCApplicationControllerImpl::NewL()                                                           
+    {
+    CVCApplicationControllerImpl* self= new (ELeave) CVCApplicationControllerImpl();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::ExecuteCommandL
+// Checks the Id and diverts the application or profile
+// to the right launching engine.
+// ---------------------------------------------------------
+//
+TInt CVCApplicationControllerImpl::ExecuteCommandL( TUint aCommandId,
+                                                    const TDesC& /*aParameters*/ )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::ExecuteCommandL" );
+    
+    TInt err = KErrNone;
+
+    // The method we're about to launch is an application, recognized by it's first name.
+    if( aCommandId < KFirstProfileValue )
+        {
+        err = DoExecuteCommandL( aCommandId, KNullDesC() );
+        }
+    // The method we're about to launch is a profile, recognized by it's first name
+    else if( ( aCommandId >= KFirstProfileValue) && ( aCommandId < KSecondProfileValue) )
+        {
+        aCommandId -= KProfileValue;
+        ProfileEngL( aCommandId );
+        }
+    // The method we're about to launch is a profile, recognized by it's second name
+    else if ( ( aCommandId >= KSecondProfileValue ) )
+        {
+        aCommandId -= KFirstProfileValue;
+        ProfileEngL( aCommandId );
+        }
+    else
+        {
+        // Id does not match.
+        RUBY_DEBUG1( "CVCApplicationControllerImpl::ExecuteCommandL: command id %d not found", aCommandId );
+        User::Leave( KErrArgument );
+        }
+
+    return err;
+    }
+    
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::DoExecuteCommandL
+// Checks the Id and diverts the application or profile
+// to the right launching engine.
+// ---------------------------------------------------------
+//
+TInt CVCApplicationControllerImpl::DoExecuteCommandL( TUint aCommandId, const TDesC& /*aParameters*/ )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::DoExecuteCommandL" );
+     
+    RUBY_DEBUG1( "CVCApplicationControllerImpl::DoExecuteCommandL. executing command with id %d", aCommandId );
+
+    iCallStatus = EFalse;
+    TInt err = KErrNone;
+    CGSLauncher* gsLauncher( NULL );
+    TUid zeroUid = {0};
+    // Check which app needs to be activated
+    switch( aCommandId )
+        {
+        case EAppVoiceMail:
+
+            err = VmbxEngL();
+            break;
+#ifdef __BT
+        case EAppBluetooth:
+            
+            err = BTEngL();
+            break;
+#endif
+        case EAppWriteMessage:
+    
+            ActivateMessageL( EEditorTypeNewMessage );
+            break;
+            
+        case EAppWriteEmail:
+
+            ActivateMessageL( EEditorTypeNewEmail );
+            break;
+            
+        case EAppWritePostcard:
+       
+            ActivateMessageL( EEditorTypePostcard );
+            break;
+        
+        case EAppApplicationManagerCPView:
+            gsLauncher = CGSLauncher::NewLC();
+            gsLauncher->LaunchGSViewL( KAppManagerUid, zeroUid, KNullDesC8 );
+            CleanupStack::PopAndDestroy( gsLauncher );
+            break;
+            
+        case EAppVoiceCommandCPView:
+            gsLauncher = CGSLauncher::NewLC();
+            gsLauncher->LaunchGSViewL( KVoiceCommandUid, zeroUid, KNullDesC8 );
+            CleanupStack::PopAndDestroy( gsLauncher );
+            break;
+            
+        default:
+            err = KErrNotSupported;
+            break;
+        }
+
+        // Check if it's profile
+    if ( err == KErrNotSupported && aCommandId >= KProfileIdsStart )
+        {
+        ProfileEngL( aCommandId );
+        }
+
+    return err;
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::ProfileEngL
+// Check which profile user wants to activate and do it.
+// ---------------------------------------------------------
+//
+void CVCApplicationControllerImpl::ProfileEngL( TUint aCommandId )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::ProfileEngL" );
+
+    // cut the VAS DB value from aCommandId so we can activate the profile.
+    iProfileId = 0;
+    iProfileId = aCommandId -= KProfileValue;
+        
+    RUBY_DEBUG1( "CVCApplicationControllerImpl::ProfileEngL: Trying to activate profile id: %d", iProfileId );
+    
+    // Create profile engine
+    iProfileEngine = CreateProfileEngineL();
+    
+        // If Off-line profile is supported
+    if( ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ) &&
+        // and active profile is Off-line
+        ( iProfileEngine->ActiveProfileId() == EProfileOffLineId ) &&
+        // and currently focused profile is not Off-line
+        ( iProfileId != EProfileOffLineId ) )
+        {
+        // We are changing from Off-line to a normal profile.
+        // Check if SIM card exists or not
+        TInt simCStatus( ESimNotPresent );
+
+        RProperty simStatus;
+        User::LeaveIfError(
+        simStatus.Attach( KPSUidStartup, KPSSimStatus ) );
+        User::LeaveIfError( simStatus.Get( simCStatus ) );
+        simStatus.Close();
+
+        if( simCStatus == ESimNotPresent )
+            {
+            // SIM card does not exist.
+            // Show an information note and exit from method.
+            HBufC* infoText = StringLoader::LoadLC( R_TEXT_INSERT_SIM );
+            CAknInformationNote* note =
+                new( ELeave ) CAknInformationNote( ETrue );
+// Cover UI start
+            if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+                {
+                // Initializes cover support
+                note->PublishDialogL( SecondaryDisplay::ECmdShowInsertSimNote,
+                                      SecondaryDisplay::KCatSysAp );
+                }
+// Cover UI end
+
+            note->ExecuteLD( *infoText );
+            CleanupStack::PopAndDestroy( infoText );
+            return;
+            }
+        else
+            {
+            iState = EQueryDialog;
+
+            if ( iCoeEnv && iEikonEnv->EikAppUi() )
+                {
+                iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityAlert );
+                }
+                        
+            iQueryDialog = CAknQueryDialog::NewL();
+// Cover UI start
+            if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+                {
+                // Initializes cover support
+                iQueryDialog->PublishDialogL(
+                    SecondaryDisplay::ECmdShowLeaveOfflineProfileQuery,
+                    SecondaryDisplay::KCatAppController );
+                }
+// Cover UI end
+            
+            TInt result = iQueryDialog->ExecuteLD( R_LEAVE_OFFLINE_PROFILE_CONFIRMATION_QUERY );
+            
+            iQueryDialog = NULL;            
+            if ( iCoeEnv && iEikonEnv->EikAppUi() )
+                {
+                iEikonEnv->EikAppUi()->RemoveFromStack( this );
+                }
+
+            if ( !result )
+                {
+                // SIM card exists.
+                // User replied that he/she doesn't want to activate RF.
+                // Exit from method, do not activate the selected profile.
+        
+                return;                
+                } 
+            }
+        }
+    iProfileEngine->SetActiveProfileL( iProfileId );
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::VmbxEngL()
+// Get the Voice mailbox number and make the call.
+// ---------------------------------------------------------
+//
+TInt CVCApplicationControllerImpl::VmbxEngL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCApplicationControllerImpl::VmbxEngL" );
+    
+    iState = EVoiceMail;
+
+    TBuf<KVmbxMaxNumberLength> iNumber;
+
+
+    // existing ETel connection should be used in Open() where available
+    User::LeaveIfError( iVmbx.Open() );  
+
+    // Get vmbx number, active ALS line used as default
+    TInt err = iVmbx.GetVmbxNumber( iNumber );
+    
+
+    if( err != KErrNone && err != KErrNotFound )
+        {
+        User::Leave( err );
+        }
+
+    // If not found, query the user to enter it
+    if (err == KErrNotFound)
+        {
+        RUBY_DEBUG0( "Querying voice mailbox number" );
+        if ( iVmbx.QueryNumberL(EVmbxNotDefinedQuery, iNumber) )
+            {
+            if( iNumber.Length() )
+                {
+                RUBY_DEBUG0( "CVCApplicationControllerImpl::VmbxEngL: calling voice mailbox number" );
+                DialVmbxL( iNumber );
+                }
+            else
+                {
+                // User entered incorrect number of nothing
+                // This is handled by the vmbx engine.
+                }   
+            }
+        else
+            {
+            // User pressed cancel
+            }
+        }
+    // vmbx number was found so just make the call.
+    else if (!err && iNumber.Length())
+        {
+        RUBY_DEBUG0( "CVCApplicationControllerImpl::VmbxEngL: calling voice mailbox number" );
+        DialVmbxL( iNumber );
+        }
+        
+    iVmbx.Close();
+
+    return err;
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::DialVmbxL
+// Does the call to voice mailbox number
+// ---------------------------------------------------------
+//
+void CVCApplicationControllerImpl::DialVmbxL( const TDesC& aNumber )
+    {
+
+    CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewLC();
+
+    // Create AIW interest
+    RCriteriaArray interest;
+    CleanupClosePushL( interest );      // cleanup stack 2
+    CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC( 
+                                        KAiwCmdCall, KAiwCmdCall,
+                                        _L8( "*" ) );  // cleanup stack 3
+    TUid base;
+    base.iUid = KAiwClassBase;
+    criteria->SetServiceClass( base );
+    User::LeaveIfError( interest.Append( criteria ) );
+     
+    // attach to AIW interest
+    serviceHandler->AttachL( interest );
+        
+    CAiwDialData* dialData = CAiwDialData::NewLC();   
+    dialData->SetPhoneNumberL( aNumber );
+           
+    dialData->SetCallType( CAiwDialData::EAIWForcedCS );
+    
+    CAiwGenericParamList& paramList = serviceHandler->InParamListL();
+    dialData->FillInParamListL(paramList);
+
+    serviceHandler->ExecuteServiceCmdL( KAiwCmdCall,
+                                        paramList,
+                                        serviceHandler->OutParamListL(),
+                                        0,
+                                        this );
+                                        
+    iWait.Start();
+                                        
+    CleanupStack::PopAndDestroy( dialData );
+    CleanupStack::PopAndDestroy( criteria ); 
+    CleanupStack::PopAndDestroy( &interest );
+    CleanupStack::PopAndDestroy( serviceHandler );
+
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::BTEngL()
+// Check if BT is on/off and change it.
+// ---------------------------------------------------------
+//
+#ifdef __BT
+TInt CVCApplicationControllerImpl::BTEngL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::BTEngL" );
+    
+    TInt err = KErrNone;
+
+    TBTPowerStateValue powerState = EBTPowerOff;
+    CBTEngSettings* mcm = CBTEngSettings::NewLC(NULL); // No callbacks from this environment
+    
+    // Getter for BT MCM power mode
+    // returns power mode via powerState reference
+    err = mcm->GetPowerState(  powerState );
+
+    if( ( powerState == EBTPowerOff ) && ( !err ) ) // Power is OFF
+        {
+        TInt offlineModeOff( 0 );    // possible values are 0 and 1
+        TInt activationEnabled( 0 ); // possible values are 0 and 1
+
+        // Check whether local Bluetooth name is defined
+        TBuf<KBTMaxNameLength> btName;
+        mcm->GetLocalName( btName );
+        if ( btName.Length() <= 0 )
+            {
+            // Activate Bluetooth UI
+            ActivateAppL( KUidAppBtUi );
+            }
+        else
+            {
+            // Checks whether off-line mode is on and whether Bluetooth can be
+            // activated in off-line mode
+            GetOfflineModeFlagsL( offlineModeOff, activationEnabled );
+
+            if ( !offlineModeOff )
+                {
+                // Choose user interaction
+                if ( activationEnabled )
+                    {
+                    iState = EQueryDialog;
+    
+                    if ( iCoeEnv && iEikonEnv->EikAppUi() )
+                        {
+                        iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityAlert );
+                        }
+
+                    // Create and show query
+                    //
+                    iQueryDialog = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone);
+// Cover UI start
+                    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+            		    {
+                        // Initializes cover support
+                        iQueryDialog->PublishDialogL( 
+                            SecondaryDisplay::ECmdShowOfflineBtActivationQuery,
+                	    	SecondaryDisplay::KCatAppController );
+                        }
+// Cover UI end
+                    TInt result = iQueryDialog->ExecuteLD(R_BT_ACTIVATE_IN_OFFLINE_QUERY);
+                    
+                    iQueryDialog = NULL;                    
+                    if ( iCoeEnv && iEikonEnv->EikAppUi() )
+                        {
+                        iEikonEnv->EikAppUi()->RemoveFromStack( this );
+                        }
+                    
+                    if ( result )
+                        {
+                        err = mcm->SetPowerState( EBTPowerOn );  // Set power on
+                        }
+                    }
+                else
+                    {
+                    HBufC* stringHolder = StringLoader::LoadLC( R_BT_OFFLINE_DISABLED );
+                    CAknInformationNote* note = new (ELeave) CAknInformationNote();
+// Cover UI start
+                    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+                        {
+                        // Initializes cover support
+                        note->PublishDialogL( SecondaryDisplay::ECmdShowBtDisabledOfflineNote,
+                                              SecondaryDisplay::KCatAppController );
+                        }
+// Cover UI end
+
+                    note->ExecuteLD( *stringHolder );
+                    CleanupStack::PopAndDestroy(); //stringHolder
+                    }
+                }
+            else
+                {
+                // Offline mode is off
+                //
+                if ( activationEnabled )
+                    {
+                    err = mcm->SetPowerState( EBTPowerOn );  // Set power on
+                    }
+                }
+            }
+        }
+    else if(( powerState == EBTPowerOn ) && ( !err ))     // Power is ON
+        {
+        err = mcm->SetPowerState( EBTPowerOff ); // Set power off
+        }
+          
+    CleanupStack::PopAndDestroy( mcm );
+
+    if ( err != KErrNone )
+        {
+        HBufC* text = StringLoader::LoadLC(R_BT_GENERAL_ERROR);
+        CAknErrorNote* dlg = new (ELeave) CAknErrorNote(ETrue);
+// Cover UI start
+        if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+            {
+            // Initializes cover support
+            dlg->PublishDialogL( SecondaryDisplay::ECmdShowBtGeneralErrorNote,
+                                 SecondaryDisplay::KCatAppController );
+            }
+// Cover UI end
+
+        dlg->ExecuteLD(*text);
+        CleanupStack::PopAndDestroy(); // text
+        }
+    return err;
+    }
+
+#endif // __BT
+
+// ----------------------------------------------------------
+// CVCApplicationControllerImpl::GetOfflineModeFlagsL
+// ----------------------------------------------------------
+//
+void CVCApplicationControllerImpl::GetOfflineModeFlagsL( TInt& aOfflineModeOff, 
+                                                    TInt& aBTActivationEnabled ) const
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::GetOfflineModeFlagsL" );
+    
+    // Connecting and initialization:
+    CRepository* repository = CRepository::NewL(KCRUidCoreApplicationUIs);
+    
+    // Offline mode on?
+    repository->Get( KCoreAppUIsNetworkConnectionAllowed, aOfflineModeOff );
+    
+    RUBY_DEBUG1( "CVCApplicationControllerImpl::GetOfflineModeFlagsL: offline status %d", aOfflineModeOff );
+    
+    // Closing connection:
+    delete repository;
+    
+    // BT Activation enabled?
+    
+    CRepository* repository2 = CRepository::NewL( KCRUidBluetoothEngine );
+  
+    repository2->Get(KBTEnabledInOffline, aBTActivationEnabled);
+
+    RUBY_DEBUG1( "CVCApplicationControllerImpl::GetOfflineModeFlagsL: activation allowed %d", aBTActivationEnabled );
+    
+    // Closing connection:
+    delete repository2;
+    }
+
+// ----------------------------------------------------------
+// CVCApplicationControllerImpl::GetSimcardMode
+// ----------------------------------------------------------
+//
+void CVCApplicationControllerImpl::GetSIMCardMode( TInt& aSIMCardMode ) const                               
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::GetSIMCardMode" );
+
+        // We are changing from Off-line to a normal profile.
+        // Check if SIM card exists or not
+        aSIMCardMode = ESimNotPresent;
+
+        RProperty simStatus;
+        simStatus.Attach( KPSUidStartup, KPSSimStatus );
+        simStatus.Get( aSIMCardMode );
+        simStatus.Close();
+        }
+
+// ---------------------------------------------------------------------------
+// CVCApplicationControllerImpl::ActivateMessageL
+// ---------------------------------------------------------------------------
+TInt CVCApplicationControllerImpl::ActivateMessageL(TEditorType aType)
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::ActivateMessageL" );
+    
+    TInt err = KErrNone;
+    TUid mtmType = KNullUid;
+
+    switch( aType )
+        {
+        case EEditorTypeNewMessage:            
+            mtmType.iUid = KSenduiMtmUniMessageUidValue ;
+            break;
+        case EEditorTypeNewEmail:            
+            mtmType.iUid = KSenduiMtmSmtpUidValue;
+            break;
+        case EEditorTypePostcard:
+            mtmType.iUid = KSenduiMtmPostcardUidValue;
+            break;
+        default:
+            err = KErrNotFound;
+            break;
+        }
+    if (!err)
+        {
+        MHandlesSendAppUi().CreateAndSendMessageL( mtmType, 
+                                                   NULL,
+                                                   KNullUid,
+                                                   EFalse );
+        }
+    return err;
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCApplicationControllerImpl::MHandlesSendAppUi()
+// Returns send ui instance.
+// ---------------------------------------------------------------------------
+CSendUi& CVCApplicationControllerImpl::MHandlesSendAppUi()
+    {
+    if ( !iSendUi )
+        {
+        TRAPD( error, iSendUi = CSendUi::NewL() );
+        if ( error != KErrNone )
+            {
+            iSendUi = NULL;    
+            }
+        }
+    return *iSendUi;
+    }
+
+// ----------------------------------------------------
+// CVCApplicationControllerImpl::HandleCurrentCallStatusChange
+// Handle call status change event.
+// ----------------------------------------------------
+//
+void CVCApplicationControllerImpl::HandleCurrentCallStatusChange()
+    {
+    switch( iPropertyHandler->Value() )
+        {
+        case EPSCTsyCallStateNone:
+        case EPSCTsyCallStateAlerting:
+        case EPSCTsyCallStateRinging:
+            {
+            switch (iState)
+                {
+                case EVoiceMail:
+                    {
+                    iCallStatus = ETrue;
+                    // Cancel the menu
+                    iVmbx.Close();
+                    
+                    break;
+                    }
+                case ENewMessage:
+                    {                  
+                    iCallStatus = ETrue;
+                    // Cancel the menu
+                    Cancel();
+                    if (iCoeEnv && iEikonEnv->EikAppUi())
+                        {
+                        iEikonEnv->EikAppUi()->RemoveFromStack(this);
+                        }
+                    break;
+                    }
+                case EQueryDialog:
+                    {
+                    iCallStatus = ETrue;
+                    
+                    DismissQueryDialog();
+                        
+                    break;
+                    }
+                default:
+                    // Pass
+                    break;
+                }
+            break;
+            }
+
+        default:
+            {
+            // pass
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::Cancel
+// ---------------------------------------------------------
+//
+void CVCApplicationControllerImpl::Cancel()
+    {
+    // Cancel the menu
+    if ( iPopupList )
+        {
+        iPopupList->CancelPopup();
+        iPopupList = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::OfferKeyEventL
+// ---------------------------------------------------------
+//
+TKeyResponse CVCApplicationControllerImpl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::OfferKeyEventL" );
+    
+    TKeyResponse keyEvent( EKeyWasNotConsumed );
+    
+    if ( aType == EEventKey && ( aKeyEvent.iScanCode == EStdKeyNo ||
+         aKeyEvent.iScanCode == EStdKeyApplication0 ) )
+        {
+        switch ( iState )
+            {
+            case EVoiceMail:
+                iVmbx.Close();
+                keyEvent = EKeyWasConsumed;
+                break;
+
+            case ENewMessage:
+                Cancel();
+
+                if ( iCoeEnv && iEikonEnv->EikAppUi() )
+                    {
+                    iEikonEnv->EikAppUi()->RemoveFromStack( this );
+                    }
+                keyEvent = EKeyWasConsumed;
+                break;
+                
+            case EQueryDialog:            
+                DismissQueryDialog();
+                    
+                keyEvent = EKeyWasConsumed;
+                break;
+
+            default:
+                break;
+            }
+        }
+
+    return keyEvent;
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::HandleNotifyL
+// ---------------------------------------------------------
+//    
+TInt CVCApplicationControllerImpl::HandleNotifyL( TInt aCmdId, TInt /*aEventId*/,
+                                                  CAiwGenericParamList& /*aEventParamList*/,
+                                                  const CAiwGenericParamList& /*aInParamList*/ )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCApplicationControllerImpl::HandleNotifyL" );
+    
+    if ( aCmdId == KAiwCmdCall )
+        {
+        if ( iWait.IsStarted() )
+            {
+            iWait.AsyncStop();
+            }
+        }
+        
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CVCApplicationControllerImpl::HandleActiveObjectStatus
+// ---------------------------------------------------------
+//
+void CVCApplicationControllerImpl::HandleActiveObjectStatus(TInt aStatus)
+    {
+    RUBY_DEBUG1( "CVCApplicationControllerImpl::HandleActiveObjectStatus() aStatus = %d", aStatus);
+    
+    // Cancel active object and note.
+    iActiveObject->Cancel();
+    iGlobalConfQuery->CancelConfirmationQuery();    
+    
+    // Check that user pressed softkey YES
+    if ( (aStatus == EAknSoftkeyYes ||    
+          aStatus == EAknSoftkeySelect ||
+          aStatus == EAknSoftkeyOk) && 
+          iProfileEngine )    
+        {
+        TRAP_IGNORE( iProfileEngine->SetActiveProfileL( iProfileId ) );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCApplicationControllerImpl::CreateConnectionL
+// Connects to RApaLsSession.
+// ----------------------------------------------------------------------------
+//
+void CVCApplicationControllerImpl::CreateApaConnectionL()
+    {
+    iApaLsSession = new RApaLsSession();
+       
+    if ( !iApaLsSession->Handle() )
+        {
+        User::LeaveIfError( iApaLsSession->Connect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCApplicationControllerImpl::ActivateAppL
+// Used to launch applications. Checks whether an instance of the launched
+// application is already running.
+// ----------------------------------------------------------------------------
+//
+void CVCApplicationControllerImpl::ActivateAppL( const TUid aUid,
+                                                 TBool aMultipleInstances )
+    {
+    CreateApaConnectionL();
+
+    if ( aMultipleInstances )
+        {
+        ActivateAppInstanceL( aUid );
+        }
+    else
+        {
+        // Session to window server
+        RWsSession wsSession;
+        User::LeaveIfError( wsSession.Connect() );
+        CleanupClosePushL( wsSession );
+        
+        TApaTaskList apaTaskList( wsSession );
+        TApaTask apaTask = apaTaskList.FindApp( aUid );
+        if ( apaTask.Exists() )
+            {
+            // Already running, close application
+            apaTask.EndTask();
+            }
+        ActivateAppInstanceL( aUid );
+            
+        CleanupStack::PopAndDestroy( &wsSession );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCApplicationControllerImpl::ActivateAppInstanceL
+// Activates an instance of an application.
+// ----------------------------------------------------------------------------
+//
+void CVCApplicationControllerImpl::ActivateAppInstanceL( const TUid aUid )
+    {
+    TApaAppInfo appInfo;
+    User::LeaveIfError( iApaLsSession->GetAppInfo( appInfo, aUid ) );
+    TFileName appName = appInfo.iFullName;
+    CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+
+    apaCommandLine->SetExecutableNameL( appName );
+    apaCommandLine->SetCommandL( EApaCommandRun );
+    
+    User::LeaveIfError ( iApaLsSession->StartApp( *apaCommandLine ) );
+    CleanupStack::PopAndDestroy( apaCommandLine );
+    }
+
+// ----------------------------------------------------------------------------
+// CVCApplicationControllerImpl::DismissQueryDialog
+// Closes query dialog
+// ----------------------------------------------------------------------------
+//
+void CVCApplicationControllerImpl::DismissQueryDialog()
+    {
+    if ( iQueryDialog )
+        {
+        iQueryDialog->MakeLeftSoftkeyVisible( EFalse );
+        TRAP_IGNORE( iQueryDialog->DismissQueryL() );
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/src/appcontrolleractiveobject.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Active object to handle global list query results.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "appcontrolleractiveobject.h"
+#include "appcontroller.h"
+#include <coemain.h>
+
+
+// CONSTANTS
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CAppControllerActiveObject::CAppControllerActiveObject
+// 
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CAppControllerActiveObject::CAppControllerActiveObject(CVCApplicationControllerImpl& aController)
+:   CActive( EPriorityStandard ), iController(aController)
+    {
+    CActiveScheduler::Add( this );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAppControllerActiveObject::~CAppControllerActiveObject
+// 
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CAppControllerActiveObject::~CAppControllerActiveObject()
+    {
+    Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAppControllerActiveObject::DoCancel
+// 
+// 
+// -----------------------------------------------------------------------------
+//
+void CAppControllerActiveObject::DoCancel()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAppControllerActiveObject::RunL
+// 
+// 
+// -----------------------------------------------------------------------------
+//
+void CAppControllerActiveObject::RunL()
+    {
+	iController.HandleActiveObjectStatus( iStatus.Int() );
+    Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CAppControllerActiveObject::RunError
+// 
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CAppControllerActiveObject::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CAppControllerActiveObject::SetActive
+// 
+// 
+// -----------------------------------------------------------------------------
+//
+void CAppControllerActiveObject::SetActive()
+    {
+    if( !IsActive() )
+        {
+        CActive::SetActive();
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/src/appcontrollerpropertyhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Active object for subscribing to Publish & Suscribe properties
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include "appcontrollerpropertyhandler.h"
+#include "appcontroller.h"
+
+// ---------------------------------------------------------
+// CAppControllerPropertyHandler::NewL
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------
+//
+CAppControllerPropertyHandler* CAppControllerPropertyHandler::NewL(
+    TUid aCategory, TUint aKey, CVCApplicationControllerImpl* aController)
+    {
+    CAppControllerPropertyHandler* self = new ( ELeave ) CAppControllerPropertyHandler( aController );
+    CleanupStack::PushL( self );
+    self->ConstructL( aCategory, aKey );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------
+// CAppControllerPropertyHandler::CAppControllerPropertyHandler
+// C++ constructor
+// ---------------------------------------------------------
+//
+CAppControllerPropertyHandler::CAppControllerPropertyHandler( CVCApplicationControllerImpl* aController )
+													: CActive( EPriorityStandard ), 
+													iController( aController )
+    {
+    }
+
+// ---------------------------------------------------------
+// CAppControllerPropertyHandler::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------
+//
+void CAppControllerPropertyHandler::ConstructL(TUid aCategory, TUint aKey )
+    {
+    User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );
+
+    CActiveScheduler::Add(this);
+    // Initial subscription and process current property value
+    RunL();
+
+    iRequestIssued = ETrue;
+    }
+
+// Destructor
+CAppControllerPropertyHandler::~CAppControllerPropertyHandler()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+
+
+// ---------------------------------------------------------
+// CAppControllerPropertyHandler::DoCancel   
+// Cancel the request to receive events
+// ---------------------------------------------------------
+//
+void CAppControllerPropertyHandler::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+
+// ---------------------------------------------------------
+// CAppControllerPropertyHandler::RunL
+// Handle a change event.
+// ---------------------------------------------------------
+//
+void CAppControllerPropertyHandler::RunL()
+    {
+    // Resubscribe before processing new value to prevent missing updates
+    iProperty.Subscribe( iStatus );
+    SetActive();
+
+    if ( iRequestIssued )
+        {
+        iController->HandleCurrentCallStatusChange();
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CAppControllerPropertyHandler::Value
+// Get current property value
+// ---------------------------------------------------------
+//
+TInt CAppControllerPropertyHandler::Value()
+    {
+    TInt value = 0;
+    iProperty.Get( value );
+    return value;
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/src/vcexecutorapp.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application class
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <eikstart.h>
+#include "vcexecutorapp.h"
+#include "vcexecutorappdocument.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CVCExecutorApp::AppDllUid
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CVCExecutorApp::AppDllUid() const
+    {
+    return KUidVcExecutorApp;
+    }
+
+   
+// ---------------------------------------------------------
+// CVCExecutorApp::CreateDocumentL
+// Creates document object
+// ---------------------------------------------------------
+//
+CApaDocument* CVCExecutorApp::CreateDocumentL()
+    {
+    return CVCExecutorAppDocument::NewL( *this );
+    }
+
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+// ---------------------------------------------------------
+// NewApplication
+// Creates CVCExecutorApp object
+// ---------------------------------------------------------
+//
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CVCExecutorApp;
+    }
+    
+// ---------------------------------------------------------
+// E32Main
+// Main
+// ---------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/src/vcexecutorappdocument.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Document class
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <apgwgnam.h>
+
+#include "vcexecutorappdocument.h"
+#include "vcexecutorappui.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------------------------
+// CVCExecutorAppDocument::CVCExecutorAppDocument
+// Default constructor
+// ----------------------------------------------------------------------------
+//
+CVCExecutorAppDocument::CVCExecutorAppDocument( CEikApplication& aApp ): 
+                                                CAknDocument( aApp )    
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CVCExecutorAppDocument::~CVCExecutorAppDocument()
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CVCExecutorAppDocument::~CVCExecutorAppDocument()
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CVCExecutorAppDocument::UpdateTaskNameL
+// Updates task name
+// ----------------------------------------------------------------------------
+//
+void CVCExecutorAppDocument::UpdateTaskNameL( CApaWindowGroupName* aWgName )
+    {
+    CAknDocument::UpdateTaskNameL( aWgName );
+    aWgName->SetHidden( ETrue ); 
+    }
+
+// ----------------------------------------------------------------------------
+// CVCExecutorAppDocument::ConstructL()
+// Second phase constructor
+// ----------------------------------------------------------------------------
+//
+void CVCExecutorAppDocument::ConstructL()
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CVCExecutorAppDocument::NewL
+// Symbian constructor
+// ----------------------------------------------------------------------------
+//
+CVCExecutorAppDocument* CVCExecutorAppDocument::NewL( CEikApplication& aApp )
+    {
+    CVCExecutorAppDocument* self = new (ELeave) CVCExecutorAppDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CVCExecutorAppDocument::CreateAppUiL
+// Instantiates AppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CVCExecutorAppDocument::CreateAppUiL()
+    {
+    return new (ELeave) CVCExecutorAppUi;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcexecutorapp/src/vcexecutorappui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  vcexecutorapp application UI class
+*
+*/
+
+
+// INCLUDE FILES
+#include <aknenv.h>
+#include <akntitle.h>
+#include <f32file.h>
+#include <apgwgnam.h>
+#include <AknSgcc.h>
+#include <data_caging_path_literals.hrh>
+
+#include <vcexecutorapp.rsg>
+
+#include "vcexecutorappui.h"
+#include "appcontroller.h"
+#include "rubydebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCExecutorAppUi::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCExecutorAppUi::ConstructL" );
+    
+    // Remember the idle status pane resource id
+    iInitialStatuspaneResourceId = CAknSgcClient::CurrentStatuspaneResource();
+
+   
+    // Cannot set ENoScreenFurniture here since after that StatusPane() function
+    // returns NULL. "Voice mailbox" command requires status pane to be available
+    // when executing.
+    // ENoAppResourceFile seems to have no effect -> not setting that either
+    BaseConstructL( EAknEnableSkin | EAknEnableMSK /*ENoScreenFurniture*/ );
+
+    // Set the title pane text to empty so that the default "vcexecutorapp" text
+    // won't be shown when activating applications.
+    CAknTitlePane* title =
+        static_cast<CAknTitlePane*>( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+        
+    TResourceReader rReader;
+    iCoeEnv->CreateResourceReaderLC( rReader, R_EMPTY_TITLE_PANE );
+    title->SetFromResourceL( rReader );
+    CleanupStack::PopAndDestroy(); // rReader
+
+    // Set this as system application    
+    iEikonEnv->SetSystem( ETrue );
+    
+    UpdateStatusPaneL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::~CVCExecutorAppUi
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CVCExecutorAppUi::~CVCExecutorAppUi()
+    {  
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::EikonEnv
+// Returns the CEikonEnv
+// -----------------------------------------------------------------------------
+//    
+CEikonEnv* CVCExecutorAppUi::EikonEnv() const
+    {
+    return iEikonEnv;
+    }    
+    
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::UpdateStatusPaneL
+// Switch to initial status pane
+// -----------------------------------------------------------------------------
+//     
+void CVCExecutorAppUi::UpdateStatusPaneL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCExecutorAppUi::UpdateStatusPaneL" );
+    
+    // Use same status pane as idle has
+    StatusPane()->SwitchLayoutL( iInitialStatuspaneResourceId );
+    
+    // Title pane is set as empty
+    CAknTitlePane* title = static_cast<CAknTitlePane*> ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    title->SetTextL( KNullDesC );
+    
+    StatusPane()->MakeVisible( EFalse ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::HandleScreenDeviceChangedL
+// Empty implementation to prevent crash when changing screen resolution
+// -----------------------------------------------------------------------------
+//     
+void CVCExecutorAppUi::HandleScreenDeviceChangedL()
+    {
+    CAknAppUi::HandleScreenDeviceChangedL();
+    }
+
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::HandleCommandL
+// Handle events from app framework
+// -----------------------------------------------------------------------------
+//      
+void CVCExecutorAppUi::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+        case EAknSoftkeyBack:
+        case EEikCmdExit:
+            {
+            Exit();
+            break;
+            }
+
+        default:
+            break;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCExecutorAppUi::ProcessCommandParametersL
+//
+// -----------------------------------------------------------------------------
+//         
+TBool CVCExecutorAppUi::ProcessCommandParametersL( CApaCommandLine& aCommandLine )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCExecutorAppUi::ProcessCommandParametersL" );
+    
+    TPtrC8 argumentPtr( aCommandLine.TailEnd() );
+    
+    // Convert argument to TInt
+    TLex8 lex( argumentPtr );
+    TInt commandId;
+    User::LeaveIfError( lex.Val( commandId ) );
+    
+    // Execute command with CVCApplicationController
+    CVCApplicationControllerImpl* appController = CVCApplicationControllerImpl::NewL();
+    CleanupStack::PushL( appController );
+    appController->ExecuteCommandL( commandId, KNullDesC );
+    
+    CleanupStack::PopAndDestroy( appController );
+    
+    // Exit application
+    Exit();
+    
+    return EFalse;
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/data/nss_voicecommands.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource header of NSS Voice Commands localization info
+*
+*/
+
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// VCOMMANDITEM
+// ?description
+// -----------------------------------------------------------------------------
+//
+STRUCT VCOMMANDITEM
+    {
+    WORD key;
+    LTEXT txt; // variable length
+    }
+
+// -----------------------------------------------------------------------------
+// NSSVCOMMANDS
+// ?description
+// -----------------------------------------------------------------------------
+//
+STRUCT NSSVCOMMANDS
+    {
+    STRUCT items[];
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/data/nss_voicecommands.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  NSS voice commands localization resource
+*
+*/
+
+
+// INCLUDES
+#include <defaultvoicecommands.loc>
+#include <badef.rh>
+#include <uikon.rh>
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// ?resource_name
+// ?description
+//
+// -----------------------------------------------------------------------------
+//
+/*RESOURCE NSSVCOMMANDS nssvoicecommands
+    {
+    items =
+        {
+        VCOMMANDITEM
+            {
+            key = 0;
+            txt = qtn_command_calendar;
+            },
+        VCOMMANDITEM
+            {
+            key = 1;
+            txt = qtn_command_calendartoday;
+            }
+        };
+    }*/
+    
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE LBUF prompt_time24  { txt = qtn_prompt_time24; }
+RESOURCE LBUF prompt_time12am  { txt = qtn_prompt_time12am; }
+RESOURCE LBUF prompt_time12pm  { txt = qtn_prompt_time12pm; }
+RESOURCE LBUF prompt_operator  { txt = qtn_prompt_operator; }
+RESOURCE LBUF prompt_nooperator  { txt = qtn_prompt_nooperator; }
+RESOURCE LBUF prompt_batteryfull  { txt = qtn_prompt_batteryfull; }
+RESOURCE LBUF prompt_batteryalmostfull  { txt = qtn_prompt_batteryalmostfull; }
+RESOURCE LBUF prompt_batteryhalf  { txt = qtn_prompt_batteryhalf; }
+RESOURCE LBUF prompt_batteryalmostempty  { txt = qtn_prompt_batteryalmostempty; }
+RESOURCE LBUF prompt_batterylow  { txt = qtn_prompt_batterylow; }
+RESOURCE LBUF prompt_batteryinfonotavailable  { txt = qtn_prompt_battery_info_not_available; }
+RESOURCE LBUF prompt_networkexcellent  { txt = qtn_prompt_networkexcellent; }
+RESOURCE LBUF prompt_networkgood  { txt = qtn_prompt_networkgood; }
+RESOURCE LBUF prompt_networkrathergood  { txt = qtn_prompt_networkrathergood; }
+RESOURCE LBUF prompt_networklow  { txt = qtn_prompt_networklow; }
+RESOURCE LBUF prompt_networknone  { txt = qtn_prompt_networknone; }
+RESOURCE LBUF prompt_networkinfonotavailable  { txt = qtn_prompt_network_info_not_available; }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/data/vcommandexecutor.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource header of NSS Voice Commands localization info
+*
+*/
+
+
+//  STRUCTURE DEFINITIONS
+
+// -----------------------------------------------------------------------------
+// VCOMMANDITEM
+// ?description
+// -----------------------------------------------------------------------------
+//
+STRUCT VCOMMANDITEM
+    {
+    WORD key;
+    LTEXT txt; // variable length
+    }
+
+// -----------------------------------------------------------------------------
+// NSSVCOMMANDS
+// ?description
+// -----------------------------------------------------------------------------
+//
+STRUCT NSSVCOMMANDS
+    {
+    STRUCT items[];
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/data/vcommandexecutor.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  NSS voice commands localization resource
+*
+*/
+
+
+// INCLUDES
+#include <defaultvoicecommands.loc>
+#include "vcommandexecutor.rh"
+#include <badef.rh>
+#include <uikon.rh>
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+
+    
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE LBUF prompt_time24  { txt = qan_vc_prompt_time24; }
+RESOURCE LBUF prompt_time12am  { txt = qan_vc_prompt_time12am; }
+RESOURCE LBUF prompt_time12pm  { txt = qan_vc_prompt_time12pm; }
+RESOURCE LBUF prompt_operator  { txt = qan_vc_prompt_operator; }
+RESOURCE LBUF prompt_nooperator  { txt = qan_vc_prompt_nooperator; }
+RESOURCE LBUF prompt_batteryfull  { txt = qan_vc_prompt_batteryfull; }
+RESOURCE LBUF prompt_batteryalmostfull  { txt = qan_vc_prompt_batteryalmostfull; }
+RESOURCE LBUF prompt_batteryhalf  { txt = qan_vc_prompt_batteryhalf; }
+RESOURCE LBUF prompt_batteryalmostempty  { txt = qan_vc_prompt_batteryalmostempty; }
+RESOURCE LBUF prompt_batterylow  { txt = qan_vc_prompt_batterylow; }
+RESOURCE LBUF prompt_nobattery  { txt = qan_vc_prompt_nobattery; }
+RESOURCE LBUF prompt_networkexcellent  { txt = qan_vc_prompt_networkexcellent; }
+RESOURCE LBUF prompt_networkgood  { txt = qan_vc_prompt_networkgood; }
+RESOURCE LBUF prompt_networkrathergood  { txt = qan_vc_prompt_networkrathergood; }
+RESOURCE LBUF prompt_networklow  { txt = qan_vc_prompt_networklow; }
+RESOURCE LBUF prompt_networknone  { txt = qan_vc_prompt_networknone; }
+RESOURCE LBUF prompt_nonetwork  { txt = qan_vc_prompt_nonetwork; }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for VCommandExecutor
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+// specify the platforms your component needs to be built for here
+// recommended value is DEFAULT
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example: 
+/*
+/agnmodel/inc/AGMCOMON.H
+*/
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+/agnmodel/group/agnmodel.mmp
+#if defined(MARM)
+/agnmodel/group/agsvexe.mmp
+#endif
+*/
+nssvcommandexecutor.mmp
+
+PRJ_TESTEXPORTS
+// Specify the exports needed by the productized test program.
+// These will be exported with command 'abld test export'.
+// Default location for productized test harness is /tsrc
+// Example:
+/*
+../tsrc/testdata/audio.wav /epoc32/winscw/c/testdata/audio.wav
+*/
+
+PRJ_TESTMMPFILES
+// Specify the .mmp files required for building the productized 
+// test harness. 'abld test build' will do the compilation.
+// Example:
+/*
+../tsrc/group/test.mmp
+*/
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/group/nssvcexecutor.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains all the resources
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    VCEX
+
+#include <defaultvoicecommands.loc>
+
+//  RESOURCE DEFINITIONS
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf = "NssVCommandExecutor"; }
+
+
+RESOURCE TBUF prompt_time24
+    {
+    buf = qtn_prompt_time24;
+    }
+    
+
+RESOURCE TBUF prompt_time12am
+    {
+    buf = qtn_prompt_time12am;
+    }
+
+RESOURCE TBUF prompt_time12pm
+    {
+    buf = qtn_prompt_time12pm;
+    }
+    
+
+RESOURCE TBUF prompt_operator
+    {
+    buf = qtn_prompt_operator;
+    }
+    
+
+RESOURCE TBUF prompt_nooperator
+    {
+    buf = qtn_prompt_nooperator;
+    }
+    
+
+RESOURCE TBUF prompt_batteryfull
+    {
+    buf = qtn_prompt_batteryfull;
+    }
+    
+RESOURCE TBUF prompt_batteryalmostfull
+    {
+    buf = qtn_prompt_batteryalmostfull;
+    }
+
+RESOURCE TBUF prompt_batteryhalf
+    {
+    buf = qtn_prompt_batteryhalf;
+    }
+    
+RESOURCE TBUF prompt_batteryalmostempty
+    {
+    buf = qtn_prompt_batteryalmostempty;
+    }
+    
+RESOURCE TBUF prompt_batterylow
+    {
+    buf = qtn_prompt_batterylow;
+    }
+
+RESOURCE TBUF prompt_networkexcellent
+    {
+    buf = qtn_prompt_networkexcellent;
+    }
+    
+RESOURCE TBUF prompt_networkgood
+    {
+    buf = qtn_prompt_networkgood;
+    }
+    
+
+RESOURCE TBUF prompt_networkrathergood
+    {
+    buf = qtn_prompt_networkrathergood;
+    }
+    
+RESOURCE TBUF prompt_networklow
+    {
+    buf = qtn_prompt_networklow;
+    }
+    
+RESOURCE TBUF prompt_networknone
+    {
+    buf = qtn_prompt_networknone;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/group/nssvcommandexecutor.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for VCommandExecutor
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          nssvcommandexecutor.exe
+TARGETTYPE      EXE
+UID             0x1000007A 0x10208AE1
+
+VENDORID        VID_DEFAULT
+
+TARGETPATH      /sys/bin
+CAPABILITY      LocalServices
+
+START RESOURCE  ../data/vcommandexecutor.rss
+HEADER
+#include "data_caging_paths.hrh"
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+SOURCEPATH      ../src
+SOURCE          nssvcommandexecutor.cpp
+SOURCE          nssvcapplauncher.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+USERINCLUDE     ../data
+
+USERINCLUDE     ../../rubydebug 
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/remcon
+
+LIBRARY     	euser.lib
+LIBRARY         nssttsutility.lib
+LIBRARY         nssttscommon.lib
+LIBRARY         etel.lib
+LIBRARY         etelmm.lib
+LIBRARY         commdb.lib
+LIBRARY     	bafl.lib
+LIBRARY         ws32.lib
+LIBRARY	        apparc.lib // StartApp
+LIBRARY         apgrfx.lib // For RApaLsSession
+LIBRARY         efsrv.lib  // File server client side
+LIBRARY         ecom.lib  //
+LIBRARY 		remconextensionapi.lib
+LIBRARY 		remconinterfacebase.lib
+LIBRARY			remconcoreapi.lib
+LIBRARY			remcontypes.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/inc/nssvcapplauncher.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,290 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Does the application launching of the recognized voice command
+*
+*/
+
+
+#ifndef __NSSVCAPPLAUNCHER_H__
+#define __NSSVCAPPLAUNCHER_H__
+
+//  INCLUDES
+//#include "AppControllerConstants.h"
+#include "nssvcapplauncher.hrh"
+#include <e32base.h>
+#include <e32std.h>
+#include <apgcli.h>
+#include <barsc.h>       // RResourceFile
+
+#include <remconcoreapicontrollerobserver.h>
+
+#include <nssttsutility.h>
+#include <nssttscommon.h>
+
+// FORWARD DECLARATIONS
+class RFs;
+class RResourceFile;
+
+// CLASS DECLARATION
+
+/**
+* This is the implementation class for launching applications and initiating profiles.
+* @lib AppController.lib
+* @since 3.0
+*/
+
+class CNssVCAppLauncher : public CBase, public MTtsClientUtilityObserver, public MRemConCoreApiControllerObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CNssVCAppLauncher* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CNssVCAppLauncher();
+
+    public: // New functions
+        
+        /**
+        * Checks the id and calls the appropriate function.
+        * @since Averell 2.0
+        * @param aCommandId     ID of command to be executed.
+        * @return TInt          KErrNone if OK, else value indicating error situation.
+        */
+        TInt ExecuteCommandL( TUint aCommandId );
+    
+    public: // Functions from base classes
+        
+        // From MTtsClientUtilityObserver
+        void MapcPlayComplete( TInt aError );
+        
+        // From MTtsClientUtilityObserver
+        void MapcInitComplete( TInt aError,
+                               const TTimeIntervalMicroSeconds& aDuration );
+        
+        // Not implemented
+        void MapcCustomCommandEvent( TInt /*aEvent*/, TInt /*aError*/ ) {};
+                        
+        /** 
+	    A response has been received. 
+	    @param aOperationId The operation ID. The response is to a previous 
+	    command of this type.
+	    @param The response error.
+	    */
+	    void MrccacoResponse( TRemConCoreApiOperationId aOperationId, TInt aError );
+
+		
+    private: // Constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CNssVCAppLauncher();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+	private: // New functions
+	    
+	    /**
+        * Launches calendars day view to a selected day.
+        * @since 3.0
+        * @param day Which day will be opened in the wiew:
+                      today | tomorrow | monday | tuesday | ...
+        * @return void
+        */
+        void CalendarDayViewL( const TInt aDay );
+        
+        /**
+        * Launches calendars week view to a selected week.
+        * @since 3.0
+        * @param week Which week will be opened in the wiew:
+                      this week | next week
+        * @return void
+        */
+        void CalendarWeekViewL( const TInt aWeek );
+        
+        /**
+        * Launches calendars month view to a selected month.
+        * @since 3.0
+        * @param month Which month will be opened in the wiew:
+                       this month | next month | january | february | ...
+        * @return void
+        */
+        void CalendarMonthViewL( const TInt aMonth );
+        
+        /**
+        * Opens browser with the user defined homepage.
+        * @since 3.0
+        * @return void
+        */
+        void OpenHomepageL();
+        
+        /**
+        * Activates SMS reader
+        * @since 3.0
+        * @param aAppUid UID for SMS reader
+        * @return
+        */
+        TInt SMSReaderL( const TUid aAppUid );
+        
+        /**
+        * Provides the answer to the voice command "What time is it?"
+        * @since 3.0
+        * @return void
+        */
+        void StatusTimeL();
+        
+        /**
+        * Provides the answer to the voice command "Who is my operator?"
+        * @since 3.0
+        * @return void
+        */
+        void StatusOperatorL();
+        
+        /**
+        * Provides the answer to the voice command "What is the battery strength?"
+        * @since 3.0
+        * @return void
+        */
+        void StatusBatteryL();
+        
+        /**
+        * Provides the answer to the voice command "What is the signal strength?"
+        * @since 3.0
+        * @return void
+        */
+        void StatusSignalL();
+        
+        /**
+        * Performs text to speech answer for a status query.
+        * @since 3.0
+        * @return void
+        */
+        void PlaybackStatusInfoL();
+        
+        /**
+        * Connects to RApaLsSession.
+        * @since 3.0
+        * @return void
+        */  
+        void CreateApaConnectionL();
+
+        /* Activates an instance of an application.
+        * @since 3.0
+        * @param aUid Application UID
+        * @param aCommandLine Command line parameters.
+        * @return void
+        */
+        void ActivateAppInstanceL( const TUid aUid,
+                                   const TDesC16* aCmdLine = NULL );
+    
+        /**
+        * Used to launch applications. Checks whether an instance of the launched
+        * application is already running.
+        * @since 3.0
+        * @param aUid The Uid of the specific application.
+        * @param aCommandLine Command line parameters.
+        * @param aMultipleInstances If true, the application is activated
+        *        in multiple instances.
+        * @return void
+        */
+        void ActivateAppL( const TUid aUid,
+                           const TDesC16* aCmdLine = NULL,
+                           TBool aMultipleInstances = EFalse );
+        
+        /**
+        * Tells whether it is am or pm.
+        * @since 3.0
+        * @param aTime Current time
+        * @return TTimeOfDay enum value for am or pm is put here
+        */
+        void GetAmOrPmL( const TTime& aTime, TAmPm& aTod );
+        
+        /**
+        * Gets network operator's name.
+        * @since 3.0
+        * @param aOperator The name of the operator will be put here
+        *        if it is found.
+        * @return void
+        */
+        void GetOperatorL( TDesC*& aOperator );
+        
+        /**
+        * Gets the battery strength.
+        * @since 3.0
+        * @param aBattStrength The battery strength will be put here
+        * return void
+        */
+        void GetBatteryStrengthL( TSpokenStatusInfo& aBattStrength );
+        
+        /**
+        * Gets the signal strength.
+        * @since 3.0
+        * @param aSignalStrength The signal strength will be put here
+        * @return void
+        */
+        void GetSignalStrengthL( TSpokenStatusInfo& aSignalStrength );
+        
+        /**
+        * Gets the name of the currently selected TSY.
+        * @since 3.0
+        * @param aTSYName The name of the currently selected TSY will be put
+        *        here.
+        * @return void
+        */
+        void GetTSYNameL( TDes& aTSYName );
+        
+        /**
+        * Executes a media command using Symbian Remote Control FW.
+        * @since 3.0
+        * @param aCommandId The media command to be executed
+        * @return void
+        */
+        void ExecuteMediaCommandL( TUint aMediaCommandId );
+        
+        /*
+        * Gets localized string from the resource file for text-to-speech
+        * status info.
+        * @since 3.0
+        * @param aStringId The string which we want
+        * @param aString Localized string will be put here
+        */
+        void GetLocalizedStringL( TSpokenStatusInfo aStringId, HBufC*& aString );   
+
+
+    private:     // Data
+        
+        RApaLsSession*   iApaLsSession;
+		
+		// Text to speech stuff
+		CTtsUtility*     iTts;
+        CTtsParsedText*  iParsedText;
+        TTtsStyle        iStyle;
+        // Answer for a status query
+        HBufC*           iStatusInfo;
+        
+        // Wait loop for TTS callbacks
+        CActiveSchedulerWait iWait;
+    };
+
+#endif      // __NSSVCAPPLAUNCHER_H__   
+            
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/inc/nssvcapplauncher.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains declarations for resources of voice command
+*               executor. The file can be included in C++ or resource file.
+*
+*/
+
+
+#ifndef NSSVCAPPLAUNCHER_HRH
+#define NSSVCAPPLAUNCHER_HRH
+
+
+#include    <bldvariant.hrh>
+
+//  CONSTANTS
+
+/**
+* Application ids used to
+* check which application needs to be started
+*/
+enum TAppLauncherIds
+    {
+    ECalendar = 1,
+    ECalendarToday,
+    ECalendarTomorrow,
+    ECalendarMonday,
+    ECalendarTuesday,         // 5
+    ECalendarWednesday,
+    ECalendarThursday,
+    ECalendarFriday,
+    ECalendarSaturday,
+    ECalendarSunday,          // 10
+    ECalendarThisWeek,
+    ECalendarNextWeek,
+    ECalendarThisMonth,
+    ECalendarNextMonth,
+    ECalendarJanuary,         // 15
+    ECalendarFebruary,
+    ECalendarMarch,
+    ECalendarApril,
+    ECalendarMay,
+    ECalendarJune,            // 20
+    ECalendarJuly,
+    ECalendarAugust,
+    ECalendarSeptember,
+    ECalendarOctober,
+    ECalendarNovember,        //25
+    ECalendarDecember,
+    EStatusTime,
+    EStatusOperator,
+    EStatusBatteryStrength,
+    EStatusSignalStrength,    // 30
+    EBrowser,
+    ESMSReader,
+    EMediaPlay,
+    EMediaPause,
+    EMediaStop,               // 35
+    EMediaNextSong,
+    EMediaPreviousSong,
+    EMediaNextChannel,
+    EMediaPreviousChannel,
+    EMediaChannelUp,          // 40
+    EMediaChannelDown,
+    EMediaVolumeUp,
+    EMediaVolumeDown
+    };
+
+/**
+* Constants for commanding which day in day view
+* is to be opened. Days Mon-Sun (0-6) from enum
+* TDay (in e32std.h).
+*/    
+enum TDayViewExtraConsts
+    {
+    EToday = 7,
+    ETomorrow
+    };
+    
+/**
+* Constants for commanding which week in week view
+* is to be opened.
+*/    
+enum TWeekViewConsts
+    {
+    EThisWeek = 0,
+    ENextWeek
+    };
+
+/**
+* Constants for commanding which month in month
+* view is to be opened. Months Jan-Dec (0-11)
+* from enum TMonth (in e32std.h).
+*/    
+enum TMonthViewExtraConsts
+    {
+    EThisMonth = 12,
+    ENextMonth
+    };
+
+/*
+* Spoken status infos for time, operator, battery, and signal strengths
+*/
+enum TSpokenStatusInfo
+    {
+    ETime24Format,
+    ETimeAm,
+    ETimePm,
+    EOperator,
+    EOperatorNotAvailable,
+    EBatteryFull,
+    EBattetteryAlmostFull,
+    EBatteryHalfFull,
+    EBatteryAlmostEmpty,
+    EBatteryLow,
+    EBatteryStrengthNotAvailable,
+    ESignalStrengthExcellent,
+    ESignalStrengthGood,
+    ESignalStrengthRatherGood,
+    ESignalStrengthLow,
+    ESignalStrengthNoSignal,
+    ESignalStrengthNotAvailable
+    };
+
+/*
+* 
+*/     
+
+#endif // NSSVCAPPLAUNCHER_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/inc/nssvcapplauncherconstants.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains the UIDs for applications.
+*
+*/
+
+
+
+#ifndef NSSVCAPPLAUNCHERCONSTANTS_H
+#define NSSVCAPPLAUNCHERCONSTANTS_H
+
+// INCLUDES
+#include    <e32base.h>
+#include    <e32keys.h>
+#include    <e32svr.h>
+
+// CONSTANTS
+
+/**
+* APPLICATION UIDS
+*/
+
+// VCommandExecutor bearer
+const TUid KUidVCExecutorBearer = { 0x10281C7E };
+
+// Calendar UID
+const TUid KUidAppCalendar = { 0x10005901 };
+
+// Browser UID
+const TUid KUidAppBrowser = { 0x10008D39 };
+
+
+#endif      // NSSVCAPPLAUNCHERCONSTANTS_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/src/nssvcapplauncher.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1445 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is an implementation class for checking which 
+*               application or profile needs to be activated and then
+*               Starts it.
+*
+*/
+
+
+// INCLUDE FILES
+#include "rubydebug.h"
+#include "nssvcapplauncher.h"
+#include "nssvcapplauncher.hrh"
+#include "nssvcapplauncherconstants.h"
+#include <etel.h>
+#include <etelmm.h>
+#include <commdb.h>
+#include <apgtask.h>     // TApaTask, TApaTaskList
+#include <apacmdln.h>    // CApaCommandLine
+#include <e32def.h>
+#include <f32file.h>     // RFs
+#include <bautils.h>     // BaflUtils
+#include <RemConExtensionApi.h>
+#include <remconinterfaceselector.h>
+#include <remconcoreapicontroller.h>
+
+
+#include <vcommandexecutor.rsg>
+
+#include <AknGlobalConfirmationQuery.h> // Confirmation query.
+
+// CONSTANTS
+
+_LIT( KPanicCategory, "VCommandExecutor" );
+//Command line parameter for launching calendar to day view
+_LIT16( KCalendarDayCmdLine, "DATE %d %d %d 08 00 00 000000" );
+//Command line parameter for launching calendar to week view
+_LIT16( KCalendarWeekCmdLine, "WEEK %d %d %d %d 00 00 000000" );
+//Command line parameter for launching calendar to month view
+_LIT16( KCalendarMonthCmdLine, "MONTH %d %d %d 08 00 00 000000" );
+// Command line parameter for Browser application for opening the browser
+// to start page
+_LIT16( KBrowserArgStartPage, "5" );
+
+// Battery charge level in percentage scaled to five values
+const TInt KBatteryFull = 85; // full >= 85
+const TInt KBatteryAlmostFull = 65; // 65 <= almost full < 85 
+const TInt KBatteryHalfFull = 35; // 35 <= half full < 65
+const TInt KBatteryAlmostEmpty = 15; // 15 <= almost empty < 35
+// low < 15
+
+// Signal strength level in seven bars scaled to five values
+const TInt KSignalExcellent = 6; // excellent >= 6
+const TInt KSignalGood = 5; // good == 5 
+const TInt KSignalRatherGood = 3; // 3 <= rather good < 5
+const TInt KSignalLow = 1; // 1 <= low < 3
+const TInt KSignalNone = 0;
+// low < 15
+
+// letters for drives in search order
+const TBuf<1> KResourceDrivers = _L("z"); 
+_LIT( KResourceDir, "\\resource\\" );
+_LIT( KResourceFileName, "VCommandExecutor.rsc" );
+
+// String from loc-file must be modified for TTime::FormatL function
+_LIT( KLocFileHourString, "%0N" );
+_LIT( KLocFileMinuteString, "%1N" );
+_LIT( KTTimeHourString, "%J");
+_LIT( KTTimeHourStringWithZero, "0%J");
+_LIT( KTTimeMinuteString, "%T");
+
+const TInt KDaysInAWeek = 7;
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CNssVCAppLauncher::CNssVCAppLauncher()
+    {
+    }
+
+// Destructor
+CNssVCAppLauncher::~CNssVCAppLauncher()
+    {
+    
+    if ( iApaLsSession )
+        {
+        iApaLsSession->Close();
+        delete iApaLsSession;
+        iApaLsSession = NULL;
+        }
+    if ( iTts )
+        {
+        delete iTts;
+        iTts = NULL;
+        }
+    if ( iParsedText )
+        {
+        delete iParsedText;
+        iParsedText = NULL;
+        }
+    if ( iStatusInfo )
+        {
+        delete iStatusInfo;
+        iStatusInfo = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::ConstructL
+// Symbian 2nd phase constructor
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::ConstructL" );
+    }
+
+
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher* CNssVCAppLauncher::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CNssVCAppLauncher* CNssVCAppLauncher::NewL()                                                           
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::NewL" );
+    
+    CNssVCAppLauncher* self= new (ELeave) CNssVCAppLauncher();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::ExecuteCommandL
+// Checks the id and calls the appropriate function.
+// ----------------------------------------------------------------------------
+//
+TInt CNssVCAppLauncher::ExecuteCommandL( TUint aCommandId )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::ExecuteCommandL" );
+    
+    TInt err = KErrNone;
+
+	switch( aCommandId )
+		{
+		case ECalendar:
+			ActivateAppL( KUidAppCalendar );
+			break;
+			
+        case ECalendarToday:
+			CalendarDayViewL( EToday );
+			break;
+			
+        case ECalendarTomorrow:
+			CalendarDayViewL( ETomorrow );
+			break;
+			
+        case ECalendarMonday:
+			CalendarDayViewL( EMonday );
+			break;
+			
+        case ECalendarTuesday:
+			CalendarDayViewL( ETuesday );
+			break;
+			
+        case ECalendarWednesday:
+			CalendarDayViewL( EWednesday );
+			break;
+			
+        case ECalendarThursday:
+			CalendarDayViewL( EThursday );
+			break;
+			
+        case ECalendarFriday:
+			CalendarDayViewL( EFriday );
+			break;
+			
+        case ECalendarSaturday:
+			CalendarDayViewL( ESaturday );
+			break;
+			
+        case ECalendarSunday:
+			CalendarDayViewL( ESunday );
+			break;
+			
+        case ECalendarThisWeek:
+			CalendarWeekViewL( EThisWeek );
+			break;
+			
+        case ECalendarNextWeek:
+			CalendarWeekViewL( ENextWeek );
+			break;
+			
+        case ECalendarThisMonth:
+			CalendarMonthViewL( EThisMonth );
+			break;
+			
+        case ECalendarNextMonth:
+			CalendarMonthViewL( ENextMonth );
+			break;
+			
+        case ECalendarJanuary:
+			CalendarMonthViewL( EJanuary );
+			break;
+			
+        case ECalendarFebruary:
+			CalendarMonthViewL( EFebruary );
+			break;
+			
+        case ECalendarMarch:
+			CalendarMonthViewL( EMarch );
+			break;
+			
+        case ECalendarApril:
+			CalendarMonthViewL( EApril );
+			break;
+			
+        case ECalendarMay:
+			CalendarMonthViewL( EMay );
+			break;
+			
+        case ECalendarJune:
+			CalendarMonthViewL( EJune );
+			break;
+			
+        case ECalendarJuly:
+			CalendarMonthViewL( EJuly );
+			break;
+			
+        case ECalendarAugust:
+			CalendarMonthViewL( EAugust );
+			break;
+			
+        case ECalendarSeptember:
+			CalendarMonthViewL( ESeptember );
+			break;
+			
+        case ECalendarOctober:
+			CalendarMonthViewL( EOctober );
+			break;
+			
+        case ECalendarNovember:
+			CalendarMonthViewL( ENovember );
+			break;
+			
+        case ECalendarDecember:
+			CalendarMonthViewL( EDecember );
+			break;
+				
+        case EStatusTime:
+		    StatusTimeL();
+		    break;
+		
+        case EStatusOperator:
+		    StatusOperatorL();
+		    break;
+		    
+        case EStatusBatteryStrength:
+		    StatusBatteryL();
+		    break;
+		    
+        case EStatusSignalStrength:
+		    StatusSignalL();
+		    break;
+		    
+        case EBrowser:
+		    ActivateAppL( KUidAppBrowser );
+		    break;
+		    
+        /*case ESMSReader:
+            ActivateAppL( KUidAppSMSReader );
+            break;*/
+        
+        case EMediaPlay:
+            ExecuteMediaCommandL( EMediaPlay );
+            break;
+            
+        case EMediaStop:
+            ExecuteMediaCommandL( EMediaStop );
+            break;
+            
+        case EMediaPause:
+            ExecuteMediaCommandL( EMediaPause );
+            break;
+            
+        case EMediaNextSong:
+            ExecuteMediaCommandL( EMediaNextSong );
+            break;
+            
+        case EMediaNextChannel:
+            ExecuteMediaCommandL( EMediaNextChannel );
+            break;
+            
+        case EMediaPreviousSong:
+            ExecuteMediaCommandL( EMediaPreviousSong );
+            break;
+            
+        case EMediaPreviousChannel:
+            ExecuteMediaCommandL( EMediaPreviousChannel );
+            break;
+            
+        case EMediaVolumeUp:
+            ExecuteMediaCommandL( EMediaVolumeUp );
+            break;
+       		
+       case EMediaVolumeDown:
+            ExecuteMediaCommandL( EMediaVolumeDown );
+            break;
+
+       		
+		default:
+			err = KErrNotSupported;
+			break;
+		}
+		
+    return err;
+    }
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::CreateConnectionL
+// Connects to RApaLsSession.
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::CreateApaConnectionL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::CreateApaConnectionL" );
+    
+    iApaLsSession = new RApaLsSession();
+       
+    if ( !iApaLsSession->Handle() )
+        {
+        User::LeaveIfError( iApaLsSession->Connect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::ActivateAppL
+// Used to launch applications. Checks whether an instance of the launched
+// application is already running.
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::ActivateAppL( const TUid aUid,
+                                      const TDesC16* aCmdLine,
+                                      TBool aMultipleInstances )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::ActivateAppL" );
+    
+    CreateApaConnectionL();
+
+    if ( aMultipleInstances )
+        {
+        ActivateAppInstanceL( aUid );
+        }
+    else
+        {
+        // Session to window server
+        RWsSession wsSession;
+        User::LeaveIfError( wsSession.Connect() );
+        
+        TApaTaskList apaTaskList( wsSession );
+        TApaTask apaTask = apaTaskList.FindApp( aUid );
+        if ( apaTask.Exists() )
+            {
+            // Already running, close application
+            apaTask.EndTask();
+            }
+        ActivateAppInstanceL( aUid, aCmdLine );
+            
+        wsSession.Close();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::ActivateAppInstanceL
+// Activates an instance of an application.
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::ActivateAppInstanceL( const TUid aUid, const TDesC16* aCmdLine )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::ActivateAppInstanceL" );
+    
+	TApaAppInfo appInfo;
+    User::LeaveIfError( iApaLsSession->GetAppInfo( appInfo, aUid ) );
+	TFileName appName = appInfo.iFullName;
+	CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+
+	apaCommandLine->SetExecutableNameL( appName );
+	apaCommandLine->SetCommandL( EApaCommandRun );
+	if ( aCmdLine )
+	    {
+	    // copy the 16-bit data into 8-bit buffer
+        HBufC8* paramBuf = HBufC8::NewLC( aCmdLine->Length() *2 );
+        TPtr8 tailBuf = paramBuf->Des();
+        tailBuf.Copy( reinterpret_cast<const TUint8*>( aCmdLine->Ptr() ), aCmdLine->Length() *2 );
+	    
+	    // Command line parameters
+	    apaCommandLine->SetTailEndL( tailBuf );
+	    
+	    CleanupStack::PopAndDestroy( paramBuf );
+	    }
+	
+	User::LeaveIfError ( iApaLsSession->StartApp( *apaCommandLine ) );
+	CleanupStack::PopAndDestroy( apaCommandLine );
+	}
+    
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::StatusTimeL
+// Provides the answer to the voice command "What time is it?"
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::StatusTimeL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::StatusTimeL" );
+    
+    TTime time;
+    time.HomeTime();
+    
+    HBufC* timeStatusString = NULL;
+    
+    TLocale locale;
+    if ( locale.TimeFormat() == ETime24 )
+        {
+        // "It is %N0:%N1"
+        GetLocalizedStringL( ETime24Format, timeStatusString );
+        }
+    else // 12-hour format
+        {
+        TAmPm timeOfDay;
+        GetAmOrPmL( time, timeOfDay );
+        if ( timeOfDay == EAm )
+            {
+            // "It is %0N:%1N AM"
+            GetLocalizedStringL( ETimeAm, timeStatusString );
+            }
+        else
+            {
+            // "It is %0N:%1N PM"
+            GetLocalizedStringL( ETimePm, timeStatusString );
+            }
+        }
+    
+    CleanupStack::PushL( timeStatusString );
+    // Modify timeStatusString for TTime:FormatL
+    TInt index( KErrNotFound );
+    index = timeStatusString->Find( KLocFileHourString );
+    if( index != KErrNotFound )
+        {
+        // Hour
+    	if ( locale.TimeFormat() == ETime12 && 
+                 ( ( time.DateTime().Hour() > 0 && time.DateTime().Hour() < 10 ) || 
+                 ( time.DateTime().Hour() > 12 && time.DateTime().Hour() < 22 ) ) )
+    	    {
+    	    timeStatusString->Des().Replace( index, KLocFileHourString.iTypeLength,
+                                             KTTimeHourStringWithZero );
+        	}
+        else
+        	{
+        	timeStatusString->Des().Replace( index, KLocFileHourString.iTypeLength,
+                                                 KTTimeHourString );
+        	}
+        }
+    index = timeStatusString->Find( KLocFileMinuteString );
+    if( index != KErrNotFound )
+        {
+        // Minute
+        timeStatusString->Des().Replace( index, KLocFileMinuteString.iTypeLength,
+                                         KTTimeMinuteString );
+        }
+    iStatusInfo = HBufC::NewL( timeStatusString->Length() );
+    TBuf<256> string;
+    time.FormatL( string, *timeStatusString );
+    iStatusInfo->Des().Append( string );
+    CleanupStack::PopAndDestroy( timeStatusString );
+    
+    PlaybackStatusInfoL();
+    }
+    
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::StatusOperatorL
+// Provides the answer to the voice command "Who is my operator?"
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::StatusOperatorL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::StatusOperatorL" );
+    
+    // The operator
+    TDesC* oper = NULL;
+    HBufC* operStatusString = NULL;
+    GetOperatorL( oper );
+    
+    if ( oper && oper->Length() > 0 )
+        {
+        CleanupStack::PushL( oper );
+        // "Your operator is %U"
+        GetLocalizedStringL( EOperator, operStatusString );
+        CleanupStack::PushL( operStatusString );
+        TInt index( -1 );
+        index = operStatusString->Find( _L( "%U" ) );
+        if( index > -1 )
+           {
+           operStatusString->Des().Replace( index, 2, _L( "%S" ) );
+           }    
+        iStatusInfo = HBufC::NewL( operStatusString->Length() * 2 ); // Just to be on the safe side
+        iStatusInfo->Des().Format( operStatusString->Des(), oper );
+        CleanupStack::PopAndDestroy( operStatusString );
+        CleanupStack::PopAndDestroy( oper );
+        }
+    else
+        {
+        delete oper;
+        // "Operator information not available"
+        GetLocalizedStringL( EOperatorNotAvailable, operStatusString );
+        CleanupStack::PushL( operStatusString );
+        iStatusInfo = operStatusString->Des().Alloc();
+        CleanupStack::PopAndDestroy( operStatusString );
+        }
+    PlaybackStatusInfoL();
+    }
+    
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::StatusBatteryL
+// Provides the answer to the voice command "What is the battery strength?"
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::StatusBatteryL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::StatusBatteryL" );
+    
+    TSpokenStatusInfo battStrength;
+    GetBatteryStrengthL( battStrength );
+    
+    HBufC* battStatusString;
+    
+    switch ( battStrength )
+        {
+        case EBatteryFull:
+            // "The battery is full"
+            GetLocalizedStringL( EBatteryFull, battStatusString );
+            iStatusInfo = battStatusString;
+            break;
+            
+        case EBattetteryAlmostFull:
+            // "The battery is almost full"
+            GetLocalizedStringL( EBattetteryAlmostFull, battStatusString );
+            iStatusInfo = battStatusString;
+            break;
+            
+        case EBatteryHalfFull:
+            // "The battery is half full"
+            GetLocalizedStringL( EBatteryHalfFull, battStatusString );
+            iStatusInfo = battStatusString;
+            break;
+            
+        case EBatteryAlmostEmpty:
+            // "The battery is almost empty"
+            GetLocalizedStringL( EBatteryAlmostEmpty, battStatusString );
+            iStatusInfo = battStatusString;
+            break;
+            
+        case EBatteryLow:
+            // "The battery is low. Please recharge"
+            GetLocalizedStringL( EBatteryLow, battStatusString );
+            iStatusInfo = battStatusString;
+            break;
+            
+        case EBatteryStrengthNotAvailable:
+            // "Battery strength information not available"
+            GetLocalizedStringL( EBatteryStrengthNotAvailable, battStatusString );
+            iStatusInfo = battStatusString;
+            break;
+        }
+        
+    PlaybackStatusInfoL();
+    }
+    
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::StatusSignalL
+// Provides the answer to the voice command "What is the signal strength?"
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::StatusSignalL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::StatusSignalL" );
+    
+    TSpokenStatusInfo signalStrength;
+    GetSignalStrengthL( signalStrength );
+    
+    HBufC* signalStatusString;
+    
+    switch ( signalStrength )
+        {
+        case ESignalStrengthExcellent:
+            // "The network strength is excellent"
+            GetLocalizedStringL( ESignalStrengthExcellent, signalStatusString );
+            iStatusInfo = signalStatusString;
+            break;
+            
+        case ESignalStrengthGood:
+            // "The network strength is good"
+            GetLocalizedStringL( ESignalStrengthGood, signalStatusString );
+            iStatusInfo = signalStatusString;
+            break;
+            
+        case ESignalStrengthRatherGood:
+            // "The network strength is rather good"
+            GetLocalizedStringL( ESignalStrengthRatherGood, signalStatusString );
+            iStatusInfo = signalStatusString;
+            break;
+            
+        case ESignalStrengthLow:
+            // "The network strength is low"
+            GetLocalizedStringL( ESignalStrengthLow, signalStatusString );
+            iStatusInfo = signalStatusString;
+            break;
+            
+        case ESignalStrengthNoSignal:
+            // "No network"
+            GetLocalizedStringL( ESignalStrengthNoSignal, signalStatusString );
+            iStatusInfo = signalStatusString;
+            break;
+            
+        case ESignalStrengthNotAvailable:
+            // "Signal strength information not available"
+            GetLocalizedStringL( ESignalStrengthNotAvailable, signalStatusString );
+            iStatusInfo = signalStatusString;
+            break;
+        }
+        
+    PlaybackStatusInfoL();
+    }
+
+// ----------------------------------------------------------------------------
+// CNssVCAppLauncher::PlaybackStatusInfoL
+// Performs text to speech answer for a status query.
+// ----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::PlaybackStatusInfoL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::PlaybackStatusInfoL" );
+    
+    __ASSERT_ALWAYS( iStatusInfo,
+                     User::Panic( KPanicCategory, KErrArgument ) );
+                     
+    RUBY_DEBUG1( "TTS text: \"%S\"", iStatusInfo );
+    
+    // TTS utility for playback
+    iTts = CTtsUtility::NewL( *this );
+    
+    // Create TTS style with language + NLP on
+    TTtsStyle style;
+    style.iNlp = ETrue;
+    style.iLanguage = User::Language();
+    
+    // Add style to TTS
+    TTtsStyleID styleId = iTts->AddStyleL( style );
+    
+    // Segment
+    TTtsSegment segment( styleId );
+    
+    // Parsed text
+    iParsedText = CTtsParsedText::NewL();  
+    iParsedText->SetTextL( *iStatusInfo );
+    segment.SetTextPtr( iParsedText->Text() );
+    iParsedText->AddSegmentL( segment );
+        
+    // Run synthesis
+    iTts->OpenAndPlayParsedTextL( *iParsedText );
+    
+    if ( !iWait.IsStarted() )
+        {
+        iWait.Start();
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::MapcPlayComplete
+// Callback, playback has been initialized.
+// -----------------------------------------------------------------------------
+//
+void CNssVCAppLauncher::MapcInitComplete( TInt aError,
+                                          const TTimeIntervalMicroSeconds& /*aDuration*/ )
+    {
+    RUBY_DEBUG1( "CNssVCAppLauncher::MapcInitComplete [%d]", aError );
+    
+    if ( ( aError != KErrNone ) && ( iWait.IsStarted() ) )
+        {
+        iWait.AsyncStop();
+        }
+    }  
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::MapcPlayComplete
+// Callback, playback has been completed.
+// -----------------------------------------------------------------------------
+//     
+#if defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+void CNssVCAppLauncher::MapcPlayComplete( TInt aError )
+#else
+void CNssVCAppLauncher::MapcPlayComplete( TInt /*aError*/ )
+#endif
+    {
+    RUBY_DEBUG1( "NssVCAppLauncher::MapcPlayComplete [%d]", aError );         
+          
+    if ( iTts )
+        {
+        iTts->Stop();
+        iTts->Close();
+        }
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetAmOrPmL
+// Tells whether it is am or pm.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::GetAmOrPmL( const TTime& aTime, TAmPm& aTod )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::GetAmOrPmL" );
+    
+    TTime time = aTime;
+    // Add one day
+    time += TTimeIntervalDays( 1 );
+    // Copy to TDateTime object
+    TDateTime dateTime = time.DateTime();
+    // Set to midnight
+    dateTime.SetHour( 0 );
+    dateTime.SetMinute( 0 );
+    dateTime.SetMicroSecond( 0 );
+    // Copy to TTime object
+    time = dateTime;
+    
+    TTimeIntervalHours hours;
+    aTime.HoursFrom( time, hours );
+    // Hours from midnight
+    TInt hoursInt = hours.Int();
+    if ( hours.Int() > -12 )
+        {
+        aTod = EPm;
+        }
+    else
+        {
+        aTod = EAm;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetOperatorL
+// Gets network operator's name.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::GetOperatorL( TDesC*& aOperator )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::GetOperatorL" );
+    
+    TFileName tsyName;
+    GetTSYNameL( tsyName );
+    RTelServer server;
+    User::LeaveIfError( server.Connect() );
+    server.LoadPhoneModule( tsyName );
+    
+    RMobilePhone::TMobilePhoneNetworkInfoV1 networkInfo;
+    RMobilePhone::TMobilePhoneNetworkInfoV1Pckg networkInfoPkg( networkInfo );
+    RMobilePhone::TMobilePhoneLocationAreaV1 locationInfo;
+
+    TRequestStatus reqStatus = KErrNone;
+    RMobilePhone phone;
+    RTelServer::TPhoneInfo info;
+    User::LeaveIfError( server.GetPhoneInfo( 0, info ) );
+    User::LeaveIfError( phone.Open( server, info.iName ) );
+    phone.GetCurrentNetwork( reqStatus, networkInfoPkg, locationInfo );
+    
+    User::WaitForRequest( reqStatus );
+    if( reqStatus == KErrNone )
+        {
+        TBuf<256> networkName;
+        networkName.Copy( networkInfo.iLongName );
+        HBufC* oper = networkName.AllocL();
+        aOperator = oper;
+        }
+        
+    phone.Close(); 
+    server.UnloadPhoneModule( tsyName );
+    server.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetBatteryStrengthL
+// Gets the battery strength.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::GetBatteryStrengthL( TSpokenStatusInfo& aBattStrength )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::GetBatteryStrengthL" );
+    
+    aBattStrength = EBatteryStrengthNotAvailable;
+    
+    TFileName tsyName;
+    GetTSYNameL( tsyName );
+    RTelServer server;
+    User::LeaveIfError( server.Connect() );
+    server.LoadPhoneModule( tsyName );
+    
+    TRequestStatus reqStatus = KErrNone;
+    RMobilePhone phone;
+    RTelServer::TPhoneInfo info;
+    User::LeaveIfError( server.GetPhoneInfo( 0, info ) );
+    User::LeaveIfError( phone.Open( server, info.iName ) );
+    
+    TUint32 batteryCaps;
+    // Test if battery strength can be obtained
+    if ( phone.GetBatteryCaps( batteryCaps ) != KErrNone )
+        {
+        return;
+        }
+
+    TInt charge = -1;
+    if ( batteryCaps & RMobilePhone::KCapsGetBatteryInfo )
+        {
+        RMobilePhone::TMobilePhoneBatteryInfoV1 mobilePhoneBatteryInfo;
+        TRequestStatus status;
+        phone.GetBatteryInfo( status, mobilePhoneBatteryInfo );
+        User::WaitForRequest( status );
+        User::LeaveIfError( status.Int() );
+        if ( mobilePhoneBatteryInfo.iStatus == RMobilePhone::EPoweredByBattery )
+            {
+            // The percentage battery charge level
+            charge = mobilePhoneBatteryInfo.iChargeLevel;
+            if ( charge >= KBatteryFull )
+                {
+                aBattStrength = EBatteryFull;
+                }
+            else if ( charge >= KBatteryAlmostFull )
+                {
+                aBattStrength = EBattetteryAlmostFull;
+                }
+            else if ( charge >= KBatteryHalfFull )
+                {
+                aBattStrength = EBatteryHalfFull;
+                }
+            else if ( charge >= KBatteryAlmostEmpty )
+                {
+                aBattStrength = EBatteryAlmostEmpty;
+                }
+            else
+                {
+                aBattStrength = EBatteryLow;
+                }
+            }
+        }
+        //else BATTERY INFO NOT AVAILABLE
+        
+    phone.Close(); 
+    server.UnloadPhoneModule( tsyName );
+    server.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetSignalStrengthL
+// Gets the signal strength.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::GetSignalStrengthL( TSpokenStatusInfo& aSignalStrength )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::GetSignalStrengthL" );
+    
+    aSignalStrength = ESignalStrengthNotAvailable;
+    
+    TFileName tsyName;
+    GetTSYNameL( tsyName );
+    RTelServer server;
+    User::LeaveIfError( server.Connect() );
+    server.LoadPhoneModule( tsyName );
+
+    RMobilePhone phone;
+    RTelServer::TPhoneInfo info;
+    User::LeaveIfError( server.GetPhoneInfo( 0, info ) );
+    User::LeaveIfError( phone.Open( server, info.iName ) );
+    
+    TUint32 signalCaps;
+    // Test if signal information can be obtained
+    User::LeaveIfError( phone.GetSignalCaps( signalCaps ) );
+
+    TInt32 signalStrength = -1;
+    TInt8 bars = -1;
+    if ( signalCaps & RMobilePhone::KCapsGetSignalStrength )
+        {
+        TRequestStatus status = KErrNone;
+        phone.GetSignalStrength( status, signalStrength, bars );
+        User::WaitForRequest( status );
+        RUBY_DEBUG1( "Signal strength in dBm: %d", signalStrength );
+        RUBY_DEBUG1( "Number of signal bars: %d", bars );
+        if ( bars >= KSignalExcellent )
+            {
+            aSignalStrength = ESignalStrengthExcellent;
+            }
+        else if ( bars == KSignalGood )
+            {
+            aSignalStrength = ESignalStrengthGood;
+            }
+        else if ( bars >= KSignalRatherGood )
+            {
+            aSignalStrength = ESignalStrengthRatherGood;
+            }
+        else if ( bars >= KSignalLow )
+            {
+            aSignalStrength = ESignalStrengthLow;
+            }
+        else if ( bars == KSignalNone )
+            {
+            aSignalStrength = ESignalStrengthNoSignal;
+            }
+        }
+    
+    phone.Close(); 
+    server.UnloadPhoneModule( tsyName );
+    server.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::CalendarDayViewL
+// Activates calendars day view.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::CalendarDayViewL( const TInt aDay )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::CalendarDayViewL" );
+    
+    __ASSERT_ALWAYS( aDay >= EMonday && aDay <= ETomorrow,
+                     User::Panic( KPanicCategory, KErrArgument ) );
+    
+    TTime time;
+    // Current date
+    time.HomeTime();
+    TDateTime dateTime = time.DateTime();
+    // TTime::DayNoInMonth()'s first day in month is zero
+    const TInt KCurrentDayInMonth = time.DayNoInMonth() + 1;
+    const TInt KCurrentDayInWeek = time.DayNoInWeek();
+    const TInt KCurrentMonth = dateTime.Month();
+    const TInt KCurrentYear = dateTime.Year();
+    // Variables used to form parameters for calendar launching
+    TInt day = KCurrentDayInMonth;
+    TInt month = KCurrentMonth;
+    TInt year = KCurrentYear;
+    
+    // Command for weekday
+    if( aDay >= EMonday && aDay <= ESunday )
+        {
+        if ( KCurrentDayInWeek <= aDay )
+            {
+            // Depend on existing enum values, not good
+            day += aDay - KCurrentDayInWeek; 
+            }
+        else if ( KCurrentDayInWeek > aDay )
+            {
+            // Depend on existing enum values, not good
+            // Go to monday of next week and add whatever is necessery
+            day += KDaysInAWeek - KCurrentDayInWeek + aDay;
+            }
+        
+        // Month changes
+        if ( day > time.DaysInMonth() )
+            {
+            day -= time.DaysInMonth();
+            // Year changes
+            if ( month == EDecember )
+                {
+                month = EJanuary;
+                year++;
+                }
+            else
+                {
+                month++;
+                }
+            }
+        }
+   // Command for tomorrow     
+   else if ( aDay == ETomorrow )
+        {
+        day++;
+        // Month changes
+        if ( day > time.DaysInMonth() )
+            {
+            // First day
+            day = 1;
+            month++;
+            
+            // Year changes
+            if ( KCurrentMonth == EDecember )
+                {
+                month = EJanuary;
+                year++;
+                }
+            }
+        }
+    
+    // Offset for TMonth is zero, so we add one
+    month++; 
+    
+    HBufC16* cmdLine = HBufC16::NewLC( KCalendarDayCmdLine().Length() * 2 ); // Just to be on the safe side
+    cmdLine->Des().Format( KCalendarDayCmdLine, year, month, day );
+    
+    // Launch calendar
+    ActivateAppL( KUidAppCalendar, cmdLine );
+    
+    CleanupStack::PopAndDestroy( cmdLine );
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::CalendarWeekViewL
+// Launches calendars week view to a selected week.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::CalendarWeekViewL( const TInt aWeek )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::CalendarWeekViewL" );
+    
+    __ASSERT_ALWAYS( aWeek == EThisWeek || aWeek == ENextWeek,
+                     User::Panic( KPanicCategory, KErrArgument ) );
+    
+    TLocale locale;
+    TTime time;
+    // Current date
+    time.HomeTime();
+    TDateTime dateTime = time.DateTime();
+    // TTime::DayNoInMonth()'s first day in month is zero
+    const TInt KCurrentDayInMonth = time.DayNoInMonth() + 1;
+    // According to documentation, TTime::DayNoInWeek() should honour the 
+    // setting specified in TLocale::SetStartOfWeek(). It doesn't though.
+    TInt currentDayInWeek;
+    if( time.DayNoInWeek() >= locale.StartOfWeek() )
+        {
+        currentDayInWeek = time.DayNoInWeek() - locale.StartOfWeek() ;
+        }
+    else
+        {
+        currentDayInWeek = KDaysInAWeek - locale.StartOfWeek() + time.DayNoInWeek();
+        }
+    const TInt KCurrentDayInWeek = currentDayInWeek;
+    const TInt KCurrentMonth = dateTime.Month();
+    const TInt KCurrentYear = dateTime.Year();
+    // Variables used to form parameters for calendar launching
+    TInt year = KCurrentYear;
+    TInt month = KCurrentMonth;
+    TInt day = KCurrentDayInMonth;
+    TInt hour = dateTime.Hour();
+    
+    if ( aWeek == ENextWeek )
+        {
+        // 8 am
+        hour = 8;
+        // Go to the first day of next week
+        day += KDaysInAWeek - KCurrentDayInWeek;
+        
+        // Month changes
+        if( day > time.DaysInMonth() )
+            {
+            day -= time.DaysInMonth();
+            month++;
+            
+            // Year changes
+            if ( KCurrentMonth == EDecember )
+                {
+                year++;
+                month = EJanuary;
+                }
+            }
+        }
+        
+    // Offset for TMonth is zero, so we add one
+    month++;
+    
+    HBufC16* cmdLine = HBufC16::NewLC( KCalendarWeekCmdLine().Length() * 2 ); // Just to be on the safe side
+    cmdLine->Des().Format( KCalendarWeekCmdLine, year, month, day, hour );
+    
+    // Launch calendar
+    ActivateAppL( KUidAppCalendar, cmdLine );
+    
+    CleanupStack::PopAndDestroy( cmdLine );
+    }
+        
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::CalendarMonthViewL
+// Launches calendars month view to a selected month.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::CalendarMonthViewL( const TInt aMonth )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::CalendarMonthViewL" );
+    
+    __ASSERT_ALWAYS( aMonth >= EMonday && aMonth <= ENextMonth,
+                     User::Panic( KPanicCategory, KErrArgument ) );
+                     
+    TTime time;
+    // Current date
+    time.HomeTime();
+    TDateTime dateTime = time.DateTime();
+    const TInt KCurrentMonth = dateTime.Month();
+    // Variables used to form parameters for calendar launching
+    TInt year = dateTime.Year();
+    TInt month = KCurrentMonth;
+    // TDateTime::Day() offset is zero
+    TInt day = dateTime.Day() + 1;
+    
+    if ( aMonth >= EJanuary && aMonth <= EDecember )
+        {
+        if( aMonth != KCurrentMonth )
+            {
+            day = 1;
+            }
+        month = aMonth;
+        // If the requested month is already past for this year
+        // month view is openend for next year. 
+        if ( aMonth < KCurrentMonth )
+            {
+            year++;
+            }
+        }
+    else if ( aMonth == ENextMonth )
+        {
+        day = 1;
+        if ( KCurrentMonth == EDecember )
+            {
+            year++;
+            month = EJanuary;
+            }
+        else
+            {
+            month++;
+            }
+        }
+        
+    // Offset for TMonth is zero, so we add one
+    month++;    
+    
+    HBufC16* cmdLine = HBufC16::NewLC( KCalendarMonthCmdLine().Length() * 2 ); // Just to be on the safe side
+    cmdLine->Des().Format( KCalendarMonthCmdLine, year, month, day );
+    
+    // Launch calendar
+    ActivateAppL( KUidAppCalendar, cmdLine );
+    
+    CleanupStack::PopAndDestroy( cmdLine );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetOpenHomepageL
+// Opens browser with the user defined homepage.
+// ----------------------------------------------------------------------------- 
+void CNssVCAppLauncher::OpenHomepageL()
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::OpenHomepageL" );
+    
+    // Command line parameter for starting the browser with start page
+    HBufC16* cmdLine = KBrowserArgStartPage().AllocLC();
+    
+    // Launch browser
+    ActivateAppL( KUidAppBrowser, cmdLine );
+    
+    CleanupStack::PopAndDestroy( cmdLine );
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetTSYNameL
+// Gets the name of the currently selected TSY.
+// -----------------------------------------------------------------------------    
+void CNssVCAppLauncher::GetTSYNameL( TDes& aTSYName )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::GetTSYNameL" );
+    
+    CCommsDatabase* const db = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
+    CleanupStack::PushL( db );
+    TUint32 modemId = 0;
+    db->GetGlobalSettingL( TPtrC( MODEM_PHONE_SERVICES_SMS ), modemId );
+    CCommsDbTableView* const view
+        = db->OpenViewMatchingUintLC( TPtrC( MODEM ), TPtrC( COMMDB_ID ),
+                                      modemId );
+    TInt err = view->GotoFirstRecord();
+    User::LeaveIfError( err );
+    view->ReadTextL( TPtrC( MODEM_TSY_NAME ), aTSYName );
+    CleanupStack::PopAndDestroy( view );
+    CleanupStack::PopAndDestroy( db );
+    }
+    
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::ExecuteMediaCommandL
+// Executes a media command using Symbian Remote Control FW.
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::ExecuteMediaCommandL( TUint aMediaCommandId )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::ExecuteMediaCommandL" );
+    
+    __ASSERT_ALWAYS( aMediaCommandId >= EMediaPlay &&
+                     aMediaCommandId <= EMediaVolumeDown,
+                     User::Panic( KPanicCategory, KErrArgument ) );
+    
+    CRemConInterfaceSelector* interfaceSelector
+        = CRemConInterfaceSelector::NewL();
+    
+    // Owned by interfaceSelector
+    CRemConCoreApiController* coreIf
+        = CRemConCoreApiController::NewL( *interfaceSelector, *this );
+    
+    interfaceSelector->OpenControllerL();
+    
+    TRemConAddress addr;
+    addr.BearerUid() = KUidVCExecutorBearer;
+    // No bearer-specific connection data
+    interfaceSelector->GoConnectionOrientedL( addr );
+        
+    TRequestStatus status;
+    
+    interfaceSelector->ConnectBearer( status );
+    User::WaitForRequest( status );    
+    
+    TUint numRemotes;
+    
+    switch ( aMediaCommandId )
+        {
+        // TODO: remove User::After calls. They are for testing purposes only.
+        case EMediaPlay:
+            coreIf->PausePlayFunction( status, numRemotes,
+                                       ERemConCoreApiButtonPress );
+            User::WaitForRequest( status );
+            break;
+         
+        case EMediaPause:
+            coreIf->Pause( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+        
+        case EMediaStop:
+            coreIf->Stop( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;    
+       
+        case EMediaNextSong:
+            coreIf->Forward( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaNextChannel:
+            coreIf->Forward( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaPreviousSong:
+            coreIf->Backward( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaPreviousChannel:
+            coreIf->Backward( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaChannelUp:
+            coreIf->ChannelUp( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaChannelDown:
+            coreIf->ChannelDown( status, numRemotes,
+                                 ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaVolumeUp:
+            coreIf->VolumeUp( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+            
+        case EMediaVolumeDown:
+            coreIf->VolumeDown( status, numRemotes, ERemConCoreApiButtonClick );
+            User::WaitForRequest( status );
+            break;
+        }
+    
+    delete interfaceSelector;
+    interfaceSelector = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::MrccacoResponse
+// Called by RemCon as a response for a remote control command sent by this
+// RemCon controller client
+// -----------------------------------------------------------------------------
+void CNssVCAppLauncher::MrccacoResponse( TRemConCoreApiOperationId /*aOperationId*/,
+                                         TInt /*aError*/ )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVCAppLauncher::GetLocalizedStringL
+// Gets localized string from the resource file for text-to-speech status info.
+// -----------------------------------------------------------------------------    
+    
+void CNssVCAppLauncher::GetLocalizedStringL( TSpokenStatusInfo aStringId,
+                                             HBufC*& aString )
+    {
+    RUBY_DEBUG_BLOCKL( "CNssVCAppLauncher::GetLocalizedStringL" );
+    
+    __ASSERT_ALWAYS( aStringId >= ETime24Format &&
+                     aStringId <= ESignalStrengthNotAvailable, 
+                     User::Panic( KPanicCategory, KErrArgument ) );
+    
+    // load resources
+    RResourceFile resourceFile;
+    RFs fileServer;
+    TBool found( EFalse );
+    User::LeaveIfError( fileServer.Connect() );
+    CleanupClosePushL( fileServer );
+    
+    // try finding a localized or default resource file browsing through the drivers 
+    TFileName name;
+    TInt i( 0 );
+    // use the first drive
+    name.Append( KResourceDrivers[i] );
+    name.Append( ':' );
+    name.Append( KResourceDir );
+    name.Append( KResourceFileName );
+
+    while ( !found && i < KResourceDrivers.Length() )
+        {
+        name[0] = KResourceDrivers[i++];
+
+        BaflUtils::NearestLanguageFile( fileServer, name );
+       
+        if ( BaflUtils::FileExists(fileServer, name) )
+            {
+            // open resource
+            resourceFile.OpenL( fileServer, name );
+            CleanupClosePushL( resourceFile );
+            resourceFile.ConfirmSignatureL();
+            found = ETrue;
+            }
+        }
+
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+        
+    TResourceReader reader;
+    
+    // Get correct localized string    
+    switch ( aStringId )
+        {
+        case ETime24Format:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_TIME24 ) );
+        break;
+            
+        case ETimeAm:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_TIME12AM ) );
+        break;
+            
+        case ETimePm:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_TIME12PM ) );
+        break;
+            
+        case EOperator:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_OPERATOR ) );
+        break;
+        
+        case EOperatorNotAvailable:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NOOPERATOR ) );
+        break;
+         
+        case EBatteryFull:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_BATTERYFULL ) );
+        break;
+        
+        case EBattetteryAlmostFull:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_BATTERYALMOSTFULL ) );
+        break;
+        
+        case EBatteryHalfFull:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_BATTERYHALF ) );
+        break;
+        
+        case EBatteryAlmostEmpty:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_BATTERYALMOSTEMPTY ) );
+        break;
+        
+        case EBatteryLow:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_BATTERYLOW ) );
+        break;
+        
+        case EBatteryStrengthNotAvailable:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NOBATTERY ) );
+        break;
+        
+        case ESignalStrengthExcellent:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NETWORKEXCELLENT ) );
+        break;
+            
+        case ESignalStrengthGood:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NETWORKGOOD ) );
+        break;
+        
+        case ESignalStrengthRatherGood:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NETWORKRATHERGOOD ) );
+        break;
+        
+        case ESignalStrengthLow:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NETWORKLOW ) );
+        break;
+        
+        case ESignalStrengthNoSignal:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NETWORKNONE ) );
+        break;
+        
+        case ESignalStrengthNotAvailable:
+        reader.SetBuffer( resourceFile.AllocReadLC( PROMPT_NONETWORK ) );
+        break;
+        
+        default:
+            break;
+
+        }
+            
+    aString = reader.ReadHBufCL();
+    
+    CleanupStack::PopAndDestroy(); // AllocReadLC
+    
+    CleanupStack::PopAndDestroy( &resourceFile );
+    CleanupStack::PopAndDestroy( &fileServer );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutor/src/nssvcommandexecutor.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include    "rubydebug.h"
+#include    "nssvcapplauncher.hrh"
+#include    "nssvcapplauncher.h"
+#include    <e32std.h>
+#include    <bacline.h>
+
+//=============================================================================
+
+TInt ReadArgumentL( TInt& aArgument )
+    {
+    CCommandLineArguments* args = CCommandLineArguments::NewLC();
+    // First argument is program name. Therefore there must be two arguments
+    if ( args->Count() < 2 )
+        {
+        User::Leave( KErrArgument ); 
+        }
+    // We are interested in only the second argument (command to be executed).
+    TPtrC argumentPrt( args->Arg( 1 ) );
+    // Convert argument to TInt
+    TLex lex( argumentPrt );
+    User::LeaveIfError( lex.Val( aArgument ) );
+    
+    CleanupStack::PopAndDestroy( args );
+    
+    return KErrNone;
+    }
+
+//=============================================================================
+
+void ExecuteL()
+    {
+    // Create active scheduler (to run active objects)
+    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+    
+    // Command line argument
+    TInt clArgument( -1 );
+    ReadArgumentL( clArgument );
+    
+    if ( clArgument >= ECalendar && clArgument <= EMediaVolumeDown )
+        {
+        __UHEAP_MARK;
+        CNssVCAppLauncher* appLauncher = CNssVCAppLauncher::NewL();
+        CleanupStack::PushL( appLauncher );
+        
+        appLauncher->ExecuteCommandL( clArgument );
+        
+        CleanupStack::PopAndDestroy ( appLauncher ); 
+        __UHEAP_MARKEND;
+        }
+        
+    // Delete active scheduler
+    CleanupStack::PopAndDestroy( scheduler );
+    }
+    
+//=============================================================================
+
+GLDEF_C TInt E32Main()
+    {
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    
+    RUBY_TRAP_IGNORE( ExecuteL() );
+    
+    delete cleanup;
+    
+    return KErrNone;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/group/10281c7e.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 1020 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+//  INCLUDES
+#include <ecom/registryinfo.rh>
+#include "nssvcexecutorbearer.hrh"
+ 
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// REGISTRY_INFO theInfo
+// Information needed for Ecom Plugin
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = NssVCExecutorBearerPluginDllUid;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = NssVCExecutorBearerPluginInterfaceUid;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = NssVCExecutorBearerPluginImplementationUid;
+					version_no = 1;
+					display_name = "NssVCExecutorBearer";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
+//
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for VCommandExecutorBearer
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+nssvcexecutorbearer.mmp
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/group/nssvcexecutorbearer.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP file for nssvcexecutorbearer.dll
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <remcon/remconservercaps.mmh>
+#include <data_caging_paths.hrh>
+
+TARGET			nssvcexecutorbearer.dll
+
+// CAPABILITY      CAP_ECOM_PLUGIN 
+// capabilities are required as that of remconbearerplugin.dll
+// getting it from #include <remcon/remconservercaps.mmh>
+
+TARGETTYPE		PLUGIN
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID'
+UID 			0x10009d8d 0x10281C7E
+VENDORID		VID_DEFAULT
+
+SOURCEPATH		../src
+SOURCE			nssvcexecutorbearermain.cpp
+SOURCE			nssvcexecutorbearerimpl.cpp
+
+SOURCEPATH      .
+
+START RESOURCE 10281c7e.rss
+#ifdef SYMBIAN_SECURE_ECOM
+target nssvcexecutorbearer.rsc
+#endif
+END
+
+USERINCLUDE 	. ../inc
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY 		euser.lib 
+LIBRARY			ecom.lib
+LIBRARY 		c32.lib 
+LIBRARY 		remconbearerplugin.lib 
+LIBRARY 		remcontypes.lib
+LIBRARY 		flogger.lib
+LIBRARY         avkon.lib
+LIBRARY         akncapserverclient.lib
+LIBRARY         apparc.lib
+LIBRARY         eikcore.lib
+
+#include <comms-infras/commsdebugutility.mmh>
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/inc/nssvcexecutorbearer.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+//  DLL UID
+#define NssVCExecutorBearerPluginDllUid            0x10281C7E
+
+// Interface from RemCon. VCExecutor bearer implements this interface.
+#define NssVCExecutorBearerPluginInterfaceUid      0x10204546
+
+// Implementation Uid - Used by the Target Selector Plugin.
+#define NssVCExecutorBearerPluginImplementationUid 0x10281C7E
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/inc/nssvcexecutorbearerimpl.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*       Declaration of class NssVCExecutorBearer.
+*       
+*
+*/
+
+
+#ifndef __NSSVCEXECUTORBEARERIMPL_H__
+#define __NSSVCEXECUTORBEARERIMPL_H__
+
+// INCLUDE
+#include <e32base.h>
+#include <c32comm.h>
+#include <remcon/remconbearerplugin.h>
+#include <remcon/remconbearerinterface.h>
+#include <remcon/messagetype.h>
+
+//CONSTANTS
+const TInt KDataBufferSize = 10;
+
+/**
+*  NssVCExecutorBearer
+*     Implementation of the Rem Con Bearer Plugin
+*  @lib Nssvcexecutorbearer.dll
+*  @since 3.0
+*/
+class NssVCExecutorBearer : public CRemConBearerPlugin,
+                     public MRemConBearerInterface
+    {
+    public:
+        /**
+        * Creates instance of the NssVCExecutorBearer class.
+        *
+        * @param  TBearerParams: required for the CRemConBearerPlugin
+        * @return : Instance of the NssVCExecutorBearer
+        */
+        static NssVCExecutorBearer* NewL(TBearerParams& aParams);
+
+        /**
+        * Destructor.
+        */    
+        virtual ~NssVCExecutorBearer();
+
+    private:  // constructors
+        /**
+        * default constructor.
+        * @param aParams: BearerPlugin Params
+        */
+        NssVCExecutorBearer(TBearerParams& aParams);
+        
+        /**
+        * Two - phase construction.
+        */
+        void ConstructL();
+
+    private: // from CRemConBearerPlugin
+        /** @see CRemConBearerPlugin::GetInterface() */
+    	TAny* GetInterface(TUid aUid);
+
+    private: // from MRemConBearerInterface
+    
+        /** @see MRemConBearerInterface::GetResponse() */
+        TInt GetResponse(TUid& aInterfaceUid, 
+            TUint& aTransactionId, 
+            TUint& aOperationId, 
+            RBuf8& aData, 
+            TRemConAddress& aAddr);
+            
+        /** @see MRemConBearerInterface::SendCommand() */            
+        TInt SendCommand(TUid aInterfaceUid, 
+            TUint aCommand, 
+            TUint aTransactionId,  
+            RBuf8& aData, 
+            const TRemConAddress& aAddr);
+            
+        /** @see MRemConBearerInterface::GetCommand() */            
+        TInt GetCommand(TUid& aInterfaceUid, 
+            TUint& aTransactionId, 
+            TUint& aCommand, 
+            RBuf8& aData, 
+            TRemConAddress& aAddr);
+            
+        /** @see MRemConBearerInterface::SendResponse() */
+        TInt SendResponse(TUid aInterfaceUid, 
+            TUint aOperationId, 
+            TUint aTransactionId, 
+            RBuf8& aData, 
+            const TRemConAddress& aAddr);
+
+        /** @see MRemConBearerInterface::ConnectRequest() */
+        void ConnectRequest(const TRemConAddress& aAddr);
+        
+        /** @see MRemConBearerInterface::DisconnectRequest() */        
+        void DisconnectRequest(const TRemConAddress& aAddr);
+        
+        /** @see MRemConBearerInterface::ClientStatus() */        
+        void ClientStatus(TBool aControllerPresent, TBool aTargetPresent);
+        
+        /** @see MRemConBearerInterface::SecurityPolicy() */        
+        TSecurityPolicy SecurityPolicy() const;
+
+
+    private: // Data
+
+        // Last received and corrected-decoded message.
+        TUid iInterfaceUid;
+        TUint iOperationId;
+
+        TBuf8<KDataBufferSize> iData;
+        
+        TUint iTransactionId;
+    };
+
+#endif // __NSSVCEXECUTORBEARERIMPL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/src/nssvcexecutorbearerimpl.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,228 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Bearer plugin API Implementation file
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32def.h>
+#include <remcon/remconbearerobserver.h>
+#include <remcon/remconconverterplugin.h>
+#include <remconaddress.h>
+#include <remconcoreapi.h>
+
+// Include this once it is exported
+// #include <RemConExtensionApi.h>
+
+#include "nssvcexecutorbearerimpl.h"                                     
+
+//Constants
+_LIT8( KFormatString, "%c" );
+
+// ---------------------------------------------------------
+// NssVCExecutorBearer::NewL()
+// Description: Factory function.
+// return: Ownership of a new NssVCExecutorBearer.
+// ---------------------------------------------------------
+//
+NssVCExecutorBearer* NssVCExecutorBearer::NewL( TBearerParams& aParams )
+    {
+    NssVCExecutorBearer* self = new(ELeave) NssVCExecutorBearer( aParams );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------
+// NssVCExecutorBearer::~NssVCExecutorBearer()
+// Destructor.
+// ---------------------------------------------------------
+//
+NssVCExecutorBearer::~NssVCExecutorBearer()
+    {    
+    }
+
+// ---------------------------------------------------------
+// NssVCExecutorBearer::NssVCExecutorBearer()
+// construction.
+// ---------------------------------------------------------
+//
+NssVCExecutorBearer::NssVCExecutorBearer( TBearerParams& aParams )
+:   CRemConBearerPlugin( aParams )
+    {
+    //Pass
+    }
+
+// ---------------------------------------------------------
+// NssVCExecutorBearer::ConstructL()
+// 2nd-phase construction.
+// ---------------------------------------------------------
+//
+void NssVCExecutorBearer::ConstructL()
+    {
+    // throw an indication up to RemCon.
+    TRemConAddress addr;
+    addr.BearerUid() = Uid();
+    TInt err = Observer().ConnectIndicate( addr );
+    }
+    
+// ---------------------------------------------------------
+// NssVCExecutorBearer::ConnectRequest()
+// Rem Con server send connect request to Bearer Plugin
+// ---------------------------------------------------------
+//
+void NssVCExecutorBearer::ConnectRequest(const TRemConAddress& /*aAddr*/)
+    {
+    // Pass
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::DisconnectRequest()
+// Rem Con server send disconnect request to Bearer Plugin
+// ---------------------------------------------------------
+//
+void NssVCExecutorBearer::DisconnectRequest(const TRemConAddress& /*aAddr*/)
+    {
+    // Pass
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::SendResponse()
+// @see MRemConBearerInterface::SendResponse()
+// ---------------------------------------------------------
+//
+TInt NssVCExecutorBearer::SendResponse(TUid /* aInterfaceUid */, 
+        TUint /*aOperationId*/, 
+        TUint /*aTransactionId*/, // we don't care about this transaction ID
+        RBuf8& /* aData */, 
+        const TRemConAddress& /*aAddr*/)
+    {
+    return KErrNone;
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::SendCommand()
+// @see MRemConBearerInterface::SendCommand()
+// ---------------------------------------------------------
+//
+TInt NssVCExecutorBearer::SendCommand( TUid  /*aInterfaceUid */ , 
+        TUint  aOperationId , 
+        TUint /* aTransactionId */,  
+        RBuf8& /* aData */, 
+        const TRemConAddress& /*aAddr*/)
+    {
+    // 1. Button click
+    iData.Format( KFormatString, ERemConCoreApiButtonClick );
+    
+    // 2. Operation id. No conversion is done.
+    iOperationId = aOperationId;
+    
+    // 3. Interface ID is required when GetCommand is called
+    iInterfaceUid = TUid::Uid( KRemConCoreApiUid ); // from Remconcoreapi.h
+    
+    // 4. Transaction ID
+    iTransactionId = Observer().NewTransactionId();
+    
+    // 5. Addr 
+    TRemConAddress addr;
+    addr.BearerUid() = Uid();
+    addr.Addr() = KNullDesC8();
+    
+    // Msgtype  is ERemConCommand
+    TInt aError = Observer().NewCommand( addr );
+    
+    return KErrNone;
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::GetResponse()
+// @see MRemConBearerInterface::GetResponse()
+// ---------------------------------------------------------
+//
+TInt NssVCExecutorBearer::GetResponse( TUid& /* aInterfaceUid */, 
+        TUint& /* aTransactionId*/, 
+        TUint& /* aOperationId */, 
+        RBuf8& /* aData */, 
+        TRemConAddress& /*aAddr */)
+    {
+    return KErrNone;
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::GetCommand()
+// @see MRemConBearerInterface::GetCommand()
+// ---------------------------------------------------------
+//
+TInt NssVCExecutorBearer::GetCommand( TUid& aInterfaceUid, 
+                                      TUint& aTransactionId, 
+                                      TUint& aOperationId, 
+                                      RBuf8& aData,
+                                      TRemConAddress& aAddr )
+    {
+    TInt error( KErrNone );
+    
+    aInterfaceUid = iInterfaceUid;
+    aOperationId = iOperationId;
+
+    // Pass ownership of this to RemCon.
+    error = aData.Create( iData );
+    
+    if ( error == KErrNone )
+        {
+        aAddr.BearerUid() = Uid();
+        aAddr.Addr() = KNullDesC8();
+    
+        aTransactionId = iTransactionId;
+        }
+    
+    return error;
+    }
+
+
+// ---------------------------------------------------------
+// NssVCExecutorBearer::SecurityPolicy()
+// @see MRemConBearerInterface::SecurityPolicy()
+// ---------------------------------------------------------
+//
+TSecurityPolicy NssVCExecutorBearer::SecurityPolicy() const
+    {
+    return TSecurityPolicy(ECapabilityLocalServices);
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::ClientStatus()
+// @see MRemConBearerInterface::ClientStatus()
+// ---------------------------------------------------------
+//
+void NssVCExecutorBearer::ClientStatus(TBool /*aControllerPresent*/, 
+                                TBool /*aTargetPresent*/)
+    {
+    //Pass
+    }
+// ---------------------------------------------------------
+// NssVCExecutorBearer::GetInterface()
+// @see CRemConBearerPlugin::GetInterface()
+// ---------------------------------------------------------
+//
+TAny* NssVCExecutorBearer::GetInterface(TUid aUid)
+    {
+    TAny* ret = NULL;
+    if ( aUid == TUid::Uid( KRemConBearerInterface1 ) )
+        {
+        ret = reinterpret_cast<TAny*>(
+                    static_cast<MRemConBearerInterface*>(this)
+                    );
+        }
+    return ret;
+
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandexecutorbearer/src/nssvcexecutorbearermain.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*       Bearer plugin main file
+*       
+*
+*/
+
+
+// INCLUDE FILES
+#include <ecom/implementationproxy.h>
+#include "nssvcexecutorbearerimpl.h"
+#include "nssvcexecutorbearer.hrh"
+
+// CONSTANTS
+// Define the private interface UIDs
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( NssVCExecutorBearerPluginImplementationUid, NssVCExecutorBearer::NewL ),
+    };
+
+// ---------------------------------------------------------
+// ImplementationGroupProxy ()
+// ---------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+    return ImplementationTable;
+    }
+
+//
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/bwins/vcommandhandleru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+EXPORTS
+	??1CVCCommandUi@@UAE@XZ @ 1 NONAME ; CVCCommandUi::~CVCCommandUi(void)
+	??1CVCFolderInfo@@UAE@XZ @ 2 NONAME ; CVCFolderInfo::~CVCFolderInfo(void)
+	??1CVCRecognitionManager@@UAE@XZ @ 3 NONAME ; CVCRecognitionManager::~CVCRecognitionManager(void)
+	??1CVCRunnable@@UAE@XZ @ 4 NONAME ; CVCRunnable::~CVCRunnable(void)
+	??1CVCommand@@UAE@XZ @ 5 NONAME ; CVCommand::~CVCommand(void)
+	??1CVCommandArray@@UAE@XZ @ 6 NONAME ; CVCommandArray::~CVCommandArray(void)
+	??1CVCommandHandler@@UAE@XZ @ 7 NONAME ; CVCommandHandler::~CVCommandHandler(void)
+	??8CVCCommandUi@@QBEHABV0@@Z @ 8 NONAME ; int CVCCommandUi::operator==(class CVCCommandUi const &) const
+	??8CVCFolderInfo@@QBEHABV0@@Z @ 9 NONAME ; int CVCFolderInfo::operator==(class CVCFolderInfo const &) const
+	??8CVCRunnable@@QBEHABV0@@Z @ 10 NONAME ; int CVCRunnable::operator==(class CVCRunnable const &) const
+	??8CVCommand@@QBEHABV0@@Z @ 11 NONAME ; int CVCommand::operator==(class CVCommand const &) const
+	??ACVCommandArray@@QBEABVCVCommand@@H@Z @ 12 NONAME ; class CVCommand const & CVCommandArray::operator[](int) const
+	?AddCommandL@CVCommandHandler@@UAEXABVCVCommand@@@Z @ 13 NONAME ; void CVCommandHandler::AddCommandL(class CVCommand const &)
+	?AddCommandsL@CVCommandHandler@@UAEXABV?$RPointerArray@VCVCommand@@@@H@Z @ 14 NONAME ; void CVCommandHandler::AddCommandsL(class RPointerArray<class CVCommand> const &, int)
+	?AlternativeSpokenText@CVCommand@@QBEABVTDesC16@@XZ @ 15 NONAME ; class TDesC16 const & CVCommand::AlternativeSpokenText(void) const
+	?Arguments@CVCRunnable@@QBEABVTDesC8@@XZ @ 16 NONAME ; class TDesC8 const & CVCRunnable::Arguments(void) const
+	?At@CVCommandArray@@QBEABVCVCommand@@H@Z @ 17 NONAME ; class CVCommand const & CVCommandArray::At(int) const
+	?CancelPlaybackL@CVCommand@@UBEXABVCVCommandHandler@@@Z @ 18 NONAME ; void CVCommand::CancelPlaybackL(class CVCommandHandler const &) const
+	?CommandUi@CVCommand@@QBEABVCVCCommandUi@@XZ @ 19 NONAME ; class CVCCommandUi const & CVCommand::CommandUi(void) const
+	?ConfirmationNeeded@CVCCommandUi@@QBEHXZ @ 20 NONAME ; int CVCCommandUi::ConfirmationNeeded(void) const
+	?Count@CVCommandArray@@QBEHXZ @ 21 NONAME ; int CVCommandArray::Count(void) const
+	?EqualNonUserChangeableData@CVCCommandUi@@QBEHABV1@@Z @ 22 NONAME ; int CVCCommandUi::EqualNonUserChangeableData(class CVCCommandUi const &) const
+	?EqualNonUserChangeableData@CVCommand@@QBEHABV1@@Z @ 23 NONAME ; int CVCommand::EqualNonUserChangeableData(class CVCommand const &) const
+	?ExeName@CVCRunnable@@QBEABVTDesC16@@XZ @ 24 NONAME ; class TDesC16 const & CVCRunnable::ExeName(void) const
+	?ExecuteL@CVCRunnable@@QBEXXZ @ 25 NONAME ; void CVCRunnable::ExecuteL(void) const
+	?ExternalizeL@CVCCommandUi@@QBEXAAVRWriteStream@@@Z @ 26 NONAME ; void CVCCommandUi::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CVCFolderInfo@@QBEXAAVRWriteStream@@@Z @ 27 NONAME ; void CVCFolderInfo::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CVCRunnable@@QBEXAAVRWriteStream@@@Z @ 28 NONAME ; void CVCRunnable::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CVCommand@@QBEXAAVRWriteStream@@@Z @ 29 NONAME ; void CVCommand::ExternalizeL(class RWriteStream &) const
+	?FolderInfo@CVCCommandUi@@QBEABVCVCFolderInfo@@XZ @ 30 NONAME ; class CVCFolderInfo const & CVCCommandUi::FolderInfo(void) const
+	?HelpTopicId@CVCFolderInfo@@QBEKXZ @ 31 NONAME ; unsigned long CVCFolderInfo::HelpTopicId(void) const
+	?IconFile@CVCFolderInfo@@IBEAAVTDesC16@@XZ @ 32 NONAME ; class TDesC16 & CVCFolderInfo::IconFile(void) const
+	?IconIndex@CVCFolderInfo@@IBEIXZ @ 33 NONAME ; unsigned int CVCFolderInfo::IconIndex(void) const
+	?IconLC@CVCCommandUi@@QBEPAVCGulIcon@@XZ @ 34 NONAME ; class CGulIcon * CVCCommandUi::IconLC(void) const
+	?IconLC@CVCFolderInfo@@QBEPAVCGulIcon@@XZ @ 35 NONAME ; class CGulIcon * CVCFolderInfo::IconLC(void) const
+	?IconUid@CVCCommandUi@@QBEABVTUid@@XZ @ 36 NONAME ; class TUid const & CVCCommandUi::IconUid(void) const
+	?ListCommandsL@CVCommandHandler@@UAEPAVCVCommandArray@@XZ @ 37 NONAME ; class CVCommandArray * CVCommandHandler::ListCommandsL(void)
+	?ListedName@CVCFolderInfo@@QBEABVTDesC16@@XZ @ 38 NONAME ; class TDesC16 const & CVCFolderInfo::ListedName(void) const
+	?Modifiable@CVCCommandUi@@QBEHXZ @ 39 NONAME ; int CVCCommandUi::Modifiable(void) const
+	?NewL@CVCCommandUi@@SAPAV1@AAVRReadStream@@@Z @ 40 NONAME ; class CVCCommandUi * CVCCommandUi::NewL(class RReadStream &)
+	?NewL@CVCCommandUi@@SAPAV1@ABV1@@Z @ 41 NONAME ; class CVCCommandUi * CVCCommandUi::NewL(class CVCCommandUi const &)
+	?NewL@CVCCommandUi@@SAPAV1@ABVTDesC16@@ABVCVCFolderInfo@@H0ABVTUid@@0H@Z @ 42 NONAME ; class CVCCommandUi * CVCCommandUi::NewL(class TDesC16 const &, class CVCFolderInfo const &, int, class TDesC16 const &, class TUid const &, class TDesC16 const &, int)
+	?NewL@CVCFolderInfo@@SAPAV1@AAVRReadStream@@@Z @ 43 NONAME ; class CVCFolderInfo * CVCFolderInfo::NewL(class RReadStream &)
+	?NewL@CVCFolderInfo@@SAPAV1@ABV1@@Z @ 44 NONAME ; class CVCFolderInfo * CVCFolderInfo::NewL(class CVCFolderInfo const &)
+	?NewL@CVCFolderInfo@@SAPAV1@ABVTDesC16@@0KI0@Z @ 45 NONAME ; class CVCFolderInfo * CVCFolderInfo::NewL(class TDesC16 const &, class TDesC16 const &, unsigned long, unsigned int, class TDesC16 const &)
+	?NewL@CVCRecognitionManager@@SAPAV1@XZ @ 46 NONAME ; class CVCRecognitionManager * CVCRecognitionManager::NewL(void)
+	?NewL@CVCRunnable@@SAPAV1@AAVRReadStream@@@Z @ 47 NONAME ; class CVCRunnable * CVCRunnable::NewL(class RReadStream &)
+	?NewL@CVCRunnable@@SAPAV1@ABV1@@Z @ 48 NONAME ; class CVCRunnable * CVCRunnable::NewL(class CVCRunnable const &)
+	?NewL@CVCRunnable@@SAPAV1@ABVTDesC16@@ABVTDesC8@@@Z @ 49 NONAME ; class CVCRunnable * CVCRunnable::NewL(class TDesC16 const &, class TDesC8 const &)
+	?NewL@CVCRunnable@@SAPAV1@VTUid@@ABVTDesC8@@@Z @ 50 NONAME ; class CVCRunnable * CVCRunnable::NewL(class TUid, class TDesC8 const &)
+	?NewL@CVCommand@@SAPAV1@AAVRReadStream@@@Z @ 51 NONAME ; class CVCommand * CVCommand::NewL(class RReadStream &)
+	?NewL@CVCommand@@SAPAV1@ABV1@@Z @ 52 NONAME ; class CVCommand * CVCommand::NewL(class CVCommand const &)
+	?NewL@CVCommand@@SAPAV1@ABVTDesC16@@ABVCVCRunnable@@ABVCVCCommandUi@@@Z @ 53 NONAME ; class CVCommand * CVCommand::NewL(class TDesC16 const &, class CVCRunnable const &, class CVCCommandUi const &)
+	?NewL@CVCommandArray@@SAPAV1@ABV?$RPointerArray@VCVCommand@@@@@Z @ 54 NONAME ; class CVCommandArray * CVCommandArray::NewL(class RPointerArray<class CVCommand> const &)
+	?NewL@CVCommandHandler@@SAPAV1@PAVMVCommandHandlerObserver@@@Z @ 55 NONAME ; class CVCommandHandler * CVCommandHandler::NewL(class MVCommandHandlerObserver *)
+	?PlayAlternativeSpokenTextL@CVCommand@@UBEXABVCVCommandHandler@@AAVMNssPlayEventHandler@@@Z @ 56 NONAME ; void CVCommand::PlayAlternativeSpokenTextL(class CVCommandHandler const &, class MNssPlayEventHandler &) const
+	?PlaySpokenTextL@CVCommand@@UBEXABVCVCommandHandler@@AAVMNssPlayEventHandler@@@Z @ 57 NONAME ; void CVCommand::PlaySpokenTextL(class CVCommandHandler const &, class MNssPlayEventHandler &) const
+	?PointerArray@CVCommandArray@@QBEABV?$RPointerArray@VCVCommand@@@@XZ @ 58 NONAME ; class RPointerArray<class CVCommand> const & CVCommandArray::PointerArray(void) const
+	?ProduceTrainSetByRunnablesLC@CVCommandArray@@QBEPAV1@ABV?$RPointerArray@VCVCommand@@@@@Z @ 59 NONAME ; class CVCommandArray * CVCommandArray::ProduceTrainSetByRunnablesLC(class RPointerArray<class CVCommand> const &) const
+	?ProduceUntrainSetByRunnablesLC@CVCommandArray@@QBEPAV1@ABV?$RPointerArray@VCVCommand@@@@@Z @ 60 NONAME ; class CVCommandArray * CVCommandArray::ProduceUntrainSetByRunnablesLC(class RPointerArray<class CVCommand> const &) const
+	?RemoveCommandL@CVCommandHandler@@UAEXABVCVCommand@@@Z @ 61 NONAME ; void CVCommandHandler::RemoveCommandL(class CVCommand const &)
+	?RemoveCommandsL@CVCommandHandler@@UAEXABV?$RPointerArray@VCVCommand@@@@H@Z @ 62 NONAME ; void CVCommandHandler::RemoveCommandsL(class RPointerArray<class CVCommand> const &, int)
+	?Runnable@CVCommand@@QBEABVCVCRunnable@@XZ @ 63 NONAME ; class CVCRunnable const & CVCommand::Runnable(void) const
+	?SpokenText@CVCommand@@QBEABVTDesC16@@XZ @ 64 NONAME ; class TDesC16 const & CVCommand::SpokenText(void) const
+	?Title@CVCFolderInfo@@QBEABVTDesC16@@XZ @ 65 NONAME ; class TDesC16 const & CVCFolderInfo::Title(void) const
+	?Tooltip@CVCCommandUi@@QBEABVTDesC16@@XZ @ 66 NONAME ; class TDesC16 const & CVCCommandUi::Tooltip(void) const
+	?Uid@CVCRunnable@@QBE?BVTUid@@XZ @ 67 NONAME ; class TUid const CVCRunnable::Uid(void) const
+	?UserText@CVCCommandUi@@QBEABVTDesC16@@XZ @ 68 NONAME ; class TDesC16 const & CVCCommandUi::UserText(void) const
+	?WrittenText@CVCCommandUi@@QBEABVTDesC16@@XZ @ 69 NONAME ; class TDesC16 const & CVCCommandUi::WrittenText(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/eabi/vcommandhandleru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,119 @@
+EXPORTS
+	_ZN11CVCRunnable4NewLE4TUidRK6TDesC8 @ 1 NONAME
+	_ZN11CVCRunnable4NewLER11RReadStream @ 2 NONAME
+	_ZN11CVCRunnable4NewLERK7TDesC16RK6TDesC8 @ 3 NONAME
+	_ZN11CVCRunnable4NewLERKS_ @ 4 NONAME
+	_ZN11CVCRunnableD0Ev @ 5 NONAME
+	_ZN11CVCRunnableD1Ev @ 6 NONAME
+	_ZN11CVCRunnableD2Ev @ 7 NONAME
+	_ZN12CVCCommandUi4NewLER11RReadStream @ 8 NONAME
+	_ZN12CVCCommandUi4NewLERK7TDesC16RK13CVCFolderInfoiS2_RK4TUidS2_i @ 9 NONAME
+	_ZN12CVCCommandUi4NewLERKS_ @ 10 NONAME
+	_ZN12CVCCommandUiD0Ev @ 11 NONAME
+	_ZN12CVCCommandUiD1Ev @ 12 NONAME
+	_ZN12CVCCommandUiD2Ev @ 13 NONAME
+	_ZN13CVCFolderInfo4NewLER11RReadStream @ 14 NONAME
+	_ZN13CVCFolderInfo4NewLERK7TDesC16S2_mjS2_ @ 15 NONAME
+	_ZN13CVCFolderInfo4NewLERKS_ @ 16 NONAME
+	_ZN13CVCFolderInfoD0Ev @ 17 NONAME
+	_ZN13CVCFolderInfoD1Ev @ 18 NONAME
+	_ZN13CVCFolderInfoD2Ev @ 19 NONAME
+	_ZN14CVCommandArray4NewLERK13RPointerArrayI9CVCommandE @ 20 NONAME
+	_ZN14CVCommandArrayD0Ev @ 21 NONAME
+	_ZN14CVCommandArrayD1Ev @ 22 NONAME
+	_ZN14CVCommandArrayD2Ev @ 23 NONAME
+	_ZN16CVCommandHandler11AddCommandLERK9CVCommand @ 24 NONAME
+	_ZN16CVCommandHandler12AddCommandsLERK13RPointerArrayI9CVCommandEi @ 25 NONAME
+	_ZN16CVCommandHandler13ListCommandsLEv @ 26 NONAME
+	_ZN16CVCommandHandler14RemoveCommandLERK9CVCommand @ 27 NONAME
+	_ZN16CVCommandHandler15RemoveCommandsLERK13RPointerArrayI9CVCommandEi @ 28 NONAME
+	_ZN16CVCommandHandler4NewLEP24MVCommandHandlerObserver @ 29 NONAME
+	_ZN16CVCommandHandlerD0Ev @ 30 NONAME
+	_ZN16CVCommandHandlerD1Ev @ 31 NONAME
+	_ZN16CVCommandHandlerD2Ev @ 32 NONAME
+	_ZN21CVCRecognitionManager4NewLEv @ 33 NONAME
+	_ZN21CVCRecognitionManagerD0Ev @ 34 NONAME
+	_ZN21CVCRecognitionManagerD1Ev @ 35 NONAME
+	_ZN21CVCRecognitionManagerD2Ev @ 36 NONAME
+	_ZN9CVCommand4NewLER11RReadStream @ 37 NONAME
+	_ZN9CVCommand4NewLERK7TDesC16RK11CVCRunnableRK12CVCCommandUi @ 38 NONAME
+	_ZN9CVCommand4NewLERKS_ @ 39 NONAME
+	_ZN9CVCommandD0Ev @ 40 NONAME
+	_ZN9CVCommandD1Ev @ 41 NONAME
+	_ZN9CVCommandD2Ev @ 42 NONAME
+	_ZNK11CVCRunnable12ExternalizeLER12RWriteStream @ 43 NONAME
+	_ZNK11CVCRunnable3UidEv @ 44 NONAME
+	_ZNK11CVCRunnable7ExeNameEv @ 45 NONAME
+	_ZNK11CVCRunnable8ExecuteLEv @ 46 NONAME
+	_ZNK11CVCRunnable9ArgumentsEv @ 47 NONAME
+	_ZNK11CVCRunnableeqERKS_ @ 48 NONAME
+	_ZNK12CVCCommandUi10FolderInfoEv @ 49 NONAME
+	_ZNK12CVCCommandUi10ModifiableEv @ 50 NONAME
+	_ZNK12CVCCommandUi11WrittenTextEv @ 51 NONAME
+	_ZNK12CVCCommandUi12ExternalizeLER12RWriteStream @ 52 NONAME
+	_ZNK12CVCCommandUi18ConfirmationNeededEv @ 53 NONAME
+	_ZNK12CVCCommandUi26EqualNonUserChangeableDataERKS_ @ 54 NONAME
+	_ZNK12CVCCommandUi6IconLCEv @ 55 NONAME
+	_ZNK12CVCCommandUi7IconUidEv @ 56 NONAME
+	_ZNK12CVCCommandUi7TooltipEv @ 57 NONAME
+	_ZNK12CVCCommandUi8UserTextEv @ 58 NONAME
+	_ZNK12CVCCommandUieqERKS_ @ 59 NONAME
+	_ZNK13CVCFolderInfo10ListedNameEv @ 60 NONAME
+	_ZNK13CVCFolderInfo11HelpTopicIdEv @ 61 NONAME
+	_ZNK13CVCFolderInfo12ExternalizeLER12RWriteStream @ 62 NONAME
+	_ZNK13CVCFolderInfo5TitleEv @ 63 NONAME
+	_ZNK13CVCFolderInfo6IconLCEv @ 64 NONAME
+	_ZNK13CVCFolderInfo8IconFileEv @ 65 NONAME
+	_ZNK13CVCFolderInfo9IconIndexEv @ 66 NONAME
+	_ZNK13CVCFolderInfoeqERKS_ @ 67 NONAME
+	_ZNK14CVCommandArray12PointerArrayEv @ 68 NONAME
+	_ZNK14CVCommandArray28ProduceTrainSetByRunnablesLCERK13RPointerArrayI9CVCommandE @ 69 NONAME
+	_ZNK14CVCommandArray2AtEi @ 70 NONAME
+	_ZNK14CVCommandArray30ProduceUntrainSetByRunnablesLCERK13RPointerArrayI9CVCommandE @ 71 NONAME
+	_ZNK14CVCommandArray5CountEv @ 72 NONAME
+	_ZNK14CVCommandArrayixEi @ 73 NONAME
+	_ZNK9CVCommand10SpokenTextEv @ 74 NONAME
+	_ZNK9CVCommand12ExternalizeLER12RWriteStream @ 75 NONAME
+	_ZNK9CVCommand15CancelPlaybackLERK16CVCommandHandler @ 76 NONAME
+	_ZNK9CVCommand15PlaySpokenTextLERK16CVCommandHandlerR20MNssPlayEventHandler @ 77 NONAME
+	_ZNK9CVCommand21AlternativeSpokenTextEv @ 78 NONAME
+	_ZNK9CVCommand26EqualNonUserChangeableDataERKS_ @ 79 NONAME
+	_ZNK9CVCommand26PlayAlternativeSpokenTextLERK16CVCommandHandlerR20MNssPlayEventHandler @ 80 NONAME
+	_ZNK9CVCommand8RunnableEv @ 81 NONAME
+	_ZNK9CVCommand9CommandUiEv @ 82 NONAME
+	_ZNK9CVCommandeqERKS_ @ 83 NONAME
+	_ZTI10CTagGetter @ 84 NONAME ; #<TI>#
+	_ZTI10CTagPlayer @ 85 NONAME ; #<TI>#
+	_ZTI11CTagNameSet @ 86 NONAME ; #<TI>#
+	_ZTI11CVCRunnable @ 87 NONAME ; #<TI>#
+	_ZTI12CAsyncWorker @ 88 NONAME ; #<TI>#
+	_ZTI12CVCCommandUi @ 89 NONAME ; #<TI>#
+	_ZTI13CVCFolderInfo @ 90 NONAME ; #<TI>#
+	_ZTI14CVCommandArray @ 91 NONAME ; #<TI>#
+	_ZTI15CStoredVCommand @ 92 NONAME ; #<TI>#
+	_ZTI16CContextProvider @ 93 NONAME ; #<TI>#
+	_ZTI16CVCommandHandler @ 94 NONAME ; #<TI>#
+	_ZTI16CVCommandService @ 95 NONAME ; #<TI>#
+	_ZTI19CIntPropertyWatcher @ 96 NONAME ; #<TI>#
+	_ZTI21CVCRecognitionHandler @ 97 NONAME ; #<TI>#
+	_ZTI21CVCRecognitionManager @ 98 NONAME ; #<TI>#
+	_ZTI23TVCommandTagPtrArrayKey @ 99 NONAME ; #<TI>#
+	_ZTI9CVCommand @ 100 NONAME ; #<TI>#
+	_ZTV10CTagGetter @ 101 NONAME ; #<VT>#
+	_ZTV10CTagPlayer @ 102 NONAME ; #<VT>#
+	_ZTV11CTagNameSet @ 103 NONAME ; #<VT>#
+	_ZTV11CVCRunnable @ 104 NONAME ; #<VT>#
+	_ZTV12CAsyncWorker @ 105 NONAME ; #<VT>#
+	_ZTV12CVCCommandUi @ 106 NONAME ; #<VT>#
+	_ZTV13CVCFolderInfo @ 107 NONAME ; #<VT>#
+	_ZTV14CVCommandArray @ 108 NONAME ; #<VT>#
+	_ZTV15CStoredVCommand @ 109 NONAME ; #<VT>#
+	_ZTV16CContextProvider @ 110 NONAME ; #<VT>#
+	_ZTV16CVCommandHandler @ 111 NONAME ; #<VT>#
+	_ZTV16CVCommandService @ 112 NONAME ; #<VT>#
+	_ZTV19CIntPropertyWatcher @ 113 NONAME ; #<VT>#
+	_ZTV21CVCRecognitionHandler @ 114 NONAME ; #<VT>#
+	_ZTV21CVCRecognitionManager @ 115 NONAME ; #<VT>#
+	_ZTV23TVCommandTagPtrArrayKey @ 116 NONAME ; #<VT>#
+	_ZTV9CVCommand @ 117 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for the VCommandHandler modules.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+vcommandhandler.mmp
+
+PRJ_TESTEXPORTS
+//#include "testexports.inc"
+
+PRJ_TESTMMPFILES
+//#include "testmmpfiles.inc"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/group/testexports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* ==============================================================================
+*        %name: testexports.inc %
+*     %version: 7 %
+*      Part of: SRSF / VCommandHandler
+*  Description: List of test exports for the VCommandHandler modules.
+*               To be included into bld.infs
+*
+*  Copyright c 2006 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+* ==============================================================================
+*/
+
+// Global test exports
+//..\internal\tsrc\vcommandhandler_tests.cfg \epoc32\winscw\c\TestFramework\vcommandhandler_tests.cfg
+//..\internal\tsrc\vcommandhandler_tests.cfg \epoc32\wins\c\TestFramework\vcommandhandler_tests.cfg
+//..\internal\tsrc\vcommandhandler_tests.cfg \epoc32\data\c\TestFramework\vcommandhandler_tests.cfg
+
+//..\internal\tsrc\testframework.ini \epoc32\data\c\TestFramework\testframework.ini
+//..\internal\tsrc\testframework.ini \epoc32\wins\c\TestFramework\testframework.ini
+//..\internal\tsrc\testframework.ini \epoc32\winscw\c\TestFramework\testframework.ini
+
+
+// Exports of the test projects
+#include "../internal/tsrc/VcsPrimTest/group/exports.inc"
+#include "../internal/tsrc/VcsUnitTest/group/exports.inc"
+#include "../internal/tsrc/VCommandVasTest/group/exports.inc"
+#include "../internal/tsrc/VCommandHandlerTest/group/exports.inc"
+#include "../internal/tsrc/TagCommandConverterTest/group/exports.inc"
+#include "../internal/tsrc/MultiUseTest/group/exports.inc"
+#include "../internal/tsrc/RecogHandlerTest/group/exports.inc"
+#include "../internal/tsrc/IntPropertyWatcherTest/group/exports.inc"
+#include "../internal/tsrc/VcsMultiThreadingTest/group/exports.inc"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/group/testmmpfiles.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* ==============================================================================
+*        %name: testmmpfiles.inc %
+*     %version: 6 %
+*      Part of: SRSF / VCommandHandler
+*  Description: List of test mmp files for the VCommandHandler modules.
+*               To be included into bld.infs
+*
+*  Copyright c 2006 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+* ==============================================================================
+*/
+
+..\internal\tsrc\VcsPrimTest\group\VcsPrimTest.mmp
+..\internal\tsrc\VcsUnitTest\group\VcsUnitTest.mmp
+..\internal\tsrc\VCommandVasTest\group\VCommandVasTest.mmp
+..\internal\tsrc\VCommandHandlerTest\group\VCommandHandlerTest.mmp
+..\internal\tsrc\TagCommandConverterTest\group\TagCommandConverterTest.mmp
+..\internal\tsrc\MultiUseTest\group\MultiUseTest.mmp
+..\internal\tsrc\IntPropertyWatcherTest\group\IntPropertyWatcherTest.mmp
+..\internal\tsrc\VcsMultiThreadingTest\group\VcsMultiThreadingTest.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/group/vcommandhandler.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for the VCommand API implementation
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET        vcommandhandler.dll
+TARGETTYPE    dll
+
+UID           0x1000008d 0x10281CA9 // UID: 271064233
+VENDORID      VID_DEFAULT
+
+CAPABILITY    CAP_GENERAL_DLL
+
+SOURCEPATH    ../src
+SOURCE        vcommandhandler.cpp
+SOURCE        vcommandservices.cpp
+SOURCE        asyncworker.cpp
+SOURCE        contextprovider.cpp
+SOURCE        tagnameset.cpp
+SOURCE        taggetter.cpp
+SOURCE        vcommandui.cpp
+SOURCE        vcommandrunnable.cpp
+SOURCE        vcommand.cpp
+SOURCE        vcommandarray.cpp
+SOURCE        storedvcommand.cpp
+SOURCE        desarrayconverter.cpp
+SOURCE        vcommandrecoghandler.cpp
+SOURCE        vcommandrecogmanager.cpp
+SOURCE	      tagcommandconverter.cpp
+SOURCE	      tagplayer.cpp
+SOURCE	      vcfolderinfo.cpp
+SOURCE	      intpropertywatcher.cpp
+
+USERINCLUDE   ../inc
+// Global project includes
+USERINCLUDE   ../../inc
+USERINCLUDE   ../../rubydebug
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+// for CleanupResetAndDestroy declared in mmfcontrollerpluginresolver.h
+SYSTEMINCLUDE /epoc32/include/mmf/common
+
+LIBRARY     euser.lib
+LIBRARY     estor.lib
+LIBRARY     nssvasapi.lib
+LIBRARY	    apgrfx.lib		// RApaLsSession
+LIBRARY	    apparc.lib 		// CApaCommandLine, TApaAppInfo
+LIBRARY	    egul.lib
+LIBRARY	    aknskins.lib
+LIBRARY	    aknskinsrv.lib 
+LIBRARY	    aknswallpaperutils.lib 
+LIBRARY     cone.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/asyncworker.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class that is able to pause the execution until the 
+*                asynchronous call resumes it. Knows how to leave the
+*                resumed function with the error code supplied by the
+*                resuming asynchronous call
+*
+*/
+
+
+ 
+#ifndef ASYNCWORKER_H
+#define ASYNCWORKER_H
+
+class CActiveSchedulerWait;
+
+/**
+ * Is able to pause the execution until the 
+ * asynchronous call resumes it. Knows how to leave the
+ * resumed function with the error code supplied by the
+ * resuming asynchronous call
+ */
+class CAsyncWorker : public CBase 
+	{
+	public:
+		CAsyncWorker* NewLC();
+		CAsyncWorker* NewL();
+		virtual ~CAsyncWorker();
+		
+	public:
+		/**
+        * Pauses the execution until StopAsyncWaitingL is called
+        * Leaves if StopAsyncWaitingL is called with the negative error code
+        * @leave KErrNotReady if another waiting is still in progress
+        * @leave Leaves with the error code passed to StopAsyncWaitingL
+        */
+        void WaitForAsyncCallbackL();
+        
+        /** 
+        * Resumes the process paused by WaitForAsyncCallbackL
+        * @param aErr Result code to pass to the 
+        *        WaitForAsyncCallbackL error handling. Note, that 
+        *        WaitForAsyncCallbackL leaves only if aErr is negative
+        * @return KErrNotReady if no waiting is in progress. Otherwise KErrNone
+        */
+        TInt StopAsyncWaiting( TInt aErr );
+        
+        /**
+		* Same as StopAsyncWaiting, but panics with AWRK <error code> instead 
+		* of returning the error code
+		* @see StopAsyncWaiting
+		*/
+        void StopAsyncWaitingOrPanic( TInt aErr );
+        
+	private:
+		// To pass the error code from the async callback
+		TInt	iErr;
+		
+		// Performs the waiting
+		CActiveSchedulerWait* iWaiter;
+	};
+
+#endif // ASYNCWORKER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/contextprovider.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility object to provide a VAS context
+*
+*/
+
+
+ 
+#ifndef CONTEXTPROVIDER_H
+#define CONTEXTPROVIDER_H
+
+#include "asyncworker.h"
+
+#include <nssvasmgetcontextclient.h>
+#include <nssvasmsavecontextclient.h>
+#include <nssvascvasdbmgr.h>
+
+class MNssContext;
+class MNssContextMgr;
+
+/**
+* Provides the access to the VAS context
+*/
+class CContextProvider : public CAsyncWorker, public MNssGetContextClient,
+                         public MNssSaveContextClient
+	{
+	public:
+		static CContextProvider* NewL( CNssVASDBMgr& aVasDbManager );
+		static CContextProvider* NewLC( CNssVASDBMgr& aVasDbManager );
+		~CContextProvider();
+		
+		/**
+		* Returns the VCommand VAS context. If it doesn't exists,
+		* it is being created. client is responsible for the context deletion
+		* 
+		*
+		* @todo If support for different contexts is needed, 
+		* 1) Rename the method into GetContextLC;
+		* 2) Add the optional
+		*    argument "const TDesC& aContextName = KVoiceCommandContext"
+		*/
+		MNssContext* GetVCommandContextLC();
+		               
+    public:
+    
+    // From MNssGetContextClient
+        /**
+        * Callback to indicate GetContext successed.
+        * client has to delete the context after using the context.
+        * @since 2.0
+        * @param aContext
+        * @param aErrorCode KErrNone if getting of context was successfull
+        * @return None
+        */
+        virtual void GetContextCompleted( MNssContext* aContext,
+                                          TInt aErrorCode );
+
+        /**
+        * Callback to indicate GetContext successed.
+        * client has to ResetAndDestroy() after using the list.
+        * @since 2.0
+        * @param aContextList A list of contexts.
+        * @param aErrorCode KErrNone if getting of context list was successfull
+        * @return None
+        */
+        virtual void GetContextListCompleted(
+            MNssContextListArray *aContextList, TInt aErrorCode );
+        
+	public:        
+    
+    // From MNssSaveContextClient
+       /**
+       * Callback to indicate SaveContext successed.
+       * @since 2.0
+       * @param aErrorCode KErrNone if saving of context was successfull
+       * @return None
+       */
+       virtual void SaveContextCompleted( TInt aErrorCode );
+       
+    private:
+		/**
+        * Creates VCommand context. To be called during the GetVCommandContextLC
+        * sequence
+        */
+        MNssContext* CreateVCommandContextLC();
+
+   	
+    private:
+    	// VAS context manager. Not owned
+    	MNssContextMgr*             iContextManager;
+    	
+    	// Temporary variable to be used with async callbacks 
+        MNssContext*                iVasContext;
+        
+        // Extra waiter for the SaveContext operation
+        CAsyncWorker* iSaveContextWaiter;
+	};
+
+
+#endif // CONTEXTPROVIDER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/desarrayconverter.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A utility class for converting arrays to descriptors and vise versa
+*
+*/
+
+
+ 
+#ifndef DESARRAYCONVERTER_H
+#define DESARRAYCONVERTER_H
+
+#include <nssvasmrrd.h> // NssRRDText
+
+/**
+* A utility class for converting arrays to descriptors and vise versa
+*/
+class CDesArrayConverter : public CBase
+	{
+	public:
+		/**
+        * Converts the stream data into the array of fixed size descriptors
+        * @param aSource 8-bit descriptor to convert
+        */
+		static CArrayFixFlat<NssRRDText>* DesC8ToArrayLC( const TDesC8& aSource );
+    	
+    	/**
+        * Constructs DesC8 descriptor from the given array slice. Almost a 
+        * counterpart of the DesC8ToArrayLC
+        * @param aArray Array to convert
+        * @param aStartIndex First element to convert. Zero-based
+        * @param aCount number of elements to convert. 
+        * @leave KErrArgument if aStartIndex or aCount are out of the array bounds
+        */
+    	static TDesC8* ArrayToDesC8LC( const CArrayFixFlat<NssRRDText>& aArray, 
+    											TInt aStartIndex, TInt aCount );
+	};
+
+#endif // DESARRAYCONVERTER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/intpropertywatcher.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches for the integer P&S property and notifies the observer
+*                about the changes
+*
+*/
+
+
+
+#ifndef INTPROPERTYWATCHER_H
+#define INTPROPERTYWATCHER_H
+
+#include <e32property.h>
+#include <e32base.h>
+
+/**
+ * Interface for those who want to be notified about the property change
+ */
+class MIntChangeNotifiable
+    {
+    public:
+        virtual void IntValueChanged(TInt aNewValue) = 0;
+    };
+
+/**
+ * After the creation watches for the given Publish & Subscribe property
+ * changes and notifies the observer about the changes
+ */
+class CIntPropertyWatcher : public CActive
+    {
+    public:
+        static CIntPropertyWatcher* NewL( const TUid aCategory, TUint aKey, 
+                                        MIntChangeNotifiable& aObserver );
+        
+        virtual ~CIntPropertyWatcher();
+    
+    private:
+    
+        CIntPropertyWatcher( MIntChangeNotifiable& aObserver );
+        
+        void ConstructL( const TUid aCategory, TUint aKey );
+        
+        void RunL();
+        
+        void DoCancel();
+        
+    private:
+    
+        RProperty iProperty;
+        
+        MIntChangeNotifiable& iObserver;
+        
+    };
+
+    
+#endif // INPROPERTYWATCHER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/tagcommandconverter.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Converts VCommands into tags and vise veraa
+*
+*/
+
+
+ 
+#ifndef TAGCOMMANDCONVERTER_H
+#define TAGCOMMANDCONVERTER_H
+
+#include <nssvasmtag.h>
+#include <nssvasmtagmgr.h>
+#include "vcommandinternalapi.h"
+
+class CVCommand;
+
+/**
+* A VCommand can be translated in no more, than KMaxTagsPerCommand tags
+*/
+const TInt KMaxTagsPerCommand = 2;
+
+/** Index of the voice command id in the voice tag's rrd int array */
+const TInt KCommandIdRrdIntIndex = 0;
+
+
+
+/**
+* Converts VCommands into tags and vise veraa
+*/
+class CTagCommandConverter : public CBase
+	{
+	public:
+		/**
+		* Converts given tags to the VCommand. These tags must have been generated
+		* from a single VCommand (via CommandToTagsLC2 ) 
+		* @leave KErrOverflow if given array has more, than two elements
+		* @leave KErrUnderflow if given array is empty
+		* @leave KErrArgument if given tags correspond to the different VCommands
+		*/
+		static CStoredVCommand* TagsToCommandLC( const CArrayPtr<MNssTag>& aTags );
+		
+		/**
+		* Constructs new VAS tags from a command and a context. 
+		* Does not save to VAS, just creates. At the end of this function two
+		* items are pushed to the cleanup stack. The first PopAndDestroy will
+		* ResetAndDestroy the generated tags, the second one will delete the
+		* CArrayPtr itself
+		*
+		* @return array of one or two VAS tags. Two tags are created if a given 
+		*         command has a UserText set. The created tags bear the identical
+		*         data
+		*/
+		static CArrayPtr<MNssTag>* CommandToTagsLC2( const CVCommand& aCommand, 
+						const MNssContext& aContext, MNssTagMgr& aTagMgr );
+		
+		/**
+		* Converts given tag to the CStoredVCommand
+		* @leave KErrTotalLossOfPrecision if the aTag's intArray is empty
+		*/
+		static CStoredVCommand* TagToCommandLC( const MNssTag& aTag );
+		
+		/**
+		* Constructs a new VAS tag from a command and a context. 
+		* Does not save to VAS, just creates. Created tag stores the streamed
+		* VCommand in its RRDText array. The tag's rrd int array of the created 
+		* tag is empty
+		*/
+		static MNssTag* CommandToTagLC( const CVCommand& aCommand, 
+						const MNssContext& aContext, MNssTagMgr& aTagMgr );
+	};
+
+#endif // TAGCOMMANDCONVERTER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/taggetter.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Fetches the VAS tags from VAS DB
+*
+*/
+
+
+ 
+#ifndef TAGGETTER_H
+#define TAGGETTER_H
+
+#include "asyncworker.h"
+#include <nssvasmgettagclient.h>
+#include <nssvasmgettagclient.h>
+#include <nssvasmcontext.h>
+#include <nssvasmtagmgr.h>
+
+/*
+* Fetches the context voice tags from VAS. Makes the asynchronous process
+* look like synchronous to the clients
+*/
+class CTagGetter : public CAsyncWorker, public MNssGetTagClient
+	{
+	public:
+		static CTagGetter* NewL();
+		static CTagGetter* NewLC();
+		
+    	/**
+    	* Retrieves the list of tags for a given context. Synchronous.
+    	* Leaves two objects on the cleanup stack!
+    	* First PopAndDestroy will ResetAndDestroy content
+    	* Second one will destroy the MNssTagListArray itself
+    	*/
+        MNssTagListArray* GetTagListLC2( MNssTagMgr& aTagManager, const MNssContext& aContext );
+        
+        /**
+    	* Retrieves the list of tags for a given context and vcommand id. Synchronous.
+    	* Leaves two objects on the cleanup stack!
+    	* First PopAndDestroy will ResetAndDestroy content
+    	* Second one will destroy the MNssTagListArray itself
+    	*/
+        MNssTagListArray* GetTagListLC2( MNssTagMgr& aTagManager, const MNssContext& aContext, 
+                                         TInt aCommandId );
+        
+        // From  MNssGetTagClient
+           
+        /**
+        * Callback to indicate GetTag successed.
+        * client has to delete the tag list
+        * @param aTagList 
+        * @param aErrorCode KErrNone if getting of tag list was successfull
+        * @return None
+        */
+        virtual void GetTagListCompleted( MNssTagListArray* aTagList,
+                                          TInt aErrorCode );
+    
+    private:
+    
+        /** 
+        * After one of the GetTagListLC2 functions requested a list of 
+        * tags from VAS, they call this function to wait for the query
+        * result and process it 
+        * Leaves two objects on the cleanup stack!
+    	* First PopAndDestroy will ResetAndDestroy content
+    	* Second one will destroy the MNssTagListArray itself
+    	* @param aNssErr Error code from the GetTagList request
+    	*/
+        MNssTagListArray* WaitAndFormTagListLC2( TInt aNssErr );
+        
+    private:
+        // Temporary holder for the tag list. Is used with async callbacks
+        MNssTagListArray*           iTagList;
+		
+	};
+
+#endif // TAGGETTER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/tagnameset.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Array of tags and corresponding spoken texts
+*
+*/
+
+
+ 
+#ifndef TAGNAMESET_H
+#define TAGNAMESET_H
+
+#include "asyncworker.h"
+#include <nssvasmtraintexteventhandler.h>
+#include <nssvasmsavetagclient.h>
+#include <nssvasmdeletetagclient.h>
+
+class MNssTagMgr;
+class MNssTag;
+class CNssTrainingParameters;
+
+/** 
+* Array of tags and corresponding spoken texts
+*/        
+class CTagNameSet : public CAsyncWorker, public MNssTrainTextEventHandler, 
+                    public MNssSaveTagClient, public MNssDeleteTagClient
+    {
+    public:
+        static CTagNameSet* NewLC();
+        
+        ~CTagNameSet();
+
+        /**
+        * Adds a tag-text pair to be trained
+        * @param aTag tag to be trained and saved. This objects takes ownership
+        *        on the aTag
+        * @param aTrainingText text to be recognized. This object doesn't
+        *        take ownership on aTrainingText, but makes an own copy
+        */
+        void AppendL( const MNssTag* aTag, const TDesC& aTrainingText = KNullDesC );
+        
+        /**
+        * Train and save to VAS all the stored tags. It is not specified what happens
+        * to VAS if this method leaves
+        * @param aParams
+        * @param aTagMgr
+        * @param aIgnoreErrors If ETrue, doesn't fail the whole operation if some
+        *        individual trainings/savings failed. Trains and saves as much as
+        *        possible
+        */
+        void TrainAndSaveL( const CNssTrainingParameters& aParams, 
+                            MNssTagMgr& aTagMgr, TBool aIgnoreErrors = EFalse);
+
+        /**
+        * Remove all the stored tags from VAS. It is not specified what happens
+        * to VAS if this method leaves
+        * @param aTagMgr
+        * @param aIgnoreErrors If ETrue, doesn't fail the whole operation if some
+        *        individual removals failed. Removes as many tags as
+        *        possible
+        */                            
+        void UntrainL( MNssTagMgr& aTagMgr, TBool aIgnoreErrors = EFalse );
+        
+        /**
+        * @return Number of tag-name pairs stored
+        */
+        TInt Count() const;
+        
+        /**
+        * @param aIndex must be >= 0 and < Count()
+        * @return Voice tag at the given position
+        * @panic KErrArgument if aIndex is out of bounds
+        */
+        const MNssTag& TagAt( TInt aIndex ) const;
+        
+        /**
+        * @param aIndex must be >= 0 and < Count()
+        * @return Recognition text at the given position
+        * @panic KErrArgument if aIndex is out of bounds
+        */
+        const TDesC& TextAt( TInt aIndex ) const;
+        
+    public:
+      
+        // From MNssTrainTextEventHandler
+        
+        /**
+	    * Train Complete Event - Voice tag training completed
+	    * @param aErrorCode KErrNone if training was successfull
+	    */       
+        void HandleTrainComplete( TInt aErrorCode );
+  
+  public:
+        
+        // From MNssSaveTagClient
+       
+        /**
+        * Callback to indicate that SaveTag sequence has been completed
+        * @param aErrorCode KErrNone if saving of tag was successfull
+        */
+        void SaveTagCompleted( TInt aErrorCode );
+       
+        // From MNssDeleteTagClient
+	       
+	    /**
+	    * Callback to indicate a tag was deleted successfully.
+	    * @param aErrorCode KErrNone if deletion of tag was successfull
+	    */
+	    virtual void DeleteTagCompleted( TInt aErrorCode );
+
+
+  private:
+        
+        /**
+        * Train all the stored tag-name pairs. Synchronous
+        */
+        void TrainTagsL( const CNssTrainingParameters& aParams );
+
+  		/**
+        * Trains the voice tag. Asynchronous
+        * @leave VAS error codes
+        */
+        void TrainTagL( const MNssTag& aTag, 
+        		const CNssTrainingParameters& aParams, const TDesC& aSpokenText );
+
+        /**
+        * Saves to VAS all the stored voice tags. Synchronous
+        * All the voice tags must be previously trained
+        */        		
+        void SaveTagsL( MNssTagMgr& aTagManager );
+
+        /**
+        * Saves the trained voice tag to VAS. 
+        */
+        void SaveTagL( MNssTagMgr& aTagManager, const MNssTag& aTag );
+        
+  		/**
+        * Deletes the voice tag from VAS. Asynchronous
+        * @leave VAS error codes
+        */
+        void DeleteTagL( MNssTagMgr& aTagManager, MNssTag& aTag );
+        
+        /**
+        * Handles the common part of the callback processing
+        * Decrements the number of still expected callbacks and
+        * handles the errors according to aIgnoreErrors from the 
+        * public methods
+        */
+        void ProcessCallback( TInt aErrorCode );
+        
+        /**
+        * Sets the number of callbacks to expect
+        */
+        void SetCallbacksExpected ( TUint aCallbacksExpected );
+        
+        /**
+        * Decreases the number of callbacks to expect by one
+        * @return Number of callbacks expected after decreasing
+        */
+        TUint DecreaseCallbacksExpected();
+        
+        /**
+        * Waits until all the expected callbacks are received
+        * If no callbacks are expected returns immediately
+        * @leave @see CAsyncWorker::WaitForAsyncCallbackL
+        */
+        void WaitUntilOperationsAreCompletedL();
+
+    private:
+        RPointerArray<MNssTag> iTags;
+        RPointerArray<HBufC> iTexts;
+        
+        // Counter to count how many 
+        // callbacks are still expected
+        TUint iCallbacksExpected;
+        
+        // Ignore individual train/save/remove errors
+        TBool iIgnoreErrors;
+    };
+
+#endif // TAGNAMESET_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/tagplayer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Plays back voice commands
+*
+*/
+
+
+ 
+#ifndef TAGPLAYER_H
+#define TAGPLAYER_H
+
+#include <nssvasmplayeventhandler.h>
+#include <nssvasmtag.h>
+#include <nssvasmgettagclient.h>  // for MNssTagListArray
+#include "vcommandinternalapi.h"
+
+/**
+* Plays back the voice commad
+*/
+class CTagPlayer : public CBase, public MNssPlayEventHandler
+    {
+    public:
+        
+        static CTagPlayer* NewL();
+        
+        ~CTagPlayer();
+        
+        /**
+        * Attempts to play back the text expected to be recognized. 
+        * This object takes ownership on the aTag and will delete it upon
+        * the playback completion.
+        * This function is asynchronous
+        *
+        * @param aTag Tag to play. Will be deleted (not from VAS) upon the 
+        *        playback completion
+        * @param aPlayEventHandler Entity that handles the playback callbacks
+        * @see NssVasMPlayEventHandler.h
+        *
+        * @leave KErrBadHandle if the current command has not been retrieved 
+        *        from CVCommandHandler (i.e. was not trained for recognition)
+        * @leave KErrNotFound if this command cannot be found in aHandler
+        * @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasUnexpectedRequest
+        * @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInUse
+        * @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInvalidParameter
+        * @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                             EVasPlayFailed
+        */
+        virtual void PlayTagL( MNssTag* aTag, MNssPlayEventHandler& aPlayEventHandler );
+        
+        /**
+        * Cancels playback. No PlayStarted/PlayComplete after it
+        *
+        * @leave KErrNotReady if playback has never been started
+        */                                   
+        virtual void CancelPlaybackL();
+    
+        // From MNsPlayEventHandler
+
+        /**
+        * The HandlePlayStarted method is a virtual method implemented by the
+        * client and is called when play is started
+        * @param aDuration - the duration of the utterance data
+        */       
+        virtual void HandlePlayStarted( TTimeIntervalMicroSeconds32 aDuration );
+
+        /**
+        * The HandlePlayComplete method is a virtual method implemented by the
+        * client and is called when play is completed
+        * @param aErrorCode EVasErrorNone if playing was successfull
+        */       
+        virtual void HandlePlayComplete( TNssPlayResult aErrorCode );        
+        
+    private:
+        // Playback is asynchronous function. 
+        // This variable is used to hold the tag being played back
+        MNssTag*                    iPlaybackTag;
+        
+        // Playback is asynchronous function. 
+        // This variable is used to hold the external play event
+        // handler
+        MNssPlayEventHandler*       iPlayEventHandler;
+
+    };
+
+#endif // TAGPLAYER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/vcommandinternalapi.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,246 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice command service interfaces, that are private for the
+*              : vcommand API implementation
+*
+*/
+
+
+
+#ifndef VCOMMANDINTERNALAPI_H
+#define VCOMMANDINTERNALAPI_H
+
+#include <e32def.h>
+#include <e32cmn.h>
+#include <s32strm.h>
+#include <vcommandapi.h>
+
+// context for voice commands tags
+_LIT( KVoiceCommandContext, "COMMAND" );	
+    
+/**
+* VCommand with a link to the VAS. This link is a command id
+* Stored VCommand can be played back
+*/
+class CStoredVCommand : public CVCommand
+    {
+    private:
+        // suppress inherited constructors by making them private
+        /**
+        * Factory function. Create a const snapshop of exe-ui-vastext collection
+        * @param aText Text to be trained by VAS. Can be of any length, however
+        *        only first KNssVasDbTagName characters will be trained by VAS
+        * @see KNssVasDbTagName in nssvasdbkonsts.h
+        * @param aRunnable Executable to be fired when the command is recognized. 
+        *        VCommand takes the ownership on the aRunnable
+        * @param aUi visible strings to be displayed in VC App. VCommand takes 
+        *        the ownership on the aUi
+        */
+        static CVCommand* NewL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                                         const CVCCommandUi& aUi );
+        
+		/** 
+        * Internalizes the command from stream 
+        * @leave KErrNotSupported if the stream data format is unsupported
+        *        e.g. if it has been written by newer implementation
+        */
+        static CVCommand* NewL( RReadStream &aStream );
+        
+    public:        
+        // constructors with the commandId
+        /**
+        * Factory function. Create a const snapshop of exe-ui-vastext collection
+        * @param aText Text to be trained by VAS. Can be of any length, however
+        *        only first KNssVasDbTagName characters will be trained by VAS
+        * @see KNssVasDbTagName in nssvasdbkonsts.h
+        * @param aRunnable Executable to be fired when the command is recognized. 
+        *        VCommand takes the ownership on the aRunnable
+        * @param aUi visible strings to be displayed in VC App. VCommand takes 
+        *        the ownership on the aUi
+        */
+        static CStoredVCommand* NewL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                                         const CVCCommandUi& aUi, TInt aCommandId );
+        
+		/** 
+        * Internalizes the command from stream 
+        * @leave KErrNotSupported if the stream data format is unsupported
+        *        e.g. if it has been written by newer implementation
+        */
+        static CStoredVCommand* NewL( RReadStream &aStream, TInt aCommandId );
+        
+        /**
+        * @return CommandId
+        */
+        TInt CommandId() const;
+        
+        /**
+        * Attempts to play back the text expected to be recognized. 
+        * To be playable command has to be added to CVCommandHandler AND
+        * then retrieved back
+        *
+        * @param aHandler CVCommandHandler where the command is stored
+        * @todo Consider storing link to CVCommandHandler within the CStoredVCommand
+        *       Pros: No clumsy aHandler argument for the playback
+        *       Pros: No need to remember in which handler the command is stored
+        *             and why specifying storage is needed during the playback
+        *       Cons: In case of internal link the linked handler should still
+        *             exist. It cannot be e.g. destroyed and recreated later even
+        *             if the latter one is using the same VAS
+        *
+        * @param aPlayEventHandler Entity that handles the playback callbacks
+        * @see NssVasMPlayEventHandler.h
+        *
+        * @leave KErrBadHandle if the current command has not been retrieved 
+        *        from CVCommandHandler (i.e. was not trained for recognition)
+        * @leave KErrNotFound if this command cannot be found in aHandler
+        * @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasUnexpectedRequest
+        * @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInUse
+        * @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInvalidParameter
+        * @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                             EVasPlayFailed
+        */
+        void PlaySpokenTextL( const CVCommandHandler& aHandler, 
+                                     MNssPlayEventHandler& aPlayEventHandler ) const;
+        
+        /**
+        * Plays back the user-specified alternative spoken text. 
+        * Otherwise is identical to PlaySpokenTextL
+        * @see PlaySpokenTextL
+        * @leave KErrNotFound if this command cannot be found in aHandler of if 
+        *        it doesn't have a user-specified text
+        */                                      
+        void PlayAlternativeSpokenTextL( const CVCommandHandler& aHandler, 
+                                     MNssPlayEventHandler& aPlayEventHandler ) const;
+                                     
+        /**
+        * Cancels playback of a spoken or alternative spoken text
+        * To be playable command has to be added to CVCommandHandler AND
+        * then retrieved back. After this function neither HandlePlayStarted,
+        * nor HandlePlayComplete will be called
+        *
+        * @param aHandler CVCommandHandler where the command is stored
+        *
+        * @leave KErrBadHandle if the current command has not been retrieved 
+        *        from CVCommandHandler (i.e. was not trained for recognition)
+        * @leave KErrNotReady if playback has never been started
+        *
+        */                                   
+        void CancelPlaybackL( const CVCommandHandler& aHandler ) const;
+        
+    protected:
+    	/**
+    	* @see CVCommand::ConstructL
+    	*/ 
+        void ConstructL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                         const CVCCommandUi& aUi, TInt aCommandId );
+        /**
+        * @see CVCommand::ConstructL
+        */
+        void ConstructL( RReadStream& aStream, TInt aCommandId );
+        
+        /**
+        * Clone itself
+        * Is used for copying via NewL( CVCommand& aOriginal )
+        */
+        CVCommand* CloneL() const; 
+                
+    private:
+        TInt iCommandId;
+    };
+
+
+/**
+* Interface for storing, listing and removing voice commands to/from VAS
+*/
+class MVCService 
+    {
+    public:
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copy
+        * Duplicates can be added
+        * @todo should we check for duplicates and leave with KErrAlreadyExists?
+        */
+        virtual void AddCommandL( const CVCommand& aCommand ) = 0;
+        
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copy
+        * Duplicates can be added
+        * @todo Should we check for duplicates and leave with KErrAlreadyExists?
+        * @param aIgnoreErrors If ETrue, even if some commands fail to be trained,
+        *        handler adds all that are trainable
+        */
+        virtual void AddCommandsL( const RVCommandArray& aCommands, 
+                                   TBool aIgnoreErrors = EFalse ) = 0;
+        
+        /**
+        * Synchronous. Removes the command from the system
+        * @param aCommand Reference to the command to be removed. Existing commands are
+        *		 compared against aCommand. All the matches are removed from VAS
+        * @leave KErrNotFound No such command
+        */
+        virtual void RemoveCommandL( const CVCommand& aCommand ) = 0;
+
+        /**
+        * Synchronous. 
+        * @param aCommands Reference to the list of commands to be removed. Existing commands are
+        *		 compared against aCommands items. All the matches are removed from VAS
+        * @param aIgnoreErrors If ETrue, even if some commands fail to be removed,
+        *        handler will remove as many as possible
+        */
+        virtual void RemoveCommandsL( const RVCommandArray& aCommands, 
+                                      TBool aIgnoreErrors = EFalse ) = 0;
+
+        
+        /**
+        * Synchronous
+        * @return an array of the commands in the system
+        *         Ownership of the array is transfered to the client
+        *         The returned CVCommandArray contains copies of all the 
+        *         commands currently stored in this handler
+        */
+        virtual CVCommandArray* ListCommandsL() = 0;
+        
+        /**
+        * This method is not intended to be called directly. 
+        * Use CVCommand::PlaySpokenTextL instead
+        * @see CVCommand::PlaySpokenTextL
+        * @see CStoredVCommand::PlaySpokenTextL
+        */
+        virtual void PlaySpokenTextL( const CStoredVCommand& aCommand, 
+                                      MNssPlayEventHandler& aPlayEventHandler ) = 0;
+                                      
+        /**
+        * This method is not intended to be called directly. 
+        * Use CVCommand::PlayAlternativeSpokenTextL instead
+        * @see CVCommand::PlayAlternativeSpokenTextL 
+        * @see CStoredVCommand::PlayAlternativeSpokenTextL 
+        */
+        virtual void PlayAlternativeSpokenTextL( const CStoredVCommand& aCommand, 
+                                      MNssPlayEventHandler& aPlayEventHandler ) = 0;
+                                      
+        /**
+        * This method is not intended to be called directly. 
+        * Use CVCommand::CancelPlaybackL instead
+        * @see CVCommand::CancelPlaybackL
+        * @see CStoredVCommand::CancelPlaybackL
+        */
+        virtual void CancelPlaybackL( const CStoredVCommand& aCommand ) = 0;
+        
+        virtual ~MVCService() {};
+    };
+    
+#endif // VCOMMANDINTERNALAPI_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/vcommandrecoghandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Engine to perform the action corresponding to
+*                the recognized and selected command
+*
+*/
+
+
+ 
+#ifndef VCOMMANDRECOGHANDLER_H
+#define VCOMMANDRECOGHANDLER_H
+
+#include <nssvasmtagselecthandler.h>
+
+class CVCommand;
+
+/**
+* Manages the recognized command selection
+*/
+class CVCRecognitionHandler : public CBase, public MNssTagSelectHandler 
+	{
+	public:
+		/**
+		* Factory function
+		*/ 
+		static CVCRecognitionHandler* NewL();
+		
+	public:
+		// From MNssTagSelectHandler
+		/**
+	    * Handle Tag Select Event - Event indicating a voice tag has been selected.
+	    * @param aClientTag The voice tag which has been selected. This object is
+		*                   resonsible for deleting aClientTag.
+	    * @return void
+	    */
+		virtual void HandleTagSelect( MNssTag* aClientTag );
+		
+	private:
+		/** 
+		* Execute a VCommand stored in the voice tag
+		* @leave If aTag does not contain a VCommand according to 
+		*			CVCommand::NewL codes
+		*/ 
+		void HandleTagSelectL( const MNssTag& aTag );
+		
+	};
+
+#endif // VCOMMANDRECOGHANDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/vcommandrecogmanager.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constructs / destroyes the recognition selection handler
+*
+*/
+
+
+ 
+#ifndef VCOMMANDRECOGMANAGER_H
+#define VCOMMANDRECOGMANAGER_H
+
+class CVCRecognitionHandler;
+class CNssSelectNotificationBuilder;
+
+/**
+* Prepares the recognition selection handling facilities and destroys them.
+* In particular establishes and managed the connections to VAS
+*/
+class CVCRecognitionManager : public CBase 
+	{
+	public:
+		/** 
+		* Factory function
+		* @todo Remove comments for such a simple and standard methods?
+		*/ 
+		IMPORT_C static CVCRecognitionManager* NewL();
+		
+		/**
+		* Destructor
+		*/ 
+		IMPORT_C virtual ~CVCRecognitionManager();
+	
+	private:
+		void ConstructL();
+		
+	private:
+		// Selection handling logic
+		CVCRecognitionHandler*	iRecognitionHandler;
+		
+		// VAS counterpart
+		CNssSelectNotificationBuilder* iSelectNotificationBuilder;
+	};
+
+#endif // VCOMMANDRECOGMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/inc/vcommandservices.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,365 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Engine, that links the VCommand application to VAS
+*
+*/
+
+
+ 
+#ifndef VCOMMANDSERVICES_H
+#define VCOMMANDSERVICES_H
+
+#include <nssvasmrrd.h>
+#include <nssvasctrainingparameters.h>
+#include <vcommandapi.h>
+#include <nssvasmgettagclient.h>  // For MNssTagListArray
+#include <nssvasmplayeventhandler.h>
+#include "vcommandinternalapi.h"
+#include "intpropertywatcher.h"
+
+// Forward declarations
+class CNssVASDBMgr;
+class MNssContextMgr;
+class MNssTagMgr;
+class MNssTag;
+class CTagPlayer;
+
+/**
+* Key for sorting CArrayPtr<MNssTag> by the value of the
+* first element of the RRD IntArray
+*/
+class TVCommandTagPtrArrayKey : public TKeyArrayFix
+    {
+    public:
+        inline TVCommandTagPtrArrayKey( TKeyCmpNumeric aType)
+            :TKeyArrayFix( 0, aType ) {}
+            virtual TAny* At( TInt aIndex ) const;
+        };
+
+/**
+* Engine, that links the VCommand application to VAS
+* @todo isolate the MNssPlayEventHandler dependency
+*/
+class CVCommandService : public CBase, public MVCService, public MNssPlayEventHandler, 
+                         private MIntChangeNotifiable
+                        
+    {
+    public:
+        // Construction/destruction
+		/**
+		 * @param aObserver Listener to be notified whenever the VCommand set is changed
+         *	 by *another* instance of CVCommandHandler. I.e. lets the client know if
+         *	 his understanding of the VCommand set is up to date
+	     */
+        static CVCommandService* NewL( MVCommandHandlerObserver* aObserver = NULL );
+        
+        virtual ~CVCommandService();
+
+        // From the MVCService
+        
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copy
+        * Duplicates can be added
+        * @todo Should we check for duplicates and leave with KErrAlreadyExists?
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        */
+        void AddCommandL( const CVCommand& aCommand );
+        
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copy
+        * Duplicates can be added
+        * @todo Should we check for duplicates and leave with KErrAlreadyExists?
+        * @param aIgnoreErrors If ETrue, even if some commands fail to be trained,
+        *        handler adds all that are trainable
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        */
+        void AddCommandsL( const RVCommandArray& aCommands, TBool aIgnoreErrors = EFalse );
+        
+        /**
+        * Synchronous. Removes the command from the system
+        * @param aCommand Reference to the command to be removed. Existing commands are
+        *		 compared against aCommand. All the matches are removed from VAS
+        * @leave KErrNotFound No such command
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        */
+        void RemoveCommandL( const CVCommand& aCommand );
+        
+        /**
+        * Synchronous. 
+        * @param aCommands Reference to the list of commands to be removed. Existing commands are
+        *		 compared against aCommands items. All the matches are removed from VAS
+        * @param aIgnoreErrors If ETrue, even if some commands fail to be removed,
+        *        handler will remove as many as possible
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        */
+        void RemoveCommandsL( const RVCommandArray& aCommands, TBool aIgnoreErrors = EFalse );
+
+        /**
+        * Synchronous
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        * @return an array of the commands in the system
+        *         Ownership of the array is transfered to the client
+        *         The returned CVCommandArray contains copies of all the 
+        *         commands currently stored in this handler
+        */
+        CVCommandArray* ListCommandsL();
+        
+        /**
+        * Asynchronous
+        * Attempts to play back the text expected to be recognized. 
+        * To be playable command has to be added to CVCommandHandler AND
+        * then retrieved back. This function is asynchronous
+        *
+        * @param aPlayEventHandler Entity that handles the playback callbacks
+        * @see NssVasMPlayEventHandler.h
+        *
+        * @leave KErrBadHandle if the current command has not been retrieved 
+        *        from CVCommandHandler (i.e. was not trained for recognition)
+        * @leave KErrNotFound if this command cannot be found in aHandler
+        * @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasUnexpectedRequest
+        * @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInUse
+        * @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                              EVasInvalidParameter
+        * @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+        *                                             EVasPlayFailed
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        */
+        void PlaySpokenTextL( const CStoredVCommand& aCommand, 
+                                      MNssPlayEventHandler& aPlayEventHandler );
+        
+        /**
+        * Asynchronous
+        * Plays back the user-specified alternative spoken text. 
+        * Otherwise is identical to PlaySpokenTextL
+        * @see PlaySpokenTextL
+        * @leave KErrNotFound if this command cannot be found in aHandler of if 
+        *        it doesn't have a user-specified text
+        * @leave KErrLocked if there is an ongoing operation started by the same thread
+        */ 
+        void PlayAlternativeSpokenTextL( const CStoredVCommand& aCommand, 
+                                      MNssPlayEventHandler& aPlayEventHandler );
+        
+        /**
+        * This method is not intended to be called directly. 
+        * Use CVCommand::CancelPlaybackL instead
+        * @see CVCommand::CancelPlaybackL
+        * @see CStoredVCommand::CancelPlaybackL
+        */
+        void CancelPlaybackL( const CStoredVCommand& aCommand );
+        
+    public:
+    
+        // From MNssPlayEventHandler                                      
+        /**
+        * The HandlePlayStarted method is a virtual method implemented by the
+        * client and is called when play is started
+        * @param aDuration - the duration of the utterance data
+        */       
+        virtual void HandlePlayStarted( TTimeIntervalMicroSeconds32 aDuration );
+
+        /**
+        * The HandlePlayComplete method is a virtual method implemented by the
+        * client and is called when play is completed
+        * @param aErrorCode EVasErrorNone if playing was successfull
+        */       
+        virtual void HandlePlayComplete( TNssPlayResult aErrorCode );
+                                      
+    private:
+        CVCommandService( MVCommandHandlerObserver* aObserver );
+        
+        void ConstructL();
+        
+        /**
+        * Returns the VCommand context. Creates one on demand if none exists yet
+        * @return VCommand context. Ownership is transfered to the client
+        */
+        MNssContext* GetVCommandContextLC() const;
+        
+        /**
+        * Constructs a set of new VAS tags from a command and a context. 
+        * Does not save to VAS, just creates. Ownership on the created tag is 
+        * passed to the client
+        */
+        CArrayPtr<MNssTag>* CreateTagsLC2( const CVCommand& aCommand, 
+                                           const MNssContext& aContext );
+        
+        /**
+        * Constructs training related parameters. Like language to be used
+        * @leave negated TNssSpeechItemResult
+        * @todo Is it ok to mix system-wide codes with the TNssSpeechItemResult codes
+        */
+        CNssTrainingParameters* ConstructTrainingParametersLC() const;
+
+        /**
+		* Retrieves the list of tags for a given context. Synchronous.
+		* Leaves two objects on the cleanup stack!
+		* First PopAndDestroy will ResetAndDestroy content
+		* Second one will destroy the MNsstagListArray itself
+		*/
+        MNssTagListArray* GetTagListLC2( const MNssContext& aContext ) const;
+        
+        /**
+		* Retrieves the list of tags for a given context and voice command id. 
+		* Synchronous. Leaves two objects on the cleanup stack!
+		* First PopAndDestroy will ResetAndDestroy content
+		* Second one will destroy the MNsstagListArray itself
+		*/
+        MNssTagListArray* GetTagListLC2( const MNssContext& aContext, TInt aCommandId ) const;
+        
+        /**
+        * Resets iCommands and fills them with the commands from VAS
+        */
+        void RefreshCommandListL();
+        
+        /**
+        * Marks the iCommands as an invalid reflection of the VAS content.
+        * To make iCommands reflect the real VAS content a call to 
+        * RefreshCommandsL is needed
+        */
+        void InvalidateCacheL();
+        
+        /**
+        * Marks the iCommands as the valid reflection of the VAS content.
+        */
+        void MarkCacheValidL();
+        
+        /**
+        * Tells if the iCommands reflect the content of the VAS DB correctly
+        * @return ETrue if the cache is valid, EFalse otherwise
+        */
+        TBool IsCacheValidL();
+        
+        /**
+        * Generates new command id to be used for identifying voice tags, that
+        * belong to the same VCommand
+        */
+        TInt NewCommandIdL();
+        
+        /** 
+        * Sets the given aId as a VCommand id for all the tags in the given list
+        * This id is set as a first RRD int element of all the given MNssTags.
+        * If the RRD int array has no elements yet, one element is added
+        */
+        void SetVCommandIdL( CArrayPtr<MNssTag>& aTags, TInt aId ) const;
+        
+        /**
+        * Searches vcommand tags for the tag, that corresponds to the given
+        * commandId and is trained against the given text
+        * @param aCommandId Command id to search for
+        * @param aText
+        * @return ANY of the voice tags corresponding to the given aCommandId
+        *         and aText. Typically there will be one such tag only. However,
+        *         if there are several it is not specified which one will be 
+        *         returned
+        * @return NULL if no satisfying tag is found
+        */
+        MNssTag* TagByCommandIdTextL( TInt aCommandId, const TDesC& aText );
+        
+        /**
+        * Synchronous. Service doesn't take the ownership, but makes an own copy
+        * Duplicates can be added
+        * Is not the atomic operation
+        * @see AddCommandsL
+        */
+        void DoAddCommandsL( const RVCommandArray& aCommands, 
+                             TBool aIgnoreErrors = EFalse );
+
+		/**
+		 * Synchronous
+		 * @see RemoveCommandsL
+		 */                             
+        void DoRemoveCommandsL( const RVCommandArray& aCommands,
+        						TBool aIgnoreErrors = EFalse );
+        
+        /**
+        * Starts the section of the code, that can be simultaneously executed
+        * only by a single instance of this class. Other instances have to wait
+        * Same as starting the Java "synchronized" method. Puts the function
+        * EndAtomicOperation to cleanup stack to make the use leave safe. Subsequent
+        * call to CleanupStack::PopAndDestroy will run EndAtomicOperation.
+        */
+        void StartAtomicOperationLC();
+        
+        /**
+        * Ends the section of the code, that can be simultaneously executed
+        * only by a single instance of this class. Other instances have to wait
+        * Same as exiting the Java "synchronized" method
+        * @leave KErrNotReady if atomic operation hasn't been started
+        */
+        void EndAtomicOperation();
+        
+        /**
+        * Runs the EndAtomicOperation when calling CleanupStack::PopAndDestroy after
+        * a call to StartAtomicOperationLC
+        */ 
+        static void CleanupEndAtomicOperation( TAny* aService );
+        
+        /**
+        * Creates and pushes to cleanup stack a TCleanupItem that calls
+        * EndAtomicOperation when CleanupStack::PopAndDestroy is called
+        */
+        void CreateAndPushEndAtomicCleanupItemL();
+        
+    private:
+        // From MIntChangeNotifiable
+        /**
+         * Is called by the P&S property watcher to let this object know that
+         * the global tick property has been changed
+         */
+        void IntValueChanged( TInt aNewValue );
+        
+    private:
+        // Main access point to VAS
+        CNssVASDBMgr*               iVasDbManager;      // Owned
+        MNssTagMgr*                 iTagManager;        // Not owned.
+        
+        // Stores the local tick count. When local tick count
+        // is equal to the global tick count, this object is aware
+        // of all the VAS updates
+        TInt						iLocalTickCount;
+        
+        // Commands in the system
+        RVCommandArray              iCommands;        
+        
+        // Maximal used command id
+        TInt                        iMaxCommandId;
+        
+        // Utility that plays back the voice commands
+        CTagPlayer*                 iTagPlayer;
+        
+        RMutex                      iLock;
+        
+        // Client that should be notified about the playback events
+        MNssPlayEventHandler*       iPlaybackHandler;
+        
+        // Is used to check the global "tick count", i.e.
+        // number of operations performed by this
+        // and another instances of VCommand handler
+        RProperty                   iGlobalTickProperty;
+        
+        MVCommandHandlerObserver*	iObserver;
+        
+        // Watches for the global tick property to let the services observer
+        // know when the local cache is out of date
+        CIntPropertyWatcher*        iGlobalTickWatcher;
+        
+        // Last time when this instance set the global tick count
+        // it was this value.
+        // Is used to distinguish own global tick changes from external global tick changes
+        TInt                        iLastSetGlobalTickCount;
+    };
+
+#endif // VCOMMANDSERVICES_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/asyncworker.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class that is able to pause the execution until the 
+*                asynchronous call resumes it. Knows how to leave the
+*                resumed function with the error code supplied by the
+*                resuming asynchronous call
+*
+*/
+
+
+#include "rubydebug.h"
+#include "asyncworker.h"
+
+// async worker panic code
+_LIT( KAsyncWorkerPanic, "AWRK" );
+
+CAsyncWorker* CAsyncWorker::NewLC()
+	{
+	CAsyncWorker* self = new (ELeave) CAsyncWorker;
+	CleanupStack::PushL( self );
+	return self;
+	}
+	
+CAsyncWorker* CAsyncWorker::NewL()
+	{
+	CAsyncWorker* self = CAsyncWorker::NewLC();
+	CleanupStack::Pop( self );
+	return self;
+	}
+	
+CAsyncWorker::~CAsyncWorker()
+	{
+	delete iWaiter;  // if any
+	}
+
+/**
+* Pauses the execution until StopAsyncWaitingL is called
+* Leaves if StopAsyncWaitingL is called with the negative error code
+* @leave KErrNotReady if another waiting is still in progress
+* @leave Leaves with the error code passed to StopAsyncWaitingL
+*/
+void CAsyncWorker::WaitForAsyncCallbackL()
+	{
+	/** @todo Change to RUBY_ASSERT_ALWAYS */
+	RUBY_DEBUG_BLOCKL( "CAsyncWorker::WaitForAsyncCallbackL" );
+	if( iWaiter )
+		{
+		RUBY_ERROR0( "CAsyncWorker::WaitForAsyncCallbackL Already waiting" );
+		}
+	
+	__ASSERT_ALWAYS( !iWaiter, User::Leave( KErrNotReady ) );
+	iErr = KErrNone;
+    iWaiter = new (ELeave) CActiveSchedulerWait;
+    iWaiter->Start();
+    delete iWaiter;
+    iWaiter = NULL;
+    User::LeaveIfError( iErr );
+	}
+
+/** 
+* Resumes the process paused by WaitForAsyncCallbackL
+* @param aErr Result code to pass to the 
+*        WaitForAsyncCallbackL error handling. Note, that 
+*        WaitForAsyncCallbackL leaves only if aErr is negative
+* @return KErrNotReady if no waiting is in progress. Otherwise KErrNone
+*/
+TInt CAsyncWorker::StopAsyncWaiting( TInt aErr )
+	{
+    RUBY_DEBUG1( "CAsyncWorker::StopAsyncWaitingL aErr [%d] ", aErr ); 
+    iErr = aErr;   
+    /** @todo Change to RUBY_ASSERT_ALWAYS */
+	if( !iWaiter )
+		{
+		RUBY_ERROR0( "CAsyncWorker::WaitForAsyncCallbackL Not waiting" );
+		}
+	if( !iWaiter)
+		{
+		return KErrNotReady;
+		}
+	
+    iWaiter->AsyncStop();
+    return KErrNone;
+	}
+	
+/**
+* Same as StopAsyncWaiting, but panics with AWRK <error code> instead 
+* of returning the error code
+* @see StopAsyncWaiting
+*/
+void CAsyncWorker::StopAsyncWaitingOrPanic( TInt aErr )
+	{
+	TInt err = StopAsyncWaiting( aErr );
+	if( err != KErrNone ) 
+		{
+		User::Panic( KAsyncWorkerPanic, err );
+		}
+	}
+	
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/contextprovider.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,262 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Provides access to the VAS context
+*
+*/
+
+
+#include "rubydebug.h"
+#include "contextprovider.h"
+
+#include <nssvasmcontextmgr.h>
+#include <nssvasmcontext.h>
+#include "vcommandinternalapi.h"
+
+_LIT( KContextProviderPanic, "VCP" );
+
+CContextProvider* CContextProvider::NewL( CNssVASDBMgr& aVasDbManager )
+	{
+	CContextProvider* self = CContextProvider::NewLC( aVasDbManager );
+	CleanupStack::Pop( self );
+	return self;
+	}
+	
+CContextProvider* CContextProvider::NewLC( CNssVASDBMgr& aVasDbManager )
+	{
+	CContextProvider* self = new (ELeave) CContextProvider;
+	CleanupStack::PushL( self );
+	// No part of initialization can leave -> no ConstructL()
+	self->iContextManager = aVasDbManager.GetContextMgr();
+	return self;
+	}
+	
+CContextProvider::~CContextProvider()
+	{
+	delete iSaveContextWaiter; // if any
+	delete iVasContext;  // if any
+	}
+	
+/**
+* Returns the VCommand VAS context. If it doesn't exists,
+* it is being created. client is responsible for the context deletion
+* 
+* @todo If support for different contexts is needed, 
+* 1) Rename the method into GetContextLC;
+* 2) add the optional
+* argument "const TDesC& aContextName = KVoiceCommandContext"
+*/
+MNssContext* CContextProvider::GetVCommandContextLC()
+	{
+	RUBY_DEBUG0( "CContextProvider::GetVCommandContextL start" );
+    __ASSERT_ALWAYS( !iVasContext, User::Leave( KErrNotReady ) );
+    if( iContextManager->GetContextList( this ) != KErrNone )
+        {
+        RUBY_DEBUG0( "CContextProvider::GetVCommandContextL No context in the VAS yet. Creating one" );
+        return CreateVCommandContextLC();
+        }
+    else
+        {
+        RUBY_DEBUG0( "CContextProvider::GetVCommandContextL List of contexts requested" );
+        }
+        TRAPD ( err, WaitForAsyncCallbackL(); );
+        if ( err )
+            {
+            iContextManager->CancelGetContext();
+            User::Leave( err );
+            }
+        MNssContext* result = iVasContext;
+        iVasContext = NULL;        
+        CleanupDeletePushL( result );
+        
+        RUBY_DEBUG0( "CContextProvider::GetVCommandContextL end" );
+        return result;
+	}
+
+/**
+* Creates VCommand context. To be called during the GetVCommandContextLC
+* sequence
+*/	
+MNssContext* CContextProvider::CreateVCommandContextLC()
+	{
+	RUBY_DEBUG0( "CContextProvider::CreateVCommandContextLC start" );
+	__ASSERT_ALWAYS( !iVasContext, User::Leave( KErrNotReady ) );
+    iVasContext = iContextManager->CreateContextL();
+    iVasContext->SetNameL( KVoiceCommandContext );
+    iVasContext->SetGlobal( ETrue );
+    
+    if ( iContextManager->SaveContext( this, iVasContext ) != 
+                            KErrNone )
+        {
+        RUBY_ERROR0( "CContextProvider::CreateVCommandContextLC SaveContext call failed" );
+        User::Leave( KErrAbort );
+        }
+    else 
+        {
+        RUBY_DEBUG0( "CContextProvider::CreateVCommandContextLC SaveContext requested" );
+        }
+        
+    // We cannot use the inherited WaitForAsyncCallback. 
+    // It might already be waiting from GetVCommandContextLC
+    /** 
+     * @todo Consider transforming WaitForAsyncCallback from wait/released into 
+     *        wait_counter
+     */
+    iSaveContextWaiter = CAsyncWorker::NewL();
+    iSaveContextWaiter->WaitForAsyncCallbackL();
+    delete iSaveContextWaiter;
+    iSaveContextWaiter = NULL;
+    MNssContext* result = iVasContext;
+    iVasContext = NULL;
+    CleanupDeletePushL( result );
+
+    RUBY_DEBUG0( "CContextProvider::CreateVCommandContextLC end" );
+    return result;
+	}	
+				
+// From MNssGetContextClient
+/**
+* Callback to indicate GetContext successed.
+* client has to delete the context after using the context.
+* @since 2.0
+* @param aContext
+* @param aErrorCode KErrNone if getting of context was successfull
+* @return None
+*/
+void CContextProvider::GetContextCompleted( MNssContext* /*aContext*/,
+                                            TInt /*aErrorCode*/ )
+	{
+	RUBY_ERROR0( "CContextProvider::GetContextCompleted Should never be called" );
+	__ASSERT_ALWAYS( EFalse, User::Panic( KContextProviderPanic, KErrNotSupported ) );
+	}
+
+/**
+* Callback to indicate GetContext successed.
+* client has to ResetAndDestroy() after using the list.
+* @since 2.0
+* @param aContextList A list of contexts. 
+* @param aErrorCode KErrNone if getting of context list was successfull
+* @return None
+*/
+void CContextProvider::GetContextListCompleted(
+    MNssContextListArray *aContextList, TInt aErrorCode )
+	{
+	// No single L function called => TRAPD( DoGetContextListCompletedL() ) not needed
+    RUBY_DEBUG0( "CContextProvider::GetContextListCompleted start" );
+    
+    if( aErrorCode == KErrNone )
+        {
+        TInt err = KErrNone;
+
+        if ( iVasContext )
+            {
+            RUBY_ERROR0( "CContextProvider::GetContextListCompleted iVasContext is not NULL" );
+            err = KErrAlreadyExists;
+            }
+       
+        if( !aContextList )
+            {
+            RUBY_ERROR0( "CContextProvider::GetContextListCompleted empty context list" );
+            err = KErrArgument;
+            }
+        
+        if( err == KErrNone )  // guarding conditions are ok
+            {
+            RUBY_DEBUG1( "CContextProvider::GetContextListCompleted Iterating over [%d] contexts",
+                        aContextList->Count() );
+            for( TInt i ( 0 ); i < aContextList->Count(); i++ ) 
+                {
+                if ( aContextList->At(i)->ContextName() == KVoiceCommandContext )
+                    {
+                    iVasContext = aContextList->At( i );
+                    }
+                else
+                    {
+                    delete aContextList->At( i );
+                    }
+                }  // for
+            aContextList->Reset();
+            delete aContextList;
+        
+        	if( !iVasContext ) 
+    	        {
+    	        RUBY_DEBUG0( "CContextProvider::GetContextListCompleted COMMAND context not found" );
+    	        TRAP( err,
+    	                iVasContext = CreateVCommandContextLC();
+    	        		CleanupStack::Pop( iVasContext );
+    	        		);
+    	        if( err != KErrNone )
+    	        	{
+    	        	RUBY_ERROR1( "CContextProvider::GetContextListCompleted \
+    	        				 Failed to create the VCommandContext", err );
+    	        	}
+    	        }
+            }  // if guarding conditions are ok
+            
+        if( err != KErrNone )
+        	{
+        	RUBY_ERROR1( "CContextProvider::GetContextListCompleted failed with [%d]", err );
+        	// Whenever error is returned, post-WaitForAsynchCallbackL code has no chance
+            // to clean the iVasContext;
+            delete iVasContext;
+            iVasContext = NULL;
+        	}
+            
+        StopAsyncWaitingOrPanic( err );
+        }
+        
+    else // aErrorCode is not KErrNone
+        {
+        RUBY_ERROR1( "CContextProvider::GetContextCompleted error. Error code [%d] ", aErrorCode );
+        
+        // Whenever error is returned, post-WaitForAsynchCallbackL code has no chance
+        // to clean the iVasContext;
+        delete iVasContext;
+        iVasContext = NULL;
+        StopAsyncWaitingOrPanic( aErrorCode );       
+        }
+    
+    RUBY_DEBUG0( "CContextProvider::GetContextListCompleted end" );     
+   	}
+
+// From MNssSaveContextClient
+
+/**
+* Callback to indicate SaveContext successed.
+* @since 2.0
+* @param aErrorCode KErrNone if saving of context was successfull
+* @return None
+*/
+void CContextProvider::SaveContextCompleted( TInt aErrorCode )
+	{
+	RUBY_DEBUG0( "CContextProvider::SaveContextCompleted start" );
+	
+	if( aErrorCode == KErrNone )
+	    {
+	    iSaveContextWaiter->StopAsyncWaitingOrPanic( KErrNone );    
+	    }
+    else
+        {
+        RUBY_ERROR1( "CContextProvider::SaveContextCompleted error. Error code [%d] ", aErrorCode );
+        
+        // Whenever error is returned, post-WaitForAsynchCallbackL code has no chance
+        // to clean the iVasContext;
+        delete iVasContext;
+        iVasContext = NULL;
+        iSaveContextWaiter->StopAsyncWaitingOrPanic( aErrorCode );        
+        }
+    
+    RUBY_DEBUG0( "CContextProvider::SaveContextCompleted end" );
+	}
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/desarrayconverter.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A utility object to convert descriptors to 
+*                VAS savable arrays and vise versa
+*
+*/
+
+
+#include "rubydebug.h"
+#include "desarrayconverter.h"
+
+/**
+* Converts the stream data into the array of fixed size descriptors
+* @param aSource 8-bit descriptor to convert
+*/
+CArrayFixFlat<NssRRDText>* CDesArrayConverter::DesC8ToArrayLC( 
+											  const TDesC8& aSource )
+	{
+    NssRRDText buf;
+    
+    const TInt fieldSize = buf.MaxLength(); 
+    TInt textFieldCount = aSource.Length() / fieldSize;
+    if( aSource.Length() % fieldSize != 0 )
+        {
+        textFieldCount++;
+        }
+    RUBY_DEBUG1( "CDesArrayConverter::DesC8ToArrayLC [%d] slots are needed \
+    			to store the streamed command", textFieldCount );
+    
+    
+    CArrayFixFlat<NssRRDText>* array = new (ELeave) CArrayFixFlat<NssRRDText>( textFieldCount );
+    CleanupStack::PushL( array );
+    
+    TInt appendedSize = fieldSize;
+    for( TInt i(0); i < textFieldCount; i++ )
+        {
+        // the last piece
+        if( i == textFieldCount - 1 ) 
+            {
+            appendedSize = aSource.Length() - fieldSize * i;
+            }
+        buf.Copy( aSource.Mid( fieldSize*i, appendedSize ) );
+        array->AppendL( buf );
+        }
+    return array;
+	}
+
+/**
+* Constructs Des8 descriptor from the given array slice. Almost a 
+* counterpart of the DesC8ToArrayLC
+* @param aArray Array to convert
+* @param aStartIndex First element to convert. Zero-based
+* @param aCount number of elements to convert. 
+* @leave KErrArgument if aStartIndex or aCount are out of the array bounds
+*/
+TDesC8* CDesArrayConverter::ArrayToDesC8LC( const CArrayFixFlat<NssRRDText>& aArray, 
+													TInt aStartIndex, TInt aCount )
+	{
+    __ASSERT_ALWAYS( aStartIndex < aArray.Count(), User::Leave( KErrArgument) );
+    __ASSERT_ALWAYS( aStartIndex + aCount <= aArray.Count(), User::Leave( KErrArgument) );
+    // Calculate the required descriptor length
+    TInt storageLength (0);
+    for( TInt i = aStartIndex; i < aStartIndex + aCount; i++ )
+        {
+        storageLength += aArray[i].Length();
+        }
+    HBufC8* storage = HBufC8::NewLC( storageLength );
+    
+    for( TInt i = aStartIndex; i < aStartIndex + aCount; i++ ) 
+        {
+        // 16 bit chars are converted to 8-bit chars
+        storage->Des().Append( aArray[i] );
+        }
+    return storage;
+	}
+
+			
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/intpropertywatcher.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches for the integer P&S property and notifies observer
+* 		 about the changes
+*
+*/
+
+
+#include "rubydebug.h"
+#include "intpropertywatcher.h"
+
+CIntPropertyWatcher* CIntPropertyWatcher::NewL( const TUid aCategory, TUint aKey, 
+                                    MIntChangeNotifiable& aObserver )
+    {
+    CIntPropertyWatcher* self = new (ELeave) CIntPropertyWatcher( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL( aCategory, aKey );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CIntPropertyWatcher::CIntPropertyWatcher( MIntChangeNotifiable& aObserver )
+    :CActive( CActive::EPriorityStandard ), iObserver( aObserver )
+    {}
+
+void CIntPropertyWatcher::ConstructL( const TUid aCategory, TUint aKey )
+    {
+    User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );
+    CActiveScheduler::Add(this);
+    // initial subscription
+    iProperty.Subscribe(iStatus);
+    SetActive();
+    }
+
+CIntPropertyWatcher::~CIntPropertyWatcher()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+
+void CIntPropertyWatcher::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+void CIntPropertyWatcher::RunL()
+    {
+    RUBY_DEBUG_BLOCKL( "" );
+    // resubscribe before processing new value to prevent missing updates
+    iProperty.Subscribe(iStatus);
+    SetActive();    
+    // property updated, get new value
+    TInt newValue;
+    if (iProperty.Get( newValue ) == KErrNotFound )
+        {
+        RUBY_DEBUG0( "Property deleted or was never defined, ignoring" );
+        }
+    else
+        {
+        iObserver.IntValueChanged( newValue );
+        }
+    }
+    
+
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/storedvcommand.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice command with the link to the VAS
+*
+*/
+
+
+
+#include <e32def.h>
+#include "vcommandinternalapi.h"
+#include "rubydebug.h"
+
+ /**
+* Factory function. Create a const snapshop of exe-ui-vastext collection
+* @param aText Text to be trained by VAS. Can be of any length, however
+*        only first KNssVasDbTagName characters will be trained by VAS
+* @see KNssVasDbTagName in nssvasdbkonsts.h
+* @param aRunnable Executable to be fired when the command is recognized. 
+*        VCommand takes the ownership on the aRunnable
+* @param aUi visible strings to be displayed in VC App. VCommand takes 
+*        the ownership on the aUi
+*/
+CStoredVCommand* CStoredVCommand::NewL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                                 const CVCCommandUi& aUi, TInt aCommandId )
+    {
+    CStoredVCommand* self = new (ELeave) CStoredVCommand;
+    CleanupStack::PushL( self );
+    self->ConstructL( aText, aRunnable, aUi, aCommandId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+/** 
+* Internalizes the command from stream 
+* @leave KErrNotSupported if the stream data format is unsupported
+*        e.g. if it has been written by newer implementation
+*/
+CStoredVCommand* CStoredVCommand::NewL( RReadStream &aStream, TInt aCommandId )
+    {
+    CStoredVCommand* self = new (ELeave) CStoredVCommand;
+    CleanupStack::PushL( self );
+    self->ConstructL( aStream, aCommandId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/**
+* @see CVCommand::ConstructL
+*/ 
+void CStoredVCommand::ConstructL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                 const CVCCommandUi& aUi, TInt aCommandId ) 
+    {
+    CVCommand::ConstructL( aText, aRunnable, aUi );
+    iCommandId = aCommandId;
+    }
+    
+/**
+* @see CVCommand::ConstructL
+*/
+void CStoredVCommand::ConstructL( RReadStream& aStream, TInt aCommandId )
+    {
+    CVCommand::ConstructL( aStream );
+    iCommandId = aCommandId;
+    }
+    
+/**
+* Clone itself
+* Is used for copying via NewL( CVCommand& aOriginal )
+*/
+CVCommand* CStoredVCommand::CloneL() const
+    {
+    CVCommand* clone = CStoredVCommand::NewL( SpokenText(), Runnable(), 
+                                                CommandUi(), CommandId() );
+    return clone;
+    }
+
+/**
+* @return CommandId
+*/
+TInt CStoredVCommand::CommandId() const
+    {
+    return iCommandId;
+    }
+
+/**
+* Asynchronous
+* Attempts to play back the text expected to be recognized. 
+* To be playable command has to be added to CVCommandHandler AND
+* then retrieved back
+*
+* @param aHandler CVCommandHandler where the command is stored
+* @todo Consider storing link to CVCommandHandler within the CStoredVCommand
+*       Pros: No clumsy aHandler argument for the playback
+*       Pros: No need to remember in which handler the command is stored
+*             and why specifying storage is needed during the playback
+*       Cons: In case of internal link the linked handler should still
+*             exist. It cannot be e.g. destroyed and recreated later even
+*             if the latter one is using the same VAS
+*
+* @param aPlayEventHandler Entity that handles the playback callbacks
+* @see NssVasMPlayEventHandler.h
+*
+* @leave KErrBadHandle if the current command has not been retrieved 
+*        from CVCommandHandler (i.e. was not trained for recognition)
+* @leave KErrNotFound if this command cannot be found in aHandler
+* @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasUnexpectedRequest
+* @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInUse
+* @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInvalidParameter
+* @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                             EVasPlayFailed
+*/
+void CStoredVCommand::PlaySpokenTextL( const CVCommandHandler& aHandler, 
+                          MNssPlayEventHandler& aPlayEventHandler ) const
+    {
+    RUBY_DEBUG_BLOCK( "CStoredVCommand::PlaySpokenTextL" );
+    aHandler.PlaySpokenTextL( *this, aPlayEventHandler );
+    }
+
+/**
+* Plays back the user-specified alternative spoken text. 
+* Otherwise is identical to PlaySpokenTextL
+* @see PlaySpokenTextL
+* @leave KErrNotFound if this command cannot be found in aHandler of if 
+*        it doesn't have a user-specified text
+*/     
+void CStoredVCommand::PlayAlternativeSpokenTextL( const CVCommandHandler& aHandler, 
+                          MNssPlayEventHandler& aPlayEventHandler ) const
+    {
+    RUBY_DEBUG_BLOCK( "CStoredVCommand::PlaySpokenTextL" );
+    aHandler.PlayAlternativeSpokenTextL( *this, aPlayEventHandler );
+    }
+    
+/**
+* Cancels playback of a spoken or alternative spoken text
+* To be playable command has to be added to CVCommandHandler AND
+* then retrieved back. After this function neither HandlePlayStarted,
+* nor HandlePlayComplete will be called
+*
+* @param aHandler CVCommandHandler where the command is stored
+*
+* @leave KErrBadHandle if the current command has not been retrieved 
+*        from CVCommandHandler (i.e. was not trained for recognition)
+* @leave KErrNotReady if playback has never been started
+*
+*/
+void CStoredVCommand::CancelPlaybackL( const CVCommandHandler& aHandler ) const
+    {
+    aHandler.CancelPlaybackL( *this );
+    }
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/tagcommandconverter.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,189 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Converts VCommands into tags and vise veraa
+*
+*/
+
+
+
+#include <e32def.h>
+#include <s32mem.h>  // memory streams
+#include <vcommandapi.h>
+#include "rubydebug.h"
+#include "desarrayconverter.h"
+#include "tagcommandconverter.h"
+#include "vcommandinternalapi.h"
+
+// For CleanupResetAndDestroy
+#include <mmfcontrollerpluginresolver.h>  
+
+/** The index of the first element of the tag RRD text array, that is used to 
+ * store the streamed VCommand
+ */
+const TInt KStreamStartIndex = 1;
+
+/** 
+ * Streamimg the VCommand might take arbitrary amount of space.
+ * Every time the streaming buffer needs to be increased it grows up
+ * this amount of bytes
+ */
+const TInt KCommandBufferSizeExpansion = 500;
+
+/** 
+* Granularity for the returned tag array
+*/ 
+const TInt KDefaultTagsPerCommand = 2;
+
+/**
+* Converts given tag to the VCommand
+* @leave KErrTotalLossOfPrecision if the aTag's intArray is empty
+*/
+CStoredVCommand* CTagCommandConverter::TagToCommandLC( const MNssTag& aTag )
+	{
+    MNssTag& varTag ( const_cast<MNssTag&>(aTag) );
+    CArrayFixFlat<TInt>& intArray = *( varTag.RRD()->IntArray() );
+    __ASSERT_ALWAYS( intArray.Count() > 0, User::Leave( KErrTotalLossOfPrecision  ) );
+    
+    CArrayFixFlat<NssRRDText>& tagArray = *(varTag.RRD()->TextArray());
+    TDesC8* storage = CDesArrayConverter::ArrayToDesC8LC( tagArray, KStreamStartIndex, 
+                            tagArray.Count() - KStreamStartIndex );
+    TInt commandId = intArray[KCommandIdRrdIntIndex];
+        
+    RDesReadStream readStream( *storage );
+    CleanupClosePushL( readStream );
+    CStoredVCommand* command = CStoredVCommand::NewL( readStream, commandId );
+    
+    CleanupStack::PopAndDestroy( &readStream );    
+    CleanupStack::PopAndDestroy( storage );
+    CleanupStack::PushL( command );
+    return command;
+	}
+    
+/**
+* Constructs a new VAS tag from a command and a context. 
+* Does not save to VAS, just creates. Created tag stores the streamed
+* VCommand in its RRDText array. The tag's rrd int array is empty
+*/
+MNssTag* CTagCommandConverter::CommandToTagLC( const CVCommand& aCommand, 
+						const MNssContext& aContext, MNssTagMgr& aTagMgr )
+    {
+    MNssTag* tag = aTagMgr.CreateTagL( const_cast<MNssContext*>( &aContext ) );
+    CleanupDeletePushL( tag );
+
+    // the first (and only) element of the rrdint array is the application uid
+    // the first element of the rrdtext array is the command line arguments 
+    // converted to 16 bit representation (on 16-bit systems)
+    /** @todo consider removing this "simple" shortcut of saving the arguments 
+     *        into the first RRD text element. This information is 
+     *        anyway streamed into the other rrdtext slots
+     */
+    CArrayFixFlat<TInt> *theId = new (ELeave) CArrayFixFlat<TInt>( 1 );
+    CleanupStack::PushL( theId );
+    
+    
+    CBufFlat* storage = CBufFlat::NewL( KCommandBufferSizeExpansion );
+    CleanupStack::PushL( storage );
+    
+    RBufWriteStream writeStream( *storage);
+    CleanupClosePushL( writeStream );
+    writeStream << aCommand;    
+    CleanupStack::PopAndDestroy( &writeStream );
+   
+    CArrayFixFlat<NssRRDText>* streamChunks = 
+                        CDesArrayConverter::DesC8ToArrayLC( storage->Ptr( 0 ) );
+    // 1 for the command line args. They are saved separately
+    CArrayFixFlat<NssRRDText>* theText = 
+    	new (ELeave) CArrayFixFlat<NssRRDText>( streamChunks->Count() + 1 );
+    CleanupStack::PushL(theText);
+    
+    NssRRDText bufArguments;
+    // converts to 16-bits in unicode builds
+    bufArguments.Copy( aCommand.Runnable().Arguments() );
+    theText->AppendL( bufArguments );
+        
+    for( TInt i(0); i < streamChunks->Count(); i++ )
+        {
+        // the last piece
+        theText->AppendL( streamChunks->At( i ) );
+        }
+    RUBY_DEBUG0( "CTagCommandConverter::CommandToTagLC Saved command to the rrd text array" );
+    tag->RRD()->SetIntArrayL( theId );
+    tag->RRD()->SetTextArrayL( theText );
+    
+    CleanupStack::PopAndDestroy( theText );
+    CleanupStack::PopAndDestroy( streamChunks );
+    CleanupStack::PopAndDestroy( storage );
+    CleanupStack::PopAndDestroy( theId );
+    
+    return tag;
+    }    
+
+/**
+* Converts given tags to the VCommand. This tags must have been generated
+* from a single VCommand (via CommandToTagsLC2 ) 
+* @leave KErrOverflow if given array has more, than two elements
+* @leave KErrUnderflow if given array is empty
+* @leave KErrArgument if given tags correspond to the different VCommands
+*/
+CStoredVCommand* CTagCommandConverter::TagsToCommandLC( const CArrayPtr<MNssTag>& aTags )
+    {
+    __ASSERT_ALWAYS( aTags.Count() <= KMaxTagsPerCommand, User::Leave( KErrOverflow ) );
+    __ASSERT_ALWAYS( aTags.Count() > 0, User::Leave( KErrUnderflow ) );
+    CStoredVCommand* firstCommand = TagToCommandLC( *aTags[0] );
+    // Comparing tags is complex. Comparing VCommands is simple
+    if( aTags.Count() == KMaxTagsPerCommand )
+        {
+        CStoredVCommand* secondCommand = TagToCommandLC( *aTags[1] );
+        if( !( *firstCommand == *secondCommand ) )
+            {
+            RUBY_ERROR0( "CTagCommandConverter::TagsToCommandLC firstCommand is NOT equal to second command. Leaving with KErrArgument");
+            User::Leave( KErrArgument );
+            }
+        CleanupStack::PopAndDestroy( secondCommand );
+        }
+    return firstCommand;    
+    }
+
+/**
+* Constructs new VAS tags from a command and a context. 
+* Does not save to VAS, just creates. At the end of this function two
+* items are pushed to the cleanup stack. The first PopAndDestroy will
+* ResetAndDestroy the generated tags, the second one will delete the
+* CArrayPtr itself
+*
+* @return array of one or two VAS tags. Two tags are created if a given 
+*         command has a UserText set. The created tags bear the identical
+*         data
+*/
+CArrayPtr<MNssTag>* CTagCommandConverter::CommandToTagsLC2( const CVCommand& aCommand, 
+				const MNssContext& aContext, MNssTagMgr& aTagMgr )
+    {
+    CArrayPtr<MNssTag>* array = new (ELeave) CArrayPtrFlat<MNssTag>( KDefaultTagsPerCommand );
+    CleanupStack::PushL( array );
+    CleanupResetAndDestroyPushL( *array );
+    
+    MNssTag* firstTag = CommandToTagLC( aCommand, aContext, aTagMgr );
+    array->AppendL( firstTag );
+    CleanupStack::Pop( firstTag );
+    if( aCommand.AlternativeSpokenText() != KNullDesC )
+        {
+        // Second tag is needed
+        MNssTag* secondTag = CommandToTagLC( aCommand, aContext, aTagMgr );
+        array->AppendL( secondTag );
+        CleanupStack::Pop( secondTag );
+        }
+    return array;    
+    }
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/taggetter.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Gets the voice tags from VAS
+*
+*/
+
+
+#include "rubydebug.h"
+#include "taggetter.h"
+
+#include <nssvascoreconstant.h>
+
+// For CleanupResetAndDestroy
+#include <mmfcontrollerpluginresolver.h>  
+
+// For getting tags basing on the convertion details
+// KCommandIdRrdIntIndex has to be known
+#include "tagcommandconverter.h"
+
+CTagGetter* CTagGetter::NewLC()
+	{
+	CTagGetter* self = new (ELeave) CTagGetter;
+	CleanupStack::PushL( self );
+	return self;
+	}
+	
+CTagGetter* CTagGetter::NewL()
+	{
+	CTagGetter* self = CTagGetter::NewLC();
+	CleanupStack::Pop( self );
+	return self;
+	}
+	
+/**
+* Retrieves the list of tags for a given context. Synchronous.
+* Leaves two objects on the cleanup stack!
+* First PopAndDestroy will ResetAndDestroy content
+* Second one will destroy the MNsstagListArray itself
+*/
+MNssTagListArray* CTagGetter::GetTagListLC2( MNssTagMgr& aTagManager, const MNssContext& aContext )
+	{
+	RUBY_DEBUG0( "CTagGetter::GetTagListLC2 start" );
+    __ASSERT_ALWAYS( !iTagList, User::Leave( KErrNotReady ) );
+    TInt nssErr = 
+            aTagManager.GetTagList( this, const_cast<MNssContext*>( &aContext) );
+    MNssTagListArray* result = WaitAndFormTagListLC2( nssErr );
+    RUBY_DEBUG0( "CTagGetter::GetTagListLC2 end" );
+    return result;
+	}
+
+/**
+* Retrieves the list of tags for a given context and vcommand id. Synchronous.
+* Leaves two objects on the cleanup stack!
+* First PopAndDestroy will ResetAndDestroy content
+* Second one will destroy the MNsstagListArray itself
+*/
+MNssTagListArray* CTagGetter::GetTagListLC2( MNssTagMgr& aTagManager, const MNssContext& aContext, 
+                                 TInt aCommandId )
+    {
+    RUBY_DEBUG0( "CTagGetter::GetTagListLC2 start" );
+    __ASSERT_ALWAYS( !iTagList, User::Leave( KErrNotReady ) );
+    TInt nssErr = 
+            aTagManager.GetTagList( this, const_cast<MNssContext*>( &aContext), 
+                                    aCommandId, KCommandIdRrdIntIndex );
+    MNssTagListArray* result = WaitAndFormTagListLC2( nssErr );
+
+    RUBY_DEBUG0( "CTagGetter::GetTagListLC2 end" );
+    return result;
+    }
+    
+/** 
+* After one of the GetTagListLC2 functions requested a list of 
+* tags from VAS, they call this function to wait for the query
+* result and process it 
+* Leaves two objects on the cleanup stack!
+* First PopAndDestroy will ResetAndDestroy content
+* Second one will destroy the MNssTagListArray itself
+* @param aNssErr Error code from the GetTagList request
+*/
+MNssTagListArray* CTagGetter::WaitAndFormTagListLC2( TInt aNssErr )
+    {
+    RUBY_DEBUG0( "CTagGetter::WaitAndFormTagListLC2 start" );
+    MNssTagListArray* result = NULL;
+    if( aNssErr != KErrNone ) 
+        {
+        RUBY_ERROR1( "CTagGetter::GetTagListLC2 GetTagList failed with nss code [%d]",
+                    aNssErr );
+        // Unfortunately VAS does not report if it was a real failure or just no tags
+        // Return empty list in both cases
+        // 1 stands for the random granularity, not for a number of elements
+        result = new (ELeave) MNssTagListArray( 1 );
+        }
+    else 
+    	{
+    	// Tag list requested
+    	WaitForAsyncCallbackL();
+    	result = iTagList;
+	    iTagList = NULL;
+    	}
+    CleanupDeletePushL( result );	
+    CleanupResetAndDestroyPushL( *result );
+
+    RUBY_DEBUG0( "CTagGetter::WaitAndFormTagListLC2 end" );
+    return result;
+    }
+    
+// From  MNssGetTagClient
+
+/**
+* Callback to indicate GetTag successed.
+* client has to delete the tag list
+* @param aTagList
+* @param aErrorCode KErrNone if getting of tag list was successfull
+* @return None
+*/
+void CTagGetter::GetTagListCompleted( MNssTagListArray* aTagList, 
+                                      TInt aErrorCode )
+	{
+	RUBY_DEBUG0( "CTagGetter::GetTagListCompleted start" );
+    
+    if( aErrorCode == KErrNone )
+        {
+        TInt err = KErrNone;
+        if( !aTagList )
+            {
+            RUBY_ERROR0( "CTagGetter::GetTagListCompleted NULL received" );
+            err = KErrArgument;
+            }
+        else if( iTagList ) 
+            {
+            // Whenever error is returned, post-WaitForAsynchCallbackL code has no chance
+            // to clean the iVasContext;
+            delete iTagList;
+            iTagList = NULL;
+            RUBY_ERROR0( "CTagGetter::GetTagListCompleted iTagList is not empty" );
+            err = KErrAlreadyExists;
+            }
+        else 
+            {
+            iTagList = aTagList;
+            }
+        StopAsyncWaitingOrPanic( err );        
+        }
+    
+    else // aErrorCode is not KErrNone
+        {
+        RUBY_ERROR1( "CTagGetter::GetTagCompleted error. Error code[%d] ", aErrorCode );
+        StopAsyncWaitingOrPanic( aErrorCode );
+        }
+    
+    RUBY_DEBUG0( "CTagGetter::GetTagListCompleted end" );   
+	}
+			
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/tagnameset.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Array of tags and corresponding spoken texts
+*
+*/
+
+
+#include "rubydebug.h"
+#include "tagnameset.h"
+#include <nssvasmspeechitem.h>
+#include <nssvasmtag.h>
+#include <nssvasmtagmgr.h>
+
+_LIT( KTagNameSetPanic, "TNS" );
+
+CTagNameSet* CTagNameSet::NewLC()
+    {
+    CTagNameSet* self = new (ELeave) CTagNameSet;
+    CleanupStack::PushL( self );
+    return self;
+    }
+    
+CTagNameSet::~CTagNameSet()
+    {
+    iTags.ResetAndDestroy();
+    iTexts.ResetAndDestroy();
+    }
+    
+        
+/**
+* Adds a tag-text pair to be trained
+* @param aTag tag to be trained and saved. This objects takes ownership
+*        on the aTag
+* @param aTrainingText text to be recognized. This object doesn't
+*        take ownership on aTrainingText, but makes an own copy
+*/
+void CTagNameSet::AppendL( const MNssTag* aTag, const TDesC& aTrainingText )
+    {
+    HBufC* text = aTrainingText.AllocL();
+    iTexts.Append( text );
+    iTags.Append( aTag );    
+    }
+
+/**
+* Train and save to VAS all the stored tags. It is not specified what happens
+* to VAS if this method leaves
+* @param aParams
+* @param aTagMgr
+* @param aIgnoreErrors If ETrue, doesn't fail the whole operation if some
+*        individual trainings/savings failed. Trains and saves as much as
+*        possible
+*/
+void CTagNameSet::TrainAndSaveL( const CNssTrainingParameters& aParams, 
+                                 MNssTagMgr& aTagMgr, TBool aIgnoreErrors )
+    {
+    RUBY_DEBUG_BLOCK( "CTrainingPack::TrainAndSaveL" );
+    iIgnoreErrors = aIgnoreErrors;
+    RUBY_DEBUG1( "CTrainingPack::TrainAndSaveL Processing [%d] pairs", iTags.Count() );
+    
+    TrainTagsL( aParams );
+    SaveTagsL( aTagMgr );
+    }
+    
+/**
+* Remove all the stored tags from VAS. It is not specified what happens
+* to VAS if this method leaves
+* @param aTagMgr
+* @param aIgnoreErrors If ETrue, doesn't fail the whole operation if some
+*        individual removals failed. Removes as many tags as
+*        possible
+*/                            
+void CTagNameSet::UntrainL( MNssTagMgr& aTagMgr, TBool aIgnoreErrors )
+    {
+    RUBY_DEBUG_BLOCK("");
+    iIgnoreErrors = aIgnoreErrors;
+    RUBY_DEBUG1( "Removing [%d] tags from VAS", iTags.Count() );
+    SetCallbacksExpected( iTags.Count() );
+    
+    if( iCallbacksExpected > 0 )
+        {
+       	for( TInt i = 0; i < iTags.Count(); i++ )
+        	{
+            DeleteTagL( aTagMgr, *iTags[i] );
+    	    }  // for
+        WaitUntilOperationsAreCompletedL();
+        }
+    }
+
+/**
+* @return Number of tag-name pairs stored
+*/
+TInt CTagNameSet::Count() const
+    {
+    return iTags.Count();
+    }
+
+/**
+* @param aIndex must be >= 0 and < Count()
+* @return Voice tag at the given position
+* @panic KErrArgument if aIndex is out of bounds
+*/    
+const MNssTag& CTagNameSet::TagAt( TInt aIndex ) const
+    {
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < iTags.Count(), 
+                    User::Panic( KTagNameSetPanic, KErrArgument ));
+    return *iTags[aIndex];
+    }
+
+/**
+* @param aIndex must be >= 0 and < Count()
+* @return Recognition text at the given position
+* @panic KErrArgument if aIndex is out of bounds
+*/        
+const TDesC& CTagNameSet::TextAt( TInt aIndex ) const
+    {
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < iTexts.Count(), 
+                    User::Panic( KTagNameSetPanic, KErrArgument ));
+    return *iTexts[aIndex];
+    }
+
+/**
+* Train all the stored tag-name pairs. Synchronous
+*/
+void CTagNameSet::TrainTagsL( const CNssTrainingParameters& aParams )
+    {
+    __ASSERT_ALWAYS( iCallbacksExpected == 0, User::Leave( KErrInUse) );
+    SetCallbacksExpected( Count() );
+    if( iCallbacksExpected > 0 )
+        {
+        for( TInt i = 0; i < Count(); i++ )
+            {
+            TrainTagL( TagAt( i ), aParams, TextAt( i ) );
+            }  // for
+        WaitUntilOperationsAreCompletedL();
+        }  // if
+    }
+
+
+/**
+* Trains the voice tag. Asynchronous
+* @leave VAS error code
+* @todo Is it ok to mix system-wide codes with the TNssSpeechItemResult codes
+*/
+void CTagNameSet::TrainTagL( const MNssTag& aTag, 
+		const CNssTrainingParameters& aParams, const TDesC& aSpokenText )
+	{
+	RUBY_DEBUG_BLOCKL( "CTagNameSet::TrainTagL" );
+    RUBY_DEBUG1( "Training for spoken text [%S]", &aSpokenText )
+
+    MNssSpeechItem* speechItem = const_cast<MNssTag&>(aTag).SpeechItem();
+    speechItem->SetTextL( aSpokenText );
+    MNssSpeechItem::TNssSpeechItemResult nssErr = 
+		speechItem->TrainTextL( this, const_cast<CNssTrainingParameters*>( &aParams ) );
+    
+    if ( nssErr != MNssSpeechItem::EVasErrorNone )
+        {
+        RUBY_ERROR1( "CTagNameSet::TrainTagL training start failed with the nss code [%d]", 
+                    nssErr );
+        if( iIgnoreErrors )
+            {
+            RUBY_DEBUG0( "CTagNameSet::TrainTagL ignoring error" );
+            DecreaseCallbacksExpected();
+            }
+        else 
+            {
+            // Wait for started operations before leaving
+            DecreaseCallbacksExpected();
+            WaitUntilOperationsAreCompletedL();
+            
+            switch( nssErr )
+                {
+                case MNssSpeechItem::EVasInvalidParameter:
+                    User::Leave( KErrArgument );
+                case MNssSpeechItem::EVasTrainFailed:
+                    User::Leave( KErrGeneral );
+                default:
+                    User::Leave( nssErr );
+                } 
+            }        
+        }
+    RUBY_DEBUG0( "CTagNameSet::TrainTagL Tag training has been initiated" );
+	}			
+			
+
+/**
+* Train Complete Event - Voice tag training completed
+* @param aErrorCode KErrNone if training was successfull
+*/       
+void CTagNameSet::HandleTrainComplete( TInt aErrorCode )
+	{
+	//RUBY_DEBUG0( "Start" );
+	ProcessCallback( aErrorCode );
+	//RUBY_DEBUG0( "End" );
+	}
+
+/**
+* Saves the trained voice tag to VAS. Synchronous
+*/
+void CTagNameSet::SaveTagsL( MNssTagMgr& aTagManager )
+	{
+	RUBY_DEBUG_BLOCK( "CTagSaver::SaveTagsL" );
+	__ASSERT_ALWAYS( iCallbacksExpected == 0, User::Leave( KErrInUse) );
+    SetCallbacksExpected( Count() );
+    if( iCallbacksExpected > 0 )
+        {
+        for( TInt i = 0; i < Count(); i++ )
+            {
+            SaveTagL( aTagManager, TagAt( i ) );
+            }  // for
+            
+        WaitUntilOperationsAreCompletedL();
+        }  // if
+	}
+	
+
+/**
+* Saves the trained voice tag to VAS. 
+*/
+void CTagNameSet::SaveTagL( MNssTagMgr& aTagManager, const MNssTag& aTag )
+	{
+	RUBY_DEBUG_BLOCKL( "CTagNameSet::SaveTagL" );
+    TInt nssErr = 
+            aTagManager.SaveTag( this, const_cast<MNssTag*>( &aTag ) );
+    if( nssErr != KErrNone ) 
+        {
+        RUBY_ERROR1( "CTagNameSet::SaveTagL Savetag start failed with the nss code [%d]", nssErr );
+        if( iIgnoreErrors )
+            {
+            RUBY_DEBUG0( "CTagNameSet::SaveTagL ignoring error" );
+            DecreaseCallbacksExpected();
+            }
+        else 
+            {
+            // Wait for started operations before leaving
+            DecreaseCallbacksExpected();
+            WaitUntilOperationsAreCompletedL();
+            
+            User::Leave( KErrGeneral );
+            }        
+        }
+    RUBY_DEBUG0( "CTagNameSet::SaveTagL Savetag sequence started" );
+
+	}
+
+/**
+* Callback to indicate that SaveTag sequence has been completed
+* @param aErrorCode KErrNone if saving of tag was successfull
+*/
+void CTagNameSet::SaveTagCompleted( TInt aErrorCode )
+	{
+	RUBY_DEBUG0( "Start" );
+    ProcessCallback( aErrorCode );
+    RUBY_DEBUG0( "End" );
+    }
+
+/**
+* Deletes the voice tag from VAS. Asynchronous
+* @leave VAS error codes
+*/
+void CTagNameSet::DeleteTagL( MNssTagMgr& aTagManager, MNssTag& aTag )
+    {
+    User::LeaveIfError( aTagManager.DeleteTag( this, &aTag ) );
+    }
+
+/**
+* Callback to indicate a tag was deleted successfully.
+* @param aErrorCode KErrNone if deletion of tag was successfull
+*/
+void CTagNameSet::DeleteTagCompleted( TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "Start" );
+    ProcessCallback( aErrorCode );
+    RUBY_DEBUG0( "End" );
+    }
+
+/**
+* Handles the common part of the callback processing
+* Decrements the number of still expected callbacks and
+* handles the errors according to aIgnoreErrors from the 
+* public methods
+*/
+void CTagNameSet::ProcessCallback( TInt aErrorCode )
+    {
+    //RUBY_DEBUG0( "Start" );
+    if( iIgnoreErrors || aErrorCode == KErrNone )
+        {
+        if( DecreaseCallbacksExpected() == 0 )
+            {
+            StopAsyncWaitingOrPanic( KErrNone );
+            }  
+        }
+    else
+        {
+        RUBY_ERROR1( "Callback reported error [%d] ", aErrorCode );
+        if( DecreaseCallbacksExpected() == 0 )
+            {
+            StopAsyncWaitingOrPanic( aErrorCode );
+            }
+        }
+    //RUBY_DEBUG0( "End" );    
+    }
+
+/**
+* Sets the number of callbacks to expect
+*/
+void CTagNameSet::SetCallbacksExpected (TUint aCallbacksExpected )
+    {
+    RUBY_DEBUG2( "Changing from [%d] to [%d]", iCallbacksExpected, aCallbacksExpected );
+    iCallbacksExpected = aCallbacksExpected;
+    }
+
+/**
+* Decreases the number of callbacks to expect by one
+* @return Number of callbacks expected after decreasing        
+*/
+TUint CTagNameSet::DecreaseCallbacksExpected()
+    {
+    __ASSERT_ALWAYS( iCallbacksExpected > 0, User::Panic( KTagNameSetPanic, KErrNotReady ) );
+    RUBY_DEBUG2( "Changing from [%d] to [%d]", iCallbacksExpected, iCallbacksExpected - 1 );
+    return --iCallbacksExpected;
+    }
+
+/**
+* Waits until all the expected callbacks are received
+* If no callbacks are expected returns immediately
+* @leave @see CAsyncWorker::WaitForAsyncCallbackL
+*/
+void CTagNameSet::WaitUntilOperationsAreCompletedL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    if( iCallbacksExpected > 0 )
+        {
+        RUBY_DEBUG1( "[%d] callbacks expected. Waiting for them", iCallbacksExpected );
+        WaitForAsyncCallbackL();
+        }
+    else 
+        {
+        RUBY_DEBUG0( "no callbacks expected. Returning immediately" );
+        }
+    }
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/tagplayer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,131 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Plays voice commands
+*
+*/
+
+
+#include "rubydebug.h"
+#include "tagplayer.h"
+
+_LIT( KStoredVCommandPlayerPanic, "SVCP" );
+
+CTagPlayer* CTagPlayer::NewL()
+    {
+    CTagPlayer* self = new (ELeave) CTagPlayer;
+    return self;
+    }
+    
+CTagPlayer::~CTagPlayer()
+    {
+    // if any
+    delete iPlaybackTag;  
+    // to panic in HandlePlays if they are called after the object destruction
+    iPlaybackTag = NULL;  
+    }
+
+/**
+* Attempts to play back the text expected to be recognized. 
+* To be playable command has to be added to CVCommandHandler AND
+* then retrieved back. This function is asynchronous
+*
+* @param aHandler CVCommandHandler where the command is stored
+* @param aPlayEventHandler Entity that handles the playback callbacks
+* @see NssVasMPlayEventHandler.h
+*
+* @leave KErrBadHandle if the current command has not been retrieved 
+*        from CVCommandHandler (i.e. was not trained for recognition)
+* @leave KErrNotFound if this command cannot be found in aHandler
+* @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasUnexpectedRequest
+* @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInUse
+* @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInvalidParameter
+* @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                             EVasPlayFailed
+*/
+void CTagPlayer::PlayTagL( MNssTag* aTag, MNssPlayEventHandler& aPlayEventHandler )
+    {
+    RUBY_DEBUG_BLOCK( "CTagPlayer::PlayTagL" );
+    CleanupDeletePushL( aTag );
+    __ASSERT_ALWAYS( !iPlaybackTag, User::Leave( KErrLocked ) );
+    CleanupStack::Pop( aTag );
+    iPlaybackTag = aTag;
+    iPlayEventHandler = &aPlayEventHandler;
+
+    MNssSpeechItem::TNssSpeechItemResult err = iPlaybackTag->SpeechItem()->PlayL( this );
+    switch( err ) 
+        {
+        case MNssSpeechItem::EVasErrorNone:
+            break;
+        case MNssSpeechItem::EVasUnexpectedRequest:
+            User::Leave( KErrNotReady );
+        case MNssSpeechItem::EVasInUse:
+            User::Leave( KErrInUse );
+        case MNssSpeechItem::EVasInvalidParameter:
+            User::Leave( KErrArgument );
+        case MNssSpeechItem::EVasPlayFailed:
+            User::Leave( KErrGeneral );
+        case MNssSpeechItem::EVasTrainFailed:
+        default:
+            RUBY_ERROR1( "CTagPlayer::PlaySpokenTextL Unexpected error code [%d]", err );
+            User::Leave( KErrGeneral );
+        }
+    }
+    
+/**
+* Cancels playback. No PlayStarted/PlayComplete after it
+*
+* @leave KErrNotReady if playback has never been started
+*/                                   
+void CTagPlayer::CancelPlaybackL()
+    {
+    RUBY_DEBUG_BLOCK( "CTagPlayer::CancelPlaybackL" );
+    __ASSERT_ALWAYS( iPlaybackTag, User::Leave( KErrNotReady ) );
+    TInt err = iPlaybackTag->SpeechItem()->CancelL();
+    RUBY_DEBUG1( "CTagPlayer::CancelPlaybackL Canceled with the error code [%d]", err );
+    delete iPlaybackTag;
+    iPlaybackTag = NULL;
+    iPlayEventHandler = NULL;
+    }
+
+// From MNsPlayEventHandler
+
+/**
+* The HandlePlayStarted method is a virtual method implemented by the
+* client and is called when play is started
+* @param aDuration - the duration of the utterance data
+*/       
+void CTagPlayer::HandlePlayStarted( TTimeIntervalMicroSeconds32 aDuration )
+    {
+    __ASSERT_ALWAYS( iPlaybackTag, User::Panic( KStoredVCommandPlayerPanic, KErrNotReady ) );
+    iPlayEventHandler->HandlePlayStarted( aDuration );
+    }
+
+/**
+* The HandlePlayComplete method is a virtual method implemented by the
+* client and is called when play is completed
+* @param aErrorCode EVasErrorNone if playing was successfull
+*/       
+void CTagPlayer::HandlePlayComplete( TNssPlayResult aErrorCode )
+    {
+    __ASSERT_ALWAYS( iPlaybackTag, User::Panic( KStoredVCommandPlayerPanic, KErrNotReady ) );
+    delete iPlaybackTag;
+    iPlaybackTag = NULL;
+    iPlayEventHandler->HandlePlayComplete( aErrorCode );
+    iPlayEventHandler = NULL;
+    }
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcfolderinfo.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,259 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CVFolderInfo class
+*
+*/
+
+
+#include <vcommandapi.h>
+#include <AknsSkinInstance.h>
+#include <AknsUtils.h>
+#include <AknsConstants.h>
+#include <gulicon.h>
+#include <mifconvdefs.h>
+#include "rubydebug.h"
+
+/**
+ * File name to read icons from if icon file name is not specified
+ */
+_LIT( KDefaultIconFile, "Z:\\resource\\apps\\vcommand.mif" );
+const TInt KDefaultIconIndex = KMifIdFirst;  // first image in the file
+
+/**
+* The version of the streamed data protocol
+* It is rather likely, that the format of the data streamed changes in the future.
+* Using the protocol version, the code can check if it knows how to parse the 
+* input stream
+*/
+const TInt32 KVCFolderInfoProtocolVersion = 2;
+
+static const TAknsItemID* const KIconId[] = 
+    {
+    &KAknsIIDQgnPropFolderVcGeneral,
+    &KAknsIIDQgnPropFolderVcTools,
+    &KAknsIIDQgnPropFolderVcOrganiser,
+    &KAknsIIDQgnPropFolderVcMessage,
+    &KAknsIIDQgnPropFolderVcMedia,
+    &KAknsIIDQgnPropFolderVcProfiles
+    };
+
+/**
+ * This object does not take an ownership of the passed descriptors, 
+ * but makes own copies. 
+ * 
+ * @param aTitle Folder title. It is shown at the top of the screen,
+ *        when the folder is opened in the VCommand application
+ * @param aListedName Version of a title shown when the folder is
+ *        is displayed in the list of VCommands in the VCommand app
+ * @param aHelpTopicId Topic to open when help is requested for the 
+ *        given folder
+ * @param aIconIndex Index of the folder icon in the folder icons mbm file
+ *        each index correspods to two images - the actual icon and its mask
+ * @param aIconFile Mbm file where the icons are obtained from. If KNullDesC, 
+ * 		  the default icon file is used
+ */
+EXPORT_C CVCFolderInfo* CVCFolderInfo::NewL( const TDesC& aTitle,
+        const TDesC& aListedName, TUint32 aHelpTopicId, TUint aIconIndex,
+                const TDesC& aIconFile )
+    {
+    CVCFolderInfo* self = new (ELeave) CVCFolderInfo( aHelpTopicId, aIconIndex );
+    CleanupStack::PushL( self );
+    self->ConstructL( aTitle, aListedName, aIconFile );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/**
+* Copy the existing CVCFolderInfo
+*/
+EXPORT_C CVCFolderInfo* CVCFolderInfo::NewL( const CVCFolderInfo& aOriginal )
+    {
+    CVCFolderInfo* self = new (ELeave) CVCFolderInfo( aOriginal.HelpTopicId(), 
+                                                      aOriginal.IconIndex() );
+    CleanupStack::PushL( self );
+    self->ConstructL( aOriginal.Title(), aOriginal.ListedName(), aOriginal.IconFile() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/**
+ * Constructs the folder information from stream
+ * @leave KErrNotSupported if the stream data format is unsupported
+ */
+ EXPORT_C CVCFolderInfo* CVCFolderInfo::NewL( RReadStream &aStream )
+    {
+    CVCFolderInfo* self = new (ELeave) CVCFolderInfo;
+    CleanupStack::PushL( self );
+    self->ConstructL( aStream );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CVCFolderInfo::CVCFolderInfo( TUint32 aHelpTopicId, TUint aIconIndex ) :
+    iHelpTopicId( aHelpTopicId ), iIconIndex (aIconIndex )
+    {
+    // empty
+    }
+        
+void CVCFolderInfo::ConstructL( RReadStream &aStream )
+	{
+	/**
+	* @todo extract the repeated descriptor internalization code into
+	*       a separate method
+	*/
+	TInt32 ver;
+    aStream >> ver;
+    __ASSERT_ALWAYS( ver == KVCFolderInfoProtocolVersion, User::Leave( KErrNotSupported  ) );
+    iTitle = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pTitle = iTitle->Des();
+    aStream >> pTitle;
+    iListedName = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pListedName = iListedName->Des();
+    aStream >> pListedName;
+    iHelpTopicId = aStream.ReadUint32L();
+    iIconFile = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pIconFile = iIconFile->Des();
+    aStream >> pIconFile;
+    iIconIndex = aStream.ReadUint32L();
+	}
+    
+    
+/** 
+* Second-phase constructor 
+*/
+void CVCFolderInfo::ConstructL( const TDesC& aTitle, const TDesC& aListedName,
+                                const TDesC& aIconFile )
+    {
+    RUBY_DEBUG_BLOCKL( "" );
+    iTitle = HBufC::NewL( aTitle.Length() );
+    *iTitle = aTitle;
+    iListedName = HBufC::NewL( aListedName.Length() );
+    *iListedName = aListedName;    
+    iIconFile = HBufC::NewL( aIconFile.Length() );
+    *iIconFile = aIconFile;
+    }
+    
+EXPORT_C CVCFolderInfo::~CVCFolderInfo() 
+    {
+    delete iListedName;
+    delete iTitle;
+    delete iIconFile;
+    }
+    
+/** 
+ * Saves the command to stream.
+ * Descriptor components are saved as <length><descriptor> pairs, where 
+ * <length> is TInt32 and <descriptor> is the default descriptor represetation
+ * TBools are saved as TInt32 either
+ */
+EXPORT_C void CVCFolderInfo::ExternalizeL( RWriteStream &aStream ) const
+    {
+    aStream << KVCFolderInfoProtocolVersion;
+    aStream << static_cast<TInt32>( iTitle->Length() );
+    aStream << *iTitle;
+    aStream << static_cast<TInt32>( iListedName->Length() );
+    aStream << *iListedName;
+    aStream << iHelpTopicId;
+    aStream << static_cast<TInt32> ( iIconFile->Length() );
+    aStream << *iIconFile;
+    // Mandate saving index as Uint32 to preserve the string format
+    aStream << static_cast<TUint32> ( iIconIndex );
+    }
+    
+
+EXPORT_C const TDesC& CVCFolderInfo::Title() const 
+    {
+    return *iTitle;
+    }
+
+EXPORT_C const TDesC& CVCFolderInfo::ListedName() const 
+    {
+    return *iListedName;
+    }
+
+EXPORT_C TUint32 CVCFolderInfo::HelpTopicId() const 
+    {
+    return iHelpTopicId;
+    }
+    
+EXPORT_C TBool CVCFolderInfo::operator==( const CVCFolderInfo& aFolderInfo ) const
+    {
+    return (
+            ( iHelpTopicId == aFolderInfo.HelpTopicId() ) &&
+            ( *iTitle == aFolderInfo.Title()            ) &&
+            ( *iListedName == aFolderInfo.ListedName()  ) &&
+            ( *iIconFile == aFolderInfo.IconFile()      ) &&
+            ( iIconIndex == aFolderInfo.IconIndex()     ) 
+           );
+    }
+    
+EXPORT_C TDesC& CVCFolderInfo::IconFile() const
+	{
+	return *iIconFile;
+	}    
+    
+EXPORT_C TUint CVCFolderInfo::IconIndex() const
+	{
+	return iIconIndex;
+	}
+
+/**
+* Creates an icon to represent this folder. Works only if CEikonEnv is available
+* @return Icon for the folder
+*/
+EXPORT_C CGulIcon* CVCFolderInfo::IconLC() const
+	{
+ 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+	CFbsBitmap* bitmap = NULL;
+    CFbsBitmap* mask = NULL;
+    const TInt KBitmapsPerIcon = 2;
+    
+    // Every "index" corrsponds to two bitmaps - actual icon and its mask
+    TInt iconIndex = KMifIdFirst + IconIndex()*KBitmapsPerIcon;
+    TInt maskIndex = iconIndex + 1;
+    TDesC& iconFile = IconFile();
+    if ( iconFile == KNullDesC )
+        {
+        iconFile = KDefaultIconFile;
+        }
+    
+    TRAPD( err,    
+	    AknsUtils::CreateIconLC( skin, *KIconId[ IconIndex() ],
+       	                     bitmap, mask, iconFile, iconIndex, 
+       	                     maskIndex );
+        CleanupStack::Pop( 2 );  // mask, bitmap
+         )
+    if( err != KErrNone )
+        {
+        RUBY_DEBUG1( "CreateIconLC failed with %d. Loading default icon", err );
+        AknsUtils::CreateIconLC( skin, *KIconId[ IconIndex() ],
+                             bitmap, mask, KDefaultIconFile, KDefaultIconIndex, 
+                             KDefaultIconIndex + 1 );
+        CleanupStack::Pop( 2 );  // mask, bitmap
+        }
+ 
+    CleanupStack::PushL( mask );
+    CleanupStack::PushL( bitmap );
+    CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
+    icon->SetBitmapsOwnedExternally( EFalse );
+
+    // icon now owns the bitmaps, no need to keep on cleanup stack.
+    CleanupStack::Pop( bitmap );  
+    CleanupStack::Pop( mask );  
+
+    CleanupStack::PushL( icon );
+    return icon;
+	}
+	    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommand.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the VCommand class
+*
+*/
+
+
+
+#include <e32def.h>
+#include <vcommandapi.h>
+#include "rubydebug.h"
+
+/**
+* The version of the streamed data protocol
+* It is rather likely, that the format of the data streamed changes in the future.
+* Using the protocol version, the code can check if it knows how to parse the 
+* input stream
+*/
+const TInt32 KVCommandProtocolVersion = 1;
+
+/**
+* Create a const snapshop of exe-ui-vastext collection
+* @param aText Text to be trained by VAS. No longer, than KMaxVCTextLength. 
+*        CVCommand doesn't take the ownership
+* @param aRunnable Executable to be fired when the command is recognized. 
+*        VCommand doesn't take the ownership
+* @param aUi visible strings to be displayed in VC App. 
+*        VCommand doesn't take the ownership
+*/
+EXPORT_C CVCommand* CVCommand::NewL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                            const CVCCommandUi& aUi )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCCommand::NewL with args" );
+    CVCommand* self = new (ELeave) CVCommand;
+    CleanupStack::PushL( self );
+    self->ConstructL( aText, aRunnable, aUi );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/** 
+* Internalizes the command from stream 
+*/
+EXPORT_C CVCommand* CVCommand::NewL( RReadStream &aStream )
+    {
+    CVCommand* self = new (ELeave) CVCommand;
+    CleanupStack::PushL( self );
+    self->ConstructL( aStream );
+    CleanupStack::Pop( self );
+    return self;    
+    }
+
+EXPORT_C CVCommand* CVCommand::NewL( const CVCommand& aOriginal )
+    {
+    // Original knows better how to copy itself
+    return aOriginal.CloneL();    
+    }
+
+void CVCommand::ConstructL( RReadStream &aStream )
+	{
+	TInt32 ver;
+    aStream >> ver;
+    __ASSERT_ALWAYS( ver == KVCommandProtocolVersion, User::Leave( KErrNotSupported  ) );
+    iSpokenText = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pSpokenText = iSpokenText->Des();
+    aStream >> pSpokenText;
+    iRunnable = CVCRunnable::NewL( aStream );
+    iCommandUi = CVCCommandUi::NewL( aStream );
+	}
+	
+void CVCommand::ConstructL( const TDesC& aText, const CVCRunnable& aRunnable, 
+                            const CVCCommandUi& aUi )
+    {
+    __ASSERT_ALWAYS( aText.Length() > 0, User::Leave( KErrUnderflow ) );
+    iSpokenText = HBufC::NewL( aText.Length() );
+    *iSpokenText = aText;
+  	iRunnable = CVCRunnable::NewL( aRunnable );
+    iCommandUi = CVCCommandUi::NewL( aUi );    
+    }
+	
+	
+EXPORT_C CVCommand::~CVCommand()
+    {
+    delete iCommandUi;
+    delete iRunnable;
+    delete iSpokenText;
+    }
+
+CVCommand* CVCommand::CloneL() const
+    {
+    CVCommand* clone = CVCommand::NewL( SpokenText(), Runnable(), CommandUi() );
+    return clone;
+    }
+    
+/**
+* Saves the command to stream 
+* Format: <protocol version: int32><SpokenTextLength: int32><SpokenText descriptor>
+*         <runnable><commandui>
+*/
+EXPORT_C void CVCommand::ExternalizeL( RWriteStream &aStream ) const
+    {
+    aStream << KVCommandProtocolVersion;
+    aStream << static_cast<TInt32>( iSpokenText->Length() );
+    aStream << *iSpokenText;
+    aStream << *iRunnable;
+    aStream << *iCommandUi;
+    }
+    
+EXPORT_C TBool CVCommand::operator==( const CVCommand& aCommand ) const
+    {
+    return (
+            ( *iSpokenText == aCommand.SpokenText() ) &&
+            ( *iRunnable == aCommand.Runnable() ) &&
+            ( *iCommandUi == aCommand.CommandUi() ) 
+           );
+    
+    }	
+
+
+/**
+* @return the Runnable component of the command
+*/
+EXPORT_C const CVCRunnable& CVCommand::Runnable() const
+    {
+    return *iRunnable;
+    }
+
+/**
+* @return the UI-related component of the command
+*/
+EXPORT_C const CVCCommandUi& CVCommand::CommandUi() const
+    {
+    return *iCommandUi;
+    }
+
+/**
+* @return the text, that user is expected to pronounce
+*/
+EXPORT_C const TDesC& CVCommand::SpokenText() const
+    {
+    return *iSpokenText;
+    }
+    
+/**
+* @return the user specified text, that user can pronounce to
+*         recognize the command. Is always identical to the 
+*         CVCommandUi::UserText()
+*         Can be KNullDesC
+*/
+EXPORT_C const TDesC& CVCommand::AlternativeSpokenText() const
+    {
+    return iCommandUi->UserText();
+    }
+    
+/**
+* Asynchronous
+* Attempts to play back the text expected to be recognized. 
+* To be playable command has to be added to CVCommandHandler AND
+* then retrieved back
+*
+* @param aHandler CVCommandHandler where the command is stored
+* @todo Consider storing link to CVCommandHandler within the CVCommand (CStoredVCommand)
+*       Pros: No clumsy aHandler argument for the playback
+*       Pros: No need to remember in which handler the command is stored
+*             and why specifying storage is needed during the playback
+*       Cons: In case of internal link the linked handler should still
+*             exist. It cannot be e.g. destroyed and recreated later even
+*             if the latter one is using the same VAS
+*
+* @param aPlayEventHandler Entity that handles the playback callbacks
+* @see NssVasMPlayEventHandler.h
+*
+* @leave KErrBadHandle if the current command has not been retrieved 
+*        from CVCommandHandler (i.e. was not trained for recognition)
+* @leave KErrNotFound if this command cannot be found in aHandler
+* @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasUnexpectedRequest
+* @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInUse
+* @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInvalidParameter
+* @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                             EVasPlayFailed
+*/
+EXPORT_C void CVCommand::PlaySpokenTextL( const CVCommandHandler& /*aHandler*/, 
+                          MNssPlayEventHandler& /*aPlayEventHandler*/ ) const
+    {
+    RUBY_DEBUG_BLOCK( "CVCommand::PlaySpokenTextL" );
+    RUBY_ERROR0( "Attempt to play never added command" );
+    User::Leave( KErrBadHandle );
+    }
+
+/**
+* Asynchronous
+* Plays back the user-specified alternative spoken text. 
+* Otherwise is identical to PlaySpokenTextL
+* @see PlaySpokenTextL
+* @leave KErrNotFound if this command cannot be found in aHandler of if 
+*        it doesn't have a user-specified text
+*/     
+EXPORT_C void CVCommand::PlayAlternativeSpokenTextL( const CVCommandHandler& /*aHandler*/, 
+                          MNssPlayEventHandler& /*aPlayEventHandler*/ ) const
+    {
+    RUBY_DEBUG_BLOCK( "CVCommand::PlaySpokenTextL" );
+    RUBY_ERROR0( "Attempt to play never added command" );
+    User::Leave( KErrBadHandle );
+    }
+    
+/**
+* Cancels playback of a spoken or alternative spoken text
+* To be playable command has to be added to CVCommandHandler AND
+* then retrieved back. After this function neither HandlePlayStarted,
+* nor HandlePlayComplete will be called
+*
+* @param aHandler CVCommandHandler where the command is stored
+*
+* @leave KErrBadHandle if the current command has not been retrieved 
+*        from CVCommandHandler (i.e. was not trained for recognition)
+* @leave KErrNotReady if playback has never been started
+*
+*/
+EXPORT_C void CVCommand::CancelPlaybackL( const CVCommandHandler& /*aHandler*/ ) const
+    {
+    RUBY_DEBUG_BLOCK( "CVCommand::CancelPlaybackL" );
+    RUBY_ERROR0( "CVCommand::CancelPlaybackL Attempt to cancel playback of the command\
+                  never added to the VCommandHandler" );
+    User::Leave( KErrBadHandle );
+    }
+
+/**
+ * Tells if all non user-changeable parts of aCommand are equal to this command
+ * @return ETrue if equal, EFalse otherwise
+ */
+EXPORT_C TBool CVCommand::EqualNonUserChangeableData( const CVCommand& aCommand ) const
+    {
+    if( SpokenText() != aCommand.SpokenText() ) return EFalse;
+    if( !(Runnable() == aCommand.Runnable() ) ) return EFalse;
+    
+    return CommandUi().EqualNonUserChangeableData( aCommand.CommandUi() );
+    }
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandarray.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CVCommandRunnable class
+*
+*/
+
+
+
+#include <vcommandapi.h>
+#include "rubydebug.h"
+
+/** 
+* Constructs the non-modifiable CVCommandArray
+* @param aSource Commands to store. CVCommandArray makes
+*        copies of them
+*/
+EXPORT_C CVCommandArray* CVCommandArray::NewL( const RVCommandArray& aSource )
+	{
+	RUBY_DEBUG_BLOCK( "CVCommandArray::NewL" );
+	CVCommandArray* self = new (ELeave) CVCommandArray;
+	CleanupStack::PushL( self );
+	self->ConstructL( aSource );
+	CleanupStack::Pop( self );
+	return self;
+	}
+	
+void CVCommandArray::ConstructL( const RVCommandArray& aSource )
+	{
+	RUBY_DEBUG_BLOCKL( "CVCommandArray::ConstructL" );
+	iCommands.ResetAndDestroy();
+	for( TInt j = 0; j < aSource.Count(); j++ ) 
+		{
+		CVCommand* addition = CVCommand::NewL( *aSource[j] );
+		CleanupStack::PushL( addition );
+		iCommands.AppendL( addition );
+		CleanupStack::Pop( addition );
+		}
+	}	
+
+/**
+* Destructor
+*/
+EXPORT_C CVCommandArray::~CVCommandArray()
+	{
+	RUBY_DEBUG0( "CVCommandArray::~CVCommandArray start" );
+	iCommands.ResetAndDestroy();
+	RUBY_DEBUG0( "CVCommandArray::~CVCommandArray end" );
+	}
+
+/**
+* Returns the reference to the command stored in this
+* CVCommandArray
+* @param aIndex Zero-based index of the command. If aIndex is out of
+*               bounds, this method will panic with USER 130
+* @return Unmodifiable reference to CVCommand
+*/
+EXPORT_C const CVCommand& CVCommandArray::At( TInt aIndex ) const
+	{
+	return *iCommands[ aIndex ];
+	}
+
+/**
+* Equivalent to the operator At
+* @see At()
+*/
+EXPORT_C const CVCommand& CVCommandArray::operator[]( TInt aIndex ) const
+	{
+	return At( aIndex );
+	}
+
+/** 
+* Returns the number of commands
+*/
+EXPORT_C TInt CVCommandArray::Count() const
+	{
+	return iCommands.Count();
+	}
+
+/**
+* For the compatibility with routines, requiring RVCommandArray
+* @return Unmodifiable array of pointers to VCommands
+*/
+EXPORT_C const RVCommandArray& CVCommandArray::PointerArray() const
+    {
+    return iCommands;
+    }
+
+/**
+ * Figures out which commands have to untrained (removed from VCommandHandler)
+ * if this command set is merged with aUpdates.
+ * Merging is performed on the basis of comapring the commands' Runnable component
+ * If runnables are equal, the commands are considered being equal.
+ * It is useful e.g. when figuring out what to (un)train after the language change
+ * 
+ * @param aUpdates Set of commands to merge in. 
+ * @return Set of commands to be removed from the system if the merging takes place
+ */
+EXPORT_C CVCommandArray* CVCommandArray::ProduceUntrainSetByRunnablesLC( 
+                            const RVCommandArray& aUpdates ) const
+    {
+    RVCommandArray deduction;
+    CleanupClosePushL( deduction );
+    for( TInt i = 0; i < Count(); i++ )
+        {
+        for( TInt j = 0; j < aUpdates.Count(); j++ )
+            {
+            if( ( At(i).Runnable() == aUpdates[j]->Runnable() ) &&
+                !( At(i).EqualNonUserChangeableData( *aUpdates[j] ) ) 
+               )
+                { 
+                deduction.AppendL( &At(i) );
+                break;
+                }
+            }
+        }
+    CVCommandArray* result = CVCommandArray::NewL( deduction );
+    CleanupStack::PopAndDestroy( &deduction );
+    CleanupStack::PushL( result );
+    return result;
+    }
+    
+/**
+ * Figures out which commands have to trained (removed added to the system)
+ * if this command set is merged with aUpdates.
+ * Merging is performed on the basis of comapring the commands' Runnable component
+ * If runnables are equal, the commands are considered being equal.
+ * It is useful e.g. when figuring out what to (un)train after the language change
+ * 
+ * @param aUpdates Set of commands to merge in. 
+ * @return Set of commands to be added to the system if the merging takes place
+ * @see ProduceUntrainSetByRunnables
+ */
+EXPORT_C CVCommandArray* CVCommandArray::ProduceTrainSetByRunnablesLC( 
+                            const RVCommandArray& aUpdates ) const
+    {
+    RVCommandArray addition;
+    CleanupClosePushL( addition );
+    for( TInt j = 0; j < aUpdates.Count(); j++ )
+        {
+        TBool injectedMatchesSomeTarget = EFalse;
+        for( TInt i = 0; i < Count(); i++ )
+            {
+            if( At(i).EqualNonUserChangeableData( *aUpdates[j] ) )
+                { 
+                injectedMatchesSomeTarget = ETrue;
+                break;
+                }
+            else if( At(i).Runnable() == aUpdates[j]->Runnable() &&
+                     At(i).CommandUi().UserText() != KNullDesC )
+                {
+                CVCCommandUi* updatedCommandUi( NULL );
+                updatedCommandUi = CVCCommandUi::NewL( aUpdates[j]->CommandUi().WrittenText(), 
+                                                       aUpdates[j]->CommandUi().FolderInfo(),
+                                                       aUpdates[j]->CommandUi().Modifiable(),
+                                                       aUpdates[j]->CommandUi().Tooltip(), 
+                                                       aUpdates[j]->CommandUi().IconUid(),
+                                                       At(i).CommandUi().UserText(),
+                                                       aUpdates[j]->CommandUi().ConfirmationNeeded() );
+                CleanupStack::PushL( updatedCommandUi );
+
+                CVCommand* updatedCommand( NULL );
+                updatedCommand = CVCommand::NewL( aUpdates[j]->SpokenText(),
+                                                  aUpdates[j]->Runnable(),
+                                                  *updatedCommandUi );
+                CleanupStack::PushL( updatedCommand );
+
+                addition.AppendL( updatedCommand );
+
+                CleanupStack::Pop( updatedCommand );
+                CleanupStack::PopAndDestroy( updatedCommandUi );
+                
+                injectedMatchesSomeTarget = ETrue;
+                break;
+                }
+            }  // for i
+        if( !injectedMatchesSomeTarget )
+            {
+            addition.AppendL( aUpdates[j] );
+            }  // if
+        }  // for j
+    CVCommandArray* result = CVCommandArray::NewL( addition );
+    CleanupStack::PopAndDestroy( &addition );
+    CleanupStack::PushL( result );
+    return result;
+    }
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Bridge-like class that creates the actual worker and tunnels 
+*                all the client calls to it
+*
+*/
+
+
+#include "rubydebug.h"
+#include <vcommandapi.h>
+#include "vcommandservices.h"
+
+/** 
+* Factory function
+* @param aObserver Listener to be notified whenever the VCommand set is changed
+* 		 by *another* instance of CVCommandHandler. I.e. lets the client know if
+* 		 his understanding of the VCommand set is up to date
+*/ 
+EXPORT_C CVCommandHandler* CVCommandHandler::NewL( MVCommandHandlerObserver* aObserver )
+	{
+	CVCommandHandler* self = new (ELeave) CVCommandHandler;
+	CleanupStack::PushL( self );
+	self->ConstructL( aObserver );
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+void CVCommandHandler::ConstructL( MVCommandHandlerObserver* aObserver )
+	{
+	iImpl = CVCommandService::NewL( aObserver );
+	}
+
+/**
+* Synchronous. Service doesn't take the ownership, but makes an own copy
+* Duplicates can be added
+* @todo should we check for duplicates and leave with KErrAlreadyExists?
+*/
+EXPORT_C void CVCommandHandler::AddCommandL( const CVCommand& aCommand )
+	{
+	iImpl->AddCommandL( aCommand );
+	}
+	
+/**
+* Synchronous. Service doesn't take the ownership, but makes an own copies
+* Duplicates can be added
+* @todo should we check for duplicates and leave with KErrAlreadyExists?
+*/
+EXPORT_C void CVCommandHandler::AddCommandsL( const RVCommandArray& aCommands, 
+                                              TBool aIgnoreErrors )
+    {
+    iImpl->AddCommandsL( aCommands, aIgnoreErrors );
+    }
+
+/**
+* Synchronous. Removes the command from the system
+* @param aCommand Reference to the command to be removed. Existing commands are
+*		 compared against aCommand. All the matches are removed from VAS
+* @leave KErrNotFound No such command
+*/
+EXPORT_C void CVCommandHandler::RemoveCommandL( const CVCommand& aCommand )
+	{
+	iImpl->RemoveCommandL( aCommand );
+	}
+
+/**
+* Synchronous. 
+* @param aCommands Reference to the list of commands to be removed. Existing commands are
+*		 compared against aCommands items. All the matches are removed from VAS
+* @param aIgnoreErrors If ETrue, even if some commands fail to be removed,
+*        handler will remove as many as possible
+*/
+EXPORT_C void CVCommandHandler::RemoveCommandsL( const RVCommandArray& aCommands, 
+		      TBool aIgnoreErrors )
+	{
+	iImpl->RemoveCommandsL( aCommands, aIgnoreErrors );
+	}
+	
+/**
+* Synchronous
+* @return an array of the commands in the system
+*         Ownership of the array is transfered to the client
+*         The returned CVCommandArray contains copies of all the 
+*         commands currently stored in this handler
+*/
+EXPORT_C CVCommandArray* CVCommandHandler::ListCommandsL()
+	{
+	return iImpl->ListCommandsL();
+	}
+
+EXPORT_C CVCommandHandler::~CVCommandHandler()
+	{
+	delete iImpl;
+	}
+
+void CVCommandHandler::PlaySpokenTextL( const CStoredVCommand& aCommand, 
+                                  MNssPlayEventHandler& aPlayEventHandler ) const
+    {
+    iImpl->PlaySpokenTextL( aCommand, aPlayEventHandler );
+    }
+
+void CVCommandHandler::PlayAlternativeSpokenTextL( const CStoredVCommand& aCommand, 
+                                  MNssPlayEventHandler& aPlayEventHandler ) const
+    {
+    iImpl->PlayAlternativeSpokenTextL( aCommand, aPlayEventHandler );
+    }
+    
+/**
+* Not intented to be called directly.
+* @see CVCommand::CancelPlaybackL
+*/                                   
+void CVCommandHandler::CancelPlaybackL( const CStoredVCommand& aCommand ) const
+    {
+    iImpl->CancelPlaybackL( aCommand );
+    }
+    	        	
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandrecoghandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Engine to perform the action corresponding to
+*                the recognized and selected command
+*
+*/
+
+
+#include <nssvasmtag.h>
+#include <vcommandapi.h>
+#include "vcommandinternalapi.h"
+#include "rubydebug.h"
+#include "tagcommandconverter.h"
+#include "vcommandrecoghandler.h"
+
+/**
+* Factory function
+*/
+CVCRecognitionHandler* CVCRecognitionHandler::NewL()
+	{
+	CVCRecognitionHandler* self = new (ELeave) CVCRecognitionHandler;
+	return self;
+	}
+
+// From MNssTagSelectHandler
+/**
+* Handle Tag Select Event - Event indicating a voice tag has been selected.
+* @param aClientTag The voice tag which has been selected. This object is
+*                   resonsible for deleting aClientTag.
+* @return void
+*/
+void CVCRecognitionHandler::HandleTagSelect( MNssTag* aClientTag )
+	{
+	RUBY_DEBUG0( "CVCRecognitionHandler::HandleTagSelect start" );
+	TRAPD( err, HandleTagSelectL( *aClientTag ) );
+	if( err != KErrNone )
+		{
+		RUBY_ERROR1( "CVCRecognitionHandler::HandleTagSelectL failed with [%d] ", err );
+		}
+	
+	delete aClientTag;
+	RUBY_DEBUG0( "CVCRecognitionHandler::HandleTagSelect end" );
+	}
+	
+void CVCRecognitionHandler::HandleTagSelectL( const MNssTag& aTag )
+	{
+	RUBY_DEBUG_BLOCK( "CVCRecognitionHandler::HandleTagSelectL" );
+	CStoredVCommand* command = CTagCommandConverter::TagToCommandLC( aTag );
+	command->Runnable().ExecuteL();
+	CleanupStack::PopAndDestroy( command );
+	}
+	
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandrecogmanager.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constructs / destroyes the recognition selection handler
+*
+*/
+
+
+#include <nssvascvasdbmgr.h>
+#include <nssvasmcontextmgr.h>
+#include <nssvascselectnotificationbuilder.h>
+#include <nssvasmtagselectnotification.h>
+#include "vcommandinternalapi.h"
+#include "rubydebug.h"
+#include "vcommandrecogmanager.h"
+#include "vcommandrecoghandler.h"
+
+/**
+* Factory function
+*/
+EXPORT_C CVCRecognitionManager* CVCRecognitionManager::NewL()
+	{
+	CVCRecognitionManager* self = new (ELeave) CVCRecognitionManager;
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	return self;
+	}
+	
+/**
+* Destructor
+*/	
+EXPORT_C CVCRecognitionManager::~CVCRecognitionManager()
+	{
+	RUBY_DEBUG0( "CVCRecognitionManager::~CVCRecognitionManager start" );
+	delete iRecognitionHandler;
+	delete iSelectNotificationBuilder;
+	RUBY_DEBUG0( "CVCRecognitionManager::~CVCRecognitionManager end" );
+	}
+
+/**
+* Second-phase constructor
+*/
+void CVCRecognitionManager::ConstructL()
+	{
+	RUBY_DEBUG_BLOCK( "CVCRecognitionManager::ConstructL" );
+	CNssVASDBMgr* vasDbManager = CNssVASDBMgr::NewL();
+	CleanupStack::PushL( vasDbManager );
+	
+    vasDbManager->InitializeL();
+    MNssContextMgr* contextManager = vasDbManager->GetContextMgr();
+      
+    iSelectNotificationBuilder = CNssSelectNotificationBuilder::NewL();
+    iSelectNotificationBuilder->InitializeL();
+    MNssTagSelectNotification* tagSelectNotification = 
+    				iSelectNotificationBuilder->GetTagSelectNotification();
+
+    iRecognitionHandler = CVCRecognitionHandler::NewL();
+    
+    MNssContext* context = contextManager->CreateContextL();
+    CleanupDeletePushL( context );
+    context->SetNameL( KVoiceCommandContext );
+    context->SetGlobal( ETrue );
+    tagSelectNotification->RegisterL( context, iRecognitionHandler );
+    // Context is copied inside RegisterL - no need to keep it anymore
+    CleanupStack::PopAndDestroy( context );
+	CleanupStack::PopAndDestroy( vasDbManager );
+	}
+	
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandrunnable.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,268 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CVCommandRunnable class
+*
+*/
+
+
+
+#include <vcommandapi.h>
+#include "rubydebug.h"
+
+#include <apaid.h>
+#include <apgcli.h>
+#include <apacmdln.h>
+#include <apgtask.h>
+#include <eikappui.h>
+
+/**
+* The version of the streamed data protocol
+* It is rather likely, that the format of the data streamed changes in the future.
+* Using the protocol version, the code can check if it knows how to parse the 
+* input stream
+*/
+const TInt32 KVCRunnableProtocolVersion = 2;
+
+/**
+* @leave KErrOverflow if aArguments is longer, than KMaxVCArgumentLength
+* @leave KErrArgument if aAppUid is KNullUidValue
+*/
+EXPORT_C CVCRunnable* CVCRunnable::NewL( TUid aAppUid, const TDesC8& aArguments )
+    {
+    CVCRunnable* self = new ( ELeave ) CVCRunnable;
+    CleanupStack::PushL( self );
+    self->ConstructL( aAppUid, aArguments );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/**
+* Factory function
+* @param aExeName Exe-file to start. Can be full or partical name according to 
+*        the RProcess::Create rules. Cannot be KNullDesC
+* @param aArguments Command line to pass to the application. This object makes
+*        a copy of the passed string
+* @leave KErrOverflow if aArguments is longer, than KMaxVCArgumentLength or 
+*		 aExeName is longer, than KMaxOsName
+* @leave KErrUndeflow if aExeName is empty
+*/
+EXPORT_C CVCRunnable* CVCRunnable::NewL( const TDesC& aExeName, const TDesC8& aArguments )
+	{
+	CVCRunnable* self = new( ELeave ) CVCRunnable;
+	CleanupStack::PushL( self );
+	self->ConstructL( aExeName, aArguments);
+	CleanupStack::Pop( self );
+	return self;
+	}
+    
+/**
+* Copy the existing CVRunnable
+*/
+EXPORT_C CVCRunnable* CVCRunnable::NewL( const CVCRunnable& aOriginal )
+	{
+	CVCRunnable* self = new (ELeave) CVCRunnable;
+	CleanupStack::PushL( self );
+	if( aOriginal.Uid() == KNullUid ) 
+		{
+		self->ConstructL( aOriginal.ExeName(), aOriginal.Arguments() );
+		}
+	else 
+		{
+		self->ConstructL( aOriginal.Uid(), aOriginal.Arguments() );
+		}
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+/** 
+* Internalizes from stream 
+* values are read in the same order as ExternalizeL wrote them
+*/
+EXPORT_C CVCRunnable* CVCRunnable::NewL( RReadStream &aStream )
+    {
+    CVCRunnable* self = new (ELeave) CVCRunnable;
+    CleanupStack::PushL( self );
+    self->ConstructL( aStream );
+    CleanupStack::Pop( self );
+    return self;    
+    }
+    
+void CVCRunnable::ConstructL( RReadStream &aStream )
+	{
+	TInt32 ver;
+    aStream >> ver;
+    __ASSERT_ALWAYS( ver == KVCRunnableProtocolVersion, User::Leave( KErrNotSupported  ) );
+    iExeUid = TUid::Uid( aStream.ReadInt32L() );
+    iArguments = HBufC8::NewL( aStream.ReadInt32L() );
+    TPtr8 pArguments = iArguments->Des();
+    aStream >> pArguments;
+    TInt exeNameLength = aStream.ReadInt32L();
+    if( exeNameLength > 0 )
+    	{
+    	iExeName = HBufC::NewL( exeNameLength );
+    	TPtr pExeName = iExeName->Des();
+	    aStream >> pExeName;
+    	}
+	}
+    
+void CVCRunnable::ConstructL( TUid aAppUid, const TDesC8& aArguments )
+    {
+    __ASSERT_ALWAYS( aArguments.Length() <= KMaxVCArgumentLength, User::Leave( KErrOverflow) );
+    __ASSERT_ALWAYS( aAppUid != KNullUid, User::Leave( KErrArgument ) );
+    iExeUid = TUid::Uid( aAppUid.iUid );
+    iArguments = HBufC8::NewL( aArguments.Length() );
+    *iArguments = aArguments;
+    }
+
+void CVCRunnable::ConstructL( const TDesC& aExeName, const TDesC8& aArguments )
+    {
+    __ASSERT_ALWAYS( aArguments.Length() <= KMaxVCArgumentLength, User::Leave( KErrOverflow) );
+    __ASSERT_ALWAYS( aExeName.Length() <= KMaxFileName, User::Leave( KErrOverflow ) );
+    __ASSERT_ALWAYS( aExeName.Length() > 0, User::Leave( KErrUnderflow ) );
+    iExeName = HBufC::NewL( aExeName.Length() );
+    *iExeName = aExeName;
+    iArguments = HBufC8::NewL( aArguments.Length() );
+    *iArguments = aArguments;
+    }
+
+EXPORT_C CVCRunnable::~CVCRunnable()
+    {
+    delete iExeName;
+    delete iArguments;
+    }
+    
+/** 
+ * Saves the object to stream.
+ * The current format is as follows:
+ * <protocol version: int32><uid: int32; KNullUidValue if no><argument length: int32>
+ * <argument descriptor streamed by the default descriptor ExternalizeL>
+ * <exe filename length><exe filename descriptor only if filename length is not 0>
+ */
+EXPORT_C void CVCRunnable::ExternalizeL( RWriteStream &aStream ) const
+    {
+    aStream << KVCRunnableProtocolVersion;
+    aStream << iExeUid.iUid;
+    aStream << static_cast<TInt32>( iArguments->Length() );
+    aStream << *iArguments;
+    if( iExeName )
+    	{
+    	aStream << static_cast<TInt32>( iExeName->Length() );
+    	aStream << *iExeName;
+    	}
+    else 
+    	{
+    	aStream << static_cast<TInt32>( 0 );
+    	}
+    }
+    
+EXPORT_C TBool CVCRunnable::operator==( const CVCRunnable& aRunnable ) const
+    {
+    return ( 
+            ( Uid() == aRunnable.Uid()) && 
+            ( Arguments() == aRunnable.Arguments() ) &&
+            ( ExeName() == aRunnable.ExeName() )
+           );
+    }
+    
+
+/**
+* @return The uid of the application to be started
+*/
+EXPORT_C const TUid CVCRunnable::Uid() const
+    {
+    return iExeUid;
+    }
+    
+/**
+* @return The filename of the application to be started. KNullDesC if there is none
+*/
+EXPORT_C const TDesC& CVCRunnable::ExeName() const
+	{
+	if( iExeName )
+		{
+		return *iExeName;
+		}
+	else 
+		{
+		return KNullDesC;
+		}
+	}
+
+/**
+* The arguments to be passed to the application
+*/
+EXPORT_C const TDesC8& CVCRunnable::Arguments() const
+    {
+    return *iArguments;
+    }
+    
+/** 
+* Run the command. In case of aAppUid specified during the construction
+* application is started via the RApaLsSession::StartApp, otherwise
+* via the RProcess::Create
+* @leave System-wide error code. In particular KErrNotFound if there is
+*        no such app in the system
+*/
+EXPORT_C void CVCRunnable::ExecuteL() const
+	{
+	RUBY_DEBUG_BLOCK( "CVCRunnable::ExecuteL" );
+	if( iExeName ) 
+		{
+		RProcess process;
+		CleanupClosePushL( process );
+		// Convert arguments into system_number_of_bits-bit descriptor 
+		// (needed for exe, not needed for GUI apps)
+		HBufC* arguments = HBufC::NewLC( iArguments->Length() );
+		arguments->Des().Copy( *iArguments );
+		
+		User::LeaveIfError( process.Create( *iExeName, *arguments) );
+		process.Resume();
+		
+		CleanupStack::PopAndDestroy( arguments );
+		CleanupStack::PopAndDestroy( &process );
+		}
+	else 
+		{
+        const TUid KLogsUID3 = { 270486741 };//101F4CD5
+        //In case logs.exe run in background [EDCN-84B68Q]
+        //todo: General support for this kind of case,
+		//      eg, add "view" keyworkd in defaultvoicecommands.xml...
+        if ( iExeUid == KLogsUID3 )
+            {
+            TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
+            TApaTask task = taskList.FindApp( iExeUid );
+            if( task.Exists() ) //Logs already open. Request it to
+                {               //activate the correct view
+                task.SendMessage( iExeUid, *iArguments );
+                return;
+                }
+            }
+        
+		TApaAppInfo appInfo;
+		RApaLsSession apaLsSession;
+		CleanupClosePushL( apaLsSession );
+		User::LeaveIfError( apaLsSession.Connect() );
+		User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, iExeUid ) );
+		
+		CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+		apaCommandLine->SetExecutableNameL( appInfo.iFullName );
+        apaCommandLine->SetTailEndL( *iArguments );
+        User::LeaveIfError( apaLsSession.StartApp( *apaCommandLine ) );
+
+		CleanupStack::PopAndDestroy( apaCommandLine );
+		CleanupStack::PopAndDestroy( &apaLsSession );
+		}
+	}
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandservices.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,794 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of VCommand Handler that links the VCommand 
+*                app to VAS
+*
+*/
+
+
+#include "rubydebug.h"
+#include "vcommandservices.h"
+#include "contextprovider.h"
+#include "tagnameset.h"
+#include "taggetter.h"
+#include "tagcommandconverter.h"
+#include "tagplayer.h"
+#include <nssvascoreconstant.h>
+
+#include <s32mem.h>
+#include <nssvascvasdbmgr.h>
+#include "vcommandinternalapi.h"
+
+// For CleanupResetAndDestroy
+#include <mmfcontrollerpluginresolver.h>  
+
+
+/**
+* Name of the global mutex used to serialize the operations
+*/
+_LIT( KCommandHandlerLockName, "VCOMHNDLR" );
+
+_LIT( KCommandHandlerPanic, "VCH" );
+
+TAny* TVCommandTagPtrArrayKey::At( TInt aIndex ) const
+    {
+    MNssTag* tag ( NULL );
+    TInt* key (NULL);
+    if ( aIndex==KIndexPtr )
+        {
+        // iPtr is a pointer to the array element which is a pointer itself 
+        // in case of the CArrayPtr
+        tag = *(MNssTag**)iPtr;
+        key = &tag->RRD()->IntArray()->At( 0 );
+        }
+    else 
+        {
+        // iBase is CBufBase* of the searched array
+        // CBufBase memory buffer stores pointers to MNssTag* (i.e. MNssTag**)
+        // iBase->Ptr returns TPtr8 to the desired pointer 
+        // TPtr8.Ptr returns TUint8* of the element
+        // This element itself is a pointer to CPerson (i.e. MNssTag**)
+        tag = *(MNssTag**)iBase->Ptr( aIndex*sizeof( MNssTag** ) ).Ptr();
+        key = &tag->RRD()->IntArray()->At( 0 );
+        }        
+        return key;        
+    }
+    
+// Construction/destruction
+CVCommandService* CVCommandService::NewL( MVCommandHandlerObserver* aObserver )
+    {
+    CVCommandService* self = new (ELeave) CVCommandService( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+CVCommandService::~CVCommandService()
+    {
+    RUBY_DEBUG0( "CVCommandService::~CVCommandService" );
+    delete iGlobalTickWatcher;
+    iGlobalTickProperty.Close();
+    delete iVasDbManager;
+    iCommands.ResetAndDestroy();
+    delete iTagPlayer;
+    if( iLock.IsHeld() )
+        {
+        RUBY_DEBUG0( "CVCommandService::~CVCommandService. Mutex is still held.\
+                     Signaling it" );
+        iLock.Signal();
+        }
+    iLock.Close();
+    }
+   
+// From the MVCService
+
+/**
+* Synchronous. Service doesn't take the ownership, but makes an own copy
+* Duplicates can be added
+* @todo should we check for duplicates and leave with KErrAlreadyExists?
+*/
+void CVCommandService::AddCommandL( const CVCommand& aCommand )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandService::AddCommandL" );
+    StartAtomicOperationLC();
+    
+    RVCommandArray commands;
+    CleanupClosePushL( commands );
+    commands.Append( &aCommand );
+    DoAddCommandsL( commands );
+    
+    CleanupStack::PopAndDestroy( &commands );
+    CleanupStack::PopAndDestroy();  // Calls EndAtomicOperation
+    }
+
+/**
+* Synchronous. Service doesn't take the ownership, but makes an own copy
+* Duplicates can be added
+* @todo Should we check for duplicates and leave with KErrAlreadyExists?
+* @param aIgnoreErrors If ETrue, even if some commands fail to be trained,
+*        handler adds all that are trainable
+*/
+void CVCommandService::AddCommandsL( const RVCommandArray& aCommands, TBool aIgnoreErrors )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandService::AddCommandsL" );
+    StartAtomicOperationLC();
+    DoAddCommandsL( aCommands, aIgnoreErrors );
+    CleanupStack::PopAndDestroy();  // Calls EndAtomicOperation
+    }
+    
+void CVCommandService::DoAddCommandsL( const RVCommandArray& aCommands, TBool aIgnoreErrors )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCommandService::DoAddCommandsL" );
+    MNssContext* context = GetVCommandContextLC();
+    CTagNameSet* trainingPack = CTagNameSet::NewLC();
+    
+    for( TInt i = 0; i < aCommands.Count(); i++ )
+        {
+        CArrayPtr<MNssTag>* tags = CreateTagsLC2( *aCommands[i], *context); 
+        // tags array contains 1 tag if UserText is not defined
+        // tags array contains 2==KMaxTagsPerCommand tags if UserText is defined
+        __ASSERT_ALWAYS( tags->Count() > 0, User::Leave( KErrCorrupt ) );
+        __ASSERT_ALWAYS( tags->Count() <= KMaxTagsPerCommand, User::Leave( KErrCorrupt ) );
+        
+        // All the tags corresponding to the same VCommand get the same command id
+        SetVCommandIdL( *tags, NewCommandIdL() );
+        trainingPack->AppendL( tags->At( 0 ), aCommands[i]->SpokenText() );
+        if( tags->Count() == KMaxTagsPerCommand )
+            {
+            // UserText tag is present and this command has been converted into two tags
+            trainingPack->AppendL( tags->At( 1 ), aCommands[i]->AlternativeSpokenText() );
+            }    
+            
+        CleanupStack::Pop( tags );  // ResetAndDestroy
+        CleanupStack::PopAndDestroy( tags );  // delete the CArrayPtr itself
+        }  // for aCommands
+    
+    
+    CNssTrainingParameters* trainingParams = ConstructTrainingParametersLC();    
+    trainingPack->TrainAndSaveL( *trainingParams, *iTagManager, aIgnoreErrors );
+    CleanupStack::PopAndDestroy( trainingParams );
+    
+    CleanupStack::PopAndDestroy( trainingPack );
+    CleanupStack::PopAndDestroy( context );
+    RUBY_DEBUG0( "CVCH::DoAddCommandsL Context destroyed" );        
+    InvalidateCacheL();
+    }
+
+
+/**
+* Synchronous. Removes the command from the system
+* @param aCommand Reference to the command to be removed. Existing commands are
+*		 compared against aCommand. All the matches are removed from VAS
+* @leave KErrNotFound No such command
+*/
+void CVCommandService::RemoveCommandL( const CVCommand& aCommand )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandService::RemoveCommandL" );
+    StartAtomicOperationLC();
+	RVCommandArray array;
+	CleanupClosePushL( array );
+	array.AppendL( &aCommand );
+	DoRemoveCommandsL( array );
+	CleanupStack::PopAndDestroy( &array );
+    CleanupStack::PopAndDestroy();  // Calls EndAtomicOperation
+    }
+    
+/**
+* Synchronous. 
+* @param aCommands Reference to the list of commands to be removed. Existing commands are
+*		 compared against aCommands items. All the matches are removed from VAS
+* @param aIgnoreErrors If ETrue, even if some commands fail to be removed,
+*        handler will remove as many as possible
+*/
+void CVCommandService::RemoveCommandsL( const RVCommandArray& aCommands, TBool aIgnoreErrors )
+	{
+    RUBY_DEBUG_BLOCK( "RemoveCommandsL" );
+    StartAtomicOperationLC();
+    DoRemoveCommandsL( aCommands, aIgnoreErrors );
+    CleanupStack::PopAndDestroy();  // Calls EndAtomicOperation
+	
+	}
+    
+void CVCommandService::DoRemoveCommandsL( const RVCommandArray& aCommands,
+        						TBool aIgnoreErrors )
+	{
+	// for tracking the not found situations
+	RArray<TBool> foundCommands;
+	CleanupClosePushL( foundCommands );
+	for( TInt i=0; i < aCommands.Count(); i++ )
+	    {
+	    foundCommands.AppendL( EFalse );
+	    }
+	
+	// Iterate over all the tags in the system. Whenever a tag can be converted
+	// to one of the aCommands, move it to the deletion bunch
+	CTagNameSet* removeTags = CTagNameSet::NewLC();
+	MNssContext* context = GetVCommandContextLC();    
+	MNssTagListArray* tags = CVCommandService::GetTagListLC2( *context );
+	for( TInt i = 0; i < tags->Count(); i++ )
+		{
+		CVCommand* command = CTagCommandConverter::TagToCommandLC( *tags->At( i ) );
+		for( TInt j = 0; j < aCommands.Count(); j++ )
+			{
+			if( *command == *aCommands[j] )
+				{
+				RUBY_DEBUG1( "CVCH::RemoveCommandsL Tag [%d] should be deleted", i );
+				foundCommands[j] = ETrue;
+				removeTags->AppendL( tags->At( i ) );  
+				// ownership to removeTags, current tag to be removed from tags => index--
+				tags->Delete( i );
+				i--;
+				break;
+				}
+			}
+		CleanupStack::PopAndDestroy( command );
+		}
+
+    // Handle not founds
+    if( !aIgnoreErrors )
+        {
+        for( TInt i=0; i < foundCommands.Count(); i++ )
+            {
+            if( foundCommands[i] == EFalse )
+                {
+                RUBY_ERROR1( "Command [%d] not found", i );
+                User::Leave( KErrNotFound );
+                }
+            }
+        }
+	// Delete all the discovered tags
+	removeTags->UntrainL( *iTagManager, aIgnoreErrors );
+	
+	CleanupStack::PopAndDestroy( tags );  // ResetAndDestroy
+	CleanupStack::PopAndDestroy( tags );  // delete	
+    CleanupStack::PopAndDestroy( context );
+    CleanupStack::PopAndDestroy( removeTags );
+    CleanupStack::PopAndDestroy( &foundCommands );
+    InvalidateCacheL();
+	}
+        						
+/**
+* Synchronous
+* @return an array of the commands in the system
+*         Ownership of the array is transfered to the client
+*         The returned CVCommandArray contains copies of all the 
+*         commands currently stored in this handler
+*/
+CVCommandArray* CVCommandService::ListCommandsL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandService::ListCommandsL" );
+    StartAtomicOperationLC();
+    if( !IsCacheValidL() )
+    	{
+    	RUBY_DEBUG0( "CVCommandService::ListCommandsL Cache is invalid. \
+    					Refresh the command list" );
+    	RefreshCommandListL();
+    	}
+    
+    CVCommandArray* result = CVCommandArray::NewL( iCommands );
+    CleanupStack::PopAndDestroy();  // Calls EndAtomicOperation
+    return result;
+    }
+
+// Private methods
+
+CVCommandService::CVCommandService( MVCommandHandlerObserver* aObserver ) :
+    iObserver( aObserver )
+    {
+    // nothing
+    }
+
+void CVCommandService::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCommandService::ConstructL" );
+    TInt err = iLock.OpenGlobal( KCommandHandlerLockName );
+    if( err != KErrNone )
+        {
+        RUBY_DEBUG1( "CVCommandService::ConstructL failed to open mutex with [%d].\
+                      Creating a new one", err );
+        err = iLock.CreateGlobal( KCommandHandlerLockName );
+        RUBY_DEBUG1( "CVCommandService::ConstructL. Created mutex. Err [%d]", err );
+        User::LeaveIfError( err );
+        }
+    iTagPlayer = CTagPlayer::NewL();
+    iVasDbManager = CNssVASDBMgr::NewL();
+    iVasDbManager->InitializeL();
+    iTagManager = iVasDbManager->GetTagMgr();
+    TInt propertyErr = RProperty::Define( KSINDUID, ECommandHandlerTickKey, RProperty::EInt );
+    if( ( propertyErr != KErrNone ) && ( propertyErr != KErrAlreadyExists ) )
+        {
+        RUBY_ERROR1( "Attempt to define the ECommandHandlerTickKey flag failed with [%d]", 
+                     propertyErr )
+        User::Leave( propertyErr );
+        }
+    
+    RUBY_DEBUG0( "Attaching to the global tick property" );
+    User::LeaveIfError( iGlobalTickProperty.Attach( KSINDUID, ECommandHandlerTickKey ) );
+    // right after creation, local cache cannot be valid
+    TInt globalTickCount;
+    User::LeaveIfError( iGlobalTickProperty.Get( globalTickCount ) );
+    iLocalTickCount = globalTickCount - 1;
+    
+    iLastSetGlobalTickCount = iLocalTickCount;
+    iGlobalTickWatcher = CIntPropertyWatcher::NewL( KSINDUID, ECommandHandlerTickKey, *this );
+    }
+    
+/**
+* Returns the VCommand context. Creates one on demand if none exists yet
+*/
+MNssContext* CVCommandService::GetVCommandContextLC() const
+    {
+    RUBY_DEBUG0( "CVCommandService::GetVCommandContextL start" );
+    CContextProvider* contextProvider = CContextProvider::NewLC( *iVasDbManager );
+    MNssContext* result = contextProvider->GetVCommandContextLC();
+    CleanupStack::Pop( result );
+    CleanupStack::PopAndDestroy( contextProvider );
+    CleanupDeletePushL( result );
+    RUBY_DEBUG0( "CVCommandService::GetVCommandContextL end" );
+    return result;    
+    }
+    
+    
+/**
+* Constructs a set of new VAS tags from a command and a context. 
+* Does not save to VAS, just creates. Ownership on the created tag is 
+* passed to the client
+*/
+CArrayPtr<MNssTag>* CVCommandService::CreateTagsLC2( const CVCommand& aCommand, 
+                                                     const MNssContext& aContext )
+    {
+    return CTagCommandConverter::CommandToTagsLC2( aCommand, aContext, *iTagManager );
+    }
+    
+/**
+* Constructs training related parameters. Like language to be used
+* @leave negated TNssSpeechItemResult
+* @todo Is it ok to mix system-wide codes with the TNssSpeechItemResult codes
+*/
+CNssTrainingParameters* CVCommandService::ConstructTrainingParametersLC() const
+    {
+    RUBY_DEBUG0( "CVCommandService::SetLanguageParamersL start" );
+    RArray<TLanguage>* languageArray = new (ELeave) RArray<TLanguage>;
+    CleanupDeletePushL ( languageArray ); // Protect [allocated on the heap] array itself
+    CleanupClosePushL( *languageArray );  // Protect the array elements
+    
+    // Always generate a pronunciation in UI language
+    User::LeaveIfError( languageArray->Append( User::Language() ) );
+    
+    // Add an extra language, which can be determined by language identification
+    User::LeaveIfError( languageArray->Append( ELangOther ) );
+
+    CNssTrainingParameters* trainingParams = CNssTrainingParameters::NewL();
+    // No L-functions for some time, delay pushing parameters to the cleanup stack
+    
+    trainingParams->SetLanguages( languageArray );
+    // No need to protect the language array anymore. 
+    // From now on it is managed by the parameters 
+    
+    // For array elements pushed via CleanupClosePushL
+    CleanupStack::Pop( languageArray );
+    CleanupStack::Pop( languageArray );
+    CleanupStack::PushL( trainingParams );
+    RUBY_DEBUG0( "CVCommandService::SetLanguageParamersL end" );
+    return trainingParams;    
+    }
+
+/**
+* Retrieves the list of tags for a given context. Synchronous.
+* Leaves two objects on the cleanup stack!
+* First PopAndDestroy will ResetAndDestroy content
+* Second one will destroy the MNsstagListArray itself
+*/
+MNssTagListArray* CVCommandService::GetTagListLC2( const MNssContext& aContext ) const
+    {
+    RUBY_DEBUG0( "CVCommandService::GetTagListLC start" );
+    CTagGetter* tagGetter = CTagGetter::NewLC();
+    MNssTagListArray* result = tagGetter->GetTagListLC2( *iTagManager, aContext );
+
+    CleanupStack::Pop( result );
+    CleanupStack::Pop( result );
+    CleanupStack::PopAndDestroy( tagGetter );
+    CleanupDeletePushL( result );
+    CleanupResetAndDestroy<MNssTagListArray>::PushL( *result );
+    RUBY_DEBUG0( "CVCommandService::GetTagListLC end" );
+
+    return result;
+    }
+    
+/**
+* Retrieves the list of tags for a given context and voice command id. 
+* Synchronous. Leaves two objects on the cleanup stack!
+* First PopAndDestroy will ResetAndDestroy content
+* Second one will destroy the MNsstagListArray itself
+*/
+MNssTagListArray* CVCommandService::GetTagListLC2( const MNssContext& aContext, 
+                                                   TInt aCommandId ) const
+    {
+    RUBY_DEBUG0( "CVCommandService::GetTagListLC start" );
+    CTagGetter* tagGetter = CTagGetter::NewLC();
+    MNssTagListArray* result = tagGetter->GetTagListLC2( *iTagManager, aContext, aCommandId );
+
+    CleanupStack::Pop( result );
+    CleanupStack::Pop( result );
+    CleanupStack::PopAndDestroy( tagGetter );
+    CleanupDeletePushL( result );
+    CleanupResetAndDestroy<MNssTagListArray>::PushL( *result );
+    RUBY_DEBUG0( "CVCommandService::GetTagListLC end" );
+
+    return result;
+    }
+
+/**
+* Resets iCommands and fills them with the commands from VAS
+*/
+void CVCommandService::RefreshCommandListL()
+	{
+	RUBY_DEBUG_BLOCK( "CVCommandService::RefreshCommandListL" );
+	const TInt KMinimalCommandId = 0;
+	iCommands.ResetAndDestroy();
+	iMaxCommandId = KMinimalCommandId - 1;
+    MNssContext* context = GetVCommandContextLC();
+    MNssTagListArray* tagList = GetTagListLC2( *context );
+    RUBY_DEBUG1( "CVCommandService::RefreshCommandListL Found [%d] tags", tagList->Count() );
+    
+    // Sort array by command ids
+    TVCommandTagPtrArrayKey key( ECmpTInt );
+    tagList->Sort( key );
+    
+    // Array of tags related to the same VCommand
+    CArrayPtrFlat<MNssTag>* commandArray = 
+                new ( ELeave) CArrayPtrFlat<MNssTag>( KMaxTagsPerCommand ); 
+    CleanupStack::PushL( commandArray );
+    // No need for CleanupResetAndDestroyPushL. 
+    // MNssTag objects are not copied to the commandArray
+    
+    TInt currentId = KMinimalCommandId - 1;
+    
+    for( TInt i = 0; i < tagList->Count(); i++ ) 
+        {
+        RUBY_DEBUG1( "CVCommandService::RefreshCommandListL Processing tag [%d]", i );
+        TInt commandId = tagList->At( i )->RRD()->IntArray()->At( 0 );
+        if( currentId != commandId )  // new or first command
+            {
+            if( commandArray->Count() > 0  )
+                {
+                RUBY_DEBUG1( "CVCommandService::RefreshCommandListL Converting [%d] tags to command", commandArray->Count() );
+                CStoredVCommand* command = CTagCommandConverter::TagsToCommandLC( *commandArray );
+                RUBY_DEBUG2( "CVCommandService::RefreshCommandListL Converted successfully to command id [%d], command text [%S]", command->CommandId(), &(command->SpokenText() ) );
+                iCommands.AppendL( command );
+                CleanupStack::Pop( command );
+                }
+            commandArray->Reset();
+            currentId = commandId;
+            }
+        commandArray->AppendL( tagList->At( i ) );
+        iMaxCommandId = Max( iMaxCommandId, commandId );
+        }
+        
+    // Flush the last buffer
+    if( commandArray->Count() > 0  )
+        {
+        RUBY_DEBUG1( "CVCommandService::RefreshCommandListL Converting [%d] tags to command", commandArray->Count() );
+        CStoredVCommand* command = CTagCommandConverter::TagsToCommandLC( *commandArray );
+        RUBY_DEBUG2( "CVCommandService::RefreshCommandListL Converted successfully to command id [%d], command text [%S]", command->CommandId(), &(command->SpokenText() ) );
+        iCommands.AppendL( command );
+        CleanupStack::Pop( command );
+        }
+    CleanupStack::PopAndDestroy( commandArray );
+    CleanupStack::PopAndDestroy( tagList );  // ResetAndDestroy
+    CleanupStack::PopAndDestroy( tagList );  // delete
+    CleanupStack::PopAndDestroy( context );
+    MarkCacheValidL();
+	}
+	
+/**
+* Marks the iCommands as an invalid reflection of the VAS content.
+* To make iCommands reflect the real VAS content a call to 
+* RefreshCommandsL is needed
+*/
+void CVCommandService::InvalidateCacheL()
+	{
+	// Invalidating own cache means unvalidating the other instances' caches as well
+	TInt globalTickCount;
+	User::LeaveIfError( iGlobalTickProperty.Get( globalTickCount ) );
+	
+	iLocalTickCount = globalTickCount;
+    iLastSetGlobalTickCount = globalTickCount + 1;
+	User::LeaveIfError( iGlobalTickProperty.Set( iLastSetGlobalTickCount ) );
+	}
+	
+/**
+* Marks the iCommands as the valid reflection of the VAS content.
+*/
+void CVCommandService::MarkCacheValidL()
+	{
+	// Since all the cache comparison/update functions are executed under the
+	// StartAtomicOperation/EndAtomicOperation, we can be sure that nobody
+	// touched VAS and global tick count since the last IsCacheValidL
+	TInt globalTickCount;
+	User::LeaveIfError( iGlobalTickProperty.Get( globalTickCount ) );
+	
+	iLocalTickCount = globalTickCount;
+	}
+
+/**
+* Tells if the iCommands reflect the content of the VAS DB correctly
+* @return ETrue if the cache is valid, EFalse otherwise
+*/
+TBool CVCommandService::IsCacheValidL()
+	{
+	RUBY_DEBUG_BLOCKL( "CVCommandService::IsCacheValidL" );
+	TInt globalTickCount;
+	User::LeaveIfError( iGlobalTickProperty.Get( globalTickCount ) );
+	RUBY_DEBUG2( "CVCommandService::IsCacheValidL Local tick count [%d], \
+	              globalTickCount [%d]", iLocalTickCount, globalTickCount );
+	return iLocalTickCount == globalTickCount;
+	}
+
+/**
+* Generates new command id to be used for identifying voice tags, that
+* belong to the same VCommand
+*/
+TInt CVCommandService::NewCommandIdL()
+    {
+    if( !IsCacheValidL() )
+        {
+        // Fills the max used command id
+        RefreshCommandListL();
+        }
+    return ++iMaxCommandId;
+    }
+    
+/** 
+* Sets the given aId as a VCommand id for all the tags in the given list
+* This id is set as a first RRD int element of all the given MNssTags.
+* If the RRD int array has no elements yet, one element is added
+*/
+void CVCommandService::SetVCommandIdL( CArrayPtr<MNssTag>& aTags, TInt aId ) const
+    {
+    // All the tags corresponding to the same VCommand get the same command id
+    
+    for( TInt i = 0; i < aTags.Count(); i++ )
+        {
+        if( aTags[i]->RRD()->IntArray()->Count() > 0 ) 
+            {
+            aTags[i]->RRD()->IntArray()->At( i ) = aId;
+            }
+        else 
+            {
+            aTags[i]->RRD()->IntArray()->AppendL( aId );
+            }
+        }
+     }
+
+/**
+* Asynchronous
+* Attempts to play back the text expected to be recognized. 
+* To be playable command has to be added to CVCommandHandler AND
+* then retrieved back
+*
+* @param aHandler CVCommandHandler where the command is stored
+* @param aPlayEventHandler Entity that handles the playback callbacks
+* @see NssVasMPlayEventHandler.h
+*
+* @leave KErrBadHandle if the current command has not been retrieved 
+*        from CVCommandHandler (i.e. was not trained for recognition)
+* @leave KErrNotFound if this command cannot be found in aHandler
+* @leave KErrNotReady @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasUnexpectedRequest
+* @leave KErrInUse @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInUse
+* @leave KErrArgument @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                              EVasInvalidParameter
+* @leave KErrGeneral @see nssvasmspeechitem.h MNssSpeechItem::TNssSpeechItemResult 
+*                                             EVasPlayFailed
+*/
+void CVCommandService::PlaySpokenTextL( const CStoredVCommand& aCommand, 
+                                        MNssPlayEventHandler& aPlayEventHandler )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandService::PlaySpokenTextL" );
+    __ASSERT_ALWAYS( !iPlaybackHandler, User::Leave( KErrInUse  ) );
+    StartAtomicOperationLC();
+    iPlaybackHandler = &aPlayEventHandler;
+    MNssTag* playbackTag = TagByCommandIdTextL( aCommand.CommandId(), 
+                                    aCommand.SpokenText() );
+    if( !playbackTag )
+        {
+        User::Leave( KErrNotFound );
+        }
+    iTagPlayer->PlayTagL( playbackTag, *this ); 
+    CleanupStack::Pop(); // EndOfAtomicOperation
+    }
+
+/**
+* Asynchronous
+* Plays back the user-specified alternative spoken text. 
+* Otherwise is identical to PlaySpokenTextL
+* @see PlaySpokenTextL
+* @leave KErrNotFound if this command cannot be found in aHandler of if 
+*        it doesn't have a user-specified text
+*/     
+void CVCommandService::PlayAlternativeSpokenTextL( const CStoredVCommand& aCommand, 
+                                        MNssPlayEventHandler& aPlayEventHandler )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandService::PlayAlternativeSpokenTextL" );
+    __ASSERT_ALWAYS( !iPlaybackHandler, User::Leave( KErrInUse  ) );
+    StartAtomicOperationLC();
+    iPlaybackHandler = &aPlayEventHandler;
+    MNssTag* playbackTag = TagByCommandIdTextL( aCommand.CommandId(), 
+                                    aCommand.AlternativeSpokenText() );
+    if( !playbackTag )
+        {
+        User::Leave( KErrNotFound );
+        }
+    iTagPlayer->PlayTagL( playbackTag, *this ); 
+    CleanupStack::Pop(); // EndOfAtomicOperation
+    }
+    
+/**
+* This method is not intended to be called directly. 
+* Use CVCommand::CancelPlaybackL instead
+* @see CVCommand::CancelPlaybackL
+* @see CStoredVCommand::CancelPlaybackL
+*/
+void CVCommandService::CancelPlaybackL( const CStoredVCommand& /*aCommand*/ )
+    {
+    // For calling EndOfAtomicOperation if a leave occurs 
+    CreateAndPushEndAtomicCleanupItemL();
+
+    __ASSERT_ALWAYS( iPlaybackHandler, User::Leave( KErrNotReady ) );
+    iTagPlayer->CancelPlaybackL();
+    iPlaybackHandler = NULL;
+    CleanupStack::PopAndDestroy(); // Calls EndAtomicOperation
+    }
+    
+/**
+* The HandlePlayStarted method is a virtual method implemented by the
+* client and is called when play is started
+* @param aDuration - the duration of the utterance data
+*/       
+void CVCommandService::HandlePlayStarted( TTimeIntervalMicroSeconds32 aDuration )
+    {
+    __ASSERT_ALWAYS( iPlaybackHandler, User::Panic( KCommandHandlerPanic, KErrNotReady ) );
+    iPlaybackHandler->HandlePlayStarted( aDuration );
+    }
+
+/**
+* The HandlePlayComplete method is a virtual method implemented by the
+* client and is called when play is completed
+* @param aErrorCode EVasErrorNone if playing was successfull
+*/       
+void CVCommandService::HandlePlayComplete( TNssPlayResult aErrorCode )
+    {
+    __ASSERT_ALWAYS( iPlaybackHandler, User::Panic( KCommandHandlerPanic, KErrNotReady ) );
+    
+    // End atomic operation before calling the observer not to block its potential
+    // VCommandHandler usage from the HandlePlayComplete
+    
+    // Before ending atomic operation, store the current event handler to the 
+    // temporary variable to protect it against the potential change by the new
+    // PlaySpokenTextL call
+    MNssPlayEventHandler* handler = iPlaybackHandler;
+    iPlaybackHandler = NULL;
+    EndAtomicOperation();
+    handler->HandlePlayComplete( aErrorCode );    
+    }
+
+    
+/**
+* Searches vcommand tags for the tag, that corresponds to the given
+* commandId and is trained against the given text
+* @param aCommandId Command id to search for
+* @param aText
+* @return ANY of the voice tags corresponding to the given aCommandId
+*         and aText. Typically there will be one such tag only. However,
+*         if there are several it is not specified which one will be 
+*         returned
+* @return NULL if no satisfying tag is found
+*/
+MNssTag* CVCommandService::TagByCommandIdTextL( TInt aCommandId, const TDesC& aText )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCommandService::TagByCommandIdTextL" );
+    MNssContext* context = GetVCommandContextLC();
+    MNssTagListArray* tagList = GetTagListLC2( *context, aCommandId );
+    // A command can have up to two voice tags. We need to locate the one, 
+    // that has been trained against a given text
+    MNssTag* tag (NULL);
+    for( TInt i = 0; i < tagList->Count(); i++ )
+        {
+        if( tagList->At(i)->SpeechItem()->RawText() == aText )
+            {
+            tag = tagList->At(i);
+            // deletes pointer only. tag will be returned to the calling party
+            tagList->Delete( i );  
+            break;
+            }  // if
+        }  // for
+    CleanupStack::PopAndDestroy( tagList );  // ResetAndDestroy
+    CleanupStack::PopAndDestroy( tagList );  // delete
+    CleanupStack::PopAndDestroy( context );
+    
+    return tag;
+    }
+
+/**
+* Starts the section of the code, that can be simultaneously executed
+* only by a single instance of this class. Other instances have to wait
+* Same as starting the Java "synchronized" method. Puts the function
+* EndAtomicOperation to cleanup stack to make the use leave safe. Subsequent
+* call to CleanupStack::PopAndDestroy will run EndAtomicOperation.
+*/
+void CVCommandService::StartAtomicOperationLC()
+    {
+    RUBY_DEBUG0( "CVCommandService::StartAtomicOperation start" );
+    if ( iLock.IsHeld() )
+        {
+        User::Leave( KErrLocked );
+        }
+        
+    iLock.Wait();
+    
+    CreateAndPushEndAtomicCleanupItemL();
+    
+    RUBY_DEBUG0( "CVCommandService::StartAtomicOperation end" );
+    }
+
+/**
+* Ends the section of the code, that can be simultaneously executed
+* only by a single instance of this class. Other instances have to wait
+* Same as exiting the Java "synchronized" method
+* @leave KErrNotReady if atomic operation hasn't been started
+*/
+void CVCommandService::EndAtomicOperation()
+    {
+    RUBY_DEBUG0( "CVCommandService::EndAtomicOperation start" );
+    __ASSERT_ALWAYS( iLock.IsHeld(), User::Panic( KCommandHandlerPanic, KErrNotReady ) );
+    iLock.Signal();
+    RUBY_DEBUG0( "CVCommandService::EndAtomicOperation end" );
+    }
+    
+/**
+* Runs the EndAtomicOperation when calling CleanupStack::PopAndDestroy after
+* a call to StartAtomicOperationLC
+*/    
+void CVCommandService::CleanupEndAtomicOperation( TAny* aService )
+    {
+    CVCommandService* service = static_cast<CVCommandService*>(aService);
+    service->EndAtomicOperation();
+    }
+
+/**
+* Creates and pushes to cleanup stack a TCleanupItem that calls
+* EndAtomicOperation when CleanupStack::PopAndDestroy is called
+*/   
+void CVCommandService::CreateAndPushEndAtomicCleanupItemL()
+    {
+    TCleanupItem item( CleanupEndAtomicOperation, this );
+    CleanupStack::PushL( item );
+    }
+    
+void CVCommandService::IntValueChanged( TInt aNewValue )
+    {
+    RUBY_DEBUG2( "iLocalTickCount [%d], aNewValue [%d]", iLocalTickCount, aNewValue );
+    if( aNewValue != iLastSetGlobalTickCount )
+        {
+        if( iObserver )
+            {
+            iObserver->CommandSetChanged();
+            }  // if iObserver
+        }  // if local cache is out of date
+    }
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandhandler/src/vcommandui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,250 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CVCommandUi class
+*
+*/
+
+
+#include <vcommandapi.h>
+#include <AknsSkinInstance.h>
+#include <AknsUtils.h>
+#include <gulicon.h>
+#include "rubydebug.h"
+
+/**
+* The version of the streamed data protocol
+* It is rather likely, that the format of the data streamed changes in the future.
+* Using the protocol version, the code can check if it knows how to parse the 
+* input stream
+*/
+const TInt32 KVCCommandUiProtocolVersion = 5;
+
+
+/**
+* This object does not take an ownership of the passed descriptors, 
+* but makes own copies. 
+* 
+* @param aWrittenText Text to display
+* @param aTooltip Second line of the text if ant
+* @param aFolderInfo Folder-related details
+* @param aModifiable If user can modify the command
+* @leave KErrOverflow if descriptors are too big
+*/
+EXPORT_C CVCCommandUi* CVCCommandUi::NewL( const TDesC& aWrittenText, 
+                                  const CVCFolderInfo& aFolderInfo, 
+                                  TBool aModifiable, const TDesC& aTooltip,
+                                  const TUid& aIconUid, const TDesC& aUserText, 
+                                  TBool aConfirmationNeeded ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCCommandUi::NewL" );
+    CVCCommandUi* self = new (ELeave) CVCCommandUi;
+    CleanupStack::PushL( self );
+    self->ConstructL( aWrittenText, aFolderInfo, aModifiable, aTooltip, aIconUid, 
+                      aUserText, aConfirmationNeeded );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/**
+* Copy the existing CVCCommandUi
+*/
+EXPORT_C CVCCommandUi* CVCCommandUi::NewL( const CVCCommandUi& aOriginal )
+    {
+    CVCCommandUi* self = new (ELeave) CVCCommandUi;
+    CleanupStack::PushL( self );
+    self->ConstructL( aOriginal.WrittenText(), aOriginal.FolderInfo(), 
+                      aOriginal.Modifiable(), aOriginal.Tooltip(), 
+                      aOriginal.IconUid(), aOriginal.UserText(),
+                      aOriginal.ConfirmationNeeded() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+/** 
+* Internalizes the command from stream 
+* values are read in the same order as ExternalizeL wrote them
+*/
+EXPORT_C CVCCommandUi* CVCCommandUi::NewL( RReadStream &aStream )
+    {
+    CVCCommandUi* self = new (ELeave) CVCCommandUi;
+    CleanupStack::PushL( self );
+    self->ConstructL( aStream );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+    
+void CVCCommandUi::ConstructL( RReadStream &aStream )
+	{
+	/**
+	* @todo extract the repeated descriptor internalization code into
+	*       a separate method
+	*/
+	TInt32 ver;
+    aStream >> ver;
+    __ASSERT_ALWAYS( ver == KVCCommandUiProtocolVersion, User::Leave( KErrNotSupported  ) );
+    iWrittenText = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pWrittenText = iWrittenText->Des();
+    aStream >> pWrittenText;
+    iFolderInfo = CVCFolderInfo::NewL( aStream );
+    TInt32 intModifiable;
+    aStream >> intModifiable;
+    iUserCanModify = static_cast<TBool>( intModifiable );
+    iTooltip = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pTooltip = iTooltip->Des();
+    aStream >> pTooltip;
+    iIconUid = TUid::Uid( aStream.ReadInt32L() );
+    iUserText = HBufC::NewL( aStream.ReadInt32L() );
+    TPtr pUserText = iUserText->Des();
+    aStream >> pUserText;
+    TInt32 intConfirmationNeeded;
+    aStream >> intConfirmationNeeded;
+    iConfirmationNeeded = static_cast<TBool>( intConfirmationNeeded );
+	}
+    
+    
+/** 
+* Second-phase constructor 
+* @see NewL for guarding conditions
+*/    
+void CVCCommandUi::ConstructL( const TDesC& aWrittenText, const CVCFolderInfo& aFolderInfo,
+                               TBool aModifiable, const TDesC& aTooltip, const TUid& aIconUid,
+                               const TDesC& aUserText, TBool aConfirmationNeeded ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCCommandUi::ConstructL" );
+    iWrittenText = HBufC::NewL( aWrittenText.Length() );
+    *iWrittenText = aWrittenText;
+    iFolderInfo = CVCFolderInfo::NewL( aFolderInfo );
+    iTooltip = HBufC::NewL( aTooltip.Length() );
+    *iTooltip = aTooltip;
+    iUserCanModify = aModifiable;
+    iIconUid = TUid::Uid( aIconUid.iUid );
+    iUserText = HBufC::NewL( aUserText.Length() );
+    *iUserText = aUserText;
+    iConfirmationNeeded = aConfirmationNeeded;
+    }
+    
+EXPORT_C CVCCommandUi::~CVCCommandUi() 
+    {
+    delete iUserText;
+    delete iWrittenText;
+    delete iFolderInfo;
+    delete iTooltip;
+    }
+    
+/** 
+ * Saves the command to stream.
+ * Descriptor components are saved as <length><descriptor> pairs, where 
+ * <length> is TInt32 and <descriptor> is the default descriptor represetation
+ * TBools are saved as TInt32 either
+ */
+EXPORT_C void CVCCommandUi::ExternalizeL( RWriteStream &aStream ) const
+    {
+    aStream << KVCCommandUiProtocolVersion;
+    aStream << static_cast<TInt32>( iWrittenText->Length() );
+    aStream << *iWrittenText;
+    aStream << *iFolderInfo;
+    aStream << static_cast<TInt32> ( iUserCanModify );
+    aStream << static_cast<TInt32>( iTooltip->Length() );
+    aStream << *iTooltip;
+    aStream << iIconUid.iUid;
+    aStream << static_cast<TInt32>( iUserText->Length() );
+    aStream << *iUserText;
+    aStream << static_cast<TInt32> ( iConfirmationNeeded );
+    }
+    
+
+EXPORT_C const TDesC& CVCCommandUi::WrittenText() const 
+    {
+    return *iWrittenText;
+    }
+
+EXPORT_C const TDesC& CVCCommandUi::UserText() const 
+    {
+    return *iUserText;
+    }
+
+EXPORT_C const CVCFolderInfo& CVCCommandUi::FolderInfo() const 
+    {
+    return *iFolderInfo;
+    }
+
+EXPORT_C const TDesC& CVCCommandUi::Tooltip() const 
+    {
+    return *iTooltip;
+    }
+    
+EXPORT_C TBool CVCCommandUi::Modifiable() const
+    {
+    return iUserCanModify;
+    }
+
+EXPORT_C TBool CVCCommandUi::ConfirmationNeeded() const
+    {
+    return iConfirmationNeeded;
+    }
+    
+EXPORT_C const TUid& CVCCommandUi::IconUid() const 
+    {
+    return iIconUid;
+    }
+    
+EXPORT_C TBool CVCCommandUi::operator==( const CVCCommandUi& aCommandUi ) const
+    {
+    return (
+            ( *iWrittenText == aCommandUi.WrittenText() ) &&
+            ( *iFolderInfo == aCommandUi.FolderInfo() ) &&
+            ( *iTooltip == aCommandUi.Tooltip() ) &&
+            ( iUserCanModify == aCommandUi.Modifiable() ) &&
+            ( iIconUid == aCommandUi.IconUid() ) &&
+            ( *iUserText == aCommandUi.UserText() ) &&
+            ( iConfirmationNeeded == aCommandUi.ConfirmationNeeded() )
+           );
+    }
+    
+EXPORT_C CGulIcon* CVCCommandUi::IconLC() const
+	{
+	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+
+    CFbsBitmap* bitmap = NULL;
+    CFbsBitmap* mask = NULL;
+
+	AknsUtils::CreateAppIconLC( skin, IconUid(), EAknsAppIconTypeList, bitmap, mask );
+
+    CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
+    icon->SetBitmapsOwnedExternally( EFalse );
+
+    // icon now owns the bitmaps, no need to keep on cleanup stack.
+    CleanupStack::Pop( 2 ); // mask, bitmap
+
+    CleanupStack::PushL( icon );
+    return icon;
+	}
+
+/**
+ * Tells if all non user-changeable parts of aCommandUi are equal to this object's
+ * @return ETrue if equal, EFalse otherwise
+ */
+EXPORT_C TBool CVCCommandUi::EqualNonUserChangeableData( const CVCCommandUi& aCommandUi ) const
+    {
+    if( WrittenText() != aCommandUi.WrittenText() ) return EFalse;
+    if( !(FolderInfo() == aCommandUi.FolderInfo()) ) return EFalse;    
+    if( Modifiable() != aCommandUi.Modifiable() ) return EFalse;    
+    if( ConfirmationNeeded() != aCommandUi.ConfirmationNeeded() ) return EFalse;    
+    if( Tooltip() != aCommandUi.Tooltip() ) return EFalse;    
+    if( IconUid() != aCommandUi.IconUid() ) return EFalse;    
+    return ETrue;    
+    }
+    
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/data/defaultvoicecommands.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,867 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Automatically generated by sheetconvertor.py
+*             : Do not modify
+*
+*/
+
+
+//  INCLUDES
+#include <defaultvoicecommands.loc>
+#include "voicecommands.rh"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// VCOMMANDS
+// Key value pairs of localized voice command strings
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE VCOMMANDS voicecommands
+    {
+    items =
+        {
+     
+        // Folder title pane - main
+        VCOMMANDITEM
+            {
+            key = 0;
+            txt = main;
+            },
+
+        // Tooltip logical string - Music Player
+        VCOMMANDITEM
+            {
+            key = 10001;
+            txt = qtn_vc_info_popup_text_gen;
+            },
+
+        // Tooltip logical string - Bluetooth
+        VCOMMANDITEM
+            {
+            key = 10002;
+            txt = qtn_vc_info_popup_text_binary;
+            },
+
+        // Tooltip logical string - New MMS postcard
+        VCOMMANDITEM
+            {
+            key = 10003;
+            txt = qtn_vc_info_popup_text_msg;
+            },
+
+        // Tooltip logical string - Offline
+        VCOMMANDITEM
+            {
+            key = 10004;
+            txt = qtn_vc_info_popup_text_prof;
+            },
+
+        // Tooltip logical string - What time is it
+        VCOMMANDITEM
+            {
+            key = 10006;
+            txt = qtn_vc_info_popup_text_time;
+            },
+
+        // Tooltip logical string - Play
+        VCOMMANDITEM
+            {
+            key = 10012;
+            txt = qtn_vc_info_popup_text_play;
+            },
+
+        // Tooltip logical string - Pause
+        VCOMMANDITEM
+            {
+            key = 10013;
+            txt = qtn_vc_info_popup_text_pause;
+            },
+
+        // Tooltip logical string - Stop
+        VCOMMANDITEM
+            {
+            key = 10014;
+            txt = qtn_vc_info_popup_text_stop;
+            },
+
+        // Tooltip logical string - Next song
+        VCOMMANDITEM
+            {
+            key = 10015;
+            txt = qtn_vc_info_popup_text_next;
+            },
+
+        // Tooltip logical string - Next channel
+        VCOMMANDITEM
+            {
+            key = 10016;
+            txt = qtn_vc_info_popup_text_radionext;
+            },
+
+        // Tooltip logical string - Previous song
+        VCOMMANDITEM
+            {
+            key = 10017;
+            txt = qtn_vc_info_popup_text_prev;
+            },
+
+        // Tooltip logical string - Previous channel
+        VCOMMANDITEM
+            {
+            key = 10018;
+            txt = qtn_vc_info_popup_text_radioprev;
+            },
+
+        // Tooltip logical string - Volume up
+        VCOMMANDITEM
+            {
+            key = 10019;
+            txt = qtn_vc_info_popup_text_vup;
+            },
+
+        // Tooltip logical string - Volume down
+        VCOMMANDITEM
+            {
+            key = 10020;
+            txt = qtn_vc_info_popup_text_vdown;
+            },
+        
+        // Tooltip logical string - New Mail
+        VCOMMANDITEM
+            {
+            key = 10021;
+            txt = qtn_vc_info_popup_text_mail;
+            },
+                
+        // Logical string (written) - Browser
+        VCOMMANDITEM
+            {
+            key = 101;
+            txt = qtn_vc_main_services;
+            },
+
+        // Logical string (written) - Navigator
+        VCOMMANDITEM
+            {
+            key = 102;
+            txt = qtn_vc_main_blid;
+            },
+
+        // Logical string (written) - Bluetooth
+        VCOMMANDITEM
+            {
+            key = 103;
+            txt = qtn_vc_main_bt;
+            },
+
+        // Logical string (written) - Phonebook
+        VCOMMANDITEM
+            {
+            key = 104;
+            txt = qtn_vc_main_phonebook;
+            },
+
+        // Logical string (written) - Logs
+        VCOMMANDITEM
+            {
+            key = 105;
+            txt = qtn_vc_main_logs;
+            },
+
+        // Logical string (written) - Application manager
+        VCOMMANDITEM
+            {
+            key = 106;
+            txt = qtn_vc_main_am;
+            },
+
+        // Logical string (written) - Personalisation
+        VCOMMANDITEM
+            {
+            key = 107;
+            txt = qtn_vc_main_skins;
+            },
+
+        // Logical string (written) - Help
+        VCOMMANDITEM
+            {
+            key = 108;
+            txt = qtn_vc_main_help;
+            },
+
+        // Logical string (written) - Profiles
+        VCOMMANDITEM
+            {
+            key = 109;
+            txt = qtn_vc_command_profiles;
+            },
+
+        // Logical string (written) - Voice mail
+        VCOMMANDITEM
+            {
+            key = 110;
+            txt = qtn_vc_main_mail;
+            },
+
+        // Logical string (written) - Chinese dictionary
+        VCOMMANDITEM
+            {
+            key = 111;
+            txt = qtn_vc_main_dict;
+            },
+
+        // Logical string (written) - Voice commands
+        VCOMMANDITEM
+            {
+            key = 112;
+            txt = qtn_vc_main_vc;
+            },
+
+        // Logical string (written) - Settings
+        VCOMMANDITEM
+            {
+            key = 113;
+            txt = qtn_vc_main_settings;
+            },
+
+        // Logical string (written) - Landmarks
+        VCOMMANDITEM
+            {
+            key = 114;
+            txt = qtn_vc_main_lm;
+            },
+
+        // Logical string (written) - Device manager
+        VCOMMANDITEM
+            {
+            key = 115;
+            txt = qtn_vc_main_dm;
+            },
+
+        // Logical string (written) - Connection manager
+        VCOMMANDITEM
+            {
+            key = 116;
+            txt = qtn_vc_main_cmon;
+            },
+
+        // Logical string (written) - Notepad
+        VCOMMANDITEM
+            {
+            key = 117;
+            txt = qtn_vc_main_notepad;
+            },
+
+        // Logical string (written) - Calculator
+        VCOMMANDITEM
+            {
+            key = 118;
+            txt = qtn_vc_main_calculator;
+            },
+
+        // Logical string (written) - Converter
+        VCOMMANDITEM
+            {
+            key = 119;
+            txt = qtn_vc_main_converter;
+            },
+
+        // Logical string (written) - Data synchronisation
+        VCOMMANDITEM
+            {
+            key = 120;
+            txt = qtn_vc_main_datasync;
+            },
+
+        // Logical string (written) - Clock
+        VCOMMANDITEM
+            {
+            key = 121;
+            txt = qtn_vc_main_clock;
+            },
+
+        // Logical string (written) - File manager
+        VCOMMANDITEM
+            {
+            key = 123;
+            txt = qtn_vc_main_fmgr;
+            },
+
+        // Logical string (written) - Calendar
+        VCOMMANDITEM
+            {
+            key = 124;
+            txt = qtn_vc_main_calendar;
+            },
+
+        // Logical string (written) - Speed dialing
+        VCOMMANDITEM
+            {
+            key = 125;
+            txt = qtn_vc_main_sd;
+            },
+
+        // Logical string (written) - Instant messaging
+        VCOMMANDITEM
+            {
+            key = 126;
+            txt = qtn_vc_main_instant;
+            },
+
+        // Logical string (written) - Messaging
+        VCOMMANDITEM
+            {
+            key = 127;
+            txt = qtn_vc_main_messaging;
+            },
+
+        // Logical string (written) - New message
+        VCOMMANDITEM
+            {
+            key = 128;
+            txt = qtn_vc_main_message_editor;
+            },
+
+        // Logical string (written) - New e-mail
+        VCOMMANDITEM
+            {
+            key = 129;
+            txt = qtn_vc_main_email_editor;
+            },
+
+        // Logical string (written) - Radio
+        VCOMMANDITEM
+            {
+            key = 130;
+            txt = qtn_vc_main_radio;
+            },
+
+        // Logical string (written) - Cameras
+        VCOMMANDITEM
+            {
+            key = 131;
+            txt = qtn_vc_main_camcorder;
+            },
+
+        // Logical string (written) - Voice recorder
+        VCOMMANDITEM
+            {
+            key = 132;
+            txt = qtn_vc_main_recorder;
+            },
+
+        // Logical string (written) - Photos
+        VCOMMANDITEM
+            {
+            key = 133;
+            txt = qtn_vc_main_photos;
+            },
+
+        // Logical string (written) - Real Player
+        VCOMMANDITEM
+            {
+            key = 134;
+            txt = qtn_vc_main_mp;
+            },
+
+        // Logical string (written) - Music Player
+        VCOMMANDITEM
+            {
+            key = 135;
+            txt = qtn_vc_main_music;
+            },
+
+        // Logical string (written) - New MMS postcard
+        VCOMMANDITEM
+            {
+            key = 136;
+            txt = qtn_vc_main_postcard;
+            },
+            
+        // Logical string (written) - Video Player
+        VCOMMANDITEM
+            {
+            key = 137;
+            txt = qtn_vc_main_mp_nonbranded;
+            },
+            
+        // Folder - qtn_vc_main_tools
+        VCOMMANDITEM
+            {
+            key = 20002;
+            txt = qtn_vc_main_tools;
+            },
+
+        // Folder - qtn_vc_main_organizer
+        VCOMMANDITEM
+            {
+            key = 20003;
+            txt = qtn_vc_main_organizer;
+            },
+
+        // Folder - qtn_vc_main_messaging_folder
+        VCOMMANDITEM
+            {
+            key = 20004;
+            txt = qtn_vc_main_messaging_folder;
+            },
+
+        // Folder - qtn_vc_main_media
+        VCOMMANDITEM
+            {
+            key = 20005;
+            txt = qtn_vc_main_media;
+            },
+
+        // Logical string (written) - What time is it
+        VCOMMANDITEM
+            {
+            key = 226;
+            txt = qtn_vc_main_time;
+            },
+
+        // Logical string (written) - Play
+        VCOMMANDITEM
+            {
+            key = 230;
+            txt = qtn_vc_media_play;
+            },
+
+        // Logical string (written) - Pause
+        VCOMMANDITEM
+            {
+            key = 231;
+            txt = qtn_vc_media_pause;
+            },
+
+        // Logical string (written) - Stop
+        VCOMMANDITEM
+            {
+            key = 232;
+            txt = qtn_vc_media_stop;
+            },
+
+        // Logical string (written) - Next song
+        VCOMMANDITEM
+            {
+            key = 233;
+            txt = qtn_vc_media_next;
+            },
+
+        // Logical string (written) - Next channel
+        VCOMMANDITEM
+            {
+            key = 234;
+            txt = qtn_vc_media_radionext;
+            },
+
+        // Logical string (written) - Previous song
+        VCOMMANDITEM
+            {
+            key = 235;
+            txt = qtn_vc_media_previous;
+            },
+
+        // Logical string (written) - Previous channel
+        VCOMMANDITEM
+            {
+            key = 236;
+            txt = qtn_vc_media_radioprevious;
+            },
+
+        // Logical string (written) - Volume up
+        VCOMMANDITEM
+            {
+            key = 237;
+            txt = qtn_vc_media_volume_up;
+            },
+
+        // Logical string (written) - Volume down
+        VCOMMANDITEM
+            {
+            key = 238;
+            txt = qtn_vc_media_volume_down;
+            },
+
+        // Folder title pane - qtn_vc_title_tools
+        VCOMMANDITEM
+            {
+            key = 30002;
+            txt = qtn_vc_title_tools;
+            },
+
+        // Folder title pane - qtn_vc_title_organizer
+        VCOMMANDITEM
+            {
+            key = 30003;
+            txt = qtn_vc_title_organizer;
+            },
+
+        // Folder title pane - qtn_vc_title_messaging
+        VCOMMANDITEM
+            {
+            key = 30004;
+            txt = qtn_vc_title_messaging;
+            },
+
+        // Folder title pane - qtn_vc_title_media
+        VCOMMANDITEM
+            {
+            key = 30005;
+            txt = qtn_vc_title_media;
+            },
+
+        // Logical string (spoken) - Browser
+        VCOMMANDITEM
+            {
+            key = 9101;
+            txt = qan_vc_main_services;
+            },
+
+        // Logical string (spoken) - Navigator
+        VCOMMANDITEM
+            {
+            key = 9102;
+            txt = qan_vc_main_blid;
+            },
+
+        // Logical string (spoken) - Bluetooth
+        VCOMMANDITEM
+            {
+            key = 9103;
+            txt = qan_vc_main_bt;
+            },
+
+        // Logical string (spoken) - Phonebook
+        VCOMMANDITEM
+            {
+            key = 9104;
+            txt = qan_vc_main_phonebook;
+            },
+
+        // Logical string (spoken) - Logs
+        VCOMMANDITEM
+            {
+            key = 9105;
+            txt = qan_vc_main_logs;
+            },
+
+        // Logical string (spoken) - Application manager
+        VCOMMANDITEM
+            {
+            key = 9106;
+            txt = qan_vc_main_am;
+            },
+
+        // Logical string (spoken) - Personalisation
+        VCOMMANDITEM
+            {
+            key = 9107;
+            txt = qan_vc_main_skins;
+            },
+
+        // Logical string (spoken) - Help
+        VCOMMANDITEM
+            {
+            key = 9108;
+            txt = qan_vc_main_help;
+            },
+
+        // Logical string (spoken) - Profiles
+        VCOMMANDITEM
+            {
+            key = 9109;
+            txt = qan_vc_command_profiles;
+            },
+
+        // Logical string (spoken) - Voice mail
+        VCOMMANDITEM
+            {
+            key = 9110;
+            txt = qan_vc_main_mail;
+            },
+
+        // Logical string (spoken) - Chinese dictionary
+        VCOMMANDITEM
+            {
+            key = 9111;
+            txt = qan_vc_main_dict;
+            },
+
+        // Logical string (spoken) - Voice commands
+        VCOMMANDITEM
+            {
+            key = 9112;
+            txt = qan_vc_main_vc;
+            },
+
+        // Logical string (spoken) - Settings
+        VCOMMANDITEM
+            {
+            key = 9113;
+            txt = qan_vc_main_settings;
+            },
+
+        // Logical string (spoken) - Landmarks
+        VCOMMANDITEM
+            {
+            key = 9114;
+            txt = qan_vc_main_lm;
+            },
+
+        // Logical string (spoken) - Device manager
+        VCOMMANDITEM
+            {
+            key = 9115;
+            txt = qan_vc_main_dm;
+            },
+
+        // Logical string (spoken) - Connection manager
+        VCOMMANDITEM
+            {
+            key = 9116;
+            txt = qan_vc_main_cmon;
+            },
+
+        // Logical string (spoken) - Notepad
+        VCOMMANDITEM
+            {
+            key = 9117;
+            txt = qan_vc_main_notepad;
+            },
+
+        // Logical string (spoken) - Calculator
+        VCOMMANDITEM
+            {
+            key = 9118;
+            txt = qan_vc_main_calculator;
+            },
+
+        // Logical string (spoken) - Converter
+        VCOMMANDITEM
+            {
+            key = 9119;
+            txt = qan_vc_main_converter;
+            },
+
+        // Logical string (spoken) - Data synchronisation
+        VCOMMANDITEM
+            {
+            key = 9120;
+            txt = qan_vc_main_datasync;
+            },
+
+        // Logical string (spoken) - Clock
+        VCOMMANDITEM
+            {
+            key = 9121;
+            txt = qan_vc_main_clock;
+            },
+
+        // Logical string (spoken) - File manager
+        VCOMMANDITEM
+            {
+            key = 9123;
+            txt = qan_vc_main_fmgr;
+            },
+
+        // Logical string (spoken) - Calendar
+        VCOMMANDITEM
+            {
+            key = 9124;
+            txt = qan_vc_main_calendar;
+            },
+
+        // Logical string (spoken) - Speed dialing
+        VCOMMANDITEM
+            {
+            key = 9125;
+            txt = qan_vc_main_sd;
+            },
+
+        // Logical string (spoken) - Instant messaging
+        VCOMMANDITEM
+            {
+            key = 9126;
+            txt = qan_vc_main_instant;
+            },
+
+        // Logical string (spoken) - Messaging
+        VCOMMANDITEM
+            {
+            key = 9127;
+            txt = qan_vc_main_messaging;
+            },
+
+        // Logical string (spoken) - New message
+        VCOMMANDITEM
+            {
+            key = 9128;
+            txt = qan_vc_main_message_editor;
+            },
+
+        // Logical string (spoken) - New e-mail
+        VCOMMANDITEM
+            {
+            key = 9129;
+            txt = qan_vc_main_email_editor;
+            },
+
+        // Logical string (spoken) - Radio
+        VCOMMANDITEM
+            {
+            key = 9130;
+            txt = qan_vc_main_radio;
+            },
+
+        // Logical string (spoken) - Cameras
+        VCOMMANDITEM
+            {
+            key = 9131;
+            txt = qan_vc_main_camcorder;
+            },
+
+        // Logical string (spoken) - Voice recorder
+        VCOMMANDITEM
+            {
+            key = 9132;
+            txt = qan_vc_main_recorder;
+            },
+
+        // Logical string (spoken) - Photos
+        VCOMMANDITEM
+            {
+            key = 9133;
+            txt = qan_vc_main_photos;
+            },
+
+        // Logical string (spoken) - Real Player
+        VCOMMANDITEM
+            {
+            key = 9134;
+            txt = qan_vc_main_mp;
+            },
+
+        // Logical string (spoken) - Music Player
+        VCOMMANDITEM
+            {
+            key = 9135;
+            txt = qan_vc_main_music;
+            },
+
+        // Logical string (spoken) - New MMS postcard
+        VCOMMANDITEM
+            {
+            key = 9136;
+            txt = qan_vc_main_postcard;
+            },
+            
+        // Logical string (spoken) - Video Player
+        VCOMMANDITEM
+            {
+            key = 9137;
+            txt = qan_vc_main_mp_nonbranded;
+            },
+            
+        // Logical string (spoken) - What time is it
+        VCOMMANDITEM
+            {
+            key = 9226;
+            txt = qan_vc_main_time;
+            },
+
+        // Logical string (spoken) - Play
+        VCOMMANDITEM
+            {
+            key = 9230;
+            txt = qan_vc_media_play;
+            },
+
+        // Logical string (spoken) - Pause
+        VCOMMANDITEM
+            {
+            key = 9231;
+            txt = qan_vc_media_pause;
+            },
+
+        // Logical string (spoken) - Stop
+        VCOMMANDITEM
+            {
+            key = 9232;
+            txt = qan_vc_media_stop;
+            },
+
+        // Logical string (spoken) - Next song
+        VCOMMANDITEM
+            {
+            key = 9233;
+            txt = qan_vc_media_next;
+            },
+
+        // Logical string (spoken) - Next channel
+        VCOMMANDITEM
+            {
+            key = 9234;
+            txt = qan_vc_media_radionext;
+            },
+
+        // Logical string (spoken) - Previous song
+        VCOMMANDITEM
+            {
+            key = 9235;
+            txt = qan_vc_media_previous;
+            },
+
+        // Logical string (spoken) - Previous channel
+        VCOMMANDITEM
+            {
+            key = 9236;
+            txt = qan_vc_media_radioprevious;
+            },
+
+        // Logical string (spoken) - Volume up
+        VCOMMANDITEM
+            {
+            key = 9237;
+            txt = qan_vc_media_volume_up;
+            },
+
+        // Logical string (spoken) - Volume down
+        VCOMMANDITEM
+            {
+            key = 9238;
+            txt = qan_vc_media_volume_down;
+            }
+
+        };
+    }
+
+// -----------------------------------------------------------------------------
+//   
+// VCOMMANDINTEGERS
+// Key value pairs of integers
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE VCOMMANDINTEGERS vcommandintegers
+    {
+    intitems =
+        {
+        // Nothing
+        };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/data/vcommandmanager.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application resource file of VCommandManager
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    VCMR
+
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <appinfo.rh>
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF r_default_document_name { buf=""; }
+
+RESOURCE EIK_APP_INFO { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/data/vcommandmanager_reg.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application registration resource file of VCommandManager
+*
+*/
+
+
+// ========== INCLUDE FILES ===================================================
+
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+// ========== CONSTANTS =======================================================
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x102818E7 // Define your application UID here
+
+// ========== RESOURCE DEFINITIONS ============================================
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "vcommandmanager";
+    launch = KAppLaunchInBackground;
+    hidden = KAppIsHidden;
+    }
+
+// End of File.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/data/voicecommands.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,463 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  NSS voice commands localization resource
+*
+*/
+
+
+//  INCLUDES
+#include <defaultvoicecommands.loc>
+#include "voicecommands.rh"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// VCOMMANDS
+// Key value pairs of localized voice command strings
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE VCOMMANDS voicecommands
+    {
+    items =
+        {
+     
+// --- Folder texts start ---        
+        
+        // Folder qtn_vc_main_media
+        VCOMMANDITEM
+            {
+            key = 20005;
+            txt = qtn_vc_main_media;
+            },
+        // Folder qtn_vc_main_calendar_folder
+        VCOMMANDITEM
+            {
+            key = 20006;
+            txt = qtn_vc_main_calendar_folder;
+            },
+        // Folder qtn_vc_main_statusinfo
+        VCOMMANDITEM
+            {
+            key = 20007;
+            txt = qtn_vc_main_statusinfo;
+            },
+        
+// --- Folder texts end ---
+
+// --- Folder title texts start ---
+
+        // Folder title qtn_vc_title_calendar
+        VCOMMANDITEM
+            {
+            key = 30006;
+            txt = qtn_vc_title_calendar;
+            },
+        // Folder title qtn_vc_title_statusinfo
+        VCOMMANDITEM
+            {
+            key = 30007;
+            txt = qtn_vc_title_statusinfo;
+            },
+
+// --- Folder title texts end ---
+                
+// --- Tooltip texts start ---
+        
+        // Tooltip qtn_vc_info_popup_text_calcommand
+        VCOMMANDITEM
+            {
+            key = 10005;
+            txt = qtn_vc_info_popup_text_calcommand;
+            },
+        // Tooltip qtn_vc_info_popup_text_operator
+        VCOMMANDITEM
+            {
+            key = 10007;
+            txt = qtn_vc_info_popup_text_operator;
+            },
+        // Tooltip qtn_vc_info_popup_text_battery
+        VCOMMANDITEM
+            {
+            key = 10008;
+            txt = qtn_vc_info_popup_text_battery;
+            },
+        // Tooltip qtn_vc_info_popup_text_signal
+        VCOMMANDITEM
+            {
+            key = 10009;
+            txt = qtn_vc_info_popup_text_signal;
+            },
+            
+// --- Tooltip texts end ---        
+        
+
+// --- Voice commands start ---
+        
+        // Show today (written)
+        VCOMMANDITEM
+            {
+            key = 201;
+            txt = qtn_vc_calendar_calendartoday;
+            },
+        // Show today (spoken)
+        VCOMMANDITEM
+            {
+            key = 9201;
+            txt = qan_vc_calendar_calendartoday;
+            },
+        // Show tomorrow (written)
+        VCOMMANDITEM
+            {
+            key = 202;
+            txt = qtn_vc_calendar_calendartomorrow;
+            },
+        // Show tomorrow (spoken)
+        VCOMMANDITEM
+            {
+            key = 9202;
+            txt = qan_vc_calendar_calendartomorrow;
+            },
+        // Show Monday (written)
+        VCOMMANDITEM
+            {
+            key = 203;
+            txt = qtn_vc_calendar_calendarmonday;
+            },
+        // Show Monday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9203;
+            txt = qan_vc_calendar_calendarmonday;
+            },
+        // Show Tuesday (written)
+        VCOMMANDITEM
+            {
+            key = 204;
+            txt = qtn_vc_calendar_calendartuesday;
+            },
+        // Show Tuesday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9204;
+            txt = qan_vc_calendar_calendartuesday;
+            },
+        // Show Wednesday (written)
+        VCOMMANDITEM
+            {
+            key = 205;
+            txt = qtn_vc_calendar_calendarwednesday;
+            },
+        // Show Wednesday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9205;
+            txt = qan_vc_calendar_calendarwednesday;
+            },
+        // Show Thursday (written)
+        VCOMMANDITEM
+            {
+            key = 206;
+            txt = qtn_vc_calendar_calendarthursday;
+            },
+        // Show Thursday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9206;
+            txt = qan_vc_calendar_calendarthursday;
+            },
+        // Show Friday (written)
+        VCOMMANDITEM
+            {
+            key = 207;
+            txt = qtn_vc_calendar_calendarfriday;
+            },
+        // Show Friday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9207;
+            txt = qan_vc_calendar_calendarfriday;
+            },
+        // Show Saturday (written)
+        VCOMMANDITEM
+            {
+            key = 208;
+            txt = qtn_vc_calendar_calendarsaturday;
+            },
+        // Show Saturday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9208;
+            txt = qan_vc_calendar_calendarsaturday;
+            },
+        // Show Sunday (written)
+        VCOMMANDITEM
+            {
+            key = 209;
+            txt = qtn_vc_calendar_calendarsunday;
+            },
+        // Show Sunday (spoken)
+        VCOMMANDITEM
+            {
+            key = 9209;
+            txt = qan_vc_calendar_calendarsunday;
+            },
+        // Show this week (written)
+        VCOMMANDITEM
+            {
+            key = 210;
+            txt = qtn_vc_calendar_calendarthisweek;
+            },
+        // Show this week (spoken)
+        VCOMMANDITEM
+            {
+            key = 9210;
+            txt = qan_vc_calendar_calendarthisweek;
+            },
+        // Show next week (written)
+        VCOMMANDITEM
+            {
+            key = 211;
+            txt = qtn_vc_calendar_calendarnextweek;
+            },
+        // Show next week (spoken)
+        VCOMMANDITEM
+            {
+            key = 9211;
+            txt = qan_vc_calendar_calendarnextweek;
+            },
+        // Show this month (written)
+        VCOMMANDITEM
+            {
+            key = 212;
+            txt = qtn_vc_calendar_calendarthismonth;
+            },
+        // Show this month (spoken)
+        VCOMMANDITEM
+            {
+            key = 9212;
+            txt = qan_vc_calendar_calendarthismonth;
+            },
+        // Show next month (written)
+        VCOMMANDITEM
+            {
+            key = 213;
+            txt = qtn_vc_calendar_calendarnextmonth;
+            },
+        // Show next month (spoken)
+        VCOMMANDITEM
+            {
+            key = 9213;
+            txt = qan_vc_calendar_calendarnextmonth;
+            },
+        // Show January (written)
+        VCOMMANDITEM
+            {
+            key = 214;
+            txt = qtn_vc_calendar_calendarjanuary;
+            },
+        // Show January (spoken)
+        VCOMMANDITEM
+            {
+            key = 9214;
+            txt = qan_vc_calendar_calendarjanuary;
+            },
+        // Show February (written)
+        VCOMMANDITEM
+            {
+            key = 215;
+            txt = qtn_vc_calendar_calendarfebruary;
+            },
+        // Show February (spoken)
+        VCOMMANDITEM
+            {
+            key = 9215;
+            txt = qan_vc_calendar_calendarfebruary;
+            },
+        // Show March (written)
+        VCOMMANDITEM
+            {
+            key = 216;
+            txt = qtn_vc_calendar_calendarmarch;
+            },
+        // Show March (spoken)
+        VCOMMANDITEM
+            {
+            key = 9216;
+            txt = qan_vc_calendar_calendarmarch;
+            },
+        // Show April (written)
+        VCOMMANDITEM
+            {
+            key = 217;
+            txt = qtn_vc_calendar_calendarapril;
+            },
+        // Show April (spoken)
+        VCOMMANDITEM
+            {
+            key = 9217;
+            txt = qan_vc_calendar_calendarapril;
+            },
+        // Show May (written)
+        VCOMMANDITEM
+            {
+            key = 218;
+            txt = qtn_vc_calendar_calendarmay ;
+            },
+        // Show May (spoken)
+        VCOMMANDITEM
+            {
+            key = 9218;
+            txt = qan_vc_calendar_calendarmay ;
+            },
+        // Show June (written)
+        VCOMMANDITEM
+            {
+            key = 219;
+            txt = qtn_vc_calendar_calendarjune;
+            },
+        // Show June (spoken)
+        VCOMMANDITEM
+            {
+            key = 9219;
+            txt = qan_vc_calendar_calendarjune;
+            },
+        // Show July (written)
+        VCOMMANDITEM
+            {
+            key = 220;
+            txt = qtn_vc_calendar_calendarjuly;
+            },
+        // Show July (spoken)
+        VCOMMANDITEM
+            {
+            key = 9220;
+            txt = qan_vc_calendar_calendarjuly;
+            },
+        // Show August (written)
+        VCOMMANDITEM
+            {
+            key = 221;
+            txt = qtn_vc_calendar_calendaraugust;
+            },
+        // Show August (spoken)
+        VCOMMANDITEM
+            {
+            key = 9221;
+            txt = qan_vc_calendar_calendaraugust;
+            },
+        // Show September (written)
+        VCOMMANDITEM
+            {
+            key = 222;
+            txt = qtn_vc_calendar_calendarseptember;
+            },
+        // Show September (spoken)
+        VCOMMANDITEM
+            {
+            key = 9222;
+            txt = qan_vc_calendar_calendarseptember;
+            },
+        // Show October (written)
+        VCOMMANDITEM
+            {
+            key = 223;
+            txt = qtn_vc_calendar_calendaroctober;
+            },
+        // Show October (spoken)
+        VCOMMANDITEM
+            {
+            key = 9223;
+            txt = qan_vc_calendar_calendaroctober;
+            },
+        // Show November (written)
+        VCOMMANDITEM
+            {
+            key = 224;
+            txt = qtn_vc_calendar_calendarnovember;
+            },
+        // Show November (spoken)
+        VCOMMANDITEM
+            {
+            key = 9224;
+            txt = qan_vc_calendar_calendarnovember;
+            },
+        // Show December (written)
+        VCOMMANDITEM
+            {
+            key = 225;
+            txt = qtn_vc_calendar_calendardecember;
+            },
+        // Show December (spoken)
+        VCOMMANDITEM
+            {
+            key = 9225;
+            txt = qan_vc_calendar_calendardecember;
+            },
+        // Who is my operator (written)
+        VCOMMANDITEM
+            {
+            key = 227;
+            txt = qtn_vc_main_operator;
+            },
+        // Who is my operator (spoken)
+        VCOMMANDITEM
+            {
+            key = 9227;
+            txt = qan_vc_main_operator;
+            },
+        // What is the battery strength (written)
+        VCOMMANDITEM
+            {
+            key = 228;
+            txt = qtn_vc_main_battery ;
+            },
+        // What is the battery strength (spoken)
+        VCOMMANDITEM
+            {
+            key = 9228;
+            txt = qan_vc_main_battery ;
+            },
+        // What is the signal strength (written)
+        VCOMMANDITEM
+            {
+            key = 229;
+            txt = qtn_vc_main_signal;
+            },
+        // What is the signal strength (spoken)
+        VCOMMANDITEM
+            {
+            key = 9229;
+            txt = qan_vc_main_signal;
+            }
+// --- Voice commands end ---
+        };
+    }
+
+// -----------------------------------------------------------------------------
+//   
+// VCOMMANDINTEGERS
+// Key value pairs of integers
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE VCOMMANDINTEGERS vcommandintegers
+    {
+    intitems =
+        {
+        // Nothing
+        };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for VCommandManager
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+PRJ_EXPORTS
+
+#include "exports.inc"
+
+PRJ_MMPFILES
+
+vcommandmanager.mmp
+
+
+PRJ_TESTEXPORTS
+
+
+PRJ_TESTMMPFILES
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* ==============================================================================
+*        %name: exports.inc %
+*     %version: 15 %
+*      Part of: VoiceUIPluginFramework / VCommandManager
+*  Description: VCommandManager exports
+*
+*  Copyright © 2006-2007 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+* ==============================================================================
+*/
+
+
+
+//..\inc\voicecommands.xml               \epoc32\data\z\private\102818E7\voicecommands.xml
+//..\inc\voicecommands.xml               \epoc32\release\winscw\udeb\z\private\102818E7\voicecommands.xml
+//..\inc\voicecommands.xml               \epoc32\release\winscw\urel\z\private\102818E7\voicecommands.xml
+
+../inc/defaultvoicecommands.xml        /epoc32/data/z/private/102818e7/defaultvoicecommands.xml
+../inc/defaultvoicecommands.xml        /epoc32/release/winscw/udeb/z/private/102818e7/defaultvoicecommands.xml
+../inc/defaultvoicecommands.xml        /epoc32/release/winscw/urel/z/private/102818e7/defaultvoicecommands.xml
+
+../inc/btvoicecommands.xml             /epoc32/data/z/private/102818e7/btvoicecommands.xml
+../inc/btvoicecommands.xml             /epoc32/release/winscw/udeb/z/private/102818e7/btvoicecommands.xml
+../inc/btvoicecommands.xml             /epoc32/release/winscw/urel/z/private/102818e7/btvoicecommands.xml
+
+../inc/emailvoicecommands.xml          /epoc32/data/z/private/102818e7/emailvoicecommands.xml
+../inc/emailvoicecommands.xml          /epoc32/release/winscw/udeb/z/private/102818e7/emailvoicecommands.xml
+../inc/emailvoicecommands.xml          /epoc32/release/winscw/urel/z/private/102818e7/emailvoicecommands.xml
+
+../inc/imvoicecommands.xml             /epoc32/data/z/private/102818e7/imvoicecommands.xml
+../inc/imvoicecommands.xml             /epoc32/release/winscw/udeb/z/private/102818e7/imvoicecommands.xml
+../inc/imvoicecommands.xml             /epoc32/release/winscw/urel/z/private/102818e7/imvoicecommands.xml
+
+../inc/radiovoicecommands.xml          /epoc32/data/z/private/102818e7/radiovoicecommands.xml
+../inc/radiovoicecommands.xml          /epoc32/release/winscw/udeb/z/private/102818e7/radiovoicecommands.xml
+../inc/radiovoicecommands.xml          /epoc32/release/winscw/urel/z/private/102818e7/radiovoicecommands.xml
+
+../inc/realplayervoicecommands.xml     /epoc32/data/z/private/102818e7/realplayervoicecommands.xml
+../inc/realplayervoicecommands.xml     /epoc32/release/winscw/udeb/z/private/102818e7/realplayervoicecommands.xml
+../inc/realplayervoicecommands.xml     /epoc32/release/winscw/urel/z/private/102818e7/realplayervoicecommands.xml
+
+../inc/vrvoicecommands.xml             /epoc32/data/z/private/102818e7/vrvoicecommands.xml
+../inc/vrvoicecommands.xml             /epoc32/release/winscw/udeb/z/private/102818e7/vrvoicecommands.xml
+../inc/vrvoicecommands.xml             /epoc32/release/winscw/urel/z/private/102818e7/vrvoicecommands.xml
+
+../inc/dictvoicecommands.xml           /epoc32/data/z/private/102818e7/dictvoicecommands.xml
+../inc/dictvoicecommands.xml           /epoc32/release/winscw/udeb/z/private/102818e7/dictvoicecommands.xml
+../inc/dictvoicecommands.xml           /epoc32/release/winscw/urel/z/private/102818e7/dictvoicecommands.xml
+
+../inc/mmspostcardvoicecommands.xml    /epoc32/data/z/private/102818e7/mmspostcardvoicecommands.xml
+../inc/mmspostcardvoicecommands.xml    /epoc32/release/winscw/udeb/z/private/102818e7/mmspostcardvoicecommands.xml
+../inc/mmspostcardvoicecommands.xml    /epoc32/release/winscw/urel/z/private/102818e7/mmspostcardvoicecommands.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/group/vcommandmanager.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for VCommandManager
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+
+TARGET          vcommandmanager.exe
+
+TARGETTYPE      EXE
+
+// 20K of stack
+EPOCSTACKSIZE   0x5000
+// Heap: 32K ->
+EPOCHEAPSIZE    0x8000 0xF4FFFF
+
+UID             0x100039CE 0x102818E7 // UID: 271063271
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_APPLICATION MultiMediaDD NetworkControl
+
+SOURCEPATH      ../data
+
+START RESOURCE  vcommandmanager.rss
+HEADER
+TARGETPATH      APP_RESOURCE_DIR
+END
+
+START RESOURCE  vcommandmanager_reg.rss
+TARGETPATH      /private/10003a3f/apps
+END
+
+START RESOURCE  defaultvoicecommands.rss
+LANGUAGE_IDS
+HEADER
+TARGETPATH      RESOURCE_FILES_DIR
+END
+
+SOURCEPATH      ../src
+SOURCE          vcommandmanager.cpp
+SOURCE          vcxmlparser.cpp
+SOURCE          vcresource.cpp
+SOURCE          vcmanagerapp.cpp
+SOURCE          vcmanagerdocument.cpp
+SOURCE          vcmanagerappui.cpp
+SOURCE          vcmanagerbackupobserver.cpp
+SOURCE          vcmanagervoicekeylauncher.cpp
+SOURCE          vcmanagervoiceheadsetlauncher.cpp
+SOURCE		      vcommandmerger.cpp
+SOURCE          vcmanagercontactselecthandler_aiw.cpp
+SOURCE          vcmanagerdialer_aiw.cpp
+
+
+USERINCLUDE     ../../vuiphandler/inc
+USERINCLUDE     ../../vcommandhandler/inc
+USERINCLUDE     ../../rubydebug
+USERINCLUDE     ../src
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+USERINCLUDE     ../../group
+
+
+// This is a SYSTEMINCLUDE macro containing the application
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/xml
+SYSTEMINCLUDE   /epoc32/include/connect
+SYSTEMINCLUDE   /epoc32/include/remcon
+
+LIBRARY         remconinterfacebase.lib
+LIBRARY         remconextensionapi.lib
+LIBRARY         euser.lib 
+LIBRARY         nssvoiceuipluginhandler.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         xmlframework.lib
+LIBRARY         numberconversion.lib
+LIBRARY         featmgr.lib
+LIBRARY         charconv.lib
+LIBRARY         vcommandhandler.lib
+LIBRARY         centralrepository.lib
+LIBRARY         cenrepnotifhandler.lib
+LIBRARY         nssvascontacthdlr.lib
+LIBRARY         avkon.lib
+LIBRARY         eikcore.lib 
+LIBRARY         apparc.lib 
+LIBRARY         eiksrv.lib 
+LIBRARY         cone.lib
+LIBRARY         apgrfx.lib
+LIBRARY         ws32.lib 
+LIBRARY         eikcoctl.lib 
+LIBRARY         sendui.lib
+LIBRARY         nssvasapi.lib
+LIBRARY         servicehandler.lib
+LIBRARY         aiwdialdata.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/btvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- main -->
+    
+        <!-- Bluetooth -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9103"/>
+            <written locindex="103"/>
+            <tooltip locindex="10002"/>
+            <executes uid="0x10281D15"/>
+            <cmdlineparams>
+            2
+            </cmdlineparams>
+            <icon uid="0x10005951"/>
+        </vcommand>
+
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/defaultvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,341 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- main -->
+    
+        <!-- Browser -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9101"/>
+            <written locindex="101"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10008D39"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10008D39"/>
+        </vcommand>
+
+        <!-- Phonebook -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9104"/>
+            <written locindex="104"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F4CCE"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F4CCE"/>
+        </vcommand>
+
+        <!-- Logs -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9105"/>
+            <written locindex="105"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F4CD5"/>
+            <cmdlineparams>
+            counters
+            </cmdlineparams>
+            <icon uid="0x101F4CD5"/>
+        </vcommand>
+
+        <!-- Application manager -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9106"/>
+            <written locindex="106"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10281D15"/>
+            <cmdlineparams>
+            6
+            </cmdlineparams>
+            <icon uid="0x101F8512"/>
+        </vcommand>
+
+     <!-- qtn_vc_main_media -->
+    
+     <vcommandfolder locindex="20005" titlelocindex="30005" iconfile="Z:\resource\apps\vcommand.mif" iconindex="4">
+        
+        <!-- Voice recorder -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9132"/>
+            <written locindex="132"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x100058CA"/>
+            <cmdlineparams>
+            record
+            </cmdlineparams>
+            <icon uid="0x100058CA"/>
+        </vcommand>
+
+        <!-- Gallery -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9133"/>
+            <written locindex="133"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x200009EE"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x200009EE"/>
+        </vcommand>
+
+        <!-- Music Player -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9135"/>
+            <written locindex="135"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x102072C3"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x102072C3"/>
+        </vcommand>
+        
+        <!-- Video Player -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9137"/>
+            <written locindex="137"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x200159B2"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x200159B2"/>
+        </vcommand>
+                
+    </vcommandfolder>
+     <!-- qtn_vc_main_messaging_folder -->
+    
+     <vcommandfolder locindex="20004" titlelocindex="30004" iconfile="Z:\resource\apps\vcommand.mif" iconindex="3">
+        
+        <!-- Messaging -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9127"/>
+            <written locindex="127"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x100058C5"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x100058C5"/>
+        </vcommand>
+
+        <!-- New message -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9128"/>
+            <written locindex="128"/>
+            <tooltip locindex="10003"/>
+            <executes uid="0x10281D15"/>
+            <cmdlineparams>
+            3
+            </cmdlineparams>
+            <icon uid="0x100058BC"/>
+        </vcommand>
+        
+    </vcommandfolder>
+     <!-- qtn_vc_main_organizer -->
+    
+     <vcommandfolder locindex="20003" titlelocindex="30003" iconfile="Z:\resource\apps\vcommand.mif" iconindex="2">
+        
+        <!-- Notepad -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9117"/>
+            <written locindex="117"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10005907"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10005907"/>
+        </vcommand>
+
+        <!-- Calculator -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9118"/>
+            <written locindex="118"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10005902"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10005902"/>
+        </vcommand>
+
+        <!-- Data synchronisation -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9120"/>
+            <written locindex="120"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F6DE4"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F6DE4"/>
+        </vcommand>
+
+        <!-- Clock -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9121"/>
+            <written locindex="121"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10005903"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10005903"/>
+        </vcommand>
+
+        <!-- File manager -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9123"/>
+            <written locindex="123"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F84EB"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F84EB"/>
+        </vcommand>
+
+        <!-- Calendar -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9124"/>
+            <written locindex="124"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10005901"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10005901"/>
+        </vcommand>
+
+        <!-- What time is it -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9226"/>
+            <written locindex="226"/>
+            <tooltip locindex="10006"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            27
+            </cmdlineparams>
+            <icon uid="0x101F8555"/>
+        </vcommand>
+        
+    </vcommandfolder>
+     <!-- qtn_vc_main_tools -->
+    
+     <vcommandfolder locindex="20002" titlelocindex="30002" iconfile="Z:\resource\apps\vcommand.mif" iconindex="1">
+        
+        <!-- Personalisation -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9107"/>
+            <written locindex="107"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10005A32"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10005A32"/>
+        </vcommand>
+
+        <!-- Help -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9108"/>
+            <written locindex="108"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10005234"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10005234"/>
+        </vcommand>
+
+        <!-- Profiles -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9109"/>
+            <written locindex="109"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x100058F8"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x100058F8"/>
+        </vcommand>
+
+        <!-- Voice mail -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9110"/>
+            <written locindex="110"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10281D15"/>
+            <cmdlineparams>
+            1
+            </cmdlineparams>
+            <icon uid="0x100058F5"/>
+        </vcommand>
+
+        <!-- Voice commands -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9112"/>
+            <written locindex="112"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F8555"/>
+            <cmdlineparams>
+            </cmdlineparams>
+            <icon uid="0x101F8555"/>
+        </vcommand>
+
+        <!-- Settings -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9113"/>
+            <written locindex="113"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x100058EC"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x100058EC"/>
+        </vcommand>
+
+        <!-- Device manager -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9115"/>
+            <written locindex="115"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F6DE5"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F6DE5"/>
+        </vcommand>
+
+        <!-- Connection manager -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9116"/>
+            <written locindex="116"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F84D0"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F84D0"/>
+        </vcommand>
+
+        <!-- Speed dialing -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9125"/>
+            <written locindex="125"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x1000590A"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x1000590A"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/dictvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_tools -->
+    
+     <vcommandfolder locindex="20002" titlelocindex="30002" iconfile="Z:\resource\apps\vcommand.mif" iconindex="1">
+        
+        <!-- Chinese dictionary -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9111"/>
+            <written locindex="111"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F9CFE"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F9CFE"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/emailvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_messaging_folder -->
+    
+     <vcommandfolder locindex="20004" titlelocindex="30004" iconfile="Z:\resource\apps\vcommand.mif" iconindex="3">
+        
+        <!-- New e-mail -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9129"/>
+            <written locindex="129"/>
+            <tooltip locindex="10021"/>
+            <executes uid="0x10281D15"/>
+            <cmdlineparams>
+            4
+            </cmdlineparams>
+            <icon uid="0x101F4CD6"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/imvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_messaging_folder -->
+    
+     <vcommandfolder locindex="20004" titlelocindex="30004" iconfile="Z:\resource\apps\vcommand.mif" iconindex="3">
+        
+        <!-- Instant messaging -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9126"/>
+            <written locindex="126"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F4673"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F4673"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/locationvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- main -->
+
+        <!-- Navigator -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9102"/>
+            <written locindex="102"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F85A0"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F85A0"/>
+        </vcommand>
+
+     <!-- qtn_vc_main_tools -->
+    
+     <vcommandfolder locindex="20002" titlelocindex="30002" iconfile="Z:\resource\apps\vcommand.mif" iconindex="1">
+
+        <!-- Landmarks -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9114"/>
+            <written locindex="114"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F85A2"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F85A2"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/mmspostcardvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_messaging_folder -->
+    
+     <vcommandfolder locindex="20004" titlelocindex="30004" iconfile="Z:\resource\apps\vcommand.mif" iconindex="3">
+        
+        <!-- New MMS postcard -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9136"/>
+            <written locindex="136"/>
+            <tooltip locindex="10003"/>
+            <executes uid="0x10281D15"/>
+            <cmdlineparams>
+            5
+            </cmdlineparams>
+            <icon uid="0x10207247"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/radiovoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_media -->
+    
+     <vcommandfolder locindex="20005" titlelocindex="30005" iconfile="Z:\resource\apps\vcommand.mif" iconindex="4">
+        
+        <!-- Radio -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9130"/>
+            <written locindex="130"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x10207A89"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x10207A89"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/realplayervoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_media -->
+    
+     <vcommandfolder locindex="20005" titlelocindex="30005" iconfile="Z:\resource\apps\vcommand.mif" iconindex="4">
+        
+        <!-- Real Player -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9134"/>
+            <written locindex="134"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x200159B2"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x200159B2"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/remconradiovoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_media -->
+    
+     <vcommandfolder locindex="20005" titlelocindex="30005" iconfile="Z:\resource\apps\vcommand.mif" iconindex="4">
+        
+        <!-- Next channel -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9234"/>
+            <written locindex="234"/>
+            <tooltip locindex="10016"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            37
+            </cmdlineparams>
+            <icon uid="0x10207A89"/>
+        </vcommand>
+
+        <!-- Previous channel -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9236"/>
+            <written locindex="236"/>
+            <tooltip locindex="10018"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            39
+            </cmdlineparams>
+            <icon uid="0x10207A89"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/remconvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_media -->
+    
+     <vcommandfolder locindex="20005" titlelocindex="30005" iconfile="Z:\resource\apps\vcommand.mif" iconindex="4">
+        
+        <!-- Play -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9230"/>
+            <written locindex="230"/>
+            <tooltip locindex="10012"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            33
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+
+        <!-- Pause -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9231"/>
+            <written locindex="231"/>
+            <tooltip locindex="10013"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            34
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+
+        <!-- Stop -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9232"/>
+            <written locindex="232"/>
+            <tooltip locindex="10014"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            35
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+
+        <!-- Next song -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9233"/>
+            <written locindex="233"/>
+            <tooltip locindex="10015"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            36
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+
+        <!-- Previous song -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9235"/>
+            <written locindex="235"/>
+            <tooltip locindex="10017"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            38
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+
+        <!-- Volume up -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9237"/>
+            <written locindex="237"/>
+            <tooltip locindex="10019"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            42
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+
+        <!-- Volume down -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9238"/>
+            <written locindex="238"/>
+            <tooltip locindex="10020"/>
+            <executes exe="Nssvcommandexecutor.exe"/>
+            <cmdlineparams>
+            43
+            </cmdlineparams>
+            <icon uid="0x10005A3E"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/inc/vrvoicecommands.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Automatically generated by sheetconvertor.py from voice_commands.xls. Don't modify -->
+
+<nssvcommands version="1.0" localizationfile="defaultvoicecommands">
+  
+     <!-- qtn_vc_main_media -->
+    
+     <vcommandfolder locindex="20005" titlelocindex="30005" iconfile="Z:\resource\apps\vcommand.mif" iconindex="4">
+        
+        <!-- Cameras -->
+        <vcommand tts="true" modifiable="true">
+            <spoken locindex="9131"/>
+            <written locindex="131"/>
+            <tooltip locindex="10001"/>
+            <executes uid="0x101F857A"/>
+            <cmdlineparams>
+            
+            </cmdlineparams>
+            <icon uid="0x101F857A"/>
+        </vcommand>
+        
+    </vcommandfolder>
+
+</nssvcommands>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerapp.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Starts VCommand modules at start up.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <nssvasccontacthandler.h>
+#include <eikstart.h>
+#include "nssvoiceuipluginhandler.h"
+#include "vcmanagerapp.h"
+#include "vcmanagerdocument.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CVCommandManagerApp::AppDllUid
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CVCommandManagerApp::AppDllUid() const
+    {
+    return KUidVcManager;
+    }
+
+   
+// ---------------------------------------------------------
+// CVCommandManagerApp::CreateDocumentL
+// Creates document object
+// ---------------------------------------------------------
+//
+CApaDocument* CVCommandManagerApp::CreateDocumentL()
+    {
+    return CVCommandManagerDocument::NewL( *this );
+    }
+
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+// ---------------------------------------------------------
+// NewApplication
+// Creates CVCommandManagerApp object
+// ---------------------------------------------------------
+//
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CVCommandManagerApp;
+    }
+    
+// ---------------------------------------------------------
+// E32Main
+// Main
+// ---------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerapp.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application class of VCommandManager
+*
+*/
+
+
+#ifndef VCMANAGERAPP_H
+#define VCMANAGERAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+
+// UID of the application
+const TUid KUidVcManager = { 0x102818E7 };
+
+
+// CLASS DECLARATION
+
+/**
+* CVCommandManagerApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CVCommandManagerApp : public CAknApplication
+    {
+    
+    private: // Functions from base classes
+
+        /**
+        * From CApaApplication
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID.
+        * @return The value of KUidVcManager.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif // VCMANAGERAPP_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerappui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,230 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommandManager Application UI class
+*
+*/
+
+
+// INCLUDE FILES
+#include <aknenv.h>
+#include <akntitle.h>
+#include <f32file.h>
+#include <apgwgnam.h>
+#include <AknSgcc.h>
+#include <nssvasccontacthandler.h>
+#include <data_caging_path_literals.hrh>
+#include "nssvoiceuipluginhandler.h"
+#include "rubydebug.h"
+#include "vcmanagerappui.h"
+#include "vcommandrecogmanager.h"
+#include "vcommandmanager.h"
+#include "vcmanagervoicekeylauncher.h"
+#include "vcmanagervoiceheadsetlauncher.h"
+#include "vcmanagercontactselecthandler_aiw.h"
+
+#include "vcmanagerbackupobserver.h"
+
+// CONSTANTS
+_LIT( KVCThreadName, "VCManagerThread" );
+const TThreadPriority KVCThreadPriority = EPriorityAbsoluteLow;
+
+// Thread heap min-max
+const TInt KVCHeapMinSize = KMinHeapSize;
+const TInt KVCHeapMaxSize = 0x200000;       // Max size is set to 2MB
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::StartServicesL
+// Starts SIND services
+// -----------------------------------------------------------------------------
+//
+void CVCommandManagerAppUi::StartServicesL()
+    {
+    RUBY_DEBUG0( "CVCommandManagerAppUi::StarServices" );
+
+    TInt error = KErrNone;
+
+    TSecureId sid = RThread().SecureId();
+    RUBY_DEBUG1( "VCommandManager secure id [%x]", sid.iId );
+
+    // Create thread which starts to run the xml parsing
+    RThread parserThread;
+
+    error = parserThread.Create( KVCThreadName, CVCommandManager::VCMThreadFunction, 
+                                 KDefaultStackSize, KVCHeapMinSize, KVCHeapMaxSize, NULL );
+    CleanupClosePushL( parserThread );
+                             
+    if ( error == KErrNone )
+        {
+        parserThread.SetPriority( KVCThreadPriority );
+        
+        // Create VoiceUI Plug-in handler
+        iPluginHandler = CNssVoiceUIPluginHandler::NewL();
+    
+        // Recognition selection handling
+        iRecogManager = CVCRecognitionManager::NewL();
+       
+        // Create backup/restore observer
+        iBackupObserver = CVCommandManagerBackupObserver::NewL();
+        
+        // Create dialer
+        RUBY_DEBUG0( "CVCommandManagerAppUi::StarServices creating dialer" ); 
+        
+        iVasDbManager = CNssVASDBMgr::NewL();
+        iVasDbManager->InitializeL();
+        iContextManager = iVasDbManager->GetContextMgr();
+      
+        iSelectNotificationBuilder = CNssSelectNotificationBuilder::NewL();
+        iSelectNotificationBuilder->InitializeL();
+        iTagSelectNotification = iSelectNotificationBuilder->GetTagSelectNotification();
+
+        iContactSelectHandler = CVcManagerContactSelectHandler::NewL( iContextManager, 
+                                                                      iTagSelectNotification );
+                                                                              
+        delete iVasDbManager;
+        iVasDbManager = NULL;
+        
+        iVoiceKeyLauncher = CVCommandManagerVoiceKeyLauncher::NewL();
+        iVoiceHeadSetLauncher = CVCommandManagerVoiceHeadSetLauncher::NewL();
+        
+        // Dialer created
+        RUBY_DEBUG0( "CVCommandManagerAppUi::StarServices dialer created" );        
+        
+        // Create VAS contact handler
+        iContactHandler = CNssContactHandler::NewL();
+        
+        // Start XML parsing
+        parserThread.Resume();
+        
+        CleanupStack::PopAndDestroy( &parserThread );
+        }
+    else
+        {        	
+        RUBY_ERROR0( "CVCommandManagerAppUi::StarServices cannot create thread" );
+        }
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCommandManagerAppUi::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManagerAppUi::ConstructL version 9" );
+    
+    // Remember the idle status pane resource id
+    iInitialStatuspaneResourceId = CAknSgcClient::CurrentStatuspaneResource();
+        
+    // Cannot set ENoScreenFurniture here since after that StatusPane() function
+    // returns NULL. "Voice mailbox" command requires status pane to be available
+    // when executing.
+    // ENoAppResourceFile seems to have no effect -> not setting that either
+    BaseConstructL( EAknEnableSkin );
+
+    // Set this as system application    
+    iEikonEnv->SetSystem( ETrue );
+    
+    iEikonEnv->SetAutoForwarding( ETrue );
+    
+    UpdateStatusPaneL();
+   
+    StartServicesL();
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::~CVCommandManagerAppUi
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CVCommandManagerAppUi::~CVCommandManagerAppUi()
+    {  
+    RUBY_DEBUG0( "CVCommandManagerAppUi::~CVCommandManagerAppUi" );
+    // Destroy VAS contact handler
+    delete iContactHandler;
+    // Destroy VAS global context
+    delete iRecogManager;
+    // Destroy VoiceUI Plug-in handler
+    delete iPluginHandler;
+    
+    delete iContactSelectHandler;
+    delete iSelectNotificationBuilder;
+    delete iVasDbManager;    
+    delete iBackupObserver;
+    delete iVoiceKeyLauncher;
+    delete iVoiceHeadSetLauncher;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::EikonEnv
+// Returns the CEikonEnv
+// -----------------------------------------------------------------------------
+//    
+CEikonEnv* CVCommandManagerAppUi::EikonEnv() const
+    {
+    return iEikonEnv;
+    }    
+    
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::UpdateStatusPaneL
+// Switch to initial status pane
+// -----------------------------------------------------------------------------
+//     
+void CVCommandManagerAppUi::UpdateStatusPaneL()
+    {
+    // Use same status pane as idle has
+    StatusPane()->SwitchLayoutL( iInitialStatuspaneResourceId );
+    
+    // Title pane is set as empty
+    CAknTitlePane* title =
+        static_cast<CAknTitlePane*>(
+            StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+        
+    //const TDesC* temp = title->Text();
+    title->SetTextL( KNullDesC );
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::HandleScreenDeviceChangedL
+// -----------------------------------------------------------------------------
+//     
+void CVCommandManagerAppUi::HandleScreenDeviceChangedL()
+    {
+    CAknAppUiBase::HandleScreenDeviceChangedL();
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerAppUi::HandleCommandL
+// Handle events from app framework
+// -----------------------------------------------------------------------------
+//      
+void CVCommandManagerAppUi::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EEikCmdExit:
+            {
+            Exit();
+            break;
+            }
+
+        default:
+            break;
+        }
+    }  
+      
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerappui.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AppUi class of VCommandManager
+*
+*/
+
+
+#ifndef VCMANAGERAPPUI_H
+#define VCMANAGERAPPUI_H
+
+//  INCLUDES
+#include <aknappui.h>
+#include <nssvasmtagselecthandler.h>
+#include <nssvasmcontext.h>
+#include <nssvascselectnotificationbuilder.h>
+#include <nssvasmtagselectnotification.h>
+#include <nssvasmcontextmgr.h>
+
+// FORWARD DECLARATIONS
+class CNssVoiceUIPluginHandler;
+class CVCRecognitionManager;
+class CNssContactHandler;
+class CVcManagerContactSelectHandler;
+class CNssVASDBMgr;
+class CVCommandManagerBackupObserver;
+class CVCommandManagerVoiceKeyLauncher;
+class CVCommandManagerVoiceHeadSetLauncher;
+
+// CLASS DECLARATION
+
+/**
+* This class is a part of the standard application framework.
+*/
+class CVCommandManagerAppUi : public CAknAppUi 
+    {
+    public: // Constructors and destructor
+            
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+	
+        /**
+        * Destructor.
+        */
+       virtual ~CVCommandManagerAppUi();   
+	    
+    public: // New functions
+    
+        /**
+        * Method to get the CEikonEnv pointer
+        *
+        * @return CEikonEnv
+        */
+        CEikonEnv* EikonEnv() const;
+	    
+        /**
+        * Updates status pane to the idle pane
+        */
+        void UpdateStatusPaneL();
+
+    private: // From CEikAppUi
+
+        /**
+        * From CEikAppUi, takes care of command handling.
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL( TInt aCommand );
+                
+        /**
+        * From CEikAppUi, takes care of screen resolution change
+        */
+        void HandleScreenDeviceChangedL();
+        
+    private: // New functions
+    
+        /**
+        * Creates SIND services
+        */
+        void StartServicesL();
+        
+    private:
+    
+        // Resource id of the current status pane
+        TInt iInitialStatuspaneResourceId;
+        
+        // VUIPF plugin handler
+        CNssVoiceUIPluginHandler* iPluginHandler;
+        
+        // Recognition result handler
+        CVCRecognitionManager* iRecogManager;
+        
+        // VAS contact handler
+        CNssContactHandler* iContactHandler;
+        
+        // Backup/restore observer
+        CVCommandManagerBackupObserver* iBackupObserver;
+        
+        // Starting voice ui
+        CVCommandManagerVoiceKeyLauncher* iVoiceKeyLauncher;
+        CVCommandManagerVoiceHeadSetLauncher* iVoiceHeadSetLauncher;
+        
+        // For dialing
+        MNssTagSelectNotification* iTagSelectNotification;
+        CNssSelectNotificationBuilder* iSelectNotificationBuilder;
+        CVcManagerContactSelectHandler* iContactSelectHandler;
+        CNssVASDBMgr* iVasDbManager;
+        MNssContextMgr* iContextManager;
+    };
+
+#endif // VCMANAGERAPPUI_H 
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerbackupobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watches changes of the PC-Suite data sync state
+*
+*/
+
+
+#include "vcmanagerbackupobserver.h"
+#include "rubydebug.h"
+
+#include "srsfprivatecrkeys.h"
+
+#include <sbdefs.h>
+#include <centralrepository.h>
+
+// CONSTANTS
+
+static const TInt KUndefinedLanguage = -1;
+
+/**
+ @todo generalize the common parts of this class, CVCommandManagerBackupObserver
+       and CNssVasBackupObserver from VAS API
+       At the moment the code is copy-pasted and duplicated
+*/
+
+// ---------------------------------------------------------
+// CVCommandManagerBackupObserver::NewL
+// ---------------------------------------------------------
+//
+CVCommandManagerBackupObserver* CVCommandManagerBackupObserver::NewL()
+    {
+    CVCommandManagerBackupObserver* self = new (ELeave) CVCommandManagerBackupObserver();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerBackupObserver::CVCommandManagerBackupObserver
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+CVCommandManagerBackupObserver::CVCommandManagerBackupObserver()
+ : CActive( CActive::EPriorityHigh ), iRestoreStarted( EFalse )
+    {
+    // Nothing
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerBackupObserver::ConstructL
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+void CVCommandManagerBackupObserver::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManagerBackupObserver::ConstructL" );
+    User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) );
+       
+    // initial subscription and process current property value
+    iProperty.Subscribe( iStatus );
+    
+    CActiveScheduler::Add( this ); 
+    SetActive();   
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerBackupObserver::~CVCommandManagerBackupObserver
+// ---------------------------------------------------------
+//
+CVCommandManagerBackupObserver::~CVCommandManagerBackupObserver()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+    
+// ---------------------------------------------------------
+// CNssVasBackupObserver::DoCancel
+// Cancel listening now
+// ---------------------------------------------------------
+//    
+void CVCommandManagerBackupObserver::DoCancel() 
+    {
+    iProperty.Cancel();
+    }
+
+// ---------------------------------------------------------
+// CVCommandManagerBackupObserver::RunL
+// Is called, when property changed
+// ---------------------------------------------------------
+//
+void CVCommandManagerBackupObserver::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManagerBackupObserver::RunL" );
+    
+    if( iStatus != KErrNone ) 
+        {
+        // At least report the error
+        RUBY_ERROR1( "CVCommandManagerBackupObserver::RunL - iStatus is [%d]", iStatus.Int() );
+        }
+        
+    // resubscribe before processing new value to prevent missing updates
+    // even if some error happened
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    // property updated, get new value
+	TInt backupFlag;
+	User::LeaveIfError( iProperty.Get( backupFlag ) );
+	switch ( backupFlag & conn::KBURPartTypeMask )
+	    {
+	    case conn::EBURNormal:
+	        RUBY_DEBUG0( "CVCommandManagerBackupObserver::RunL - Backup/restore ended" );
+	        SetVoiceCommandRetrainingL();
+	        iRestoreStarted = EFalse;
+	        break;
+	        
+	    case conn::EBURBackupFull:
+	    case conn::EBURBackupPartial:
+	        RUBY_DEBUG0( "CVCommandManagerBackupObserver::RunL - Backup started" );
+            iRestoreStarted = EFalse;
+	        break;
+	    
+	    case conn::EBURRestoreFull:
+	    case conn::EBURRestorePartial:
+	        RUBY_DEBUG0( "CVCommandManagerBackupObserver::RunL - Restore started" );
+            iRestoreStarted = ETrue;
+	        break;
+	        
+	    case conn::EBURUnset:
+	    default:
+	        RUBY_ERROR1( "CVCommandManagerBackupObserver::RunL - Backup flag unknown %h ", backupFlag );
+	    }
+    }
+
+// ---------------------------------------------------------
+// CVCommandManagerBackupObserver::SetVoiceCommandRetrainingL
+// Enables voice command retraining
+// ---------------------------------------------------------
+//    
+void CVCommandManagerBackupObserver::SetVoiceCommandRetrainingL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManagerBackupObserver::SetVoiceCommandRetrainingL" );
+    
+    if ( iRestoreStarted )
+        {
+        CRepository* client = CRepository::NewLC( KCRUidSRSFSettings );
+        User::LeaveIfError( client->Set( KSRSFUiLanguage, KUndefinedLanguage ) );
+        CleanupStack::PopAndDestroy( client );
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerbackupobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Watcher for the PC-Suite data sync state
+*
+*/
+
+
+#ifndef VCMANAGERBACKUPOBSERVER_H
+#define VCMANAGERBACKUPOBSERVER_H
+
+//  INCLUDES
+
+#include <e32base.h>
+
+// Publish & Subscribe of the contact handler activity
+#include <e32property.h>  
+
+// CONSTANTS
+
+// MACROS
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+ @todo generalize the common parts of this class, CNssChBackupObserver
+       and CNssVasBackupObserver from VAS API
+       At the moment the code is copy-pasted and duplicated
+*/
+
+
+
+/**
+* RProperty based data sync watcher implementation
+*/
+NONSHARABLE_CLASS( CVCommandManagerBackupObserver ) : public CActive
+    {
+    public:
+        /** 
+        *  Factory construction
+        *  @return Constructed and already started observer
+        */
+        static CVCommandManagerBackupObserver* NewL();
+        
+        /** 
+        * Destructor 
+        */
+        ~CVCommandManagerBackupObserver();
+ 
+    private:
+        /**
+        * C++ constructor 
+        */
+        CVCommandManagerBackupObserver();
+        
+        /**
+        * Symbian second phase constructor 
+        */
+        void ConstructL();
+        
+        /**
+        * is called when data sync property changed 
+        */
+        void RunL();
+        
+        /**
+        * Is called when system wants immediate cancelling of the watching 
+        */
+        void DoCancel();
+        
+        /**
+        * Enables voice command retraining
+        */
+        void SetVoiceCommandRetrainingL();
+        
+    private:
+        // Publish & Subscribe property about backup/restore 
+        RProperty   iProperty;
+        
+        // Has restore started
+        TBool       iRestoreStarted;
+    };
+
+#endif // VCMANAGERBACKUPOBSERVER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagercontactselecthandler_aiw.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,273 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "vcmanagercontactselecthandler_aiw.h"
+#include "vcmanagerdialer_aiw.h"
+
+#include <CPbkFieldInfo.h>
+
+#include <vascvpbkhandler.h>
+
+#include <cntdef.h>
+#include <eikenv.h>
+
+#include <featmgr.h> // FeatureManager.
+
+#ifdef __SIND_EXTENSIONS
+#include <sendui.h>
+#include <SendUiConsts.h>
+#include <CMessageData.h>
+#endif // __SIND_EXTENSIONS
+
+#include "rubydebug.h"
+
+#ifdef __WINS__
+// Text to show in emulator when dialing
+_LIT( KDialingNoteWins, "Dialing" );
+#endif
+
+// CONSTANTS
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::CVcManagerContactSelectHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CVcManagerContactSelectHandler::CVcManagerContactSelectHandler()
+ : iVideoTelephonySupported( EFalse ), iVoIPFeatureSupported( EFalse )     
+    {
+    // Nothing
+    }
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CVcManagerContactSelectHandler* CVcManagerContactSelectHandler::NewL(
+                                       MNssContextMgr* aContextManager,
+                                       MNssTagSelectNotification* aTagSelectNotification )
+    {
+    CVcManagerContactSelectHandler* self = new (ELeave) CVcManagerContactSelectHandler;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aContextManager, aTagSelectNotification );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::~CVcManagerContactSelectHandler
+// Destructor
+// ---------------------------------------------------------
+//
+CVcManagerContactSelectHandler::~CVcManagerContactSelectHandler()
+    {
+    RUBY_DEBUG0( "CVcManagerContactSelectHandler::~CVcManagerContactSelectHandler" );
+
+    delete iPbkHandler;
+
+    if ( iTagSelectNotification )
+        {
+        iTagSelectNotification->Deregister( iContext, this );
+        }
+
+    delete iContext;
+
+#ifdef __SIND_EXTENSIONS
+    delete iSendUi;
+#endif // __SIND_EXTENSIONS
+
+    delete iGlobalDialer;
+    }
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::HandleTagSelect
+// EPOC default constructor can leave.
+// ---------------------------------------------------------
+//
+void CVcManagerContactSelectHandler::ConstructL( MNssContextMgr* aContextManager,
+                                                 MNssTagSelectNotification* aTagSelectNotification )
+    {
+    RUBY_DEBUG_BLOCK( "CVcManagerContactSelectHandler::ConstructL" );
+    
+    iTagSelectNotification = aTagSelectNotification;
+    
+    iContext = aContextManager->CreateContextL();
+    iContext->SetNameL( KNssGCHNameDialContext );
+    iContext->SetGlobal( ETrue );
+    iTagSelectNotification->RegisterL( iContext, this );
+
+    RUBY_DEBUG0( "CVcManagerContactSelectHandler::ConstructL creating instance of CVasVPbkHandler" );
+    iPbkHandler = CVasVPbkHandler::NewL();
+    iPbkHandler->InitializeL();
+    
+    FeatureManager::InitializeLibL();
+    iVideoTelephonySupported = FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony );
+    
+    iVoIPFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
+
+    // Frees the TLS. Must be done after FeatureManager is used.
+    FeatureManager::UnInitializeLib();
+    
+    // Take Eikon environment
+    iEikonEnvironment = CEikonEnv::Static();
+    }
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::HandleTagSelect
+// Dials number
+// ---------------------------------------------------------
+//
+void CVcManagerContactSelectHandler::HandleTagSelect( MNssTag* aTag )
+    {
+    RUBY_DEBUG2( "CVcManagerContactSelectHandler::HandleTagSelect VOIP %i video %i", iVoIPFeatureSupported, iVideoTelephonySupported );
+
+    TRAP_IGNORE( DoHandleTagSelectL( aTag ) );
+    }
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::DoHandleTagSelect
+// Dials number or create message
+// ---------------------------------------------------------
+//
+void CVcManagerContactSelectHandler::DoHandleTagSelectL( MNssTag* aTag )
+    {
+    RUBY_DEBUG_BLOCK( "CVcManagerContactSelectHandler::DoHandleTagSelectL" );
+   
+    CleanupDeletePushL( aTag );
+   
+    HBufC* name = aTag->SpeechItem()->PartialTextL( KNameTrainingIndex );        
+    CleanupStack::PushL( name ); 
+   
+    iContactId = aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation );
+  
+    iPbkHandler->FindContactFieldL( aTag );
+       
+    TVasExtensionAction action =
+         (TVasExtensionAction)aTag->RRD()->IntArray()->At( KVasExtensionRrdLocation );
+    TVasExtensionCommand command =
+         (TVasExtensionCommand)aTag->RRD()->IntArray()->At( KVasExtensionCommandRrdLocation );
+
+    if ( action == EDial )
+        {
+        DialL( *name, iPbkHandler->TextL(), iPbkHandler->FieldTypeL(), command ); 
+        }
+#ifdef __SIND_EXTENSIONS  
+    else
+        {
+        CMessageData* messageData = CMessageData::NewL();
+        CleanupStack::PushL( messageData );
+                   
+        // created when needed first time
+        if ( !iSendUi )
+            {
+            iSendUi = CSendUi::NewL();
+            }
+         
+        TUid sendUid( KSenduiMtmSmsUid );
+        switch ( action )
+            {
+            case ENewMessage:
+                // @todo Check that KSenduiMtmUniMessageUid is ok to use
+                // instead of SenduiMtmMmsUid or KSenduiMtmSmsUid
+                sendUid = KSenduiMtmUniMessageUid;
+                messageData->AppendToAddressL( iPbkHandler->TextL(), *name );  
+                break;
+                   
+            case ENewEmail:
+                sendUid = KSenduiMtmSmtpUid;
+                messageData->AppendToAddressL( iPbkHandler->TextL(), *name );
+                break;
+                   
+            default:
+                RUBY_ERROR0( "CVcManagerContactSelectHandler::DoHandleTagSelectL wrong action id" );
+            }
+              
+        RUBY_DEBUG1( "CVcManagerContactSelectHandler::DoHandleTagSelectL action %i",
+                      action );               
+        // launch editor as a stand-alone application so that 
+        // it can/will be restored if put to background
+        iSendUi->CreateAndSendMessageL( sendUid, messageData, KNullUid, EFalse );
+        
+        CleanupStack::PopAndDestroy( messageData );
+        } 
+#endif // __SIND_EXTENSIONS        
+
+    CleanupStack::PopAndDestroy( name );
+    CleanupStack::Pop( aTag );
+    }
+
+
+// ---------------------------------------------------------
+// CVcManagerContactSelectHandler::DialL
+// Dials contact
+// ---------------------------------------------------------
+//
+#ifndef __WINS__
+void CVcManagerContactSelectHandler::DialL( const TDesC& aName,
+                                            const TDesC& aPhoneNumber,
+                                            TFieldType aFieldType,
+                                            TVasExtensionCommand aCommandId )
+#else
+void CVcManagerContactSelectHandler::DialL( const TDesC& /*aName*/,
+                                            const TDesC& aPhoneNumber,
+                                            TFieldType aFieldType,
+                                            TVasExtensionCommand aCommandId )
+#endif // __WINS__                                            
+    {
+    RUBY_DEBUG2( "CVcManagerContactSelectHandler::DialL fieldtype %i commandId %i", aFieldType, aCommandId );
+
+    // select call type
+    TCallType callType( EVoice );
+
+    if ( ( aCommandId == EVoipCommand || ( aCommandId == EDefaultCommand &&
+           aFieldType == KUidContactFieldVCardMapVOIP ) ) && iVoIPFeatureSupported )
+        {
+        RUBY_DEBUG0( "CVcManagerContactSelectHandler::SetupDialData VOIP" );
+
+        callType = EVoIP;
+        }
+    
+    if ( ( aCommandId == EVideoCommand || ( aCommandId == EDefaultCommand &&
+           aFieldType == KUidContactFieldVCardMapVIDEO ) ) && iVideoTelephonySupported )
+        {
+        RUBY_DEBUG0( "CVcManagerContactSelectHandler::SetupDialData video" );
+
+        callType = EVideo;
+        }
+
+#ifndef __WINS__
+    if ( !iGlobalDialer )
+        {
+        iGlobalDialer = CVcManagerDialer::NewL();
+        }
+    iGlobalDialer->ExecuteL( aName, aPhoneNumber, callType );
+#else
+    iEikonEnvironment->AlertWin( KDialingNoteWins, aPhoneNumber );
+#endif // __WINS__
+
+    RUBY_DEBUG0( "CVcManagerContactSelectHandler::DialL done" );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagercontactselecthandler_aiw.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of class which takes care of contacts data after
+*               voice tag recognition.
+*
+*/
+
+
+#ifndef VCMANAGERCONTACTSELECTHANDLER_H
+#define VCMANAGERCONTACTSELECTHANDLER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <coemain.h>
+
+#include <cntdef.h> 
+#include <PhCltTypes.h>
+
+#include <nssvascvasdbmgr.h>
+#include <nssvasapi.h>
+
+#include "srsfbldvariant.hrh"
+
+// FORWARD DECLARATIONS
+class CSendUi;
+class CEikonEnv;
+class MVasBasePbkHandler;
+class CVcManagerDialer;
+
+// CONSTANTS
+_LIT( KNssGCHNameDialContext, "NAMEDIAL" );
+
+// CLASS DECLARATION
+
+/**
+*  Responsible for dialing a selected contact
+*
+*/
+NONSHARABLE_CLASS ( CVcManagerContactSelectHandler ) : public CBase,
+                                                       public MNssTagSelectHandler
+   {
+   public:
+
+      /**
+      * Two-phased constructor.
+      * 
+      * @param aContextManager VAS context manager
+      * @param aTagSelectNotification VAS tag select notifier
+      */
+      static CVcManagerContactSelectHandler* NewL( 
+                    MNssContextMgr* aContextManager,
+                    MNssTagSelectNotification* aTagSelectNotification);
+
+      /**
+      * Destructor.
+      */
+      ~CVcManagerContactSelectHandler();
+
+      /**
+      * From MNssTagSelectHandler Called when a tag is selected following recognition
+      */
+      void HandleTagSelect( MNssTag* aTag );
+
+   private:
+
+      /**
+      * Dials phone number
+      * @param aName Descriptor containing the name of the contact
+      * @param aPhoneNumber Descriptor containing the phone number
+      * @param aNumberFieldType A UID which identifies a contact item field's type.
+      * @param aCommandId Extension command id
+      * @return void
+      */
+      void DialL( const TDesC& aName, const TDesC& aPhoneNumber,
+                  TFieldType aNumberFieldType, TVasExtensionCommand aCommandId );
+
+      /**
+      * Checks if character is acceptable.
+      *
+      * @param aChar character.
+      * @return ETrue iff characters is ok.
+      */
+      static TBool IsValidChar( TChar aChar );
+
+      /**
+      * Removes all illegal characters from descriptor.
+      *
+      * @param aString string from which those characters are removed.
+      */
+      static void RemoveInvalidChars( TDes& aString );
+
+      /**
+      * By default EPOC constructor is private.
+      *
+      * @param aContextManager VAS context manager
+      * @param aTagSelectNotification VAS tag select notifier
+      */
+      void ConstructL( MNssContextMgr* aContextManager, 
+                       MNssTagSelectNotification* aTagSelectNotification );
+
+      /**
+      * C++ default constructor.
+      */
+      CVcManagerContactSelectHandler();
+
+      /**
+      * Performs action after contact recognition
+      */
+      void DoHandleTagSelectL( MNssTag* aTag );
+      
+   private://data
+       
+       // VAS database manager
+       CNssVASDBMgr* iVasDbManager;
+       
+       // Phonebook engine
+       MVasBasePbkHandler* iPbkHandler;
+       
+       // Contact id
+       TInt iContactId;
+
+       // Number which will be dialed
+       TPhCltTelephoneNumber iTelNumber;
+
+       // VAS context
+       MNssContext* iContext;
+
+       // VAS tag select notifier to get information about selected tag
+       MNssTagSelectNotification* iTagSelectNotification;
+       
+       // Video call support on/off
+       TBool iVideoTelephonySupported;
+       
+       // VOIP support on/off
+       TBool iVoIPFeatureSupported;
+       
+       // Send UI to open message editor
+       CSendUi* iSendUi;
+       
+       // Eikon environment
+       CEikonEnv* iEikonEnvironment;
+       
+       // Global dialer
+       CVcManagerDialer* iGlobalDialer;
+   };
+
+#endif // VCMANAGERCONTACTSELECTHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerdialer_aiw.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the implementation of the class for global dialer.
+*
+*/
+
+
+// INCLUDE FILES
+#include "vcmanagerdialer_aiw.h"
+#include <AiwCommon.hrh>    //KAiwCmdCall
+#include <aiwdialdataext.h>
+#include <AiwDialDataTypes.h>
+#include <AiwServiceHandler.h> 
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CVcManagerDialer::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CVcManagerDialer* CVcManagerDialer::NewL()
+    { 
+    CVcManagerDialer* self = new (ELeave) CVcManagerDialer;    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CVcManagerDialer::~CVcManagerDialer
+// Destructor
+// ---------------------------------------------------------
+// 
+CVcManagerDialer::~CVcManagerDialer() 
+    {
+    delete iServiceHandler;
+    }
+
+// ---------------------------------------------------------
+// CVcManagerDialer::ExecuteLD
+// Execute dialer
+// ---------------------------------------------------------
+//
+void CVcManagerDialer::ExecuteL( TPtrC aName, TPtrC aNumber, TCallType aCallType ) 
+    {
+    if( aNumber.Length() )
+        {
+        CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC();   
+        dialData->SetNameL( aName.Left( AIWDialDataExt::KMaximumNameLength ) );
+        dialData->SetPhoneNumberL( aNumber );
+            
+        // convert TPbkFielId to TAiwCallType
+        CAiwDialData::TCallType callType( CAiwDialData::EAIWForcedCS );
+        
+        if ( aCallType == EVideo )
+            {
+            callType = CAiwDialData::EAIWForcedVideo;
+            }
+        else if ( aCallType == EVoIP )
+            {
+            callType = CAiwDialData::EAIWVoiP;
+            }
+            
+        dialData->SetCallType( callType );
+        
+        CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
+        dialData->FillInParamListL(paramList);
+        
+        iServiceHandler->ExecuteServiceCmdL( KAiwCmdCall,
+                                             paramList,
+                                             iServiceHandler->OutParamListL(),
+                                             0,
+                                             NULL ); //Callback is NULL as no dial results wanted.
+                                            
+        CleanupStack::PopAndDestroy( dialData ); 
+        }
+    }
+    
+// ---------------------------------------------------------
+// CVcManagerDialer::CVcManagerDialer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CVcManagerDialer::CVcManagerDialer()
+    { 
+    // nothing
+    }
+    
+// ---------------------------------------------------------
+// CVcManagerDialer::ConstructL
+// Second phase constructor.
+// ---------------------------------------------------------
+//
+void CVcManagerDialer::ConstructL()
+    {
+    iServiceHandler = CAiwServiceHandler::NewL();
+
+    // Create AIW interest
+    RCriteriaArray interest;
+    CleanupClosePushL( interest );
+    CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC( KAiwCmdCall, KAiwCmdCall,
+                                                          _L8( "*" ) );
+    TUid base;
+    base.iUid = KAiwClassBase;
+    criteria->SetServiceClass( base );
+    User::LeaveIfError( interest.Append( criteria ) );
+
+    // attach to AIW interest
+    iServiceHandler->AttachL( interest );
+    
+    CleanupStack::PopAndDestroy( criteria ); 
+    CleanupStack::PopAndDestroy( &interest );
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerdialer_aiw.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of class for dialing a phone number.
+*
+*/
+
+
+#ifndef VCMANAGERDIALER_H
+#define VCMANAGERDIALER_H
+
+//  INCLUDES
+#include <e32base.h>    // CBase
+
+enum TCallType
+    {
+    EVoice,
+    EVideo,
+    EVoIP
+    };
+    
+// FORWARD DECLARATIONS
+class CAiwServiceHandler;
+    
+// CLASS DEFINITION
+
+/**
+* Does the dialing based on recognized voice tag.
+*
+*/
+NONSHARABLE_CLASS ( CVcManagerDialer ) : public CBase
+    {
+    public: 
+
+        /**
+        * Two-phased constructor.
+        */
+        static CVcManagerDialer* NewL();
+
+        /**
+        * Destructor.
+        */
+        ~CVcManagerDialer();
+
+    public: 
+	
+        /**
+        * Dials to given number
+        * @param aName name of the contact
+        * @param aNumber number to be called
+        * @param aCallType Type of calling (voice, video, VoIP)
+        */
+        void ExecuteL( TPtrC aName, TPtrC aNumber, TCallType aCallType );
+        
+    private:
+    
+        /**
+        * Default constructor.
+        */
+        CVcManagerDialer();
+        
+        /**
+        * Second phase constructor.
+        */
+        void ConstructL();
+        
+    private:
+    
+        // Aiw service handler
+        CAiwServiceHandler* iServiceHandler;
+
+    };
+
+#endif // VCMANAGERDIALER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerdocument.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommandManager document class
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <apgwgnam.h>
+
+#include "vcmanagerdocument.h"
+#include "vcmanagerappui.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------------------------
+// CVCommandManagerDocument::CVCommandManagerDocument
+// Default constructor
+// ----------------------------------------------------------------------------
+//
+CVCommandManagerDocument::CVCommandManagerDocument( CEikApplication& aApp ): 
+                                                    CAknDocument( aApp )    
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CVCommandManagerDocument::~CVCommandManagerDocument()
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CVCommandManagerDocument::~CVCommandManagerDocument()
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CVCommandManagerDocument::UpdateTaskNameL
+// Updates task name
+// ----------------------------------------------------------------------------
+//
+void CVCommandManagerDocument::UpdateTaskNameL( CApaWindowGroupName* aWgName )
+    {
+    CAknDocument::UpdateTaskNameL( aWgName );
+    aWgName->SetHidden( ETrue ); 
+    }
+
+// ----------------------------------------------------------------------------
+// CVCommandManagerDocument::ConstructL()
+// Second phase constructor
+// ----------------------------------------------------------------------------
+//
+void CVCommandManagerDocument::ConstructL()
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CVCommandManagerDocument::NewL
+// Symbian constructor
+// ----------------------------------------------------------------------------
+//
+CVCommandManagerDocument* CVCommandManagerDocument::NewL( CEikApplication& aApp )
+    {
+    CVCommandManagerDocument* self = new (ELeave) CVCommandManagerDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CVCommandManagerDocument::CreateAppUiL
+// Instantiates AppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CVCommandManagerDocument::CreateAppUiL()
+    {
+    return new (ELeave) CVCommandManagerAppUi;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagerdocument.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Document class of VCommandManager
+*
+*/
+
+
+#ifndef VCMANAGERDOCUMENT_H
+#define VCMANAGERDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CAiNameDialerDocument application class.
+*/
+class CVCommandManagerDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+    
+        /**
+        * Two-phased constructor.
+        *
+        * @param "CEikApplication& aApp" Application object
+        */
+        static CVCommandManagerDocument* NewL( CEikApplication& aApp );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCommandManagerDocument();
+
+    public: // From CAknDocument
+    
+        /**
+        * Updates window group task name
+        *
+        * @param "CApaWindowGroupName* aWgName" Window group name
+        */
+        void UpdateTaskNameL( CApaWindowGroupName* aWgName );
+
+    private:
+
+        /**
+        * Default constructor.
+        *
+        * @param "CEikApplication& aApp" Application object
+        */
+        CVCommandManagerDocument( CEikApplication& aApp );
+        
+        /**
+        * Second phase constructor
+        */        
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, creates CAiNameDialerAppUi "App UI" object.
+        *
+        * @return Created AppUi instance
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif // VCMANAGERDOCUMENT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagervoiceheadsetlauncher.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,328 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Observer voice headset key presses
+*
+*/
+
+
+#include "vcmanagervoiceheadsetlauncher.h"
+#include "rubydebug.h"
+#include <apgcli.h>
+#include <apgtask.h>
+#include <apacmdln.h>
+#include <remconinterfaceselector.h>
+#include <RemConCallHandlingTarget.h>
+#include <voiceuidomainpskeys.h>
+#include <vuivoicerecogdefs.h>
+#include <ctsydomainpskeys.h>
+#include <coreapplicationuisdomainpskeys.h>
+
+// CONSTANTS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::CVCommandManagerVoiceHeadSetLauncher
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVCommandManagerVoiceHeadSetLauncher::CVCommandManagerVoiceHeadSetLauncher() 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManagerVoiceHeadSetLauncher::ConstructL" );
+    iSelector = CRemConInterfaceSelector::NewL();
+    iCallHandlingTarget = CRemConCallHandlingTarget::NewL( *iSelector, *this );
+    // Connect to Remote Control server as target. After succesfull call
+    // client is ready to receive commands. Call this method only once in a
+    // process.
+    iSelector->OpenTargetL();
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCommandManagerVoiceHeadSetLauncher* CVCommandManagerVoiceHeadSetLauncher::NewL()
+    {
+    CVCommandManagerVoiceHeadSetLauncher* self = new( ELeave ) CVCommandManagerVoiceHeadSetLauncher;    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+    
+// Destructor
+CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher()
+    {
+    RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher - START" );
+    
+    // iCallHandlingTarget will be destroyed when iSelector is destroyed.  
+    delete iSelector;
+    iProperty.Close();
+    
+    RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher - EXIT" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::AnswerCall
+// ---------------------------------------------------------------------------
+//    
+void CVCommandManagerVoiceHeadSetLauncher::AnswerCall()
+    {
+    RUBY_DEBUG0( "" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtAnswerCall, KErrNone );
+    User::WaitForRequest( response );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::AnswerCall
+// ---------------------------------------------------------------------------
+//    
+void CVCommandManagerVoiceHeadSetLauncher::AnswerEndCall()
+    {
+    RUBY_DEBUG0( "" );
+    iProperty.Set( KPSUidVoiceUiAccMonitor, KVoiceUiAccessoryEvent, KVoiceUiShortPressEvent );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtAnswerEnd, KErrNone );
+    User::WaitForRequest( response );
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::EndCall
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::EndCall()
+    {
+    RUBY_DEBUG0( "" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response,  ERemConExtEndCall, KErrNone );
+    User::WaitForRequest( response );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::LastNumberRedial
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::LastNumberRedial()
+    {
+    RUBY_DEBUG0( "" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtLastNumberRedial, KErrNone );
+    User::WaitForRequest( response );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::VoiceDial
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::VoiceDial( const TBool /*aActivate*/ )
+    {
+    RUBY_DEBUG0( "" );
+    if ( GetAutoLockValue() > EAutolockOff )
+        {
+        TRemConExtCmdSource source;
+        iCallHandlingTarget->GetCommandSourceInfo( source );
+        
+        if ( source == ERemConExtCmdSourceBluetooth )
+            {
+            TRAP_IGNORE( LaunchVoiceUiL( ETrue ) );
+            }
+        }
+    else
+        {
+        TRAP_IGNORE( LaunchVoiceUiL( EFalse ) );
+        }
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtVoiceDial, KErrNone );
+    User::WaitForRequest( response );
+    }
+
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::DialCall
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::DialCall( const TDesC8& /*aTelNumber*/ )
+    {
+    RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::DialCall" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtDialCall, KErrNone );
+    User::WaitForRequest( response );
+    }    
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::MultipartyCalling
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::MultipartyCalling( const TDesC8& /*aData*/ )
+    {
+    RUBY_DEBUG0( "" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExt3WaysCalling, KErrNone );
+    User::WaitForRequest( response );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::GenerateDTMF
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::GenerateDTMF( const TChar /*aChar*/ )
+    {
+    RUBY_DEBUG0( "" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtGenerateDTMF, KErrNone );
+    User::WaitForRequest( response );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::SpeedDial
+// ---------------------------------------------------------------------------
+//
+void CVCommandManagerVoiceHeadSetLauncher::SpeedDial( const TInt /*aIndex*/ )
+    {
+    RUBY_DEBUG0( "" );
+    TRequestStatus response( KErrNone );
+    iCallHandlingTarget->SendResponse( response, ERemConExtSpeedDial, KErrNone );    
+    User::WaitForRequest( response );
+    }
+
+    
+// ---------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::LaunchVoiceUiL
+// ---------------------------------------------------------
+//     
+void CVCommandManagerVoiceHeadSetLauncher::LaunchVoiceUiL( TBool aDeviceLockMode )
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // Check that phone or video call is not currently active
+    TInt state = CheckCallState();
+    if ( ( state == EPSCTsyCallStateNone ||
+           state == EPSCTsyCallStateUninitialized ||
+           state == KErrUnknown ) && !IsVideoCall() )
+        {
+        TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
+        TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUID );
+
+        if ( apaTask.Exists() )
+            {
+            apaTask.BringToForeground();
+            
+            iProperty.Set( KPSUidVoiceUiAccMonitor, KVoiceUiAccessoryEvent, KVoiceUiLongPressEvent );
+            }
+        else
+            {
+            RApaLsSession apaLsSession;
+            User::LeaveIfError( apaLsSession.Connect() );
+            CleanupClosePushL(apaLsSession);
+            
+            TApaAppInfo appInfo;
+            User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, KVoiceUiUID ) );
+            
+            TFileName appName = appInfo.iFullName;
+            CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+
+            apaCommandLine->SetExecutableNameL( appName );
+            apaCommandLine->SetCommandL( EApaCommandRunWithoutViews );
+            
+            if ( aDeviceLockMode )
+                {
+                // Command line parameters
+                apaCommandLine->SetTailEndL( KVoiceUiMode );
+                }
+            
+            User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) );
+            CleanupStack::PopAndDestroy( apaCommandLine );
+
+            CleanupStack::PopAndDestroy(&apaLsSession);
+            }    
+        }
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::CheckCallState
+// ---------------------------------------------------------
+//
+TInt CVCommandManagerVoiceHeadSetLauncher::CheckCallState()
+    {
+    RUBY_DEBUG0( "START" );
+    
+    TInt callState;
+    TInt err = RProperty::Get( KPSUidCtsyCallInformation,
+                               KCTsyCallState,
+                               callState );
+    if ( err == KErrNotFound )
+        {
+        callState = KErrNotFound;
+        }
+    
+    RUBY_DEBUG0( "EXIT" );
+    
+    return callState;    
+    }    
+    
+// -----------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::IsVideoCall 
+// -----------------------------------------------------------------------------
+//
+TBool CVCommandManagerVoiceHeadSetLauncher::IsVideoCall() 
+    {
+    RUBY_DEBUG0( "START" );
+    
+    TInt callType;
+    RProperty::Get( KPSUidCtsyCallInformation,
+                    KCTsyCallType, 
+                    callType );// Ignore errors  
+
+    RUBY_DEBUG0( "EXIT" );
+
+    return callType == EPSCTsyCallTypeH324Multimedia;
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue 
+// -----------------------------------------------------------------------------
+//
+TInt CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue()
+    {
+    RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue START" );
+  
+    TInt autoLockValue;
+    TInt err = RProperty::Get( KPSUidCoreApplicationUIs,
+                               KCoreAppUIsAutolockStatus,
+                               autoLockValue );
+    if ( err == KErrNotFound )
+        {
+        autoLockValue = KErrNotFound;
+        }
+        
+    RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue EXIT" );
+    
+    return autoLockValue;
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagervoiceheadsetlauncher.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Headset key observer
+*
+*/
+
+
+#ifndef VCMANAGERVOICEHEADSETLAUNCHER_H
+#define VCMANAGERVOICEHEADSETLAUNCHER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+#include <w32std.h> 
+#include <eikenv.h>
+#include <RemConCallHandlingTargetObserver.h>
+
+
+// CONSTANTS
+
+// MACROS
+
+// FORWARD DECLARATIONS
+class CRemConInterfaceSelector;
+class CRemConCallHandlingTarget;
+
+/**
+* Class for starting Voice UI
+* @since 5.0
+*/
+NONSHARABLE_CLASS( CVCommandManagerVoiceHeadSetLauncher ) : public CBase,
+                                                            MRemConCallHandlingTargetObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CVCommandManagerVoiceHeadSetLauncher* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVCommandManagerVoiceHeadSetLauncher();
+
+    public: // New functions
+     
+
+    public: // Functions from base classes
+        
+         
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void AnswerCall();
+        
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void AnswerEndCall();
+         
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void EndCall();
+         
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void VoiceDial( const TBool aActivate );
+         
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void LastNumberRedial();
+         
+         /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void DialCall( const TDesC8& aTelNumber );
+    
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void MultipartyCalling( const TDesC8& aData );
+    
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void GenerateDTMF( const TChar aChar );
+    
+        /**
+        * @see MRemConCallHandlingTargetObserver
+        */
+        void SpeedDial( const TInt aIndex );
+ 
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CVCommandManagerVoiceHeadSetLauncher();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Start voice ui
+        * @param aDeviceLockMode ETrue if started in device lock mode else EFalse
+        */        
+        void LaunchVoiceUiL( TBool aDeviceLockMode );
+        
+        /**
+        * Checks if call is active
+        * @return Call state or KErrNotFound
+        */
+        TInt CheckCallState();
+        
+        /**
+        * Checks if video call is active
+        * @return ETrue if video call else EFalse
+        */
+        TBool IsVideoCall();
+        
+        /**
+        * Checks if auto lock is active
+        * @return Auto lock value or KErrNotFound
+        */
+        TInt GetAutoLockValue();
+
+    private:    // Data
+    
+        CRemConInterfaceSelector*      iSelector;             // Owned
+        CRemConCallHandlingTarget*     iCallHandlingTarget;   // Not owned
+
+        RProperty                      iProperty;
+    };
+
+#endif // VCMANAGERVOICEHEADSETLAUNCHER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagervoicekeylauncher.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,196 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Observer voice key presses
+*
+*/
+
+
+#include "vcmanagervoicekeylauncher.h"
+#include "rubydebug.h"
+#include <featmgr.h>
+#include <eikappui.h>
+#include <apgcli.h>
+#include <apgtask.h>
+#include <apacmdln.h>
+#include <apgwgnam.h>
+
+
+// CONSTANTS
+const TInt KCapturePriority( 255 );
+const TUint KLongVoiceKey( 0x102818E7 ); // unique (UID of this exe)
+const TUid KVoiceUiUID = { 0x101F8543 };
+
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::NewL
+// ---------------------------------------------------------
+//
+CVCommandManagerVoiceKeyLauncher* CVCommandManagerVoiceKeyLauncher::NewL()
+    {
+    CVCommandManagerVoiceKeyLauncher* self = new (ELeave) CVCommandManagerVoiceKeyLauncher();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::CVCommandManagerVoiceKeyLauncher
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+CVCommandManagerVoiceKeyLauncher::CVCommandManagerVoiceKeyLauncher()
+    : CActive( EPriorityStandard )
+    {
+    // nothing
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::ConstructL
+// C++ constructor can NOT contain any code, that might leave.
+// ---------------------------------------------------------
+//
+void CVCommandManagerVoiceKeyLauncher::ConstructL() 
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    // Check if the voice key exist
+    iKeyEnabled = FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey );
+    if ( iKeyEnabled )
+        {
+        User::LeaveIfError( iWsSession.Connect() );
+        
+        iWindowGroup = RWindowGroup ( iWsSession );
+        iWindowGroup.Construct( (TUint32) &iWindowGroup, EFalse );
+        
+        iWindowGroup.SetOrdinalPosition( -1 );
+        iWindowGroup.EnableReceiptOfFocus( EFalse );
+    
+        iKeyCaptureHandle = iWindowGroup.CaptureKey( EKeyDevice6, 0, 0 );
+        iLongKeyCaptureHandle = iWindowGroup.CaptureLongKey( (TUint)EKeyDevice6, 
+                                    KLongVoiceKey, 0, 0, KCapturePriority, ELongCaptureNormal );
+                                    
+        CApaWindowGroupName* name = CApaWindowGroupName::NewLC( iWsSession );
+        name->SetHidden( ETrue );
+        name->SetWindowGroupName( iWindowGroup );
+        CleanupStack::PopAndDestroy( name );
+                                    
+        iWsSession.EventReady( &iStatus );
+     
+        CActiveScheduler::Add( this );
+        SetActive();
+
+        }
+  
+    }
+    
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::~CVCommandManagerVoiceKeyLauncher
+// ---------------------------------------------------------
+//
+CVCommandManagerVoiceKeyLauncher::~CVCommandManagerVoiceKeyLauncher()
+    {
+    RUBY_DEBUG0( "START" );
+    if ( iKeyEnabled )
+        {        
+        Cancel();
+        iWindowGroup.Close();        
+        iWsSession.Close();        
+        }
+        
+    RUBY_DEBUG0( "EXIT" );
+    }
+    
+
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::DoCancel
+// ---------------------------------------------------------
+// 
+void CVCommandManagerVoiceKeyLauncher::DoCancel()
+    {
+    RUBY_DEBUG0( "START" );
+    
+    
+    if ( iKeyEnabled )
+        {
+        iWsSession.EventReadyCancel();
+        iWindowGroup.CancelCaptureKey( iKeyCaptureHandle );
+        iWindowGroup.CancelCaptureKey( iLongKeyCaptureHandle );       
+        }    
+    
+    RUBY_DEBUG0( "EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::RunL
+// ---------------------------------------------------------
+//     
+void CVCommandManagerVoiceKeyLauncher::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+    
+    if ( iStatus.Int() == KErrNone )
+        {
+        TWsEvent event;
+        iWsSession.GetEvent( event );
+        
+        iWsSession.EventReady( &iStatus );
+        SetActive();
+        
+        if ( event.Key()->iCode == KLongVoiceKey )
+            {
+            //iWsSession.SendEventToOneWindowGroupsPerClient( event );
+            
+            LaunchVoiceUiL();
+            }
+        }
+    }
+
+    
+// ---------------------------------------------------------
+// CVCommandManagerVoiceKeyLauncher::LaunchVoiceUiL
+// ---------------------------------------------------------
+//     
+void CVCommandManagerVoiceKeyLauncher::LaunchVoiceUiL()
+    {
+    RUBY_DEBUG_BLOCK( "" );
+   
+    TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
+    TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUID );
+    
+    if ( apaTask.Exists() )
+        {
+        apaTask.BringToForeground();
+        }
+    else
+        {
+        RApaLsSession apaLsSession;
+        User::LeaveIfError( apaLsSession.Connect() );
+        CleanupClosePushL(apaLsSession);
+        
+        TApaAppInfo appInfo;
+        User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, KVoiceUiUID ) );
+        
+        TFileName appName = appInfo.iFullName;
+        CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+
+        apaCommandLine->SetExecutableNameL( appName );
+        apaCommandLine->SetCommandL( EApaCommandRunWithoutViews );
+        User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) );
+        CleanupStack::PopAndDestroy( apaCommandLine );
+    
+        CleanupStack::PopAndDestroy(&apaLsSession);
+        }    
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcmanagervoicekeylauncher.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice key observer
+*
+*/
+
+
+#ifndef VCMANAGERVOICEKEYLAUNCHER_H
+#define VCMANAGERVOICEKEYLAUNCHER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <w32std.h> 
+#include <eikenv.h>
+
+// CONSTANTS
+
+// MACROS
+
+// FORWARD DECLARATIONS
+
+
+/**
+* Class for starting Voice UI
+* @since 5.0
+*/
+NONSHARABLE_CLASS( CVCommandManagerVoiceKeyLauncher ) : public CActive
+    {
+    public:
+        /** 
+        *  Factory construction
+        *  @return Constructed and already started observer
+        */
+        static CVCommandManagerVoiceKeyLauncher* NewL();
+        
+        /** 
+        * Destructor 
+        */
+        ~CVCommandManagerVoiceKeyLauncher();
+
+    public:     // From base classes
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void DoCancel();
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void RunL();
+        
+    private:
+        /**
+        * C++ constructor 
+        */
+        CVCommandManagerVoiceKeyLauncher();
+        
+        /**
+        * Symbian second phase constructor 
+        */
+        void ConstructL();
+        
+        /**
+        * Start voice ui 
+        */        
+        void LaunchVoiceUiL();
+        
+        
+    private:
+        
+        // is key capture enabled
+        TBool iKeyEnabled;
+        
+        // key handle for window group
+        TInt32 iKeyCaptureHandle;
+        TInt32 iLongKeyCaptureHandle;
+        
+        // window group
+        RWindowGroup iWindowGroup;
+        
+        RWsSession iWsSession;
+    };
+
+#endif // VCMANAGERVOICEKEYLAUNCHER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcommandmanager.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,413 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommandManager application which is started during boot. 
+*
+*/
+
+
+// INCLUDE FILES
+#include "rubydebug.h"
+
+#include <centralrepository.h>
+
+#include "srsfprivatecrkeys.h"
+#include <menu2internalcrkeys.h>
+#include <f32file.h>
+#include "vcommandmanager.h"
+#include "vcxmlparser.h"
+#include "vcommandmerger.h"
+
+// CONSTANTS
+_LIT( KPrivateSubDirectory, "import\\" );
+_LIT( KFileFilter, "*.xml" );
+
+//static const TInt KUndefinedLanguage = -1;
+
+
+// -----------------------------------------------------------------------------
+// CVCommandManager::CVCommandManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVCommandManager::CVCommandManager( TBool aForceRetrain )
+ : iCommands(), iMatchingIndices(), iLanguageChanged( aForceRetrain )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCommandManager::ConstructL()
+    {
+    User::LeaveIfError( iRFs.Connect() );
+    
+    iParser = CVcXmlParser::NewL( iRFs, *this );
+    
+    // Create service object
+    CVCommandHandler* service = CVCommandHandler::NewL();
+    CleanupStack::PushL( service );
+    
+    ParseAllFilesL();
+    
+    // Get all existing commands from VCommandHandler
+    iCommandArray = service->ListCommandsL();
+
+    CVCommandMerger* merger = CVCommandMerger::NewLC();
+    CVCommandArray* deduction = merger->ProduceDeductionByRunnablesLC( *iCommandArray, iCommands );
+    CVCommandArray* addition = merger->ProduceAdditionByRunnablesLC( *iCommandArray, iCommands );
+    
+    service->RemoveCommandsL( deduction->PointerArray(), ETrue );
+    service->AddCommandsL( addition->PointerArray(), ETrue );
+    
+    CleanupStack::PopAndDestroy( addition );
+    CleanupStack::PopAndDestroy( deduction );
+    CleanupStack::PopAndDestroy( merger );
+    CleanupStack::PopAndDestroy( service );
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCommandManager* CVCommandManager::NewL( TBool aForceRetrain )
+    {
+    CVCommandManager* self = new ( ELeave ) CVCommandManager( aForceRetrain );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManager::ParseAllFilesL
+// Goes through directories and parses all xml files.
+// -----------------------------------------------------------------------------
+//
+void CVCommandManager::ParseAllFilesL()
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManager::ParseAllFilesL" );
+        
+    TDriveList drivelist;
+    User::LeaveIfError( iRFs.DriveList( drivelist ) ); 
+
+    for ( TInt drive( EDriveA ); drive <= EDriveZ; drive++ )
+        {
+        if ( drivelist[drive] ) 
+            {
+            TChar driveLetter; 
+			User::LeaveIfError( iRFs.DriveToChar( drive, driveLetter ) );
+
+            TFileName directory;
+            iRFs.PrivatePath( directory );
+            directory.Insert( 0, _L(" :"));
+            directory[0] = driveLetter; // replace " " with a drive letter
+            
+            // parse files from private directory
+            ParseAllFilesFromDirectoryL( directory );
+            
+            // parse filer from import directory
+            directory.Append( KPrivateSubDirectory );
+            ParseAllFilesFromDirectoryL( directory );    
+            
+            }
+        }
+    }
+    
+
+    
+// -----------------------------------------------------------------------------
+// CVCommandManager::ParseAllFilesFromDirectoryL
+// Goes through directory and parses all xml files.
+// -----------------------------------------------------------------------------
+//
+void CVCommandManager::ParseAllFilesFromDirectoryL( const TDesC& aDirectory )
+    {
+    RUBY_DEBUG_BLOCK( "CVCommandManager::ParseAllFilesFromDirectoryL" );
+    
+    CDir* dirContents = NULL;
+
+    TFileName searchPath( aDirectory );
+    searchPath.Append( KFileFilter );
+    
+    RUBY_DEBUG1( "CVCommandManager::ParseAllFilesFromDirectoryL - Search path: [%S]", &searchPath );
+    
+    TInt error = iRFs.GetDir( searchPath, KEntryAttMatchMask, ESortNone, dirContents );   
+    if ( error == KErrNone )
+        {        
+        CleanupStack::PushL( dirContents );
+        
+        RUBY_DEBUG1( "CVCommandManager::ParseAllFilesFromDirectoryL - Found %d xml-file(s)", dirContents->Count() );
+
+        // Go through all found xml files
+        for ( TInt iCounter = 0; iCounter < dirContents->Count(); iCounter++ )
+            {
+            TEntry entry = (*dirContents)[iCounter];
+            if ( !entry.IsDir() )
+                {
+                TFileName filename( aDirectory );
+                filename.Append( entry.iName );                
+                
+                TRAPD( error, iParser->ParseFileL( filename ) );
+                if ( error )
+                    {
+                    // Reset parser if an error occurs
+                    delete iParser;
+                    iParser = NULL;
+                    
+                    iParser = CVcXmlParser::NewL( iRFs, *this );
+                    }
+                }
+            }
+         
+        CleanupStack::PopAndDestroy( dirContents );    
+        }
+    else
+        {
+        RUBY_DEBUG1( "CVCommandManager::ParseAllFilesFromDirectoryL - GetDir returns [%d]", error );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandManager::CompareCommands
+// Compares if two commands are equal
+// -----------------------------------------------------------------------------
+//  
+TBool CVCommandManager::CompareCommands( const CVCommand* aFirst, const CVCommand* aSecond )
+    {
+    TBool result = EFalse;
+        
+    if ( aFirst && aSecond )
+        {
+        result = aFirst->Runnable() == aSecond->Runnable();
+        }
+    
+    return result;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandManager::~CVCommandManager
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CVCommandManager::~CVCommandManager()
+    {
+    delete iParser;
+//    delete iClient;
+    delete iCommandArray;
+    
+    iCommands.ResetAndDestroy();
+    iMatchingIndices.Close();
+    
+    iRFs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManager::VCMThreadFunction
+// Static main function for Voice Command Manager thread
+// -----------------------------------------------------------------------------
+//    
+TInt CVCommandManager::VCMThreadFunction( TAny* /*aParams*/ )
+    {
+    __UHEAP_MARK;
+    
+    // CleanupStack creation
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+
+    CActiveScheduler* scheduler = NULL;
+    
+    TInt error = KErrNone;
+    
+    TRAP( error, 
+
+        // ActiveScheduler creation
+        scheduler = new ( ELeave ) CActiveScheduler();
+        
+        CleanupStack::PushL( scheduler );
+
+        CActiveScheduler::Install( scheduler );
+        
+        TSecureId sid = RThread().SecureId();
+        RUBY_DEBUG1( "VCommandManager secure id [%x]", sid.iId );
+        
+        // Create VCommandManager
+        CVCommandManager* vcmanager = CVCommandManager::NewL( EFalse );
+        delete vcmanager;
+
+        CleanupStack::PopAndDestroy( scheduler ); 
+    ); // TRAP
+    
+    delete cleanupStack;
+    
+    __UHEAP_MARKEND;
+    
+    RUBY_DEBUG0( "CVCommandManager::VCMThreadFunction finished ok" );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CVCommandManager::ConstructCommandL
+// Constructs new command with given data
+// -----------------------------------------------------------------------------
+//      
+void CVCommandManager::ConstructCommandL( const TDesC& aWrittenText,
+                                          const TDesC& aSpokenText,
+                                          const TDesC& aTooltipText,
+                                          const TDesC& aFolder,
+                                          const TDesC& aFolderTitle,
+                                          const TDesC& aParameters, 
+                                          TUid aIcon,
+                                          TUid aAppId,
+                                          const TDesC& aAppName,
+                                          TBool aStartImmediately,
+                                          TBool aUserCanModify,
+                                          const TDesC& aFolderIconFile,
+                                      	  TInt aFolderIconIndex
+                                           )
+    {
+    const TInt KCenRepBufferSize = 255;
+
+    RUBY_DEBUG_BLOCKL( "CVCommandManager::ConstructCommandL" );
+    
+    RUBY_DEBUG1( "CVCommandManager::ConstructCommandL - Creating command: [%S]", &aWrittenText );    
+    
+    // First check that if the application is hidden so voice command is not created then
+    if ( aAppId != KNullUid )
+    	{
+    	
+	    TBuf<KCenRepBufferSize> buf;
+	    CRepository* cenRepSession = CRepository::NewLC( KCRUidMenu );
+	    cenRepSession->Get( KMenuHideApplication, buf );
+	    CleanupStack::PopAndDestroy( cenRepSession );
+
+		buf.LowerCase();
+	    TBuf<8> textUidHex;
+	    textUidHex.AppendNumFixedWidth( aAppId.iUid, EHex, 8 );    
+	    if ( buf.Find( textUidHex ) != KErrNotFound )
+	    	{
+	    	// hidden application: no voice tag needed
+	    	RUBY_DEBUG1( "%S hidden application", &aWrittenText );  
+	    	return;
+	    	}
+        }
+        	    
+	HBufC8* arguments = HBufC8::NewL( aParameters.Length() );
+	CleanupStack::PushL( arguments );
+	TPtr8 argumentsPtr = arguments->Des();
+	argumentsPtr.Copy( aParameters );        
+
+            
+    // Create runnable object
+    CVCRunnable* runnable = NULL;        
+    if ( aAppId != KNullUid )
+        {
+        runnable = CVCRunnable::NewL( aAppId, argumentsPtr );
+        }
+    else
+        {
+        runnable = CVCRunnable::NewL( aAppName, argumentsPtr );
+        }
+    CleanupStack::PushL( runnable );
+    
+    CVCFolderInfo* folderInfo = CVCFolderInfo::NewL( aFolderTitle, aFolder, 0, 
+    												 aFolderIconIndex, aFolderIconFile );
+    CleanupStack::PushL( folderInfo );
+    // Create commandUi object
+    CVCCommandUi* commandUi = CVCCommandUi::NewL( aWrittenText,
+                                                  *folderInfo,
+                                                  aUserCanModify,
+                                                  aTooltipText,
+                                                  aIcon,
+                                                  KNullDesC,
+                                                  !aStartImmediately );
+    CleanupStack::PopAndDestroy( folderInfo );
+    CleanupStack::PushL( commandUi );
+       
+    // Create command object
+    CVCommand* command = CVCommand::NewL( aSpokenText, *runnable, *commandUi );
+        
+    TBool found = EFalse;
+      
+    // Check that identical command has not already been found from some xml-file
+    for ( int i = 0; i < iCommands.Count(); ++i )
+        {
+        if ( CompareCommands( iCommands[ i ], command ) )
+            {
+            found = ETrue;
+            break;
+            }            
+        }
+        
+    // Add command if not found already
+    if ( !found )
+        {
+        iCommands.Append( command );
+        iMatchingIndices.Append( KErrNotFound );
+        }
+    else
+        {
+        delete command;
+        }
+        
+    CleanupStack::PopAndDestroy( commandUi ); 
+    CleanupStack::PopAndDestroy( runnable ); 
+    CleanupStack::PopAndDestroy( arguments );    
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCommandManager::MvcxpoVoiceCommandFound
+// Callback from VC XML parser
+// -----------------------------------------------------------------------------
+//        
+void CVCommandManager::MvcxpoVoiceCommandFound( const TDesC& aWrittenText,
+                                                const TDesC& aSpokenText,
+                                                const TDesC& aTooltipText,
+                                                const TDesC& aFolder,
+                                                const TDesC& aFolderTitle,
+                                                const TDesC& aParameters, 
+                                                TUid aIcon,
+                                                TUid aAppId,
+                                                const TDesC& aAppName,
+                                                TBool aStartImmediately,
+                                                TBool aUserCanModify,
+                                                const TDesC& aFolderIconFile,
+		                                        TInt aFolderIconIndex
+                                                 )
+    {
+    RUBY_DEBUG0( "CVCommandManager::MvcxpoVoiceCommandFound START" );
+    
+    TRAP_IGNORE( ConstructCommandL( aWrittenText,
+                                    aSpokenText,
+                                    aTooltipText,
+                                    aFolder,
+                                    aFolderTitle,
+                                    aParameters,
+                                    aIcon,
+                                    aAppId,
+                                    aAppName,
+                                    aStartImmediately,
+                                    aUserCanModify,
+                                    aFolderIconFile,
+                                    aFolderIconIndex ) );
+      
+    RUBY_DEBUG0( "CVCommandManager::MvcxpoVoiceCommandFound EXIT" );
+    }
+                                      
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcommandmanager.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main class of Voice Command Manager
+*
+*/
+
+
+#ifndef VCOMMANDMANAGER_H
+#define VCOMMANDMANAGER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include "vcxmlparser.h"
+
+#include "vcommandapi.h"
+
+// FORWARD DECLARATIONS
+
+class CRepository;
+class CVCommandHandler;
+class CVCommandArray;
+class CVCommand;
+
+// CLASS DECLARATION
+
+/**
+* Main class of Voice Command Manager
+*
+* @lib nssvcommandmanager.exe
+*
+*/
+class CVCommandManager : public CBase, public MVcXmlParserObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * 
+        * @param aForceRetrain For testing purposes. ETrue to retrain all commands
+        */
+        static CVCommandManager* NewL( TBool aForceRetrain );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVCommandManager();
+        
+    public: // From MVcXmlParserObserver
+    
+        /**
+        * Creates new voice command with given parameters
+        *
+        * @see MVcXmlParserObserver for more information
+        */
+        void MvcxpoVoiceCommandFound( const TDesC& aWrittenText,
+                                      const TDesC& aSpokenText,
+                                      const TDesC& aTooltipText,
+                                      const TDesC& aFolder,
+                                      const TDesC& aFolderTitle,
+                                      const TDesC& aParameters, 
+                                      TUid aIcon,
+                                      TUid aAppId,
+                                      const TDesC& aAppName,
+                                      TBool aStartImmediately,
+                                      TBool aUserCanModify,
+                                      const TDesC& aFolderIconFile,
+                                      TInt aFolderIconIndex
+                                      );
+        
+    public: // New functions
+
+        /**
+        * Thread function.
+        */
+        static TInt VCMThreadFunction( TAny* aParams );
+       
+    private:
+        
+        /**
+        * C++ default constructor.
+        * 
+        * @param aForceRetrain For testing purposes. ETrue to retrain all commands
+        */
+        CVCommandManager( TBool aForceRetrain );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Goes through all XML files
+        */ 
+        void ParseAllFilesL();
+        
+        
+        /**
+        * Goes through all XML files in directory
+        *
+        * @param aDrive Contains directory path (e.g. C:\private\)
+        */
+        void ParseAllFilesFromDirectoryL( const TDesC& aDirectory );
+
+        /**
+        * Compares if two commands are equal
+        * @param aFirst Command to compare
+        * @param aSecond Command to compare
+        * @return ETrue if commands are equal else EFalse
+        */
+        TBool CompareCommands( const CVCommand* aFirst, const CVCommand* aSecond );
+        
+        void ConstructCommandL( const TDesC& aWrittenText,
+                                const TDesC& aSpokenText,
+                                const TDesC& aTooltipText,
+                                const TDesC& aFolder,
+                                const TDesC& aFolderTitle,
+                                const TDesC& aParameters, 
+                                TUid aIcon,
+                                TUid aAppId,
+                                const TDesC& aAppName,
+                                TBool aStartImmediately,
+                                TBool aUserCanModify,
+                                const TDesC& aFolderIconFile,
+                                TInt aFolderIconIndex
+                                );
+
+        
+    private: // Data
+
+        // Parser
+        CVcXmlParser*                   iParser;
+        
+        // Command array for commands found from xml-files
+        RVCommandArray                  iCommands;
+        
+        // Command index array
+        RArray<TInt>                    iMatchingIndices;
+        
+        // Command array for commands found from VAS
+        CVCommandArray*                 iCommandArray;
+        
+        // Tells if language has changed
+        TBool                           iLanguageChanged;
+        
+        // File system handle
+        RFs                             iRFs;
+ 
+    };
+
+#endif // VCOMMANDMANAGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcommandmerger.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommandManager application which is started during boot. 
+*
+*/
+
+
+// INCLUDE FILES
+#include "rubydebug.h"
+#include "vcommandmerger.h"
+// For CleanupResetAndDestroyPushL
+//#include <mmfcontrollerpluginresolver.h> 
+
+CVCommandMerger* CVCommandMerger::NewLC()
+    {
+    CVCommandMerger* self = new (ELeave) CVCommandMerger;
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+/** 
+ * @todo Move the internal member comparisons to the primitive classes
+ */
+
+// Returns the array of commands from aTarget that have counterparts
+// in aInjection with the equal Runnable, but with different spoken text or UI
+// Difference in user texts only does not count
+CVCommandArray* CVCommandMerger::ProduceDeductionByRunnablesLC( const CVCommandArray& aTarget, 
+                                                          const RVCommandArray& aInjection ) const
+    {
+    return aTarget.ProduceUntrainSetByRunnablesLC( aInjection );;
+    }                                                                    
+                                       
+// Returns the array of commands from aInjection that have 
+// counterparts in aTarget with the equal Runnable, but with different spoken text or UI
+// Difference in user texts only does not count
+CVCommandArray* CVCommandMerger::ProduceAdditionByRunnablesLC( const CVCommandArray& aTarget, 
+                                                     const RVCommandArray& aInjection ) const
+    {
+    return aTarget.ProduceTrainSetByRunnablesLC( aInjection );
+    }                                                                    
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcommandmerger.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VCOMMANDMERGER_H
+#define VCOMMANDMERGER_H
+
+//  INCLUDES
+#include <e32base.h>
+
+#include "vcommandapi.h"
+
+class CVCommandMerger : public CBase
+	{
+	public:
+		static CVCommandMerger* NewLC();
+		
+		/**
+         * Compares the runnable component of the aTarget commands with the one of
+         * aInjection commands. Returns the array of commands from aTarget that have counterparts
+         * in aInjection with the equal Runnable, but with different spoken text or UI.
+         * Difference in user texts only does not count
+         * 
+         * This is to detect the commands that should be removed when the system language 
+         * is changed
+         * 
+         * @param aTarget Set of commands "already existing in the system".
+         * @param aInjection Set of new commands to replace the aTarget commands with the equal
+         *        runnables
+         * 
+         * @return Array of commands from aTarget that have counterparts
+         *         in aInjection with the equal Runnable, but with different spoken text or UI.
+		 */
+		CVCommandArray* ProduceDeductionByRunnablesLC( const CVCommandArray& aTarget, 
+											   	       const RVCommandArray& aInjection ) const;
+											   
+        /**
+         * Compares the runnable component of the aTarget commands with the one of
+         * aInjection commands. Returns the array of commands consisting of everything
+         * in aInjection, without the commands fully equal to any command in aTarget
+         * Difference in user texts only does not count
+         * 
+         * This is to detect the commands that should be (re)trained when the system language 
+         * is changed
+         * 
+         * @param aTarget Set of commands "already existing in the system".
+         * @param aInjection Set of new commands to replace the aTarget commands with the equal
+         *        runnables
+         * 
+         * @return the array of commands consisting of everything
+         * in aInjection, without the commands fully equal to any command in aTarget
+         */
+         CVCommandArray* ProduceAdditionByRunnablesLC( const CVCommandArray& aTarget, 
+											           const RVCommandArray& aInjection ) const;
+	};
+
+#endif // VCOMMANDMERGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcresource.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,273 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include "vcresource.h"
+#include "rubydebug.h"
+#include <defaultvoicecommands.rsg>
+#include <barsc.h>
+#include <barsread.h>
+#include <bautils.h>
+#include <data_caging_path_literals.hrh>
+#include <numberconversion.h>
+
+// CONSTANTS
+
+// File name extension for EngineeringEnglish resource file
+_LIT( KDefaultLanguageExtension, ".rsc" );
+
+// Drives where resource file will be searched
+const TBuf<2> KResourceDrives = _L("cz");
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVcResource::CVcResource
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVcResource::CVcResource( RFs& aRFs )
+ : iRFs( aRFs )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcResource::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVcResource::ConstructL( const TDesC& aFileName )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcResource::ConstructL" );
+    
+    ResolveResourceFileL( aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcResource::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVcResource* CVcResource::NewL( RFs& aRFs, const TDesC& aFileName )
+    {
+    CVcResource* self = new( ELeave ) CVcResource( aRFs );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL( aFileName );
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcResource::~CVcResource
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CVcResource::~CVcResource()
+    {
+    iKeys.Close();
+    iCommands.ResetAndDestroy();
+    iCommands.Close();
+    iIntegerKeys.Close();
+    iIntegerValues.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CVcResource::GetCommand
+// Gets the localized string based on integer key
+// -----------------------------------------------------------------------------
+//
+HBufC& CVcResource::GetCommandL( TInt aKey )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcResource::GetCommandL(TInt)" );
+    
+    TInt index = iKeys.Find( aKey );
+    User::LeaveIfError( index );
+
+    return *iCommands[ index ];
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ReadValueFromLocFile
+// Gets the localized string based on descriptor key 
+// -----------------------------------------------------------------------------
+//
+HBufC& CVcResource::GetCommandL( const TDesC& aKey )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcResource::GetCommandL(TDesC)" );
+    
+    TInt length( 0 );
+    TInt result( 0 );
+    TDigitType dt( EDigitTypeWestern );
+    result = NumberConversion::ConvertFirstNumber( aKey, length, dt );
+
+    if ( length == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    return GetCommandL( result );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcResource::GetValueL
+// Gets the localized string based on integer key
+// -----------------------------------------------------------------------------
+//
+TInt CVcResource::GetValueL( TInt aKey )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcResource::GetValueL(TInt)" );
+    
+    TInt index = iIntegerKeys.Find( aKey );
+    User::LeaveIfError( index );
+
+    return iIntegerValues[ index ];
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ReadValueFromLocFile
+// Gets the localized string based on descriptor key 
+// -----------------------------------------------------------------------------
+//
+TInt CVcResource::GetValueL( const TDesC& aKey )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcResource::GetValueL(TDesC)" );
+    
+    TInt length( 0 );
+    TInt result( 0 );
+    TDigitType dt( EDigitTypeWestern );
+    result = NumberConversion::ConvertFirstNumber( aKey, length, dt );
+
+    if ( length == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    return GetValueL( result );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVcResource::ResolveResourceFileL
+// Resolves the correct localized resource file name
+// -----------------------------------------------------------------------------
+//
+void CVcResource::ResolveResourceFileL( const TDesC& aFileName )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveResourceFileL" );
+    
+    // Resource file found/not found flag
+    TBool found( EFalse );
+    
+    TFileName name;
+
+    name.Append( 'a' ); // this will be replaced by real drive letter
+    name.Append( ':' );
+    name.Append( KDC_RESOURCE_FILES_DIR );
+    name.Append( aFileName );
+    name.Append( KDefaultLanguageExtension );
+             
+    TDriveList drivelist;
+    User::LeaveIfError( iRFs.DriveList( drivelist ) ); 
+    TInt drive( EDriveA );
+    
+    while ( !found && drive <= EDriveZ )
+        {
+        if ( drivelist[drive] ) 
+            {
+            TChar driveLetter; 
+			User::LeaveIfError( iRFs.DriveToChar( drive, driveLetter ) );
+            name[0] = driveLetter;
+                    
+            BaflUtils::NearestLanguageFile( iRFs, name );
+         
+            if ( BaflUtils::FileExists( iRFs, name ) )
+                {
+                // Read resource
+                found = ETrue;
+                ReadResourceFileL( iRFs, name );
+                }
+            }
+        drive++;
+        }
+        
+    }
+
+// -----------------------------------------------------------------------------
+// CVcResource::ReadResourceFileL
+// Loads the resource file content
+// -----------------------------------------------------------------------------
+//
+void CVcResource::ReadResourceFileL( RFs& aRfs, const TDesC& aFileName )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ReadResourceFileL" );
+    
+    RResourceFile resourceFile;
+
+    resourceFile.OpenL( aRfs, aFileName );
+    CleanupClosePushL( resourceFile );
+
+	HBufC8* res = resourceFile.AllocReadLC( VOICECOMMANDS );
+
+	TResourceReader reader;
+	reader.SetBuffer( res );
+
+    TInt index( 0 );
+    TInt number( 0 );
+    
+    // The first WORD contains the number 
+    // of structs within the resource
+    number = reader.ReadInt16();
+
+    for ( index = 0; index < number ; index++ )
+        {
+        TInt key = reader.ReadInt16();
+        iKeys.Append( key );
+        HBufC* command = reader.ReadHBufCL();
+        iCommands.Append( command );
+        }
+
+	CleanupStack::PopAndDestroy( res );
+	
+	
+	res = resourceFile.AllocReadLC( VCOMMANDINTEGERS );
+
+	reader.SetBuffer( res );
+
+    index = 0;
+    number = 0;
+    
+    // The first WORD contains the number 
+    // of structs within the resource
+    number = reader.ReadInt16();
+
+    for ( index = 0; index < number ; index++ )
+        {
+        iIntegerKeys.Append( reader.ReadInt16() );
+        iIntegerValues.Append( reader.ReadInt16() );
+        }
+
+	CleanupStack::PopAndDestroy( res );
+	CleanupStack::PopAndDestroy( &resourceFile );
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcresource.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class which contains localized voice command strings. Read 
+*               from a resource file.
+*
+*/
+
+
+#ifndef VCRESOURCE_H
+#define VCRESOURCE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+
+// CLASS DECLARATION
+
+/**
+*   Class which contains localized voice command strings. Read 
+*   from a resource file.
+*
+*/
+NONSHARABLE_CLASS( CVcResource ) : public CBase
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor. Leaves if resource file cannot be found.
+        * 
+        * @param aRFs File system handle
+        * @param aFileName Resource file name without any path info
+        *        and without any filename extension.
+        */
+        static CVcResource* NewL( RFs& aRFs, const TDesC& aFileName );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVcResource();
+        
+    public: // New functions
+        
+        /**
+        * Gets the localized string based on an integer key value.
+        * Ownership of the returned string is not transferred
+        *
+        * @param aKey Key integer
+        * @return Reference to localized voice command string
+        */
+        HBufC& GetCommandL( TInt aKey );
+        
+        /**
+        * Gets the localized string based on a descriptor key value.
+        * Descriptor needs to contain numerical information.
+        * Ownership of the returned string is not transferred
+        *
+        * @param aKey Key containing numerical information
+        * @return Reference to localized voice command string
+        */
+        HBufC& GetCommandL( const TDesC& aKey );
+
+        /**
+        * Gets integer value based on descriptor key.
+        *
+        * @param aKey Key containing numerical information
+        * @return Value for the key
+        */
+        TInt GetValueL( const TDesC& aKey );
+       
+        /**
+        * Gets integer value based on integer key.
+        *
+        * @param aKey Key integer
+        * @return Value for the key
+        */
+        TInt GetValueL( TInt aKey );
+       
+    private:
+        
+        /**
+        * C++ default constructor.
+        *
+        * @param aRFs File system handle
+        */
+        CVcResource( RFs& aRFs );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        *
+        * @param aFileName Resource file name
+        */
+        void ConstructL( const TDesC& aFileName );
+        
+        /**
+        * Resolves the correct localized resource file name.
+        * 
+        * @param aFileName Resource file name
+        */
+        void ResolveResourceFileL( const TDesC& aFileName );
+        
+        /**
+        * Loads the resource file content
+        *
+        * @param aRfs File system handle
+        * @param aFileName Resource file name
+        */
+        void ReadResourceFileL( RFs& aRfs, const TDesC& aFileName );
+        
+    private: // Data
+
+        // List of keys
+        RArray<TInt>            iKeys;
+        
+        // List of localized strings
+        RPointerArray<HBufC>    iCommands;
+                
+        // List of keys to the integer array
+        RArray<TInt>            iIntegerKeys;
+        
+        // List of integer values
+        RArray<TInt>            iIntegerValues;
+        
+        // File system handle
+        RFs&                    iRFs;        
+    };
+
+#endif // VCRESOURCE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcxmlparser.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1181 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Parser for Voice Commands XML files
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32math.h>
+#include <featmgr.h>
+#include <parser.h>
+#include <utf.h>
+#include "vcxmlparser.h"
+#include "vcresource.h"
+#include "rubydebug.h"
+
+// CONSTANTS
+// XML Tags
+_LIT8( KXmlDocumentTag, "nssvcommands" );
+_LIT8( KXmlFolderTag, "vcommandfolder" );
+_LIT8( KXmlVCommandTag, "vcommand" );
+_LIT8( KXmlSpokenTag, "spoken" ); 
+_LIT8( KXmlWrittenTag, "written" ); 
+_LIT8( KXmlExecutesTag, "executes" );
+_LIT8( KXmlCmdlineparamsTag, "cmdlineparams" );
+_LIT8( KXmlIconTag, "icon" );
+_LIT8( KXmlTooltipTag, "tooltip" );
+
+// XML attributes
+_LIT8( KXmlVersionAttr, "version" );
+_LIT8( KXmlLocFileAttr, "localizationfile" );
+_LIT8( KXmlLocAttr, "locindex" );
+_LIT8( KXmlFolderTitleLocAttr, "titlelocindex" );
+_LIT8( KXmlFolderIconFileAttr, "iconfile" );
+_LIT8( KXmlFolderIconIndexAttr, "iconindex" );
+_LIT8( KXmlTtsAttr, "tts" );
+_LIT8( KXmlModifiableAttr, "modifiable" );
+_LIT8( KXmlUidAttr, "uid" );
+_LIT8( KXmlExeAttr, "exe" );
+
+// XML attribute values
+_LIT8( KXmlVersionValue, "1.0" );
+_LIT8( KXmlTrueValue, "true" );
+_LIT8( KXmlFalseValue, "false" );
+
+// XML file MIME type
+_LIT8( KMimeType, "text/xml" );
+
+static const TInt KNoTags = 0;
+static const TInt KLastTag = 1;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::CVcXmlParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVcXmlParser::CVcXmlParser( RFs& aRFs, MVcXmlParserObserver& aObserver )
+ : iObserver( aObserver ), iRFs( aRFs )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVcXmlParser::ConstructL" );
+    
+    ResetVCommandFolder();
+    
+    using namespace Xml;
+    
+    iParser = CParser::NewL( KMimeType, *this );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVcXmlParser* CVcXmlParser::NewL( RFs& aRFs, MVcXmlParserObserver& aObserver )
+    {
+    CVcXmlParser* self = new( ELeave ) CVcXmlParser( aRFs, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::~CVcXmlParser
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CVcXmlParser::~CVcXmlParser()
+    {
+    iXmlNesting.Close();
+    ResetVCommandInfo();
+    delete iResource;
+    delete iFolder;
+    delete iFolderTitle;
+    delete iFolderIconFile;
+    delete iAttributeValue;
+    delete iParser;
+    delete iParameters;
+    delete iParameters8;
+    delete iAppName;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ParseFileL
+// Parses a specific file.
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::ParseFileL( const TFileName& aFileName )
+    {
+    RUBY_DEBUG_BLOCK( "CVcXmlParser::ParseFileL" );
+    
+    iParser->ParseBeginL();
+    
+    ParseL( *iParser, iRFs, aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnStartDocumentL
+// Callback from XML parser when beginning of document has been found
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnStartDocumentL( const Xml::RDocumentParameters& /*aDocParam*/, 
+                                     TInt aErrorCode )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::OnStartDocumentL" );
+    
+    delete iResource;
+    iResource = NULL;
+    
+    if ( ( iXmlNesting.Count() == KNoTags ) && ( aErrorCode == KErrNone ) )
+        {
+        iXmlNesting.Append( EXmlStarted );
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnEndDocumentL
+// Callback from XML parser when end of document has been reached
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnEndDocumentL( TInt aErrorCode )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::OnEndDocumentL" );
+    
+    if ( ( iXmlNesting.Count() == KLastTag ) && ( aErrorCode == KErrNone ) )
+        {
+        iXmlNesting.Reset();
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnStartElementL
+// Callback from XML parser when new element has been found
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnStartElementL( const Xml::RTagInfo& aElement, 
+	                                const Xml::RAttributeArray& aAttributes, 
+	                                TInt aErrorCode )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::OnStartElementL" );
+    __ASSERT_ALWAYS( iXmlNesting.Count() > 0, User::Leave( KErrCorrupt ) );    
+    
+    User::LeaveIfError( aErrorCode );
+
+    HBufC8* name = ToLowercaseLC( aElement.LocalName().DesC() );
+
+    // Check what was the previous tag
+    switch ( iXmlNesting[ iXmlNesting.Count() - 1 ] )
+        {
+        case EXmlStarted:
+            {
+            if ( !ResolveDocumentTagL( name->Des(), aAttributes ) )
+                {
+                User::Leave( KErrNotFound );
+                }
+            break;
+            }
+            
+        case EXmlDocument:
+            {
+            if ( !ResolveFolderTagL( name->Des(), aAttributes ) )
+                {
+                if ( !ResolveVCommandTagL( name->Des(), aAttributes ) )
+                    {
+                    RUBY_DEBUG0( "VC XML ERROR: <vcommandfolder> or <vcommand> exptected but not found" );
+                    User::Leave( KErrNotFound );
+                    }
+                }
+            break;
+            }
+        
+        case EXmlFolder:
+            {
+            if ( !ResolveVCommandTagL( name->Des(), aAttributes ) )
+                {
+                RUBY_DEBUG0( "VC XML ERROR: <vcommand> exptected but not found" );
+                User::Leave( KErrNotFound );
+                }
+
+            // New voice command starts
+            ResetVCommandInfo();
+             
+            break;
+            }
+        
+        case EXmlVCommand:
+            {
+            if ( !ResolveSpokenTagL( name->Des(), aAttributes ) )
+                {
+                if ( !ResolveWrittenTagL( name->Des(), aAttributes ) )
+                    {
+                    if ( !ResolveExecutesTagL( name->Des(), aAttributes ) )
+                        {
+                        if ( !ResolveCmdlineparamsTag( name->Des(), aAttributes ) )
+                            {
+                            if ( !ResolveIconTagL( name->Des(), aAttributes ) )
+                                {
+                                if ( !ResolveTooltipTagL( name->Des(), aAttributes ) )
+                                    {
+                                    RUBY_DEBUG0( "VC XML ERROR: <spoken> <written> <executes> or <cmdlineparams> exptected but not found" );   
+                                    User::Leave( KErrNotFound );
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            break;
+            }
+            
+        default:
+            {
+            
+            RUBY_DEBUG0( "VC XML ERROR: Unexpected starting tag found" );
+            User::Leave( KErrNotFound );
+            
+            break;
+            }
+
+        }
+        
+    CleanupStack::PopAndDestroy( name );
+ 
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnEndElementL
+// Callback from XML parser when ending tag has been found
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnEndElementL( const Xml::RTagInfo& aElement, 
+                                  TInt aErrorCode )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::OnEndElementL" );
+    __ASSERT_ALWAYS( iXmlNesting.Count() > 0, User::Leave( KErrCorrupt ) );
+    
+    User::LeaveIfError( aErrorCode );
+    
+    HBufC8* name = ToLowercaseLC( aElement.LocalName().DesC() );
+    
+    switch ( iXmlNesting[ iXmlNesting.Count() - 1 ] )
+        {
+        case EXmlDocument:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlDocumentTag );
+            break;
+            }
+        
+        case EXmlFolder:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlFolderTag );
+            ResetVCommandFolder();
+            break;
+            }
+        
+        case EXmlVCommand:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlVCommandTag );
+            CheckVoiceCommmandData();
+            break;
+            }
+            
+         case EXmlSpoken:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlSpokenTag );
+            break;
+            }
+         
+         case EXmlWritten:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlWrittenTag );
+            break;
+            }
+        
+         case EXmlExecutes:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlExecutesTag );
+            break;
+            }
+         
+         case EXmlCmdlineparams:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlCmdlineparamsTag );   
+                
+            // Convert content of <cmdlineparams> into unicode
+            // First trim out unnecessary white space
+            TPtr8 des8( iParameters8->Des() );
+            des8.Trim();
+                
+            // Delete previous unicode buffer and create new
+            delete iParameters;
+            iParameters = NULL;
+            iParameters = CnvUtfConverter::ConvertToUnicodeFromUtf8L( des8 );
+                
+            break;
+            }
+
+         case EXmlIcon:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlIconTag );
+            break;
+            }
+
+         case EXmlTooltip:
+            {
+            PopFromStackIfFoundL( name->Des(), KXmlTooltipTag );
+            break;
+            }
+           
+        default:
+            {
+            RUBY_DEBUG0( "VC XML ERROR: Ending tag found when not expected" );
+            User::Leave( KErrGeneral );
+            break;
+            }
+
+        }
+    CleanupStack::PopAndDestroy( name );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::PopFromStackIfFoundL
+// Checks that last item on stack is the expected one
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::PopFromStackIfFoundL( const TDesC8& aTagName, const TDesC8& aExpectedTag )
+    {
+    if ( aTagName != aExpectedTag )
+        {
+        RUBY_DEBUG0( "VC XML ERROR: Unexpected ending tag found" );
+        User::Leave( KErrNotFound );
+        }
+        
+    iXmlNesting.Remove( iXmlNesting.Count() - 1 );    
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnContentL
+// Callback from XML parser when element has some content
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnContentL( const TDesC8& aBytes, TInt aErrorCode )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::OnContentL" );
+    
+    User::LeaveIfError( aErrorCode );
+    
+    TInt lastTag = iXmlNesting.Count() - 1;
+    
+    if ( iXmlNesting[ lastTag ] == EXmlCmdlineparams )
+        {
+        if ( !iParameters8 )
+            {
+            // Create new buffer
+            iParameters8 = HBufC8::NewL( aBytes.Size() );
+            TPtr8 des( iParameters8->Des() );
+            des.Copy( aBytes );
+            }
+        else
+            {
+            // Append at the end of previous stuff
+            iParameters8 = iParameters8->ReAllocL( iParameters8->Size() + aBytes.Size() );
+            TPtr8 des( iParameters8->Des() );
+            des.Append( aBytes );
+            }
+
+        RUBY_DEBUG0( "<cmdlineparams> content resolved" );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnStartPrefixMappingL
+// Callback from XML parser
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
+	                                      const RString& /*aUri*/, 
+	                                      TInt /*aErrorCode*/ )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnEndPrefixMappingL
+// Callback from XML parser
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
+                                        TInt /*aErrorCode*/ )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnIgnorableWhiteSpaceL
+// Callback from XML parser
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
+                                           TInt /*aErrorCode*/ )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnSkippedEntityL
+// Callback from XML parser
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnSkippedEntityL( const RString& /*aName*/, 
+                                     TInt /*aErrorCode*/ )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnProcessingInstructionL
+// Callback from XML parser
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, 
+                                             const TDesC8& /*aData*/, 
+	                                         TInt /*aErrorCode*/ )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::OnError
+// Callback from XML parser when general error has occured
+// -----------------------------------------------------------------------------
+//
+#if defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+void CVcXmlParser::OnError( TInt aErrorCode )
+    {
+    RUBY_DEBUG1( "CVcXmlParser::OnError general error: [%d]", aErrorCode );
+    }
+#else
+void CVcXmlParser::OnError( TInt /*aErrorCode*/ )
+    {
+    // Nothing
+    }
+#endif // #if defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+    
+// -----------------------------------------------------------------------------
+// CVcXmlParser::GetExtendedInterface
+// Callback from XML parser
+// -----------------------------------------------------------------------------
+//
+TAny* CVcXmlParser::GetExtendedInterface( const TInt32 /*aUid*/ )
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::CheckAttributeL
+// Checks the value of certain attribute
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::CheckAttributeL( const Xml::RAttributeArray& aAttributes,
+                                     const TDesC8& aAttribute, const TDesC8& aValue )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::CheckAttributeL" );
+    
+    TBool resolved( EFalse );
+    
+    // Loop through attribute list
+    for ( TInt iCounter = 0 ; iCounter < aAttributes.Count() ; iCounter++ )
+        {        
+        HBufC8* name = ToLowercaseLC( aAttributes[iCounter].Attribute().LocalName().DesC() );
+       
+        if ( name->Des() == aAttribute )
+            {
+            HBufC8* value = ToLowercaseLC( aAttributes[iCounter].Value().DesC() );
+            
+            // If value is null descriptor, then we just check if attribute exists           
+            if ( aValue == KNullDesC8 || value->Des() == aValue )
+                {                
+                resolved = ETrue;
+                }
+            
+            CleanupStack::PopAndDestroy( value );
+            }
+        CleanupStack::PopAndDestroy( name );
+        }
+        
+    return resolved;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveDocumentTagL
+// Resolves the content of <nssvcommands>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveDocumentTagL( const TDesC8& aName, 
+                                        const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveDocumentTagL" );
+    
+    TBool resolved( EFalse );
+    
+    if ( aName == KXmlDocumentTag )
+        {
+        iXmlNesting.Append( EXmlDocument );
+        resolved = CheckAttributeL( aAttributes, KXmlVersionAttr, KXmlVersionValue );
+        if ( !resolved )
+            {
+            RUBY_DEBUG0( "VC XML ERROR: Version information not found or it does not match" );
+            User::Leave( KErrGeneral );
+            }
+        else
+            {
+            CVcResource* newResource( NULL );
+            TPtrC8 locFileAttr( KXmlLocFileAttr );
+            TRAPD( error, newResource =
+                CVcResource::NewL( iRFs, Find16ValueL( locFileAttr, aAttributes ) ) );
+
+            // Delete old resource object if new was found
+            if ( newResource )
+                {
+                delete iResource;
+                iResource = newResource;
+                }
+        
+            if ( error != KErrNone )
+                {
+                resolved = EFalse;
+                RUBY_DEBUG0( "VC XML ERROR: Resource file load error" );
+                User::Leave( KErrNotFound );
+                }
+            }
+        }
+     else
+        {
+        RUBY_DEBUG0( "VC XML ERROR: <nssvoicecommands> exptected but not found" );
+        User::Leave( KErrNotFound );        
+        }
+               
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveFolderTagL
+// Resolves the content of <vcommandfolder>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveFolderTagL( const TDesC8& aName, 
+                                       const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveFolderTagL" );
+    
+    // Use specific resource file for folder strings if specified
+    CVcResource* mainResource = iResource;
+    
+    CVcResource* newResource( NULL );
+    TPtrC locFile = Find16ValueL( KXmlLocFileAttr, aAttributes );
+    if ( locFile != KNullDesC )
+        {
+        newResource = CVcResource::NewL( iRFs, locFile );
+        }
+                  
+    if ( newResource )
+        {
+        iResource = newResource;
+        CleanupStack::PushL( mainResource );
+        }    
+    
+    // Find folder name
+    TBool resolved = ResolveLocalizedTagL( aName, aAttributes, KXmlFolderTag, 
+                                           EXmlFolder );
+    if ( resolved )
+        {
+        delete iFolder;
+        iFolder = iCurrentLocalizedString;
+        iCurrentLocalizedString = NULL;
+        
+        // Find folder title string
+        TBool titleFound = GetLocalizedStringL( aAttributes, KXmlFolderTitleLocAttr );
+        
+        if ( titleFound )
+            {
+            delete iFolderTitle;
+            iFolderTitle = iCurrentLocalizedString;
+            iCurrentLocalizedString = NULL;
+            }
+            
+        TBool iconFileFound = ResolveFolderIconFileL( aAttributes );
+        RUBY_DEBUG1( "iconFileFound [%d]", iconFileFound );
+        iFolderIconIndex = ResolveFolderIconIndexL( aAttributes );
+       
+        }
+        
+    // Revert back to use the old resource file
+    iResource = mainResource;
+    if ( newResource )
+        {
+        delete newResource;
+        CleanupStack::Pop( mainResource );
+        }
+                
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveVCommandTagL
+// Resolves the content of <vcommand>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveVCommandTagL( const TDesC8& aName, 
+                                         const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveVCommandTagL" );
+    
+    TBool resolved( EFalse );
+    if ( aName == KXmlVCommandTag )
+        {
+        resolved = ETrue;
+        iXmlNesting.Append( EXmlVCommand );
+        }
+    
+    if ( resolved )
+        {
+        // TTS on/off  
+        resolved = CheckAttributeL( aAttributes, KXmlTtsAttr, KXmlTrueValue );
+        if ( resolved )
+            {
+            // By default, tts is on
+            iStartImmediately = ETrue;
+            }
+        
+        // Modifiable on/off
+        resolved = CheckAttributeL( aAttributes, KXmlModifiableAttr, KXmlFalseValue );
+        if ( resolved )
+            {
+            iUserCanModify = EFalse;
+            }
+            
+        resolved = ETrue;
+        }
+
+    return resolved;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveSpokenTagL
+// Resolves the content of <spoken>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveSpokenTagL( const TDesC8& aName, 
+                                       const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveSpokenTagL" );
+    
+    TBool resolved = ResolveLocalizedTagL( aName, aAttributes, KXmlSpokenTag, 
+                                           EXmlSpoken );
+
+    if ( resolved )
+        {
+        delete iSpokenText;
+        iSpokenText = iCurrentLocalizedString;
+        iCurrentLocalizedString = NULL;
+        }
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveWrittenTagL
+// Resolves the content of <written>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveWrittenTagL( const TDesC8& aName,
+                                        const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveWrittenTagL" );
+    
+    TBool resolved = ResolveLocalizedTagL( aName, aAttributes, KXmlWrittenTag, 
+                                           EXmlWritten );
+    if ( resolved )
+        {
+        delete iWrittenText;
+        iWrittenText = iCurrentLocalizedString;
+        iCurrentLocalizedString = NULL;
+        }
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveTooltipTagL
+// Resolves the content of <tooltip>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveTooltipTagL( const TDesC8& aName,
+                                        const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveTooltipTagL" );
+    
+    TBool resolved = ResolveLocalizedTagL( aName, aAttributes, KXmlTooltipTag, 
+                                           EXmlTooltip );
+    if ( resolved )
+        {
+        delete iTooltipText;
+        iTooltipText = iCurrentLocalizedString;
+        iCurrentLocalizedString = NULL;
+        }
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveLocalizedTagL
+// Resolves content of tag which contains localized data
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveLocalizedTagL( const TDesC8& aName,
+                                          const Xml::RAttributeArray& aAttributes,
+                                          const TDesC8& aExpectedName,
+                                          TVcXmlTagNesting aTagEnum )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveLocalizedTagL" );
+    
+    TBool resolved( EFalse );
+    if ( aName == aExpectedName )
+        {
+        resolved = ETrue;
+        iXmlNesting.Append( aTagEnum );
+        
+        resolved = GetLocalizedStringL( aAttributes, KXmlLocAttr );
+        }
+
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveExecutesTagL
+// Resolves the content of <executes>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveExecutesTagL( const TDesC8& aName,
+                                         const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveExecutesTagL" );
+    
+    TBool resolved( EFalse );
+   
+    if ( aName == KXmlExecutesTag )
+        {
+        resolved = ETrue;
+        iXmlNesting.Append( EXmlExecutes );
+
+        iAppId = ResolveUidL( aAttributes );
+        if ( iAppId == KNullUid )
+            {
+            resolved = ResolveExeL( aAttributes );
+            }
+        }
+
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveCmdlineparamsTag
+// Resolves the content of <cmdlineparams>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveCmdlineparamsTag( const TDesC8& aName, 
+                                             const Xml::RAttributeArray& /*aAttributes*/ )
+    {
+    TBool resolved( EFalse );
+    
+    if ( aName == KXmlCmdlineparamsTag )
+        {
+        iXmlNesting.Append( EXmlCmdlineparams );
+        delete iParameters;
+        delete iParameters8;
+        iParameters = NULL;
+        iParameters8 = NULL;
+        resolved = ETrue;        
+        }
+        
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveIconTagL
+// Resolves the content of <icon>
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveIconTagL( const TDesC8& aName,
+                                     const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveIconTagL" );
+    
+    TBool resolved( EFalse );
+    
+    if ( aName == KXmlIconTag )
+        {
+        resolved = ETrue;
+        iXmlNesting.Append( EXmlIcon );
+
+        iIcon = ResolveUidL( aAttributes );
+        if ( iIcon == KNullUid )
+            {
+            resolved = EFalse;
+            }
+        }
+
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::Find16ValueL
+// Finds a certain attribute and returns its value as unicode
+// -----------------------------------------------------------------------------
+//
+const TDesC& CVcXmlParser::Find16ValueL( const TDesC8& aName, 
+                                         const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::Find16ValueL" );
+    
+    delete iAttributeValue;
+    iAttributeValue = NULL;
+    
+    iAttributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( Find8ValueL( aName, aAttributes ) );
+       
+    return *iAttributeValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::Find8ValueL
+// Finds a certain attribute and returns its value as utf-8
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CVcXmlParser::Find8ValueL( const TDesC8& aName, 
+                                         const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::Find8ValueL" );
+    
+    // Loop through attribute list
+    for ( TInt iCounter = 0 ; iCounter < aAttributes.Count() ; iCounter++ )
+        {
+        HBufC8* name = ToLowercaseLC( aAttributes[iCounter].Attribute().LocalName().DesC() );
+        
+        if ( name->Des() == aName )
+            {
+            CleanupStack::PopAndDestroy( name );
+
+            return aAttributes[iCounter].Value().DesC();
+            }
+        CleanupStack::PopAndDestroy( name );
+        }
+        
+    return KNullDesC8;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResetVCommandFolder
+// Destroys the data of one voice command folder
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::ResetVCommandFolder()
+    {
+    delete iFolder;
+    iFolder = HBufC16::New( 0 );
+    
+    delete iFolderTitle;
+    iFolderTitle = HBufC16::New( 0 );
+    
+    delete iFolderIconFile;
+    iFolderIconFile = HBufC16::New( 0 );
+    
+    iFolderIconIndex = -1;
+    
+    ResetVCommandInfo();
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResetVCommandInfo
+// Destroys the data of one voice command
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::ResetVCommandInfo()
+    {
+    delete iWrittenText;
+    iWrittenText = NULL;
+    delete iSpokenText;
+    iSpokenText = NULL;
+    delete iTooltipText;
+    iTooltipText = NULL;
+    delete iParameters;
+    iParameters = NULL;
+    delete iParameters8;
+    iParameters8 = NULL;
+    delete iAppName;
+    iAppName = NULL;
+    
+    iAppId = KNullUid;
+    iIcon = KNullUid;
+    
+    iStartImmediately = EFalse;
+    iUserCanModify = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::CheckVoiceCommmandData
+// Checks if all mandatory data for one voice command is available and makes
+// callback based on that
+// -----------------------------------------------------------------------------
+//
+void CVcXmlParser::CheckVoiceCommmandData()
+    {
+    if ( iWrittenText && ( iAppId != KNullUid || iAppName ) )
+        {
+        RUBY_DEBUG0( "CVcXmlParser::CheckVoiceCommmandData(): All required data for voice command found ok" );
+        
+        // folder icon file is optional
+        // if it is not present, reference to KNullDesC should be passed
+        const TDesC* pFolderIconFile =iFolderIconFile;
+        if( !pFolderIconFile )
+            {
+            pFolderIconFile = &KNullDesC;
+            }
+        
+        iObserver.MvcxpoVoiceCommandFound( *iWrittenText, *iSpokenText, 
+                                           *iTooltipText, *iFolder, *iFolderTitle, 
+                                           *iParameters, iIcon,
+                                           iAppId, *iAppName,
+                                           iStartImmediately, iUserCanModify,
+                                           *pFolderIconFile, iFolderIconIndex );
+        }
+    else
+        {
+        RUBY_DEBUG0( "VC XML ERROR: Mandatory data not found for Voice Command" );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::GetLocalizedStringL
+// Reads localized string from resource file
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::GetLocalizedStringL( const Xml::RAttributeArray& aAttributes,
+                                         const TDesC8& aAttributeName )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::GetLocalizedStringL" );
+    
+    TBool resolved( EFalse );
+    iCurrentLocalizedString = NULL;
+    
+    // Resource file object should have been initialized
+    if ( !iResource )
+        {
+        return resolved;
+        }
+
+    // locIndex is key to the localized resource file
+    TPtrC8 locAttr( aAttributeName );    
+    TPtrC locIndex = Find16ValueL( locAttr, aAttributes );
+    
+    if ( locIndex != KNullDesC )
+        {
+        HBufC* command = NULL;
+        // Find string from loc file based on key
+        TRAPD( error,  command = &iResource->GetCommandL( locIndex ) );
+        if ( error == KErrNone )
+            {
+            // Make a copy of localized string
+            TPtr des = command->Des();
+            delete iCurrentLocalizedString;
+            iCurrentLocalizedString = des.Alloc();
+            resolved = ETrue;
+            }
+        else
+            {
+            resolved = EFalse;
+            iCurrentLocalizedString = NULL;
+            RUBY_DEBUG0( "VC XML ERROR: Cannot resolve localized string" );
+            User::Leave( KErrGeneral );
+            }
+        }
+        
+    return resolved;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveUidL
+// Resolves the content of uid="0x1234567" attribute
+// -----------------------------------------------------------------------------
+//
+TUid CVcXmlParser::ResolveUidL( const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveUidL" );
+    
+    _LIT( KHexIdentifierLowercase, "0x" );
+    _LIT( KHexIdentifierUppercase, "0X" );
+    const TInt KHexIndentifierLength = 2;
+    
+    TUid newUid( KNullUid );
+    
+    TPtrC uidDes = Find16ValueL( KXmlUidAttr, aAttributes );
+    
+    if ( uidDes != KNullDesC )
+        {
+        TPtrC ptr( uidDes );
+        // Check if string starts with 0x or 0X
+        if ( ( uidDes.Find( KHexIdentifierLowercase ) == 0 ) ||
+             ( uidDes.Find( KHexIdentifierUppercase ) == 0 ) )
+            {
+            ptr.Set( uidDes.Right( uidDes.Length() - KHexIndentifierLength ) );
+            }
+        
+        // Do conversion from string to number
+        TLex lex( ptr );
+        TInt64 intUid( 0 );
+        TInt error = lex.Val( intUid, EHex );
+        newUid.iUid = intUid;
+        }
+        
+    return newUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ResolveExeL
+// Resolves the content of exe="name.exe" attribute
+// -----------------------------------------------------------------------------
+//
+TBool CVcXmlParser::ResolveExeL( const Xml::RAttributeArray& aAttributes )
+    {
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveExeL" );
+    
+    TBool resolved( EFalse );
+    
+    TPtrC nameDes = Find16ValueL( KXmlExeAttr, aAttributes );
+    if ( nameDes != KNullDesC )
+        {
+        delete iAppName;
+        iAppName = NULL;
+        
+        iAppName = HBufC::NewL( nameDes.Length() );
+        TPtr namePtr = iAppName->Des();
+        namePtr.Copy( nameDes );
+        
+        resolved = ETrue;
+        }
+        
+    return resolved;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVcXmlParser::ToLowercaseLC
+// Converts given string to lowercase
+// -----------------------------------------------------------------------------
+//
+HBufC8* CVcXmlParser::ToLowercaseLC( const TDesC8& aString )
+    {
+    // RUBY_DEBUG0( "CVcXmlParser::ToLowercaseLC START" );
+    
+    // Convert string to lowercase    
+    HBufC8* string = HBufC8::NewL( aString.Length() );
+    CleanupStack::PushL( string );
+    TPtr8 des = string->Des();
+    des.Copy( aString );
+    des.LowerCase();
+    
+    //RUBY_DEBUG0( "CVcXmlParser::ToLowercaseLC EXIT" );
+    
+    return string;
+    }
+
+// -----------------------------------------------------------------------------
+// Reads the iconfile attribute and constructs the file name or
+// sets it to NULL
+// 
+// @params aAttributes List of XML attributes
+// @return ETrue if resolved successfully, EFalse otherwise
+// -----------------------------------------------------------------------------
+TBool CVcXmlParser::ResolveFolderIconFileL( const Xml::RAttributeArray& aAttributes )
+	{
+    RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveFolderIconFileL" );
+    
+    TBool resolved( EFalse );
+    delete iFolderIconFile;
+    iFolderIconFile = NULL;
+    
+    TPtrC nameDes = Find16ValueL( KXmlFolderIconFileAttr, aAttributes );
+    if ( nameDes != KNullDesC )
+        {
+        iFolderIconFile = HBufC::NewL( nameDes.Length() );
+        TPtr folderIconFilePtr = iFolderIconFile->Des();
+        folderIconFilePtr.Copy( nameDes );
+        
+        resolved = ETrue;
+        }
+        
+    return resolved;
+	
+	}
+
+// -----------------------------------------------------------------------------
+// Reads the iconindex attribute and stores the index or sets it to 0
+// 
+// @params aAttributes List of XML attributes
+// @return ETrue if resolved successfully, EFalse otherwise
+// -----------------------------------------------------------------------------
+TInt CVcXmlParser::ResolveFolderIconIndexL( const Xml::RAttributeArray& aAttributes )
+	{
+	RUBY_DEBUG_BLOCKL( "CVcXmlParser::ResolveFolderIconIndexL" );
+	
+	TInt index = -1;
+    
+    TPtrC indexDes = Find16ValueL( KXmlFolderIconIndexAttr, aAttributes );
+    
+    if ( indexDes != KNullDesC )
+        {
+        TPtrC ptr( indexDes );
+        
+        // Do conversion from string to number
+        TLex lex( ptr );
+        TInt error = lex.Val( index );
+        if( error != KErrNone )
+        	{
+        	RUBY_ERROR1( "Converting icon index from string to int resulted in [%d]", error );
+        	index = -1;
+        	}
+        }
+        
+    return index;	
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vcommandmanager/src/vcxmlparser.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,537 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Parser class for Voice Commands XML
+*
+*/
+
+
+#ifndef VCXMLPARSER_H
+#define VCXMLPARSER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <contenthandler.h>
+#include <parser.h>
+
+// DATA TYPES
+
+// Enumeration that is used when saving information
+// of last found xml tag
+enum TVcXmlTagNesting
+    {
+     EXmlStarted = 0,
+     EXmlDocument, 
+     EXmlFolder,
+     EXmlVCommand,
+     EXmlSpoken,
+     EXmlWritten,
+     EXmlExecutes,
+     EXmlCmdlineparams,
+     EXmlIcon,
+     EXmlTooltip
+     };
+
+// FORWARD DECLARATIONS
+class CVcResource;
+
+// CLASS DECLARATION
+
+/**
+* Observer mixin class for Voice Commands XML parser
+*
+* @lib nssvcommandmanager.exe
+*
+*/
+NONSHARABLE_CLASS( MVcXmlParserObserver )
+    {
+    public: // New functions
+        
+        /**
+        * Callback when voice command data has been completely resolved.
+        * 
+        * @param aWrittenText Voice Command text in written form
+        * @param aSpokenText Voice Command text in spoken form
+        * @param aTooltipText Tooltip text
+        * @param aFolder Folder where Voice Command should be placed
+        *                               in the UI
+        * @param aFolderTitle String which is used in folder title pane
+        * @param aParameters Command line parameters for the application
+        *                                   which is started
+        * @param aIcon Icon which is used when showing the voice command
+        * @param aAppId UID of the application which will be started
+        * @param aAppName Name of the application which will be started
+        * @param aStartImmediately ETrue if no TTS verification is needed when
+        *                                  command has been recognized
+        * @param aUserCanModify ETrue if user can modify the command
+        * @param aFolderIconFile Full path to the MBM file where to get the folder icon from
+        *        or KNullDesC if not defined
+        * @param aFolderIconIndex Index of the folder icon in the aFolderIconFile.
+        *        or -1 if not defined
+        */
+        virtual void MvcxpoVoiceCommandFound( const TDesC& aWrittenText,
+                                              const TDesC& aSpokenText,
+                                              const TDesC& aTooltipText,
+                                              const TDesC& aFolder,
+                                              const TDesC& aFolderTitle,
+                                              const TDesC& aParameters, 
+                                              TUid aIcon,
+                                              TUid aAppId,
+                                              const TDesC& aAppName,
+                                              TBool aStartImmediately,
+                                              TBool aUserCanModify, 
+                                              const TDesC& aFolderIconFile,
+                                              TInt aFolderIconIndex
+                                              ) = 0;
+        
+    };
+    
+
+/**
+* Parser class for Voice Commands XML
+*
+* @lib nssvcommandmanager.exe
+*
+*/
+NONSHARABLE_CLASS( CVcXmlParser ) : public CBase, public Xml::MContentHandler
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CVcXmlParser* NewL( RFs& aRFs, MVcXmlParserObserver& aObserver );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVcXmlParser();
+        
+    public: // New functions
+        
+        /**
+        * Parses one XML file
+        *
+        * @param aFileName XML file name
+        */
+        void ParseFileL( const TFileName& aFileName );
+        
+        
+        
+    public: // From Xml::MContentHandler
+        
+        /**
+        This method is a callback to indicate the start of the document.
+        @param				aDocParam Specifies the various parameters of the document.
+        @param				aDocParam.iCharacterSetName The character encoding of the document.
+        @param				aErrorCode is the error code. 
+				        	If this is not KErrNone then special action may be required.
+        */
+	    void OnStartDocumentL( const Xml::RDocumentParameters& aDocParam, 
+	                           TInt aErrorCode );
+
+        /**
+        This method is a callback to indicate the end of the document.
+        @param				aErrorCode is the error code. 
+        					If this is not KErrNone then special action may be required.
+        */
+	    void OnEndDocumentL( TInt aErrorCode );
+
+        /**
+        This method is a callback to indicate an element has been parsed.
+        @param				aElement is a handle to the element's details.
+        @param				aAttributes contains the attributes for the element.
+        @param				aErrorCode is the error code.
+		        			If this is not KErrNone then special action may be required.
+        */
+	    void OnStartElementL( const Xml::RTagInfo& aElement, 
+	                          const Xml::RAttributeArray& aAttributes, 
+	                          TInt aErrorCode );
+
+        /**
+        This method is a callback to indicate the end of the element has been reached.
+        @param				aElement is a handle to the element's details.
+        @param				aErrorCode is the error code.
+        					If this is not KErrNone then special action may be required.
+        */
+	    void OnEndElementL( const Xml::RTagInfo& aElement, TInt aErrorCode );
+
+        /**
+        This method is a callback that sends the content of the element.
+        Not all the content may be returned in one go. The data may be sent in chunks.
+        When an OnEndElementL is received this means there is no more content to be sent.
+        @param				aBytes is the raw content data for the element. 
+		        			The client is responsible for converting the data to the 
+				        	required character set if necessary.
+					        In some instances the content may be binary and must not be converted.
+        @param				aErrorCode is the error code.
+		        			If this is not KErrNone then special action may be required.
+        */
+	    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
+
+        /**
+        This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping.
+        This method is always called before the corresponding OnStartElementL method.
+        @param				aPrefix is the Namespace prefix being declared.
+        @param				aUri is the Namespace URI the prefix is mapped to.
+        @param				aErrorCode is the error code.
+		        			If this is not KErrNone then special action may be required.
+        */
+	    void OnStartPrefixMappingL( const RString& aPrefix, 
+	                                const RString& aUri, 
+	                                TInt aErrorCode );
+
+        /**
+        This method is a notification of the end of the scope of a prefix-URI mapping.
+        This method is called after the corresponding DoEndElementL method.
+        @param				aPrefix is the Namespace prefix that was mapped.
+        @param				aErrorCode is the error code.
+		        			If this is not KErrNone then special action may be required.
+        */
+	    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
+
+       /**
+        This method is a notification of ignorable whitespace in element content.
+        @param				aBytes are the ignored bytes from the document being parsed.
+        @param				aErrorCode is the error code.
+        					If this is not KErrNone then special action may be required.
+        */
+	    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
+
+        /**
+        This method is a notification of a skipped entity. If the parser encounters an 
+        external entity it does not need to expand it - it can return the entity as aName 
+        for the client to deal with.
+        @param				aName is the name of the skipped entity.
+        @param				aErrorCode is the error code.
+		        			If this is not KErrNone then special action may be required.
+        */
+	    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
+
+        /**
+        This method is a receive notification of a processing instruction.
+        @param				aTarget is the processing instruction target.
+        @param				aData is the processing instruction data. If empty none was supplied.
+        @param				aErrorCode is the error code.
+        					If this is not KErrNone then special action may be required.
+        */
+	    void OnProcessingInstructionL( const TDesC8& aTarget, 
+	                                   const TDesC8& aData, 
+	                                   TInt aErrorCode );
+
+        /**
+        This method indicates an error has occurred.
+        @param				aError is the error code
+        */
+	    void OnError( TInt aErrorCode );
+
+        /**
+        This method obtains the interface matching the specified uid.
+        @return				0 if no interface matching the uid is found.
+        					Otherwise, the this pointer cast to that interface.
+        @param				aUid the uid identifying the required interface.
+        */
+	    TAny* GetExtendedInterface( const TInt32 aUid );
+
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CVcXmlParser( RFs& aRFs, MVcXmlParserObserver& aObserver );
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Checks if attribute value equals to the expected. If no value is given, just
+        * checks that the attribute exists.
+        *
+        * @param aAttributes List of attributes
+        * @param aAttribute Name of the attribute which is searched
+        * @param aValue Needed value.
+        * @return ETrue if attribute was found, EFalse otherwise
+        */        
+        TBool CheckAttributeL( const Xml::RAttributeArray& aAttributes,
+                               const TDesC8& aAttribute, const TDesC8& aValue = KNullDesC8 );
+                             
+
+        /**
+        * Resolves content of <nssvcommands> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if document tag was resolved
+        */                             
+        TBool ResolveDocumentTagL( const TDesC8& aName,
+                                   const Xml::RAttributeArray& aAttributes );
+
+        /**
+        * Resolves content of <vcommandfolder> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if folder tag was resolved
+        */         
+        TBool ResolveFolderTagL( const TDesC8& aName,
+                                 const Xml::RAttributeArray& aAttributes );
+
+        /**
+        * Resolves content of <vcommand> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if vcommand tag was resolved
+        */         
+        TBool ResolveVCommandTagL( const TDesC8& aName,
+                                   const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Resolves content of <spoken> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if spoken tag was resolved
+        */         
+        TBool ResolveSpokenTagL( const TDesC8& aName,
+                                 const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Resolves content of <written> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if written tag was resolved
+        */         
+        TBool ResolveWrittenTagL( const TDesC8& aName,
+                                  const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Resolves content of <tooltip> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return Error code
+        */         
+        TBool ResolveTooltipTagL( const TDesC8& aName,
+                                  const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Resolves content of <executes> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return Error code
+        */         
+        TBool ResolveExecutesTagL( const TDesC8& aName,
+                                  const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Resolves content of <cmdlineparams> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if commandline parameters were found correctly
+        */         
+        TBool ResolveCmdlineparamsTag( const TDesC8& aName,
+                                       const Xml::RAttributeArray& aAttributes );
+
+        /**
+        * Resolves content of <icon> element.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return ETrue if icon element was found
+        */        
+        TBool ResolveIconTagL( const TDesC8& aName,
+                               const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Destroys the data of one voice command folder.
+        */ 
+        void ResetVCommandFolder();
+        
+        /**
+        * Destroys the data of one voice command.
+        */        
+        void ResetVCommandInfo();
+        
+        /**
+        * Checks that all mandatory data is found for one voice command.
+        */
+        void CheckVoiceCommmandData();
+
+        /**
+        * Reads localized string from loc file based on locindex attribute
+        *
+        * @param aAttributes Attribute list
+        * @param aAttributeName Name of the loc index attribute
+        * @return Error code
+        */      
+        TBool GetLocalizedStringL( const Xml::RAttributeArray& aAttributes,
+                                   const TDesC8& aAttributeName );
+                
+        /**
+        * Reads uid attribute and constructs TUid
+        *
+        * @params aAttributes List of XML attributes
+        * @return Parsed UID
+        */
+        TUid ResolveUidL( const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Reads exe attribute and constructs exe file name
+        *
+        * @params aAttributes List of XML attributes
+        * @return Error code
+        */
+        TBool ResolveExeL( const Xml::RAttributeArray& aAttributes );
+        
+        /**
+         * Reads the iconfile attribute and constructs the file name or
+         * sets it to NULL
+         * 
+         * @params aAttributes List of XML attributes
+         * @return ETrue if resolved successfully, EFalse otherwise
+         */
+        TBool ResolveFolderIconFileL( const Xml::RAttributeArray& aAttributes );
+
+        /**
+         * Reads the iconindex attribute and stores the index or sets it to 0
+         * 
+         * @params aAttributes List of XML attributes
+         * @return parsed index if any. -1 if there is no icon index
+         */
+        TInt ResolveFolderIconIndexL( const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Common function to resolve content of all elements which contain localized data.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @param aExpectedName Expected element name
+        * @param aTagEnum Enum value equal to tag name
+        * @param aAttributeName name of the attribute which contains loc index
+        * @return Error code
+        */
+        TBool ResolveLocalizedTagL( const TDesC8& aName, const Xml::RAttributeArray& aAttributes,
+                                    const TDesC8& aExpectedName, TVcXmlTagNesting aTagEnum );
+       
+        
+        
+        /**
+        * Tries to find matching element name from the attribute list.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return Found attribute as a 16-bit descriptor
+        */
+        const TDesC& Find16ValueL( const TDesC8& aName,
+                                   const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Tries to find matching element name from the attribute list.
+        *
+        * @param aName Element name
+        * @param aAttributes Attribute list
+        * @return Found attribute as a 8-bit descriptor
+        */  
+        const TDesC8& Find8ValueL( const TDesC8& aName,
+                                   const Xml::RAttributeArray& aAttributes );
+                                   
+        /**
+        * Converts given string to lowercase
+        *
+        * @param aString String to convert
+        * @return Converted string
+        */  
+        HBufC8* ToLowercaseLC( const TDesC8& aString );
+        
+        /**
+        * Pops the last element from XML stack if aTagName and aExpectedTag are equal
+        *
+        * @param aTagName Tag name which was found in XML file
+        * @param aExpectedTag Tag which was expected
+        */
+        void PopFromStackIfFoundL( const TDesC8& aTagName, const TDesC8& aExpectedTag );
+     
+    private: // Data
+    
+        // Callback observer
+        MVcXmlParserObserver& iObserver;    
+    
+        // Currently open localization resource file
+        CVcResource* iResource;
+        
+        // String read from localization resource file
+        HBufC* iCurrentLocalizedString;
+        
+        // Stack of XML elements
+        RArray<TVcXmlTagNesting> iXmlNesting;
+        
+        // Data for one Voice Command
+        // Text shown on screen
+        HBufC* iWrittenText;
+        
+        // Text which will be trained, if KNullDesC then iWrittenText will be trained
+        HBufC* iSpokenText;
+        
+        // Icon
+        TUid iIcon;
+        
+        // Text of the tooltip
+        HBufC* iTooltipText;
+        
+        // Folder name, if it does not exist, then it will be created
+        // If NULL then "root" will be used
+        HBufC* iFolder;
+        
+        // Title pane text for folder
+        HBufC* iFolderTitle;
+        
+        HBufC* iFolderIconFile;
+        
+        TInt iFolderIconIndex;
+        
+        // UID of the application which will be started when this voice command has been recognized
+        TUid iAppId;
+        
+        // Name of the application which will be started when this voice command has been recognized
+        HBufC* iAppName;
+        
+        // Command line parameters for the application which will be started
+        HBufC* iParameters;
+        HBufC8* iParameters8;
+        
+        // TTS feedback & adaptation of the recognition result on/off
+        TBool iStartImmediately;
+        
+        // Can user modify?
+        TBool iUserCanModify;
+        
+        // Value for attribute
+        HBufC* iAttributeValue;
+        
+        // XML Parser
+        Xml::CParser* iParser;
+        
+        // File system handle
+        RFs& iRFs;
+    };
+
+#endif // VCXMLPARSER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/bmarm/nssvoiceuipluginhandleru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	NewL__24CNssVoiceUIPluginHandler @ 1 NONAME R3UNUSED ; CNssVoiceUIPluginHandler::NewL(void)
+	"_._24CNssVoiceUIPluginHandler" @ 2 NONAME R3UNUSED ; CNssVoiceUIPluginHandler::~CNssVoiceUIPluginHandler(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/bwins/nssvoiceuipluginhandleru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	??1CNssVoiceUIPluginHandler@@UAE@XZ @ 1 NONAME ; public: virtual __thiscall CNssVoiceUIPluginHandler::~CNssVoiceUIPluginHandler(void)
+	?NewL@CNssVoiceUIPluginHandler@@SAPAV1@XZ @ 2 NONAME ; public: static class CNssVoiceUIPluginHandler * __cdecl CNssVoiceUIPluginHandler::NewL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/eabi/nssvoiceuipluginhandleru.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN24CNssVoiceUIPluginHandler4NewLEv @ 1 NONAME
+	_ZN24CNssVoiceUIPluginHandlerD0Ev @ 2 NONAME
+	_ZN24CNssVoiceUIPluginHandlerD1Ev @ 3 NONAME
+	_ZN24CNssVoiceUIPluginHandlerD2Ev @ 4 NONAME
+	_ZTI24CNssVoiceUIPluginHandler @ 5 NONAME ; #<TI>#
+	_ZTV24CNssVoiceUIPluginHandler @ 6 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Compilation information for VoiceUIPlug-inHandler
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+// specify the platforms your component needs to be built for here
+// recommended value is DEFAULT
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+/agnmodel/group/agnmodel.mmp
+#if defined(MARM)
+/agnmodel/group/agsvexe.mmp
+#endif
+*/
+nssvoiceuipluginhandler.mmp
+
+PRJ_TESTEXPORTS
+// Specify the exports needed by the productized test program.
+// These will be exported with command 'abld test export'.
+// Default location for productized test harness is /tsrc
+// Example:
+/*
+../tsrc/testdata/audio.wav /epoc32/winscw/c/testdata/audio.wav
+*/
+
+PRJ_TESTMMPFILES
+// Specify the .mmp files required for building the productized 
+// test harness. 'abld test build' will do the compilation.
+// Example:
+/*
+../tsrc/group/test.mmp
+*/
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/group/nssvoiceuipluginhandler.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Building information for VUIPHandler
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          nssvoiceuipluginhandler.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10201AF7
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL
+
+SOURCEPATH      ../src
+SOURCE          nssvoiceuipluginhandler.cpp
+
+USERINCLUDE     ../inc
+
+USERINCLUDE     ../../rubydebug 
+
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE	../inc
+SYSTEMINCLUDE	/epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/libc
+
+LIBRARY     	euser.lib ecom.lib
+
+LIBRARY     	efsrv.lib // For writing RubyDebug messages to file
+
+LANG            SC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/inc/nssvoiceuipluginhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface definition for Voice UI plug-in Handler
+*
+*/
+
+
+#ifndef NSSVOICEUIPLUGINHANDLER_H
+#define NSSVOICEUIPLUGINHANDLER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <nssvoiceevent.h>
+#include <nssvoiceuiplugin.h>
+
+// CLASS DECLARATION
+
+/**
+*  Class for handling voiceUI plug-ins
+*
+*  @lib NssVoiceUIPluginHandler.lib
+*  @since 3.1
+*/
+class CNssVoiceUIPluginHandler : public CBase, MVoiceEventExecutor
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CNssVoiceUIPluginHandler* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CNssVoiceUIPluginHandler();
+        
+    public: // Functions from base classes
+        
+        /**
+        * From MVoiceEventExecutor
+        * @since 3.1
+        * @param aEventUID UID of voice event
+        * @return One of the system wide error codes, KErrNone if successful.
+        */
+        TInt VoiceEvent( TUid aEventUID ); 
+        
+    private:
+        
+        /**
+        * C++ default constructor.
+        */
+        CNssVoiceUIPluginHandler();
+        
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Plug-in loading
+        */
+        void LoadPluginsL();
+
+        /**
+        * Plug-in unloading
+        */
+        void UnloadPlugins();
+        
+    private: // Data
+        
+        // Array for event plug-ins
+        RPointerArray<CVoiceEventObserverPluginBase> iEventPlugins;
+
+        // IDs in Ecom
+        RArray<TUid> iEventPluginDtorIds;
+
+        // Array for action plug-ins
+        RPointerArray<CVoiceUiPluginBase> iActionPlugins;
+
+        // IDs in Ecom
+        RArray<TUid> iActionPluginDtorIds;
+        
+    };
+
+#endif // NSSVOICEUIPLUGINHANDLER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/srsf/vuiphandler/src/nssvoiceuipluginhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,327 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of VoiceUIPluginHandler
+*
+*/
+
+
+// INCLUDE FILES
+#include <ecom.h>
+#include <nssvuipf.hrh>
+#include "nssvoiceuipluginhandler.h" 
+#include "rubydebug.h"
+#include <nssvoicestatus.h>
+
+
+// CONSTANTS
+const TUid KEventPluginUid =  { KVuipfEventInterfaceUid };
+const TUid KActionPluginUid = { KVuipfExecutionInterfaceUid };
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::CNssVoiceUIPluginHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNssVoiceUIPluginHandler::CNssVoiceUIPluginHandler()
+    {
+    // nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNssVoiceUIPluginHandler::ConstructL()
+    {
+    LoadPluginsL();
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssVoiceUIPluginHandler* CNssVoiceUIPluginHandler::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CNssVoiceUIPluginHandler::NewL()" );
+    CNssVoiceUIPluginHandler* self = new( ELeave ) CNssVoiceUIPluginHandler;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::~CNssVoiceUIPluginHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CNssVoiceUIPluginHandler::~CNssVoiceUIPluginHandler()
+    {
+    UnloadPlugins();
+    RUBY_DEBUG0( "CNssVoiceUIPluginHandler::~CNssVoiceUIPluginHandler() end" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::VoiceEvent
+// Handle voice event
+// -----------------------------------------------------------------------------
+//
+TInt CNssVoiceUIPluginHandler::VoiceEvent( TUid aEventUid ) 
+    {
+    RUBY_DEBUG1( "CNssVoiceUIPluginHandler::VoiceEvent(0x%x)", aEventUid.iUid );
+    CVoiceUiPluginBase* plugin = NULL;
+    CVoiceUiPluginBase* previousPlugin = NULL;
+    TInt highestPriority( KMinTInt );
+
+    RPointerArray<CVoiceUiPluginBase> usedPlugins;
+    // Select the suitable plug-in with highest priority
+    // In case of multiple plug-ins with same priority the first one is selected. 
+    
+    TInt status( KErrNoneEventNotConsumed );
+    
+    // execute plug-ins until the event has been successfully processed
+    while ( status != KErrNone )
+        {
+        
+        // Loop all plugins
+        for( TInt i( 0 ); i < iActionPlugins.Count(); i++ ) 
+            {
+            CVoiceUiPluginBase* tmpPlugin = iActionPlugins[i];
+     
+            // Loop all supported events in the plugin
+            for ( TInt j( 0 ); j < tmpPlugin->EventUids().Count(); j++ ) 
+                {
+                RUBY_DEBUG2( "VoiceEvent Comparing event uid [0x%x] against plugin's [0x%x]", 
+                             aEventUid.iUid, tmpPlugin->EventUids()[j].iUid );
+                             
+                TVuipPriority priority = tmpPlugin->Priority();
+                if ( tmpPlugin->EventUids()[j] == aEventUid 
+                    && priority > highestPriority )
+                    {
+                    
+                    // find the next plug-in in the order of priority
+                    TBool alreadyUsed( EFalse );
+                    TInt k( 0 );
+                    while( k < usedPlugins.Count() && !alreadyUsed )
+                        {
+                        if ( usedPlugins[k] == tmpPlugin )
+                            {
+                            alreadyUsed = ETrue;
+                            }
+                        k++;
+                        }
+
+                    if ( !alreadyUsed )
+                        {
+                        plugin = tmpPlugin;
+                        highestPriority = priority; 
+                        }
+                    }
+                }
+            }
+
+        if ( plugin && plugin != previousPlugin )
+            {
+            // execute a plug-in
+            status = plugin->Execute( aEventUid );
+            previousPlugin = plugin;
+            }
+        else
+            {
+            // all plug-ins checked -> exit loop
+            RUBY_DEBUG0( "No plugin for the event");
+            break;    
+            }
+        }
+        
+    
+    if ( status == KErrNoneForwardEvent )
+        {
+        status = KErrNoneEventNotConsumed;
+        }
+        
+    usedPlugins.Reset();
+    usedPlugins.Close();
+    return status;
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::LoadPluginsL
+// Loads plug-ins
+// -----------------------------------------------------------------------------
+//
+void CNssVoiceUIPluginHandler::LoadPluginsL() 
+    {
+    RUBY_DEBUG_BLOCK( "CNssVoiceUIPluginHandler::LoadPluginsL()" );
+    TInt i( 0 );
+    RImplInfoPtrArray eventPluginArray;
+    CleanupClosePushL( eventPluginArray );
+
+    REComSession::ListImplementationsL( KEventPluginUid, eventPluginArray );
+
+    RUBY_DEBUG1( "CNssVoiceUIPluginHandler::LoadPluginsL() found %i event plugins", 
+                 eventPluginArray.Count() );
+    // load event plug-ins
+    for ( i = 0; i < eventPluginArray.Count(); i++ )
+        {
+        // Get Uid of plug-in
+        TUid id = eventPluginArray[i]->ImplementationUid();
+      
+        // create plug-in
+        TUid dtorID;
+        CVoiceEventObserverPluginBase* tmpPlugin = NULL;
+        
+        TRAPD( error, 
+            tmpPlugin = 
+                reinterpret_cast<CVoiceEventObserverPluginBase*> 
+                ( REComSession::CreateImplementationL( id, dtorID ) ) );
+
+        if ( error == KErrNone )
+            {           
+            // initialize plug-in
+            TRAP( error, tmpPlugin->InitializeL( *this ) );
+            }
+            
+        if ( error == KErrNone )
+            {
+            error = iEventPlugins.Append( tmpPlugin );   
+            }
+            
+        if ( error == KErrNone )
+            {
+            error = iEventPluginDtorIds.Append( dtorID );
+            }
+           
+        if ( error != KErrNone )
+            {
+            REComSession::DestroyedImplementation( dtorID );
+            delete tmpPlugin;
+            tmpPlugin = NULL;
+            }
+
+        }
+
+    eventPluginArray.ResetAndDestroy();
+
+    CleanupStack::PopAndDestroy( &eventPluginArray );
+
+    RImplInfoPtrArray actionPluginArray;
+    CleanupClosePushL( actionPluginArray );    
+    REComSession::ListImplementationsL( KActionPluginUid, actionPluginArray );
+
+    RUBY_DEBUG1( "CNssVoiceUIPluginHandler::LoadPluginsL() found %i VUI plugins", 
+                 actionPluginArray.Count() );
+
+    // load action plug-ins
+    for ( i = 0; i < actionPluginArray.Count(); i++ )
+        {
+        // Get Uid of plug-in
+        TUid id = actionPluginArray[i]->ImplementationUid();
+      
+        // create plug-in
+        TUid dtorID;
+        CVoiceUiPluginBase* tmpPlugin = NULL;
+        
+        TRAPD( error, 
+            tmpPlugin = 
+                reinterpret_cast<CVoiceUiPluginBase*> 
+                ( REComSession::CreateImplementationL( id,dtorID ) ) );
+
+        if ( error == KErrNone )
+            {
+            // initialize plug-in
+            TRAP( error, tmpPlugin->InitializeL() );
+            }
+            
+        if ( error == KErrNone )
+            {
+            error = iActionPlugins.Append( tmpPlugin );
+            }
+        
+        if ( error == KErrNone )
+            {    
+            error = iActionPluginDtorIds.Append( dtorID );
+            }
+
+        if ( error != KErrNone )
+            {
+            REComSession::DestroyedImplementation( dtorID );
+            delete tmpPlugin;
+            tmpPlugin = NULL;
+            }
+        }
+
+    actionPluginArray.ResetAndDestroy();
+    CleanupStack::PopAndDestroy( &actionPluginArray );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CNssVoiceUIPluginHandler::UnloadPlugins
+// Unloads plug-ins
+// -----------------------------------------------------------------------------
+//
+void CNssVoiceUIPluginHandler::UnloadPlugins() 
+    {
+    TInt i( 0 );
+    iEventPlugins.ResetAndDestroy();
+    iEventPlugins.Close();
+
+    // notify ecom
+    for ( i = 0; i < iEventPluginDtorIds.Count(); i++ )
+        {
+        REComSession::DestroyedImplementation( iEventPluginDtorIds[i] );
+        }
+
+    iEventPluginDtorIds.Close();
+    iActionPlugins.ResetAndDestroy();
+    iActionPlugins.Close();
+    
+    // notify ecom
+    for ( i = 0; i < iActionPluginDtorIds.Count(); i++ )
+        {
+        REComSession::DestroyedImplementation( iActionPluginDtorIds[i] );
+        }
+    iActionPluginDtorIds.Close();
+
+    // Release REComSession allocations.
+    REComSession::FinalClose(); 
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// For DLL goodness.
+// -----------------------------------------------------------------------------
+//
+#ifndef EKA2
+GLDEF_C TInt E32Dll( TDllReason /*aReason*/ )
+    {
+    return KErrNone;
+    }
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  For test api modules
+*
+*/
+
+PRJ_TESTMMPFILES
+
+#include "../../speechsrv_plat/ui_voice_recognition_api/tsrc/group/bld.inf"
+#include "../../srsf/speechsynthesis/tsrc/speechsynthesistest/group/bld.inf"
+#include "../../srsf/tsrc/public/basic/group/bld.inf"
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/group/aiwpbkinfoviewprovider.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP file for aiwpbkinfoviewprovider.dll
+*
+*/
+
+
+#include "../inc/aiwpbkinfoviewprovideruids.hrh"
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET		aiwpbkinfoviewprovider.dll
+TARGETTYPE	PLUGIN
+
+
+VENDORID VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+// uid for aiwinfoviewprovider 10281C81
+UID	0x10009D8D KAspInfoViewProviderDllUid
+
+
+USERINCLUDE	../inc
+
+// for pbkinfoviewpi.h
+USERINCLUDE     ../../pbkinfoviewimpl/inc
+
+// for pbkinfoview.loc
+USERINCLUDE     ../../pbkinfoviewimpl/src
+
+// This is a SYSTEMINCLUDE macro containing the applications
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE	/epoc32/include/ecom
+
+SOURCEPATH	../src
+SOURCE		aiwpbkinfoviewprovider.cpp
+
+START RESOURCE  10281c81.rss
+TARGET          aiwpbkinfoviewprovider
+TARGETPATH ECOM_RESOURCE_DIR
+END
+
+START RESOURCE  aiwpbkinfoviewprovider.rss
+HEADER
+TARGET          aiwpbkinfoviewprovider
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE       ../../rubydebug
+
+
+LIBRARY	euser.lib
+LIBRARY servicehandler.lib
+LIBRARY pbkinfoview.lib
+LIBRARY vpbkeng.lib
+LIBRARY ecom.lib // For CVPbkContactIdConverter
+
+LIBRARY	efsrv.lib
+LIBRARY avkon.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Provides information for building aiwpbkinfoviewprovider.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+aiwpbkinfoviewprovider.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewprovider.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AIW provider for pbkinfoview.
+*
+*/
+
+
+#ifndef AIWPBKINFOVIEWPROVIDER_H
+#define AIWPBKINFOVIEWPROVIDER_H
+
+//  INCLUDES
+#include <AiwServiceIfMenu.h>
+
+// CONSTANTS
+const TInt KBufSize = 128;
+const TInt KSyncApplicationId = 0;
+
+const TInt KAiwCmdSindInfoView =  0x10281C83;
+
+
+// CLASS DECLARATION
+class CPbkInfoViewApi;
+class MVPbkContactStoreListObserver;
+
+/**
+* CAiwPbkInfoViewProvider
+*  
+* CAiwPbkInfoViewProvider implements CAiwServiceIfMenu interface to
+* allow synchronize functionality to be called via AIW.
+*
+* @lib syncservice.lib
+* @since Series 60 3.0
+*/
+class CAiwPbkInfoViewProvider : public CAiwServiceIfMenu,
+                                public MVPbkContactStoreListObserver
+	{
+	public:
+        /**
+        * Two-phased constructor.
+        */
+		static CAiwPbkInfoViewProvider* NewL();
+
+        /**
+        * Destructor.
+        */
+		~CAiwPbkInfoViewProvider();
+
+	public:		
+        /**
+        * From the CAiwServiceIfMenu.
+		* Not implemented.
+        */
+		void InitialiseL(MAiwNotifyCallback& aFrameworkCallback,
+			                     const RCriteriaArray& aInterest);
+
+        /**
+        * From the base class.
+		* Not implemented.
+        */
+		void HandleServiceCmdL(const TInt& aCmdId,
+                                       const CAiwGenericParamList& aInParamList,
+                                       CAiwGenericParamList& aOutParamList,
+                                       TUint aCmdOptions = 0,
+                                       const MAiwNotifyCallback* aCallback = NULL);
+
+     	 /**
+         * Initialises menu pane by adding provider specific menu items.
+	     * The AIW Framework gives the parameters to be used in addition.
+	     * @param aMenuPane Menu pane handle
+	     * @param aIndex position of item where to add menu items.
+	     * @param aCascadeId ID of cascade menu item.
+	     * @param aInParamList input parameter list for provider's parameters checking
+	     */
+		void InitializeMenuPaneL(CAiwMenuPane& aMenuPane,
+                                         TInt aIndex,
+                                         TInt aCascadeId,
+                                         const CAiwGenericParamList& aInParamList);
+
+        /**
+        * Handles a menu command invoked by the Handler.
+        * @param aMenuCmdId Command ID for the menu command,
+        *        defined by the provider when adding the menu commands.
+        * @param aInParamList Input parameters, could be empty list
+        * @param aOutParamList Output parameters, could be empty list
+        * @param aCmdOptions Options for the command, see KAiwCmdOpt* constants.
+        * @param aCallback callback if asynchronous command handling is wanted by consumer.
+        *    The provider may or may not support this, leaves with KErrNotSupported if not.
+        */
+		void HandleMenuCmdL(TInt aMenuCmdId,
+                                    const CAiwGenericParamList& aInParamList,
+                                    CAiwGenericParamList& aOutParamList,
+                                    TUint aCmdOptions = 0,
+                                    const MAiwNotifyCallback* aCallback = NULL);
+                                    
+    private:
+        /*
+        * From MVPbkContactStoreListObserver
+        */
+        void StoreReady( MVPbkContactStore& aContactStore );
+        void StoreUnavailable( MVPbkContactStore& aContactStore,
+                               TInt aReason );
+        void HandleStoreEventL( MVPbkContactStore& aContactStore, 
+                                TVPbkContactStoreEvent aStoreEvent );
+        void OpenComplete();
+
+	private:
+        /**
+        * C++ default constructor.
+        */
+		CAiwPbkInfoViewProvider();
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+		void ConstructL();
+	
+	private:
+        /**
+		* Gets service command id from AIW parameter list.
+        * @param aInParamList AIW parameter list.
+		* @return TInt Service command id.
+        */
+		TInt GetServiceCommandId( const CAiwGenericParamList& aInParamList );
+
+        /**
+		* Gets the contact id from AIW parameter list.
+        * @param aInParamList AIW parameter list.
+		* @return TInt id.
+        */
+	    TInt GetContactIdL( const CAiwGenericParamList& aInParamList );
+        /**
+		* Gets this plugin resource file name.
+        * @param aText Resource file name.
+		* @return None.
+        */
+		void GetResFileName( TDes& aText );
+		
+        /**
+		* Copies strings.
+        * @param aTarget Copied text will be put to this variable.
+        * @param aSource Includes the text to be copied.
+		* @return None.
+        */
+    	void StrCopy( TDes& aTarget, const TDesC& aSource );
+
+	private:
+		CPbkInfoViewApi* iInfoViewApi;
+		// Scheduler wait object
+        CActiveSchedulerWait* iWait;
+		// Error code received from observer call-back methods.
+        TInt iErr;
+	};	
+
+#endif  // AIWPBKINFOVIEWPROVIDER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewprovider.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     
+*
+*/
+
+#ifndef AIWPBKINFOVIEWPROVIDER_RH
+#define AIWPBKINFOVIEWPROVIDER_RH
+
+enum
+	{
+	EPbkInfoViewProviderCmd = 1
+	};
+
+#endif  // AIWPBKINFOVIEWPROVIDER_RH
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewproviderdebug.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef _AIW_SYNCPROVIDER_DEBUG_H
+#define _AIW_SYNCPROVIDER_DEBUG_H
+
+
+#ifdef _DEBUG
+
+#include <e32svr.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT(KLogFile,"aiwsyncprovider.txt");
+_LIT(KLogDirFullName,"c:\\logs\\");
+_LIT(KLogDir,"aiwsyncprovider");
+
+// Declare the FPrint function
+inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+    }
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#define FLOG(a)   { FPrint(a); }
+#define FTRACE(a) { a; }
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#define FLOG(a) { RDebug::Print(a);  }
+#define FTRACE(a) { a; }
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG(a)
+#define FTRACE(a)
+
+#endif // _DEBUG
+
+
+#endif // _AIW_SYNCPROVIDER_DEBUG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewprovideruids.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef AIWPBKINFOVIEWPROVIDERUIDS_HRH
+#define AIWPBKINFOVIEWPROVIDERUIDS_HRH
+
+// AIW command
+#define KAiwCmdSindInfoView 0x10281C83
+
+// dll uid
+#define KAspInfoViewProviderDllUid   0x10281C81
+
+// aiw service class uid
+#define KAspInfoViewProviderIfaceUid 0x101F8652    // KAiwClassMenu (aiw	common.hrh)
+
+#define KAspInfoViewProviderImplUid   0x10281C81
+
+#endif  // AIWPBKINFOVIEWPROVIDERUIDS_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/inc/aiwpbkinfoviewproviderutil.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility classes.
+*
+*/
+
+
+#ifndef _AIW_PBKINFOVIEWPROVIDER_H
+#define _AIW_PBKINFOVIEWPROVIDER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <eikenv.h>
+
+
+// CONSTANTS
+
+const TInt KBufSize = 128;
+
+
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+/**
+* TAspUtil 
+* 
+*/
+class TUtil
+	{
+    public:
+        static void Panic(TInt aReason);
+		static void StrCopy(TDes& aTarget, const TDesC& aSource);
+		static TInt StrToInt(const TDesC& aText, TInt& aNum);
+		static void Print(const TDesC& aText);
+		static void Print(const TDesC& aText, TInt aNum);
+	};
+
+
+/**
+* TFileLog 
+* 
+*/
+class TFileLog
+    {
+    public:
+        static void Log(const TDesC& aText);
+		static void Log(const TDesC& aText1, const TDesC& aText2);
+		static void GetDateTime(TDes& aStr, TTime aTimeNum, TBool aDate, TBool aTime);
+		static void GetMediumType(TDes& aText, TInt aType);
+    };
+
+
+
+#endif  // _AIW_PBKINFOVIEWPROVIDER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/src/10281c81.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Declares Base service API for all providers to implement in order to
+*     offer services to Application Interworking Framework.
+*
+*/
+
+
+#include <eikon.rh>
+#include "registryinfov2.rh" 
+#include "aiwpbkinfoviewprovider.rh"
+#include "aiwpbkinfoviewprovideruids.hrh"
+#include <AiwCommon.hrh>
+
+
+//
+// plugin resources are placed in z:/system/libs/plugins
+//
+// this resource is needed by CAiwServiceHandler/ECom for
+// finding out what plugins exist
+//
+//
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	resource_format_version = RESOURCE_FORMAT_VERSION_2; 
+	dll_uid = KAspInfoViewProviderDllUid;  // dll id
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+
+			// aiw service class (menu/base)
+			interface_uid = KAiwClassMenu;
+
+			implementations = 
+				{
+				  IMPLEMENTATION_INFO
+					{
+
+					// unique aiw service id that identifies the exact service 
+					implementation_uid = KAspInfoViewProviderImplUid;
+
+					version_no = 1;
+					display_name = "AIW Info View Provider";
+					default_data = "*";
+					opaque_data = "10281C83";
+					}
+				};
+			}
+
+		};
+	}
+
+
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/src/aiwpbkinfoviewprovider.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,391 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AIW provider for pbkinfoview.
+*
+*/
+
+
+#include "pbkinfoviewapi.h"
+#include "rubydebug.h"
+
+#include <AiwMenu.h>
+#include <CVPbkContactManager.h>
+#include <CVPbkContactLinkArray.h>
+#include <MVPbkContactLink.h>
+#include <CVPbkContactStoreUriArray.h>
+#include <CVPbkContactIdConverter.h>
+#include <MVPbkContactStoreListObserver.h>
+#include <VPbkContactStoreUris.h>
+#include <VPbkContactStoreUris.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreProperties.h>
+
+#include <implementationproxy.h>
+
+#include <data_caging_path_literals.hrh>  // for resource and bitmap directories
+
+#include <aiwpbkinfoviewprovider.rsg>
+#include "aiwpbkinfoviewprovider.h"
+#include "aiwpbkinfoviewprovideruids.hrh"
+#include "aiwpbkinfoviewprovider.rh"
+
+_LIT( KResFileName, "z:aiwpbkinfoviewprovider.rsc" );
+const TInt32 KVoiceTaglessContactId = -2;
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CAiwPbkInfoViewProvider* CAiwPbkInfoViewProvider::NewL()
+	{
+	CAiwPbkInfoViewProvider* self = new (ELeave) CAiwPbkInfoViewProvider();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::Constructor
+//
+// -----------------------------------------------------------------------------
+//
+CAiwPbkInfoViewProvider::CAiwPbkInfoViewProvider()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CAiwPbkInfoViewProvider::~CAiwPbkInfoViewProvider()
+	{
+	delete iInfoViewApi;
+	iInfoViewApi = NULL;
+	delete iWait;
+	iWait = NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::ConstructL()
+    {
+	iInfoViewApi = CPbkInfoViewApi::NewL();
+	iWait = new (ELeave) CActiveSchedulerWait();
+    } 
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::InitialiseL (from CAiwServiceIfBase)
+//
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::InitialiseL( 
+                                  MAiwNotifyCallback& /*aFrameworkCallback*/,
+	                              const RCriteriaArray& /*aInterest*/ )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::HandleServiceCmdL (from CAiwServiceIfBase)
+//
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::HandleServiceCmdL(
+                                  const TInt& /*aCmdId*/,
+                                  const CAiwGenericParamList& /*aInParamList*/,
+                                  CAiwGenericParamList& /*aOutParamList*/,
+                                  TUint /*aCmdOptions*/,
+                                  const MAiwNotifyCallback* /*aCallback*/ )
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::InitializeMenuPaneL (from CAiwServiceIfMenu)
+// Initialises menu pane by adding provider specific menu items. The AIW
+// framework gives the parameters to be used in addition.
+// @param aMenuPane Menu pane handle
+// @param aIndex position of item where to add menu items.
+// @param aCascadeId ID of cascade menu item.
+// @param aInParamList input parameter list for provider's parameters checking
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::InitializeMenuPaneL(
+                                  CAiwMenuPane& aMenuPane,
+			                      TInt aIndex,
+								  TInt /*aCascadeId*/,
+                                  const CAiwGenericParamList& aInParamList )
+	{
+	TFileName resFile;
+	GetResFileName( resFile );
+
+    TInt serviceCommand = GetServiceCommandId( aInParamList );
+    
+    if ( serviceCommand == KErrNotFound )
+        {
+        User::Leave( KErrArgument );
+    	}
+       	
+    if ( serviceCommand == KAiwCmdSindInfoView )
+    	{
+        aMenuPane.AddMenuItemsL( resFile, R_PBKINFOVIEWPROVIDER_SUBMENU,
+    	                         KAiwCmdSindInfoView, aIndex );
+    	}
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::HandleMenuCmdL (from CAiwServiceIfMenu)
+// Handles a menu command invoked by the Handler.
+// @param aMenuCmdId Command ID for the menu command,
+//        defined by the provider when adding the menu commands.
+// @param aInParamList Input parameters, could be empty list
+// @param aOutParamList Output parameters, could be empty list
+// @param aCmdOptions Options for the command, see KAiwCmdOpt* constants.
+// @param aCallback callback if asynchronous command handling is wanted by consumer.
+//        The provider may or may not support this, leaves with KErrNotSupported
+//        if not.
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::HandleMenuCmdL( 
+                                  TInt aMenuCmdId, 
+                                  const CAiwGenericParamList& aInParamList,
+                                  CAiwGenericParamList& /*aOutParamList*/,
+                                  TUint /*aCmdOptions*/,
+                                  const MAiwNotifyCallback* /*aCallback*/ )
+	{
+	RUBY_DEBUG_BLOCK( "CAiwPbkInfoViewProvider::HandleMenuCmdL" );
+	
+	if( aMenuCmdId == EPbkInfoViewProviderCmd )
+		{
+		TInt contactId = GetContactIdL( aInParamList );
+		
+        iInfoViewApi->ShowInfoViewL( contactId );
+		}
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreObserver)
+//
+// -----------------------------------------------------------------------------
+//	
+void CAiwPbkInfoViewProvider::StoreReady( MVPbkContactStore& /*aContactStore*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::StoreUnavailable( MVPbkContactStore& /*aContactStore*/, 
+        TInt /*aReason*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/,
+        TVPbkContactStoreEvent /*aStoreEvent*/ )
+    {
+    }
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::OpenComplete (from MVPbkContactStoreListObserver)
+//
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::OpenComplete()
+	{
+    // Continue with GetContactIdL-method
+    if ( iWait && iWait->IsStarted() )
+        {
+        iWait->AsyncStop();
+        }
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::GetContactIdL
+// Gets the contact id from AIW parameter list.
+// @param aInParamList AIW parameter list.
+// @return Contact id.
+// -----------------------------------------------------------------------------
+//
+TInt CAiwPbkInfoViewProvider::GetContactIdL(
+                                  const CAiwGenericParamList& aInParamList )
+	{
+	RUBY_DEBUG_BLOCK( "CAiwPbkInfoViewProvider::GetContactIdL" );
+	
+	TInt index( 0 );
+	TInt32 contactId( KVoiceTaglessContactId );
+	
+    const TAiwGenericParam* param
+        = aInParamList.FindFirst( index, EGenericParamContactLinkArray );
+        
+    if( param )
+        {
+        // Get the externalized contact link array
+        TPtrC8 packedLinkArray = param->Value().AsData();
+        
+        CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+
+        uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) );
+
+        CVPbkContactManager* contactManager = CVPbkContactManager::NewL( *uriArray );
+        CleanupStack::PushL( contactManager );
+        
+        // Open contact stores
+        MVPbkContactStoreList& storeList = contactManager->ContactStoresL();
+        storeList.OpenAllL( *this );
+        
+        // Let's synchronize the OpenAllL call
+        if ( iWait && !iWait->IsStarted() )
+            {
+            iWait->Start();
+            }
+        
+        // Internalize contact link array
+        CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC(
+            packedLinkArray, contactManager->ContactStoresL() );
+        
+        if( links->Count() > 0 )
+            {
+            // There should only be one link in the array
+            const MVPbkContactLink& link = links->At( 0 );
+            
+            MVPbkContactStore& store = link.ContactStore();
+            
+            // Get the contact id    
+            CVPbkContactIdConverter* idConverter
+                = CVPbkContactIdConverter::NewL( store );
+            CleanupStack::PushL( idConverter );
+            
+            contactId = idConverter->LinkToIdentifier( link ); 
+            
+            CleanupStack::PopAndDestroy( idConverter );  
+            }
+
+        CleanupStack::PopAndDestroy( links );
+        CleanupStack::PopAndDestroy( contactManager );
+        CleanupStack::PopAndDestroy( uriArray );
+        }
+
+    RUBY_DEBUG1( "Contact id: %d", contactId );
+	return contactId;
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::GetServiceCommandId
+// Gets service command id from AIW parameter list.
+// @param aInParamList AIW parameter list.
+// @return TInt Service command id.
+// -----------------------------------------------------------------------------
+//
+TInt CAiwPbkInfoViewProvider::GetServiceCommandId(
+                                  const CAiwGenericParamList& aInParamList)
+	{
+	TInt index( 0 );
+	TInt32 num( 0 );
+	
+	const TAiwGenericParam* param
+	    = aInParamList.FindFirst( index, EGenericParamServiceCommand );
+
+	const TAiwVariant& val = param->Value();
+	if ( !val.Get( num ) )
+		{
+		num = KErrNotFound;
+		}
+	return num;
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::GetResFileName
+// Gets this plugin resource file name.
+// @param aText Resource file name.
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::GetResFileName( TDes& aText )
+	{
+	TParse parse;
+	parse.Set( KResFileName, &KDC_RESOURCE_FILES_DIR, NULL );
+	StrCopy( aText, parse.FullName() );
+	}
+
+// -----------------------------------------------------------------------------
+// CAiwPbkInfoViewProvider::StrCopy
+//
+// String copy with lenght check.
+// @param TDes& aTarget Copied text will be put to this variable.
+// @param TDesC8& aSource Includes the text to be copied.
+// -----------------------------------------------------------------------------
+//
+void CAiwPbkInfoViewProvider::StrCopy( TDes& aTarget, const TDesC& aSource )
+    {
+	TInt len = aTarget.MaxLength();
+    if( len < aSource.Length() ) 
+	    {
+		aTarget.Copy( aSource.Left( len ) );
+		return;
+	    }
+	aTarget.Copy( aSource );
+    }
+
+//
+// Rest of the file is for ECom initialization. 
+//
+
+// -----------------------------------------------------------------------------
+// Map the interface UIDs to implementation factory functions
+//
+// -----------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KAspInfoViewProviderImplUid,
+                                CAiwPbkInfoViewProvider::NewL )
+    };
+
+// -----------------------------------------------------------------------------
+// Exported proxy for instantiation method resolution
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+{
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+    return ImplementationTable;
+}
+
+//
+// DLL entry point
+//
+#ifndef EKA2
+GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
+	{
+	return KErrNone;
+	}
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/aiwpbkinfoviewprovider/src/aiwpbkinfoviewprovider.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+// End of file
+
+
+/*
+* ==============================================================================
+*  Name        : aiwpbkinfoviewprovider.rss
+*  Part of     : pbkinfoview/aiwpbkinfoviewprovider
+*  Description : 
+*  Version     : 
+*
+*  Copyright © 2002-2005 Nokia. All rights reserved.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia. All rights are reserved. Copying, including 
+*  reproducing, storing, adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia.
+* ==============================================================================
+*/
+
+#include <eikon.rh>
+#include "registryinfov2.rh" 
+#include "aiwpbkinfoviewprovider.rh"
+#include <pbkinfoview.loc>
+#include "AiwCommon.hrh"
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+
+
+
+//  RESOURCE IDENTIFIER
+//NAME MTMU
+
+NAME ASPP
+
+RESOURCE RSS_SIGNATURE { }
+
+
+RESOURCE MENU_PANE r_pbkinfoviewprovider_menu
+{
+    items=
+		{
+		MENU_ITEM { cascade=r_pbkinfoviewprovider_submenu; command=EPbkInfoViewProviderCmd; txt=qtn_options_infoview; }
+		};
+}
+
+
+RESOURCE MENU_PANE r_pbkinfoviewprovider_submenu
+	{
+	items =
+		{
+		MENU_ITEM { command=EPbkInfoViewProviderCmd;	 txt=qtn_phob_vc_info_options_infoview; }
+		};
+	}
+
+
+
+
+
+// End of file
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for all VoiceUI modules.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include "voiceuibldvariant.hrh"
+#include "../vcommand/group/bld.inf"
+#include "../voiceuivoicerecognition/group/bld.inf"
+#include "../pbkinfoviewimpl/group/bld.inf"
+#include "../aiwpbkinfoviewprovider/group/bld.inf"
+
+#ifdef __VCOMMAND_CONTROL_PANEL
+#include "../vccontrolpanelplugin/group/bld.inf"
+#endif
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+#include "exports.inc"
+#include "../rom/exports.inc"
+
+PRJ_MMPFILES
+
+
+PRJ_EXTENSIONS
+
+#ifdef __SIND
+START EXTENSION s60/mifconv
+OPTION TARGETFILE voiceui.mif
+OPTION HEADERFILE voiceui.mbg
+OPTION SOURCES -c8,1 qgn_prop_profiles_small -c8,1 qgn_prop_fmgr_file_apps
+END
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,3 @@
+// exports.inc
+
+//#include "..\VoiceUiVoiceRecognition\group\exports.inc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/group/icons.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,72 @@
+#
+# Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icons used for Speaker independent voice commands
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\system\data
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\voiceui.mif
+HEADERFILENAME=$(HEADERDIR)\voiceui.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+			/c8,1 qgn_prop_profiles_small.bmp \
+			/c8,1 qgn_prop_fmgr_file_apps.bmp \
+
+
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/group/icons_scalable.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,72 @@
+#
+# Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icons used for Speaker independent voice commands
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\voiceui.mif
+HEADERFILENAME=$(HEADERDIR)\voiceui.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+			/c8,1 qgn_prop_profiles_small.svg \
+			/c8,1 qgn_prop_fmgr_file_apps.svg \
+
+
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/group/voiceuibldvariant.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Flags for VoiceUi build
+*
+*/
+
+
+#ifndef VOICEUIBLDVARIANT_HRH
+#define VOICEUIBLDVARIANT_HRH
+
+
+#define __VCOMMAND_CONTROL_PANEL
+
+
+// For fullduplex change
+#define __FULLDUPLEX_CHANGE
+
+#endif // VOICEUIBLDVARIANT_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/bwins/pbkinfoviewu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	?NewL@CPbkInfoViewApi@@SAPAV1@XZ @ 1 NONAME ; class CPbkInfoViewApi * CPbkInfoViewApi::NewL(void)
+	?ShowInfoViewL@CPbkInfoViewApi@@QAEXH@Z @ 2 NONAME ; void CPbkInfoViewApi::ShowInfoViewL(int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/eabi/pbkinfoviewu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN15CPbkInfoViewApi13ShowInfoViewLEi @ 1 NONAME
+	_ZN15CPbkInfoViewApi4NewLEv @ 2 NONAME
+	_ZTI15CPbkInfoViewApi @ 3 NONAME DATA 12 ; #<TI>#
+	_ZTI23CPbkInfoViewSindHandler @ 4 NONAME DATA 48 ; #<TI>#
+	_ZTV15CPbkInfoViewApi @ 5 NONAME DATA 20 ; #<VT>#
+	_ZTV23CPbkInfoViewSindHandler @ 6 NONAME DATA 108 ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build info for pbkinfoview
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../loc/pbkinfoview.loc                APP_LAYER_LOC_EXPORT_PATH(pbkinfoview.loc)
+
+
+PRJ_MMPFILES
+pbkinfoview.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/group/pbkinfoview.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP file for pbkinfoview.dll
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET        pbkinfoview.dll
+TARGETTYPE    dll
+
+// 0x10281C82 infoview.dll
+UID	0x10009D8D 0x10281C82
+
+VENDORID VID_DEFAULT
+
+CAPABILITY CAP_GENERAL_DLL
+
+
+USERINCLUDE	../inc
+
+// This is a SYSTEMINCLUDE macro containing the applications
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE	/epoc32/include/ecom
+
+// other resources must be placed in z:/system/data
+START RESOURCE ../src/pbkinfoview.rss
+TARGETPATH      RESOURCE_FILES_DIR
+HEADER
+LANGUAGE_IDS
+END
+
+SOURCEPATH	    ../src
+SOURCE		    pbkinfoviewapi.cpp
+SOURCE          pbkinfoviewutil.cpp
+SOURCE          pbkinfoviewreshandler.cpp
+SOURCE          pbkinfoviewdialog.cpp
+SOURCE          pbkinfoviewdialogutil.cpp
+SOURCE          pbkinfoviewsindhandler.cpp
+
+USERINCLUDE       ../../rubydebug
+
+
+LIBRARY	euser.lib
+LIBRARY cone.lib 
+
+LIBRARY eikcore.lib 
+LIBRARY avkon.lib
+LIBRARY eikctl.lib
+LIBRARY ecom.lib
+LIBRARY eikdlg.lib
+LIBRARY bafl.lib
+LIBRARY commonengine.lib
+LIBRARY eikcoctl.lib
+LIBRARY estor.lib
+LIBRARY edbms.lib
+LIBRARY aknskins.lib
+LIBRARY nssttsutility.lib
+
+//LIBRARY	FeatMgr.lib
+LIBRARY commdb.lib
+LIBRARY	efsrv.lib
+LIBRARY commondialogs.lib
+LIBRARY	hlplch.lib
+
+LIBRARY nssvasapi.lib
+LIBRARY pbkeng.lib
+LIBRARY nssttscommon.lib
+
+LIBRARY VPbkEng.lib
+LIBRARY Pbk2Presentation.lib
+LIBRARY Pbk2CommonUI.lib
+LIBRARY	fbscli.lib
+LIBRARY	egul.lib 
+//EXPORTUNFROZEN
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoview.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     
+*
+*/
+
+#ifndef _INFOVIEW_RH
+#define _INFOVIEW_RH
+
+#define PBKINFOVIEW_UID 0x10281C82
+#define PBKINFOVIEW_HELP_UID  0x101F8555
+
+enum TDialogControlIds
+    {
+    EInfoViewDialogList = 1
+    };
+
+enum TInfoViewMenuCommands
+	{
+	EInfoViewMenuCmdPlay = 1,
+	EInfoViewMenuCmdHelp = 2,
+	EInfoViewMenuCmdExit = 3
+	};
+
+
+
+#endif  // _INFOVIEW_RH
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoviewapi.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains functions that are exported from PbkInfoView for 
+*                PbkInfoView AIW provider.
+*
+*/
+
+
+#ifndef PBKINFOVIEWAPI_H
+#define PBKINFOVIEWAPI_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CLASS DECLARATION
+class CPbkInfoViewDialog;
+
+/**
+*  Public API for executing info view. 
+* 
+*  @lib pbkinfoview.lib
+*  
+*/
+class CPbkInfoViewApi : public CBase
+    {
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+	    IMPORT_C static CPbkInfoViewApi* NewL();
+
+	    /**
+        * Destructor.
+        */
+	    virtual ~CPbkInfoViewApi();
+	    
+        /**
+        * Shows info view displaying voice commands related to the contact.
+        * @param aContactId Contact id from contacts db.
+	    * @return None.
+        */
+		IMPORT_C void ShowInfoViewL( TInt aContactId );
+
+    private:
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+        CPbkInfoViewApi();
+    };
+
+
+#endif  // PBKINFOVIEWAPI_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoviewdialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,270 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Pbk info view dialog.
+*
+*/
+
+
+#ifndef PBKINFOVIEWDIALOG_H
+#define PBKINFOVIEWDIALOG_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <eikdialg.h>
+#include <eiklbo.h>
+#include <aknlists.h>
+#include <AknDialog.h>
+#include <aknnavi.h>
+#include <AknInfoPopupNoteController.h>
+
+#include "pbkinfoviewdialogutil.h"
+#include "pbkinfoviewreshandler.h"
+#include "pbkinfoviewsindhandler.h"
+
+// FORWARD DECLARATIONS
+class TXspIconHelper;
+
+// CLASS DECLARATION
+
+/**
+*  Pbk info view dialog.
+*/
+NONSHARABLE_CLASS (CPbkInfoViewDialog) : public CAknDialog, public MEikListBoxObserver
+	{
+    enum TInfoViewDialogIconIndex
+		{
+		EIconIndexPhone = 0,
+		EIconIndexMobile,
+	    EIconIndexVideo,
+	    EIconIndexVoip,
+	    EIconIndexEmail,
+	    EIconIndexEmpty
+		};	
+
+    public:// Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CPbkInfoViewDialog* NewL( TInt aContactId );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CPbkInfoViewDialog();
+        
+    public:
+    
+        /**
+        * Overrides CAknDialog::ExecuteLD. Checks whether the contact has any
+        * voice tags. If not an info note is displayed. Otherwise calls
+        * CAknDialog::ExecuteLD
+        * @param aResourceId The resource ID of the dialog to be loaded
+        * @return see CAknDialog::ExecuteLD
+        */
+        TInt ExecuteLD( TInt aResourceId );
+        
+        /** 
+         * Responds to a change in focus.
+         *
+         * @param aDrawNow Contains the value that was passed to it by 
+         *        @c SetFocus(). 
+         */         
+        void FocusChanged(TDrawNow aDrawNow); 
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CPbkInfoViewDialog( TInt aContactId );
+	
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+	private:
+	
+	    /**
+        * Called by framework before the dialog is shown.
+        * @param None
+		* @return None
+        */
+		void PostLayoutDynInitL();
+
+        /**
+        * Called by framework after the dialog is shown.
+        * @param None
+		* @return None
+        */
+		void PreLayoutDynInitL();
+
+		/**
+		* Handles menu events.
+		* @param  aCommandId Command id.
+		* @return None.
+		*/
+		void ProcessCommandL( TInt aCommandId );
+
+        /**
+        * From the base class.
+		* Called by framework for key event handling.
+        * @param aKeyEvent.
+		* @param TEventCode.
+		* @return Return code.
+        */
+		TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
+
+        /**
+        * From the base class.
+		* Called by framework before exiting the dialog.
+        * @param Button id.
+		* @return ETrue to exit\ EFalse to not to exit.
+        */
+		TBool OkToExitL(TInt aButtonId);
+
+		/**
+        * From the base class.
+		* Called by framework before menu is shown.
+        * @param aResourceId Menu resource id.
+		* @param aMenuPane Pointer to the menu.
+        * @return None.
+        */
+		void DynInitMenuPaneL( TInt aResourceID,	CEikMenuPane* aMenuPane );
+
+	   /**
+		* From the base class.
+        * Called when dialog is activated.
+        * @return None.
+        */
+		void ActivateL();
+		
+		/**
+		* Method to get context sensitive help topic.
+        * @param aContext Help topic to open.
+		* @return None.
+        */
+		void GetHelpContext( TCoeHelpContext& aContext ) const;
+		
+		/**
+		* Called when display resolution changes.
+        * @param aType.
+		* @return None.
+        */
+		void HandleResourceChange( TInt aType );
+		
+		/**
+		* Updates dialog cba.
+		* @param aResourceId Resource id.
+		* @return None.
+		*/
+		void UpdateCbaL( TInt aResourceId );
+		
+	    /**
+        * Returns TInfoViewDialogIconIndex enumeration icon index.
+		* @param aIconId enumeration TPbkIconId from PbkIconId.hrh.
+		*        aTagIndex voice tag index
+        * @return Icon index.
+        */
+		TInt IconIndex( TInt aIconId,TInt aTagIndex );
+		
+		/**
+        * Creates listbox items.
+        * @return None.
+        */
+		void CreateListBoxItemsL();
+		
+		/**
+        * Shows popup for a voice command in the list.
+        * @return None.
+        */
+		void ShowPopupL();
+
+		/**
+		* Gets current listbox item.
+		* @param None.
+		* @return Current listbox item index.
+		*/
+		TInt CurrentItemIndex();
+		
+		/**
+	    * Displays an information note
+	    * @param aResourceId Id for the resource text to be shown
+	    */
+        void ShowInformationNoteL( TInt aResourceId );
+
+		/**
+	    * Check if call is ongoing
+	    */		
+		TBool IsCallActive();
+		
+		/**
+	    * Show "Call in progress" note
+	    */		
+		void CallInProgressNoteL();
+		
+		/**
+	    * Create field icons
+	    */			
+		void CreateFieldIconsL(CArrayPtr<CGulIcon>* aIconArray);
+		
+	private: // from MEikListBoxObserver
+        /**
+        * From MEikListBoxObserver, called by framework.
+        * @param aListBox.
+        * @param aEventType.
+		* @return None
+        */
+		void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
+		
+    private:
+
+		// Id of the contact in contacts db
+		TInt iContactId;
+		
+		// Contact is on sim or mmc card and has no voice tags
+		TBool iVoiceTaglessContact;
+
+		// Id of the dialog mode
+		TInt iDialogMode;
+
+		// List of voice commands, does not take ownership
+		CAknDoubleGraphicStyleListBox* iListBox;
+		
+		// For title and icon handling
+		CStatusPaneHandler* iStatusPaneHandler;
+		
+		// For hiding tabs, does not take ownership
+		CAknNavigationControlContainer* iNaviPane;
+		
+		// Popup controller
+		CAknInfoPopupNoteController* iPopupController;
+		
+		// Resource handler
+		CPbkInfoViewResHandler* iResHandler;
+
+		// Currently selected listbox item
+		TInt iCurrentListBoxIndex;
+		
+		// SIND handler
+		CPbkInfoViewSindHandler* iSindHandler;
+		
+		//XSp icon helper
+		RArray<TXspIconHelper>   iXspIconHelper;
+    };
+
+#endif    // PBKINFOVIEWDIALOG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoviewdialogutil.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for info view dialog.
+*
+*/
+
+
+#ifndef PBKINFOVIEWDIALOGUTIL_H
+#define PBKINFOVIEWDIALOGUTIL_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <akntabgrp.h>      // for AknTextUtils
+#include <aknlistquerycontrol.h>
+#include <AknQueryDialog.h>
+#include <AknsUtils.h>      // for AknsUtils
+
+// CONSTANTS
+const TInt KBufSize = 128;
+
+
+/**
+* TDialogUtil
+* 
+* TDialogUtil contains general dialog utilities.
+*/
+NONSHARABLE_CLASS ( TDialogUtil )
+	{
+    public:
+    
+        /**
+		* Constructs a list-box item for CAknDoubleLargeStyleListBox.
+		* @param aFirstLine First line of the dialog item
+        * @param aSecondLine Second line of the dialog item
+        * @param aIconIndex Icon index
+        * @return HBufC* Pointer to the newly created list box item.
+		*/
+        static HBufC* ConstructListBoxItemLC( const TDesC& aFirstLine,
+                                              const TDesC& aSecondLine,
+                                              TInt aIconIndex );
+        
+        /**
+		* Constructs an independent CGulIcon object with fallback support.
+		* If no matching item (aId) is found in the currently active skin,
+		* attempts to construct the item using the given file (last 3 parameters).
+		* @param aID Item ID of the masked bitmap to be created.
+        * @param aFilename Filename to be used to construct the item, 
+        * @param aFileBitmapId Id (for bitmap) in the file. 
+        * @param aFileMaskId Id (for mask) in the file.
+        * @return CGulIcon* Pointer to the newly created CGulIcon object.
+        *         Ownership of the object is transferred to the caller.
+		*/
+		static CGulIcon* CreateIconL( TAknsItemID aId, const TDesC& aFileName,
+		                              TInt aFileBitmapId, TInt aFileMaskId);
+	};
+
+/**
+* CStatusPaneHandler
+* 
+* This class is used for changing dialog title and image.
+*/
+NONSHARABLE_CLASS (CStatusPaneHandler) : public CBase
+	{
+    public:
+        /**
+        * Two-phased constructor.
+        */
+		static CStatusPaneHandler* NewL(CAknAppUi* aAppUi);
+
+        /**
+        * Destructor.
+        */
+		virtual ~CStatusPaneHandler();
+
+    private:
+        /**
+        * By default Symbian OS constructor is private.
+        */
+		void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+		CStatusPaneHandler(CAknAppUi* aAppUi);
+
+	public:
+	    /**
+		* Sets the member variable for previous title.
+		* @param  None.
+		* @return None.
+		*/
+        void StoreOriginalTitleL();
+        
+        /**
+		* Sets the dialog title.
+		* @param aResourceId Resource id from resource file.
+		* @return None.
+		*/
+		void SetTitleL( TInt aResourceId );
+
+		/**
+		* Restores previous title when returning to previous view.
+		* @param  None.
+		* @return None.
+		*/
+		void RestorePreviousTitleL();
+
+     private:	
+		/**
+		* Gets the dialog title.
+		* @param aAppUi Pointer to UI class.
+		* @param aText Title will be put to this variable.
+		* @return TBool ETrue: success / EFalse: failure.
+		*/
+		static TBool GetPreviousTitleL( CAknAppUi* aAppUi, TDes& aText );
+		
+		/**
+		* Restores previous title image when returning to previous view.
+		* @param  None.
+		* @return None.
+		*/
+		void RestoreOriginalImageL();
+
+		/**
+		* Sets dialog image.
+		* @param aAppUi Pointer to UI class.
+		* @param aIcon New image .
+		* @return CEikImage* previous image.
+		*/
+		static CEikImage* SetImageL( CAknAppUi* aAppUi, CEikImage* aIcon );
+		
+		/**
+		* Sets the dialog title.
+		* @param aAppUi Pointer to the UI class.
+		* @param aText TItle text.
+		*/
+		void static SetTitleL( CAknAppUi* aAppUi, const TDesC& aText );
+		
+
+	private:
+		// Access to app ui
+		CAknAppUi* iAppUi;
+
+		// Original status pane title
+		TBuf<KBufSize> iOriginalTitle;
+		
+		// Is original status pane title stored
+		TBool iOriginalTitleStored;
+
+		// Original context pane image
+		CEikImage* iOriginalImage;
+	};
+
+#endif      // PBKINFOVIEWDIALOGUTIL_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoviewreshandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is used for reading pbkinfoview resources.
+*
+*/
+
+
+#ifndef PBKINFOVIEWRESHANDLER_H
+#define PBKINFOVIEWRESHANDLER_H
+
+
+// INCLUDES
+#include <e32base.h>
+#include <eikenv.h>
+#include <aknenv.h>
+
+#include "pbkinfoviewdefines.h"
+
+// FORWARD DECLARATIONS
+class RResourceFile;
+
+// CLASS DECLARATION
+/**
+* CPbkInfoViewResHandler
+*
+* This class is used for reading pbkinfoview resources.
+*/
+NONSHARABLE_CLASS (CPbkInfoViewResHandler) : public CBase
+    {
+    public:
+    
+        /**
+        * Two-phased constructor.
+        */
+        static CPbkInfoViewResHandler* NewL();
+
+	    /**
+        * Destructor.
+        */
+        ~CPbkInfoViewResHandler();
+        
+        /**
+        * Finds out phonebook bitmap file name.
+        * @param aText File name will be put here.
+		* @return None.
+        */
+        static void GetBitmapFileName( TDes& aText );
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+	    CPbkInfoViewResHandler();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+	    void ConstructL();
+    
+    	/**
+        * Finds out the pbkinfoview resource file name.
+        * @param aText File name will be put here.
+		* @return None.
+        */
+        static void GetResFileName( TDes& aText );
+        
+    private:
+		//  sync app resource file id
+	    TInt iResId;
+    };
+
+
+
+#endif  // PBKINFOVIEWRESHANDLER_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoviewsindhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,249 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Used to fetch voice tags from vas db
+*
+*/
+
+
+#ifndef PBKINFOVIEWSINDHANDLER_H
+#define PBKINFOVIEWSINDHANDLER_H
+
+// INCLUDES
+#include <nssvasapi.h>
+#include <nssttsutility.h>
+
+// FORWARD DECLARATIONS
+class CPbkContactEngine;
+class CPbkContactItem;
+class TPbkContactItemField;
+class MVasBasePbkHandler;
+
+// CONSTANTS
+const TInt KMaxSegments = 6;
+
+// CLASS DECLARATION
+
+/**
+ * Extension for Phonebook engine.
+ */
+class CPbkInfoViewSindHandler : public CBase,
+                                public MNssGetContextClient,
+                                public MNssGetTagClient,
+                                public MNssPlayEventHandler,
+                                public MTtsClientUtilityObserver
+    {
+    public: // Constructor and destructor
+        /**
+         * Creates a new instance of CPbkSindHandler.
+         * @param aContactId Contact id for the contact whose voice tags are to
+         *        be fetched from vas db.
+         */
+        static CPbkInfoViewSindHandler* NewL( TInt aContactId );
+        /**
+         * Creates an instance that doesn't require CCoeEnv for STIF testing
+         * purposes.
+         * @param aContactId Contact id for the contact whose voice tags are to
+         *        be fetched from vas db.
+         */
+        static CPbkInfoViewSindHandler* TestNewL( TInt aContactId );
+        /**
+         * Destructor.
+         */
+        ~CPbkInfoViewSindHandler();
+        /**
+         * Returns the number of voice tags for the contact.
+         * @return TInt voice tag count.
+         */
+         TInt VoiceTagCount();
+         /**
+         * Returns a voice tag.
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         * @return TDesC& the voice tag
+         */
+         const TDesC& VoiceTagL( TInt aIndex );
+         
+         /**
+         * Returns the label associated with a voice tag (mobile, home, etc).
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         * @return HBufC* the label 
+         */
+         HBufC* VoiceTagLabelLC( TInt aIndex );
+         /**
+         * Returns the phone number, e-mail address, etc. associated with a
+         * voice tag.
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         * @return TPtrC the value
+         */
+         TPtrC VoiceTagValueL( TInt aIndex );
+         /**
+         * Returns the popup text associated with a voice tag.
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         * @return TDesC& popup text
+         */
+         TDesC& PopupTextL( TInt aIndex );
+         /**
+         * Plays a voice tag.
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         */
+         void PlayVoiceCommandL( TInt aIndex );
+         /**
+         * Cancels voice tag playback.
+         * @return TBool boolean value
+         */
+         void CancelPlaybackL();
+         /**
+         * Is voice tag playing ongoing.
+         * @return TBool boolean value
+         */
+         TBool IsPlaying();
+         /**
+         * Returns an icon id for the contact field the voice tag is associated
+         * with.
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         * @return TInt the icon id
+         */
+         TInt IconIdL( TInt aIndex );
+		 
+         /**
+         * Returns an field id that the voice tage is associated
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+		 * @return TInt field id
+         */
+         TInt FieldIdL( TInt aIndex );
+         
+         /**
+         * Returns a tag label that the voice tage is associated
+         * @param aIndex index for the voice tag.
+         *        0 <= aIndex <= VoiceTagCount() - 1
+         * @return TPtrC the tag label
+         */
+         TPtrC LabelL( TInt aIndex );
+         
+         /**
+         * Calls CompareL and catches possible leaves
+         */
+         static TInt Compare( const MNssTag& aTag1, const MNssTag& aTag2 );
+         
+         /**
+         * Compares two voice tags and decides which one should be displayed
+         * first in info view list. Used in the sorting of voice tags.
+         * @param aTag1 A voice tag
+         * @param aTag2 A voice tag
+         * @return TInt -1 if aTag1 should be displayed first, 1 if aTag2 should be 
+                   displayed first, 0 otherwise.
+         */
+         static TInt CompareL( const MNssTag& aTag1, const MNssTag& aTag2 );
+        
+    public: // From MNssGetContextClient
+    
+        void GetContextCompleted( MNssContext* aContext, TInt aErrorCode );
+        void GetContextListCompleted( MNssContextListArray* aContextList,
+                                      TInt aErrorCode );
+    
+    public: // From MNssGetTagClient
+    
+        void GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode );
+        
+    public: // From MNssPlayEventHandler
+        void HandlePlayComplete( TNssPlayResult aErrorCode );
+        // Not implemented
+        void HandlePlayStarted( TTimeIntervalMicroSeconds32 /*aDuration*/ ) {};
+
+    public: // From MTtsClientUtilityObserver
+        // Not implemented
+        void MapcCustomCommandEvent( TInt /*aEvent*/, TInt /*aError*/ ) {};
+        
+        void MapcInitComplete(TInt /*aError*/, const TTimeIntervalMicroSeconds& /*aDuration*/) {};
+        
+        void MapcPlayComplete(TInt /*aError*/) {};
+        
+    private: // own methods:
+        /**
+        * Initialization.
+        * @param aContactId Contact id for the contact whose voice tags are
+        *         fetched from vas db.
+        */
+        void InitializeL( TInt aContactId );
+        
+        /**
+        * Fetches voice tag list from vas db.
+        * @param aContactId Contact id for the contact whose voice tags are
+        *         fetched from vas db.
+        */
+        void CreateVoiceTagListL( TInt aContactId );
+        
+        /**
+        * Creates an array for popups in info view list.
+        */
+        void CreatePopupArrayL();
+        
+        /**
+        * Tries to find default contact item field.
+        * @param aContactItem A contact item
+        * @param aFieldId A field to search
+        * @return TPbkContactItemField* Default field if found, otherwise NULL
+        */
+        static TPbkContactItemField* FindDefaultField( CPbkContactItem* aContactItem,
+                                                       TInt aFieldId );
+
+    private: // Implementation
+        CPbkInfoViewSindHandler();
+        void ConstructL( TInt aContactId );
+        void TestConstructL( TInt aContactId );
+        
+    private: // Data
+       
+        // Vas databse manager
+        CNssVASDBMgr* iVasDbManager;        
+        // Nss context
+        MNssContext* iContext;
+        // Scheduler wait object
+        CActiveSchedulerWait* iWait;
+        // Context manager, does not take ownership
+        MNssContextMgr* iContextManager;        
+        // Tag manager, does not take ownership
+        MNssTagMgr* iTagManager;
+        // Error code received from observer call-back methods.
+        TInt iErr;
+        // Voice tag array
+        RPointerArray<MNssTag> iTagArray;
+        // Phonebook contact item
+        CPbkContactItem* iPbkContactItem;
+        // Phonebook engine
+        CPbkContactEngine* iPbkEngine;
+        // Phonebook contact item field for phone numbers etc, and icons.
+        // Does not take ownership
+        TPbkContactItemField* iPbkContactItemField;
+        // Array for popups in info view list.
+        RPointerArray<TDesC> iPopupArray;
+        // Current voice tag form iTagArray being played
+        TInt iPlaybackIndex;
+         // For getting the phone numbers etc used in voice tags
+        MVasBasePbkHandler* iPbkHandler;
+        // TTS Utility
+        CTtsUtility* iTts;
+
+        //static TInt iContactId;
+    };
+
+#endif  // __PBINFOVIEWKSINDHANDLER_H__
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/inc/pbkinfoviewutil.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility functions for PbkInfoView.
+*
+*/
+
+
+
+#ifndef PBKINFOVIEWUTIL_H
+#define PBKINFOVIEWUTIL_H
+
+// INCLUDES
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+/**
+* Utility functions for PbkInfoView. 
+*/
+NONSHARABLE_CLASS (TPbkInfoViewUtil)
+	{
+    public:
+        static void Panic( TInt aReason) ;
+        
+        /** 
+        * String copy with length check.
+        * @param TDes8& aTarget Copied text will be put to this variable.
+        * @param TDesC& aSource Includes the text to be copied.
+        * @return None
+        */
+		static void StrCopy( TDes8& aTarget, const TDesC& aSource );
+		
+		/** 
+        * String copy with length check.
+        * @param TDes& aTarget Copied text will be put to this variable.
+        * @param TDesC8& aSource Includes the text to be copied.
+        * @return None
+        */
+		static void StrCopy( TDes& aTarget, const TDesC8& aSource );
+		
+		/** 
+        * String copy with length check.
+        * @param TDes& aTarget Copied text will be put to this variable.
+        * @param TDesC& aSource Includes the text to be copied.
+        * @return None
+        */
+		static void StrCopy( TDes& aTarget, const TDesC& aSource );
+		
+		/** 
+        * Adds resource file to control environment.
+        * @param aFile File location.
+        * @return TInt Error code.
+        */
+		static TInt AddResFileL(const TDesC& aFile);
+	};
+
+#endif  // PBKINFOVIEWUTIL_H
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/loc/pbkinfoview.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localisation file for pbkinfoview
+*
+*/
+
+
+// d:Command in phonebook's contact info options list. Opens dialog for infoview.
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_phob_vc_info_options_infoview                "Voice command info"
+
+// d:Title for voice commands info view
+// l:title_pane_t1
+// r:3.2
+//
+#define qtn_phob_vc_info_title                           "Voice command info"
+
+// d:Options list menu item for playing the command
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_phob_opt_play                                "Play command" 
+
+// d:Options list menu item for help 
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_options_help                                 "Help"
+
+// d:Options list menu item for exiting voice commands info view
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_options_exit                                 "Exit"
+
+// d:Tooltip text instructing on how to use a voice command.
+// l:popup_preview_text_window/opt5
+// r:3.2
+//
+#define qtn_pb_voice_info_popup_contact                  "Say \"%U\" to call the contact."
+
+// d:Tooltip text instructing on how to use a voice command.
+// l:popup_preview_text_window/opt5
+// r:3.2
+//
+#define qtn_pb_voice_info_popup_contact_general          "Say \"%U\"."        
+
+// d:Information note displayed when a contact has no voice commands.
+// l:popup_note_window/opt2
+// r:3.2
+//
+#define qtn_phob_vc_info_empty_list                      "There are no voice commands for this contact."
+
+// d:Information note displayed when a contact is not stored in phone memory.
+// l:popup_note_window/opt2
+// r:3.2
+//
+#define qtn_phob_vc_info_empty_list_sim_contact          "Contacts not on phone memory cannot be voice dialed."
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoview.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+//  INCLUDES
+
+#include <eikon.rh>
+#include "registryinfov2.rh" 
+#include "pbkinfoview.rh"
+
+// aspsyncutil uses sync app .loc file
+#include <pbkinfoview.loc>
+
+// common avkon strings
+#include <avkon.loc>
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <AvkonIcons.hrh>
+
+
+#include <vuivoicerecognition.loc>
+
+//  RESOURCE IDENTIFIER
+NAME INFV
+
+
+RESOURCE RSS_SIGNATURE { }
+
+
+//
+// STRINGS
+//
+
+STRUCT STRING
+	{
+	LTEXT text;
+	}
+	
+// Dialog title
+RESOURCE TBUF r_infoview_dialog_title { buf=qtn_phob_vc_info_title; }
+
+// Popup texts
+RESOURCE TBUF r_infoview_popup_contact { buf=qtn_pb_voice_info_popup_contact; }
+RESOURCE TBUF r_infoview_popup_general { buf=qtn_pb_voice_info_popup_contact_general; }
+
+// String for a view with no voice commands
+RESOURCE TBUF r_infoview_empty_view { buf=qtn_phob_vc_info_empty_list; }
+// String for a view with a contact not from phone's contacts db 
+// that therefore no voice commands
+RESOURCE TBUF r_infoview_empty_view_sim_contact { buf=qtn_phob_vc_info_empty_list_sim_contact; }
+
+
+RESOURCE TBUF   r_text_call_in_progress         { buf = text_call_in_progress; }
+
+//------------------------------------------------------------------------------
+// r_infoview_app_listbox
+// Listbox resourcee
+//------------------------------------------------------------------------------
+//
+RESOURCE LISTBOX r_infoview_app_listbox 
+	{
+	flags = 0x0001;
+	}
+
+
+// -----------------------------------------------------------------------------
+// r_infoview_dialog
+// infoview dialog resource.
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_infoview_dialog
+    {
+	  flags=EEikDialogFlagWait | EEikDialogFlagFillAppClientRect | EEikDialogFlagNotifyEsc;
+
+    buttons=R_AVKON_SOFTKEYS_OPTIONS_EXIT; // r_softkeys_options_back__play
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtDoubleGraphicListBox;
+			      itemflags=EEikDlgItemTakesEnterKey;
+			      id=EInfoViewDialogList;
+			      control=LISTBOX
+				        {
+				        flags=0;
+				        height=2;
+				        width=80;
+				        };
+            }
+		    };
+    }
+
+// -----------------------------------------------------------------------------
+// r_infoview_dialog_menu
+// Info view menu bar.
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_infoview_dialog_menu
+	{
+	titles= 
+		{ 
+		MENU_TITLE 
+			{ 
+			menu_pane=r_infoview_dialog_menu_pane;
+			}
+		};
+	}
+
+// -----------------------------------------------------------------------------
+// r_infoview_dialog_menu_pane
+// Info view menu.
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_infoview_dialog_menu_pane
+    {
+    items =
+        {
+        MENU_ITEM 
+            {
+            command = EInfoViewMenuCmdPlay;
+            txt = qtn_phob_opt_play;
+            flags = EEikMenuItemAction;
+            },
+		    
+        MENU_ITEM
+            {
+            command = EInfoViewMenuCmdHelp;
+            txt = qtn_options_help;
+            },
+            
+        MENU_ITEM
+            {
+            command = EInfoViewMenuCmdExit;
+            txt = qtn_options_exit;
+            }
+        };
+    }
+	
+//-----------------------------------------------------------------------------
+//  r_softkeys_options_exit__select
+//  Info view softkeys
+//-----------------------------------------------------------------------------
+//
+RESOURCE CBA r_softkeys_options_back__play
+    {
+    buttons =
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back; },
+        AVKON_CBA_BUTTON{id=EAknSoftkeySelect; longpressid=0; txt = qtn_msk_play; }
+        };
+    }
+
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewapi.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains functions that are exported from PbkInfoView for 
+*               PbkInfoView AIW provider.
+*
+*/
+
+
+#include <eikenv.h>
+#include "pbkinfoviewapi.h"
+#include <pbkinfoview.rsg>
+#include "pbkinfoviewdialog.h"
+#include "rubydebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewApi::NewL
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CPbkInfoViewApi* CPbkInfoViewApi::NewL()
+    {
+    CPbkInfoViewApi* self = new (ELeave) CPbkInfoViewApi();
+    CleanupStack::PushL(self);
+	self->ConstructL();
+    CleanupStack::Pop(self);
+
+	return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Destructor.
+//
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewApi::~CPbkInfoViewApi()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewApi::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewApi::ConstructL()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewApi::CPbkInfoViewApi
+//
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewApi::CPbkInfoViewApi()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewApi::ShowInfoViewL
+// Shows info view displaying voice commands related to the contact.
+// @param aContactId Contact id from contacts db.
+// @return None.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CPbkInfoViewApi::ShowInfoViewL( TInt aContactId )
+    {
+    RUBY_DEBUG_BLOCKL( "CPbkInfoViewApi::ShowInfoViewL" );
+    
+    CPbkInfoViewDialog* infoViewDialog = CPbkInfoViewDialog::NewL( aContactId );
+    CleanupStack::PushL( infoViewDialog );
+
+    // Framework handles the destruction of infoViewDialog;
+    infoViewDialog->ExecuteLD( R_INFOVIEW_DIALOG );
+
+    CleanupStack::Pop( infoViewDialog );
+	}
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewdefines.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains general data definitions for pbkinfoview.
+*
+*/
+
+
+#ifndef PBKINFOVIEWDEFINES_H
+#define PBKINFOVIEWDEFINES_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <AiwGenericParam.hrh>
+
+// CONSTANTS
+_LIT( KLocFileString, "%U" );
+_LIT( KFormatString, "%S" );
+_LIT( KEmpty, "" );
+_LIT( KSpace, " " );
+_LIT( KUnderscore, "_" );
+_LIT( KTagNameSeparator, "_1" );
+_LIT( KTagExtensionSeparator, "_2" );
+_LIT( KMatchNameSeparator, "_1*" );
+
+const TInt KTagSeparatorLength = 2;
+const TInt32 KVoiceTaglessContactId = -2;
+
+// resource files
+_LIT( KResFileName, "z:pbkinfoview.rsc" );
+_LIT( KBitmapFileName, "z:avkon2.mbm" );
+
+// string sizes
+const TInt KBufSize16 = 16;
+
+const TInt KDefaultArraySize = 10;
+
+#endif  // PBKINFOVIEWDEFINES_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewdialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,805 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Pbk info view dialog.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <AknIconArray.h>   // for GulArray
+#include <bldvariant.hrh>
+#include "pbkinfoviewdialog.h"
+#include "pbkinfoviewutil.h"
+#include "pbkinfoviewsindhandler.h"
+#include "pbkinfoviewdefines.h"
+#include <pbkinfoview.rsg>
+#include "pbkinfoview.rh"
+#include <e32property.h>        // RProperty
+#include <PSVariables.h>        // Property values
+#include <ctsydomainpskeys.h>
+
+#include "rubydebug.h"
+
+#include <csxhelp/vc.hlp.hrh>  // for help text id
+#include <eikmenub.h>  // CEikMenuBar
+#include <PbkIconId.hrh> // Phonebook icon ids
+#include <aknnotewrappers.h>  // For information note
+#include <StringLoader.h>
+
+#include <MPbk2FieldPropertyArray.h>
+#include <VPbkEng.rsg>
+#include <CPbk2StoreConfiguration.h>
+#include <CVPbkContactStoreUriArray.h>
+#include <CVPbkContactManager.h>
+#include <VPbkContactStoreUris.h>
+#include <CVPbkFieldTypeRefsList.h>	
+#include <CPbk2IconFactory.h>
+#include <Pbk2FieldPropertiesFactory.h>
+#include <MPbk2FieldProperty.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <PbkFields.hrh>
+
+#include <MPbk2FieldPropertyArray2.h>
+#include <MPbk2FieldProperty2.h>
+#include <MPbk2FieldProperty.h>
+
+const TUint KFieldIds[] = 
+    {
+    R_VPBK_FIELD_TYPE_LANDPHONEGEN,    
+    R_VPBK_FIELD_TYPE_MOBILEPHONEGEN,  
+    R_VPBK_FIELD_TYPE_VIDEONUMBERGEN,
+    R_VPBK_FIELD_TYPE_VOIPGEN,
+    R_VPBK_FIELD_TYPE_EMAILGEN,
+    R_VPBK_FIELD_TYPE_IMPP
+    };
+
+NONSHARABLE_CLASS( TXspIconHelper )
+    {
+    public:    
+        TXspIconHelper( TInt aIndex, const TDesC& aLable );
+        TDesC& LableText();
+        TInt   Index();
+    private:
+        TBuf<KPbkSIPMaxLength> iLable;
+        TInt iIndex;
+    };
+
+TXspIconHelper::TXspIconHelper( TInt aIndex, const TDesC& aLable ):
+    iLable(aLable),iIndex(aIndex)
+    {
+    }
+
+inline TInt TXspIconHelper::Index()
+    {
+    return iIndex;
+    }
+inline TDesC& TXspIconHelper::LableText()
+    {
+    return iLable;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewDialog* CPbkInfoViewDialog::NewL( TInt aContactId )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::NewL" );
+
+    CPbkInfoViewDialog* self = new ( ELeave ) CPbkInfoViewDialog( aContactId );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::CPbkInfoViewDialog
+// 
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewDialog::CPbkInfoViewDialog( TInt aContactId )
+    {
+	iContactId = aContactId;
+	
+	if( aContactId == KVoiceTaglessContactId )
+	    {
+	    iVoiceTaglessContact = ETrue;
+	    }
+    }
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::ConstructL()
+    {
+    CAknDialog::ConstructL( R_INFOVIEW_DIALOG_MENU );
+	
+    // Hide tabs
+    CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
+    if ( statusPane && statusPane->PaneCapabilities
+             ( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() )
+        {
+        iNaviPane = (CAknNavigationControlContainer*) statusPane->ControlL
+                    ( TUid::Uid(EEikStatusPaneUidNavi ) );
+        iNaviPane->PushDefaultL();
+        }
+        
+    iAvkonAppUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyLong );
+	
+	// Get the previous title so it can be restored
+	iStatusPaneHandler = CStatusPaneHandler::NewL( iAvkonAppUi );
+	iStatusPaneHandler->StoreOriginalTitleL();
+	
+	iPopupController = CAknInfoPopupNoteController::NewL();
+	
+	iResHandler = CPbkInfoViewResHandler::NewL();
+	
+	iSindHandler = CPbkInfoViewSindHandler::NewL( iContactId );
+    } 
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::~CPbkInfoViewDialog()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewDialog::~CPbkInfoViewDialog()
+    {
+	delete iStatusPaneHandler;
+	iStatusPaneHandler = NULL;
+	delete iPopupController;
+	iPopupController = NULL;
+    delete iResHandler;
+	iResHandler = NULL;
+	delete iSindHandler;
+	iSindHandler = NULL;
+	
+	if ( iAvkonAppUi )
+		{
+		iAvkonAppUi->RemoveFromStack( this  );
+		}
+		
+    // Restore tabs
+    if ( iNaviPane )
+        {
+        iNaviPane->Pop();
+        }
+    
+    iXspIconHelper.Close();
+    }
+
+//------------------------------------------------------------------------------
+// CPbkInfoViewDialog::ExecuteLD
+// Overrides CAknDialog::ExecuteLD. Checks whether the contact has any voice
+// tags. If not an info note is displayed. Otherwise calls CAknDialog::ExecuteLD
+// @param aResourceId The resource ID of the dialog to be loaded
+// @return see CAknDialog::ExecuteLD
+//------------------------------------------------------------------------------
+//
+TInt CPbkInfoViewDialog::ExecuteLD( TInt aResourceId )
+    {
+    // Check whether info view should be shown at all
+    if( iContactId == KVoiceTaglessContactId )
+        {
+        ShowInformationNoteL( R_INFOVIEW_EMPTY_VIEW_SIM_CONTACT );
+        delete this;
+        return 0;
+        }
+    else if( iSindHandler->VoiceTagCount() == 0 )
+        {
+        ShowInformationNoteL( R_INFOVIEW_EMPTY_VIEW );
+        delete this;
+        return 0;
+        }
+    // Show info view
+    else
+        {
+        return CAknDialog::ExecuteLD( aResourceId );
+        }    
+    }
+
+//------------------------------------------------------------------------------
+// CPbkInfoViewDialog::FocusChanged (from CCoeControl)
+//------------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::FocusChanged( TDrawNow aDrawNow )
+    {
+    CAknDialog::FocusChanged(aDrawNow);
+	TRAP_IGNORE( iStatusPaneHandler->SetTitleL(R_INFOVIEW_DIALOG_TITLE) );
+    }
+//------------------------------------------------------------------------------
+// CPbkInfoViewDialog::ActivateL (from CCoeControl)
+// Called by system when dialog is activated.
+//------------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::ActivateL()
+	{
+    CAknDialog::ActivateL();
+
+    // This cannot be in ConstructL which is executed before dialog is launched
+    iAvkonAppUi->AddToStackL( this );
+    }
+
+//------------------------------------------------------------------------------
+// CPbkInfoViewDialog::GetHelpContext
+// Method to get context sensitive help topic.
+// @param aContext Help topic to open.
+//------------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::GetHelpContext( TCoeHelpContext& aContext ) const
+	{
+	aContext.iMajor = TUid::Uid( PBKINFOVIEW_HELP_UID );
+	aContext.iContext = KVCINFO_HLP_MAINVIEW;    
+	}
+
+//------------------------------------------------------------------------------
+// CPbkInfoViewDialog::ProcessCommandL
+// Handles menu events.
+// @param  aCommandId Command id.
+//------------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::ProcessCommandL( TInt aCommandId ) 
+	{
+	HideMenu();
+
+	switch ( aCommandId )
+		{
+        case EInfoViewMenuCmdPlay:
+			{
+			if ( IsCallActive() )
+			    {
+			    CallInProgressNoteL();
+			    }
+			else 
+			    {
+			    iSindHandler->PlayVoiceCommandL( CurrentItemIndex() );
+			    }
+			
+			break;
+			}
+		case EInfoViewMenuCmdHelp:
+			{
+			iAvkonAppUi->ProcessCommandL( EAknCmdHelp );
+			break;
+			}
+        case EInfoViewMenuCmdExit:
+			{
+			iAvkonAppUi->ProcessCommandL( EAknCmdExit );
+			break;
+			}
+        case EAknCmdExit:
+        case EEikCmdExit:
+			{
+            //
+			// Exit dialog
+			//
+			// CEikAppUi::ProcessCommandL starts CAknAppShutter that 
+			// closes all dialogs and finally calling application. Before 
+			// dialog is closed (deleted) it's OkToExitL(EEikBidCancel)
+			// is called. EEikBidCancel means OkToExitL must silently
+			// save and return ETrue.
+			//
+			iAvkonAppUi->ProcessCommandL( EAknCmdExit );
+
+			break;
+			}
+
+		default:
+			{
+			break;
+			}
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewDialog::IsCallActive
+// ----------------------------------------------------------------------------
+//
+TBool CPbkInfoViewDialog::IsCallActive()
+    {
+    TBool callActive( EFalse );
+    TInt state( 0 );
+    TInt err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState,
+                               state );
+                               
+    // note! errors are handled as a call is active    
+    if( err || state == EPSCTsyCallStateConnected 
+            || state == EPSCTsyCallStateAlerting
+            || state == EPSCTsyCallStateRinging
+            || state == EPSCTsyCallStateDialling
+            || state == EPSCTsyCallStateAnswering ) 
+        {
+        callActive = ETrue;
+        }
+    else
+        {
+        TInt callType( 0 );
+        TInt err =  RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType,
+                                callType );
+        if ( err || callType == EPSCTsyCallTypeH324Multimedia ) 
+            {
+            callActive = ETrue;
+            }
+        }    
+    
+    return callActive;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewDialog::CallInProgressNoteL
+// ----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::CallInProgressNoteL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_TEXT_CALL_IN_PROGRESS );
+    CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
+    note->ExecuteLD( *text );
+    CleanupStack::PopAndDestroy( text );
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::OkToExitL
+// Called by framework before exiting the dialog.
+// @param aButtonId Button id.
+// @return ETrue to exit\ EFalse to not to exit.
+// -----------------------------------------------------------------------------
+//
+TBool CPbkInfoViewDialog::OkToExitL( TInt aButtonId )
+    {
+    if( iSindHandler->IsPlaying() )
+	    {
+		iSindHandler->CancelPlaybackL();
+		}
+    
+    switch ( aButtonId )
+        {
+        case EAknSoftkeyBack:
+            {
+            return ETrue;
+            }
+            
+        case EAknSoftkeyClose:
+        case EAknSoftkeyExit:
+            {
+            iAvkonAppUi->ProcessCommandL( EAknCmdExit );
+            return ETrue;
+            }
+            
+        case EAknSoftkeySelect: // Middle soft key, no exit
+            {
+            if ( IsCallActive() )
+			    {
+			    CallInProgressNoteL();
+			    }
+			else 
+			    {
+			    iSindHandler->PlayVoiceCommandL( CurrentItemIndex() );
+			    }
+            
+            return EFalse;
+            }
+            
+         default:
+            {
+            return CAknDialog::OkToExitL( aButtonId );
+            }   
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewDialog::OfferKeyEventL
+// Called by framework for key event handling.
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CPbkInfoViewDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                                 TEventCode aType )
+	{
+	if ( aType == EEventKey )
+		{
+		switch ( aKeyEvent.iCode )
+			{
+			case EKeyEscape:  // Framework calls this when dialog must shut
+				{
+				return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
+        		}
+        		
+            case EKeyUpArrow:
+            case EKeyDownArrow:
+                {
+                CAknDialog::OfferKeyEventL( aKeyEvent, aType );
+                if( iSindHandler->VoiceTagCount() > 0 )
+                    {
+                    ShowPopupL();
+                    }
+                return EKeyWasConsumed;
+                }
+			
+            default:
+			    break;
+			}
+		}
+		
+	return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
+	}
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewDialog::HandleResourceChange
+// Called when display resolution changes.
+// ----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::HandleResourceChange( TInt aType )
+    {
+    // Handle change in layout orientation
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+                                           mainPaneRect );
+        SetRect( mainPaneRect );
+        //iListBox->SetSize( mainPaneRect.Size() );
+        iListBox->SetSize( mainPaneRect.Size() );
+        CCoeControl::HandleResourceChange( aType );
+		DrawDeferred();
+		}
+	else
+	    {
+	    CCoeControl::HandleResourceChange( aType );
+	    }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewDialog::PostLayoutDynInitL
+// Called by framework after dialog is shown.
+// ----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::PostLayoutDynInitL()
+	{
+	}
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewDialog::PreLayoutDynInitL
+// Called by framework before dialog is shown.
+// ----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::PreLayoutDynInitL()
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::PreLayoutDynInitL" );
+    
+    iListBox = ( CAknDoubleGraphicStyleListBox* ) ControlOrNull ( EInfoViewDialogList );
+    
+   	__ASSERT_ALWAYS( iListBox, TPbkInfoViewUtil::Panic( KErrGeneral ) );
+	
+	iListBox->SetListBoxObserver( this );
+	iListBox->CreateScrollBarFrameL( ETrue );
+	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
+	                                                      CEikScrollBarFrame::EAuto );                                 
+    iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
+	
+	TDesC* des;
+	// Set empty list text
+	if( iVoiceTaglessContact )
+	    {
+    	des = StringLoader::LoadLC( R_INFOVIEW_EMPTY_VIEW_SIM_CONTACT );
+    	iListBox->View()->SetListEmptyTextL( *des );
+	    }
+	else
+	    {
+    	des = StringLoader::LoadLC( R_INFOVIEW_EMPTY_VIEW );
+    	iListBox->View()->SetListEmptyTextL( *des );
+	    }
+	CleanupStack::PopAndDestroy( des );
+    
+    // Set icons
+
+	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray( KDefaultArraySize );
+	CleanupStack::PushL( icons );
+	
+	CreateFieldIconsL( icons );
+    
+    CleanupStack::Pop( icons );
+
+	CreateListBoxItemsL();
+	
+	iListBox->UpdateScrollBarsL();
+	iListBox->ScrollBarFrame()->MoveVertThumbTo( 0 );
+
+	iStatusPaneHandler->SetTitleL( R_INFOVIEW_DIALOG_TITLE );
+	
+	UpdateCbaL( R_SOFTKEYS_OPTIONS_BACK__PLAY );
+	}
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::DynInitMenuPaneL
+// Called by framework before menu is shown.
+// @param aResourceId Menu resource id.
+// @param aMenuPane Pointer to the menu.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::DynInitMenuPaneL( TInt aResourceID,
+                                           CEikMenuPane* aMenuPane )
+	{
+	if ( aResourceID == R_INFOVIEW_DIALOG_MENU_PANE )
+	    {
+	    // No play function in menu if there are no voice tags
+	    if( iSindHandler->VoiceTagCount() == 0 )
+            {
+    	    aMenuPane->SetItemDimmed( EInfoViewMenuCmdPlay, ETrue );
+            }
+	    }
+	}
+	
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::IconIndex
+// Returns TInfoViewDialogIconIndex enumeration icon index.
+// @param aIconId enumeration TPbkIconId from PbkIconId.hrh.
+// @return TInt Icon index.
+// -----------------------------------------------------------------------------
+//
+TInt CPbkInfoViewDialog::IconIndex( TInt aIconId, TInt aTagIndex )
+	{
+	TInt iconIndex;
+	
+	switch ( aIconId )
+		{
+		case EPbkqgn_prop_nrtyp_mobile:
+		    iconIndex = EIconIndexMobile;
+		    break;
+		case EPbkqgn_prop_nrtyp_phone:
+		    iconIndex = EIconIndexPhone;
+		    break;
+		case EPbkqgn_prop_nrtyp_video:
+		    iconIndex = EIconIndexVideo;
+		    break;
+		case EPbkqgn_prop_nrtyp_email:
+		    iconIndex = EIconIndexEmail;
+		    break;
+		case EPbkqgn_prop_nrtyp_voip:
+		    iconIndex = EIconIndexVoip;
+			if ( iSindHandler->FieldIdL( aTagIndex ) == EPbkFieldIdXsp )
+				{
+				for ( TInt i=0; i<iXspIconHelper.Count();i++)
+				    {
+                    if ( !iXspIconHelper[i].LableText().Compare(iSindHandler->LabelL(aTagIndex)) )
+                        {
+                        iconIndex = iXspIconHelper[i].Index();
+                        }
+				    }                
+				}
+		    break;
+		default:
+		    iconIndex = EIconIndexPhone;    
+		    break;
+		}
+		
+    return iconIndex; 
+	}
+		
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::CreateListBoxItemsL
+// Creates listbox items.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::CreateListBoxItemsL()
+	{
+	RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::CreateListBoxItemsL" );
+	
+	CAknDoubleGraphicStyleListBox* listBox = iListBox;
+	CDesCArray* items = (CDesCArray*) listBox->Model()->ItemTextArray();
+	items->Reset();
+    listBox->ItemDrawer()->ClearAllPropertiesL();
+	
+	TInt count = iSindHandler->VoiceTagCount();
+	
+	// Create dialog entries
+	for ( TInt i = 0; i < count; i++ )
+		{
+		// Line header
+		HBufC* firstLine = iSindHandler->VoiceTagLabelLC( i );
+		// Phone number, email address, etc...
+		HBufC* secondLine = iSindHandler->VoiceTagValueL( i ).AllocLC();
+
+		TInt iconIndex = IconIndex( iSindHandler->IconIdL( i ), i );
+
+		TPtr ptr1 = firstLine->Des();
+		AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr1 );
+		TPtr ptr2 = secondLine->Des();
+		AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr2 );
+
+		HBufC* listBoxItem = NULL;
+		listBoxItem = TDialogUtil::ConstructListBoxItemLC( firstLine->Des(), 
+		                                                   secondLine->Des(),
+                                                           iconIndex );         
+
+		items->AppendL( listBoxItem->Des() );
+		
+		CleanupStack::PopAndDestroy( listBoxItem );
+		CleanupStack::PopAndDestroy( secondLine );
+		CleanupStack::PopAndDestroy( firstLine );
+		}
+
+	listBox->HandleItemAdditionL();
+
+    TInt current = CurrentItemIndex();
+    if (current == KErrNotFound)
+        {
+		current = 0;
+        }
+		
+	iListBox->SetCurrentItemIndexAndDraw( current );
+	}
+	
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::HandleListBoxEventL (from MEikListBoxObserver)
+// From MEikListBoxObserver, called by framework.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/,
+                                              TListBoxEvent aEventType )
+    {
+    switch ( aEventType )
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemSingleClicked:
+            {            
+            if ( iSindHandler->VoiceTagCount() > 0 )
+                {
+                ShowPopupL();
+                
+                if ( IsCallActive() )
+                    {
+                    CallInProgressNoteL();
+                    }
+                else 
+                    {
+                    iSindHandler->PlayVoiceCommandL( CurrentItemIndex() );
+                    }
+              
+                }
+            break;
+            }
+          
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::CurrentItemIndex
+// Gets current listbox item.
+// -----------------------------------------------------------------------------
+//
+TInt CPbkInfoViewDialog::CurrentItemIndex()
+	{
+	TInt ret;
+	
+	if ( iListBox->Model()->NumberOfItems() == 0 )
+		{
+		ret = KErrNotFound;
+		}
+    else
+        {
+        ret = iListBox->CurrentItemIndex();
+        }
+	
+	return ret;
+	}
+	
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::UpdateCbaL
+// Updates dialog cba.
+// @param aResourceId Resource id.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::UpdateCbaL( TInt aResourceId )
+    {
+    CEikButtonGroupContainer& cba = ButtonGroupContainer();
+    cba.SetCommandSetL( aResourceId );
+    cba.DrawDeferred();
+    }
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::ShowPopupL
+// Shows popup for a voice command in the list.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::ShowPopupL()
+    {
+    iPopupController->SetTextL( iSindHandler->PopupTextL( CurrentItemIndex() ) );
+    iPopupController->ShowInfoPopupNote();
+    }
+    
+// -----------------------------------------------------------------------------
+// CPbkInfoViewDialog::ShowInformationNoteL
+//
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewDialog::ShowInformationNoteL( TInt aResourceId )
+	{
+	TDesC* noteText = StringLoader::LoadLC( aResourceId );
+    	
+    CAknInformationNote* dialog = 
+        new(ELeave)CAknInformationNote( R_AKN_INFORMATION_NOTE );
+    dialog->ExecuteLD( *noteText );
+    
+    CleanupStack::PopAndDestroy( noteText );
+	}
+
+void CPbkInfoViewDialog::CreateFieldIconsL(CArrayPtr<CGulIcon>* aIconArray)
+	{
+    CPbk2StoreConfiguration* configuration = CPbk2StoreConfiguration::NewL();
+    CleanupStack::PushL(configuration);
+	    
+    CVPbkContactStoreUriArray* uriArray = configuration->CurrentConfigurationL();
+    CleanupStack::PushL( uriArray ); 
+    if ( uriArray->IsIncluded(VPbkContactStoreUris::DefaultCntDbUri()) == EFalse )
+        {
+        uriArray->AppendL( VPbkContactStoreUris::DefaultCntDbUri() );	
+	    }    
+    
+    CVPbkContactManager* contactManager = CVPbkContactManager::NewL(*uriArray);
+    CleanupStack::PushL( contactManager );
+	    
+    TInt arraySize = sizeof KFieldIds / sizeof KFieldIds[0];
+    TInt count =0;
+    const MVPbkFieldType* fieldType = NULL;
+    CGulIcon* icon = NULL;
+			
+    CVPbkFieldTypeRefsList* fieldTypeList = CVPbkFieldTypeRefsList::NewL();
+    CleanupStack::PushL( fieldTypeList );
+    
+    for( count = 0; count < arraySize;  ++count )
+        {
+        fieldType = contactManager->FieldTypes().Find( KFieldIds[count] );
+        fieldTypeList->AppendL(*fieldType);	
+        }
+			
+    MPbk2FieldPropertyArray* propertyArray = Pbk2FieldPropertiesFactory::CreateLC(*fieldTypeList,
+                                                 &contactManager->FsSession() );
+    
+    CPbk2IconFactory* pbk2IconFactory = CPbk2IconFactory::NewL();
+    CleanupStack::PushL( pbk2IconFactory );
+    
+    for( count = 0; count < propertyArray->Count(); ++ count)
+        {
+        icon = pbk2IconFactory->CreateIconL( propertyArray->At(count).IconId());
+        // Append xSP icon info to helper array
+        if ( propertyArray->At(count).FieldType().FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP 
+                && icon && icon->Bitmap()->Handle() )
+            {
+            const MPbk2FieldProperty& property = propertyArray->At(count);
+            MPbk2FieldProperty2* property2 = reinterpret_cast<MPbk2FieldProperty2*>
+                ( const_cast<MPbk2FieldProperty&> (property).FieldPropertyExtension(
+                        KMPbk2FieldPropertyExtension2Uid ) );      
+            TXspIconHelper xsp( count, property2->XSpName() );
+            iXspIconHelper.Append( xsp );
+            }
+        aIconArray->AppendL(icon);
+        }
+
+	iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( aIconArray );
+	
+    //Destroy: configuration,uriArray,contactManager
+    //fieldTypeList,propertyArray,pbk2IconFactory
+    CleanupStack::PopAndDestroy( 6,configuration );
+	}
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewdialogutil.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,295 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility class for info view dialog.
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "pbkinfoviewdialogutil.h"
+#include "pbkinfoviewutil.h"
+#include "pbkinfoviewdefines.h"
+
+#include <akntitle.h>           // CAknTitlePane
+#include <akncontext.h>         // CAknTitlePane
+#include <aknnotewrappers.h>    // CAknInformationNote
+#include <eikmenup.h>           // CEikMenuPane
+#include <aknlists.h>           // CAknSingleHeadingPopupMenuStyleListBox
+
+#include <StringLoader.h>
+
+#include "rubydebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+/*******************************************************************************
+ * class TDialogUtil
+ *******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// TDialogUtil::ConstructListBoxItemL
+// @param aID Item ID of the masked bitmap to be created.
+// @param aFilename Filename to be used to construct the item, 
+// @param aFileBitmapId Id (for bitmap) in the file. 
+// @param aFileMaskId Id (for mask) in the file.
+// @return CGulIcon* Pointer to the newly created CGulIcon object.
+//         Ownership of the object is transferred to the caller.
+// -----------------------------------------------------------------------------
+//
+HBufC* TDialogUtil::ConstructListBoxItemLC( const TDesC& aFirstLine,
+                                            const TDesC& aSecondLine,
+                                            TInt aIndex1 )
+	{
+	_LIT( KFormat, "%d\t%S\t%S" );
+	
+	TInt len = aFirstLine.Length() + aSecondLine.Length() + KBufSize16;
+	
+	HBufC* hBuf = HBufC::NewLC( len );
+	TPtr ptr = hBuf->Des();
+	
+	ptr.Format( KFormat , aIndex1, &aFirstLine, &aSecondLine );
+	
+	return hBuf;
+	}
+	
+// -----------------------------------------------------------------------------
+// TDialogUtil::CreateIconL
+//
+// Constructs an independent CGulIcon object with fallback support.
+// If no matching item (aId) is found in the currently active skin,
+// attempts to construct the item using the given file (last 3 parameters).
+// @param aID Item ID of the masked bitmap to be created.
+// @param aFilename Filename to be used to construct the item, 
+// @param aFileBitmapId Id (for bitmap) in the file. 
+// @param aFileMaskId Id (for mask) in the file.
+// @return CGulIcon* Pointer to the newly created CGulIcon object.
+//         Ownership of the object is transferred to the caller.
+// -----------------------------------------------------------------------------
+//
+CGulIcon* TDialogUtil::CreateIconL( TAknsItemID aId, const TDesC& aFileName, TInt aFileBitmapId, TInt aFileMaskId )
+	{
+    CGulIcon* icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), aId, aFileName, aFileBitmapId, aFileMaskId);
+	return icon;
+	}
+
+/*******************************************************************************
+ * class CStatusPaneHandler
+ *******************************************************************************/
+
+// -----------------------------------------------------------------------------
+// CStatusPaneHandler::NewLC
+//
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CStatusPaneHandler* CStatusPaneHandler::NewL(CAknAppUi* aAppUi)
+    {
+    CStatusPaneHandler* self = new (ELeave) CStatusPaneHandler(aAppUi);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+//
+// -----------------------------------------------------------------------------
+//
+CStatusPaneHandler::~CStatusPaneHandler()
+    {
+    TInt error( KErrNone );
+    
+	TRAP( error, RestorePreviousTitleL() );
+	if ( error != KErrNone )
+		{
+		RUBY_DEBUG1( "RestoreOriginalTitleL() error: %d", error );
+		}
+	
+	TRAP( error, RestoreOriginalImageL() );
+	if ( error != KErrNone )
+		{
+		RUBY_DEBUG1( "RestoreOriginalImageL() error: %d", error );
+		}	
+    }
+
+// -----------------------------------------------------------------------------
+// CStatusPaneHandler::ConstructL
+//
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::ConstructL(void)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CStatusPaneHandler::CStatusPaneHandler
+//
+// -----------------------------------------------------------------------------
+//
+CStatusPaneHandler::CStatusPaneHandler( CAknAppUi* aAppUi ) : iAppUi( aAppUi )
+	{
+	__ASSERT_ALWAYS( iAppUi, TPbkInfoViewUtil::Panic( KErrGeneral ) );
+
+	iOriginalTitleStored = EFalse;
+	iOriginalTitle = KNullDesC;
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::GetPreviousTitleL
+// Gets the title from previous view.
+// @param aAppUi Pointer to UI class.
+// @param aText Title will be put to this variable.
+// @return TBool ETrue: success / EFalse: failure.
+// ----------------------------------------------------------------------------
+//
+TBool CStatusPaneHandler::GetPreviousTitleL( CAknAppUi* aAppUi, TDes& aTitle )
+	{
+	aTitle = KNullDesC;
+
+	CEikStatusPane* statusPane = aAppUi->StatusPane();
+    if ( statusPane && 
+         statusPane->PaneCapabilities
+             ( TUid::Uid( EEikStatusPaneUidTitle) ).IsPresent() )
+		{
+        CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
+            (statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+        if ( titlePane->Text() ) 
+			{
+		    TPbkInfoViewUtil::StrCopy( aTitle, *titlePane->Text() );
+			return ETrue;
+    		}
+		}
+	return EFalse;
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetTitleL
+// Sets the dialog title.
+// @param aAppUi Pointer to the UI class.
+// @param aText Title text.
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetTitleL( CAknAppUi* aAppUi, const TDesC& aTitle )
+	{
+	CEikStatusPane* statusPane = aAppUi->StatusPane();
+    if ( statusPane && 
+         statusPane->PaneCapabilities
+             (TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
+		{
+        CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
+            (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
+        if ( titlePane->Text() ) 
+			{
+	   		titlePane->SetTextL(aTitle);
+			}
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::StoreOriginalTitleL
+// Sets the member variable for previous title.
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::StoreOriginalTitleL()
+	{
+	TBool ret = GetPreviousTitleL( iAppUi, iOriginalTitle );
+	
+	if ( ret )
+		{
+		iOriginalTitleStored = ETrue;
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::RestorePreviousTitleL
+// Restores previous title when returning to previous view.
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::RestorePreviousTitleL()
+	{
+	if ( iOriginalTitleStored )
+		{
+		SetTitleL( iAppUi, iOriginalTitle );
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetTitleL
+// Sets the dialog title.
+// @param aResourceId Resource id from resource file.
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::SetTitleL( TInt aResourceId )
+	{
+	// Get title from resource file
+	HBufC* dialogTitle = StringLoader::LoadLC( aResourceId );
+			
+	SetTitleL( iAppUi, dialogTitle->Des() );
+	CleanupStack::PopAndDestroy( dialogTitle );
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::RestoreOriginalImageL
+// Restores previous image when returning to previous view.
+// ----------------------------------------------------------------------------
+//
+void CStatusPaneHandler::RestoreOriginalImageL()
+	{
+	if (!iOriginalImage)
+		{
+		return; // image has not been replaced
+		}
+
+	CEikImage* image = NULL;
+	TRAPD(err, image = SetImageL( iAppUi, iOriginalImage ) );
+
+	if (err == KErrNone && image)
+		{
+		delete image; // delete our own image
+		}
+	else
+		{
+		delete iOriginalImage; // delete original image (could not restore it)
+		iOriginalImage = NULL;
+		}
+	}
+
+// ----------------------------------------------------------------------------
+// CStatusPaneHandler::SetImageL
+// Sets dialog image.
+// ----------------------------------------------------------------------------
+//
+CEikImage* CStatusPaneHandler::SetImageL( CAknAppUi* aAppUi, CEikImage* aIcon )
+	{
+	CEikStatusPane* statusPane = aAppUi->StatusPane();
+    if ( statusPane && statusPane->PaneCapabilities
+         (TUid::Uid(EEikStatusPaneUidContext)).IsPresent() )
+		{
+        CAknContextPane* contextPane = static_cast<CAknContextPane*>
+            ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) );
+        if ( contextPane ) 
+			{
+	   		return contextPane->SwapPicture( aIcon );
+			}
+		}
+
+	return NULL;
+	}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewreshandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is used for reading pbkinfoview resources.
+*
+*/
+
+
+// INCLUDES
+#include "pbkinfoviewreshandler.h"
+#include "pbkinfoviewutil.h"
+
+#include <data_caging_path_literals.hrh> // For resource and bitmap directories
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewResHandler::NewL
+//
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewResHandler* CPbkInfoViewResHandler::NewL()
+    {
+    CPbkInfoViewResHandler* self = new (ELeave) CPbkInfoViewResHandler();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CPbkInfoViewResHandler::CPbkInfoViewResHandler
+//
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewResHandler::CPbkInfoViewResHandler()
+	{
+	// Nothing
+	}
+
+// -----------------------------------------------------------------------------
+// CPbkInfoViewResHandler::~CPbkInfoViewResHandler()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CPbkInfoViewResHandler::~CPbkInfoViewResHandler()
+    {
+	if ( iResId )
+		{
+        CEikonEnv::Static()->DeleteResourceFile( iResId );
+		}
+    }
+ 
+// -----------------------------------------------------------------------------
+// CPbkInfoViewResHandler::ConstructL
+//
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewResHandler::ConstructL( void )
+    {
+	// Add resource file
+	TFileName buf;
+	GetResFileName( buf );
+	iResId = TPbkInfoViewUtil::AddResFileL( buf );
+    }
+    
+// -----------------------------------------------------------------------------
+// CPbkInfoViewResHandler::GetResFileName
+// Finds out the pbkinfoview resource file name.
+// @param aText File name will be put here.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewResHandler::GetResFileName( TDes& aText )
+	{
+	TParse parse;
+	parse.Set( KResFileName, &KDC_RESOURCE_FILES_DIR, NULL );
+	TPbkInfoViewUtil::StrCopy( aText, parse.FullName() );
+	}
+
+// -----------------------------------------------------------------------------
+// CAspResHandler::GetBitmapFileName
+// Finds out the phonebook bitmap file name.
+// @param aText File name will be put here.
+// -----------------------------------------------------------------------------
+//
+void CPbkInfoViewResHandler::GetBitmapFileName(TDes& aText)
+	{
+	TParse parse;
+	parse.Set( KBitmapFileName, &KDC_APP_BITMAP_DIR, NULL );
+	TPbkInfoViewUtil::StrCopy( aText, parse.FullName() );
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewsindhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,922 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation for CPbkInfoViewSindHandler
+*
+*/
+
+
+// INCLUDE FILES
+#include "pbkinfoviewsindhandler.h"
+#include "pbkinfoviewreshandler.h"
+#include "pbkinfoviewdefines.h"
+#include <pbkinfoview.rsg>
+
+#include <vuivoicerecogdefs.h>  // KVoiceDialContext
+#include <nssvascoreconstant.h>
+#include <vascvpbkhandler.h>
+#include <CPbkContactEngine.h>
+#include <CPbkContactItem.h>
+#include <CPbkFieldInfo.h>
+#include <StringLoader.h>
+#include <nssvascoreconstant.h>
+
+#include "rubydebug.h"
+
+// ----------------------------------------------------------------------------
+// RemapCommand
+// Remap command to the correct order.
+// @param aCommandId 
+// ----------------------------------------------------------------------------
+static TInt RemapCommand( TInt aCommandId )
+    {
+    switch (aCommandId)
+        {
+        case EEmailCommand:
+            return EMessageCommand;
+        case EVoipCommand:
+            return EEmailCommand;
+        case EMessageCommand:
+            return EVoipCommand;
+        default:
+            return aCommandId;
+        }
+    }
+// ================= MEMBER FUNCTIONS =======================
+
+inline CPbkInfoViewSindHandler::CPbkInfoViewSindHandler()
+    {
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::ConstructL
+// Creates a new instance of CPbkSindHandler.
+// @param aContactId Contact id for the contact whose voice tags are to
+//        be fetched from vas db.
+// ----------------------------------------------------------------------------
+inline void CPbkInfoViewSindHandler::ConstructL( TInt aContactId )
+    {   
+    InitializeL( aContactId );
+    
+    CreateVoiceTagListL( aContactId );
+    
+    CreatePopupArrayL();
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::TestConstructL
+// Creates an instance that doesn't require CCoeEnv for STIF testing purposes.
+// @param aContactId Contact id for the contact whose voice tags are to
+//        be fetched from vas db.
+// ----------------------------------------------------------------------------
+inline void CPbkInfoViewSindHandler::TestConstructL( TInt aContactId )
+    {
+    InitializeL( aContactId );
+    
+    CreateVoiceTagListL( aContactId );
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::InitializeL
+// Initialization.
+// @param aContactId Contact id for the contact whose voice tags are
+//        fetched from vas db.
+// @return TInt KErrNone on success
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::InitializeL( TInt aContactId )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::InitializeL" );
+    
+    // create Vas db manager
+    iVasDbManager = CNssVASDBMgr::NewL();
+
+    iVasDbManager->InitializeL();
+    
+    // Ownership not transferred
+    iContextManager = iVasDbManager->GetContextMgr();
+    // Ownership not transferred
+    iTagManager = iVasDbManager->GetTagMgr();
+    
+    iWait = new (ELeave) CActiveSchedulerWait();
+    
+    // Create and initialize phonebook handler that is used to get the
+    // phone numbers etc used in voice tags.
+    iPbkHandler = CVasVPbkHandler::NewL();
+    iPbkHandler->InitializeL();
+
+    iPbkEngine = CPbkContactEngine::NewL();
+    
+    if( aContactId == KVoiceTaglessContactId )
+        {
+        iPbkContactItem = iPbkEngine->CreateEmptyContactL();
+        }
+    else
+        {
+        iPbkHandler->FindContactL( aContactId, ETrue );
+        iPbkContactItem = iPbkEngine->ReadContactL( aContactId );    
+        }
+    
+    iTts = CTtsUtility::NewL( *this );
+    
+    // Put to thread local storage so that CompareL can use this pointer
+    Dll::SetTls( iPbkContactItem );
+    
+    iPlaybackIndex = -1;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::NewL
+//
+// ----------------------------------------------------------------------------
+CPbkInfoViewSindHandler* CPbkInfoViewSindHandler::NewL( TInt aContactId )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::NewL" );
+    
+    CPbkInfoViewSindHandler* self = new (ELeave) CPbkInfoViewSindHandler;
+    CleanupStack::PushL( self );
+    self->ConstructL( aContactId );
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::TestNewL
+//
+// ----------------------------------------------------------------------------
+CPbkInfoViewSindHandler* CPbkInfoViewSindHandler::TestNewL( TInt aContactId )
+    {
+    CPbkInfoViewSindHandler* self = new (ELeave) CPbkInfoViewSindHandler;
+    CleanupStack::PushL( self );
+    self->TestConstructL( aContactId );
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::~CPbkInfoViewSindHandler
+//
+// ----------------------------------------------------------------------------
+CPbkInfoViewSindHandler::~CPbkInfoViewSindHandler()
+    {
+    delete iVasDbManager;
+    iVasDbManager = NULL;
+    
+    delete iContext;
+    iContext = NULL;
+    
+    delete iWait;
+    iWait = NULL;
+    
+    iTagArray.ResetAndDestroy();
+    
+    // Free iPbkContactItem from thread local storage
+    Dll::FreeTls();
+    
+    delete iPbkContactItem;
+    iPbkContactItem = NULL;
+    
+    delete iPbkEngine;
+    iPbkEngine = NULL;
+    
+    iPopupArray.ResetAndDestroy();
+    
+    delete iPbkHandler;
+    
+    delete iTts;
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::VoiceTagCount
+// Returns the number of voice tags for the contact.
+// @return TInt voice tag count.
+// ----------------------------------------------------------------------------
+TInt CPbkInfoViewSindHandler::VoiceTagCount()
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::VoiceTagCount" );
+    
+    return iTagArray.Count();
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::VoiceTagL
+// Returns a voice tag.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// @return TDesC& the voice tag
+// ----------------------------------------------------------------------------
+const TDesC& CPbkInfoViewSindHandler::VoiceTagL( TInt aIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::VoiceTagL" );
+    
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+    
+    return iTagArray[aIndex]->SpeechItem()->Text();
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::VoiceTagLabelLC
+// Returns the label associated with a voice tag (mobile, home, etc).
+// @param aIndex index for the voice tag label.
+//        0 <= aIndex <= VoiceTagCount() - 1
+// @return TPtrC the value
+// ----------------------------------------------------------------------------
+HBufC* CPbkInfoViewSindHandler::VoiceTagLabelLC( TInt aIndex )
+    {
+    RUBY_DEBUG0( "CPbkInfoViewSindHandler::VoiceTagLabelLC START" );
+    
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+        
+    TInt contactId = iTagArray[aIndex]->RRD()
+                         ->IntArray()->At( KVasContactIdRrdLocation );
+    TInt fieldId = iTagArray[aIndex]->RRD()
+                       ->IntArray()->At( KVasFieldIdRrdLocation );
+    
+    // RawText is in the format of _1firstName_1lastName_2extension
+    // or _2extension _1firstName_1lastName
+    HBufC* tagLabel = iTagArray[aIndex]->SpeechItem()->RawText().AllocLC();
+    tagLabel->Des().TrimAll();
+    
+    TInt separatorIndex = tagLabel->Des().Find( KTagExtensionSeparator );
+    // Checks whether this a voice tag for nick name (with or without
+    // extensions) or for first-last name combination without extension.
+    // In this case show the whole tag, just remove separators.
+    if( iTagArray[aIndex]->RRD()->IntArray()->At( KVasTagTypeRrdLocation )
+        == ETagTypeNickName || separatorIndex == KErrNotFound ) 
+        {
+        // Remove name separators
+        while( (separatorIndex = tagLabel->Des().Find( KTagNameSeparator ) )
+               != KErrNotFound )
+            {
+            tagLabel->Des().Replace( separatorIndex, KTagSeparatorLength,
+                                     KSpace );
+            }
+        // Remove extension separator
+        separatorIndex = tagLabel->Des().Find( KTagExtensionSeparator );
+        if( separatorIndex != KErrNotFound )
+            {
+            tagLabel->Des().Replace( separatorIndex, KTagSeparatorLength,
+                                     KSpace );
+            }
+            
+        RUBY_DEBUG0( "CPbkInfoViewSindHandler::VoiceTagLabelLC EXIT" );
+        return tagLabel;
+        }
+    
+    TInt nameSeparatorIndex = tagLabel->Des().Find( KTagNameSeparator );
+    CleanupStack::PopAndDestroy( tagLabel );
+    
+    // Show the extension only
+    
+    // RawText is in format _2extension _1firstName_1lastName
+    if( nameSeparatorIndex > separatorIndex )
+        {
+        TInt length( nameSeparatorIndex - separatorIndex - KTagSeparatorLength );
+        tagLabel = iTagArray[aIndex]->SpeechItem()->RawText()
+                   .Mid( separatorIndex + KTagSeparatorLength, length )
+                   .AllocLC();
+        }
+    // _1firstName_1lastName_2extension
+    else
+        {
+        tagLabel = iTagArray[aIndex]->SpeechItem()->RawText()
+                   .Mid( separatorIndex + KTagSeparatorLength ).AllocLC();
+        }
+    
+    RUBY_DEBUG0( "CPbkInfoViewSindHandler::VoiceTagLabelLC EXIT" );
+    
+    return tagLabel;
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::VoiceTagValueL
+// Returns the phone number, e-mail address, etc. associated with a voice tag.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// @return TPtrC the value
+// ----------------------------------------------------------------------------
+TPtrC CPbkInfoViewSindHandler::VoiceTagValueL( TInt aIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::VoiceTagValueL" );
+    
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+       
+    // By using CVasVPbkHandler, info view will show consistent information with
+    // Recognition UI.                    
+    iPbkHandler->FindContactFieldL( iTagArray[aIndex] );
+    return iPbkHandler->TextL();
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::PopupTextL
+// Returns the popup text associated with a voice tag.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// @return TDesC& popup text
+// ----------------------------------------------------------------------------
+TDesC& CPbkInfoViewSindHandler::PopupTextL( TInt aIndex )
+    {
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < iPopupArray.Count(),
+                     User::Leave( KErrArgument ) );
+    
+    return *iPopupArray[aIndex];
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::PlayVoiceCommandL
+// Plays a voice tag.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::PlayVoiceCommandL( TInt aIndex )
+    {
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+    
+    if( IsPlaying() )
+        {
+        CancelPlaybackL();
+        }
+    iTts->Stop();
+    
+    iPlaybackIndex = aIndex;
+    
+    // fetch contact name and contact type (mobile, e-mail etc.)
+    // ignore KErrNotFound leave
+    HBufC* contact = NULL;
+    HBufC* type = NULL;
+    TRAPD( err, contact = iTagArray[aIndex]->SpeechItem()->PartialTextL( KNameTrainingIndex ) );
+    if ( err != KErrNone && err != KErrNotFound) User::Leave( err ); 
+    TRAPD( err2, iTagArray[aIndex]->SpeechItem()->PartialTextL( KExtensionTrainingIndex ) );
+    if ( err2 != KErrNone && err2 != KErrNotFound) User::Leave( err2 );
+
+    // fetch whole tts string 
+    const TDesC& text = iTagArray[aIndex]->SpeechItem()->Text();
+    TInt contactIndex;
+    TInt typeIndex;
+    if ( contact && type )
+        {
+        // get contact and type indexes
+        // assume contactIndex is before typeIndex
+        contactIndex = text.Find( *contact );
+        typeIndex = text.Right( text.Length()-contactIndex-contact->Length() ).Find( *type );
+        if ( typeIndex==KErrNotFound )
+            {
+            // if not, change the order
+            typeIndex = text.Find( *type );
+            contactIndex = text.Right( text.Length()-typeIndex-type->Length() ).Find( *contact );
+            contactIndex = type->Length();
+            }
+        else
+            {
+            typeIndex = contact->Length();
+            }
+        // create segments
+        CTtsParsedText* parsedText = CTtsParsedText::NewL();
+        CleanupStack::PushL( parsedText );
+        
+        TTtsStyle* contactStyle = new (ELeave) TTtsStyle();
+        CleanupStack::PushL( contactStyle );
+        
+        TTtsStyleID* contactStyleId = new (ELeave) TTtsStyleID( 0 );
+        CleanupStack::PushL( contactStyleId );
+        
+        TTtsSegment* contactSegment = new (ELeave) TTtsSegment( 0 );
+        CleanupStack::PushL( contactSegment );
+        
+        contactStyle->iLanguage = User::Language();
+        *contactStyleId = iTts->AddStyleL( *contactStyle );
+        contactSegment->SetStyleID( *contactStyleId );
+        
+        TTtsStyle* typeStyle = new (ELeave) TTtsStyle();
+        CleanupStack::PushL( typeStyle );
+        
+        TTtsStyleID* typeStyleId = new (ELeave) TTtsStyleID( 0 );
+        CleanupStack::PushL( typeStyleId );
+        
+        TTtsSegment* typeSegment = new (ELeave) TTtsSegment( 0 );
+        CleanupStack::PushL( typeSegment );
+        
+        typeStyle->iLanguage = User::Language();
+        *typeStyleId = iTts->AddStyleL( *typeStyle );
+        typeSegment->SetStyleID( *typeStyleId );
+
+        if (contactIndex < typeIndex)
+            {
+            contactSegment->SetTextPtr( text.Mid( contactIndex, contact->Length() ) );
+            typeSegment->SetTextPtr( text.Right( text.Length()-typeIndex ) );
+            parsedText->AddSegmentL( *contactSegment );
+            parsedText->AddSegmentL( *typeSegment );
+            }
+        else
+            {
+            typeSegment->SetTextPtr( text.Mid( typeIndex, type->Length() ) );
+            contactSegment->SetTextPtr( text.Right( text.Length()-contactIndex ) );
+            parsedText->AddSegmentL( *typeSegment );
+            parsedText->AddSegmentL( *contactSegment );
+            }
+        parsedText->SetTextL( text );
+        iTts->OpenAndPlayParsedTextL( *parsedText );
+
+        CleanupStack::PopAndDestroy( typeSegment );
+        CleanupStack::PopAndDestroy( typeStyleId );
+        CleanupStack::PopAndDestroy( typeStyle );
+        CleanupStack::PopAndDestroy( contactSegment );
+        CleanupStack::PopAndDestroy( contactStyleId );
+        CleanupStack::PopAndDestroy( contactStyle );
+        CleanupStack::PopAndDestroy( parsedText );
+        }
+    else
+        {
+        // if there is only one part (contact), play normally
+        iTagArray[aIndex]->SpeechItem()->PlayL( this );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::CancelPlaybackL
+// Cancels voice tag playback.
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::CancelPlaybackL()
+    {
+    if( !( iPlaybackIndex > -1 &&
+        iPlaybackIndex < iTagArray.Count() ) )
+        {
+        return;
+        }
+        
+    iTagArray[iPlaybackIndex]->SpeechItem()->CancelL();
+    
+    iPlaybackIndex = -1;
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::IsPlaying
+// Is voice tag playing ongoing.
+// @return TBool boolean value
+// ----------------------------------------------------------------------------
+TBool CPbkInfoViewSindHandler::IsPlaying()
+    {
+    return iPlaybackIndex > -1;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::IconIdL
+// Returns an icon id for the contact field the voice tag is associated with.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// @return TInt the icon id
+// ----------------------------------------------------------------------------
+TInt CPbkInfoViewSindHandler::IconIdL( TInt aIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::IconIdL" );
+    
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+        
+    TInt contactId = iTagArray[aIndex]->RRD()
+                         ->IntArray()->At( KVasContactIdRrdLocation );
+    TInt fieldId = iTagArray[aIndex]->RRD()
+                       ->IntArray()->At( KVasFieldIdRrdLocation );
+    
+    iPbkContactItemField = iPbkContactItem->FindField( fieldId );
+    if ( !iPbkContactItemField )
+        {
+        iPbkContactItemField = FindDefaultField( iPbkContactItem, fieldId );
+        }
+    
+    if ( !iPbkContactItemField )
+       {
+       User::Leave( KErrNotFound );
+       }
+       
+    return iPbkContactItemField->IconId();
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::FieldIdL
+// Returns an field id for the contact field.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// @return TInt the field id
+// ----------------------------------------------------------------------------
+TInt CPbkInfoViewSindHandler::FieldIdL( TInt aIndex )
+	{    
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::FieldIdL" );
+    
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+        
+    iPbkHandler->FindContactFieldL( iTagArray[aIndex] );
+    
+	return iPbkHandler->FieldIdL();
+	}
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::LabelL
+// Returns label for the contact field.
+// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
+// @return TPtrC the tag label
+// ----------------------------------------------------------------------------
+TPtrC CPbkInfoViewSindHandler::LabelL( TInt aIndex )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::LabelL" );
+    
+    __ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
+                     User::Leave( KErrArgument ) );
+        
+    iPbkHandler->FindContactFieldL( iTagArray[aIndex] );
+    
+    return iPbkHandler->LabelL();
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::CreateVoiceTagListL
+// Fetches voice tag list from vas db.
+// @param aContactId Contact id for the contact whose voice tags are
+//        fetched from vas db.
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::CreateVoiceTagListL( TInt aContactId )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::CreateVoiceTagListL" );
+    
+    // Get context
+    TInt err = iContextManager->GetContext( this, KVoiceDialContext );
+    if ( err == KErrNone )
+        {            
+        if ( iWait && !iWait->IsStarted() )
+            {
+            // Let's synchronize GetContext-method.
+            iWait->Start();
+            if ( !iContext )
+                {
+                // the context getting has failed.
+                // cannot continue
+                User::Leave( KErrGeneral );
+                }
+                
+            }
+        else
+            {
+            User::Leave( KErrGeneral );
+            }
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    iErr = iTagManager->GetTagList( this, iContext, 
+                                    aContactId, KVasContactIdRrdLocation );
+
+    if( !iErr )
+        {
+        // Let's synchronize the GetTagList call
+        if ( iWait && !iWait->IsStarted() )
+            {
+            iWait->Start();
+            RUBY_DEBUG1( "CPbkInfoViewSindHandler::CreateVoiceTagListL - iErr=[%d]", iErr );
+            }
+        else
+            {
+            User::Leave( KErrGeneral );
+            }        
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::CreatePopupArrayL
+// Creates an array for popups in info view list.
+// @param aContactId Contact id for the contact whose voice tags are
+//        fetched from vas db.
+// @return TInt KErrNone on success
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::CreatePopupArrayL()
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::CreatePopupArrayL" );
+    
+    // Create popup text for each voice tag
+    for( TInt i( 0 ); i < iTagArray.Count(); i++ )
+        {
+        HBufC* voiceTag( iTagArray[i]->SpeechItem()->RawText().AllocLC() );
+        
+        HBufC* resourceText;
+        TInt index = voiceTag->Des().Find( KTagExtensionSeparator );
+        // Checks whether this a voice tag without an extension
+        if( index == KErrNotFound )
+            {
+            resourceText = StringLoader::LoadLC( R_INFOVIEW_POPUP_CONTACT );
+            }
+        else
+            {
+            resourceText = StringLoader::LoadLC( R_INFOVIEW_POPUP_GENERAL );
+            }
+            
+        // Remove name separators
+        while( (index = voiceTag->Des().Find( KTagNameSeparator ) )
+               != KErrNotFound )
+            {
+            voiceTag->Des().Replace( index, KTagSeparatorLength,
+                                     KSpace );
+            }
+        // Remove extension separator
+        index = voiceTag->Des().Find( KTagExtensionSeparator );
+        if( index != KErrNotFound )
+            {
+            voiceTag->Des().Replace( index, KTagSeparatorLength,
+                                     KSpace );
+            }
+        voiceTag->Des().TrimAll();
+        
+        TName popupText;
+        // Insert voiceTag to resourceText to create popupText
+        StringLoader::Format( popupText, *resourceText, -1, *voiceTag );
+        
+        iPopupArray.AppendL( popupText.AllocL() );
+        
+        //CleanupStack::Pop( popupText );
+        CleanupStack::PopAndDestroy( resourceText );
+        CleanupStack::PopAndDestroy( voiceTag );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::GetContextCompleted
+// 
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::GetContextCompleted( MNssContext* aContext,
+                                                   TInt aErrorCode )
+    {
+    if( aErrorCode == KErrNone )
+        {
+        // ownership is transferred
+        iContext = aContext;
+
+        // if the iWait has been started, the completion of GetContext method
+        // has been synchronized in VoiceTagField - method. Otherwise
+        // the completion has happened in background.
+        if ( iWait && iWait->IsStarted() )
+            {
+            iWait->AsyncStop();
+            }        
+        }
+    else
+        {
+        iErr = aErrorCode;
+        // if the get context has been synchronized:
+        if ( iWait && iWait->IsStarted() )
+            {
+            iWait->AsyncStop();
+            }        
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::GetContextListCompleted
+// Callback, getting of contexts has completed successfully.
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::GetContextListCompleted(
+    MNssContextListArray* /*aContextList*/, TInt /*aErrorCode*/ )
+    {
+    // never comes here, defined as pure virtual in MNssGetContextClient.
+    }
+
+// ----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::GetTagListCompleted
+// Callback, getting of tags has completed successfully.
+// ----------------------------------------------------------------------------
+void CPbkInfoViewSindHandler::GetTagListCompleted( MNssTagListArray* aTagList,
+                                                   TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CPbkInfoViewSindHandler::GetTagListCompleted" );
+    
+    if( aErrorCode == KErrNone )
+        {
+        // Fill the tag array
+        for( TInt i( 0 ); i < aTagList->Count(); i++ )
+            {
+            MNssTag* tag = aTagList->At( i );
+    
+            TInt fieldId = tag->RRD()->IntArray()->At( KVasFieldIdRrdLocation );
+            
+            // Get pointer to CPbkContactItem-object from thread local storage
+            CPbkContactItem* pbkContactItem =
+                static_cast<CPbkContactItem*>( Dll::Tls() );
+    
+            TPbkContactItemField* field = pbkContactItem->FindField( fieldId );
+            if ( !field )
+                {
+                field = FindDefaultField( pbkContactItem, fieldId );
+                }
+            
+            // Add only tags that have field in phonebook
+            if ( field )
+                {
+                iTagArray.Append( tag );
+                }
+            else
+                {
+                // If some tag is missing then we don't want to show anything
+                iTagArray.ResetAndDestroy();
+                break;
+                }
+            }
+            
+        aTagList->Reset();
+        delete aTagList;
+            
+        iTagArray.Sort( TLinearOrder<MNssTag>( CPbkInfoViewSindHandler::Compare ) );
+        
+        // Continue with CreateVoiceTagListL-method.
+        if ( iWait && iWait->IsStarted() )
+            {
+            iWait->AsyncStop();
+            }        
+        }
+    
+    else // aErrorCode != KErrNone
+        {
+        iErr = aErrorCode;
+        if ( iWait && iWait->IsStarted() )
+            {
+            iWait->AsyncStop();
+            }        
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CPbkInfoViewSindHandler::HandlePlayComplete
+// Callback, playback has been completed.
+// -----------------------------------------------------------------------------
+//         
+void CPbkInfoViewSindHandler::HandlePlayComplete( TNssPlayResult /*aResult*/ )
+    {
+    iPlaybackIndex = -1;        
+    }
+
+    
+// -----------------------------------------------------------------------------
+// Calls CompareL and catches possible leaves
+// -----------------------------------------------------------------------------
+//     
+TInt CPbkInfoViewSindHandler::Compare( const MNssTag& aTag1, const MNssTag& aTag2 )
+    {
+    TInt result = 0;
+    
+    TRAP_IGNORE( result = CompareL( aTag1, aTag2 ) );
+        
+    return result;
+    }
+    
+// -----------------------------------------------------------------------------
+// Compares two voice tags and decides which one should be displayed first in
+// info view list. Used in the sorting of voice tags.
+// @param aTag1 A voice tag
+// @param aTag2 A voice tag
+// @return TInt -1 if aTag1 should be displayed first, 1 if aTag2 should be 
+//         displayed first, 0 otherwise.
+// -----------------------------------------------------------------------------
+//     
+TInt CPbkInfoViewSindHandler::CompareL( const MNssTag& aTag1, const MNssTag& aTag2 )
+    {
+    RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::GetTagListCompleted" );
+    
+    MNssTag& tag1 = const_cast<MNssTag&>( aTag1 );
+    MNssTag& tag2 = const_cast<MNssTag&>( aTag2 );
+    
+    TInt tagType1 = tag1.RRD()->IntArray()->At( KVasTagTypeRrdLocation );
+    TInt tagType2 = tag2.RRD()->IntArray()->At( KVasTagTypeRrdLocation );
+    
+    // Check if one of the tags is for nickname
+    if( ( tagType1 == ETagTypeName || tagType1 == ETagTypeCompanyName ) &&
+        tagType2 == ETagTypeNickName )
+        {
+        return -1;
+        }
+    if( ( tagType2 == ETagTypeName || tagType2 == ETagTypeCompanyName ) &&
+        tagType1 == ETagTypeNickName )
+        {
+        return 1;
+        }
+        
+    TInt fieldId1 = tag1.RRD()->IntArray()->At( KVasFieldIdRrdLocation );
+    TInt fieldId2 = tag2.RRD()->IntArray()->At( KVasFieldIdRrdLocation );
+    
+    // Get pointer to CPbkContactItem-object from thread local storage
+    CPbkContactItem* pbkContactItem =
+        static_cast<CPbkContactItem*>( Dll::Tls() );
+    
+    TPbkContactItemField* field1 = pbkContactItem->FindField( fieldId1 );
+    if ( !field1 )
+        {
+        field1 = FindDefaultField( pbkContactItem, fieldId1 );
+        }
+    TPbkContactItemField* field2 = pbkContactItem->FindField( fieldId2 );
+    if ( !field2 )
+        {
+        field2 = FindDefaultField( pbkContactItem, fieldId2 );
+        }
+        
+    if ( !field1 || !field2 )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    TBool noExtension1 = EFalse;
+    TBool noExtension2 = EFalse;
+    
+    HBufC* label = tag1.SpeechItem()->RawText().AllocLC();
+    label->Des().TrimAll();
+    
+    TInt index = label->Des().Find( KTagExtensionSeparator );
+    // Checks whether this a voice tag without extension
+    if( index == KErrNotFound )
+        {
+        noExtension1 = ETrue;
+        }
+        
+    CleanupStack::PopAndDestroy( label );
+    
+    label = tag2.SpeechItem()->RawText().AllocLC();
+    label->Des().TrimAll();
+    
+    index = label->Des().Find( KTagExtensionSeparator );
+    // Checks whether this a voice tag without extension
+    if( index == KErrNotFound )
+        {
+        noExtension2 = ETrue;
+        }
+        
+    CleanupStack::PopAndDestroy( label );
+            
+    if( noExtension1 && !noExtension2 )
+        {
+        return -1;
+        }
+    else if ( !noExtension1 && noExtension2 )    
+        {
+        return 1;
+        }
+            
+//    // compare the two neighbors
+//    TInt ret = field1->Compare( *field2 );
+//    
+//    // Sorting for normal call, sms, and multimedia msg fields
+//    if ( ret == 0)
+//        {
+//        TInt actionId1 = tag1.RRD()->IntArray()->At( KVasExtensionRrdLocation );
+//        TInt actionId2 = tag2.RRD()->IntArray()->At( KVasExtensionRrdLocation );
+//        
+//        if ( actionId1 != actionId2 )
+//            {
+//            if ( actionId1 < actionId2 )
+//                {
+//                return -1;
+//                }
+//            return 1;
+//            }
+//        }
+//        
+//    return ret;
+    TInt cmdId1 = tag1.RRD()->IntArray()->At( KVasExtensionCommandRrdLocation );
+    TInt cmdId2 = tag2.RRD()->IntArray()->At( KVasExtensionCommandRrdLocation );
+    return ( RemapCommand( cmdId1 ) - RemapCommand( cmdId2 ));    
+    }
+
+// -----------------------------------------------------------------------------
+// Tries to find a default contact item field
+// @param aContactItem A contact item
+// @param aFieldId A field to search
+// @return TPbkContactItemField* Default field if found, otherwise NULL
+// -----------------------------------------------------------------------------
+//      
+TPbkContactItemField* CPbkInfoViewSindHandler::FindDefaultField
+        ( CPbkContactItem* aContactItem, TInt aFieldId )
+    {
+    TPbkContactItemField* field = NULL;
+    
+    if ( aFieldId == EPbkFieldIdPhoneNumberVideo )
+        {
+        field = aContactItem->DefaultVideoNumberField();
+        }
+    else if ( aFieldId == EPbkFieldIdEmailAddress )
+        {
+        field = aContactItem->DefaultEmailField();
+        }
+    else if ( aFieldId == EPbkFieldIdVOIP )
+        {
+        field = aContactItem->DefaultVoipField();
+        }
+
+    return field;                    
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/pbkinfoviewimpl/src/pbkinfoviewutil.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Utility functions for PbkInfoView.
+*
+*/
+
+
+// INCLUDES
+#include <eikenv.h>
+#include <bautils.h>
+#include <avkon.rsg>
+
+#include "pbkinfoviewutil.h"
+
+// -------------------------------------------------------------------------------
+// TPbkInfoViewUtil::Panic
+//
+// -------------------------------------------------------------------------------
+//
+void TPbkInfoViewUtil::Panic( TInt aReason )
+    {
+	_LIT( KPanicCategory,"Info view" );
+
+	User::Panic( KPanicCategory, aReason ); 
+    }
+
+// -------------------------------------------------------------------------------
+// TPbkInfoViewUtil::StrCopy
+//
+// String copy with length check.
+// @param TDes8& aTarget Copied text will be put to this variable.
+// @param TDesC& aSource Includes the text to be copied.
+// -------------------------------------------------------------------------------
+//
+void TPbkInfoViewUtil::StrCopy( TDes8& aTarget, const TDesC& aSource )
+    {
+	TInt len = aTarget.MaxLength();
+    if( len < aSource.Length() ) 
+	    {
+		aTarget.Copy( aSource.Left( len ) );
+		return;
+	    }
+	aTarget.Copy( aSource );
+    }
+
+// -------------------------------------------------------------------------------
+// TPbkInfoViewUtil::StrCopy
+//
+// String copy with length check.
+// @param TDes& aTarget Copied text will be put to this variable.
+// @param TDesC8& aSource Includes the text to be copied.
+// -------------------------------------------------------------------------------
+//
+void TPbkInfoViewUtil::StrCopy( TDes& aTarget, const TDesC8& aSource )
+    {
+	TInt len = aTarget.MaxLength();
+    if( len < aSource.Length() ) 
+	    {
+		aTarget.Copy( aSource.Left( len ) );
+		return;
+	    }
+	aTarget.Copy( aSource );
+    }
+
+// -------------------------------------------------------------------------------
+// TPbkInfoViewUtil::StrCopy
+//
+// String copy with length check.
+// @param TDes& aTarget Copied text will be put to this variable.
+// @param TDesC& aSource Includes the text to be copied.
+// -------------------------------------------------------------------------------
+//
+void TPbkInfoViewUtil::StrCopy( TDes& aTarget, const TDesC& aSource )
+    {
+	TInt len = aTarget.MaxLength();
+    if( len < aSource.Length() ) 
+	    {
+		aTarget.Copy( aSource.Left(len) );
+		return;
+	    }
+	aTarget.Copy( aSource );
+    }
+
+// -----------------------------------------------------------------------------
+// TPbkInfoViewUtil::AddResFileL
+// Adds resource file to control environment.
+// @param aFile File location.
+// @return TInt Error code.
+// -----------------------------------------------------------------------------
+//
+TInt TPbkInfoViewUtil::AddResFileL( const TDesC& aFile )
+	{
+	CEikonEnv* env = CEikonEnv::Static();
+
+	TFileName fileName( aFile );
+
+	BaflUtils::NearestLanguageFile( env->FsSession(), fileName );
+
+    return env->AddResourceFileL( fileName );
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rom/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,5 @@
+// exports.inc
+vcommand.iby              CORE_APP_LAYER_IBY_EXPORT_PATH(vcommand.iby)
+voiceui.iby               CORE_APP_LAYER_IBY_EXPORT_PATH(voiceui.iby)
+vcommandresources.iby     LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(vcommandresources.iby)
+voiceuiresources.iby      LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(voiceuiresources.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rom/vcommand.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for VCommand UI
+*
+*/
+
+
+#ifndef __VCOMMAND_IBY__
+#define __VCOMMAND_IBY__
+
+#ifdef __SIND
+
+// VCommand app
+S60_APP_EXE(vcommand)
+S60_APP_AIF_ICONS(vcommand)
+S60_APP_AIF_RSC(vcommand)
+
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,vcommand)
+
+
+// VcControlPanelPlugin
+ECOM_PLUGIN(vccontrolpanelplugin.dll, vccontrolpanelplugin.rsc)
+SCALABLE_IMAGE(BITMAP_DIR,BITMAP_DIR,vccontrolpanelplugin)
+
+data = ZPRIVATE\101F8555\backup_registration.xml	PRIVATE\101F8555\backup_registration.xml
+
+#endif // __SIND
+
+#endif  // __VCOMMAND_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rom/vcommandresources.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for VCommand UI resources
+*
+*/
+
+
+#ifndef __VCOMMAND_RESOURCES_IBY__
+#define __VCOMMAND_RESOURCES_IBY__
+
+#ifdef __SIND
+
+S60_APP_RESOURCE(VCommand)
+S60_APP_CAPTION(VCommand)
+
+// VCommand control panel plugin
+data=DATAZ_\RESOURCE_FILES_DIR\vccontrolpanelpluginrsc.rsc  RESOURCE_FILES_DIR\vccontrolpanelpluginrsc.rsc
+
+
+#endif // __SIND
+
+#endif // __VCOMMAND_RESOURCES_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rom/voiceui.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for VoiceUI
+*
+*/
+
+
+#ifndef VOICEUI_IBY_
+#define VOICEUI_IBY_
+
+#ifdef __SIND
+
+SCALABLE_IMAGE(BITMAP_DIR,BITMAP_DIR,voiceui)
+
+file=ABI_DIR\BUILD_DIR\voiceUiRecognition.dll                               SHARED_LIB_DIR\voiceUiRecognition.dll
+
+// Voiceui app
+S60_APP_EXE(vuivoicerecognition)
+S60_APP_AIF_ICONS(vuivoicerecognition)
+S60_APP_AIF_RSC(vuivoicerecognition)
+
+data=ABI_DIR\BUILD_DIR\z\system\sounds\digital\NameDiallerStartTone.wav     System\sounds\digital\NameDiallerStartTone.wav
+data=ABI_DIR\BUILD_DIR\z\system\sounds\digital\namediallerconfirmtone.wav   System\sounds\digital\namediallerconfirmtone.wav
+data=ABI_DIR\BUILD_DIR\z\system\sounds\digital\btnamediallerstarttone.wav   System\sounds\digital\btnamediallerstarttone.wav
+
+// PbkInfoView
+ECOM_PLUGIN(aiwpbkinfoviewprovider.dll, 10281c81.rsc)
+file=ABI_DIR\BUILD_DIR\pbkinfoview.dll      		SHARED_LIB_DIR\pbkinfoview.dll
+
+#endif // __SIND
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rom/voiceuiresources.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for VoiceUI resources
+*
+*/
+
+
+#ifndef VOICEUI_RESOURCES_IBY_
+#define VOICEUI_RESOURCES_IBY_
+
+#ifdef __SIND
+
+//Resource file(s) for VoiceUI application
+S60_APP_RESOURCE(vuivoicerecognition)
+S60_APP_CAPTION(vuivoicerecognition)
+
+// PbkInfoView
+data=DATAZ_\RESOURCE_FILES_DIR\aiwpbkinfoviewprovider.rsc    RESOURCE_FILES_DIR\aiwpbkinfoviewprovider.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\pbkinfoview.rsc    RESOURCE_FILES_DIR\pbkinfoview.rsc
+
+#endif // __SIND
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rubydebug/rubydebug.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Debugging utilities implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include "RubyDebug.h"
+
+#ifdef __RUBY_DEBUG_TRACES_TO_FILE
+#include <f32file.h>
+#endif
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::PrintToFile
+// Method for writing traces to a file.
+// -----------------------------------------------------------------------------
+//
+#ifdef __RUBY_DEBUG_TRACES_TO_FILE
+
+#ifdef _DEBUG // UDEB version:
+EXPORT_C void RRubyDebug::PrintToFile( TRefByValue<const TDesC> aFmt, ... )
+    {
+    _LIT( KRubyLogFileName, "\\Logs\\RubyTrace.log" );
+
+    const TInt KRubyDebugMaxLineLength = 0x80; // rest will be truncated
+
+    const TInt KRubyDebugOpenFileRetries = 100;
+    const TInt KRubyDebugOpenFileInterval = 1000;
+
+    const TUint16 KRubyDebugLineSep1 = 0x0d;
+    const TUint16 KRubyDebugLineSep2 = 0x0a;
+
+    // Handle variable argument list
+    VA_LIST list;
+	VA_START( list, aFmt );
+	TBuf<KRubyDebugMaxLineLength+2> aBuf;
+    TTruncateOverflow overflow;
+	aBuf.AppendFormatList( aFmt, list, &overflow );
+	if( aBuf.Length() > ( KRubyDebugMaxLineLength - 2 ) )
+		{
+		aBuf.Delete(aBuf.Length() - 2, 2);
+		}
+	
+    // Add linefeed characters
+    aBuf.Append( KRubyDebugLineSep1 );
+    aBuf.Append( KRubyDebugLineSep2 );
+
+    RFs fs;
+    if ( fs.Connect() == KErrNone )
+        {
+        RFile file;
+
+        // Open file in an exclusive mode so that only one thread 
+        // can acess it simultaneously
+        TUint fileMode = EFileWrite | EFileShareExclusive;
+
+        TInt err = file.Open( fs, KRubyLogFileName, fileMode );
+
+        // Create a file if it doesn't exist
+        if ( err == KErrNotFound )
+            {
+            err = file.Create( fs, KRubyLogFileName, fileMode );
+            }
+        else
+            {
+            // Error in opening the file
+            TInt retryCount = KRubyDebugOpenFileRetries;
+            while ( err == KErrInUse && retryCount-- )
+                {
+                // Some other tread is accessing the file, wait a while...
+                User::After( KRubyDebugOpenFileInterval );
+                err = file.Open( fs, KRubyLogFileName, fileMode );
+                }
+            }
+
+        // Check if we have access to a file
+        if ( err == KErrNone )
+            {
+            TInt offset = 0;
+            if ( file.Seek( ESeekEnd, offset ) == KErrNone )
+                {
+                // Append text to the end of file
+                TPtr8 ptr8( (TUint8*)aBuf.Ptr(), aBuf.Size(), aBuf.Size() );
+                file.Write( ptr8 );
+                }
+            file.Close();
+            }
+
+        fs.Close();
+        }
+    }
+
+#else // UREL version:
+EXPORT_C void RRubyDebug::PrintToFile( TRefByValue<const TDesC> /*aFmt*/, ... )
+    {
+    }
+#endif
+
+#endif // __RUBY_DEBUG_TRACES_TO_FILE
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rubydebug/rubydebug.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,271 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface of debugging utilities.
+*      %version: 1.1.3 %
+*
+*/
+
+
+#ifndef RUBYDEBUG_H
+#define RUBYDEBUG_H
+
+#include "rubydebugcfg.h"
+
+//  INCLUDES
+#include <e32svr.h> // For RDebug
+
+#ifndef RUBY_DISABLE_FUNCTION_NAMES
+    // No sense to store function name longer, than can be printed
+    // 0x100 is the internal RDebug limit
+    const TInt __K_RUBY_FUNCTION_NAME_LENGTH = 0x50;    
+
+    // Prepares function name for printing
+    #define __RUBY_PREPARE_FUNCTION_NAME \
+    TBuf<__K_RUBY_FUNCTION_NAME_LENGTH> __ruby_function_name__;\
+    __ruby_function_name__.Copy( TPtrC8( (TText8*)&__PRETTY_FUNCTION__ ).Left( __K_RUBY_FUNCTION_NAME_LENGTH ) ); \
+
+    // Token to paste the function name into
+    #define __K_RUBY_FUNCTION_NAME_TOKEN "%S "
+    
+    // Comma and function name
+    #define __RUBY_FUNCTION_NAME __ruby_function_name__
+    
+    // A wrapper that prepares and supplies the function name as __ruby_function_name__
+    #define __RUBY_FUNCTION_NAMED( text ) \
+	    {\
+	    __RUBY_PREPARE_FUNCTION_NAME;\
+	    text;\
+	    }
+	    
+	#define __RUBY_FUNCTION_NAME_POINTER8 (TText8*)&__PRETTY_FUNCTION__
+    
+
+#else  // RUBY_DISABLE_FUNCTION_NAMES
+
+    #define __RUBY_PREPARE_FUNCTION_NAME
+    
+    // Don't print the function name
+    #define __K_RUBY_FUNCTION_NAME_TOKEN ""
+    
+    // exclude the whole token, with the comma
+    #define __RUBY_FUNCTION_NAME KNullDesC
+    
+    // no wrapping
+    #define __RUBY_FUNCTION_NAMED( text ) text
+    
+    #define __RUBY_FUNCTION_NAME_POINTER8 NULL
+
+#endif // RUBY_DISABLE_FUNCTION_NAMES
+
+// Macro for printing filename both in unicode and non-unicode builds
+
+
+#ifdef _UNICODE
+	#define __RUBY_WIDEN2(x) L ## x
+	#define __RUBY_WIDEN(x) __RUBY_WIDEN2(x)
+	#define __RUBY_DBG_FILE__ __RUBY_WIDEN(__FILE__)
+#else
+	#define __RUBY_DBG_FILE__ __FILE__
+#endif//_UNICODE
+
+
+
+// Debugging is enabled only in _DEBUG builds
+//#ifdef _DEBUG 
+
+// Select the debug output method
+#ifndef __RUBY_DEBUG_TRACES_TO_FILE
+#define RUBY_DEBUG_METHOD RDebug::Print
+#else
+#define RUBY_DEBUG_METHOD RRubyDebug::PrintToFile
+#endif // __RUBY_DEBUG_TRACES_TO_FILE
+
+//#endif // _DEBUG
+
+#if defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+
+//	#define RUBY_DEBUG_BLOCK(text) \
+//  	RRubyDebug trace_trace( _S(text), _S("" ## __RUBY_DBG_FILE__) , __LINE__, EFalse ); \
+//  	CleanupReleasePushL( trace_trace )
+  	
+//  	#define RUBY_DEBUG_BLOCKL(text) \
+//  	RRubyDebug trace_trace( _S(text), _S("" ## __RUBY_DBG_FILE__), __LINE__, ETrue ); \
+//  	CleanupReleasePushL( trace_trace )
+// A temporary fix to cope with builds on RVCT 530. It didn't compile with _RUBY_DBG_FILE
+	#define RUBY_DEBUG_BLOCK(text) \
+  	RRubyDebug trace_trace( _S(text), _S("") , __LINE__, EFalse, __RUBY_FUNCTION_NAME_POINTER8 ); \
+  	CleanupReleasePushL( trace_trace )
+
+  	#define RUBY_DEBUG_BLOCKL(text) \
+  	RRubyDebug trace_trace( _S(text), _S(""), __LINE__, ETrue, __RUBY_FUNCTION_NAME_POINTER8 ); \
+  	CleanupReleasePushL( trace_trace )
+
+	#define RUBY_DEBUG0(text) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+	#define RUBY_DEBUG1(text, p1) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+	#define RUBY_DEBUG2(text, p1, p2) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, p2, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+#else // Debugging disabled
+
+	// Macros expand to nothing:
+	#define RUBY_DEBUG_BLOCK(text)
+	#define RUBY_DEBUG0(text)    
+	#define RUBY_DEBUG1(text, p1)
+	#define RUBY_DEBUG2(text, p1, p2)
+	#define RUBY_DEBUG_BLOCKL(text)
+
+#endif // defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+
+#if !defined(RUBY_DISABLE_ERRORS) || defined(_DEBUG)
+	// if error messages are allowed (even for UREL)
+	#define RUBY_ERROR0(text) \
+	__RUBY_FUNCTION_NAMED( \
+	    RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+
+	#define RUBY_ERROR1(text, p1) \
+	__RUBY_FUNCTION_NAMED( \
+	RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+
+	#define RUBY_ERROR2(text, p1, p2) \
+	__RUBY_FUNCTION_NAMED( \
+	RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, p2, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+#else
+	// error reporting disabled
+	// Macros expand to nothing:
+	#define RUBY_ERROR_BLOCK(text)
+	#define RUBY_ERROR0(text)    
+	#define RUBY_ERROR1(text, p1)
+	#define RUBY_ERROR2(text, p1, p2)
+#endif  // !defined(RUBY_DISABLE_ERRORS)
+
+#if !defined(RUBY_DISABLE_ASSERT_DEBUG) || defined(_DEBUG)
+	#define RUBY_ASSERT_DEBUG(condition, action) \
+	  __RUBY_FUNCTION_NAMED(\
+		__ASSERT_ALWAYS( condition, RUBY_DEBUG_METHOD(  _L("%S[Error!] %S [Assert failed!] "L###condition L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id())) ); \
+		__ASSERT_DEBUG( (condition), (action) )\
+	  );
+#else
+	// Macro expands to default:
+	#define RUBY_ASSERT_DEBUG(condition, action) __ASSERT_DEBUG(condition,action)
+#endif
+
+// Same as TRAP_IGNORE, but in case of leave, prints the leave code via RUBY_ERROR
+// Can be disabled by RUBY_DISABLE_TRAP_IGNORE or RUBY_DISABLE_ERRORS
+// If disabled, is equivalent to TRAP_IGNORE
+// @see rubydebugcfg.h
+#ifndef RUBY_DISABLE_TRAP_IGNORE 
+    #define RUBY_TRAP_IGNORE( s ) \
+        {\
+        TRAPD( err, s );\
+        if( err != KErrNone )\
+            {\
+            RUBY_ERROR1( "RUBY_TRAP_IGNORE leaves with [%d]", err );\
+            }\
+        }
+#else  // RUBY_DISABLE_TRAP_IGNORE 
+    #define RUBY_TRAP_IGNORE( s ) TRAP_IGNORE( s )
+#endif  // RUBY_DISABLE_TRAP_IGNORE 
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Debug class for printing START, EXIT and LEAVE messages to RDebug in every 
+*  code block. Must be placed in the very beginning of a code block and the
+*  code block cannot leave items in the cleanup stack (like NewLC). 
+*
+*  @since Series 60 2.8
+*
+*  @note If this object is not the topmost item when a code block is exited, 
+*        E32USER-CBase 90 panic is raised (@see CleanupStack::Pop( TAny* )).
+*/
+class RRubyDebug
+    {
+    public:
+        /**
+        * C++ constructor.
+        * @since Series 60 2.8
+        * @param aMsg Debug message.
+        * @param aCalledFromL ETrue if called from RUBY_DEBUG_BLOCK_L
+        */
+        inline RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL,
+                           const TText8* aFunctionName = NULL );
+
+        /**
+        * Destructor.
+        */
+        inline ~RRubyDebug();
+
+        /**
+        * Destructor for Cleanup support. Called when a method leaves.
+        */
+        inline void Release();
+
+        /**
+        * Support for writing traces to file.
+        */
+        IMPORT_C static void PrintToFile( TRefByValue<const TDesC> aFmt, ... );
+
+    private:
+        /**
+        *  Class for truncating debug messages if they are too long.
+        *  @since Series 60 2.8
+        */
+        class TTruncateOverflow : public TDesOverflow
+            {
+            public: // Methods from TDesOverflow
+
+                inline void Overflow( TDes& aDes );
+            };
+
+    private:
+        // A pointer to the debug message
+        TPtrC iMsg;
+        
+        // A pointer to the filename where RUBY_DEBUG_BLOCK is written
+        TPtrC iFileName;
+        
+        // Number of the line where RUBY_DEBUG_BLOCK is written
+        TInt iLine;
+
+		// ETrue if we are called from RUBY_DEBUG_BLOCKL
+        TBool iCalledFromL;
+
+        // Flag that is set when a leave occurs
+        TBool iLeave;
+
+	#ifndef RUBY_DISABLE_FUNCTION_NAMES        
+        // Used only if aFunctionName is defined in constructor
+        HBufC* iFunctionName;
+   	#endif  // RUBY_DISABLE_FUNCTION_NAMES
+        
+    };
+
+#include "rubydebug.inl"
+
+#endif      // RUBYDEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rubydebug/rubydebug.inl	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This module contains the implementation of RRubyDebug class 
+*	             member functions.
+*  %version: 3 %
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+#ifdef _DEBUG
+_LIT( KRubyDebugStart,  "START" );
+_LIT( KRubyDebugStop,   "EXIT" );
+_LIT( KRubyDebugLeave,  "LEAVE!!!" );
+_LIT( KRubyDebugStr,    "%S%S %S [F:%S][L:%d][TId:%d]" );
+#endif
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+#ifdef _DEBUG
+// -----------------------------------------------------------------------------
+// RRubyDebug::RRubyDebug
+// C++ constructor
+// -----------------------------------------------------------------------------
+//
+    
+inline RRubyDebug::RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL,
+                               const TText8* aFunctionName )
+	: iMsg( aMsg ), iFileName( aFileName ), iLine ( aLine ), iCalledFromL ( aCalledFromL ), iLeave ( EFalse )
+	{
+	#ifndef RUBY_DISABLE_FUNCTION_NAMES
+	iFunctionName = NULL;
+	// If function name is defined, use it instead of aMsg
+	if( aFunctionName )
+	    {
+	    TPtrC8 ptr8Name( aFunctionName );
+	    iFunctionName = HBufC::New( ptr8Name.Length() );
+	    if( iFunctionName )
+	        {
+	        // If memory for a 16-bit copy has been allocated successfully
+	        iFunctionName->Des().Copy( ptr8Name );
+	        iMsg.Set( *iFunctionName );
+	        }
+	    }
+	#endif // RUBY_DISABLE_FUNCTION_NAMES
+	TInt id = RThread().Id();
+    iCalledFromL = aCalledFromL;  
+    if( !iCalledFromL) 
+    	{
+    	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id );
+    	}
+    else {
+    	#ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    	// For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id );
+    	#endif
+    	}
+	}    
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::~RRubyDebug
+// Destructor
+// -----------------------------------------------------------------------------
+//
+inline RRubyDebug::~RRubyDebug()
+    {
+    if ( !iLeave ) 
+        {
+        // This is done only if destructor is NOT called from Release().
+        // Otherwise the cleanup stack pops this item automatically.
+        TInt id = RThread().Id();
+        if (!iCalledFromL) 
+        	{
+        	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStop, &iFileName, iLine, id );
+        	}
+        else
+        	{
+        	#ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    		// For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    		RUBY_DEBUG_METHOD( KRubyDebugStr, &KRubyDebugPrefix, &iMsg, &KRubyDebugStop, &iFileName, iLine, id );
+    		#endif
+        	}
+        #ifndef RUBY_DISABLE_FUNCTION_NAMES
+        delete iFunctionName;  // if any
+        #endif  // RUBY_DISABLE_FUNCTION_NAMES
+        CleanupStack::Pop( this ); // E32USER-CBase 90 panic is raised if
+                                   // this is not the topmost item
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::Release()
+// Method that makes it possible to push this object into the cleanup stack.
+// -----------------------------------------------------------------------------
+//
+inline void RRubyDebug::Release()
+    {
+    iLeave = ETrue;
+    TInt id = RThread().Id();
+    RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugLeave, &iFileName, iLine, id );
+    #ifndef RUBY_DISABLE_FUNCTION_NAMES
+    delete iFunctionName;  // if any
+    #endif  // RUBY_DISABLE_FUNCTION_NAMES
+    this->~RRubyDebug();
+    }
+#endif
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::TTruncateOverflow::Overflow()
+// Method for ignoring the overflowing part of a debug message.
+// -----------------------------------------------------------------------------
+//
+inline void RRubyDebug::TTruncateOverflow::Overflow( TDes& /*aDes*/ )
+    {
+    // We ignore the overflowing part of the descriptor...
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rubydebug/rubydebugcfg.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration file for RubyDebug macros
+*  %version: 3 %
+*
+*/
+
+
+#ifndef RUBYDEBUGCFG_H
+#define RUBYDEBUGCFG_H
+
+
+#include <e32cmn.h> // TLitC
+#include <e32def.h> // _LIT
+
+#include "rubydebugconfigselector.h"
+
+// Common settings
+// Is printed at the beginning of the line
+_LIT( __K_RUBY_HEADER, "[<SRSF>] ");
+
+// Is printed after __KRUBY_HEADER for the error messages
+_LIT( __K_RUBY_ERROR, "[Error!] ");
+
+
+#if defined(RUBY_EXTERNAL_VARIANT) && defined(__WINS__)
+// set of options to use when the project is released to the customers
+
+// Uncomment the following line to disable RUBY_DEBUGs. 
+// This has no effect on RUBY_ERRORs
+#define __RUBY_DEBUG_DISABLED
+
+// Uncomment the following line to get traces to C:\Logs\RubyTrace.log
+//#define __RUBY_DEBUG_TRACES_TO_FILE
+
+// Uncomment the following line to stop disable RUBY_ERRORs
+// Error print is always enabled in _DEBUG
+//#define RUBY_DISABLE_ERRORS
+
+// Uncomment the following line to disable extra output for RUBY_ASSERT_DEBUG
+// RUBY_ASSERT_DEBUGs will become usual __ASSERT_DEBUGs
+#define RUBY_DISABLE_ASSERT_DEBUG
+
+// Uncomment the following line to disable automated function name printing
+//#define RUBY_DISABLE_FUNCTION_NAMES
+
+//#define RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+
+// Uncomment the following line to disable leave code printing in RUBY_TRAP_IGNORE
+// macro. It would make it equivalent to TRAP_IGNORE
+// #define RUBY_DISABLE_TRAP_IGNORE
+
+
+#else //  RUBY_EXTERNAL_VARIANT
+// set of options to use in the internal development
+
+// Uncomment the following line to disable RUBY_DEBUGs. 
+// This has no effect on RUBY_ERRORs
+//#define __RUBY_DEBUG_DISABLED
+
+// Uncomment the following line to get traces to C:\Logs\RubyTrace.log
+//#define __RUBY_DEBUG_TRACES_TO_FILE
+
+// Uncomment the following line to stop disable RUBY_ERRORs
+// Error print is always enabled in _DEBUG
+#define RUBY_DISABLE_ERRORS
+
+// Uncomment the following line to disable extra output for RUBY_ASSERT_DEBUG
+// RUBY_ASSERT_DEBUGs will become usual __ASSERT_DEBUGs
+#define RUBY_DISABLE_ASSERT_DEBUG
+
+// Uncomment the following line to disable automated function name printing
+//#define RUBY_DISABLE_FUNCTION_NAMES
+
+//#define RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+
+// Uncomment the following line to disable leave code printing in RUBY_TRAP_IGNORE
+// macro. It would make it equivalent to TRAP_IGNORE
+// #define RUBY_DISABLE_TRAP_IGNORE
+
+#endif  //  RUBY_EXTERNAL_VARIANT
+
+#endif // RUBYDEBUGCFG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/rubydebug/rubydebugconfigselector.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Switches sets of the RubyDebug options. 
+*                @warning DO NOT change the file. At least DO NOT check in the modified version.
+*                Variants should be switched by replacing the whole rubydebugconfigselector.h 
+*                with the help of a Synergy task. 
+*  %version: 3 %
+*
+*/
+
+
+#ifndef RUBYDEBUGCONFIGSELECTOR_H
+#define RUBYDEBUGCONFIGSELECTOR_H
+
+
+// CONSTANTS
+
+/** 
+ * If defined, rubydebug will be tuned with a set of options designed for external users
+ * Typically it means showing all the warnings for hardware builds and only errors for the
+ * SW builds
+ *
+ * If not defined, rubydebug will be tuned for the internal Multimodal UI team development.
+ * Typically it means all the warnings always enabled
+ *
+ * The meaning of the variant is defined in the rubydebugcfg.h
+ * @warning DO NOT change the line. At least DO NOT check in the modified version.
+ *          Variants should be switched by replacing the whole rubydebugconfigselector.h 
+ *          with the help of a Synergy task. 
+ *
+ */
+#define RUBY_EXTERNAL_VARIANT
+
+#endif // RUBYDEBUGCONFIGSELECTOR_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/data/10282c40.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 1028 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin resource file for vcommand control panel plugin.
+*
+*/
+
+#include "vccontrolpanelpluginuids.hrh"
+#include <registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid     = KDllUid;
+    interfaces  =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid   = 0x10207236;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid  = KImplUid;
+                    version_no          = 1;
+                    display_name        = "";
+                    default_data        = "0x10207237"; // Parent UID
+                    opaque_data         = "40"; // Order number
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/data/vccontrolpanelpluginrsc.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file for vccontrolpanelplugin.
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME        VCCP // 4 letter ID
+
+// INCLUDES
+#include    <vcommand.loc>
+
+#include    <data_caging_paths_strings.hrh>
+#include    <bldvariant.hrh>
+#include    <avkon.loc>
+#include    <avkon.mbg>
+#include    <avkon.rsg>
+#include    <EIKCORE.rsg>
+#include    <uikon.rh>
+
+// CONSTANTS
+
+//  RESOURCE DEFINITIONS
+
+//----------------------------------------------------
+//
+//
+//    Needed or loading the resource fails!
+//
+//----------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE
+    {
+    }
+
+//----------------------------------------------------
+//
+//    r_vcommand_control_panel_plugin_caption
+//    vcommand plugin caption.
+//
+//----------------------------------------------------
+//
+RESOURCE TBUF r_vcommand_control_panel_plugin_caption
+    {
+    buf = qtn_set_pers_voicecmd;
+    }   
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Information required for building vccontrolpanelplugin.
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+
+vccontrolpanelplugin.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE vccontrolpanelplugin.mif
+OPTION HEADERFILE vccontrolpanelplugin.mbg
+OPTION SOURCES -c8,8 qgn_prop_cp_dev_vc
+END
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/group/vccontrolpanelplugin.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project specification file for vccontrolpanelplugin.
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+CAPABILITY          CAP_ECOM_PLUGIN
+TARGET              vccontrolpanelplugin.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x10282C40
+VENDORID            VID_DEFAULT
+
+SOURCEPATH          ../src
+SOURCE              vccontrolpanelplugin.cpp
+SOURCE              vccontrolpanelpluginimplementationtable.cpp
+
+SYSTEMINCLUDE       .
+SYSTEMINCLUDE       /epoc32/include/cshelp
+SYSTEMINCLUDE       /epoc32/include/ecom
+SYSTEMINCLUDE       ../../vcommand/inc
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE         ../inc
+USERINCLUDE         ../../vcommand/loc
+
+SOURCEPATH          ../data
+
+// ECOM resource definition
+START RESOURCE      10282c40.rss
+TARGET              vccontrolpanelplugin.rsc
+TARGETPATH          ECOM_RESOURCE_DIR
+END //  ECOM resource definition
+
+// Plugin's own resources.
+START RESOURCE      vccontrolpanelpluginrsc.rss
+HEADER
+TARGETPATH          RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END // own resource file
+
+LIBRARY             apgrfx.lib
+LIBRARY             apparc.lib
+LIBRARY             avkon.lib
+LIBRARY             bafl.lib
+LIBRARY             commonengine.lib
+LIBRARY             cone.lib
+LIBRARY             ecom.lib
+LIBRARY             efsrv.lib
+LIBRARY             eikcoctl.lib
+LIBRARY             eikcore.lib
+LIBRARY             euser.lib
+LIBRARY             gsecomplugin.lib
+LIBRARY             gsframework.lib
+LIBRARY             ws32.lib
+LIBRARY             aknskins.lib
+LIBRARY             aknskinsrv.lib
+LIBRARY             aknswallpaperutils.lib 
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/group/vccp_icons_scalable_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,71 @@
+#
+# Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icon makefile
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\vccontrolpanelplugin.mif
+HEADERFILENAME=$(HEADERDIR)\vccontrolpanelplugin.mbg
+
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 qgn_prop_cp_dev_vc.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/inc/vccontrolpanelplugin.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommand control panel plugin implementation.
+*
+*/
+
+#ifndef VCCONTROLPANELPLUGIN_H
+#define VCCONTROLPANELPLUGIN_H
+
+#include <gsplugininterface.h>
+#include <aknview.h>
+#include <ConeResLoader.h>
+#include <eikclb.h>
+#include <AknServerApp.h>
+#include "vccontrolpanelpluginuids.hrh"
+
+class CAknNavigationDecorator;
+class CAknViewAppUi;
+class CAknNullService;
+
+// This plugin's UID.
+const TUid KDllTUid = { KDllUid };
+// UID of VCommand application
+const TUid KVCommandAppTUid = { KVCommandAppUid };
+
+// CLASS DECLARATION
+/**
+* CVcControlPanelPlugin.
+*/
+class CVcControlPanelPlugin : public CGSPluginInterface,
+                      public MAknServerAppExitObserver
+    {
+    public:
+
+        /**
+        * Symbian OS two-phased constructor
+        * @param aInitParams initialization parameters.
+        * @return new instance of CVcControlPanelPlugin.
+        */
+        static CVcControlPanelPlugin* NewL( TAny* aInitParams );
+
+        /**
+        * Destructor.
+        */
+        ~CVcControlPanelPlugin();
+
+        /**
+        * From CAknView.
+        * This view's Id.
+        * @return This plugin's UID.
+        */
+        TUid Id() const;   
+
+        /**
+        * From CGSPluginInterface.
+        * @param aCaption this plugin's caption.
+        */
+        void GetCaptionL( TDes& aCaption ) const;
+        
+        /**
+        * From CGSPluginInterface.
+        * @param aIconType icon type
+        */
+        CGulIcon* CreateIconL( const TUid aIconType );
+
+        /**
+        * From CGSPluginInterface.
+        * @return this plugin's provider category.
+        */
+        TInt PluginProviderCategory() const;
+
+        /**
+        * From CGSPluginInterface.
+        * @return this plugin's item type.
+        */
+        TGSListboxItemTypes ItemType();
+
+        /**
+        * From CGSPluginInterface.
+        * @param aKey key name.
+        * @param aValue key value.
+        */
+        void GetValue( const TGSPluginValueKeys aKey,
+                       TDes& aValue );
+
+        /**
+        * From CGSPluginInterface.
+        * @param aSelectionType selection type.
+        */
+        void HandleSelection( const TGSSelectionTypes aSelectionType );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CVcControlPanelPlugin();
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * From CAknView.
+        * This implementation is empty because this class, being just a dialog,
+        * does not implement the CAknView finctionality.
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+
+        /**
+        * From CAknView.
+        * This implementation is empty because this class, being just a dialog,
+        * does not implement the CAknView finctionality.
+        */
+        void DoDeactivate();
+
+        /**
+        * Opens localized resource file.
+        */
+        void OpenLocalizedResourceFileL(
+            const TDesC& aResourceFileName,
+            RConeResourceLoader& aResourceLoader );
+
+        /**
+        * Launches provisioning application.
+        */
+        void LaunchVCommandAppL();
+
+    private: // Data
+
+        /**
+        * Resource loader for this plugin's resources.
+        */
+        RConeResourceLoader iResources;
+
+        /**
+        * AVKON NULL Service.
+        * Own.
+        */
+        CAknNullService* iNullService;
+    };
+
+#endif // VCCONTROLPANELPLUGIN_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/inc/vccontrolpanelpluginuids.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommand control panel plugin uids.
+*
+*/
+
+#ifndef VCCONTROLPANELPLUGINUIDS_HRH
+#define VCCONTROLPANELPLUGINUIDS_HRH
+
+// DLL uid
+#define KDllUid 0x10282C40
+
+// Implementation uid
+#define KImplUid 0x10282C41
+
+// VCommand application uid
+#define KVCommandAppUid 0x101F8555
+
+#endif  // VCCONTROLPANELPLUGINUIDS_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/src/vccontrolpanelplugin.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,241 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  VCommand control panel plugin implementation.
+*
+*/
+
+
+// GS Framework and this plugin.
+#include    "vccontrolpanelplugin.h"
+#include    <vccontrolpanelplugin.mbg>
+#include    <gsparentplugin.h>
+#include    <gscommon.hrh>
+#include    <vccontrolpanelpluginrsc.rsg>
+#include    <gsprivatepluginproviderids.h>
+#include    <gsfwviewuids.h>
+#include    <AknsUtils.h> 
+
+// General services.
+#include    <AknNullService.h>
+#include    <bautils.h>
+#include    <StringLoader.h>
+
+// This application's resource file.
+_LIT( KVcControlPanelPluginResourceFileName, "z:vccontrolpanelpluginrsc.rsc" );
+_LIT( KIconFileName, "z:vccontrolpanelplugin.mif");
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcControlPanelPlugin::CVcControlPanelPlugin() : iResources( *iCoeEnv ), iNullService( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcControlPanelPlugin::~CVcControlPanelPlugin()
+    {
+    iResources.Close();
+
+    if ( iNullService )
+        {
+        delete iNullService;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::ConstructL()
+    {
+    OpenLocalizedResourceFileL( KVcControlPanelPluginResourceFileName, iResources );    
+    }
+
+// ---------------------------------------------------------------------------
+// Static constructor
+// ---------------------------------------------------------------------------
+//
+CVcControlPanelPlugin* CVcControlPanelPlugin::NewL( TAny* /*aInitParams*/ )
+    {
+    CVcControlPanelPlugin* self = new( ELeave ) CVcControlPanelPlugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::Id
+// -----------------------------------------------------------------------------
+//
+TUid CVcControlPanelPlugin::Id() const
+    {
+    return KDllTUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::DoActivateL
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
+                                  TUid /*aCustomMessageId*/,
+                                  const TDesC8& /*aCustomMessage*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::DoDeactivate
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::DoDeactivate()
+    {
+    }
+
+// ========================= From CGSPluginInterface ==================
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::GetCaptionL
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::GetCaptionL( TDes& aCaption ) const
+    {
+    HBufC* result = StringLoader::LoadL( R_VCOMMAND_CONTROL_PANEL_PLUGIN_CAPTION );
+    aCaption.Copy( *result );
+    delete result;
+    }
+    
+// ---------------------------------------------------------
+// CVcControlPanelPlugin::CreateIconL
+// ---------------------------------------------------------
+//    
+CGulIcon* CVcControlPanelPlugin::CreateIconL( const TUid aIconType )
+    {
+    CGulIcon* icon;
+    
+    TParse parse;
+    parse.Set( KIconFileName, &KDC_BITMAP_DIR, NULL );
+    TFileName fileName( parse.FullName() );
+
+    if ( aIconType == KGSIconTypeLbxItem )
+        {
+        icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), KAknsIIDQgnPropCpDevVc, fileName,
+                                          EMbmVccontrolpanelpluginQgn_prop_cp_dev_vc,
+                                          EMbmVccontrolpanelpluginQgn_prop_cp_dev_vc_mask );
+        }
+    else
+        {
+        icon = CGSPluginInterface::CreateIconL( aIconType );
+        }
+
+    return icon;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::PluginProviderCategory
+// -----------------------------------------------------------------------------
+//
+TInt CVcControlPanelPlugin::PluginProviderCategory() const
+    {
+    return KGSPluginProviderInternal;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::ItemType()
+// -----------------------------------------------------------------------------
+//
+TGSListboxItemTypes CVcControlPanelPlugin::ItemType()
+    {
+    return EGSItemTypeSettingDialog;
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::GetValue()
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::GetValue( const TGSPluginValueKeys /*aKey*/,
+                                      TDes& /*aValue*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::HandleSelection()
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::HandleSelection(
+    const TGSSelectionTypes /*aSelectionType*/ )
+    {
+    TRAP_IGNORE( LaunchVCommandAppL() );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::OpenLocalizedResourceFileL()
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::OpenLocalizedResourceFileL(
+    const TDesC& aResourceFileName,
+    RConeResourceLoader& aResourceLoader )
+    {
+    // Find the resource file:
+    TParse* parse = new (ELeave) TParse;
+    CleanupStack::PushL( parse );
+    parse->Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
+    TFileName* fileName = new (ELeave) TFileName( parse->FullName() );
+    CleanupStack::PushL( fileName );
+
+    // Open resource file:
+    aResourceLoader.OpenL( *fileName );
+    
+    CleanupStack::PopAndDestroy( fileName );
+    CleanupStack::PopAndDestroy( parse );
+    }
+
+// -----------------------------------------------------------------------------
+// CVcControlPanelPlugin::LaunchVCommandAppL()
+// -----------------------------------------------------------------------------
+//
+void CVcControlPanelPlugin::LaunchVCommandAppL()
+    {
+    // Get the correct application data
+    RWsSession ws;
+    User::LeaveIfError( ws.Connect() );
+    CleanupClosePushL( ws );
+
+    // Find the task with uid
+    TApaTaskList taskList(ws);
+    TApaTask task = taskList.FindApp( KVCommandAppTUid );
+
+    if ( task.Exists() )
+        {
+        task.BringToForeground();
+        }
+    // Launch VCommand as embedded.
+    else
+        {
+        if ( iNullService )
+            {
+            delete iNullService;
+            iNullService = NULL;
+            }
+        // Catch the pointer to prevent a memory leak
+        iNullService = CAknNullService::NewL( KVCommandAppTUid, this );
+        }
+    CleanupStack::PopAndDestroy();  // ws
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vccontrolpanelplugin/src/vccontrolpanelpluginimplementationtable.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM proxy table for VCommand control panel plugin.
+*
+*/
+
+
+// User includes
+#include "vccontrolpanelplugin.h"
+#include "vccontrolpanelpluginuids.hrh"
+
+// System includes
+#include <e32std.h>
+#include <implementationproxy.h>
+
+
+// Constants
+const TImplementationProxy KVccontrolPanelPluginImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( KImplUid,  CVcControlPanelPlugin::NewL )
+    };
+
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Gate/factory function
+//
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+    TInt& aTableCount )
+    {
+    aTableCount = sizeof( KVccontrolPanelPluginImplementationTable )
+        / sizeof( TImplementationProxy );
+    return KVccontrolPanelPluginImplementationTable;
+    }
Binary file voiceui/vcommand/aif/context_pane_icon.bmp has changed
Binary file voiceui/vcommand/aif/context_pane_icon_mask.bmp has changed
Binary file voiceui/vcommand/aif/list_icon.bmp has changed
Binary file voiceui/vcommand/aif/list_icon_mask.bmp has changed
Binary file voiceui/vcommand/aif/qgn_indi_voice_add.bmp has changed
Binary file voiceui/vcommand/aif/qgn_indi_voice_add_mask.bmp has changed
Binary file voiceui/vcommand/aif/qgn_menu_vc_cxt.bmp has changed
Binary file voiceui/vcommand/aif/qgn_menu_vc_cxt_mask.bmp has changed
Binary file voiceui/vcommand/aif/qgn_menu_vc_lst.bmp has changed
Binary file voiceui/vcommand/aif/qgn_menu_vc_lst_mask.bmp has changed
Binary file voiceui/vcommand/aif/qgn_prop_folder_small.bmp has changed
Binary file voiceui/vcommand/aif/qgn_prop_folder_small_mask.bmp has changed
Binary file voiceui/vcommand/aif/qgn_vc_transparent_icon.bmp has changed
Binary file voiceui/vcommand/aif/qgn_vc_transparent_icon_mask.bmp has changed
Binary file voiceui/vcommand/aif/qgn_vc_voice_icon.bmp has changed
Binary file voiceui/vcommand/aif/qgn_vc_voice_icon_mask.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/aif/vcommandaif.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <aiftool.rh>
+
+RESOURCE AIF_DATA
+    {
+    app_uid=0x101F8555;
+    num_icons=2;
+    embeddability=KAppNotEmbeddable;
+    newfile=KAppDoesNotSupportNewFile;
+    }
+
+// End of File
Binary file voiceui/vcommand/cenrep/keys_vcommand.xls has changed
Binary file voiceui/vcommand/conf/vcommand.confml has changed
Binary file voiceui/vcommand/conf/vcommand_10207267.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/data/vcommand.rh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     This file contains declarations for resources of Voice commands.
+*     The file can be included only in resource file.
+*     
+*
+*/
+
+
+#ifndef VCOMMAND_RH
+#define VCOMMAND_RH
+
+//  INCLUDES
+#include "vcommand.hrh"
+
+//  STRUCTURE DEFINITIONS
+
+
+// ---------------------------------------------------------
+// new_message_mtm_type
+//
+// Message Mtm types.
+// ---------------------------------------------------------
+//
+STRUCT NEW_MESSAGE_MTM_TYPE
+    {
+    LONG id = 0;
+    LTEXT name = "";
+    }
+
+// ---------------------------------------------------------
+// new_message_mtm_array
+//
+// Message Mtm array.
+// ---------------------------------------------------------
+//
+STRUCT NEW_MESSAGE_MTM_ARRAY
+    {
+    STRUCT items[];
+    }
+
+#endif	//VCOMMAND_RH
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/data/vcommand.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,943 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains all the resources for the Voice Commands UI.
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    VCUI // 4 letter ID
+
+//  INCLUDES
+#include <uikon.rh>
+#include <eikon.rsg>
+#include <eikon.rh>
+#include <appinfo.rh>
+#include <avkon.loc>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <AvkonIcons.hrh>
+#include <data_caging_paths_strings.hrh>
+
+
+//#include <vcommand.mbg>
+
+
+#include "vcommand.hrh"
+#include "voiceuibldvariant.hrh"
+#include <vcommand.loc>
+#include <vuivoicerecognition.loc>
+
+//  RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf = r_vc_main_view_title; }
+
+RESOURCE EIK_APP_INFO
+    {
+    status_pane=r_vc_main_status_pane;
+    }
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vc_main_status_pane
+//    Status pane for main view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STATUS_PANE_APP_MODEL r_vc_main_status_pane
+    {
+    layout = R_AVKON_STATUS_PANE_LAYOUT_USUAL;
+    panes =
+        {
+        SPANE_PANE
+            {
+            id = EEikStatusPaneUidTitle;
+            type = EAknCtTitlePane;
+            resource = r_vc_main_view_title;
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vcommand_localisable_app_info
+//    menu captions and application icon
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_vcommand_localisable_app_info
+    {
+    short_caption = qtn_apps_vcommand_grid;
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = qtn_apps_vcommand_list;
+
+#ifdef __SCALABLE_ICONS
+        number_of_icons = 1;
+        icon_file = APP_BITMAP_DIR"\\VCommand_aif.mif";
+#else   // __SCALABLE_ICONS
+        number_of_icons = 2;
+        icon_file = APP_BITMAP_DIR"\\VCommand_aif.mbm";
+#endif
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vc_main_view_title
+//    Main view's title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE TITLE_PANE r_vc_main_view_title
+    {
+    txt = qtn_vc_title;
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vc_settings_view_title
+//    Setting view's title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE TITLE_PANE r_vc_settings_view_title    
+    {
+    txt = qtn_vc_title_settings;
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vcommand_main_view
+//    Applications main view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_vcommand_main_view
+    {
+    menubar=r_vcommand_menubar;
+#ifdef __VCOMMAND_CONTROL_PANEL
+    cba=r_softkeys_options_back__select;
+#else
+    cba=r_softkeys_options_exit__select;
+#endif
+    }
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vcommand_folder_view
+//    Folder view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_vcommand_folder_view
+    {
+    menubar=r_vcommand_menubar;
+    cba=r_softkeys_options_back__select;    
+    }
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vcommand_menubar
+//    Menubar for VCommand application
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_vcommand_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_vcommand_menu; txt="View"; }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vcommand_menu
+//    Menu for Main Applications view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_vcommand_menu
+    {
+    items=
+        {
+        MENU_ITEM
+            {
+            command = EVCCmdOpen;
+            txt = qtn_voice_open;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EVCCmdEdit;
+            txt = qtn_vc_edit;
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command = EVCCmdStartVui;
+            txt = qtn_vc_tutorial;
+            },			
+        MENU_ITEM
+            {
+            command = EVCCmdPlayback;
+            txt = text_voice_replay;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EVCCmdDelete;
+            txt = qtn_vc_options_remove_user_text;
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command = EVCCmdSettings;
+            txt = qtn_vc_settings;
+            },       
+        MENU_ITEM
+            {
+            command = EAknCmdHelp;
+            txt = qtn_options_help;
+            },
+        MENU_ITEM
+            {
+            command = EAknCmdExit;
+            txt = qtn_options_exit;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r__softkeys_options_exit__select
+//  Softkeys with an exit button on the right
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE CBA r_softkeys_options_exit__select
+    {
+    buttons =
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyExit; txt = text_softkey_exit; },
+        AVKON_CBA_BUTTON{id=EAknSoftkeySelect; longpressid=0; txt= text_softkey_empty; }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r_softkeys_options_back__select
+//  Softkeys with a back button on the right
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE CBA r_softkeys_options_back__select
+    {
+    buttons =
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back; },
+        AVKON_CBA_BUTTON{id=EAknSoftkeySelect; longpressid=0; txt= text_softkey_empty; }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r_softkeys_quit   
+//  Softkey for quitting voice tag playback
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE CBA r_softkeys_quit
+    {
+    buttons = 
+        {
+        CBA_BUTTON {id=0;                    txt=""; },
+        //CBA_BUTTON {id=EVCommandSoftKeyQuit; txt=text_softkey_quit;}
+        CBA_BUTTON {id=EAknSoftkeyDone; txt=text_softkey_quit;}
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r_playback_voice_command_dialog
+//  Playback voice command dialog
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_playback_voice_command_dialog
+    {
+    flags=EAknProgressNoteFlags | EEikDialogFlagWait;
+    buttons=R_AVKON_SOFTKEYS_QUIT;
+     items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtNote;
+            id=EVoicePlaybackProgressNoteId;
+            control= AVKON_NOTE 
+                { 
+                    layout = EProgressLayout;
+                    imagefile = AVKON_ICON_FILE;
+                    imageid = EMbmAvkonQgn_note_voice;
+                    imagemask = EMbmAvkonQgn_note_voice_mask;   
+                };
+            }
+        };        
+    }
+
+
+//-----------------------------------------------------------------------------
+//    
+//  r_voice_command_too_short_dialog
+//  Voice tag too short dialog
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_voice_command_too_short_dialog
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY 
+                { 
+                layout = EConfirmationLayout;
+                label = text_vc_voice_too_short;
+                bmpfile = AVKON_ICON_FILE;
+                bmpid = EMbmAvkonQgn_note_query;
+                bmpmask = EMbmAvkonQgn_note_query_mask; //0xffff;
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//    
+//  r_remove_application_dialog
+//  Removes user added command from the list
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_remove_application_dialog
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY  
+                { 
+                    layout = EConfirmationLayout;
+                    label = qtn_query_common_conf_remove;
+                };
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r_cannot_delete_note
+//  Information note for %U cannot be deleted
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AKN_NOTE_WRAPPER r_cannot_delete_note
+    {
+    resId = R_AKN_INFORMATION_NOTE_DIALOG_WAIT;
+    timeout = EAknInformationNoteTimeout;
+    tone = EAknNoteDialogWarningTone;
+    text = qtn_vc_info_cannot_del;
+    }
+
+//
+//-----------------------------------------------------------------------------
+//    
+//  r_vc_already_in_use
+//  Information note for name already in use
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AKN_NOTE_WRAPPER r_vc_already_in_use
+    {
+    resId = R_AKN_ERROR_NOTE_DIALOG_WAIT;
+    timeout = EAknErrorNoteTimeout;
+    tone = EAknNoteDialogErrorTone;
+    text = qtn_vc_error_in_use;
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r_vc_reset_adaptation_dialog
+//  Resets user learnings
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_vc_reset_adaptation_dialog
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY  
+                { 
+                    layout = EConfirmationLayout;
+                    label = qtn_vc_conf_query_reset;
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//    
+//      r_vc_data_query
+//      Edit text data query.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_vc_data_query
+    {
+    flags = EEikDialogFlagWait |
+            EEikDialogFlagNoDrag;
+
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_DATA_QUERY 
+                { 
+                layout = EStaticSizeDataLayout;
+                label = qtn_vc_heading_edit;
+                control = EDWIN
+                    {
+                    flags = EEikEdwinNoLineOrParaBreaks |
+                            EEikEdwinResizable | 
+                            EEikEdwinAutoSelection;
+                    
+                    width = KMaxEditWidthLength;
+                    lines = 1;
+                    maxlength = KMaxEditableTextLength;
+                    numeric_keymap = EAknEditorStandardNumberModeKeymap;
+                    default_input_mode = EAknEditorTextInputMode;
+                    allowed_input_modes = EAknEditorTextInputMode |
+										  EAknEditorNumericInputMode;
+                    allowed_case_modes = EAknEditorAllCaseModes;
+                    };
+                };
+            }
+        };
+    }
+    
+//-----------------------------------------------------------------------------
+//    
+//      r_vc_data_query
+//      Edit text data query.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_vc_data_query_japanese
+    {
+    flags = EEikDialogFlagWait |
+            EEikDialogFlagNoDrag;
+
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_DATA_QUERY 
+                { 
+                layout = EStaticSizeDataLayout;
+                label = qtn_vc_heading_edit;
+                control = EDWIN
+                    {
+                    flags = EEikEdwinNoLineOrParaBreaks |
+                            EEikEdwinResizable | 
+                            EEikEdwinAutoSelection;
+                    
+                    width = KMaxEditWidthLength;
+                    lines = 1;
+                    maxlength = KMaxEditableTextLength;
+                    numeric_keymap = EAknEditorStandardNumberModeKeymap;
+                    default_input_mode = EAknEditorKatakanaInputMode;
+                    allowed_input_modes = EAknEditorNumericInputMode |
+										  EAknEditorKatakanaInputMode |
+										  EAknEditorHalfWidthTextInputMode;
+                    allowed_case_modes = EAknEditorTextCase;
+                    };
+                };
+            }
+        };
+    }
+    
+// -----------------------------------------------------------------------------
+//
+// r_vc_wait_note
+// Wait note "Opening.." for main view and profiles view.
+//
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE DIALOG r_vc_wait_note
+    {
+    flags   = EAknWaitNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_EMPTY;
+    items   =
+        {
+        DLG_LINE
+            {
+            type    = EAknCtNote;
+            id      = EVCWaitNote;
+            control = AVKON_NOTE
+                {
+                layout          = EWaitLayout;
+                singular_label  = "";
+                animation       = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+    
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vc_settings_menubar
+//    Menubar visible in the setting view
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_vc_settings_menubar
+    {
+    titles = 
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_vc_settings_menu;
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vc_setting_list_view
+//    Settings view
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_vc_setting_list_view
+    {
+    menubar = r_vc_settings_menubar;
+
+    cba = r_softkeys_options_back__change;
+    }
+
+//-----------------------------------------------------------------------------
+//    
+//  r_softkeys_options_back__change
+//  Softkeys for main view
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE CBA r_softkeys_options_back__change
+    {
+    buttons =
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back; },
+        AVKON_CBA_BUTTON{id=EVCCmdChange; longpressid=0; txt = text_softkey_empty; }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_item_list
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_ITEM_LIST r_vc_setting_item_list
+    {
+    items =
+        {
+        // Synthesizer
+        AVKON_SETTING_ITEM
+            {
+            identifier = EVCSynthesizerItem;
+            setting_page_resource = r_vc_setting_synthesizer;
+            associated_resource = r_vc_setting_synthesizer_texts;
+            name = qtn_vc_set_synt;
+            },
+        // Volume control
+		AVKON_SETTING_ITEM
+            {
+            identifier = EVCVolumeItem;
+            setting_page_resource = r_vc_setting_volume;
+            name = qtn_vc_set_volume;
+            },
+        // Rejection sensitivity
+        AVKON_SETTING_ITEM
+            {
+            identifier = EVCRejectionItem;
+            setting_page_resource = r_vc_setting_rejection;
+            name = qtn_vc_set_rejection;
+            },
+        // Command verification
+        AVKON_SETTING_ITEM
+            {
+            identifier = EVCVerificationItem;
+            setting_page_resource = r_vc_setting_verification;
+            associated_resource = r_vc_setting_verification_texts;
+            name = qtn_vc_set_verification;
+            },
+        // User learnings
+        AVKON_SETTING_ITEM
+            {
+            identifier = EVCResetItem;
+            name = qtn_vc_set_reset;
+            }
+   		};
+	}
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_syntheriser
+//    Synthesizer setting page
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_vc_setting_synthesizer
+    {
+    label = qtn_vc_set_synt2;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    type =  EAknCtPopupSettingList;
+    editor_resource_id = r_vc_setting_listbox;
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_synthesizer_texts
+//    Defines list for setting page
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_vc_setting_synthesizer_texts
+    {
+    setting_texts_resource = r_vc_setting_synthesizer_text_array;
+    popped_up_texts_resource = r_binary_switch_on_off_texts_popped_up;
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_synthesizer_text_array
+//    Choices for synthesizer setting
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_vc_setting_synthesizer_text_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = ESynthesizerOn;
+            text = qtn_vc_set_on;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = ESynthesizerOff;
+            text = qtn_vc_set_off;
+            }
+        };
+    }
+    
+RESOURCE ARRAY r_binary_switch_on_off_texts_popped_up
+    {
+    items =
+        {
+        LBUF { txt = qtn_vc_set_on; },
+        LBUF { txt = qtn_vc_set_off; }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_listbox
+//    Listbox of setting page
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE POPUP_SETTING_LIST r_vc_setting_listbox
+    {
+    flags = 0;
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_vc_setting_volume
+// Volume setting page
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_vc_setting_volume
+    {
+    label = qtn_vc_set_volume2;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    type = EAknCtVolumeControl;
+    editor_resource_id = r_vc_setting_volume_control;
+    }
+    
+    
+// -----------------------------------------------------------------------------
+//
+// r_vc_setting_volume_control
+// ?description
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE VOLUME r_vc_setting_volume_control
+    {
+    flags = ESettingsVolumeControl;
+    value = 7; // Has to have a value, otherwise crashes
+    }
+    
+
+// -----------------------------------------------------------------------------
+//
+// r_vc_setting_rejection
+// Rejection setting page
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_vc_setting_rejection
+    {
+    number = EAknSettingPageNoOrdinalDisplayed;
+    label = qtn_vc_set_rejection2;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    type = EAknCtSlider;
+    editor_resource_id = r_vc_setting_rejection_control;
+    }
+    
+    
+//-----------------------------------------------------------------------------
+//    
+//  r_vc_setting_rejection_control    
+//  Slider resource setting page.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE SLIDER_WITH_FEEDBACK_STYLE  r_vc_setting_rejection_control 
+    {
+    feedbackstyle = EAknSliderFbDynamic;
+    layout = EAknSettingsItemSliderLayout;
+    minvalue = 0;
+    maxvalue = 10;
+    step = 1;
+    valuetype = EAknSliderValueBareFigure;
+    minlabel = qtn_vc_rejection_low;
+    maxlabel = qtn_vc_rejection_high;
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_verification
+//    Verification setting page
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_vc_setting_verification
+    {
+    label = qtn_vc_set_verification2;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    type =  EAknCtPopupSettingList;
+    editor_resource_id = r_vc_setting_listbox;
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_verification_texts
+//    Defines list for setting page
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_vc_setting_verification_texts
+    {
+    setting_texts_resource = r_vc_setting_verification_text_array;
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_vc_setting_verification_text_array
+//    Choices for verification setting
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_vc_setting_verification_text_array
+    {
+    items =
+        {
+        AVKON_ENUMERATED_TEXT
+            {
+            value = EAutomatic;
+            text = qtn_vc_set_verification_automatic;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = EManual;
+            text = qtn_vc_set_verification_manual;
+            },
+        AVKON_ENUMERATED_TEXT
+            {
+            value = EVoice;
+            text = qtn_vc_set_verification_voice;
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//   
+//    r_vc_settings_menu
+//    Menu visible in the setting view
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_vc_settings_menu
+    {
+    items = 
+        {
+        MENU_ITEM
+            { 
+            command = EVCMenuCmdChange;
+            txt = qtn_options_change;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            { 
+            command = EVCCmdReset;
+            txt = qtn_vc_options_reset;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EAknCmdHelp;
+            txt = qtn_options_help;
+            },
+        MENU_ITEM 
+            {
+            command = EAknCmdExit;
+            txt = qtn_options_exit;
+            }
+        };
+    }
+
+
+RESOURCE TBUF   r_text_voice_system_error                   { buf = text_voice_system_error; }
+RESOURCE TBUF   r_qtn_vc_delete_command                     { buf = qtn_query_common_conf_remove; }
+RESOURCE TBUF   r_qtn_vc_playing                            { buf = text_vc_voice_replaying; }
+RESOURCE TBUF   r_qtn_vc_open                               { buf = qtn_msk_open; }
+RESOURCE TBUF   r_qtn_vc_edit                               { buf = qtn_msk_edit; }
+RESOURCE TBUF   r_text_call_in_progress                     { buf = text_call_in_progress; }
+RESOURCE TBUF   r_qtn_vc_wait_note_removing                 { buf = qtn_vc_wait_note_removing; }
+RESOURCE TBUF   r_qtn_vc_wait_note_creating_command         { buf = qtn_vc_wait_note_creating_command; }
+RESOURCE TBUF   r_qtn_vc_info_note_synthesizer_on           { buf = qtn_vc_info_note_synthesizer_on; }
+RESOURCE TBUF   r_qtn_vc_info_note_voice_verification_off   { buf = qtn_vc_info_note_voice_verification_off; }
+RESOURCE TBUF   r_qtn_vc_error_note_invalid_text            { buf = qtn_vc_error_note_invalid_text; }
+
+// Command editing error texts
+RESOURCE TBUF   r_qtn_vc_info_cannot_del                    { buf = qtn_vc_info_cannot_del; }
+RESOURCE TBUF   r_qtn_vc_error_short                        { buf = qtn_vc_error_short; }
+RESOURCE TBUF   r_qtn_vc_error_in_use                       { buf = qtn_vc_error_in_use; }
+
+// Settings
+RESOURCE TBUF   r_qtn_vc_set_synt                           { buf = qtn_vc_set_synt; }
+RESOURCE TBUF   r_qtn_vc_set_synt2                          { buf = qtn_vc_set_synt2; }
+RESOURCE TBUF   r_qtn_vc_set_volume                         { buf = qtn_vc_set_volume; }
+RESOURCE TBUF   r_qtn_vc_set_rejection                      { buf = qtn_vc_set_rejection; }
+RESOURCE TBUF   r_qtn_vc_set_verification                   { buf = qtn_vc_set_verification; }
+RESOURCE TBUF   r_qtn_vc_set_verification2                  { buf = qtn_vc_set_verification2; }
+RESOURCE TBUF   r_qtn_vc_set_reset                          { buf = qtn_vc_set_reset; }
+RESOURCE TBUF   r_qtn_vc_set_on                             { buf = qtn_vc_set_on; }
+RESOURCE TBUF   r_qtn_vc_set_off                            { buf = qtn_vc_set_off; }
+RESOURCE TBUF   r_qtn_vc_set_verification_automatic         { buf = qtn_vc_set_verification_automatic; }
+RESOURCE TBUF   r_qtn_vc_set_verification_manual            { buf = qtn_vc_set_verification_manual; }
+RESOURCE TBUF   r_qtn_vc_set_verification_voice             { buf = qtn_vc_set_verification_voice; }
+RESOURCE TBUF   r_qtn_vc_conf_note_reset                    { buf = qtn_vc_conf_note_reset; }
+RESOURCE TBUF	  r_qtn_set_pers_voicecmd			                { buf = qtn_set_pers_voicecmd; }
+RESOURCE TBUF	  r_qtn_vc_set_msk_change                     { buf = qtn_msk_change; }
+RESOURCE TBUF	  r_qtn_vc_set_msk_reset                      { buf = qtn_vc_msk_reset; }
+
+//----------------------------------------------------
+//    
+//  r_not_enough_memory_dialog
+//  "No memory" dialog
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_not_enough_memory_dialog
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY 
+                { 
+                layout = EConfirmationLayout;
+                label = qtn_memlo_not_enough_memory;
+                };
+            }
+        };
+    }    
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/data/vcommand_caption.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Caption file for Voice Commands.
+*
+*/
+
+
+#include <vcommand.loc>
+#include <apcaptionfile.rh>
+
+RESOURCE CAPTION_DATA
+    {
+    caption=qtn_apps_vcommand_list;
+    shortcaption=qtn_apps_vcommand_grid;
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/data/vcommand_reg.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+#include <vcommand.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x101F8555 // Define your application UID here
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "VCommand";
+    localisable_resource_file = APP_RESOURCE_DIR"\\vcommand";
+    localisable_resource_id = R_VCOMMAND_LOCALISABLE_APP_INFO;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project file for vcommand
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+//  Help exports
+#include "../help/group/bld.inf"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+// Backup registration files
+../inc/backup_registration.xml     /epoc32/data/z/private/101f8555/backup_registration.xml
+../inc/backup_registration.xml     /epoc32/release/winscw/udeb/z/private/101f8555/backup_registration.xml
+../inc/backup_registration.xml     /epoc32/release/winscw/urel/z/private/101f8555/backup_registration.xml
+../loc/vcommand.loc                APP_LAYER_LOC_EXPORT_PATH(vcommand.loc)
+
+// Generic configuration interface for component cenrep settings  
+../conf/vcommand.confml                        APP_LAYER_CONFML(vcommand.confml)
+../conf/vcommand_10207267.crml          APP_LAYER_CRML(vcommand_10207267.crml)
+
+PRJ_MMPFILES
+vcommand.mmp
+
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE vcommand.mif
+OPTION HEADERFILE vcommand.mbg
+OPTION SOURCES \
+	       -c8,8 qgn_prop_folder_vc_general -c8,8 qgn_prop_folder_vc_tools \
+	       -c8,8 qgn_prop_folder_vc_organiser -c8,8 qgn_prop_folder_vc_message \
+	       -c8,8 qgn_prop_folder_vc_media -c8,8 qgn_prop_folder_vc_profiles
+END
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE vcommand_aif.mif
+OPTION SOURCES -c8,8 qgn_menu_vc
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/group/icons_aif_bitmaps_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+#
+# Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\vcommand_aif.mbm
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_vc_lst.bmp \
+		/c8,8 qgn_menu_vc_cxt.bmp
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/group/icons_aif_scalable_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\vcommand_aif.mif
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_vc.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/group/icons_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+#
+# Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icons used for Speaker independent voice commands
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\vcommand.mif
+HEADERFILENAME=$(HEADERDIR)\vcommand.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	    /c8,8 qgn_prop_folder_vc_general.bmp \
+			/c8,8 qgn_prop_folder_vc_tools.bmp \
+			/c8,8 qgn_prop_folder_vc_organiser.bmp \
+	    /c8,8 qgn_prop_folder_vc_message.bmp \
+	    /c8,8 qgn_prop_folder_vc_media.bmp \
+	    /c8,8 qgn_prop_folder_vc_profiles.bmp \
+
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/group/icons_scalable_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+#
+# Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icons used for Speaker independent voice commands
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\vcommand.mif
+HEADERFILENAME=$(HEADERDIR)\vcommand.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+	    /c8,8 qgn_prop_folder_vc_general.svg \
+	    /c8,8 qgn_prop_folder_vc_tools.svg \
+	    /c8,8 qgn_prop_folder_vc_organiser.svg \
+	    /c8,8 qgn_prop_folder_vc_message.svg \
+	    /c8,8 qgn_prop_folder_vc_media.svg \
+	    /c8,8 qgn_prop_folder_vc_profiles.svg \
+
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/group/vcommand.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project specification file for Voice Commands UI
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET  vcommand.exe
+EPOCSTACKSIZE 0x5000
+TARGETTYPE  exe
+UID  0x100039CE 0x101F8555
+
+VENDORID    VID_DEFAULT
+
+SOURCEPATH ../src
+SOURCE   vcapp.cpp
+SOURCE   vcdocument.cpp
+SOURCE   vcappui.cpp
+SOURCE   vcgenericview.cpp
+SOURCE   vcgenericcontainer.cpp
+SOURCE   vcfolderview.cpp
+SOURCE   vcsettingsengine.cpp
+SOURCE	 vcsettingsview.cpp
+SOURCE	 vcsettingscontainer.cpp
+SOURCE	 vcsettingslist.cpp
+SOURCE	 vctonereader.cpp
+SOURCE	 vcplaybackdialog.cpp
+SOURCE	 vcmodel.cpp
+SOURCE	 vcommanduientry.cpp
+SOURCE	 vcommanduientryarray.cpp
+SOURCE	 vctextquerydialog.cpp
+SOURCE	 vcdoublelargestylelistbox.cpp
+SOURCE	 uiarraysgenerator.cpp
+
+USERINCLUDE  ../rubydebug
+USERINCLUDE  ../inc
+USERINCLUDE  ../../group
+
+
+// This is a SYSTEMINCLUDE macro containing the applications
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE .
+SYSTEMINCLUDE /epoc32/include/mmf/common
+
+START RESOURCE ../data/vcommand.rss
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+LANGUAGE_IDS
+END  // RESOURCE
+
+START RESOURCE ../data/vcommand_reg.rss
+DEPENDS vcommand.rsg
+// Do not change the UID below.
+TARGETPATH /private/10003a3f/apps
+END
+
+CAPABILITY  CAP_APPLICATION MultimediaDD
+
+LIBRARY euser.lib
+LIBRARY apparc.lib
+LIBRARY cone.lib
+LIBRARY eikcore.lib
+LIBRARY eikcoctl.lib
+LIBRARY avkon.lib
+LIBRARY eikctl.lib      // for progressbar
+LIBRARY eikdlg.lib      // for dialogs
+LIBRARY sysutil.lib     // disk space checking
+LIBRARY bafl.lib
+LIBRARY egul.lib        // DrawUtils
+LIBRARY hlplch.lib      // for Help launcher
+LIBRARY profileeng.lib
+LIBRARY estor.lib
+LIBRARY commonengine.lib
+LIBRARY efsrv.lib 
+LIBRARY featmgr.lib
+LIBRARY aknskins.lib
+LIBRARY apgrfx.lib
+LIBRARY mediaclientaudio.lib
+LIBRARY ws32.lib
+LIBRARY nssvasapi.lib
+LIBRARY vcommandhandler.lib
+LIBRARY centralrepository.lib
+
+
+START WINS      
+// wins_specific_information
+END
+
+START MARM
+// marm_specific_information
+END
+
+// End of File
Binary file voiceui/vcommand/help/data/xhtml.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/help/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - Initial contribution
+* 
+* Contributors:
+* 
+* 
+* Description:
+* Export help related files.
+*
+*/
+
+#include <platform_paths.hrh>				
+PRJ_EXPORTS
+:zip ../data/xhtml.zip   /epoc32/data/z/resource/ overwrite
+:zip ../data/xhtml.zip   /epoc32/winscw/c/resource/ overwrite
+
+../inc/vc.hlp.hrh	MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/vc.hlp.hrh)
+../rom/vcommandhelps_variant.iby		CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(vcommandhelps_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/help/inc/vc.hlp.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+	
+//
+// vc.hlp.hrh generated by CSXHelp Utilities.
+//           
+
+#ifndef __VC_HLP_HRH__
+#define __VC_HLP_HRH__
+
+_LIT(KHLP_VC_SIND_FOLDER, "HLP_VC_SIND_FOLDER"); // 
+_LIT(KHLP_VC_SIND_MAIN, "HLP_VC_SIND_MAIN"); // 
+_LIT(KHLP_VC_SET, "HLP_VC_SET"); // 
+_LIT(KVCINFO_HLP_MAINVIEW, "VCINFO_HLP_MAINVIEW"); // 
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/help/rom/vcommandhelps_variant.iby	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file for VCommand helps
+*
+*/
+
+#ifndef __VCOMMANDHELPS_VARIANT_IBY__
+#define __VCOMMANDHELPS_VARIANT_IBY__
+
+#if defined(FF_S60_HELPS_IN_USE) && defined(__SIND)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F8555\contents.zip, RESOURCE_FILES_DIR\xhtml\%02d\0x101F8555\contents.zip)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F8555\index.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F8555\index.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F8555\keywords.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F8555\keywords.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F8555\meta.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F8555\meta.xml)
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/accessorybuttonmonitor.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of CVCAccessoryButtonMonitor
+*
+*/
+
+
+
+#ifndef ACCESSORYBUTTONMONITOR_H
+#define ACCESSORYBUTTONMONITOR_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+/**
+*  @app VCommand.exe
+*/
+class CVCAccessoryButtonMonitor : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CVCAccessoryButtonMonitor* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CVCAccessoryButtonMonitor();
+
+    public: // New functions
+        
+     
+    public: // Functions from base classes
+
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CVCAccessoryButtonMonitor();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private:    // Data
+
+    };
+
+#endif      // ACCESSORYBUTTONMONITOR_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/backup_registration.xml	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="yes"?>
+
+<!-- Copyright (c) 2005, Nokia. Inc. All Rights Reserved -->
+<!-- Voice commands backup registration file -->
+
+<backup_registration version="1.0">
+
+    <proxy_data_manager sid="0x10202BE9" /> 
+
+    <restore requires_reboot = "no"/>
+
+</backup_registration>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/headsetbuttonmonitor.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DOS Server Monitor Class is used to monitor Audio Accessorries,
+*                and encapsulate the interfaces with DOS Server.
+*
+*/
+
+
+
+#ifndef CHeadsetButtonMonitor_H
+#define CHeadsetButtonMonitor_H
+
+#include <e32base.h>
+#include <dossvrservices.h>
+#include <psvariables.h>		// Property values
+
+
+/**
+* DOS Server Monitor Class is used to monitor Audio Accessorries,
+* and encapsulate the interfaces with DOS Server.
+*/
+class CVoiceProgressDialog;
+class CPlaybackVoiceDialog;
+class CHeadsetButtonMonitor : public CDosEventListenerBase
+    {
+    public: // Constructors and destructor
+
+        /**
+        * The CVoiceTagHeadsetButtonMonitor destructor
+        * @param 
+        * @return 
+        */   
+        virtual ~CHeadsetButtonMonitor();
+
+
+        /**
+        * 2nd phase CVoiceTagHeadsetButtonMonitor constructor
+        * @param aObserver - an observer to be notified when the disruption occurred.
+        * @return a pointer to the new CActiveClass0SMSMonitor object
+        */   
+        static CHeadsetButtonMonitor* NewLC();
+
+
+        /**
+        * 2nd phase CVoiceTagHeadsetButtonMonitor constructor
+        * @param aObserver - an observer to be notified when the disruption occurred.
+        * @return a pointer to the new CActiveClass0SMSMonitor object
+        */   
+        static CHeadsetButtonMonitor* NewL();
+
+    public:
+    
+        /**
+        * Method to handle the registration for Audio Accessories disruption monitor.
+        * @param aDisruptionType - a disruption type to be monitored
+        * @return - Symbian standard error response
+        */   
+        TInt ActivateMonitorL();
+
+
+        /**
+        * Method to handle the deregistration of monitoring class 0 SMS
+        * @param aDisruptionType - a disruption type to be stopped monitoring
+        * @return 
+        */  
+        TInt DeActivateMonitor();
+
+        /**
+        * Method to handle the deregistration of monitoring class 0 SMS
+        * @param aDisruptionType - a disruption type to be stopped monitoring
+        * @return 
+        */  
+        void Register(CVoiceProgressDialog* aProgressObserver,CPlaybackVoiceCommandDialog* aPlaybackObserver);
+
+        /**
+        * Method to handle the deregistration of monitoring class 0 SMS
+        * @param aDisruptionType - a disruption type to be stopped monitoring
+        * @return 
+        */  
+        void DeRegister(CVoiceProgressDialog* aProgressObserver,CPlaybackVoiceCommandDialog* aPlaybackObserver);
+
+
+        /**
+        * Method to cancel the monitoring operation from Dos Server
+        * @param 
+        * @return 
+        */   
+        void CancelMonitor();
+
+    protected:
+
+        /**
+        * It notifies about a change in the status of the headset.
+        * @param aStatus The new status.
+        * @return void
+        */ 
+		void HeadsetButtonChangedL(EPSButtonState aState);
+
+        /**
+        * Handles headset button down operation
+        * @return void
+        */
+        void HandleButtonDown();
+        
+        /**
+        * Handles head set button up operation
+        * return void
+        */
+        void HandleButtonUp();
+        
+        /**
+        * Handles head set button long press down operation
+        * return void
+        */
+        void HandleButtonDownLong();
+
+      private:
+
+        /**
+        * 2nd phase CVoiceTagHeadsetButtonMonitor constructor
+        * @param 
+        * @return 
+        */   
+        void ConstructL();
+
+       /**
+        * The CVoiceTagHeadsetButtonMonitor constructor
+        * @param aObserver - an observer to be notified when the disruption occurred.
+        * @return 
+        */   
+        CHeadsetButtonMonitor ();
+
+    private: // data
+
+        RDosServer                   iDosServerSession;
+        CVoiceProgressDialog*        iProgressObserver;
+        CPlaybackVoiceCommandDialog* iPlaybackObserver;
+        TBool                        iButtonDown;
+    };
+
+
+#endif // CHeadsetButtonMonitor_H
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/uiarraysgenerator.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef UIARRAYSGENERATOR_H
+#define UIARRAYSGENERATOR_H
+
+#include <e32base.h>
+
+class CAknIconArray;
+class CDesC16ArrayFlat;
+class CVCModel;
+class CGulIcon;
+
+/**
+ * Encapsulates the listbox element. Including icon, first and second line of the text
+ */
+class CUiEntryData : public CBase
+	{
+	public:
+        /**
+         * @param aIcon. Ownership is tranfered. I.e. the icon will be destroyed,
+         *        when this object is destroyed
+         * @param aFirstLine
+         * @param aSecondLine
+         */
+		static CUiEntryData* NewL( CGulIcon* aIcon, const TDesC& aFirstLine, 
+						         	const TDesC& aSecondLine = KNullDesC );
+
+        static CUiEntryData* NewLC( CGulIcon* aIcon, const TDesC& aFirstLine, 
+                                    const TDesC& aSecondLine = KNullDesC );
+        
+		virtual ~CUiEntryData();
+        
+        /**
+         *  Compares entries alphabetically on the first line value basis. Comparison
+         *  is done with the respect to the locale rules. @see TDesC16::CompareC
+         * 
+         *  @return 1. zero, if the two objects are equal.
+         *          2. a negative value, if the first object is less than the second.
+         *          3. a positive value, if the first object is greater than the second.
+         */
+        TInt CompareByFirstLine( const CUiEntryData& aAnotherEntry ) const;
+        
+        static TInt CompareByFirstLine( const CUiEntryData& entry1, const CUiEntryData& entry2 );
+        
+        /**
+         * Returns the entry icon and tranfers the responsibility to the caller
+         * I.e. after calling this method, this object is not responsible for deleting 
+         * the icon anymore
+         */
+        CGulIcon* ReleaseIcon();
+        
+        const TDesC& FirstLine() const;
+        
+        const TDesC& SecondLine() const;
+        
+        /**
+         * Construct a text ready to be used in the listbox
+         * i.e. "<icon index>\t\FirstLine\tSecondLine"
+         * @param aIconIndex Number to use before the first tab character
+         */
+        TDesC* ConstructListboxItemStringLC( TInt aIconIndex ) const;
+
+    protected:
+        CUiEntryData( CGulIcon* aIcon, const TDesC& aFirstLine, 
+                            const TDesC& aSecondLine );
+
+	private:
+		CGulIcon* iIcon;
+		const TDesC& iFirstLine;
+        const TDesC& iSecondLine;
+	};
+
+class CUiArraysGenerator : public CBase
+	{
+	public:
+		static CUiArraysGenerator* NewLC();
+		
+		/**
+		 * Parses the model into a set of arrays required by the VCommand app ui
+		 * I.e. basing on the "current folder" prepares the arrays for the listbox
+		 * If "current" folder is the main one, it means including all the sub-folders and main
+		 * folder commands. Otherwise, it means including all the current folder commands only
+		 * 
+		 * Both folders and commands are alphabetially sorted.
+		 * All the target arrays are ResetAndDestroyed before the parsing
+		 * 
+		 * @param aSource Model to parse
+		 * @param aCurrentFolderTitle KNullDesC if "curent" folder is the main one
+		 * @param aIconArray icons to display in the listbox. Order is not specified
+		 * @param aFolderTitles List of folder titles in the alphabetical order
+		 * @param aItemIsFolder List of boolean values for all the listbox elements from top 
+		 * 		  to bottom. ETrue for every folder, EFalse for every command
+		 * @param aItemArray List of strings in the listbox expected 
+		 * 		  format ( @see LB_SINGLE_GRAPHIC_HEADING ). Includes:
+		 * 		  * a refence to the icon - zero-based index from the aIconArray
+		 *        * written text of the command
+		 *        * user-specified alternative text or KNullDesC if
+		 * 		
+		 */
+		virtual void FillArraysL( const CVCModel& aSource, const TDesC& aCurrentFolderTitle,
+						  CAknIconArray& aIconArray, CDesC16ArrayFlat& aFolderTitles, 
+						  RArray<TBool>& aItemIsFolder, CDesC16ArrayFlat& aItemArray );
+		
+		/**
+         * Updates a set of arrays required by the VCommand app ui to match current folder names
+         * I.e. basing on the "current folder" prepares the arrays for the listbox
+         * If "current" folder is the main one, it means including all the sub-folders and main
+         * folder commands. Otherwise, it means including all the current folder commands only
+         * 
+         * Both folders and commands are alphabetially sorted.
+         * 
+         * @param aSource Model to parse
+         * @param aCurrentFolderTitle KNullDesC if "curent" folder is the main one
+         * @param aIconArray icons to display in the listbox. Order is not specified
+         * @param aFolderTitles List of folder titles in the alphabetical order
+         * @param aItemIsFolder List of boolean values for all the listbox elements from top 
+         * 		  to bottom. ETrue for every folder, EFalse for every command
+         * @param aItemArray List of strings in the listbox expected 
+         * 		  format ( @see LB_SINGLE_GRAPHIC_HEADING ). Includes:
+         * 		  * a refence to the icon - zero-based index from the aIconArray
+         *        * written text of the command
+         *        * user-specified alternative text or KNullDesC if
+         * 		
+         */					  
+        void UpdateFolderArraysL( const CVCModel& aSource, const TDesC& aCurrentFolderTitle,
+				          CAknIconArray& aIconArray, CDesC16ArrayFlat& aFolderTitles, 
+				          RArray<TBool>& aItemIsFolder, CDesC16ArrayFlat& aItemArray );
+						  
+	protected:		
+        /**
+         * Create entries for all the subfolders in the given folder and sort the entries
+         * alphabetically
+         * @param aSource Model to parse
+         * @param aCurrentFolderTitle KNullDesC for the main folder
+         * @return The array of entries pushed to CS two times. First PopAndDestroy
+         *         will ResetAndDestroy, the second one will delete the array itself
+         */				  
+		virtual RPointerArray<CUiEntryData>* ExtractFoldersAndSortLC2( const CVCModel& aSource, 
+                    const TDesC& aCurrentFolderTitle = KNullDesC );
+
+        /**
+         * Create entries for all the subfolders in the given folder and sort the entries
+         * alphabetically
+         * @param aSource Model to parse
+         * @param aCurrentFolderTitle KNullDesC for the main folder
+         * @return The array of entries pushed to CS two times. First PopAndDestroy
+         *         will ResetAndDestroy, the second one will delete the array itself
+         */               
+        virtual RPointerArray<CUiEntryData>* ExtractCommandsAndSortLC2( const CVCModel& aSource, 
+                    const TDesC& aCurrentFolderTitle = KNullDesC );
+        
+        /**
+         * Fills the arrays required by the ui side with the information from entries
+         * @param aEntries Must contain folder entries only
+         *        FirstLine is FolderListedName
+         * @leave KErrCorrupt if in the aModel there is no command with the folder listed name
+         *          from aEntries
+         */                    
+        virtual void FillFolderTitlesL( RArray<TBool>& aItemIsFolder, 
+                    CDesC16ArrayFlat& aFolderTitles, const CVCModel& aModel,
+                    const RPointerArray<CUiEntryData>& aEntries );
+        
+    };
+	
+#endif //UIARRAYSGENERATOR_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcapp.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application class for vcommand app
+*
+*/
+
+
+#ifndef CVCDAPP_H
+#define CVCDAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidVCommand = { 0x101F8555 };
+
+// CLASS DECLARATION
+
+/**
+* CVCApp application class.
+* Provides factory to create concrete document object.
+*/
+class CVCApp : public CAknApplication
+    {
+    
+    private:
+
+        /**
+        * From CApaApplication
+        * @see CApaApplication for more information
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication
+        * @see CApaApplication for more information
+        */
+        TUid AppDllUid() const;
+  
+    };
+
+#endif  // CVCAPP_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcappui.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,221 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application UI class for vcommand app
+*
+*/
+
+
+#ifndef CVCAPPUI_H
+#define CVCAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknViewAppUi.h>
+#include <AknWaitDialog.h>
+#include <vcommandapi.h>
+#include "vcmodelappuiinterface.h"
+
+class CVCModel;
+class CAppCloser;
+class CVCGenericView;
+
+// CLASS DECLARATION
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+* - view architecture
+* - status pane
+*/
+class CVCAppUi : public CAknViewAppUi, public MVcModelAppUiInterface
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian C++ default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CVCAppUi();
+        
+    public: // Functions from base classes
+    
+        /**
+        * From MVcModelAppUiInterface
+        * Notifies the the command set has changed and the view may need to be
+        * updated
+        */
+        virtual void CommandSetChanged();
+        
+        /**
+        * Called before starting VCommandHandler operations that should be
+        * executed fully before application can be exited. Leave safe operation.
+        * A subsequent call to CleanupStack::PopAndDestroy should be done
+        * after such operations have completed
+        */
+        virtual void StartAtomicOperationLC();
+        
+        /**
+        * From CAknViewAppUi
+        */
+        TBool IsDisplayingMenuOrDialog();
+
+    public: // New Functions
+
+        /**
+        * Sets titlepane text
+        * @param aResourceId id for resource
+        * @return void
+        */
+        void SetTitleL( TInt aResourceId );
+
+        /**
+        * Displays command too short note
+        * @return void
+        */
+        void ShowErrorNoteL( TInt aResourceId );
+
+        /**
+        * Displays name already in use note
+        * @return void
+        */
+        void NameAlreadyInUseNoteL( const TDesC& aName );
+        
+        /**
+        * Displays wait note
+        * @param aText text to be displayed
+        * @return void
+        */
+        void ShowWaitNoteL( const TDesC& aText );
+        
+        /**
+        * Deletes wait note
+        * @return void
+        */
+        void DeleteWaitNoteL();
+
+		/**
+        * Checks if there's call in progress.
+        * @return TInt ESACallNone if there's no active call
+        */
+        TInt CheckCallStateL();
+
+	    /**
+        * Displays call in progress note
+        * @return void
+        */
+        void CallInProgressNoteL();
+        
+        /**
+        *
+        * @return TBool ETrue if there is a video call
+        */
+        TBool IsVideoCallL();
+        
+        /**
+        * Exits the application correctly, taking into account whether a call
+        * has been made to NotifyStartOfAtomicOperation
+        * @return void
+        */        
+        void ExitProgram();
+        
+        /**
+        * Exits the application
+        */
+        void DoExitProgram();
+        
+        /**
+        * Calls CAppCloser::Call. CAppCloser::RunL will eventually exit the
+        * application.
+        */
+        void ExitProgramDeferred();
+
+
+    private: // Functions from base classes
+
+        /**
+        * From MEikMenuObserver
+        * @see MEikMenuObserver for more information
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+        /**
+        * From CEikAppUi
+        * @see CEikAppUi for more information
+        */
+        void HandleCommandL( TInt aCommand );
+        
+        /**
+        * From CEikAppUi
+        * Handle skin change event.
+        */
+        void HandleResourceChangeL( TInt aType );
+        
+    private: // New functions
+    
+        /**
+        * Runs the EndAtomicOperation when calling CleanupStack::PopAndDestroy after
+        * a call to StartAtomicOperationLC
+        */
+        static void CleanupEndAtomicOperation( TAny* aService );
+        
+        /**
+        * Creates and pushes to cleanup stack a TCleanupItem that calls
+        * EndAtomicOperation when CleanupStack::PopAndDestroy is called
+        */
+        void CreateAndPushEndAtomicCleanupItemL();
+        
+        /**
+        * Called after VCommandHandler operations that need to be operated
+        * fully before application can be exited have been completed.
+        */
+        void EndAtomicOperation();
+
+    
+    private: // data
+        
+        // Wait dialog for command editing
+        CAknWaitDialog*                 iWaitNote;
+        
+        // Indicates that an operation has to be finished before the
+        // application can be exited
+        TBool                           iOperationInProgress;
+        
+        // Indicates that an request for exiting the application has been made
+        TBool                           iExitRequested;
+      
+        // Active object used to close the application
+        CAppCloser*				        iCloser;
+        
+        friend class CAppCloser; 
+        
+        CVCGenericView*                 iMainView;
+        
+        CVCGenericView*                 iFolderView;
+        
+        CVCModel*                       iModel;
+    };
+
+#endif  // CVCAPPUI_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcdocument.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Document class for vcommand app
+*
+*/
+
+
+
+#ifndef CVCDOCUMENT_H
+#define CVCDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+* CVCDocument application class.
+*/
+class CVCDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CVCDocument* NewL(CEikApplication& aApp);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCDocument();
+        
+    private: // New Functions
+
+        /**
+        * C++ default constructor.
+        * @param aApp reference to application object.
+        */
+        CVCDocument(CEikApplication& aApp);
+        
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // Functions from base classes
+
+        /**
+        * From CEikDocument
+        * £see CEikDocument for more information
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif  // CVCDOCUMENT_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcdoublelargestylelistbox.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Listbox for commands
+*
+*/
+
+
+#ifndef CVCDOUBLELARGESTYLELISTBOX_H
+#define CVCDOUBLELARGESTYLELISTBOX_H
+
+// INCLUDES
+#include <aknlists.h>
+
+class MEikScrollBarObserver;
+
+// CLASS DECLARATION
+/**
+* 
+*
+*/
+NONSHARABLE_CLASS( CVCDoubleLargeStyleListBox ) : public CAknDoubleLargeStyleListBox
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CVCDoubleLargeStyleListBox* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCDoubleLargeStyleListBox();
+        
+        /**
+         * Adds scroll bar observer
+         *
+         * @param aObserver Observer class
+         */
+        void AddScrollBarObserver( MEikScrollBarObserver* aObserver );
+                                
+    public:   // Functions from base classes
+    
+        /**
+         * From CAknDoubleLargeStyleListBox
+         * @see CAknDoubleLargeStyleListBox for more information
+         */
+        void HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType );
+                             
+    private:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CVCDoubleLargeStyleListBox();
+        
+    private:  // Data
+    
+        MEikScrollBarObserver* iObserver;
+};
+
+#endif  // CVCDOUBLELARGESTYLELISTBOX_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcfolderview.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  View class for folders
+*
+*/
+
+
+#ifndef CVCFOLDERVIEW_H
+#define CVCFOLDERVIEW_H
+
+// INCLUDES
+#include "vcgenericview.h"
+#include "vcmodel.h"
+
+// CLASS DECLARATION
+
+/**
+ * CVCFolderView view class. Inherited from a base class CVCGenericView.
+ */
+class CVCFolderView : public CVCGenericView 
+    {
+    public: // Constructors and destructor
+
+        /**
+         * Constructor.
+         *
+         * @param aService reference to VC API
+         */
+        CVCFolderView( /*CVCommandHandler& aService,*/
+                       CVCModel& aModel );
+
+    public: // Functions from base classes
+
+        /**
+         * From CAknView
+         * Returns folder view's id.
+         * @see CAknView for more information
+         */
+        TUid Id() const;
+    };
+
+#endif  // CVCFOLDERVIEW_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcgenericcontainer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,380 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Container class for vcommand app
+*
+*/
+
+
+
+#ifndef CVCGENERICCONTAINER_H
+#define CVCGENERICCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <coedef.h> 
+#include <bamdesca.h> 
+#include <barsread.h>
+#include <badesca.h>
+#include <aknlists.h>
+#include <AknIconArray.h>
+#include <eiksbobs.h> 
+#include <AknWaitDialog.h>
+#include <AknInfoPopupNoteController.h>
+#include <data_caging_path_literals.hrh>
+#include <csxhelp/vc.hlp.hrh>
+
+#include "vcgenericview.h"
+#include "vcommandconstants.h"
+#include "vcmodel.h"
+
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CEikFormattedCellListBox;
+
+// CLASS DECLARATION
+
+/**
+* CVCommandGenericContainer container control class.
+*/
+class CVCGenericContainer : public CCoeControl,
+                            public MCoeControlObserver,
+                            public MEikListBoxObserver,
+                            public MEikScrollBarObserver
+    {
+
+    public: // Constructors and destructor
+        
+        /**
+         * C++ constructor.
+         *
+         * @param aMenubar a menubar
+         * @param aView a pointer to view class
+         */
+        CVCGenericContainer::CVCGenericContainer( CEikMenuBar* aMenuBar,
+                                                  CVCModel& aModel, 
+                                                  CVCGenericView& aView );
+
+        /**
+         * Symbian default constructor.
+         *
+         * @param aRect Frame rectangle for container.
+         */
+        void ConstructL( const TRect& aRect );
+
+        /**
+         * Destructor.
+         */
+        ~CVCGenericContainer();
+        
+    public: // Functions from base classes
+    
+        /**
+         * From CoeControl
+         *
+         * @see CCoeControl for more information
+         */
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+
+
+    public: // New functions
+
+        /**
+         * Returns the focused item on listbox
+         *
+         * @return TInt Id of the focused item
+         */
+        TInt CurrentSelection() const;
+        
+        /**
+         * Sets the focused item on listbox
+         *
+         * @return void
+         */
+        void SetCurrentSelection( TInt aIndex );
+    
+        /**
+         *
+         * @return TInt the number of items in the list box
+         */
+        TInt ListBoxCount() const;
+    
+        /**
+         * Returns the first line name.
+         *
+         * @param aIndex list item index
+         * @return const TDesC& first row name
+         */
+        TDesC* GetFirstRowNameLC( TInt aIndex ) const;
+        
+        /**
+         * Returns the second line name.
+         *
+         * @param aIndex list item index
+         * @return const TDesC& second row name
+         */
+        TDesC* GetSecondRowNameLC( TInt aIndex ) const;
+        
+        /**
+         * Returns a title that is to be shown in folder view.
+         *
+         * @param aIndex list item index
+         * @return TPtrC folder title name
+         */
+        TPtrC GetFolderTitle( TInt aIndex );
+        
+        /**
+         * Returns true if pointed listbox item is a folder.
+         *
+         * @param aListBoxIndex index of listbox item
+         * @return ETrue if item is a folder
+         */
+        TBool IsItemFolderL( TInt aListBoxIndex ) const;
+        
+        /**
+         * Shows the Edit command text query.
+         *
+         * @return void
+         */
+        void ShowEditTextL();
+        
+        /**
+         * Shows delete application query
+         * and handles the voice tag deletion
+         *
+         * @return void
+         */
+        void DeleteVCommandL();
+        
+        /**
+         * Returns ETrue if event is under processing at the moment.
+         *
+         * @return ETrue if event handling process is running
+         */
+        TBool IsHandlingKeyPressInProgress();
+        
+        /**
+         * Sets event handling state.
+         *
+         * @param aValue new status for event handling process
+         * @return void
+         */
+        void SetHandlingKeyPressInProgress( TBool aValue );
+        
+        void RefreshListboxL( CVCommandUiEntryArray& oldCommands,
+                              CVCommandUiEntryArray& newCommands );
+                              
+        /**
+         * Shows tooltip text for item.
+         *
+         * @param aItemIndex index of the listbox item
+         */
+        void ShowTooltipL( TInt aItemIndex );
+
+
+    protected: // Functions from base classes
+    
+        /**
+         * From MEikListBoxObserver
+         * @see MEikListBoxObserver for more information
+         */
+        void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
+        
+        /**
+         * From MEikScrollBarObserver
+         * @see MEikScrollBarObserver for more information
+         */
+        void HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType );
+
+        /**
+       	 * From CCoeControl.
+       	 *
+       	 * @see CCoeControl for more information
+       	 */
+        void FocusChanged( TDrawNow aDrawNow );
+        
+        /**
+         * From CCoeControl.
+         *
+         * @see CCoeControl for more information
+         */
+        void SizeChanged();
+     
+        /**
+         * From CoeControl.
+         *
+         * @see CCoeControl for more information
+         */
+        TInt CountComponentControls() const;
+
+        /**
+         * From CCoeControl.
+         *
+         * @see CCoeControl for more information
+         */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+
+        /**
+         * From MCoeControlObserver.
+         *
+         * @see MCoeControlObserver for more information
+         */
+        void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
+        
+        /**
+         * From CCoeControl
+         *
+         * @see CCoeControl for more information
+         */
+        void HandleResourceChangeL( TInt aType );      
+        
+        /**        
+         * From CCoeControl
+         *
+         * @see CCoeControl for more information
+         */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+        
+    private: // New functions
+
+        /**
+         * Constructs status pane
+         *
+         * @param aResourceId
+         */
+        void SetTitlePaneL( TInt aResourceId ) const;
+        
+        /**
+         * Constructs the listbox.
+         */
+        void ConstructListBoxL();
+
+        /**
+         * Initializes the listbox. 
+         */
+        void PopulateListBoxL();
+        
+        /**
+         * Checks if the user edited name is valid.
+         * 
+         * @param aName name to check
+         * @return TBool ETrue if name exists or is too short.
+         */
+        TBool CheckNameValidityL( const TDesC& aName );
+        
+        /**
+         * Sets the new text to the list.
+         * 
+         * @param aIndex The index of an application
+         * @param aNewText the text that replaces the old one
+         * @param aOldText the old text
+         */
+        void UpdateTextL( TInt aIndex, const TDesC& aNewText,
+                          const TDesC& aOldText );
+        
+        /**
+         * Sorts the contents of the iItemNameArray to an alphabetical order.
+         */
+        void SortItemListL();
+        
+        /**
+        * Finds the commands that should be added to the listbox
+        * @param oldCommands A list of commands before an update
+        * @param newCommands A list of commands after an update
+        * @return RArray<CVCommand> Commands that need to be removed from the
+        *         listbox
+        */
+        RArray<CVCommandUiEntry> FindCommandsToBeAddedL(
+            CVCommandUiEntryArray& oldCommands, CVCommandUiEntryArray& newCommands );
+                        
+        /**
+        * Adds items to the listbox.
+        * @param aCommands Commands to be added
+        */
+        void AddCommandsL( RArray<CVCommandUiEntry>& aCommands );
+        
+        /**
+        * Finds the commands that should be removed from the listbox
+        * @param oldCommands A list of commands before an update
+        * @param newCommands A list of commands after an update
+        * @return RArray<CVCommand> Commands that need to be added to the
+        *         listbox
+        */
+        RArray<CVCommandUiEntry> FindCommandsToBeRemovedL(
+            CVCommandUiEntryArray& oldCommands, CVCommandUiEntryArray& newCommands );
+            
+        /**
+        * Removes items from listbox
+        * @param aCommands Commands to be removed
+        */
+        void RemoveCommands( RArray<CVCommandUiEntry>& aCommands );
+        
+        /**
+        * Searches for a string in listbox item array.
+        * @param aText The search string
+        * @return TInt Index in the array where the string was found.
+        *         KErrNotFound if the string was not found.
+        */
+        TInt SearchItemArrayL( const TDesC& aText );
+        
+        /**
+        * Utility function for listbox item creation
+        * @param aIconArrayIndex Icon array index for this item
+        * @param aFirstRow First row for this item
+        * @param aSecondRow Second row for this item
+        * @return TDesC* A new listbox item
+        */
+        TDesC* CreateListboxItemLC( TInt aIconArrayIndex,
+                                    const TDesC& aFirstRow,
+                                    const TDesC& aSecondRow );
+
+        /**
+        * Checks for critical level flash and shows "no memory" note if needed
+        *
+        * @return ETrue if CL would be reached after this operation.
+        */
+        TBool CheckCriticalLevelL();
+
+    private: // data
+    
+        CEikMenuBar*                    iMenuBar;           // Not owned
+        CVCGenericView&                 iView;
+        
+        CVCModel&                       iModel;
+        
+        //CEikTextListBox*                iListBox;           // Owned
+        CEikFormattedCellListBox*       iListBox;           // Owned
+        
+        // Displayed names for the items in listbox
+        CDesC16ArrayFlat*               iItemArray;     // Not owned
+        
+        // Titles for different folders in folder view
+        CDesC16ArrayFlat*               iFolderTitles;
+        
+        // Corresponds index by index with the items in iItemNameArray.
+        // Stores information on whether an item is a folder
+        RArray<TBool>                   iItemIsFolder;
+        
+        CAknInfoPopupNoteController*    iPopupController;   // Owned
+        
+        TBool                           iHandlingKeyPressInProgress;
+        
+    };
+
+#endif // CVCGENERICCONTAINER_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcgenericview.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  View class for vcommand app
+*
+*/
+
+
+#ifndef CVCGENERICVIEW_H
+#define CVCGENERICVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+#include <vcommandapi.h>
+
+#include "vcmodel.h"
+
+// FORWARD DECLARATIONS
+class CVCAppUi;
+class CVCGenericContainer;
+class CAknProgressDialog;
+class CEikProgressInfo;
+class CCoeEnv;
+
+
+// CLASS DECLARATION
+
+/**
+ * CVCGenericView view class. 
+ */
+class CVCGenericView : public CAknView
+    {
+
+    public: // Constructors and destructor
+
+        /**
+         * Constructor.
+         *
+         * @param aService reference to VC API
+         */
+        CVCGenericView( CVCModel& aModel );
+
+        /**
+         * Symbian C++ default constructor.
+         * @param aResource view resource id from the compiled resource file
+         */
+        void ConstructL( TInt aResourceId );
+
+        /**
+         * Destructor.
+         */
+        ~CVCGenericView();
+
+
+    public: // Function from base classes
+    
+        /**
+         * From CAknView
+         *
+         * @see CAknView for more information
+         */
+        void HandleCommandL( TInt aCommand );
+
+        /** 
+         * Handle screen size change.
+         */
+        void HandleSizeChange();
+        
+        /**
+         * From CAknView
+         * @see CAknView for more information
+         */
+        TUid Id() const;      
+
+
+    public: // New functions
+    
+         /**
+         * Handles basic commands like editing and playing items and opening views.
+         * To make sure only one event is handled each time, HandleCommandL should be 
+         * called instead.
+         * 
+         * @param aCommand command to handle
+         */
+        void DoHandleCommandL( TInt aCommand );
+        
+        /**
+         * Returns the title of the folder where this view is active.
+         *
+         * @return TPtrC name of the item folder in listbox
+         */
+        const TDesC& FolderTitle() const;
+        
+         /**
+         * Sets the middle softkey label. 
+         * @param aIndex index in listbox
+         */
+        void SetMiddleSoftkeyLabelL( TInt aIndex ) const;
+        
+        /**
+        * Refreshes the view to the current voice commands status
+        */
+        void RefreshViewL();
+    
+    
+    private: // Functions from base classes
+
+        /**
+         * From CAknView
+         * @see CAknView for more information
+         */
+        void HandleClientRectChange();
+
+        /**
+         * From MEikMenuObserver
+         * This function defines how to show menupanel.
+         *
+         * @see MEikMenuObserver for more information
+         */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+        /**
+         * From CAknView
+         *
+         * @see CAknView for more information
+         */
+        void DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, 
+                                  const TDesC8& aCustomMessage );
+
+        /**
+         * From CAknView
+         * @see CAknView for more information
+         */
+        void DoDeactivate();
+
+
+    private: // New functions
+
+        /**
+		 * Displays cannot delete error note.
+		 */
+        void CannotDeleteNoteL();
+        
+        /**
+         * Shows playback voice command progress dialog.
+         */
+        void PlaybackVoiceCommandL();
+        
+        /**
+         * Launches demo VoiceUI.
+         */
+        void LaunchDemoVoiceUiL() const;
+
+        /**
+         * Sets the current folders title
+         * 
+         * @see CVCFolderInfo::Title
+         * @param aNewName new name for folder
+         */
+        void SetFolderTitleL( const TDesC& aNewName );
+        
+        /**
+         * Sets the middle softkey label.
+         * @param aResourceId Label text from resource file
+         * @param aCommandId Menu c
+         */                          
+        void DoSetMiddleSoftKeyLabelL( const TInt aResourceId,
+                                       const TInt aCommandId  ) const;
+
+        /**
+         * Remove MSK command mappings.
+         */                          
+        void RemoveCommandFromMSK() const;
+     
+    private: // data        
+    
+        HBufC*                          iFolderName;
+        CVCModel&                       iModel;
+        CVCGenericContainer*            iContainer;
+        // Array of voice commands
+        CVCommandArray*                 iCommands;
+        // The focused index in listbox. Used to set the correct focus when
+        // returning from folder or settings view
+        TInt                            iFocusedIndex;
+            
+    };
+
+#endif  // CVCGENERICVIEW_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcmodel.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Model class for vcommand application wrapping CVCommandHandler
+*
+*/
+
+
+#ifndef CVCMODEL_H
+#define CVCMODEL_H
+
+// INCLUDES
+#include <vcommandapi.h>
+#include "vcommanduientry.h"
+#include "vcommanduientryarray.h"
+#include "vcmodelappuiinterface.h"
+
+//class MVcModelAppUiInterface;
+
+// CLASS DECLARATION
+
+/**
+* Wraps a list voice commands (CVCommand-objects wrapped in CVCommandUiEntry-
+* objects). 
+*/
+class CVCModel : public CBase, public MVCommandHandlerObserver
+    {
+    public: // Constructor and destructor
+    
+        /**
+        * Two-phased constructor.
+        */
+        static CVCModel* NewL( MVcModelAppUiInterface* aAppUi );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CVCModel();
+        
+    public: // Functions from base classes
+    
+        /**
+        * From MVCommandHandlerObserver. Is called whenever the VCommand set is
+    	* changed by another instance of CVCommandHandler (not the one this
+    	* class wraps. This function, however,does not load the new set.
+        */
+        void CommandSetChanged();
+        
+    public: // New Functions
+    
+        /**
+        * Returns a CVCommandUiEntry-object based on its written text. If a
+        * command matching with the written text is not found, this function
+        * leaves
+        * @param aWrittenText Text displayed in for this voice command
+        * @return CVCommandUiEntry
+        */
+        virtual const CVCommandUiEntry& GetVCommandL( const TDesC& aWrittenText );
+        
+        /**
+        * Returns a CVCommandUiEntry-object.
+        * @param aIndex Commands index in the list of commands
+        */
+        virtual const CVCommandUiEntry& At( TInt aIndex ) const;
+        
+        /**
+        * Loads vcommands from CVCommandHandler
+        */
+        virtual void LoadVCommandsL();
+        
+        /**
+        * Sets a new spoken text for a voice vommand.
+        * @param aWrittenText Text displayed for this voice command
+        */
+        virtual void SetNewSpokenTextL( const TDesC& aWrittenText, const TDesC& aNewSpokenText );
+        
+        /**
+        * Returns a boolean value on whether a voice command with a given written text exists.
+        * @param aWrittenText Text displayed in listbox for this voice command
+        * @return TBool
+        */
+        virtual TBool HasCommandL( const TDesC& aWrittenText );
+        
+        /**
+        * Returns the number of voice commands
+        * @return TInt
+        */
+        virtual TInt Count() const;
+        
+        /**
+        * Returns a list of CVCommandUiEntry-objects. Ownership of the array
+        * is passed to the client.
+        * @return CVCommandUiEntryArray
+        */
+        CVCommandUiEntryArray* VCommandArrayL();
+        
+        /**
+        * Returns a CVCommandHandler-object this class wraps.
+        */
+        CVCommandHandler& Service();
+        
+    protected:
+        /**
+        * C++ default constructor.
+        */
+		CVCModel( MVcModelAppUiInterface* aAppUi );
+        
+	private:
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+		void ConstructL();
+		
+    private: // New Functions
+    
+        /**
+        * Utility function returning the index of a voice command in the list
+        * of voice commands
+        * @param aWrittenText Text displayed in listbox for a voice command
+        * @return TInt
+        */
+        TInt FindVCommandIndexL( const TDesC& aWrittenText );        
+    
+    private: // data
+    
+        MVcModelAppUiInterface* iAppUi;
+    
+        CVCommandHandler*       iVcHandler;
+        
+        CVCommandUiEntryArray*  iListBoxVCommands;
+    };
+
+#endif  // CVCMODEL_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcmodelappuiinterface.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface implemented by the application ui class to abstract
+*                the relation with the model class
+*
+*/
+
+
+#ifndef MVCMODELAPPUIINTERFACE_H
+#define MVCMODELAPPUIINTERFACE_H
+
+// CLASS DECLARATION
+
+class MVcModelAppUiInterface
+    {
+    public: 
+        /**
+        * Notifies the the command set has changed and the view may need to be
+        * updated
+        */
+        virtual void CommandSetChanged() = 0;
+        
+        /**
+        * Called before starting VCommandHandler operations that should be
+        * executed fully before application can be exited. Leave safe operation.
+        * A subsequent call to CleanupStack::PopAndDestroy should be done
+        * after such operations have completed
+        */
+        virtual void StartAtomicOperationLC() = 0;
+    };
+
+#endif  // MVCMODELAPPUIINTERFACE_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcommand.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains declarations for constants of Voice Commands UI.
+*
+*/
+
+
+#ifndef VCOMMAND_HRH
+#define VCOMMAND_HRH
+
+enum TVCCommandIds
+    {
+    EVCCmdOpen = 1,
+    EVCCmdEdit,
+    EVCCmdPlayback,
+    EVCCmdDelete,
+    EVCCmdSettings,
+    EVCCmdStartVui,
+    EVCCmdRemove,
+    EVCCmdShowMenuBar,
+    EVCCmdIgnore // do nothing
+    };
+
+enum TVCSettingsCommandIds
+    {
+    EVCCmdChange = 1,
+    EVCMenuCmdChange,
+    EVCCmdReset
+    };
+
+enum TVCSettingsItemIds
+    {
+    EVCSynthesizerItem,
+    EVCVolumeItem,
+    EVCRejectionItem,
+    EVCVerificationItem,
+    EVCResetItem
+    };
+
+
+enum VTCommand
+    {
+    EVCommandSoftKeyQuit=3
+    };
+    
+enum DialogControlId
+    {
+    EVoicePlaybackProgressNoteId = 100
+    };
+
+// Control ids for dialogs
+enum TDeleteDialogControlId
+    {
+    EVCWaitNote = 1, 
+    EVCProgressNote
+    };
+
+enum TVCDialogId
+    {
+    EVCSettingsListboxId = 1    //Dialog control ID can't be zero
+    };
+
+enum TVcSynthesizerSettingItem
+    {
+    ESynthesizerOff,
+    ESynthesizerOn
+    };
+    
+enum TVcVerificationSettingItem
+    {
+    EAutomatic,
+    EManual,
+    EVoice
+    };
+
+// Define edwin width and maxlength for Edit label
+#define KMaxEditableTextLength 64
+#define KMaxEditWidthLength 64
+
+#endif      // VCOMMAND_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcommandconstants.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Constants for the Voice commands UI
+*
+*/
+
+
+#ifndef VCOMMANDCONSTANTS_H
+#define VCOMMANDCONSTANTS_H
+
+const TUid KUidVCMainView = { 1 };
+const TUid KUidVCSettingsView = { 3 } ;
+const TUid KUidVCFolderView = { 4 };
+
+const TInt KVCMaxNameSize = 128;
+
+// Middle Softkey control ID.
+const TInt KVcMskControlID = 3;
+
+// Setting items default values
+//
+const TInt KSettingsRejection( 5 );
+const TInt KSettingsVolume( 5 );
+const TInt KSettingsVerification( 0 );
+
+// UID of the Help
+const TUid KUidHelp = { 0x101F8555 };
+const TUid KVoiceUiUid = { 0x101F8543 };
+
+#endif      // VCOMMANDCONSTANTS_H   
+   
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcommandinternalcrkeys.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Voice Command Settings API CenRep definitions.
+*
+*/
+
+
+#ifndef VCOMMANDINTERNALCRKEYS_H
+#define VCOMMANDINTERNALCRKEYS_H
+
+#include <vcommanddomaincrkeys.h>
+
+#endif // VCOMMANDINTERNALCRKEYS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcommanduientry.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class to wrap a CVCommand object
+*
+*/
+
+
+#ifndef CVCOMMANDUIENTRY_H
+#define CVCOMMANDUIENTRY_H
+
+#include <e32base.h>
+
+class CVCommand;
+class CVCModel;
+class CGulIcon;
+class CVCommandHandler;
+class MNssPlayEventHandler;
+
+// CLASS DECLARATION
+
+/**
+* Class to wrap a CVCommand-object for abstraction and for simplified use.
+*/
+class CVCommandUiEntry : public CBase
+    {
+    public: // Constructor and destructor
+    
+        /**
+        * Two-phased constructor.
+        */
+        static CVCommandUiEntry* NewL( const CVCommand& aCommand );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CVCommandUiEntry();
+        
+    public: // New Functions
+
+        /**
+        * @return Unmodifiable user-specified shortcut for the command
+        *         KNullDesC if none
+        */
+        virtual const TDesC& UserText() const;
+        
+        /**
+        * @return Unmodifiable written text
+        */
+        virtual const TDesC& WrittenText() const;
+        
+        /**
+        * @return the text that the user is expected to pronounce
+        */
+        virtual const TDesC& SpokenText() const;
+        
+        /**
+        * @return the user specified text that the user can pronounce to
+        *         recognize the command. Is always identical to UserText
+        */
+        virtual const TDesC& AlternativeSpokenText() const;
+        
+        /**
+         * Version of the title shown when the folder is displayed in the list
+         * of voice commands
+         */
+        virtual const TDesC& FolderListedName() const;
+        
+        /**
+         * Returns folder title to be shown at the top of the screen
+         */
+        virtual const TDesC& FolderTitle() const;
+        
+        /**
+         * Returns folder title to be shown at the top of the screen
+         */
+        virtual const TDesC& Tooltip() const;
+        
+	    /**
+        * Creates the command icon.
+        * @return The command icon pushed to the cleanup stack
+        */
+        virtual CGulIcon* IconLC() const;
+        
+	    /**
+        * Creates an icon for the folder to which this command belongs to.
+	    * @return Icon for the folder
+	    */
+        virtual CGulIcon* FolderIconLC() const;
+        
+        /**
+        * Asynchronous
+        * Attempts to play the text expected to be recognized.
+        */
+        virtual void PlaySpokenTextL( CVCommandHandler& aService, 
+            MNssPlayEventHandler& aPlayEventHandler ) const;
+        
+        /**
+        * Asynchronous
+        * Plays the user-specified alternative spoken text.
+        */
+        virtual void PlayAlternativeSpokenTextL( CVCommandHandler& aService,
+            MNssPlayEventHandler& aPlayEventHandler ) const;
+          
+        /**
+        * Cancels playback of a spoken or alternative spoken text
+        * @param aHandler CVCommandHandler where the command is stored
+        */  
+        virtual void CancelPlaybackL( CVCommandHandler& aService ) const;
+        
+        /**
+        * Checks whether this voice command object is equivalent to another one
+        * @param aCommand A voice command to compare
+        * @return TBool
+        */  
+        TBool operator==( const CVCommandUiEntry& aCommand ) const;
+        
+        /**
+        * Utility function for getting the CVCommand-object this class wraps.
+        */
+        const CVCommand& Command() const;
+        
+	protected:
+	
+	    /**
+        * Constructor
+        */
+        CVCommandUiEntry( const CVCommand& aCommand );
+    
+    private: // data
+        const CVCommand& iCommand;
+    };
+
+#endif  // CVCOMMANDUIENTRY_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcommanduientryarray.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A list of CVCommandUiEntry-objects
+*
+*/
+
+
+#ifndef CVCOMMANDUIENTRYARRAY_H
+#define CVCOMMANDUIENTRYARRAY_H
+
+// INCLUDES
+#include <vcommandapi.h>
+#include "vcommanduientry.h"
+
+/** Array of pointers to CVCommandUiEntrys */
+typedef RPointerArray<CVCommandUiEntry> RVCommandUiEntryArray;
+
+/**
+* Non-modifiable list of CVCommandUiEntrys
+*/
+class CVCommandUiEntryArray : public CBase
+	{
+	public:
+		/** 
+		* Constructs the non-modifiable CVCommandUiEntryArray
+		* @param aSource Commands to store. CVCommandUiEntryArray makes
+		*        copies of them. Ownership is passed to this class.
+		*/
+		static CVCommandUiEntryArray* NewL( CVCommandArray* aArray );
+		
+		/**
+		* Destructor
+		*/
+        virtual ~CVCommandUiEntryArray();
+		
+		/**
+		* Returns the reference to the command stored in this
+		* CVCommandUiEntryArray
+		* @param The position of the object pointer within the array. This
+		*        value must not be negative and must not be greater than the
+		*        number of objects currently in the array, otherwise the
+		*        operator raises a USER-130 panic.
+		* @return Unmodifiable reference to CVCommandUiEntry
+		*/
+		const CVCommandUiEntry& At( TInt aIndex ) const;
+		
+		/**
+		* Equivalent to the operator At
+		* @see At()
+		*/
+		const CVCommandUiEntry& operator[]( TInt aIndex ) const;
+
+		/** 
+		* Returns the number of commands
+		* @return TInt The number of voice commands
+		*/
+		TInt Count() const;
+		
+		/*
+		* Creates a copy of this object. Ownership is passed to the caller.
+		* @return CVCommandUiEntryArray* Pointer to a CVCommandUiEntryArray
+		*         object
+		*/
+		CVCommandUiEntryArray* CloneL();
+		
+	private:
+	
+	    /**
+        * Constructor
+        */
+	    CVCommandUiEntryArray( CVCommandArray* aArray );
+	
+	    /**
+        * Symbian C++ default constructor.
+        */ 
+		void ConstructL();
+		
+	private:
+	
+		CVCommandArray*        iCommands;
+        
+        RVCommandUiEntryArray  iListBoxCommands;
+	};
+	
+#endif  // CVCOMMANDUIENTRYARRAY_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcplaybackdialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of class used for the playback of a voice tag
+*
+*/
+
+
+#ifndef VCPLAYBACKDIALOG_H
+#define VCPLAYBACKDIALOG_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <notecontrol.h>
+#include <eikprogi.h>
+#include <AknProgressDialog.h>
+#include <nssvasmplayeventhandler.h>
+#include <vcommand.rsg>
+#include "vcommand.hrh"
+#include "vcommandconstants.h"
+
+// CONSTANTS
+const TInt KVoiceTagRecordLength = 32;
+const TInt KVoiceTagIncrement = 1;
+const TInt KInterval = 1;
+const TInt KDelay = 1;
+const TInt KMicroSecondsInterval = 125000;
+
+// FORWARD DECLARATIONS
+class CAknProgressDialog;
+class CVCommandUiEntry;
+class CVCommandHandler;
+class CVCommandUiEntry;
+
+
+// CLASS DECLARATION
+
+/**
+* Dialog for voice command playback using TTS
+*/
+class CVCPlaybackDialog : public CAknProgressDialog,
+                          public MNssPlayEventHandler
+    {
+    struct VTimerModel
+        {
+        TInt  iFinalValue;
+        TInt  iHundreths;
+        TInt  iIncrement;
+        TBool iRunning;
+        };
+
+    public: // Constructors and destructor
+
+        /**
+        * C++ default constructor.
+        */
+        CVCPlaybackDialog( CVCommandHandler& iService,
+                           const CVCommandUiEntry& aCommand );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCPlaybackDialog();
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From CAknProgressDialog
+        * @see CAknProgressDialog for more information
+        */
+        void PreLayoutDynInitL();
+
+        /**
+        * From CAknProgressDialog
+        * @see CAknProgressDialog for more information
+        */
+        void PostLayoutDynInitL();
+
+        /**
+        * From CAknProgressDialog
+        * @see CAknProgressDialog for more information
+        */
+        TBool OkToExitL( TInt aButtonId );
+
+    private: // functions from base classes
+
+        /**
+        * From CAknProgressDialog
+        * @see CAknProgressDialog for more information
+        */        
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                     TEventCode aType);
+
+        /**
+        * Called when playing of a voice tag is completed
+        * @param aErrorCode EVasErrorNone if playing was successfull
+        */     
+        void HandlePlayComplete( TNssPlayResult aErrorCode );
+
+        /**
+        * Called when playing of a voice tag is started
+        * @param aDuration - the duration of the utterance data
+        */      
+        void HandlePlayStarted ( TTimeIntervalMicroSeconds32 aDuration );
+
+    private: // New functions
+
+        /**
+        * Starts the timer for the progress bar
+        */
+        void StartTimerL();
+
+        /**
+        * Stops the timer for the progress bar
+        */
+        void StopTimer();
+
+        /**
+        * Called by the timer class for every timer tick
+        * @param aObject Points to same place as the this pointer
+        * @return static TInt
+        */
+        static TInt OnTick( TAny* aObject );
+
+        /**
+        * Called by OnTick() - updates the progress bar
+        */
+        void DoTick();
+
+        /**
+        * Displays error note
+        */
+        void DisplayErrorNoteL();
+      
+        /**
+        * Called when HandlePlayError() completes
+        * @param aResult error code from TPlayResult
+        * @return void
+        */
+        void DoHandlePlayErrorL( TNssPlayResult aResult );
+      
+        /**
+        * Called when HandlePlayStarted() completes
+        * @param aDuration Represents a microsecond time interval stored in 32 bits
+        * @return void
+        */
+        void DoHandlePlayStartedL ( TTimeIntervalMicroSeconds32 aDuration );
+        
+    private: // data
+
+        CPeriodic*                 iProgressBarTimer;
+        CEikProgressInfo*          iProgressInfo;
+        VTimerModel                iTModel;
+        TInt                       iTickCount;
+        TInt                       iExitFlag;
+        TInt                       iExitWhenCalledBack;
+    	TBool					   iOkToExit;
+    	CVCommandHandler&          iService;
+    	const CVCommandUiEntry&    iCommand;
+    };
+
+#endif  // VCPLAYBACKDIALOG_H
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcsettingscontainer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Settings container
+*
+*/
+
+
+#ifndef CVCSETTINGSCONTAINER_H
+#define CVCSETTINGSCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <coedef.h>
+
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class CVCSettingsView;
+class CVCSettingsList;
+CEikButtonGroupContainer;
+
+// CLASS DECLARATION
+
+/**
+* Container for the settings view
+* @since 2.8
+*/
+class CVCSettingsContainer : public CCoeControl,
+								             public MCoeControlObserver,
+								             public MEikListBoxObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+        * C++ constructor.
+        */
+        CVCSettingsContainer( CEikButtonGroupContainer& aCbaGroup );
+
+        /**
+        * Symbian OS default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCSettingsContainer();
+        
+    public: // Functions from base classes
+        
+        /**
+        * From CCoeControl
+        * Gives the help context to be displayed
+        * @param aContext help context related to current view
+        */
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+        
+        /**
+		    * From MEikListBoxObserver
+		    * @see MEikListBoxObserver for more information
+		    */
+		    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+    public: // New functions
+
+        /**
+        * Open setting page for currently selected setting item.
+        * @param aCalledFromMenu True if editing command was chosen from the
+                 options menu 
+		* @return void
+        */
+        void EditCurrentL(  TBool aCalledFromMenu );
+
+		/**
+		* Shows reset confimation dialog
+		* @return void
+		*/
+		void ResetL();
+
+        /**
+        * Save all settings.
+		* @return void
+        */
+        void SaveSettingsL();
+
+		/**
+        * Returns current listbox index
+		* @return void
+        */
+		TInt CurrentItemIndex() const;
+
+        /**
+        * Returns the size of the list box.
+        *
+        */
+		TInt ItemListSize() const;
+		
+		/**
+		* Returns the setting item identifier for the current setting item.
+        * @return TInt The setting item identifier
+		*/
+		TInt CurrentItemIdentifier() const;
+		
+		/**
+        * Sets the middle softkey label. NOTE: this should be handled in the
+        * view class in a normal case where container would call this function
+        * after focused item has changed. But since there are two view classes
+        * (normal and plugin) that both use this container class, we can
+        * only have a pointer to the views' super class.
+        */
+        void SetMiddleSoftkeyLabelL() const;
+		
+
+    protected: // Functions from base classes
+
+        /**
+        * From CCoeControl return the number of controls owned
+        * @return TInt number of controls
+        */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl returns a control
+        * @param aIndex index of a control
+        * @return CCoeControl* pointer on a control
+        */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+        * From CCoeControl event handling section
+        * @param aKeyEvent the key event
+        * @param aType the type of the event
+        * @return TKeyResponse key event was used by this control or not
+        */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                     TEventCode aType );
+
+		/**
+       	* From CCoeControl
+       	* @see CCoeControl for more information
+       	*/
+        void FocusChanged(TDrawNow aDrawNow);
+
+		/**
+        * From CCoeControl
+        * @see CCoeControl for more information
+        */
+        void SizeChanged();
+
+        /**
+        * From CCoeControl
+        * @see CCoeControl for more information
+        */
+        void HandleResourceChange(TInt aType);      
+        
+        /**
+        * From MCoeControlObserver
+        * @see MCoeControlObserver for more information
+        */
+        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);        
+        
+	private:
+
+		/**
+        * returns title resource id
+        * @return TInt
+        */
+        TInt TitleResourceId() const;
+        
+        /**
+         * Sets the middle softkey label.
+         * @param aResourceId Label text from resource file
+         * @param aCommandId Menu c
+         */                          
+        void DoSetMiddleSoftKeyLabelL( const TInt aResourceId,
+                                       const TInt aCommandId  ) const;
+
+        /**
+         * Remove MSK command mappings.
+         */                          
+        void RemoveCommandFromMSK() const;
+        
+    private: //data
+    
+        CVCSettingsList*	iSettingsList;
+        CEikButtonGroupContainer& iCbaGroup;
+        
+	};
+
+#endif // CVCSETTINGSCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcsettingsengine.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the CVCSettingsEngine
+*
+*/
+
+
+#ifndef CVCSETTINGSENGINE_H
+#define CVCSETTINGSENGINE_H
+
+
+//  INCLUDES
+#include <e32base.h>
+#include <nssvasapi.h>
+#include <nssvasmresetfactorymodelsclient.h>
+#include <aknnotewrappers.h>
+
+// FORWARD DECLARATIONS
+class CAknKeySoundSystem;
+
+// CLASS DECLARATION
+
+/**
+* Definition of CVCSettingsEngine
+*/
+class CVCSettingsEngine : public CBase,
+                              public MNssResetFactoryModelsClient
+
+    {
+    
+    public:  // Constructors and destructor
+
+         /**
+         * Two-phased constructor.
+         */
+         static CVCSettingsEngine* NewL();
+        
+         /**
+         * Destructor.
+         */
+         virtual ~CVCSettingsEngine();
+
+    public:  // New Functions
+
+        /**
+        * Resets the adapted models
+        * @return void
+        */
+        void ResetAdaptationL();
+
+    protected: // Functions from base classes
+
+        /**
+        * From MNssResetFactoryModelsClient
+        * @see MNssResetFactoryModelsClient for more information.
+        */       
+        void HandleResetComplete( TInt aErrorCode );
+        
+    private:	// Constructors
+
+        /**
+        * By default Symbian constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+        CVCSettingsEngine();
+
+    private: // New functions
+
+        /*
+        * Displays error note.
+        * @return void
+        */
+        void DisplayErrorNoteL();
+
+        /**
+        * Returns sound system
+        * @return CAknKeySoundSystem
+        */
+        CAknKeySoundSystem* GetSoundSystem() const;
+
+        /**
+        * Plays the error sound
+        * @param aSound the sound type
+        * @return void
+        */
+        void PlaySound(TAvkonSystemSID aSound) const;
+
+		/**
+		* Called when HandleResetComplete() completes
+		* @return void
+		*/
+        void DoHandleResetCompleteL();
+
+        /**
+        * Called when HandleResetComplete has an error in its parameter.
+        *
+        */
+        void HandleResetFailed();
+        
+
+    private: // Data
+    
+        CNssVASDBMgr*           iVasDbManager;		// Owned
+        MNssContextMgr*         iContextManager;    // Not owned
+        CActiveSchedulerWait    iShedulerWait;
+    };
+
+#endif  // CVCSETTINGSENGINE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcsettingslist.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Settings list class
+*
+*/
+
+
+#ifndef CVCSETTINGSLIST_H
+#define CVCSETTINGSLIST_H
+
+// INCLUDES
+#include <aknsettingitemlist.h>
+#include <CAknMemorySelectionDialog.h>
+#include "vcommand.hrh"
+
+// CLASS DECLARATION
+
+/**
+* Settings list class
+*/
+class CVCSettingsList : public CAknSettingItemList
+    {
+    public: // Constructors and destructor
+
+        /** 
+        * C++ constructor.
+        */
+        CVCSettingsList();
+
+        /**
+        * Symbian 2nd phase constructor
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCSettingsList();
+
+    public: // New functions
+
+        /**
+        * Save settings.
+        */
+        void SaveSettingsL();
+
+    public: // Functions of base classes
+
+        /**
+        * From CAknSettingItemList
+        * Launch the setting page for the current item by calling
+        * EditItemL on it.
+        */
+        void EditItemL( TInt aIndex, TBool aCalledFromMenu );
+        
+        /**
+        * From CCoeControl set the size and position of its component controls.
+        */
+        void SizeChanged();
+
+    private: // Functions from base classes
+
+        /**
+        * From CAknSettingItemList Handles creating setting items
+        * @param aIdentifier Identifier of the setting item to create
+        * @see CAknSettingItemList for more information.
+		*/
+        CAknSettingItem* CreateSettingItemL( TInt aIdentifier );
+
+        /**
+        * From CAknSettingItemList Get setting values
+		* @see CAknSettingItemList for more information.
+        */
+        void LoadSettingsL();
+        
+        /**
+        * Displays "Synthesizer enabled" note
+        */
+        void SynthesizerEnabledNoteL();
+        
+        /**
+        * Displays "Voice verification disabled" note
+        */
+        void VoiceVerificationDisabledNoteL();
+
+    private: // Data
+        TInt iSynthesizer;
+        TInt iVolumeValue;
+        TInt iRejectionValue;
+        TInt iVerification;
+			
+    };
+
+#endif // CVCSETTINGSLIST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vcsettingsview.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Settings view class
+*
+*/
+
+
+#ifndef CVCSETTINGSVIEW_H
+#define CVCSETTINGSVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+#include <eiklbo.h>
+
+// FORWARD DECLARATIONS
+class CVCSettingsContainer;
+
+
+// CLASS DECLARATION
+
+/**
+* Settings view class.
+*/
+class CVCSettingsView : public CAknView
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCSettingsView();
+
+    public: // Functions from base classes
+
+        /**
+        * From CAknView Return UID of view
+        * @return TUid uid of the view
+        */
+        TUid Id() const;
+
+        /**
+        * From CAknView, handle commands
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * From MEikMenuObserver Dynamically customize menu items
+        * @param aResourceId Menu pane resource ID
+        * @param aMenuPane Menu pane pointer
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+        /**
+        * From CAknView
+        * @see CAknView for more information
+        */
+        void HandleClientRectChange();
+        
+    private: // Functions from base classes
+
+        /**
+        * From CAknView Activate this view
+        * @param aPrevViewId 
+        * @param aCustomMessageId 
+        * @param aCustomMessage 
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+
+        /**
+        * From CAknView Deactivate this view
+        */
+        void DoDeactivate();
+
+    private: // Data
+    
+        CVCSettingsContainer*	iContainer; // owned
+        TInt                    iListBoxSelectedItemIndex;
+        TVwsViewId              iPreviousView;
+        TBool                   iOperationInProgress;
+        
+    };
+
+#endif	// CVCSETTINGSVIEW_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vctextquerydialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Text query dialog for editing commands
+*
+*/
+
+
+#ifndef CVCTEXTQUERYDIALOG_H
+#define CVCTEXTQUERYDIALOG_H
+
+// INCLUDES
+#include <AknQueryDialog.h>
+
+// CLASS DECLARATION
+/**
+* 
+*
+*/
+NONSHARABLE_CLASS( CVCTextQueryDialog ) : public CAknTextQueryDialog
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CVCTextQueryDialog* NewL( TDes& aDataText, const TTone& aTone = ENoTone );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCTextQueryDialog();
+                                
+    public:   // Functions from base classes
+    
+        /**
+         * From CAknTextQueryDialog
+         * @see CAknTextQueryDialog for more information
+         */
+        virtual TBool CheckIfEntryTextOk() const;
+        
+        /**
+         * From CAknTextQueryDialog
+         * @see CAknTextQueryDialog for more information
+         */
+        virtual void UpdateLeftSoftKeyL();
+                             
+    private:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CVCTextQueryDialog( TDes& aDataText, const TTone& aTone );
+};
+
+#endif  // CVCTEXTQUERYDIALOG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vctoneplayer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The MPlayEventHandler class provides the call back methods to handle 
+*                the events during Play operation.
+*
+*/
+
+
+
+#ifndef VCTONEPLAYER_H
+#define VCTONEPLAYER_H
+
+#include <e32base.h>
+
+class MVCTonePlayer
+    {
+    public:
+
+        virtual void MntpToneComplete()=0;
+        virtual void MntpToneError()=0;
+    };
+
+
+
+#endif // VCTONEPLAYER_H
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/inc/vctonereader.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of class which handles the playing of tones
+*
+*/
+
+
+#ifndef VCTONEREADER_H
+#define VCTONEREADER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <mmfbase.h>
+#include <barsread.h>
+#include <eikenv.h>
+#include <avkon.rsg>
+#include <mdaaudiotoneplayer.h>
+#include "vctoneplayer.h"
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Class that reads the tone sequence for the Voice commands UI
+*/
+class CAknSoundInfo;
+
+class CVCToneReader : public CBase,
+                    	  public MMdaAudioToneObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Symbian Two-phased constructor.
+        */
+        static CVCToneReader* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVCToneReader();
+
+    public: // New functions
+
+        /**
+        * Sets the tone priority
+        * @param aSid The sound ID
+        * @return TInt
+        */
+        TInt TonePriority(TInt aSid);
+
+        /**
+        * Sets the appropriate priority preference
+        * @param aSid The sound ID
+        * @return TMdaPriorityPreference
+        */
+        TMdaPriorityPreference TonePriorityPreference(TInt aSid);
+
+        /**
+        * Sets the appropriate tone sequence
+        * @param aSid The sound ID
+        * @return HBufC8*
+        */
+        HBufC8* ToneSequence(TInt aSid);
+
+        /**
+        * Sets the appropriate tone volume
+        * @param aSid The sound ID
+        * @return TInt
+        */
+        TInt ToneVolume(TInt aSid);
+
+        /**
+        * Plays tone
+        * @param aTonePlayer The class requesting the tone callbacks
+        * @param aSid The sound ID
+        */
+        void PlayTone(MVCTonePlayer* aTonePlayer,TInt aSid);
+
+    public: // Functions from base classes
+
+        /**
+        * From MMdaAudioToneObserver Called when the tone preparation is complete
+        */
+        void MatoPrepareComplete(TInt aError);
+     
+        /**
+        * From MMdaAudioToneObserver Called when the tone playing is complete
+        */
+        void MatoPlayComplete(TInt aError);
+       
+    protected:  // New functions
+        
+        /**
+        * Reads the tone sequence from the avkon resource file
+        * @param aSid The sound ID
+        * @param aTonePriority The tone priority
+        * @param aTonePreference The tone priority preference
+        * @param aToneVolume The tone volume
+        * @return HBufC8*
+        */
+        HBufC8* ReadToneSequenceL( CAknSoundInfo* aInfo, TInt aSid, TInt* aTonePriority,
+                                   TMdaPriorityPreference* aTonePreference, TInt* aToneVolume );
+
+    private: // New functions
+
+        /**
+        * C++ default constructor.
+        */
+        CVCToneReader();
+
+        /**
+        * Default Symbian constructor
+        */
+        void ConstructL();
+        
+    private:    // Data
+
+      TInt                    iTonePriority;
+      TMdaPriorityPreference  iTonePreference;
+      HBufC8*                 iToneSequence;
+      TInt                    iToneVolume;
+
+      TInt                    iAbortTonePriority;
+      TMdaPriorityPreference  iAbortTonePreference;
+      HBufC8*                 iAbortToneSequence;
+      TInt                    iAbortToneVolume;
+
+      TInt                    iErrorTonePriority;
+      TMdaPriorityPreference  iErrorTonePreference;
+      HBufC8*                 iErrorToneSequence;
+      TInt                    iErrorToneVolume;
+
+      TBool                   iPrepareCallback;
+      MVCTonePlayer*          iTonePlayer;
+      CMdaAudioToneUtility*   iToneUtility;
+
+      CAknSoundInfo*          iAbortInfo;
+      CAknSoundInfo*          iErrorInfo;
+    };
+
+#endif      // VCTONEREADER_H 
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/loc/vcommand.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localisation strings for Voice Commands UI.
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+
+//************
+// Captions
+//************
+
+// d:Voice Commands app title for aif caption file
+// d:Long string
+// l:list_single_large_graphic_pane_t1_cp2
+// r:3.1
+//
+#define qtn_apps_vcommand_list "Voice Commands"
+
+// d:Voice Commands app title for aif caption file
+// d:Short string
+// l:cell_app_pane_t1
+// r:3.1
+//
+#define qtn_apps_vcommand_grid "Voice Commands"
+
+
+//***********************************************
+//			Applications Main View
+//***********************************************
+
+
+// d:Title pane text for Voice commands UI application
+// l:title_pane_t2/opt9
+// r:3.1
+//
+#define qtn_vc_title "Voice Commands"
+
+// d:Progress note.
+// d:Shown when a voice tag is being played.
+// l:popup_note_wait_window
+// r:3.1
+//
+#define text_vc_voice_replaying "Playing voice command"
+
+// d:Query heading for edit command text query
+// l:popup_query_data_window
+// r:3.1
+//
+#define qtn_vc_heading_edit "Edit command:"
+
+// d:Progress note for user edited command training
+// l:popup_note_wait_window
+// r:3.2
+//
+#define qtn_vc_wait_note_creating_command "Creating command"
+
+// d:Progress note for user edited command removing
+// l:popup_note_wait_window/opt4
+// r:3.2
+//
+#define qtn_vc_wait_note_removing "Removing %U"
+
+//******************************
+// Context specific options menu
+//******************************
+
+// d:Allows user to open a folder
+// l:list_single_pane_t1_cp2
+// r:3.1
+//
+#define qtn_voice_open "Open"
+
+// d: Allows user to playback the focused item voice tag
+// l:list_single_pane_t1_cp2
+// r:3.1
+//
+#define text_voice_replay "Playback"
+
+// d:Allows user to edit the voice command
+// l:list_single_pane_t1_cp2
+// r:3.1
+//
+#define qtn_vc_edit "Edit command"
+
+// d:Allows user to delete the user edited voice command
+// l:list_single_pane_t1_cp2
+// r:3.1
+//
+#define qtn_vc_options_delete "Delete"
+
+// d:Allows user to remove the user edited voice command
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_options_remove_user_text "Remove command"
+
+// d:Allows user to move to the settings view
+// l:list_single_pane_t1_cp2
+// r:3.1
+//
+#define qtn_vc_settings "Settings"
+
+// d:Allows user to start SIND in tutorial mode
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_vc_tutorial "Voice command tutorial"
+
+//*******************************************
+//				Error Cases
+//*******************************************
+
+// d:information note
+// d:Shown when user tries to delete default item
+// u:%U will be replaced with the focused application name
+// l:popup_note_window/opt2
+// r:3.1
+//
+#define qtn_vc_info_cannot_del "%U cannot be deleted"
+
+// d:Error Note.
+// d:Shown when user tries to accept name that already exists
+// u:%U will be replaced with the name
+// l:popup_note_window/opt2
+// r:3.1
+//
+#define qtn_vc_error_in_use "%U already in use"
+
+// d:Error Note.
+// d:Shown when user tries to create a voice command that is too short
+// l:popup_note_window/opt2
+// r:3.1
+//
+#define qtn_vc_error_short "Command too short"
+
+// d:Shown when user tries to create a voice command with invalid input
+// l:popup_note_window/opt2
+// r:3.2
+//
+#define qtn_vc_error_note_invalid_text "Invalid text"
+
+
+//***************************************
+//			Settings dialog
+//***************************************
+
+// d:Settings item
+// d:Opens settings list for synthesizer
+// l:list_setting_pane_t1
+// r:3.1
+//
+#define qtn_vc_set_synt "Synthesizer"
+
+// d:Heading for Synthesizer settings item
+// l:list_setting_pane_t1
+// r:3.1
+//
+#define qtn_vc_set_synt2 "Synthesizer"
+
+// d:Activates text-to-speech synthesizer
+// d:Value for TTS ON
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_on "On"
+
+// d:Deactivates text-to-speech synthesizer
+// d:Value for TTS OFF
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_off "Off"
+
+// d:Sets volume for speech playback.
+// d:Opens volume settings item.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_volume "Speech volume"
+
+// d:Heading for speech playback volume setting item.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_volume2 "Speech volume"
+
+// d:Sets rejection sensitivity.
+// d:Opens setting slider.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_rejection "Recognition sensitivity"
+
+// d:Opens setting pane for setting rejection sensitivity.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_rejection2 "Recognition sensitivity"
+
+// d:Label for identifying low rejection
+// l:setting_slider_pane_t2
+// r:3.2
+//
+#define qtn_vc_rejection_low "Low"
+
+// d:Label for identifying high rejection
+// l:setting_slider_pane_t2
+// r:3.2
+//
+#define qtn_vc_rejection_high "High"
+
+// d:Settings item
+// d:Opens settings list for verification
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_verification "Command verification"
+
+// d:Heading for Command verification settings item
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_verification2 "Command verification"
+
+// d:Activates automatic command verification
+// d:Value for automatic command verification
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_verification_automatic "Automatic"
+
+// d:Activates manual command verification
+// d:Value for manual command verification
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_verification_manual "Manual"
+
+// d:Activates voice command verification
+// d:Value for manual command verification
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_vc_set_verification_voice "Voice"
+
+// d:Settings item.
+// d:Opens settings list for user adaptation.
+// l:list_setting_pane_t1
+// r:3.1
+//
+#define qtn_vc_set_reset "Reset user learnings"
+
+// d:Opens setting pane of user adaptation values.
+// l:list_single_pane_t1_cp2
+// r:3.1
+//
+#define qtn_vc_options_reset "Reset"
+
+// d:Confirmation note
+// d:Displayed when user tries to reset user learnings
+// l:popup_note_window/opt2
+// r:3.1
+//
+#define qtn_vc_conf_query_reset "Are you sure you want to reset voice recognition learnings?"
+
+// d:Information note
+// d:Displayed when voice recognition
+// d:adaptation has been reseted 
+// l:popup_note_window/opt2
+// r:3.1
+//
+#define qtn_vc_conf_note_reset "Reset done"
+
+// d:Shown when voice verification is disabled
+// l:popup_note_window/opt2
+// r:3.2
+//
+#define qtn_vc_info_note_voice_verification_off "Voice Verification disabled"
+
+// d:Shown when synthesizer is enabled
+// l:popup_note_window/opt2
+// r:3.2
+//
+#define qtn_vc_info_note_synthesizer_on "Synthesizer enabled"
+
+// d:MSK label when qtn_vc_set_reset settings item is highlighted.
+// l:control_pane_t3/opt3
+// r:3.2
+//
+#define qtn_vc_msk_reset "Reset"
+
+//***************************************
+// Voice commands general settings plugin
+//***************************************
+
+// d:Voice commands application name in General 
+// d:Settings Personalisation view's main pane
+// l:list_single_large_graphic_pane_t1_cp2
+// r:3.1
+//
+#define qtn_set_pers_voicecmd "Voice commands"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/rubydebug/rubydebug.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Debugging utilities implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include "RubyDebug.h"
+
+#ifdef __RUBY_DEBUG_TRACES_TO_FILE
+#include <f32file.h>
+#endif
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::PrintToFile
+// Method for writing traces to a file.
+// -----------------------------------------------------------------------------
+//
+#ifdef __RUBY_DEBUG_TRACES_TO_FILE
+
+#ifdef _DEBUG // UDEB version:
+EXPORT_C void RRubyDebug::PrintToFile( TRefByValue<const TDesC> aFmt, ... )
+    {
+    _LIT( KRubyLogFileName, "\\Logs\\RubyTrace.log" );
+
+    const TInt KRubyDebugMaxLineLength = 0x80; // rest will be truncated
+
+    const TInt KRubyDebugOpenFileRetries = 100;
+    const TInt KRubyDebugOpenFileInterval = 1000;
+
+    const TUint16 KRubyDebugLineSep1 = 0x0d;
+    const TUint16 KRubyDebugLineSep2 = 0x0a;
+
+    // Handle variable argument list
+    VA_LIST list;
+	VA_START( list, aFmt );
+	TBuf<KRubyDebugMaxLineLength+2> aBuf;
+    TTruncateOverflow overflow;
+	aBuf.AppendFormatList( aFmt, list, &overflow );
+	if( aBuf.Length() > ( KRubyDebugMaxLineLength - 2 ) )
+		{
+		aBuf.Delete(aBuf.Length() - 2, 2);
+		}
+	
+    // Add linefeed characters
+    aBuf.Append( KRubyDebugLineSep1 );
+    aBuf.Append( KRubyDebugLineSep2 );
+
+    RFs fs;
+    if ( fs.Connect() == KErrNone )
+        {
+        RFile file;
+
+        // Open file in an exclusive mode so that only one thread 
+        // can acess it simultaneously
+        TUint fileMode = EFileWrite | EFileShareExclusive;
+
+        TInt err = file.Open( fs, KRubyLogFileName, fileMode );
+
+        // Create a file if it doesn't exist
+        if ( err == KErrNotFound )
+            {
+            err = file.Create( fs, KRubyLogFileName, fileMode );
+            }
+        else
+            {
+            // Error in opening the file
+            TInt retryCount = KRubyDebugOpenFileRetries;
+            while ( err == KErrInUse && retryCount-- )
+                {
+                // Some other tread is accessing the file, wait a while...
+                User::After( KRubyDebugOpenFileInterval );
+                err = file.Open( fs, KRubyLogFileName, fileMode );
+                }
+            }
+
+        // Check if we have access to a file
+        if ( err == KErrNone )
+            {
+            TInt offset = 0;
+            if ( file.Seek( ESeekEnd, offset ) == KErrNone )
+                {
+                // Append text to the end of file
+                TPtr8 ptr8( (TUint8*)aBuf.Ptr(), aBuf.Size(), aBuf.Size() );
+                file.Write( ptr8 );
+                }
+            file.Close();
+            }
+
+        fs.Close();
+        }
+    }
+
+#else // UREL version:
+EXPORT_C void RRubyDebug::PrintToFile( TRefByValue<const TDesC> /*aFmt*/, ... )
+    {
+    }
+#endif
+
+#endif // __RUBY_DEBUG_TRACES_TO_FILE
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/rubydebug/rubydebug.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,271 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface of debugging utilities.
+*      %version: 1.1.3 %
+*
+*/
+
+
+#ifndef RUBYDEBUG_H
+#define RUBYDEBUG_H
+
+#include "rubydebugcfg.h"
+
+//  INCLUDES
+#include <e32svr.h> // For RDebug
+
+#ifndef RUBY_DISABLE_FUNCTION_NAMES
+    // No sense to store function name longer, than can be printed
+    // 0x100 is the internal RDebug limit
+    const TInt __K_RUBY_FUNCTION_NAME_LENGTH = 0x50;    
+
+    // Prepares function name for printing
+    #define __RUBY_PREPARE_FUNCTION_NAME \
+    TBuf<__K_RUBY_FUNCTION_NAME_LENGTH> __ruby_function_name__;\
+    __ruby_function_name__.Copy( TPtrC8( (TText8*)&__PRETTY_FUNCTION__ ).Left( __K_RUBY_FUNCTION_NAME_LENGTH ) ); \
+
+    // Token to paste the function name into
+    #define __K_RUBY_FUNCTION_NAME_TOKEN "%S "
+    
+    // Comma and function name
+    #define __RUBY_FUNCTION_NAME __ruby_function_name__
+    
+    // A wrapper that prepares and supplies the function name as __ruby_function_name__
+    #define __RUBY_FUNCTION_NAMED( text ) \
+	    {\
+	    __RUBY_PREPARE_FUNCTION_NAME;\
+	    text;\
+	    }
+	    
+	#define __RUBY_FUNCTION_NAME_POINTER8 (TText8*)&__PRETTY_FUNCTION__
+    
+
+#else  // RUBY_DISABLE_FUNCTION_NAMES
+
+    #define __RUBY_PREPARE_FUNCTION_NAME
+    
+    // Don't print the function name
+    #define __K_RUBY_FUNCTION_NAME_TOKEN ""
+    
+    // exclude the whole token, with the comma
+    #define __RUBY_FUNCTION_NAME KNullDesC
+    
+    // no wrapping
+    #define __RUBY_FUNCTION_NAMED( text ) text
+    
+    #define __RUBY_FUNCTION_NAME_POINTER8 NULL
+
+#endif // RUBY_DISABLE_FUNCTION_NAMES
+
+// Macro for printing filename both in unicode and non-unicode builds
+
+
+#ifdef _UNICODE
+	#define __RUBY_WIDEN2(x) L ## x
+	#define __RUBY_WIDEN(x) __RUBY_WIDEN2(x)
+	#define __RUBY_DBG_FILE__ __RUBY_WIDEN(__FILE__)
+#else
+	#define __RUBY_DBG_FILE__ __FILE__
+#endif//_UNICODE
+
+
+
+// Debugging is enabled only in _DEBUG builds
+//#ifdef _DEBUG 
+
+// Select the debug output method
+#ifndef __RUBY_DEBUG_TRACES_TO_FILE
+#define RUBY_DEBUG_METHOD RDebug::Print
+#else
+#define RUBY_DEBUG_METHOD RRubyDebug::PrintToFile
+#endif // __RUBY_DEBUG_TRACES_TO_FILE
+
+//#endif // _DEBUG
+
+#if defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+
+//	#define RUBY_DEBUG_BLOCK(text) \
+//  	RRubyDebug trace_trace( _S(text), _S("" ## __RUBY_DBG_FILE__) , __LINE__, EFalse ); \
+//  	CleanupReleasePushL( trace_trace )
+  	
+//  	#define RUBY_DEBUG_BLOCKL(text) \
+//  	RRubyDebug trace_trace( _S(text), _S("" ## __RUBY_DBG_FILE__), __LINE__, ETrue ); \
+//  	CleanupReleasePushL( trace_trace )
+// A temporary fix to cope with builds on RVCT 530. It didn't compile with _RUBY_DBG_FILE
+	#define RUBY_DEBUG_BLOCK(text) \
+  	RRubyDebug trace_trace( _S(text), _S("") , __LINE__, EFalse, __RUBY_FUNCTION_NAME_POINTER8 ); \
+  	CleanupReleasePushL( trace_trace )
+
+  	#define RUBY_DEBUG_BLOCKL(text) \
+  	RRubyDebug trace_trace( _S(text), _S(""), __LINE__, ETrue, __RUBY_FUNCTION_NAME_POINTER8 ); \
+  	CleanupReleasePushL( trace_trace )
+
+	#define RUBY_DEBUG0(text) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+	#define RUBY_DEBUG1(text, p1) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+	#define RUBY_DEBUG2(text, p1, p2) \
+	    __RUBY_FUNCTION_NAMED( RUBY_DEBUG_METHOD( _L("%S %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, p2, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) ) )
+
+#else // Debugging disabled
+
+	// Macros expand to nothing:
+	#define RUBY_DEBUG_BLOCK(text)
+	#define RUBY_DEBUG0(text)    
+	#define RUBY_DEBUG1(text, p1)
+	#define RUBY_DEBUG2(text, p1, p2)
+	#define RUBY_DEBUG_BLOCKL(text)
+
+#endif // defined(_DEBUG) && !defined(__RUBY_DEBUG_DISABLED)
+
+#if !defined(RUBY_DISABLE_ERRORS) || defined(_DEBUG)
+	// if error messages are allowed (even for UREL)
+	#define RUBY_ERROR0(text) \
+	__RUBY_FUNCTION_NAMED( \
+	    RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+
+	#define RUBY_ERROR1(text, p1) \
+	__RUBY_FUNCTION_NAMED( \
+	RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+
+	#define RUBY_ERROR2(text, p1, p2) \
+	__RUBY_FUNCTION_NAMED( \
+	RUBY_DEBUG_METHOD( _L("%S[Error!] %S "L##text L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, p1, p2, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id()) )\
+	)
+#else
+	// error reporting disabled
+	// Macros expand to nothing:
+	#define RUBY_ERROR_BLOCK(text)
+	#define RUBY_ERROR0(text)    
+	#define RUBY_ERROR1(text, p1)
+	#define RUBY_ERROR2(text, p1, p2)
+#endif  // !defined(RUBY_DISABLE_ERRORS)
+
+#if !defined(RUBY_DISABLE_ASSERT_DEBUG) || defined(_DEBUG)
+	#define RUBY_ASSERT_DEBUG(condition, action) \
+	  __RUBY_FUNCTION_NAMED(\
+		__ASSERT_ALWAYS( condition, RUBY_DEBUG_METHOD(  _L("%S[Error!] %S [Assert failed!] "L###condition L## " [F:%s][L:%d][TId:%d]"), &__K_RUBY_HEADER, &__RUBY_FUNCTION_NAME, __RUBY_DBG_FILE__, __LINE__, TUint(RThread().Id())) ); \
+		__ASSERT_DEBUG( (condition), (action) )\
+	  );
+#else
+	// Macro expands to default:
+	#define RUBY_ASSERT_DEBUG(condition, action) __ASSERT_DEBUG(condition,action)
+#endif
+
+// Same as TRAP_IGNORE, but in case of leave, prints the leave code via RUBY_ERROR
+// Can be disabled by RUBY_DISABLE_TRAP_IGNORE or RUBY_DISABLE_ERRORS
+// If disabled, is equivalent to TRAP_IGNORE
+// @see rubydebugcfg.h
+#ifndef RUBY_DISABLE_TRAP_IGNORE 
+    #define RUBY_TRAP_IGNORE( s ) \
+        {\
+        TRAPD( err, s );\
+        if( err != KErrNone )\
+            {\
+            RUBY_ERROR1( "RUBY_TRAP_IGNORE leaves with [%d]", err );\
+            }\
+        }
+#else  // RUBY_DISABLE_TRAP_IGNORE 
+    #define RUBY_TRAP_IGNORE( s ) TRAP_IGNORE( s )
+#endif  // RUBY_DISABLE_TRAP_IGNORE 
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Debug class for printing START, EXIT and LEAVE messages to RDebug in every 
+*  code block. Must be placed in the very beginning of a code block and the
+*  code block cannot leave items in the cleanup stack (like NewLC). 
+*
+*  @since Series 60 2.8
+*
+*  @note If this object is not the topmost item when a code block is exited, 
+*        E32USER-CBase 90 panic is raised (@see CleanupStack::Pop( TAny* )).
+*/
+class RRubyDebug
+    {
+    public:
+        /**
+        * C++ constructor.
+        * @since Series 60 2.8
+        * @param aMsg Debug message.
+        * @param aCalledFromL ETrue if called from RUBY_DEBUG_BLOCK_L
+        */
+        inline RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL,
+                           const TText8* aFunctionName = NULL );
+
+        /**
+        * Destructor.
+        */
+        inline ~RRubyDebug();
+
+        /**
+        * Destructor for Cleanup support. Called when a method leaves.
+        */
+        inline void Release();
+
+        /**
+        * Support for writing traces to file.
+        */
+        IMPORT_C static void PrintToFile( TRefByValue<const TDesC> aFmt, ... );
+
+    private:
+        /**
+        *  Class for truncating debug messages if they are too long.
+        *  @since Series 60 2.8
+        */
+        class TTruncateOverflow : public TDesOverflow
+            {
+            public: // Methods from TDesOverflow
+
+                inline void Overflow( TDes& aDes );
+            };
+
+    private:
+        // A pointer to the debug message
+        TPtrC iMsg;
+        
+        // A pointer to the filename where RUBY_DEBUG_BLOCK is written
+        TPtrC iFileName;
+        
+        // Number of the line where RUBY_DEBUG_BLOCK is written
+        TInt iLine;
+
+		// ETrue if we are called from RUBY_DEBUG_BLOCKL
+        TBool iCalledFromL;
+
+        // Flag that is set when a leave occurs
+        TBool iLeave;
+
+	#ifndef RUBY_DISABLE_FUNCTION_NAMES        
+        // Used only if aFunctionName is defined in constructor
+        HBufC* iFunctionName;
+   	#endif  // RUBY_DISABLE_FUNCTION_NAMES
+        
+    };
+
+#include "rubydebug.inl"
+
+#endif      // RUBYDEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/rubydebug/rubydebug.inl	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This module contains the implementation of RRubyDebug class 
+*	             member functions.
+*  %version: 3 %
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+#ifdef _DEBUG
+_LIT( KRubyDebugStart,  "START" );
+_LIT( KRubyDebugStop,   "EXIT" );
+_LIT( KRubyDebugLeave,  "LEAVE!!!" );
+_LIT( KRubyDebugStr,    "%S%S %S [F:%S][L:%d][TId:%d]" );
+#endif
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+#ifdef _DEBUG
+// -----------------------------------------------------------------------------
+// RRubyDebug::RRubyDebug
+// C++ constructor
+// -----------------------------------------------------------------------------
+//
+    
+inline RRubyDebug::RRubyDebug( const TText* aMsg, const TText* aFileName, const TInt aLine, TBool aCalledFromL,
+                               const TText8* aFunctionName )
+	: iMsg( aMsg ), iFileName( aFileName ), iLine ( aLine ), iCalledFromL ( aCalledFromL ), iLeave ( EFalse )
+	{
+	#ifndef RUBY_DISABLE_FUNCTION_NAMES
+	iFunctionName = NULL;
+	// If function name is defined, use it instead of aMsg
+	if( aFunctionName )
+	    {
+	    TPtrC8 ptr8Name( aFunctionName );
+	    iFunctionName = HBufC::New( ptr8Name.Length() );
+	    if( iFunctionName )
+	        {
+	        // If memory for a 16-bit copy has been allocated successfully
+	        iFunctionName->Des().Copy( ptr8Name );
+	        iMsg.Set( *iFunctionName );
+	        }
+	    }
+	#endif // RUBY_DISABLE_FUNCTION_NAMES
+	TInt id = RThread().Id();
+    iCalledFromL = aCalledFromL;  
+    if( !iCalledFromL) 
+    	{
+    	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id );
+    	}
+    else {
+    	#ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    	// For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStart, &iFileName, iLine, id );
+    	#endif
+    	}
+	}    
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::~RRubyDebug
+// Destructor
+// -----------------------------------------------------------------------------
+//
+inline RRubyDebug::~RRubyDebug()
+    {
+    if ( !iLeave ) 
+        {
+        // This is done only if destructor is NOT called from Release().
+        // Otherwise the cleanup stack pops this item automatically.
+        TInt id = RThread().Id();
+        if (!iCalledFromL) 
+        	{
+        	RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugStop, &iFileName, iLine, id );
+        	}
+        else
+        	{
+        	#ifdef RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    		// For BLOCKLs show this message only if RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+    		RUBY_DEBUG_METHOD( KRubyDebugStr, &KRubyDebugPrefix, &iMsg, &KRubyDebugStop, &iFileName, iLine, id );
+    		#endif
+        	}
+        #ifndef RUBY_DISABLE_FUNCTION_NAMES
+        delete iFunctionName;  // if any
+        #endif  // RUBY_DISABLE_FUNCTION_NAMES
+        CleanupStack::Pop( this ); // E32USER-CBase 90 panic is raised if
+                                   // this is not the topmost item
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::Release()
+// Method that makes it possible to push this object into the cleanup stack.
+// -----------------------------------------------------------------------------
+//
+inline void RRubyDebug::Release()
+    {
+    iLeave = ETrue;
+    TInt id = RThread().Id();
+    RUBY_DEBUG_METHOD( KRubyDebugStr, &__K_RUBY_HEADER, &iMsg, &KRubyDebugLeave, &iFileName, iLine, id );
+    #ifndef RUBY_DISABLE_FUNCTION_NAMES
+    delete iFunctionName;  // if any
+    #endif  // RUBY_DISABLE_FUNCTION_NAMES
+    this->~RRubyDebug();
+    }
+#endif
+
+// -----------------------------------------------------------------------------
+// RRubyDebug::TTruncateOverflow::Overflow()
+// Method for ignoring the overflowing part of a debug message.
+// -----------------------------------------------------------------------------
+//
+inline void RRubyDebug::TTruncateOverflow::Overflow( TDes& /*aDes*/ )
+    {
+    // We ignore the overflowing part of the descriptor...
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/rubydebug/rubydebugcfg.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration file for RubyDebug macros
+*  %version: 3 %
+*
+*/
+
+
+#ifndef RUBYDEBUGCFG_H
+#define RUBYDEBUGCFG_H
+
+
+#include <e32cmn.h> // TLitC
+#include <e32def.h> // _LIT
+
+#include "rubydebugconfigselector.h"
+
+// Common settings
+// Is printed at the beginning of the line
+_LIT( __K_RUBY_HEADER, "[<SRSF>] ");
+
+// Is printed after __KRUBY_HEADER for the error messages
+_LIT( __K_RUBY_ERROR, "[Error!] ");
+
+
+#if defined(RUBY_EXTERNAL_VARIANT) && defined(__WINS__)
+// set of options to use when the project is released to the customers
+
+// Uncomment the following line to disable RUBY_DEBUGs. 
+// This has no effect on RUBY_ERRORs
+#define __RUBY_DEBUG_DISABLED
+
+// Uncomment the following line to get traces to C:\Logs\RubyTrace.log
+//#define __RUBY_DEBUG_TRACES_TO_FILE
+
+// Uncomment the following line to stop disable RUBY_ERRORs
+// Error print is always enabled in _DEBUG
+//#define RUBY_DISABLE_ERRORS
+
+// Uncomment the following line to disable extra output for RUBY_ASSERT_DEBUG
+// RUBY_ASSERT_DEBUGs will become usual __ASSERT_DEBUGs
+#define RUBY_DISABLE_ASSERT_DEBUG
+
+// Uncomment the following line to disable automated function name printing
+//#define RUBY_DISABLE_FUNCTION_NAMES
+
+//#define RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+
+// Uncomment the following line to disable leave code printing in RUBY_TRAP_IGNORE
+// macro. It would make it equivalent to TRAP_IGNORE
+// #define RUBY_DISABLE_TRAP_IGNORE
+
+
+#else //  RUBY_EXTERNAL_VARIANT
+// set of options to use in the internal development
+
+// Uncomment the following line to disable RUBY_DEBUGs. 
+// This has no effect on RUBY_ERRORs
+//#define __RUBY_DEBUG_DISABLED
+
+// Uncomment the following line to get traces to C:\Logs\RubyTrace.log
+//#define __RUBY_DEBUG_TRACES_TO_FILE
+
+// Uncomment the following line to stop disable RUBY_ERRORs
+// Error print is always enabled in _DEBUG
+#define RUBY_DISABLE_ERRORS
+
+// Uncomment the following line to disable extra output for RUBY_ASSERT_DEBUG
+// RUBY_ASSERT_DEBUGs will become usual __ASSERT_DEBUGs
+#define RUBY_DISABLE_ASSERT_DEBUG
+
+// Uncomment the following line to disable automated function name printing
+//#define RUBY_DISABLE_FUNCTION_NAMES
+
+//#define RUBY_DIDSPLAY_EVERYTHING_FOR_BLOCKL
+
+// Uncomment the following line to disable leave code printing in RUBY_TRAP_IGNORE
+// macro. It would make it equivalent to TRAP_IGNORE
+// #define RUBY_DISABLE_TRAP_IGNORE
+
+#endif  //  RUBY_EXTERNAL_VARIANT
+
+#endif // RUBYDEBUGCFG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/rubydebug/rubydebugconfigselector.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Switches sets of the RubyDebug options. 
+*                @warning DO NOT change the file. At least DO NOT check in the modified version.
+*                Variants should be switched by replacing the whole rubydebugconfigselector.h 
+*                with the help of a Synergy task. 
+*  %version: 3 %
+*
+*/
+
+
+#ifndef RUBYDEBUGCONFIGSELECTOR_H
+#define RUBYDEBUGCONFIGSELECTOR_H
+
+
+// CONSTANTS
+
+/** 
+ * If defined, rubydebug will be tuned with a set of options designed for external users
+ * Typically it means showing all the warnings for hardware builds and only errors for the
+ * SW builds
+ *
+ * If not defined, rubydebug will be tuned for the internal Multimodal UI team development.
+ * Typically it means all the warnings always enabled
+ *
+ * The meaning of the variant is defined in the rubydebugcfg.h
+ * @warning DO NOT change the line. At least DO NOT check in the modified version.
+ *          Variants should be switched by replacing the whole rubydebugconfigselector.h 
+ *          with the help of a Synergy task. 
+ *
+ */
+#define RUBY_EXTERNAL_VARIANT
+
+#endif // RUBYDEBUGCONFIGSELECTOR_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/accessorybuttonmonitor.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CVCAccessoryButtonMonitor
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "accessorybuttonmonitor.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCAccessoryButtonMonitor::CVCAccessoryButtonMonitor
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVCAccessoryButtonMonitor::CVCAccessoryButtonMonitor()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVCAccessoryButtonMonitor::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCAccessoryButtonMonitor::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVCAccessoryButtonMonitor::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCAccessoryButtonMonitor* CVCAccessoryButtonMonitor::NewL()
+    {
+    CVCAccessoryButtonMonitor* self = new( ELeave ) CVCAccessoryButtonMonitor;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CVCAccessoryButtonMonitor::~CVCAccessoryButtonMonitor()
+    {
+    }
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/headsetbuttonmonitor.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DOS Server Monitor Class is used to monitor Audio Accessorries,
+*                and encapsulate the interfaces with DOS Server.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include "voiceprogressdialog.h"
+#include "playbackvoicecommanddialog.h"
+#include "headsetbuttonmonitor.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::CVoiceTagHeadsetButtonMonitor
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CHeadsetButtonMonitor::CHeadsetButtonMonitor()
+   {
+   }
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::~CHeadsetButtonMonitor
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CHeadsetButtonMonitor::~CHeadsetButtonMonitor()
+    {
+
+    // Cancel the outstanding listening
+    CancelMonitor();
+
+    // Close the connection to Dos Server
+    iDosServerSession.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::ConstructL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::ConstructL()
+    {
+    RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::ConstructL" );
+
+    User::LeaveIfError( iDosServerSession.Connect() );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::NewLC
+// Two-phased constructor.
+// This is for new CVoiceTagHeadsetButtonMonitor
+// -----------------------------------------------------------------------------
+//
+CHeadsetButtonMonitor* CHeadsetButtonMonitor::NewLC()
+    {
+    RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::NewLC" );
+    
+    CHeadsetButtonMonitor* self = new ( ELeave ) CHeadsetButtonMonitor();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+/// -----------------------------------------------------------------------------
+// HeadsetButtonMonitor::NewL
+// Two-phased constructor.
+// This is for a new DosServer Monitor
+// -----------------------------------------------------------------------------
+//
+CHeadsetButtonMonitor* CHeadsetButtonMonitor::NewL()
+    {
+    RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::NewL" );
+    
+    CHeadsetButtonMonitor* self = NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::RegisterForMonitor
+// -----------------------------------------------------------------------------
+//
+TInt CHeadsetButtonMonitor::ActivateMonitorL()
+    {
+    RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::ActivateMonitorL" );
+
+    // send Dos Server the new listening list
+    StartListeningL( KHeadsetButtonChanged, sizeof( EPSButtonState ), EOnlyLast );
+
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::DeregisterForMonitor
+// -----------------------------------------------------------------------------
+//
+TInt CHeadsetButtonMonitor::DeActivateMonitor()
+    {
+    // No more registered event. Stop the event listening
+    Stop();
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::CancelMonitor
+// -----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::CancelMonitor()
+    {
+    // Stop the event listening
+    Stop();
+    }
+
+// -----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::HeadsetButtonChangedL
+// -----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::HeadsetButtonChangedL( EPSButtonState /*aState*/ )
+    {
+    // Nothing
+    }
+
+// ----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::HandleButtonDown
+// ----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::HandleButtonDown()
+   {
+   iButtonDown = ETrue;
+   }
+
+// ----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::HandleButtonUp
+// ----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::HandleButtonUp()
+    {
+    // Check iObserver for safety, also made sure we received a button down
+    if( ( iPlaybackObserver ) && ( iButtonDown ) ) 
+        {
+        CancelMonitor();    // Stop the monitoring
+        iPlaybackObserver->HandleShortKeypress();
+        }
+    else if ( ( iProgressObserver ) && ( iButtonDown ) ) 
+        {
+        CancelMonitor();    // Stop the monitoring
+        iProgressObserver->HandleShortKeypress();
+        }
+  
+    iButtonDown = EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::HandleButtonDownLong
+// ----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::HandleButtonDownLong()
+    {
+    // Check iObserver for safety, also made sure we received a button down
+    if ( ( iPlaybackObserver ) && ( iButtonDown ) ) 
+        {
+        CancelMonitor();       // stop the monitoring 
+        iPlaybackObserver->HandleLongKeypress();
+        }
+    else if ( ( iProgressObserver ) && ( iButtonDown ) ) 
+        {
+        CancelMonitor();       // stop the monitoring 
+        iProgressObserver->HandleLongKeypress();
+        }
+
+    iButtonDown = EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::Register
+// ----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::Register( CVoiceProgressDialog* aProgressObserver,
+   CPlaybackVoiceCommandDialog* aPlaybackObserver )
+   {
+   if ( aProgressObserver )
+      {
+      iProgressObserver = aProgressObserver;
+      }
+   if ( aPlaybackObserver )
+      {
+      iPlaybackObserver = aPlaybackObserver;
+      }
+   }
+
+// ----------------------------------------------------------------------------
+// CHeadsetButtonMonitor::DeRegister
+// ----------------------------------------------------------------------------
+//
+void CHeadsetButtonMonitor::DeRegister( CVoiceProgressDialog* /*aProgressObserver*/,
+   CPlaybackVoiceCommandDialog* /*aPlaybackObserver*/ )
+   {
+   iProgressObserver = NULL;
+   iPlaybackObserver = NULL;
+   }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/uiarraysgenerator.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,348 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "uiarraysgenerator.h"
+
+#include "vcmodel.h"
+#include <badesca.h>
+#include <gulicon.h>
+#include <AknIconArray.h>
+#include <e32debug.h>
+#include <mmfcontrollerpluginresolver.h>  // for CleanupResetAndDestroyPushL
+
+
+/**
+ * @param aIcon. Ownership is tranfered. I.e. the icon will be destroyed,
+ *        when this object is destroyed, unless icon has been already removed by ReleaseIcon
+ * @param aFirstLine
+ * @param aSecondLine
+ */
+CUiEntryData* CUiEntryData::NewL( CGulIcon* aIcon, const TDesC& aFirstLine,
+                            const TDesC& aSecondLine )
+    {
+    CUiEntryData* self = NewLC( aIcon, aFirstLine, aSecondLine );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CUiEntryData* CUiEntryData::NewLC( CGulIcon* aIcon, const TDesC& aFirstLine,
+                            const TDesC& aSecondLine )
+    {
+    CUiEntryData* self = new (ELeave) CUiEntryData( aIcon, aFirstLine, aSecondLine );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+CUiEntryData::CUiEntryData( CGulIcon* aIcon, const TDesC& aFirstLine, 
+                            const TDesC& aSecondLine ) :
+    iIcon( aIcon), iFirstLine( aFirstLine ), iSecondLine( aSecondLine )
+    {
+    }
+                            
+CUiEntryData::~CUiEntryData()
+    {
+    delete iIcon;
+    }
+    
+CGulIcon* CUiEntryData::ReleaseIcon()
+    {
+    CGulIcon* result = iIcon;
+    iIcon = NULL;
+    return result;
+    }
+        
+const TDesC& CUiEntryData::FirstLine() const
+    {
+    return iFirstLine;
+    }
+
+const TDesC& CUiEntryData::SecondLine() const
+    {
+    return iSecondLine;
+    }
+    
+TInt CUiEntryData::CompareByFirstLine( const CUiEntryData& aAnotherEntry ) const
+    {
+    return iFirstLine.CompareC( aAnotherEntry.FirstLine() );
+    }
+    
+TInt CUiEntryData::CompareByFirstLine( const CUiEntryData& entry1, const CUiEntryData& entry2 )
+    {
+    return entry1.CompareByFirstLine( entry2 );
+    }
+    
+TDesC* CUiEntryData::ConstructListboxItemStringLC( TInt aIconIndex ) const
+    {
+    _LIT( KListboxStringPattern, "%d\t%S\t%S");
+    const TInt KPatternOverheadLength = 2; // two characters for tabs
+    const TInt KMaxIconIndexLength = 5;  // 5 characters for the decimal number represenation
+    HBufC* result = HBufC::NewLC( KPatternOverheadLength + KMaxIconIndexLength +
+                    FirstLine().Length() + SecondLine().Length() );
+    result->Des().Format( KListboxStringPattern, aIconIndex, &FirstLine(), &SecondLine() );
+    return result;                    
+    }
+    
+CUiArraysGenerator* CUiArraysGenerator::NewLC()
+	{
+	CUiArraysGenerator* self = new (ELeave) CUiArraysGenerator;
+	CleanupStack::PushL( self );
+	return self;
+	}
+	
+/**
+ * Create entries for all the subfolders in the given folder and sort the entries
+ * alphabetically
+ * @param aSource Model to parse
+ * @param aCurrentFolderTitle KNullDesC for the main folder
+ * @return The array of entries pushed to CS two times. First PopAndDestroy
+ *         will ResetAndDestroy, the second one will delete the array itself
+ */               
+RPointerArray<CUiEntryData>* CUiArraysGenerator::ExtractFoldersAndSortLC2( const CVCModel& aSource,
+            const TDesC& aCurrentFolderTitle )
+    {
+    RPointerArray<CUiEntryData>* folderEntries = new ( ELeave ) RPointerArray<CUiEntryData>;
+    CleanupStack::PushL( folderEntries );
+    CleanupResetAndDestroyPushL( *folderEntries );
+    if( aCurrentFolderTitle != KNullDesC() )
+        {
+        return folderEntries; // no multilevel folders
+        }
+        
+    for( TInt i = 0; i < aSource.Count(); i++ )
+        {
+        if ( aSource.At(i).FolderTitle() != KNullDesC() )
+            {
+            CUiEntryData* entry = CUiEntryData::NewL( aSource.At(i).FolderIconLC(), 
+                                        aSource.At(i).FolderListedName(), KNullDesC() );
+            CleanupStack::Pop(); // icon
+            CleanupStack::PushL( entry );
+            TLinearOrder<CUiEntryData> order( CUiEntryData::CompareByFirstLine );
+            // does not allow duplicates
+            TInt err = folderEntries->InsertInOrder( entry, order );  
+            if( err != KErrNone )
+                {
+                CleanupStack::PopAndDestroy( entry );
+                }
+            else
+                {
+                CleanupStack::Pop( entry );
+                }
+            }
+        }
+    return folderEntries;
+    }
+
+/**
+ * Create entries for all the subfolders in the given folder and sort the entries
+ * alphabetically
+ * @param aSource Model to parse
+ * @param aCurrentFolderTitle KNullDesC for the main folder
+ * @return The array of entries pushed to CS two times. First PopAndDestroy
+ *         will ResetAndDestroy, the second one will delete the array itself
+ */               
+RPointerArray<CUiEntryData>* CUiArraysGenerator::ExtractCommandsAndSortLC2( 
+                const CVCModel& aSource, const TDesC& aCurrentFolderTitle )
+    {
+    RPointerArray<CUiEntryData>* commandEntries = new ( ELeave ) RPointerArray<CUiEntryData>;
+    CleanupStack::PushL( commandEntries );
+    CleanupResetAndDestroyPushL( *commandEntries );
+        
+    for( TInt i = 0; i < aSource.Count(); i++ )
+        {
+        if ( aSource.At(i).FolderTitle() == aCurrentFolderTitle )
+            {
+            CUiEntryData* entry = CUiEntryData::NewL( aSource.At(i).IconLC(), 
+                      aSource.At(i).WrittenText(), aSource.At(i).AlternativeSpokenText() );
+            CleanupStack::Pop(); // icon
+            CleanupStack::PushL( entry );
+            TLinearOrder<CUiEntryData> order( CUiEntryData::CompareByFirstLine );
+            commandEntries->InsertInOrderAllowRepeatsL( entry, order );  
+            CleanupStack::Pop( entry );
+            }
+        }
+    return commandEntries;
+    }
+            	
+/**
+ * Parses the model into a set of arrays required by the VCommand app ui
+ * I.e. basing on the "current folder" prepares the arrays for the listbox
+ * If "current" folder is the main one, it means including all the sub-folders and main
+ * folder commands. Otherwise, it means including all the current folder commands only
+ * 
+ * Both folders and commands are alphabetially sorted.
+ * All the target arrays are ResetAndDestroyed before the parsing
+ * 
+ * @param aSource Model to parse
+ * @param aCurrentFolderTitle KNullDesC if "curent" folder is the main one
+ * @param aIconArray icons to display in the listbox. Order is not specified
+ * @param aFolderTitles List of folder titles in the alphabetical order
+ * @param aItemIsFolder List of boolean values for all the listbox elements from top 
+ * 		  to bottom. ETrue for every folder, EFalse for every command
+ * @param aItemArray List of strings in the listbox expected 
+ * 		  format ( @see LB_SINGLE_GRAPHIC_HEADING ). Includes:
+ * 		  * a refence to the icon - zero-based index from the aIconArray
+ *        * written text of the command
+ *        * user-specified alternative text or KNullDesC if
+ * 		
+ */
+void CUiArraysGenerator::FillArraysL( const CVCModel& aSource, const TDesC& aCurrentFolderTitle,
+				  CAknIconArray& aIconArray, CDesC16ArrayFlat& aFolderTitles, 
+				  RArray<TBool>& aItemIsFolder, CDesC16ArrayFlat& aItemArray )
+	{
+	CleanupClosePushL( aItemIsFolder ); 
+	
+	aIconArray.ResetAndDestroy();
+	aFolderTitles.Reset();
+	aItemIsFolder.Reset();
+	aItemArray.Reset();
+    // Get folder entries
+
+    RPointerArray<CUiEntryData>* entries = 
+            ExtractFoldersAndSortLC2( aSource, aCurrentFolderTitle );
+
+    FillFolderTitlesL( aItemIsFolder, aFolderTitles, aSource, *entries );
+
+    // get command entries            
+    RPointerArray<CUiEntryData>* ordinaryCommands = 
+            ExtractCommandsAndSortLC2( aSource, aCurrentFolderTitle );
+    
+    // append commands to folder list            
+    while( ordinaryCommands->Count() > 0 )
+        {
+        entries->AppendL( (*ordinaryCommands)[0] );
+        aItemIsFolder.AppendL( EFalse );
+        ordinaryCommands->Remove( 0 );
+        }
+            
+    CleanupStack::PopAndDestroy( ordinaryCommands );  // ResetAndDestroy
+    CleanupStack::PopAndDestroy( ordinaryCommands );  // delete    
+    
+    for( TInt i = 0; i < entries->Count(); i++ )
+        {
+        aIconArray.AppendL( (*entries)[i]->ReleaseIcon() );
+        TDesC* string = (*entries)[i]->ConstructListboxItemStringLC( i );
+        aItemArray.AppendL( *string );
+        CleanupStack::PopAndDestroy( string );
+        }
+    
+    CleanupStack::PopAndDestroy( entries );  // ResetAndDestroy
+    CleanupStack::PopAndDestroy( entries );  // delete
+    
+    CleanupStack::Pop(); //aItemIsFolder
+	}
+
+/**
+ * Updates a set of arrays required by the VCommand app ui to match current folder names
+ * I.e. basing on the "current folder" prepares the arrays for the listbox
+ * If "current" folder is the main one, it means including all the sub-folders and main
+ * folder commands. Otherwise, it means including all the current folder commands only
+ * 
+ * Both folders and commands are alphabetially sorted.
+ * 
+ * @param aSource Model to parse
+ * @param aCurrentFolderTitle KNullDesC if "curent" folder is the main one
+ * @param aIconArray icons to display in the listbox. Order is not specified
+ * @param aFolderTitles List of folder titles in the alphabetical order
+ * @param aItemIsFolder List of boolean values for all the listbox elements from top 
+ * 		  to bottom. ETrue for every folder, EFalse for every command
+ * @param aItemArray List of strings in the listbox expected 
+ * 		  format ( @see LB_SINGLE_GRAPHIC_HEADING ). Includes:
+ * 		  * a refence to the icon - zero-based index from the aIconArray
+ *        * written text of the command
+ *        * user-specified alternative text or KNullDesC if
+ * 		
+ */	
+void CUiArraysGenerator::UpdateFolderArraysL( const CVCModel& aSource, const TDesC& aCurrentFolderTitle,
+				  CAknIconArray& aIconArray, CDesC16ArrayFlat& aFolderTitles, 
+				  RArray<TBool>& aItemIsFolder, CDesC16ArrayFlat& aItemArray )
+	{
+    // Get folder entries
+    RPointerArray<CUiEntryData>* entries = 
+            ExtractFoldersAndSortLC2( aSource, aCurrentFolderTitle );
+
+    for( TInt i = aItemIsFolder.Count() - 1; i >= 0 ; i-- )
+        {
+        if ( aItemIsFolder[i] )
+            {
+            aFolderTitles.Delete(i);            
+            aItemArray.Delete(i);            
+            aItemIsFolder.Remove(i);
+            }
+        }
+        
+    for( TInt i = 0; i < entries->Count(); i++ )
+        {
+        aItemIsFolder.InsertL( ETrue, i );
+        
+        TBool titleForCurrentListedNameFound = EFalse;
+        for( TInt j = 0; j < aSource.Count(); j++ )
+            {
+            if( aSource.At(j).FolderListedName() == (*entries)[i]->FirstLine() )
+                {
+                aFolderTitles.InsertL( i, aSource.At(j).FolderTitle() );
+                titleForCurrentListedNameFound = ETrue;
+                break;
+                }
+            }
+        if (!titleForCurrentListedNameFound)
+            {
+            User::Leave( KErrCorrupt );
+            }
+            
+        aIconArray.AppendL( (*entries)[i]->ReleaseIcon() );
+        
+        TDesC* string = (*entries)[i]->ConstructListboxItemStringLC( aIconArray.Count() - 1 );
+        aItemArray.InsertL( i, *string );
+        CleanupStack::PopAndDestroy( string );
+        }
+    
+    CleanupStack::PopAndDestroy( entries );  // ResetAndDestroy
+    CleanupStack::PopAndDestroy( entries );  // delete    
+	}
+    
+/**
+ * 		
+ */	
+void CUiArraysGenerator::FillFolderTitlesL( RArray<TBool>& aItemIsFolder, 
+                    CDesC16ArrayFlat& aFolderTitles, const CVCModel& aModel, 
+                    const RPointerArray<CUiEntryData>& aEntries )
+    {
+    // fill folder titles            
+    for( TInt i = 0; i < aEntries.Count(); i++ )
+        {
+        aItemIsFolder.AppendL( ETrue );
+        TBool titleForCurrentListedNameFound = EFalse;
+        for( TInt j = 0; j < aModel.Count(); j++ )
+            {
+            if( aModel.At(j).FolderListedName() == aEntries[i]->FirstLine() )
+                {
+                aFolderTitles.AppendL( aModel.At(j).FolderTitle() );
+                titleForCurrentListedNameFound = ETrue;
+                break;
+                }  // if
+            }  // for j
+        if (!titleForCurrentListedNameFound)
+            {
+            User::Leave( KErrCorrupt );
+            }
+        }  // for i
+    }    
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcapp.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application class for vcommand app
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "vcapp.h"
+#include "vcdocument.h"
+#include <eikstart.h>
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CVCApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CVCApp::AppDllUid() const
+    {
+    return KUidVCommand;
+    }
+
+   
+// ---------------------------------------------------------
+// CVCApp::CreateDocumentL()
+// Creates CVCDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CVCApp::CreateDocumentL()
+    {
+    return CVCDocument::NewL( *this );
+    }
+
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CVCApp;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcappui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,465 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Application UI class for vcommand app
+*
+*/
+
+
+// INCLUDE FILES
+#include <hlplch.h>
+#include <featmgr.h>
+#include <akntitle.h>  // CAknTitlePane
+#include <barsread.h>  // TResourceReader
+#include <StringLoader.h>
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+
+#include <e32property.h>        // RProperty
+#include <PSVariables.h>        // Property values
+#include <ctsydomainpskeys.h>
+
+#include <vcommand.rsg>
+#include "vcappui.h"
+#include "vcmodelappuiinterface.h"
+#include "vcgenericview.h"
+#include "vcfolderview.h"
+#include "vcsettingsview.h"
+#include "vcommandconstants.h"
+#include "vcmodel.h"
+
+#include "rubydebug.h"
+
+/**
+* This is an application closer class. VCommandhandler needs to finish certain
+* operations once they are started. Since the application receives key events
+* all the time, including the ones requesting application exit, we ask the
+* system to Call() this class a bit later. From its RunL it will gracefully
+* close the application
+*/
+NONSHARABLE_CLASS( CAppCloser ) : public CAsyncOneShot 
+	{
+	public:
+		CAppCloser();
+	protected:
+	    /** Is called by the system after we asked it to Call() closer
+	    */
+		virtual void RunL();
+	};
+	
+// -----------------------------------------------------------------------------
+//  Constructor
+// -----------------------------------------------------------------------------
+//
+CAppCloser::CAppCloser() :
+	CAsyncOneShot( CActive::EPriorityStandard )
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+//  CAppCloser::RunL
+//  Will be called by the system and exits the application
+// -----------------------------------------------------------------------------
+//
+void CAppCloser::RunL() 
+	{
+	if( iStatus == KErrNone ) 
+		{
+		static_cast<CVCAppUi*> ( CEikonEnv::Static()->AppUi() )->DoExitProgram();
+		}
+	else 
+		{
+		RUBY_ERROR1( "CAppCloser::RunL Unexpected iStatus [%d]", iStatus.Int() );
+		}
+	}
+
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------------------------
+// CVCAppUi::ConstructL()
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::ConstructL()
+    {
+    BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
+    
+    iCloser = new (ELeave) CAppCloser;
+ 
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    
+    iModel = CVCModel::NewL( this );
+
+    iMainView = new (ELeave) CVCGenericView( *iModel );
+    iMainView->ConstructL( R_VCOMMAND_MAIN_VIEW );
+    AddViewL( iMainView );      // transfer ownership to CAknViewAppUi
+    
+    iFolderView = new (ELeave) CVCFolderView( *iModel );
+
+    iFolderView->ConstructL( R_VCOMMAND_FOLDER_VIEW );
+    AddViewL( iFolderView );      // transfer ownership to CAknViewAppUi
+
+	CVCSettingsView* settingsView = new (ELeave) CVCSettingsView;
+
+    CleanupStack::PushL( settingsView );
+    settingsView->ConstructL();
+    AddViewL( settingsView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop( settingsView );   
+
+    SetDefaultViewL( *iMainView );
+    }
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::~CVCAppUi()
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CVCAppUi::~CVCAppUi() 
+    {    
+    delete iCloser;
+    delete iModel;
+
+    FeatureManager::UnInitializeLib();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::DynInitMenuPaneL
+// This function is called by the EIKON framework just before it displays
+// a menu pane.
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::DynInitMenuPaneL(
+    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
+    {
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::HandleCommandL
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        // Both exit commands should do the same thing
+        case EEikCmdExit:
+        case EAknSoftkeyExit:
+            {
+            ExitProgram();
+            break;
+            }
+            
+        case EAknCmdHelp:
+            {
+            HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
+                                                 AppHelpContextL() );
+            break;
+            }
+            
+        default:
+            {
+            CAknViewAppUi::HandleCommandL( aCommand );
+            break;              
+            }
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::ExitProgram
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::ExitProgram() 
+    {
+    if( iOperationInProgress ) 
+        {
+        iExitRequested = ETrue;
+        }
+    else 
+        {
+        DoExitProgram();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::DoExitProgram
+// ----------------------------------------------------------------------------
+//    
+void CVCAppUi::DoExitProgram() 
+    {
+    Exit();
+    }
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::ExitProgramDeferred
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::ExitProgramDeferred()
+    {
+    iCloser->Call();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCAppUi::StartAtomicOperationLC
+// ----------------------------------------------------------------------------
+//  
+void CVCAppUi::StartAtomicOperationLC()
+    {
+    iOperationInProgress = ETrue;
+    
+    TCleanupItem item( CleanupEndAtomicOperation, this );
+    CleanupStack::PushL( item );
+    }
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::NotifyEndOfAtomicOperationL
+// ----------------------------------------------------------------------------
+//   
+void CVCAppUi::EndAtomicOperation()
+    {
+    iOperationInProgress = EFalse;
+    if( iExitRequested ) 
+        {
+        RUBY_DEBUG0( "NotifyEndOfAtomicOperationL exit requested -> DoExit" );
+        ExitProgramDeferred();
+        
+        // A function with a NotifyStartOfAtomicOperation -
+        // NotifyEndOfAtomicOperation pair might be called from a function
+        // with the same pair, so we make sure ExitProgramDeferred is called
+        // only once in such a situation.
+        iExitRequested = EFalse;
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCAppUi::CleanupEndAtomicOperation
+// ----------------------------------------------------------------------------
+//   
+void CVCAppUi::CleanupEndAtomicOperation( TAny* aService )
+    {
+    CVCAppUi* service = static_cast<CVCAppUi*>(aService);
+    service->EndAtomicOperation();
+    }
+
+
+void CVCAppUi::CreateAndPushEndAtomicCleanupItemL()
+    {
+    TCleanupItem item( CleanupEndAtomicOperation, this );
+    CleanupStack::PushL( item );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::SetTitleL
+// Set title pane text from a resource.
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::SetTitleL( TInt aResourceId )
+    {
+    CAknTitlePane* title = static_cast<CAknTitlePane*>(
+        StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+        
+    TResourceReader reader;
+    iCoeEnv->CreateResourceReaderLC( reader, aResourceId );
+    title->SetFromResourceL( reader );
+    CleanupStack::PopAndDestroy();  // resource reader
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCAppUi::InvalidTextNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::ShowErrorNoteL( TInt aResourceId )
+    {
+    HBufC* text = StringLoader::LoadLC( aResourceId );
+    CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue );
+    note->ExecuteLD( *text );
+    CleanupStack::PopAndDestroy( text );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::NameAlreadyInUseNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::NameAlreadyInUseNoteL( const TDesC& aName )
+    {
+    if ( aName.Length() > 0 )
+        {
+        // Not using the version of LoadLC where a parameter is inserted to
+        // the returned string because for some reason that causes some weird
+        // characters to appear when using localized strings
+        TDesC* stringholder = StringLoader::LoadLC( R_QTN_VC_ERROR_IN_USE,
+                                                    iEikonEnv );
+        TName noteText;
+        StringLoader::Format( noteText, *stringholder, -1, aName );
+        CleanupStack::PopAndDestroy( stringholder );
+        
+        CAknNoteWrapper* note = new ( ELeave ) CAknNoteWrapper();
+        note->ExecuteLD( R_VC_ALREADY_IN_USE, noteText );
+        }
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CVCSindAppUi::ShowWaitNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::ShowWaitNoteL( const TDesC& aText )
+    {
+    if ( iWaitNote )
+        {
+        delete iWaitNote;
+        iWaitNote = NULL;
+        }
+    iWaitNote = new(ELeave) CAknWaitDialog(
+        ( reinterpret_cast<CEikDialog**>( &iWaitNote ) ), ETrue );
+    iWaitNote->PrepareLC( R_VC_WAIT_NOTE );
+    iWaitNote->SetTextL( aText );
+    
+    iWaitNote->RunLD();
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CVCSindAppUi::ShowWaitNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::DeleteWaitNoteL()
+    {
+    if (iWaitNote)
+    	{
+    	iWaitNote->ProcessFinishedL(); // deletes the dialog    	
+    	}
+    delete iWaitNote;
+    iWaitNote = NULL;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::CheckCallStateL
+// ----------------------------------------------------------------------------
+//
+TInt CVCAppUi::CheckCallStateL()
+    {
+    TInt callState;
+    TInt err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState,
+                               callState );
+        
+    User::LeaveIfError( err );
+        
+    return callState;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::IsVideoCallL
+// ----------------------------------------------------------------------------
+//
+TBool CVCAppUi::IsVideoCallL() 
+    { 
+    TInt callType;
+    TInt err =  RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType,
+                                callType );
+                                
+    User::LeaveIfError( err );
+
+    return callType == EPSCTsyCallTypeH324Multimedia;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::CallInProgressNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::CallInProgressNoteL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_TEXT_CALL_IN_PROGRESS );
+    CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
+    note->ExecuteLD( *text );
+    CleanupStack::PopAndDestroy( text );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCAppUi::HandleResourceChangeL
+// Handle skin change event.
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::HandleResourceChangeL( TInt aType )
+    {
+    CAknAppUi::HandleResourceChangeL( aType );
+    
+    if ( aType == KEikDynamicLayoutVariantSwitch ) 
+        {
+        CAknView* view = View( KUidVCMainView );        
+        if ( view )
+            {
+        	static_cast< CVCGenericView* >( view )->HandleSizeChange(); 
+            }
+        
+        view = View( KUidVCFolderView );        
+        if ( view )
+            {
+            static_cast< CVCGenericView* >( view )->HandleSizeChange(); 
+            }
+            
+        view = View( KUidVCSettingsView );        
+        if ( view )
+            {
+            static_cast< CVCSettingsView* >( view )->HandleClientRectChange();
+            }
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCAppUi::CommandSetChanged
+// ----------------------------------------------------------------------------
+//
+void CVCAppUi::CommandSetChanged()
+    {
+    TUid focusedView = FocusedView();
+    
+    TRAPD( err,
+        // Shouldn't all views be updated?
+/*        if( focusedView == KUidVCMainView )
+            {
+            iMainView->RefreshViewL();
+            }
+        else
+            {
+            iFolderView->RefreshViewL();
+            }*/
+        iMainView->RefreshViewL();
+        iFolderView->RefreshViewL();
+        );
+    if( err != KErrNone )
+        {
+        RUBY_ERROR1( "RefreshViewL failed with [%d]", err );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCAppUi::CommandSetChanged
+// ----------------------------------------------------------------------------
+//
+TBool CVCAppUi::IsDisplayingMenuOrDialog()
+    {
+    return EFalse;
+    }
+    
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcdocument.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Document class for vcommand app
+*
+*/
+
+
+// INCLUDE FILES
+#include "vcdocument.h"
+#include "vcappui.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CVCDocument::CVCDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// destructor
+CVCDocument::~CVCDocument()
+    {
+    }
+
+// Default constructor can leave.
+void CVCDocument::ConstructL()
+    {
+    }
+
+// Two-phased constructor.
+CVCDocument* CVCDocument::NewL(
+        CEikApplication& aApp)     // CVCommandApp reference
+    {
+    CVCDocument* self = new (ELeave) CVCDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CVCDocument::CreateAppUiL()
+// constructs CVCAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CVCDocument::CreateAppUiL()
+    {
+    return new (ELeave) CVCAppUi;
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcdoublelargestylelistbox.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Listbox for commands
+*
+*/
+
+
+// INCLUDE FILES
+#include "vcdoublelargestylelistbox.h"
+
+// -----------------------------------------------------------------------------
+// CVCDoubleLargeStyleListBox::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCDoubleLargeStyleListBox* CVCDoubleLargeStyleListBox::NewL()
+    {
+    CVCDoubleLargeStyleListBox* self = new (ELeave) CVCDoubleLargeStyleListBox();
+    return self;
+    }   
+    
+// Destructor       
+CVCDoubleLargeStyleListBox::~CVCDoubleLargeStyleListBox()
+    {
+    }
+
+// ---------------------------------------------------------
+// CVCDoubleLargeStyleListBox::AddScrollBarObserver
+// ---------------------------------------------------------
+//     
+void CVCDoubleLargeStyleListBox::AddScrollBarObserver( MEikScrollBarObserver* aObserver )
+    {
+    iObserver = aObserver;
+    }
+    
+// ---------------------------------------------------------
+// CVCDoubleLargeStyleListBox::HandleScrollEventL
+// ---------------------------------------------------------
+//    
+void CVCDoubleLargeStyleListBox::HandleScrollEventL( CEikScrollBar* aScrollBar,
+                                                     TEikScrollEvent aEventType )
+    {
+    if ( iObserver )
+        {
+        iObserver->HandleScrollEventL( aScrollBar, aEventType );
+        }
+        
+    CAknDoubleLargeStyleListBox::HandleScrollEventL( aScrollBar, aEventType );
+    }
+
+// ---------------------------------------------------------
+// CVCDoubleLargeStyleListBox::CVCDoubleLargeStyleListBox
+// ---------------------------------------------------------
+//              
+CVCDoubleLargeStyleListBox::CVCDoubleLargeStyleListBox()
+ : CAknDoubleLargeStyleListBox()
+    {
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcfolderview.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  View class for folders
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+#include <featmgr.h>
+#include <StringLoader.h>
+#include <AknGlobalNote.h>
+#include <AknWaitDialog.h>
+
+#include <vcommand.rsg>
+#include "vcappui.h"
+#include "vcfolderview.h"
+#include "vcommandconstants.h"
+#include "vcommand.hrh"
+#include "vcommandconstants.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+//
+//
+//
+CVCFolderView::CVCFolderView( /*CVCommandHandler& aService,*/ CVCModel& aModel ) : 
+    CVCGenericView( /*aService,*/ aModel ) 
+    {   
+    }
+
+
+// ---------------------------------------------------------
+// TUid CVCDefaultView::Id
+// ---------------------------------------------------------
+//
+TUid CVCFolderView::Id() const 
+    {
+    return KUidVCFolderView;
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcgenericcontainer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,1224 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Container class for vcommand app
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <StringLoader.h> 
+#include <avkon.hrh>
+#include <aknlists.h>
+#include <eikclbd.h>
+#include <aknkeys.h>
+#include <fbs.h>
+#include <eiklbd.h>
+#include <eiklbx.h>
+#include <eikclbd.h>
+#include <eiklbi.h>
+#include <aknlists.h> 
+#include <aknPopup.h>
+#include <akntitle.h>
+#include <eikspane.h>
+#include <aknlistquerydialog.h>
+#include <sysutil.h>
+#include <apgcli.h>
+#include <featmgr.h>
+#include <AknsUtils.h>
+#include <s32strm.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <AknUtils.h>
+#include <apgcli.h>
+#include <collate.h>
+
+#include <vcommand.rsg>
+#include <vcommand.mbg>
+#include "vcgenericcontainer.h"
+#include "vcgenericview.h"
+#include "vcommanduientry.h"
+#include "uiarraysgenerator.h"
+#include "vctextquerydialog.h"
+#include "vcdoublelargestylelistbox.h"
+
+#include "vcommand.hrh"
+#include "vcappui.h"
+#include "rubydebug.h"
+
+
+// CONSTANTS
+const TChar KTabulator = '\t';
+const TInt KArrayGranularity( 12 );
+// Show tooltip for four seconds
+const TInt KPopupVisibilityTime = 4000;
+_LIT( KLocReplace, "%U" );
+// Bytes that should be free in the disk drive in addition to critical level 
+// before voice command editing is allowed (10k)
+const TInt KEditDiskUsage = 10240;
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// ----------------------------------------------------------------------------
+// C++ constructor
+// ----------------------------------------------------------------------------
+CVCGenericContainer::CVCGenericContainer( CEikMenuBar* aMenuBar,
+                                          CVCModel& aModel,
+                                          CVCGenericView& aView ):
+    iMenuBar( aMenuBar ), iView( aView ), iModel( aModel )
+    { 
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::ConstructL( const TRect& aRect ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::ConstructL" );
+    
+    SetTitlePaneL( R_VC_MAIN_VIEW_TITLE );
+    CreateWindowL();
+
+    iPopupController = CAknInfoPopupNoteController::NewL();
+    iPopupController->SetTimePopupInView( KPopupVisibilityTime );
+    
+    ConstructListBoxL();
+
+    SetRect( aRect );
+    SetObserver( this );
+    ActivateL();
+    } 
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::~CVCGenericContainer
+// ----------------------------------------------------------------------------
+//
+CVCGenericContainer::~CVCGenericContainer() 
+    {
+	delete iFolderTitles;
+	iItemIsFolder.Close();
+	delete iPopupController;
+    
+    if ( iListBox )
+        {
+        static_cast<CVCDoubleLargeStyleListBox*>( iListBox )->AddScrollBarObserver( NULL );
+        }
+    delete iListBox; 
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::SetTitlePaneL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::SetTitlePaneL(TInt aResourceId) const 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::SetTitlePaneL" );
+    
+    // Set up status pane
+    CEikStatusPane* statusPane =
+        ( static_cast<CAknAppUi*> ( iCoeEnv->AppUi() ) )->StatusPane();
+    CAknTitlePane* title = 
+        static_cast<CAknTitlePane*>( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+
+    TResourceReader rReader;
+    iCoeEnv->CreateResourceReaderLC( rReader, aResourceId );
+    title->SetFromResourceL( rReader );
+    
+    // Set title for folder views
+    if( iView.FolderTitle() != KNullDesC() )
+        {
+        title->SetTextL( iView.FolderTitle() );
+        }
+    
+    CleanupStack::PopAndDestroy(); // rReader
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::OfferKeyEventL
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CVCGenericContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+                                                  TEventCode aType ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::OfferKeyEventL" );
+    
+    if( iHandlingKeyPressInProgress )
+        {
+        return EKeyWasConsumed;
+        }
+     
+    // Special case when for some reason vcommand database is empty.
+    // Only exiting is allowed
+    if( ListBoxCount() <= 0 && aKeyEvent.iCode != EKeyCBA2 ) 
+        {
+        return EKeyWasConsumed;
+        }
+     
+    SetHandlingKeyPressInProgress( ETrue );
+    TKeyResponse retval( EKeyWasConsumed );
+    TBool isFolder = IsItemFolderL( CurrentSelection() );
+        
+    switch ( aKeyEvent.iCode ) 
+        {
+        case EKeyBackspace: // C - key. Deletes an application
+            {
+            if ( iView.MenuBar()->ItemSpecificCommandsEnabled() )
+                {
+                TDesC* secondRow = GetSecondRowNameLC( CurrentSelection() );
+                if( !isFolder && secondRow->Length() > 0 ) 
+                    {
+                    SetHandlingKeyPressInProgress( EFalse );
+                    iView.HandleCommandL( EVCCmdDelete );    
+                    }
+                else 
+                    {
+                    SetHandlingKeyPressInProgress( EFalse );
+                    iView.HandleCommandL( EVCCmdRemove );
+                    }
+                CleanupStack::PopAndDestroy( secondRow );
+                }
+            break;  
+            }
+
+        case EKeyUpArrow: 
+        case EKeyDownArrow: 
+            {
+            retval = iListBox->OfferKeyEventL( aKeyEvent, aType );
+            TRAP_IGNORE(
+                ShowTooltipL( CurrentSelection() );
+                iView.SetMiddleSoftkeyLabelL( CurrentSelection() ) );
+            break;
+            }
+            
+        case EKeyCBA2:
+            {
+            if( iView.FolderTitle() == KNullDesC() ) 
+                {
+                iView.HandleCommandL( EAknSoftkeyExit );
+                }
+            }
+        
+        default: 
+            {
+            retval = iListBox->OfferKeyEventL( aKeyEvent, aType );
+            break;
+            }
+        } 
+        
+    SetHandlingKeyPressInProgress( EFalse );
+    return retval;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::IsItemFolderL
+// ----------------------------------------------------------------------------
+//
+TBool CVCGenericContainer::IsItemFolderL( TInt aListBoxIndex ) const 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::IsItemFolderL" );
+                  
+    if( aListBoxIndex >= 0 && aListBoxIndex < iItemIsFolder.Count() )
+        {
+        return iItemIsFolder[aListBoxIndex];
+        }
+    else
+        {
+        return false;
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::ConstructListBoxL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::ConstructListBoxL() 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::ConstructListBoxL" );
+    
+    CVCAppUi* appUi = static_cast<CVCAppUi*>( iEikonEnv->AppUi() );
+        
+    iListBox = CVCDoubleLargeStyleListBox::NewL();
+    iListBox->SetContainerWindowL( *this ); // set's iListBox to be contained in this container
+    
+    iListBox->ConstructL( this, EAknListBoxSelectionList );
+    iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
+    // Ownership not transferred
+    iItemArray = 
+        static_cast<CDesC16ArrayFlat*>( iListBox->Model()->ItemTextArray() );
+    
+    // Folder title array    
+    iFolderTitles = new (ELeave) CDesC16ArrayFlat( KArrayGranularity );
+        
+    // Populates the listbox
+    PopulateListBoxL();
+    
+    CEikFormattedCellListBox* listbox = static_cast<CEikFormattedCellListBox*>( iListBox );
+    
+    // Set listbox observer
+    listbox->SetListBoxObserver( this );
+    
+    static_cast<CVCDoubleLargeStyleListBox*>( iListBox )->AddScrollBarObserver( this );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::PopulateListBoxL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::PopulateListBoxL() 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::PopulateListBoxL" );
+    
+    CAknIconArray* icons = new ( ELeave ) CAknIconArray( KArrayGranularity );
+    CleanupStack::PushL( icons );
+    
+    CUiArraysGenerator* generator = CUiArraysGenerator::NewLC();
+    generator->FillArraysL( iModel, iView.FolderTitle(), *icons, *iFolderTitles, 
+                            iItemIsFolder, *iItemArray );
+    
+    CleanupStack::PopAndDestroy( generator );
+
+    CEikFormattedCellListBox* listbox = static_cast<CEikFormattedCellListBox*>( iListBox );
+    // Takes ownership of icons
+    listbox->ItemDrawer()->ColumnData()->SetIconArray( icons );
+    CleanupStack::Pop( icons );
+
+    iListBox->CreateScrollBarFrameL( ETrue );
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
+                                                         CEikScrollBarFrame::EAuto );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::SortItemListL
+// Insertion sort implementation
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::SortItemListL() 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::SortItemListL" );
+    
+    // Case insentitive comparing
+    TCollationMethod cm = *Mem::CollationMethodByIndex( 0 ); // Default collation method
+    cm.iFlags |= TCollationMethod::EFoldCase;
+    
+    TInt i( 1 );
+    while( i < iItemArray->Count() )
+        {
+        TDesC* strToCompare = GetFirstRowNameLC( i );
+        TBool isFolder = IsItemFolderL( i );
+        
+        TDesC* firstRow( NULL );
+        TInt j = i - 1;
+        // Previous item is greater than strToCompare or previous is not a
+        // folder and current item is
+        while( j >= 0 &&
+               ( (firstRow = GetFirstRowNameLC( j ))->CompareC( *strToCompare, 0, &cm ) > 0 || 
+               isFolder && !IsItemFolderL( j ) ) ) 
+            {
+            CleanupStack::PopAndDestroy( firstRow );
+            // Pointers are expected to be on the cleanup stack if they are non-null
+            firstRow = NULL;
+            if( !isFolder && IsItemFolderL( j ) ) // folders are first on the list
+                {
+                break;
+                }
+            j--;
+            }
+        // Pointers popped and destroyed are nullified, so non-null pointers
+        // are still on the cleanup stack
+        if( firstRow )
+            {
+            CleanupStack::PopAndDestroy( firstRow );
+            }
+        j++; // the last index which satisfied the conditions
+        
+        if( j < i ) 
+            {
+            iItemArray->InsertL( j, iListBox->Model()->ItemText( i ) );
+            iItemArray->Delete( i + 1 );
+            
+            // No need to sort iItemIsFolder. Folders are in the beginning
+            // and other items are in the end. This hasn't changed.
+            }
+
+        i++;
+        CleanupStack::PopAndDestroy( strToCompare );
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::HandleListBoxEventL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
+                                               TListBoxEvent aEventType ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::HandleListBoxEventL" );
+    
+    switch ( aEventType ) 
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemSingleClicked: 
+            {
+            if( IsItemFolderL( CurrentSelection() ) ) 
+                {
+                SetHandlingKeyPressInProgress( EFalse );
+                iView.HandleCommandL( EVCCmdOpen );
+                }
+            else
+                {
+                SetHandlingKeyPressInProgress( EFalse );
+                iView.HandleCommandL( EVCCmdPlayback );
+                ShowTooltipL( CurrentSelection() );
+                }
+            break;
+            }
+            
+        default:
+            {
+            ShowTooltipL( -1 );
+            }
+        
+        break;
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+//  CVCGenericContainer::HandleScrollEventL
+// ----------------------------------------------------------------------------
+void CVCGenericContainer::HandleScrollEventL( CEikScrollBar* /*aScrollBar*/,
+                                              TEikScrollEvent /*aEventType*/ )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::HandleScrollEventL" );
+    
+    ShowTooltipL( -1 );
+    }
+
+
+// ----------------------------------------------------------------------------
+//  CVCGenericContainer::DeleteVoiceCommandL
+// ----------------------------------------------------------------------------
+void CVCGenericContainer::DeleteVCommandL() 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::DeleteVCommandL" );
+    
+    // Get corresponding CVCommand-object
+    TDesC* firstRow = GetFirstRowNameLC( CurrentSelection() );
+    
+    const CVCommandUiEntry& vcommand = iModel.GetVCommandL( *firstRow );
+    CleanupStack::PopAndDestroy( firstRow );
+    
+    TDesC* secondRow = GetSecondRowNameLC( CurrentSelection() );
+    
+    // Show "cannot delete" note if the voice command is not user edited
+    if ( secondRow->Length() <= 0 ||
+        ( vcommand.UserText() == KNullDesC() &&
+          vcommand.WrittenText() != vcommand.SpokenText() ) )
+        {
+        CleanupStack::PopAndDestroy( secondRow );
+        return iView.DoHandleCommandL( EVCCmdRemove );    
+        }
+    else
+        {        
+        HBufC* stringholder = StringLoader::LoadL( R_QTN_VC_DELETE_COMMAND, *secondRow, iEikonEnv );
+        CleanupStack::PushL( stringholder );
+        
+        CAknQueryDialog* dlg = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
+         
+        if ( dlg->ExecuteLD( R_REMOVE_APPLICATION_DIALOG, *stringholder ) ) // not cancelled: ret != 0
+            {
+            UpdateTextL( CurrentSelection(), KNullDesC(), *secondRow );
+            }
+        
+        CleanupStack::PopAndDestroy( stringholder );
+        CleanupStack::PopAndDestroy( secondRow );
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+//  CVCGenericContainer::ShowTooltipL
+// ----------------------------------------------------------------------------
+void CVCGenericContainer::ShowTooltipL( TInt aItemIndex ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::ShowTooltipL" );
+    
+    if( aItemIndex >= 0 && aItemIndex < iItemArray->Count() &&
+        !IsItemFolderL( aItemIndex ) )
+        {
+        TDesC* firstRow = GetFirstRowNameLC( CurrentSelection() );
+        
+        const CVCommandUiEntry& vcommand = iModel.GetVCommandL( *firstRow );
+        
+        CleanupStack::PopAndDestroy( firstRow );
+
+        TName ttText = vcommand.Tooltip();
+        
+        const TDesC& writtenText = vcommand.WrittenText();
+        TDesC* spokenText = vcommand.AlternativeSpokenText().AllocLC();
+        // Command is not user edited
+        if( *spokenText == KNullDesC() )
+            {
+            CleanupStack::PopAndDestroy( spokenText );
+            spokenText = vcommand.SpokenText().AllocLC();
+            }
+            
+        TName ttText2;    
+        if( ttText.Find( KLocReplace ) != KErrNotFound )
+            {
+            // Replace %U with the vc api spoken text
+            StringLoader::Format( ttText2, ttText, -1, *spokenText );
+            ttText.Copy( ttText2 );
+            }
+        else
+            {
+            // Replace %0U with the vc api spoken text
+            StringLoader::Format( ttText2, ttText, 0, *spokenText );
+            // Replace %1U with the vc api written text
+            StringLoader::Format( ttText, ttText2, 1, writtenText );            
+            }
+            
+        iPopupController->SetTextL( ttText );
+        iPopupController->RestoreDefaultPosition();
+        iPopupController->ShowInfoPopupNote();
+        
+        CleanupStack::PopAndDestroy( spokenText );
+        }
+    else 
+        {
+        iPopupController->HideInfoPopupNote();
+        }
+    }
+    
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::IsHandlingKeyPressInProgress
+// ----------------------------------------------------------------------------
+//                   
+TBool CVCGenericContainer::IsHandlingKeyPressInProgress()
+    {
+    return iHandlingKeyPressInProgress;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::SetHandlingKeyPressInProgress
+// ----------------------------------------------------------------------------
+//                           
+void CVCGenericContainer::SetHandlingKeyPressInProgress( TBool aValue )
+    {
+    iHandlingKeyPressInProgress = aValue;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::CountComponentControls
+// ----------------------------------------------------------------------------
+//
+TInt CVCGenericContainer::CountComponentControls() const 
+    {
+    return 1; // return nbr of controls inside this container
+    }
+    
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::HandleControlEventL(
+//     (CCoeControl* aControl,TCoeEvent aEventType)
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::HandleControlEventL( CCoeControl* /*aControl*/, 
+                                                   TCoeEvent /*aEventType*/ )    
+    {
+    // Do nothing
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::ShowEditTextL()
+// Gets the application name from listbox and extracts it.
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::ShowEditTextL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::ShowEditTextL" );
+    
+    if( !CheckCriticalLevelL() )
+        {
+        TBuf<KMaxEditableTextLength> voiceCmd;
+        TInt index = CurrentSelection();
+        TDesC* secondRow = GetSecondRowNameLC( index );
+        
+        // 
+        if( secondRow->Length() <= 0 ) 
+            {
+            TDesC* firstRow = GetFirstRowNameLC( index );
+            const CVCommand* orgCommand = &iModel.GetVCommandL( *firstRow ).Command();
+            voiceCmd.Append( orgCommand->SpokenText() );
+            CleanupStack::PopAndDestroy( firstRow );
+            }
+        else 
+            {
+            voiceCmd.Append( *secondRow );
+            }
+
+        CleanupStack::PopAndDestroy( secondRow );
+
+        TBuf<KMaxEditableTextLength> spokenText;
+        spokenText.Copy( voiceCmd );
+        
+        // Save the currently selected command
+        TDesC* firstRow = GetFirstRowNameLC( index );
+        const CVCommand* orgCommand = &iModel.GetVCommandL( *firstRow ).Command();
+        CleanupStack::PopAndDestroy( firstRow );
+        
+        CVCommand* command = CVCommand::NewL( *orgCommand );
+        CleanupStack::PushL( command );            
+
+        // Create the data query dialog        
+        CVCTextQueryDialog* dlg = CVCTextQueryDialog::NewL( voiceCmd );
+        // Enable T9
+        dlg->SetPredictiveTextInputPermitted( ETrue );
+
+        TBool res;
+        // Check whether Japanese is in use
+        if ( FeatureManager::FeatureSupported( KFeatureIdJapanese )
+             && User::Language() == ELangJapanese )
+            {
+            res = ( dlg->ExecuteLD( R_VC_DATA_QUERY_JAPANESE ) == EAknSoftkeyOk );
+            }
+        else
+            {
+            res = ( dlg->ExecuteLD( R_VC_DATA_QUERY ) == EAknSoftkeyOk );
+            }
+        dlg = NULL;
+        
+        // User didn't cancel and the index is still in correct range
+        if ( res && index < iItemArray->Count() )
+            {
+            // Get current command
+            firstRow = GetFirstRowNameLC( index );
+            const CVCommand* currentCommand = &iModel.GetVCommandL( *firstRow ).Command();
+            CleanupStack::PopAndDestroy( firstRow );
+            
+            // If only whitespace was given, TrimAll modifies the name into an empty string
+            voiceCmd.TrimAll();
+            
+            if ( voiceCmd.Length() )
+                {
+                // The selected command is the same and the name was changed
+                if ( *command == *currentCommand && spokenText != voiceCmd )
+                    {
+                    if( !CheckNameValidityL( voiceCmd ) ) // New name base was valid. Exit from query
+                        {
+                        UpdateTextL( index, voiceCmd, spokenText );
+                        }
+                    else
+                        {
+                        ShowEditTextL(); // Query is shown again
+                        }
+                    }
+                }
+            else
+                {
+                // Remove command if possible since the inserted string was empty
+                TDesC* secondRow = GetSecondRowNameLC( index );                
+                if( !IsItemFolderL( index ) && secondRow->Length() > 0 ) 
+                    {
+                    SetHandlingKeyPressInProgress( EFalse );
+                    iView.HandleCommandL( EVCCmdDelete );    
+                    }
+                CleanupStack::PopAndDestroy( secondRow );
+                }
+            }
+        CleanupStack::PopAndDestroy( command );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::CheckCriticalLevelL
+// Checks for CL disk space
+// ----------------------------------------------------------------------------
+//
+TBool CVCGenericContainer::CheckCriticalLevelL()
+    {
+    RFs session = iCoeEnv->FsSession();
+    TBool noMemory = SysUtil::FFSSpaceBelowCriticalLevelL( &session, KEditDiskUsage );
+   
+    if ( noMemory )
+        {
+        CAknQueryDialog* dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
+        dlg->ExecuteLD( R_NOT_ENOUGH_MEMORY_DIALOG );
+        }
+        
+    return noMemory;
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::UpdateTextL
+// Sets the new application name to the list
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::UpdateTextL( TInt aIndex, const TDesC& aNewName,
+                                       const TDesC& aOldName ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::UpdateTextL" );
+    
+    TDesC* firstRow = GetFirstRowNameLC( aIndex );
+    
+    if( iModel.GetVCommandL( *firstRow ).UserText() != aNewName )
+        {
+        TPtrC itemText = iListBox->Model()->ItemText( aIndex );
+        TInt tabIndex = itemText.Locate( KTabulator );
+        
+        TBuf<KVCMaxNameSize> applicationName;
+        
+        applicationName.Append( itemText.Left( tabIndex ) );
+        applicationName.Append( KTabulator );
+        
+        applicationName.Append( *firstRow );
+    	applicationName.Append( KTabulator );
+        
+        // Add user edited text to second line
+    	if( aNewName.Size() > 0 ) 
+    	    {
+            applicationName.Append( aNewName );
+    	    }
+    	    
+    	CVCAppUi* appUi = static_cast <CVCAppUi*> ( iEikonEnv->AppUi() );
+    	
+    	HBufC* stringholder;
+        // We are removing the edited command
+        if( aNewName == KNullDesC() )
+            {
+            stringholder = StringLoader::LoadL( R_QTN_VC_WAIT_NOTE_REMOVING, aOldName, iEikonEnv );
+            CleanupStack::PushL( stringholder );
+            appUi->ShowWaitNoteL( *stringholder );
+            }
+        // We are modifying a command
+        else
+            {
+            stringholder = StringLoader::LoadLC( R_QTN_VC_WAIT_NOTE_CREATING_COMMAND, iEikonEnv );
+            appUi->ShowWaitNoteL( *stringholder );
+            }
+        
+        // Update extra text field for VCommand
+        TRAPD( error, iModel.SetNewSpokenTextL( *firstRow, aNewName ) );
+        // Untrainable text
+        if( error == KErrArgument || error == KErrGeneral )
+            {
+            appUi->DeleteWaitNoteL();
+            
+            appUi->ShowErrorNoteL( R_QTN_VC_ERROR_NOTE_INVALID_TEXT );
+            
+            ShowEditTextL();
+            }
+        else
+            {
+            appUi->DeleteWaitNoteL();
+            User::LeaveIfError( error );
+            
+            // Update listbox
+            iItemArray->Delete( aIndex );
+            iItemArray->InsertL( aIndex, applicationName );    
+            
+            iListBox->HandleItemAdditionL();
+    
+            }
+                
+        CleanupStack::PopAndDestroy( stringholder );
+        }
+    
+    CleanupStack::PopAndDestroy( firstRow );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::CurrentSelection
+// ----------------------------------------------------------------------------
+//
+TInt CVCGenericContainer::CurrentSelection() const 
+    {   
+    return iListBox->CurrentItemIndex();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::SetCurrentSelection
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::SetCurrentSelection( TInt aIndex )
+    {   
+    if ( aIndex >= 0 && aIndex < iItemArray->Count() )
+        {
+        iListBox->SetCurrentItemIndexAndDraw( aIndex );
+        }
+    else if ( iItemArray->Count() > 0 )
+        {
+        iListBox->SetCurrentItemIndexAndDraw( 0 );
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::SizeChanged
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::SizeChanged() 
+    {
+    if( iListBox ) 
+        {
+        iListBox->SetRect( Rect() );
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::FocusChanged
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::FocusChanged( TDrawNow aDrawNow ) 
+    {
+    if( iListBox ) 
+        {
+        iListBox->SetFocus( IsFocused(), aDrawNow );
+        }
+    }
+    
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::ComponentControl
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CVCGenericContainer::ComponentControl( TInt /*aIndex*/ ) const 
+    {
+    return iListBox;
+    }
+
+
+// --------------------------------------------------------------------------- 
+// CVCGenericContainer::GetHelpContext
+// Gives the help context to be displayed
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::GetHelpContext( TCoeHelpContext& aContext ) const 
+    {
+    aContext.iMajor = KUidHelp;
+    if ( iView.Id() == KUidVCMainView )
+        {
+        aContext.iContext = KHLP_VC_SIND_MAIN;
+        }
+    else
+        {
+        aContext.iContext = KHLP_VC_SIND_FOLDER;
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::CheckNameValidityL
+// ----------------------------------------------------------------------------
+//
+TBool CVCGenericContainer::CheckNameValidityL( const TDesC& aName ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::CheckNameValidityL" );
+    
+    TBool nameFound = EFalse;
+    CVCAppUi* appUi = static_cast < CVCAppUi* > ( iEikonEnv->AppUi() );
+
+    for( TInt i( 0 ); i < iModel.Count(); i++ ) 
+        {        
+        if( aName.Compare( iModel.At( i ).WrittenText() ) == 0 ||
+            aName.Compare( iModel.At( i ).SpokenText() ) == 0 ) 
+            {
+            nameFound = ETrue;
+            break;
+            }
+            
+        if( aName.Compare( KNullDesC() ) != 0 &&
+            aName.Compare( iModel.At( i ).UserText() ) == 0 )
+            {
+            nameFound = ETrue;
+            break;
+            }
+        }
+
+    if( nameFound ) 
+        {    
+        appUi->NameAlreadyInUseNoteL( aName );
+        }
+
+    return nameFound;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::GetFirstRowNameLCC
+// ----------------------------------------------------------------------------
+//
+TDesC* CVCGenericContainer::GetFirstRowNameLC( TInt aIndex ) const
+    {    
+    TBuf<KVCMaxNameSize> name;
+    name.Zero();
+
+    // Get the application name
+    TPtrC first = iListBox->Model()->ItemText( aIndex );
+    
+    // Locate the first tab char
+    TInt index = first.Locate( KTabulator );
+    
+    // delete the icon from the beginning and get the name
+    TPtrC second = first.Right( first.Length() - index - 1 );
+
+    // check if the name has more tab chars in it
+    index = second.Locate( KTabulator );
+
+    if( index == second.Length()-1 || index == KErrNotFound ) 
+        {
+        name.Append( second );
+        AknTextUtils::StripCharacters( name, KAknStripListControlChars );
+        }
+    else 
+        {
+        TInt reverse = second.LocateReverse( KTabulator );
+        
+        if( index == reverse ) 
+            {
+        
+            TPtrC third = second.Left( index );
+            name.Append( third );
+            AknTextUtils::StripCharacters( name, KAknStripListControlChars );
+            }
+        }
+
+    return name.AllocLC();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::GetSecondRowNameLC
+// ----------------------------------------------------------------------------
+//
+TDesC* CVCGenericContainer::GetSecondRowNameLC( TInt aIndex ) const
+    {    
+    TBuf<KVCMaxNameSize> secondRow;
+    
+    TPtrC temp = iListBox->Model()->ItemText( aIndex );
+    
+    TPtrC text = temp.Right( temp.Length() - 2 );
+    TInt foundTab = text.Locate( KTabulator );
+
+    if( foundTab != KErrNotFound ) 
+        {
+        TInt index = text.LocateReverse( KTabulator );
+        secondRow.Append( text.Right( text.Length() - index - 1 ) );
+        AknTextUtils::StripCharacters( secondRow, KAknStripListControlChars );
+        }
+    return secondRow.AllocLC();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::GetFolderTitle
+// ----------------------------------------------------------------------------
+//    
+TPtrC CVCGenericContainer::GetFolderTitle( TInt aIndex )
+    {
+    return (*iFolderTitles)[aIndex];
+    }
+
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::ListBoxSize
+// ----------------------------------------------------------------------------
+//
+TInt CVCGenericContainer::ListBoxCount() const
+    {
+    if( !iListBox ) 
+        {
+        return 0;
+        }
+    return iItemArray->Count();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::HandleResourceChange
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::HandleResourceChangeL( TInt aType ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::HandleResourceChangeL" );
+    
+    CCoeControl::HandleResourceChange( aType );        
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::RefreshListboxL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::RefreshListboxL( CVCommandUiEntryArray& oldCommands,
+                                           CVCommandUiEntryArray& newCommands )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericContainer::RefreshListboxL" );
+    
+    TInt currentIndex = CurrentSelection();
+    
+    RArray<CVCommandUiEntry> commands = FindCommandsToBeAddedL( oldCommands,
+                                                         newCommands );
+    CleanupClosePushL( commands );
+    AddCommandsL( commands );
+    CleanupStack::PopAndDestroy();
+        
+    commands = FindCommandsToBeRemovedL( oldCommands, newCommands );
+    CleanupClosePushL( commands );
+    RemoveCommands( commands );                                  
+    CleanupStack::PopAndDestroy( &commands );
+
+    // Owned by listbox
+    CAknIconArray* icons = (CAknIconArray*) iListBox->ItemDrawer()->ColumnData()->IconArray();
+
+    CUiArraysGenerator* generator = CUiArraysGenerator::NewLC();
+    generator->UpdateFolderArraysL( iModel, iView.FolderTitle(), *icons,
+                                    *iFolderTitles, iItemIsFolder, *iItemArray );
+    
+    CleanupStack::PopAndDestroy( generator );
+    
+    iListBox->HandleItemAdditionL();
+    iListBox->HandleItemRemovalL();
+    
+    SortItemListL();
+    
+    if ( currentIndex >= iItemArray->Count() )
+        {
+        if (iItemArray->Count() > 0)
+            {       
+            SetCurrentSelection( iItemArray->Count() - 1 );
+            }
+        else
+            {
+            // group has been renamed (ui language change) -> go back to main menu
+            iView.DoHandleCommandL( EAknSoftkeyBack );
+            }
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::FindCommandLsToBeAddedL
+// ----------------------------------------------------------------------------
+//
+RArray<CVCommandUiEntry> CVCGenericContainer::FindCommandsToBeAddedL(
+    CVCommandUiEntryArray& oldCommands, CVCommandUiEntryArray& newCommands )
+    {
+    RArray<CVCommandUiEntry> addedCmds;
+    CleanupClosePushL( addedCmds );
+    
+    // Compare items in newCommands with the items in oldCommands and see
+    // which are not found. These should be added to the listbox.
+    for( TInt i( 0 ); i < newCommands.Count(); i++ )
+        {
+        const CVCommandUiEntry& cmd = newCommands[i];
+        TBool found( EFalse );
+        
+        for( TInt j( 0 ); j < oldCommands.Count(); j++ )
+            {
+            const CVCommandUiEntry& compareCmd = oldCommands[j];
+                        
+            if( cmd == compareCmd )
+                {
+                found = ETrue;
+                break;
+                }
+            }
+            
+        if( !found )
+            {
+            addedCmds.AppendL( cmd );
+            }
+        }
+        
+    CleanupStack::Pop();
+    return addedCmds;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::AddCommandsL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::AddCommandsL( RArray<CVCommandUiEntry>& aCommands )
+    {
+    CEikFormattedCellListBox* listbox
+        = static_cast<CEikFormattedCellListBox*>( iListBox );
+    CAknIconArray* icons
+        = static_cast<CAknIconArray*>(listbox->ItemDrawer()->ColumnData()->IconArray());
+    
+    // Update the listbox and the icon array
+    for( TInt i( 0 ); i < aCommands.Count(); i++ )
+        {
+        CVCommandUiEntry& cmd = aCommands[i];
+        
+        // Check the folder
+        if( cmd.FolderTitle() == iView.FolderTitle() )
+            {
+            icons->AppendL( cmd.IconLC() );
+            CleanupStack::Pop(); // IconLC
+            
+            CVCommandUiEntry& cmd = aCommands[i];
+            
+            // Append to the end
+            iItemArray->AppendL( *CreateListboxItemLC( icons->Count()-1, // Last index
+                                                       cmd.WrittenText(),
+                                                       KNullDesC() ) );
+            CleanupStack::PopAndDestroy(); // CreateListboxItemLC
+            
+            iItemIsFolder.Append( EFalse );
+            }
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::FindCommandLsToBeRemovedL
+// ----------------------------------------------------------------------------
+//
+RArray<CVCommandUiEntry> CVCGenericContainer::FindCommandsToBeRemovedL(
+    CVCommandUiEntryArray& oldCommands, CVCommandUiEntryArray& newCommands )
+    {
+    RArray<CVCommandUiEntry> removedCmds;
+    CleanupClosePushL( removedCmds );
+        
+    // Compare items in oldCommands with the items in newCommands and see
+    // which are not found. These should be removed from the listbox.
+    for( TInt i( 0 ); i < oldCommands.Count(); i++ )
+        {
+        const CVCommandUiEntry& cmd = oldCommands[i];
+        TBool found( EFalse );
+        
+        for( TInt j( 0 ); j < newCommands.Count(); j++ )
+            {
+            const CVCommandUiEntry& compareCmd = newCommands[j];
+                        
+            if( cmd == compareCmd )
+                {
+                found = ETrue;
+                break;
+                }
+            }
+            
+        if( !found )
+            {
+            removedCmds.AppendL( cmd );
+            }
+        }
+
+    CleanupStack::Pop();
+    return removedCmds;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::RemoveCommands
+// ----------------------------------------------------------------------------
+//
+void CVCGenericContainer::RemoveCommands( RArray<CVCommandUiEntry>& aCommands )
+    {
+    CEikFormattedCellListBox* listbox
+        = static_cast<CEikFormattedCellListBox*>( iListBox );
+    CAknIconArray* icons
+        = static_cast<CAknIconArray*>(listbox->ItemDrawer()->ColumnData()->IconArray());
+    
+    // Update the listbox
+    for( TInt i( 0 ); i < aCommands.Count(); i++ )
+        {
+        CVCommandUiEntry& cmd = aCommands[i];
+        
+        // Check the folder
+        if( cmd.FolderTitle() == iView.FolderTitle() )
+            {
+            for( TInt j( 0 ); j < iItemArray->Count(); j++ )
+                {
+                TPtrC16 item = (*iItemArray)[j];
+                
+                // Written text is unique. When changing a spoken text we 
+                // check that the new spoken text is not a written text
+                // for any command. That is why it is enough to search for
+                // the written text in the item here
+                if( item.Find( cmd.WrittenText() ) != KErrNotFound )
+                    {
+                    iItemArray->Delete( j );
+                    iItemArray->Compress();
+                    }
+                }
+                
+            // Icon array now has excess items, but that is no problem.
+            // It is more efficient to leave the icons as they are.
+            }
+        }
+    }
+    
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::SearchItemArrayL
+// ----------------------------------------------------------------------------
+//
+TInt CVCGenericContainer::SearchItemArrayL( const TDesC& aText  )
+    {
+    TInt ret( KErrNotFound );
+    
+    for( TInt i( 0 ); i < iItemArray->Count(); i++ )
+        {
+        if( (*iItemArray)[i].Find( aText ) != KErrNotFound )
+            {
+            ret = i;
+            break;
+            }
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericContainer::CreateListboxItem
+// ----------------------------------------------------------------------------
+//  
+TDesC* CVCGenericContainer::CreateListboxItemLC( TInt aIconArrayIndex,
+                                               const TDesC& aFirstRow,
+                                               const TDesC& aSecondRow )
+    {
+    TBuf<KVCMaxNameSize> name;
+    name.AppendNum( aIconArrayIndex );
+    name.Append( KTabulator );
+    name.Append( aFirstRow );
+    name.Append( KTabulator );
+    name.Append( aSecondRow );
+    
+    return name.AllocLC();
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcgenericview.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,587 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Generic view class for vcommand app
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+#include <featmgr.h>
+#include <StringLoader.h>
+#include <AknGlobalNote.h>
+#include <AknWaitDialog.h>
+#include <hlplch.h>
+
+#include <ctsydomainpskeys.h>
+
+#include <vcommand.rsg>
+#include "vcappui.h"
+#include "vcgenericview.h"
+#include "vcfolderview.h"
+#include "vcgenericcontainer.h" 
+#include "vcommandconstants.h"
+#include "vcommand.hrh"
+#include "vcommandconstants.h"
+#include "vcplaybackdialog.h"
+#include "voiceuibldvariant.hrh"
+
+#include <vcommanddomaincrkeys.h>
+#include <centralrepository.h>
+
+#include <coemain.h>
+#include <apgcli.h>
+#include <apgtask.h>
+#include <apacmdln.h>
+
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::CVCGenericView
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CVCGenericView::CVCGenericView( CVCModel& aModel ): 
+    iModel( aModel )
+    {   
+    }
+ 
+// ----------------------------------------------------------------------------
+// CVCGenericView::ConstructL
+// Two-phased constructor
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::ConstructL( TInt aResourceId ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::ConstructL" );
+    
+    BaseConstructL( aResourceId );
+    SetFolderTitleL( KNullDesC() );
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::~CVCGenericView
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CVCGenericView::~CVCGenericView() 
+    {
+    delete iFolderName;
+    
+    if( iContainer ) 
+        {  
+        AppUi()->RemoveFromStack( iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// TUid CVCGenericView::Id
+// ----------------------------------------------------------------------------
+//
+TUid CVCGenericView::Id() const 
+    {
+    return KUidVCMainView;
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::HandleCommandL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::HandleCommandL( TInt aCommand ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::HandleCommandL" );
+    
+    // We will only handle one event at a time
+    if( !iContainer->IsHandlingKeyPressInProgress() )
+        {
+        iContainer->SetHandlingKeyPressInProgress( ETrue );
+        DoHandleCommandL( aCommand );
+        iContainer->SetHandlingKeyPressInProgress( EFalse );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::DoHandleCommandL
+// ----------------------------------------------------------------------------
+//
+// Defines basic operations for listbox items. Those operations are: opening a folder,
+// editing an item, playing an item and launching help. More sophisticated features
+// can be defined in inherited classes.
+//
+void CVCGenericView::DoHandleCommandL( TInt aCommand ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::DoHandleCommandL" );
+    
+    switch ( aCommand ) 
+        {
+        case EAknSoftkeySelect: // Middle softkey
+            {
+            TInt current( iContainer->CurrentSelection() );
+            
+            // Msk can be pressed before the listbox is populated in which case
+            // we ignore the key press
+            if( current != KErrNotFound )
+                {
+                if( iContainer->IsItemFolderL( current ) )
+                    {
+                    DoHandleCommandL( EVCCmdOpen );
+                    }
+                else
+                    {
+                    DoHandleCommandL( EVCCmdEdit );
+                    }                
+                }
+            
+            break;
+            }
+        
+        case EAknSoftkeyExit: // exit the application
+            {
+            static_cast<CVCAppUi*>( iEikonEnv->AppUi() )->ExitProgram();
+            break;
+            }
+      
+        case EAknSoftkeyBack: // back to main view from folder
+            {
+#ifdef __VCOMMAND_CONTROL_PANEL
+            if( Id() == KUidVCMainView )
+                {
+                static_cast<CVCAppUi*>( iEikonEnv->AppUi() )->ExitProgram();
+                break; 
+                }
+            else // Id() == KUidVCFolderView
+                {
+                AppUi()->ActivateLocalViewL( KUidVCMainView );
+                break;
+                }
+#else
+            AppUi()->ActivateLocalViewL( KUidVCMainView );
+            break;
+#endif
+            }
+      
+        case EVCCmdOpen: // open folder
+            {
+            TInt current = iContainer->CurrentSelection();
+            static_cast <CVCFolderView*>
+                ( AppUi()->View( KUidVCFolderView ) )
+                ->SetFolderTitleL( iContainer->GetFolderTitle( current ) );
+            // Store the focused folder. Used when returning from folder view.
+            iFocusedIndex = current;
+            AppUi()->ActivateLocalViewL( KUidVCFolderView );
+            
+            break; 
+            }
+
+        case EVCCmdEdit: // edit voice command extra text
+            {
+            TRAPD(err,  iContainer->ShowEditTextL() );
+            if ( err == KErrNoMemory || err == KErrDiskFull ) User::Leave(err);
+            break;
+            }
+
+        case EVCCmdPlayback: // playback voice command
+            {
+            TRAP_IGNORE( PlaybackVoiceCommandL() );
+            break;
+            }
+
+        case EVCCmdDelete: // delete a voice command
+            {
+            TRAP_IGNORE( iContainer->DeleteVCommandL() );
+            break;
+            }
+     
+        case EVCCmdSettings: // modify settings
+            {
+            iFocusedIndex = iContainer->CurrentSelection();
+            AppUi()->ActivateLocalViewL( KUidVCSettingsView );
+            break;
+            }
+   
+        case EVCCmdStartVui: // start  in tutorial mode
+            {
+            TRAP_IGNORE( LaunchDemoVoiceUiL() );
+            break;
+            }
+        
+        case EAknCmdHelp: // launch help dialog 
+            {
+            HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
+                                                 AppUi()->AppHelpContextL() );
+            break;
+            }
+        
+        case EVCCmdRemove: // item can not be removed
+            {
+            CannotDeleteNoteL();
+            break;
+            }
+            
+        case EVCCmdIgnore:
+            {
+            break; // do nothing
+            }
+        
+        default: 
+            {
+            AppUi()->HandleCommandL( aCommand );
+            break;
+            }
+        }      
+    }   
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::LaunchDemoVoiceUiL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::LaunchDemoVoiceUiL() const
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::LaunchDemoVoiceUiL" );
+
+    CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+    User::LeaveIfError( client->Set( KVuiDemoMode, ETrue ) );
+    CleanupStack::PopAndDestroy( client );
+
+    TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
+    TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUid );
+    
+    if ( apaTask.Exists() )
+        {
+        apaTask.BringToForeground();
+        }
+    else
+        {
+        RApaLsSession apaLsSession;
+        User::LeaveIfError( apaLsSession.Connect() );
+        
+        TApaAppInfo appInfo;
+        User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, KVoiceUiUid ) );
+        
+        TFileName appName = appInfo.iFullName;
+        CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+
+        apaCommandLine->SetExecutableNameL( appName );
+        apaCommandLine->SetCommandL( EApaCommandRunWithoutViews );
+        User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) );
+        CleanupStack::PopAndDestroy( apaCommandLine );
+    
+        apaLsSession.Close();
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCGenericView::CheckMiddleSoftkeyLabelL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::SetMiddleSoftkeyLabelL( TInt aIndex ) const
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::SetMiddleSoftkeyLabelL" );
+    
+    RemoveCommandFromMSK();
+    
+    if( iModel.Count() == 0 )
+        {
+        DoSetMiddleSoftKeyLabelL( R_TEXT_SOFTKEY_EMPTY, EVCCmdIgnore );
+        }
+    else if( iContainer->IsItemFolderL( aIndex ) )
+        {
+        DoSetMiddleSoftKeyLabelL( R_QTN_VC_OPEN, EVCCmdOpen );
+        }
+    else
+        {
+        DoSetMiddleSoftKeyLabelL( R_QTN_VC_EDIT, EVCCmdEdit );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCGenericView::SetMiddleSoftKeyLabelL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::DoSetMiddleSoftKeyLabelL( const TInt aResourceId,
+                                               const TInt aCommandId  ) const
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::DoSetMiddleSoftKeyLabelL" );
+    
+    CEikButtonGroupContainer* cbaGroup = Cba();
+    if ( cbaGroup )
+        {
+        HBufC* mskText = StringLoader::LoadLC( aResourceId );
+        TPtr mskPtr = mskText->Des();
+        cbaGroup->AddCommandToStackL( KVcMskControlID, aCommandId, mskPtr );
+        CleanupStack::PopAndDestroy( mskText );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCGenericView::RemoveCommandFromMSK
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::RemoveCommandFromMSK() const
+    {
+    if ( Cba() )
+        {
+        Cba()->RemoveCommandFromStack( KVcMskControlID, EVCCmdOpen );
+        Cba()->RemoveCommandFromStack( KVcMskControlID, EVCCmdEdit );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::HandleClientRectChange
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::HandleClientRectChange() 
+    {
+    if ( iContainer ) 
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::DoActivateL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::DoActivateL( const TVwsViewId& aPrevViewId,
+                                  TUid, const TDesC8& ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::DoActivateL" );
+    
+    if( !iContainer ) 
+        {
+        iContainer = new ( ELeave ) CVCGenericContainer( MenuBar(), iModel, *this );
+        iContainer->SetMopParent( this );
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        
+        iContainer->ActivateL();
+        }
+    
+    // Returning from folder or settings view
+    if( aPrevViewId.iViewUid.iUid == KUidVCFolderView.iUid ||
+        aPrevViewId.iViewUid.iUid == KUidVCSettingsView.iUid )
+        {
+        // Set the focus on the folder that was opened previously
+        iContainer->SetCurrentSelection( iFocusedIndex );
+        }
+    
+    // Set msk label  
+    SetMiddleSoftkeyLabelL( iContainer->CurrentSelection() );
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::DoDeactivate
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::DoDeactivate() 
+    {
+    if( iContainer ) 
+        {
+        AppUi()->RemoveFromStack( iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+    
+
+// ----------------------------------------------------------------------------
+//  CVCGenericView::DynInitMenuPaneL
+// ----------------------------------------------------------------------------
+void CVCGenericView::DynInitMenuPaneL( TInt aResourceId,
+                                       CEikMenuPane* aMenuPane ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::DynInitMenuPaneL" );
+    
+    if( aMenuPane ) 
+        {   
+        // Check which menu item we are handling
+        if( aResourceId == R_VCOMMAND_MENU ) 
+            {
+            // if help is not enabled, do not show "help"
+            if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) 
+                {
+                aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
+                }
+                
+            TInt listBoxIndex( iContainer->CurrentSelection() );
+            
+            if( listBoxIndex >= 0 )
+                {
+                TBool isFolder = iContainer->IsItemFolderL( listBoxIndex );
+
+                if( isFolder ) // Folder is highlighted.
+                    {
+                    aMenuPane->SetItemDimmed( EVCCmdPlayback, ETrue );
+                    aMenuPane->SetItemDimmed( EVCCmdEdit, ETrue );
+                    aMenuPane->SetItemDimmed( EVCCmdDelete, ETrue );
+                    }
+                else // Folder is not highlighted.
+                    { 
+                    aMenuPane->SetItemDimmed( EVCCmdOpen, ETrue );
+                    
+                    // Show delete item only if the command is user edited
+                    TDesC* secondRow = iContainer->GetSecondRowNameLC(
+                                       iContainer->CurrentSelection() );
+                    if( secondRow->Length() == 0 )
+                        {
+                        aMenuPane->SetItemDimmed( EVCCmdDelete, ETrue );
+                        }
+                    CleanupStack::PopAndDestroy( secondRow );
+                    }                
+                }
+            else // No items in listbox
+                {
+                aMenuPane->SetItemDimmed( EVCCmdPlayback, ETrue );
+                aMenuPane->SetItemDimmed( EVCCmdEdit, ETrue );
+                aMenuPane->SetItemDimmed( EVCCmdDelete, ETrue );
+                aMenuPane->SetItemDimmed( EVCCmdOpen, ETrue );
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+//  CVCGenericView::PlaybackVoiceCommandL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::PlaybackVoiceCommandL() 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::PlaybackVoiceCommandL" );
+    
+    CVCAppUi* appUi = static_cast <CVCAppUi*> ( iEikonEnv->AppUi() );
+    
+    TInt state = appUi->CheckCallStateL();
+    TBool videoCallState = appUi->IsVideoCallL();
+    
+    if( ( state == EPSCTsyCallStateNone || state == EPSCTsyCallStateUninitialized ||
+           state == EPSCTsyCallStateHold || state == KErrNotFound ) && !videoCallState ) 
+        {        
+        TInt listboxIndex = iContainer->CurrentSelection();
+        TDesC* listboxItem = iContainer->GetFirstRowNameLC( listboxIndex );
+        
+        const CVCommandUiEntry& vcommand = iModel.GetVCommandL( *listboxItem );
+        CleanupStack::PopAndDestroy( listboxItem );
+        
+        CVCPlaybackDialog* dlg = new (ELeave) CVCPlaybackDialog(
+            iModel.Service(), vcommand );
+        dlg->PrepareLC( R_PLAYBACK_VOICE_COMMAND_DIALOG );
+        dlg->RunLD();
+        dlg = NULL;
+        }
+    else 
+        {
+        // Display call in progress note
+        appUi->CallInProgressNoteL();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVCGenericView::CannotDeleteNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCGenericView::CannotDeleteNoteL() 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCGenericView::CannotDeleteNoteL" );
+    
+    TDesC* name;
+    name = iContainer
+        ->GetSecondRowNameLC( iContainer->CurrentSelection() );
+    
+    if( name->Length() == 0 )
+        {
+        CleanupStack::PopAndDestroy( name );
+        name = iContainer
+            ->GetFirstRowNameLC( iContainer->CurrentSelection() );
+        }
+    
+    HBufC* stringholder = StringLoader::LoadL( R_QTN_VC_INFO_CANNOT_DEL,
+                                               *name, iEikonEnv );
+    CleanupStack::PopAndDestroy( name );
+    CleanupStack::PushL( stringholder );
+    
+    CAknNoteWrapper* note = new ( ELeave ) CAknNoteWrapper();
+    note->ExecuteLD( R_CANNOT_DELETE_NOTE, *stringholder );
+    CleanupStack::PopAndDestroy( stringholder );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVCGenericView::HandleSizeChange
+// Handle screen size change.
+// -----------------------------------------------------------------------------
+//
+void CVCGenericView::HandleSizeChange() 
+    {
+    if (iContainer) 
+        {
+        TRect genericPaneRect;
+        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, genericPaneRect );
+        iContainer->SetRect( genericPaneRect );
+        }
+    }    
+
+// -----------------------------------------------------------------------------
+// CVCGenericView::FolderTitle
+// Returns the title of the view's active folder.
+// -----------------------------------------------------------------------------
+//
+const TDesC& CVCGenericView::FolderTitle() const 
+    {
+    return *iFolderName;
+    }
+
+// -----------------------------------------------------------------------------
+// CVCGenericView::SetFolderTitleL
+// -----------------------------------------------------------------------------
+//
+void CVCGenericView::SetFolderTitleL( const TDesC& aNewName ) 
+    {
+    delete iFolderName;
+    iFolderName = NULL;
+    iFolderName = aNewName.AllocL();    
+    }
+
+// -----------------------------------------------------------------------------
+// CVCGenericView::RefreshViewL
+// -----------------------------------------------------------------------------
+//   
+void CVCGenericView::RefreshViewL()
+    {
+    // This is the focused view
+    if( iContainer )
+        {
+        CVCommandUiEntryArray* oldCommands = iModel.VCommandArrayL();
+        CleanupStack::PushL( oldCommands );
+
+        // Update model
+        iModel.LoadVCommandsL();
+            
+        CVCommandUiEntryArray* newCommands = iModel.VCommandArrayL();
+        CleanupStack::PushL( newCommands );
+    
+        iContainer->RefreshListboxL( *oldCommands, *newCommands );
+    
+        CleanupStack::PopAndDestroy( newCommands );
+        CleanupStack::PopAndDestroy( oldCommands );  
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcmodel.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,237 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Model class for vcommand application wrapping CVCommandHandler
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "vcappui.h"
+#include "vcmodel.h"
+#include "vcplaybackdialog.h"
+#include "vcommanduientry.h"
+#include "vcmodelappuiinterface.h"
+
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CVCModel::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCModel* CVCModel::NewL( MVcModelAppUiInterface* aAppUi )
+    {
+    CVCModel* self = new (ELeave) CVCModel( aAppUi );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CVCModel::CVCModel
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CVCModel::CVCModel( MVcModelAppUiInterface* aAppUi ) : iAppUi( aAppUi )
+    {   
+    }
+ 
+// ----------------------------------------------------------------------------
+// CVCModel::ConstructL
+// Two-phased constructor
+// ----------------------------------------------------------------------------
+//
+void CVCModel::ConstructL() 
+    {
+    iVcHandler = CVCommandHandler::NewL( this );
+    
+    LoadVCommandsL();
+    }
+
+// ----------------------------------------------------------------------------
+// CVCModel::~CVCModel
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CVCModel::~CVCModel() 
+    {
+    delete iVcHandler;
+    delete iListBoxVCommands;
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::GetVCommandL
+// ----------------------------------------------------------------------------
+//
+const CVCommandUiEntry& CVCModel::GetVCommandL( const TDesC& aWrittenText )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCModel::GetVCommandL" );
+    
+    TInt index( KErrNotFound );
+    index = FindVCommandIndexL( aWrittenText );
+    User::LeaveIfError( index );
+    
+    return iListBoxVCommands->At( index );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::At
+// ----------------------------------------------------------------------------
+//
+const CVCommandUiEntry& CVCModel::At( TInt aIndex ) const
+    {
+    // An index that is out of bounds causes a USER-130 panic.
+    return iListBoxVCommands->At( aIndex );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::At
+// ----------------------------------------------------------------------------
+//
+TInt CVCModel::Count() const
+    {
+    return iListBoxVCommands->Count();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::VCommandArrayL
+// ----------------------------------------------------------------------------
+//
+CVCommandUiEntryArray* CVCModel::VCommandArrayL()
+    {    
+    return iListBoxVCommands->CloneL();
+    }
+
+// ----------------------------------------------------------------------------
+// CVCModel::Service
+// ----------------------------------------------------------------------------
+//
+CVCommandHandler& CVCModel::Service()
+    {    
+    return *iVcHandler;
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::LoadVCommandsL
+// ----------------------------------------------------------------------------
+//
+void CVCModel::LoadVCommandsL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCModel::LoadVCommandsL" );
+    
+    // CVCommandHandler::ListCommandsL must be completed when exiting
+    // the application or a panic might occur.
+    iAppUi->StartAtomicOperationLC();
+    CVCommandUiEntryArray* listBoxVCommands
+        = CVCommandUiEntryArray::NewL( iVcHandler->ListCommandsL() );
+        
+    delete iListBoxVCommands;
+    iListBoxVCommands = listBoxVCommands;
+        
+    CleanupStack::PopAndDestroy(); // StartAtomicOperationLC
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::iView->FindVCommandIndexL
+// ----------------------------------------------------------------------------
+//
+TInt CVCModel::FindVCommandIndexL( const TDesC& aWrittenText )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCModel::FindVCommandIndexL" );
+    
+    for( TInt i = 0; i < iListBoxVCommands->Count(); i++ ) 
+        {
+        if( aWrittenText == iListBoxVCommands->At( i ).WrittenText() )
+            {
+            return i;
+            }
+        }
+    
+    return KErrNotFound;
+    }
+
+// ----------------------------------------------------------------------------
+// CVCModel::HasCommandL
+// ----------------------------------------------------------------------------
+//
+TBool CVCModel::HasCommandL( const TDesC& aWrittenText )
+    {
+    return FindVCommandIndexL( aWrittenText ) != KErrNotFound;
+    }
+
+// ----------------------------------------------------------------------------
+// CVCModel::SetNewSpokenTextL
+// ----------------------------------------------------------------------------
+//
+void CVCModel::SetNewSpokenTextL( const TDesC& aWrittenText,
+                                  const TDesC& aNewSpokenText ) 
+    {
+    RUBY_DEBUG_BLOCKL( "CVCModel::UpdateVCommandL" );
+    
+    iAppUi->StartAtomicOperationLC();
+    
+    TInt index( KErrNotFound );
+    index = FindVCommandIndexL( aWrittenText );
+    
+    User::LeaveIfError( index );
+    
+    const CVCommand& oldCommand = iListBoxVCommands->At( index ).Command();
+
+    CVCCommandUi* updatedCommandUi( NULL );
+    CVCFolderInfo* folderInfo
+        = CVCFolderInfo::NewL( oldCommand.CommandUi().FolderInfo() );
+    CleanupStack::PushL( folderInfo );
+    updatedCommandUi = CVCCommandUi::NewL( oldCommand.CommandUi().WrittenText(), 
+                                           *folderInfo,
+                                           oldCommand.CommandUi().Modifiable(),
+                                           oldCommand.CommandUi().Tooltip(), 
+                                           oldCommand.CommandUi().IconUid(),
+                                           aNewSpokenText,
+                                           oldCommand.CommandUi().ConfirmationNeeded() );
+    CleanupStack::PopAndDestroy( folderInfo );
+    CleanupStack::PushL( updatedCommandUi );
+
+    CVCommand* updatedCommand( NULL );
+    updatedCommand = CVCommand::NewL( oldCommand.SpokenText(),
+                                      oldCommand.Runnable(),
+                                      *updatedCommandUi );
+
+    CleanupStack::PopAndDestroy( updatedCommandUi );
+    CleanupStack::PushL( updatedCommand );
+    iVcHandler->AddCommandL( *updatedCommand );
+
+    iVcHandler->RemoveCommandL( oldCommand );
+
+    CleanupStack::PopAndDestroy( updatedCommand ); 
+
+    LoadVCommandsL();
+    
+    CleanupStack::PopAndDestroy(); // StartAtomicOperationLC
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCModel::CommandSetChanged
+// ----------------------------------------------------------------------------
+//
+void CVCModel::CommandSetChanged()
+    {
+    iAppUi->CommandSetChanged();
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcommanduientry.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class to wrap a CVCommand object
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <vcommandapi.h>
+
+#include "vcommanduientry.h"
+
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CVCommandUiEntry::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCommandUiEntry* CVCommandUiEntry::NewL( const CVCommand& aCommand )                                         
+    {
+    CVCommandUiEntry* self = new (ELeave) CVCommandUiEntry( aCommand );
+    return self;
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::CVCommandUiEntry
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CVCommandUiEntry::CVCommandUiEntry( const CVCommand& aCommand ):
+    iCommand( aCommand )
+    {   
+    }
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::~CVCommandUiEntry
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CVCommandUiEntry::~CVCommandUiEntry() 
+    {
+    }
+ 
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::UserText
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::UserText() const
+    {
+    return iCommand.CommandUi().UserText();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::WrittenText
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::WrittenText() const
+    {
+    return iCommand.CommandUi().WrittenText();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::SpokenText
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::SpokenText() const
+    {
+    return iCommand.SpokenText();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::AlternativeSpokenText
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::AlternativeSpokenText() const
+    {
+    return iCommand.AlternativeSpokenText();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::IconLC
+// ----------------------------------------------------------------------------
+//
+CGulIcon* CVCommandUiEntry::IconLC() const
+    {
+    return iCommand.CommandUi().IconLC();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::FolderListedName
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::FolderListedName() const
+    {
+    return iCommand.CommandUi().FolderInfo().ListedName();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::FolderTitle
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::FolderTitle() const
+    {
+    return iCommand.CommandUi().FolderInfo().Title();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::FolderIconLC
+// ----------------------------------------------------------------------------
+//
+CGulIcon* CVCommandUiEntry::FolderIconLC() const
+    {
+    return iCommand.CommandUi().FolderInfo().IconLC();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::Tooltip
+// ----------------------------------------------------------------------------
+//
+const TDesC& CVCommandUiEntry::Tooltip() const
+    {
+    return iCommand.CommandUi().Tooltip();
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::PlaySpokenTextL
+// ----------------------------------------------------------------------------
+//
+void CVCommandUiEntry::PlaySpokenTextL( CVCommandHandler& aService,
+    MNssPlayEventHandler& aPlayEventHandler ) const
+    {
+    iCommand.PlaySpokenTextL( aService, aPlayEventHandler );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::PlayAlternativeSpokenTextL
+// ----------------------------------------------------------------------------
+//
+void CVCommandUiEntry::PlayAlternativeSpokenTextL( CVCommandHandler& aService,
+    MNssPlayEventHandler& aPlayEventHandler ) const
+    {
+    iCommand.PlayAlternativeSpokenTextL( aService, aPlayEventHandler );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::CancelPlaybackL
+// ----------------------------------------------------------------------------
+//
+void CVCommandUiEntry::CancelPlaybackL( CVCommandHandler& aService ) const
+    {
+    iCommand.CancelPlaybackL( aService );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::Command
+// ----------------------------------------------------------------------------
+//
+const CVCommand& CVCommandUiEntry::Command() const
+    {
+    return iCommand;
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCommandUiEntry::IsEqual
+// ----------------------------------------------------------------------------
+//
+TBool CVCommandUiEntry::operator==( const CVCommandUiEntry& aCommand ) const
+    {
+    return iCommand.Runnable() == aCommand.Command().Runnable();
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcommanduientryarray.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A list of CVCommandUiEntry-objects
+*
+*/
+
+
+
+#include <vcommandapi.h>
+#include <mmfcontrollerpluginresolver.h>
+#include "vcommanduientryarray.h"
+#include "rubydebug.h"
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::NewL
+// ----------------------------------------------------------------------------
+//
+CVCommandUiEntryArray* CVCommandUiEntryArray::NewL( CVCommandArray* aArray )
+	{
+	RUBY_DEBUG_BLOCK( "CVCommandUiEntryArray::NewL" );
+	CVCommandUiEntryArray* self = new (ELeave) CVCommandUiEntryArray( aArray );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::CVCommandUiEntryArray
+// ----------------------------------------------------------------------------
+//	
+CVCommandUiEntryArray::CVCommandUiEntryArray( CVCommandArray* aArray )
+    : iCommands(aArray)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::ConstructL
+// ----------------------------------------------------------------------------
+//	
+void CVCommandUiEntryArray::ConstructL()
+	{
+	RUBY_DEBUG_BLOCKL( "CVCommandUiEntryArray::ConstructL" );
+	
+	for( TInt i( 0 ); i < iCommands->Count(); i++ ) 
+		{
+		CVCommandUiEntry* addition
+		    = CVCommandUiEntry::NewL( iCommands->At( i ) );
+		CleanupStack::PushL( addition );
+		iListBoxCommands.AppendL( addition );
+		CleanupStack::Pop( addition );
+		}
+	}	
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::~CVCommandUiEntryArray
+// ----------------------------------------------------------------------------
+//
+CVCommandUiEntryArray::~CVCommandUiEntryArray()
+	{
+	iListBoxCommands.ResetAndDestroy();
+	delete iCommands;
+	}
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::At
+// ----------------------------------------------------------------------------
+//
+const CVCommandUiEntry& CVCommandUiEntryArray::At( TInt aIndex ) const
+	{
+	return *iListBoxCommands[ aIndex ];
+	}
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::operator[]
+// ----------------------------------------------------------------------------
+//
+const CVCommandUiEntry& CVCommandUiEntryArray::operator[]( TInt aIndex ) const
+	{
+	return At( aIndex );
+	}
+
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::Count
+// ----------------------------------------------------------------------------
+//
+TInt CVCommandUiEntryArray::Count() const
+	{
+	return iListBoxCommands.Count();
+	}
+	
+// ----------------------------------------------------------------------------
+// CVCommandUiEntryArray::iView->Clone
+// ----------------------------------------------------------------------------
+//
+CVCommandUiEntryArray* CVCommandUiEntryArray::CloneL()
+    {
+    RVCommandArray vcommands;
+    CleanupResetAndDestroyPushL( vcommands );
+    
+    for( TInt i( 0 ); i < iCommands->Count(); i++ )
+        {
+        vcommands.AppendL( CVCommand::NewL( iCommands->At( i ) ) );
+        }
+    
+    CVCommandArray* array = CVCommandArray::NewL( vcommands );
+    CleanupStack::PopAndDestroy( &vcommands );
+    
+    CleanupStack::PushL( array );
+    
+    CVCommandUiEntryArray* ret = CVCommandUiEntryArray::NewL( array );
+    
+    CleanupStack::Pop( array );
+    
+    return ret;
+    }
+
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcplaybackdialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,324 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CVCPlaybackDialog
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include <StringLoader.h>
+#include <aknnotewrappers.h>
+#include <aknsoundsystem.h>
+#include <aknappui.h>
+#include <avkon.hrh>
+#include <vcommandapi.h>
+#include "vcplaybackdialog.h"
+#include "vcmodel.h"
+#include "rubydebug.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCPlaybackDialog::CVCPlaybackDialog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVCPlaybackDialog::CVCPlaybackDialog( CVCommandHandler& aService,
+                                      const CVCommandUiEntry& aCommand ) : 
+                                      CAknProgressDialog( NULL ),
+                                      iService( aService ),
+                                      iCommand( aCommand )
+    {
+    iTModel.iFinalValue = KVoiceTagRecordLength;
+    iTModel.iHundreths = KInterval;
+    iTModel.iIncrement = KVoiceTagIncrement;
+    iTModel.iRunning = EFalse;
+    iVisibilityDelayOff = ETrue;
+    }
+
+
+// Destructor
+CVCPlaybackDialog::~CVCPlaybackDialog()
+    {
+    if (iProgressBarTimer)
+        {
+        iProgressBarTimer->Cancel();
+        delete iProgressBarTimer;
+        }
+    if (iProgressInfo)
+        {
+        iProgressInfo = NULL;
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::PreLayoutDynInitL
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::PreLayoutDynInitL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::PreLayoutDynInitL" );
+    
+    HBufC* text = StringLoader::LoadLC( R_QTN_VC_PLAYING );
+    SetTextL( *text );
+    CleanupStack::PopAndDestroy( text );
+
+    ButtonGroupContainer().SetCommandSetL( R_SOFTKEYS_QUIT );   
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::PostLayoutDynInitL
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::PostLayoutDynInitL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::PostLayoutDynInitL" );
+    
+    // FIrst check if a user edited command exists
+    if( iCommand.AlternativeSpokenText().Length() > 0 )
+        {
+        iCommand.PlayAlternativeSpokenTextL( iService, *this );
+        }
+    else
+        {
+        iCommand.PlaySpokenTextL( iService, *this );        
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::OkToExitL
+// ---------------------------------------------------------
+//
+TBool CVCPlaybackDialog::OkToExitL( TInt aButtonId )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::OkToExitL" );
+    
+    // Finished playing
+    if ( iExitWhenCalledBack )
+        {
+        return ETrue;
+        }
+
+    if ( ( iTickCount < 1 ) && ( !iExitFlag ) )
+        {
+        return EFalse;
+        }
+
+    // Check what button was pressed
+    switch ( aButtonId )
+        {
+        case EAknSoftkeyOk:
+        break;
+
+        case EKeyPhoneEnd:
+        case EKeyApplication:
+        case EAknSoftkeyQuit:
+            {
+            iOkToExit = ETrue;
+            
+            if ( iExitFlag )
+            	{
+            	iCommand.CancelPlaybackL( iService );
+            	}
+        	
+        	break;
+            }
+            
+        //case EVCommandSoftKeyQuit:
+        case EAknSoftkeyDone:
+            {
+            iOkToExit = ETrue;
+
+            iCommand.CancelPlaybackL( iService );
+            
+            break;
+            }
+
+        default:
+        	iOkToExit = EFalse;  
+        break;
+        }
+
+    return iOkToExit;
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::OfferKeyEventL
+// ---------------------------------------------------------
+//
+TKeyResponse CVCPlaybackDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                                TEventCode aType )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::OfferKeyEventL" );
+    
+    // Only react to red and application key
+    if ( aType == EEventKey )
+        {             
+        if ( aKeyEvent.iCode == EKeyApplication )
+            {
+            iExitFlag = ETrue;
+            TryExitL( EKeyApplication );
+            return EKeyWasConsumed;
+            }
+        else if ( aKeyEvent.iCode == EKeyPhoneEnd )
+            {
+            iExitFlag = ETrue;
+            TryExitL( EKeyPhoneEnd );
+            return EKeyWasConsumed;
+            }
+        }
+    
+    return EKeyWasConsumed;
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::StartTimerL
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::StartTimerL()
+   {
+   RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::StartTimerL" );
+   
+   iTickCount=0;
+   iProgressBarTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+   TTimeIntervalMicroSeconds32 delay( KDelay );
+   TTimeIntervalMicroSeconds32 interval( KMicroSecondsInterval*iTModel.iHundreths );
+   iProgressBarTimer->Start( delay,interval, TCallBack( OnTick, this ) );
+   }
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::StopTimer
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::StopTimer()
+    {
+    if ( iProgressBarTimer )
+        {
+        iProgressBarTimer->Cancel();
+        delete iProgressBarTimer;
+        iProgressBarTimer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::OnTick
+// ---------------------------------------------------------
+//
+TInt CVCPlaybackDialog::OnTick( TAny* aObject )
+    { 
+    STATIC_CAST( CVCPlaybackDialog*, aObject )->DoTick();
+    return 1; // magic
+    }
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::DoTick
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::DoTick()
+    {
+    if ( iTickCount != iTModel.iFinalValue+1 )
+        {
+        iProgressInfo->IncrementAndDraw( iTModel.iIncrement );
+        iTickCount++;
+        }
+
+    if (iExitFlag) 
+        {
+        RUBY_DEBUG0( "CVCPlaybackDialog::DoTick: Exit due to iExitFlag" );
+        StopTimer();
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::DoHandlePlayErrorL
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::DoHandlePlayErrorL( TNssPlayResult aResult )
+    {
+    RUBY_DEBUG1( "CVCPlaybackDialog::DoHandlePlayErrorL: [%d]", aResult );
+    HandlePlayComplete( aResult );
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::HandlePlayStarted
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::HandlePlayStarted(
+    TTimeIntervalMicroSeconds32 aDuration )
+    {
+    TRAP_IGNORE( DoHandlePlayStartedL( aDuration ) );
+    }
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::DoHandlePlayStartedL
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::DoHandlePlayStartedL(
+    TTimeIntervalMicroSeconds32 aDuration )
+    {
+    RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::DoHandlePlayStartedL" );
+    
+    iTModel.iFinalValue = aDuration.Int()/KMicroSecondsInterval;
+    iProgressInfo = GetProgressInfoL();
+    iProgressInfo->SetFinalValue( iTModel.iFinalValue );
+    StartTimerL();
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::HandlePlayComplete
+// ---------------------------------------------------------
+//
+#ifdef _DEBUG
+void CVCPlaybackDialog::HandlePlayComplete( TNssPlayResult aErrorCode )
+#else
+void CVCPlaybackDialog::HandlePlayComplete( TNssPlayResult /*aErrorCode*/ )
+#endif
+    {
+    RUBY_DEBUG1( "CVCPlaybackDialog::HandlePlayComplete: [%d]", aErrorCode );
+    iExitWhenCalledBack = ETrue;
+    StopTimer();
+    TRAP_IGNORE( TryExitL( EAknSoftkeyOk) );
+    }
+
+
+// ---------------------------------------------------------
+// CVCPlaybackDialog::DisplayErrorNoteL
+// ---------------------------------------------------------
+//
+void CVCPlaybackDialog::DisplayErrorNoteL()
+    {
+    RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::DisplayErrorNoteL" );
+    
+    iExitFlag = ETrue;
+    iOkToExit = ETrue; 
+    HBufC* text = StringLoader::LoadLC( R_TEXT_VOICE_SYSTEM_ERROR );
+    CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue );
+    dlg->ExecuteLD( *text );
+    CleanupStack::PopAndDestroy( text );
+    }
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcsettingscontainer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Settings container
+*
+*/
+
+
+// INCLUDE FILES
+#include <eiktxlbx.h>
+#include <aknlists.h>       // CAknSingleGraphicStyleListBox
+#include <barsread.h>       // TResourceReader
+#include <eikclbd.h>        // CColumnListBoxData
+#include <akntitle.h>
+#include <eikspane.h>
+#include <featmgr.h>
+#include <hlplch.h>
+#include <StringLoader.h>
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+#include <csxhelp/vc.hlp.hrh>
+
+#include <vcommand.rsg>
+#include "vcapp.h"
+#include "vcappui.h"
+#include "vcsettingscontainer.h"
+#include "vcsettingsengine.h"
+#include "vcsettingsview.h"
+#include "vcsettingslist.h"
+#include "vcommandconstants.h"
+
+// ========================= MEMBER FUNCTIONS =================================
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::CVCSettingsContainer
+// C++ constructor
+// ----------------------------------------------------------------------------
+//
+CVCSettingsContainer::CVCSettingsContainer( CEikButtonGroupContainer& aCbaGroup ):
+                                            iCbaGroup( aCbaGroup )
+    {
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::ConstructL
+// Symbian OS 2nd phase constructor
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::ConstructL( const TRect& aRect )
+    {
+    CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, iCoeEnv->AppUi() )->StatusPane();
+    CAknTitlePane* title = STATIC_CAST( CAknTitlePane*,
+            sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+
+    TResourceReader rReader;
+    iCoeEnv->CreateResourceReaderLC( rReader, TitleResourceId() );
+    title->SetFromResourceL( rReader );
+    CleanupStack::PopAndDestroy(); //rReader
+    
+    CreateWindowL();
+    iSettingsList = new ( ELeave ) CVCSettingsList();
+    iSettingsList->SetContainerWindowL( *this );
+    iSettingsList->ConstructL();
+    iSettingsList->ListBox()->SetListBoxObserver( this );
+    
+    SetRect(aRect);
+    ActivateL();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::~CVCSettingsContainer
+// ----------------------------------------------------------------------------
+//
+CVCSettingsContainer::~CVCSettingsContainer()
+    {
+    delete iSettingsList; 
+	}
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::CountComponentControls
+// From CCoeControl return the number of controls owned
+// ----------------------------------------------------------------------------
+//
+TInt CVCSettingsContainer::CountComponentControls() const
+    {
+    return 1;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::ComponentControl
+// From CCoeControl returns a control
+// ----------------------------------------------------------------------------
+//
+CCoeControl* CVCSettingsContainer::ComponentControl( TInt /*aIndex*/ ) const
+    {
+    return iSettingsList;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::EditCurrentL
+// Open setting page for currently selected setting item.
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::EditCurrentL( TBool aCalledFromMenu )
+    {
+    TInt index = iSettingsList->ListBox()->CurrentItemIndex();
+
+    iSettingsList->EditItemL( index, aCalledFromMenu );
+	}
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::ResetL
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::ResetL()
+    {
+    CAknQueryDialog* dlg = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone);
+    if ( dlg->ExecuteLD(R_VC_RESET_ADAPTATION_DIALOG) )
+        {
+        CVCSettingsEngine*	engine = CVCSettingsEngine::NewL();
+        CleanupStack::PushL( engine );
+		engine->ResetAdaptationL();
+		CleanupStack::PopAndDestroy( engine ); // engine
+		}
+	}
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::SaveSettingsL
+// Save all settings.
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::SaveSettingsL()
+    {
+    iSettingsList->SaveSettingsL();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::CurrentItemIndex
+// ----------------------------------------------------------------------------
+//
+TInt CVCSettingsContainer::CurrentItemIndex() const
+	{
+	return iSettingsList->ListBox()->CurrentItemIndex();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::ItemListSize
+// ----------------------------------------------------------------------------
+//
+TInt CVCSettingsContainer::ItemListSize() const 
+    {
+    return iSettingsList->ListBox()->Model()->ItemTextArray()->MdcaCount();
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::CurrentItemIndex
+// ----------------------------------------------------------------------------
+//
+TInt CVCSettingsContainer::CurrentItemIdentifier() const
+	{
+	CAknSettingItemArray* itemArray = iSettingsList->SettingItemArray();
+	TInt itemIndex = itemArray->ItemIndexFromVisibleIndex( CurrentItemIndex() );
+    CAknSettingItem* settingItem = itemArray->At( itemIndex );
+    return settingItem->Identifier();
+	}
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::OfferKeyEventL
+// Key event handling
+// ----------------------------------------------------------------------------
+//
+TKeyResponse CVCSettingsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+                                                   TEventCode aType )
+    {  
+    TKeyResponse ret = iSettingsList->OfferKeyEventL( aKeyEvent, aType );
+    
+    // Change MSK
+    if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
+        {
+        SetMiddleSoftkeyLabelL();
+        }
+        
+    return ret;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::GetHelpContext
+// Gives the help context to be displayed
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const
+    {
+    aContext.iMajor = KUidHelp; 
+    aContext.iContext = KHLP_VC_SET;
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::TitleResourceId()
+// Returns profiles views status pane title .
+// ----------------------------------------------------------------------------
+//
+TInt CVCSettingsContainer::TitleResourceId() const
+    {
+    return R_VC_MAIN_VIEW_TITLE;
+    }
+    
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::IsTrainingOn
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::FocusChanged(TDrawNow aDrawNow)
+	{
+    if( iSettingsList )
+        {
+        iSettingsList->SetFocus( IsFocused(), aDrawNow );
+        }
+    }
+     
+     
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::HandleResourceChange
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::HandleResourceChange(TInt aType)
+    {   
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+    	{
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+                                           mainPaneRect);
+        SetRect( mainPaneRect );
+        }
+    CCoeControl::HandleResourceChange( aType );
+    }     
+        
+        
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::SizeChanged
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::SizeChanged()
+    {
+    if (iSettingsList)
+        {
+        iSettingsList->SetRect(Rect());
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::HandleControlEventL
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::HandleControlEventL( CCoeControl* /*aControl*/,
+                                                TCoeEvent /*aEventType*/)
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// CVCSettingsContainer::HandleListBoxEventL
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
+                                                TListBoxEvent aEventType )
+    {
+    switch ( aEventType ) 
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemSingleClicked:
+            {
+            if ( CurrentItemIdentifier() == EVCResetItem )
+                {
+                ResetL();
+                }
+            else
+                {
+                EditCurrentL( EFalse );
+                }            
+            break;
+            }
+            
+        default:
+            break;
+        }
+    }
+
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::SetMiddleSoftkeyLabelL
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::SetMiddleSoftkeyLabelL() const
+    {    
+    RemoveCommandFromMSK();
+    
+    if( CurrentItemIdentifier() == EVCResetItem )
+        {
+        DoSetMiddleSoftKeyLabelL( R_QTN_VC_SET_MSK_RESET, EVCCmdReset );
+        }
+    else
+        {
+        DoSetMiddleSoftKeyLabelL( R_QTN_VC_SET_MSK_CHANGE, EVCCmdChange );
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::SetMiddleSoftKeyLabelL
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::DoSetMiddleSoftKeyLabelL( const TInt aResourceId,
+                                                const TInt aCommandId  ) const
+    {
+    HBufC* mskText = StringLoader::LoadLC( aResourceId );
+    TPtr mskPtr = mskText->Des();
+    iCbaGroup.AddCommandToStackL( KVcMskControlID, aCommandId, mskPtr );
+    CleanupStack::PopAndDestroy( mskText );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsContainer::RemoveCommandFromMSK
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsContainer::RemoveCommandFromMSK() const
+    {
+    iCbaGroup.RemoveCommandFromStack( KVcMskControlID, EVCCmdChange );
+    iCbaGroup.RemoveCommandFromStack( KVcMskControlID, EVCCmdReset );
+    }  
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcsettingsengine.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CVCSettingsEngine
+*
+*/
+
+
+// INCLUDE FILES
+#include <StringLoader.h>
+#include <aknsoundsystem.h>
+#include <aknappui.h>
+
+#include <vcommand.rsg>
+#include "vcsettingsengine.h"
+#include "vcommandconstants.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::CVCSettingsEngine
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVCSettingsEngine::CVCSettingsEngine()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVCSettingsEngine::ConstructL()
+    {
+#ifdef _DEBUG
+    RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::ConstructL"));
+#endif
+
+    iVasDbManager = CNssVASDBMgr::NewL();
+    iVasDbManager->InitializeL();
+    }
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCSettingsEngine* CVCSettingsEngine::NewL()
+    {
+    CVCSettingsEngine* self = new( ELeave ) CVCSettingsEngine;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+    
+// Destructor
+CVCSettingsEngine::~CVCSettingsEngine()
+    {
+    delete iVasDbManager;
+	iContextManager = NULL;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::ResetAdaptationL
+// -----------------------------------------------------------------------------
+//
+void CVCSettingsEngine::ResetAdaptationL()
+    {
+#ifdef _DEBUG
+    RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::ResetAdaptationL"));
+#endif
+
+    iVasDbManager->ResetFactoryModelsL( this );
+	iShedulerWait.Start();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::HandleResetComplete
+// -----------------------------------------------------------------------------
+//
+void CVCSettingsEngine::HandleResetComplete( TInt aErrorCode )
+    {
+#ifdef _DEBUG
+    RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::HandleResetComplete"));
+#endif
+
+    if( aErrorCode != KErrNone ) 
+        {
+        return HandleResetFailed();
+        }
+
+    TRAP_IGNORE( DoHandleResetCompleteL());
+
+	if ( iShedulerWait.IsStarted() )
+		{
+		iShedulerWait.AsyncStop();
+		}
+	}
+
+ 
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::HandleResetComplete
+// -----------------------------------------------------------------------------
+//
+void CVCSettingsEngine::DoHandleResetCompleteL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_QTN_VC_CONF_NOTE_RESET );
+    
+    CAknConfirmationNote* dlg = new (ELeave) CAknConfirmationNote( ETrue );
+    dlg->ExecuteLD( *text );
+    
+    CleanupStack::PopAndDestroy( text );  // text
+    }
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::HandleResetFailed
+// -----------------------------------------------------------------------------
+//
+void CVCSettingsEngine::HandleResetFailed()
+    {
+#ifdef _DEBUG
+    RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::HandleResetFailed"));
+#endif
+
+    TRAP_IGNORE( DisplayErrorNoteL());
+
+	if ( iShedulerWait.IsStarted() )
+		{
+		iShedulerWait.AsyncStop();
+		}
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVCSettingsEngine::DisplayErrorNoteL
+// -----------------------------------------------------------------------------
+//
+void CVCSettingsEngine::DisplayErrorNoteL()
+    {
+#ifdef _DEBUG
+    RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::DisplayErrorNoteL"));
+#endif
+
+    HBufC* text = StringLoader::LoadLC( R_TEXT_VOICE_SYSTEM_ERROR );
+    CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue );
+    dlg->ExecuteLD( *text );
+    PlaySound( EAvkonSIDNameDiallerErrorTone );
+    CleanupStack::PopAndDestroy( text ); // text
+    }
+
+
+// ---------------------------------------------------------
+// CVCSettingsEngine::PlaySound
+// ---------------------------------------------------------
+//
+void CVCSettingsEngine::PlaySound(TAvkonSystemSID aSound) const
+    {
+    if (GetSoundSystem())
+        {
+        GetSoundSystem()->PlaySound(aSound);
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CVCSettingsEngine::SoundSystem
+// ---------------------------------------------------------
+//
+CAknKeySoundSystem* CVCSettingsEngine::GetSoundSystem() const
+    {
+	if (iAvkonAppUiBase)
+		{
+		return iAvkonAppUiBase->KeySounds();	// Static access
+		}
+
+	return NULL;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcsettingslist.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,288 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Settings list class
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <vcommand.rsg>
+#include "vcsettingslist.h"
+#include "vcsettingsengine.h"
+#include "vcommand.hrh"
+#include "vcappui.h"
+#include "vcommandconstants.h"
+
+#include <vcommanddomaincrkeys.h>
+#include <srsfdomaincrkeys.h>
+#include <centralrepository.h>
+#include <StringLoader.h>
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+
+
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CVCSettingsList::CVCSettingsList
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CVCSettingsList::CVCSettingsList()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CVCSettingsList::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsList::ConstructL()
+    {
+    LoadSettingsL();
+    ConstructFromResourceL( R_VC_SETTING_ITEM_LIST );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CVCSettingsList::~CVCSettingsList
+// ----------------------------------------------------------------------------
+//
+CVCSettingsList::~CVCSettingsList()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CVCSettingsList::CreateSettingItemL
+// From CAknSettingItemList Handles creating setting items
+// ---------------------------------------------------------------------------
+//
+CAknSettingItem* CVCSettingsList::CreateSettingItemL( TInt aIdentifier )
+    {
+    CAknSettingItem* settingItem = NULL;
+
+    switch ( aIdentifier )
+        {
+        case EVCSynthesizerItem:
+            {
+            settingItem = new ( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, iSynthesizer );
+            break;
+            }
+    
+        case EVCVolumeItem:
+            {
+            settingItem = new ( ELeave ) CAknVolumeSettingItem( aIdentifier, iVolumeValue );
+            break;
+            }
+ 
+        case EVCRejectionItem: 
+            {
+            settingItem = new ( ELeave ) CAknSliderSettingItem( aIdentifier, iRejectionValue );
+            break;
+            } 
+            
+        case EVCVerificationItem:
+            {
+            settingItem = new ( ELeave ) CAknEnumeratedTextPopupSettingItem( aIdentifier, iVerification );
+            break;
+            }
+    
+          case EVCResetItem:
+            {
+            settingItem = new ( ELeave ) CAknBigSettingItemBase( aIdentifier );
+            break;
+            }
+        
+        default:
+            {
+            break;
+            }
+        }
+
+    return settingItem;
+    }
+
+ 
+// ---------------------------------------------------------------------------
+// CVCSettingsList::LoadSettingsL
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsList::LoadSettingsL()
+    {
+    CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+    iSynthesizer = ETrue;
+    iVolumeValue = KSettingsVolume;
+    iRejectionValue = KSettingsRejection;
+    iVerification = KSettingsVerification;
+
+    User::LeaveIfError( client->Get( KVCSynthesizer, iSynthesizer ) );
+    User::LeaveIfError( client->Get( KVCVerification, iVerification ) );
+    CleanupStack::PopAndDestroy( client ); // client
+    
+    client = CRepository::NewLC( KCRUidSRSFSettings );
+    User::LeaveIfError( client->Get( KSRSFPlaybackVolume, iVolumeValue ) );
+    User::LeaveIfError( client->Get( KSRSFRejection, iRejectionValue ) );
+    CleanupStack::PopAndDestroy( client );    // client
+    }
+
+
+// ---------------------------------------------------------------------------
+// CVCSettingsList::SaveSettingsL
+// Apply settings to CCcorController.
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsList::SaveSettingsL()
+    {
+    StoreSettingsL();
+
+    CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+    User::LeaveIfError( client->Set( KVCSynthesizer, iSynthesizer ) );
+    User::LeaveIfError( client->Set( KVCVerification, iVerification ) );
+    CleanupStack::PopAndDestroy( client );
+    
+    client = CRepository::NewLC( KCRUidSRSFSettings );
+    User::LeaveIfError( client->Set( KSRSFPlaybackVolume, iVolumeValue ) );
+    User::LeaveIfError( client->Set( KSRSFRejection, iRejectionValue ) );
+    CleanupStack::PopAndDestroy( client );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CVCSettingsList::EditItemL
+// Launch the setting page for the current item by calling
+// EditItemL on it.
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsList::EditItemL( TInt aIndex, TBool aCalledFromMenu )
+    {
+    CAknSettingItemArray* itemArray = SettingItemArray();
+    TInt itemIndex = itemArray->ItemIndexFromVisibleIndex( aIndex );
+    CAknSettingItem* settingItem = itemArray->At( itemIndex );
+    TInt itemIdentifier = settingItem->Identifier();
+    
+    switch( itemIdentifier )
+        {
+        case EVCSynthesizerItem:
+            {
+            CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
+            StoreSettingsL();
+            
+            if( iSynthesizer == ESynthesizerOff )
+                {
+                // Disable voice verification
+                if( iVerification == EVoice )
+                    {                    
+                    itemIndex = itemArray->ItemIndexFromVisibleIndex( EVCVerificationItem );
+                    settingItem = itemArray->At( itemIndex );
+                    // Change the setting
+                    iVerification = EAutomatic;
+                    settingItem->LoadL();
+                    // Update the view
+                    HandleChangeInItemArrayOrVisibilityL();
+                    
+                    // Display a note
+                    VoiceVerificationDisabledNoteL();
+                    }
+                }
+            
+            break;
+            }
+            
+        case EVCVolumeItem:
+        case EVCRejectionItem:
+            {
+            // ETrue for always opening the settings view 
+            CAknSettingItemList::EditItemL( aIndex, ETrue );
+            break;            
+            }
+            
+        case EVCVerificationItem:
+            {
+            // ETrue for always opening the settings view 
+            CAknSettingItemList::EditItemL( aIndex, ETrue );
+            StoreSettingsL();
+            
+            if( iVerification == EVoice )
+                {
+                // Enable synthesizer
+                if( iSynthesizer == ESynthesizerOff )
+                    {                    
+                    // Binary setting item, so we can just choose to the other one
+                    EditItemL( EVCSynthesizerItem, EFalse );
+                    
+                    // Update the view
+                    HandleChangeInItemArrayOrVisibilityL();
+                    
+                    // Display a note
+                    SynthesizerEnabledNoteL();
+                    }
+                }
+            
+            break;            
+            }
+        
+        default:
+            {
+            break;
+            }
+        }
+
+    SaveSettingsL();
+    }
+
+// ---------------------------------------------------------------------------
+// CVCSettingsList::SizeChanged
+// Set the size and position of component controls.
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsList::SizeChanged()
+    {
+    CAknSettingItemList::SizeChanged();
+
+    CEikListBox* lb = ListBox();
+    if( lb )
+        {
+        lb->SetRect( Rect() );  // Set container's rect to listbox
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsList::CommandTooShortNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsList::SynthesizerEnabledNoteL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_QTN_VC_INFO_NOTE_SYNTHESIZER_ON );
+    CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
+    note->ExecuteLD( *text );
+    CleanupStack::PopAndDestroy( text );
+    }
+    
+// ----------------------------------------------------------------------------
+// CVCSettingsList::VoiceVerificationDisabledNoteL
+// ----------------------------------------------------------------------------
+//
+void CVCSettingsList::VoiceVerificationDisabledNoteL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_QTN_VC_INFO_NOTE_VOICE_VERIFICATION_OFF );
+    CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
+    note->ExecuteLD( *text );
+    CleanupStack::PopAndDestroy( text );
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vcsettingsview.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,215 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Settings view
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <avkon.hrh>
+#include <aknViewAppUi.h>
+#include <akntabgrp.h>
+#include <akntitle.h>  // CAknTitlePane
+#include <featmgr.h>
+#include <eikmenup.h>
+#include <barsread.h>
+#include <StringLoader.h>
+#include <hlplch.h>
+
+#include <vcommand.rsg>
+#include "vcommand.hrh"
+#include "vcappui.h"
+#include "vcsettingsview.h"
+#include "vcsettingscontainer.h"
+#include "vcommandconstants.h"
+#include "rubydebug.h"
+
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CVCSettingsView::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsView::ConstructL()
+    {
+    BaseConstructL( R_VC_SETTING_LIST_VIEW );
+    }
+
+
+// Destructor
+CVCSettingsView::~CVCSettingsView()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromStack( iContainer );
+        delete iContainer;
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CVCSettingsView::Id
+// From CAknView, returns Uid of View
+// ---------------------------------------------------------------------------
+//
+TUid CVCSettingsView::Id() const
+    {
+    return KUidVCSettingsView;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CVCSettingsView::HandleCommandL
+// From MEikMenuObserver delegate commands from the menu
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsView::HandleCommandL( TInt aCommand )
+    {
+    if( !iOperationInProgress )
+        {
+        iOperationInProgress = ETrue;
+        
+        switch ( aCommand )
+            {
+            case EVCMenuCmdChange:
+                {
+                // ETrue for opening the settings view
+                iContainer->EditCurrentL( ETrue );
+                break;
+                }
+                
+            case EVCCmdChange:
+                {
+    		    iContainer->EditCurrentL( EFalse );
+                break;
+                }
+
+    		case EVCCmdReset:
+    			{
+    			iContainer->ResetL();
+    			break;
+    			}
+    			
+            case EAknCmdHelp:
+            	{
+                HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
+                                                     AppUi()->AppHelpContextL() );
+                break;
+            	}
+
+            case EAknSoftkeyBack:
+                {
+                AppUi()->ActivateLocalViewL( iPreviousView.iViewUid );
+                break;
+                }
+
+            default:
+                {
+                AppUi()->HandleCommandL( aCommand );
+                break;
+                }
+            }
+            
+        iOperationInProgress = EFalse;
+        }
+    
+
+    }
+
+// ---------------------------------------------------------------------------
+// CVCSettingsView::DoActivateL
+// Activate this view
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsView::DoActivateL( const TVwsViewId& aPrevViewId,
+                                   TUid /*aCustomMessageId*/,
+                                   const TDesC8& /*aCustomMessage*/ )
+    {
+    if ( !iContainer )
+        {
+        iContainer = new ( ELeave ) CVCSettingsContainer( *(Cba()) );
+        iContainer->SetMopParent( this );
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        iContainer->ActivateL();
+        }
+        
+    iPreviousView = aPrevViewId;
+        
+    iContainer->SetMiddleSoftkeyLabelL();
+    }
+
+// ---------------------------------------------------------------------------
+// CVCSettingsView::DoDeactivate
+// Deactivate this view
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsView::DoDeactivate()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromStack(iContainer);
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CVCSettingsView::DynInitMenuPaneL
+// Dynamically customize menu items
+// ---------------------------------------------------------------------------
+//
+void CVCSettingsView::DynInitMenuPaneL( TInt aResourceId,
+                                            CEikMenuPane* aMenuPane )
+    {
+	if ( aResourceId == R_VC_SETTINGS_MENU )
+        {
+        if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+            {
+            aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue);
+            }
+
+		TInt index = iContainer->CurrentItemIndex();
+
+		if ( index + 1 != iContainer->ItemListSize() )
+			{
+			aMenuPane->SetItemDimmed( EVCCmdReset, ETrue );
+			}
+		else
+			{
+			aMenuPane->SetItemDimmed( EVCMenuCmdChange, ETrue );
+			}
+        }
+	}
+
+// ---------------------------------------------------------
+// CVCSettingsView::HandleClientRectChange
+// ---------------------------------------------------------
+//
+void CVCSettingsView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, 
+            mainPaneRect );
+        iContainer->SetRect( mainPaneRect );
+        }
+    }
+    
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vctextquerydialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Text query dialog for editing commands
+*
+*/
+
+
+// INCLUDE FILES
+#include "vctextquerydialog.h"
+
+// -----------------------------------------------------------------------------
+// CVCTextQueryDialog::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVCTextQueryDialog* CVCTextQueryDialog::NewL( TDes& aDataText, const TTone& aTone )
+    {
+    CVCTextQueryDialog* self = new (ELeave) CVCTextQueryDialog( aDataText, aTone );
+    return self;
+    }   
+    
+// Destructor       
+CVCTextQueryDialog::~CVCTextQueryDialog()
+    {
+    }
+
+// ---------------------------------------------------------
+// CVCTextQueryDialog::CheckIfEntryTextOk
+// ---------------------------------------------------------
+//      
+TBool CVCTextQueryDialog::CheckIfEntryTextOk() const
+    {
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CVCTextQueryDialog::UpdateLeftSoftKeyL
+// ---------------------------------------------------------
+//   
+void CVCTextQueryDialog::UpdateLeftSoftKeyL()
+    {
+    CAknTextQueryDialog::UpdateLeftSoftKeyL();
+
+    MakeLeftSoftkeyVisible(CheckIfEntryTextOk());
+    }
+
+// ---------------------------------------------------------
+// CVCTextQueryDialog::CVCTextQueryDialog
+// ---------------------------------------------------------
+//              
+CVCTextQueryDialog::CVCTextQueryDialog( TDes& aDataText, const TTone& aTone )
+ : CAknTextQueryDialog( aDataText, aTone )
+    {
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/vcommand/src/vctonereader.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,293 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles the tone playing for the Voice commands UI
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <aknSoundinfo.h>
+#include "vctonereader.h"
+#include <eikcolib.h>
+#include <aknsoundsystem.h>
+#include <aknappui.h>
+
+// CONSTANTS
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CVCToneReader::CVCToneReader()
+    {
+    }
+
+// Default constructor can leave.
+void CVCToneReader::ConstructL()
+    {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::ConstructL"));
+#endif
+
+    iAbortInfo = CAknSoundInfo::NewL();
+    iErrorInfo = CAknSoundInfo::NewL();
+
+    iAbortToneSequence = ReadToneSequenceL(iAbortInfo,
+    							EAvkonSIDNameDiallerAbortTone,
+                            	&iAbortTonePriority,&iAbortTonePreference,
+                            	&iAbortToneVolume);
+                            	
+    iErrorToneSequence = ReadToneSequenceL(iErrorInfo,
+    							EAvkonSIDNameDiallerErrorTone,
+                            	&iErrorTonePriority,&iErrorTonePreference,
+                            	&iErrorToneVolume);
+
+    iToneUtility = CMdaAudioToneUtility::NewL(*this);    
+    }
+
+// Two-phased constructor.
+CVCToneReader* CVCToneReader::NewL()
+    {
+    CVCToneReader* self = new ( ELeave ) CVCToneReader;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+    
+// Destructor
+CVCToneReader::~CVCToneReader()
+    {
+#ifdef _DEBUG
+    RDebug::Print(_L("CVCToneReader::~CVCToneReader"));
+#endif
+   
+    delete iToneUtility;
+    
+    delete iAbortInfo;
+    delete iErrorInfo;
+    iAbortToneSequence = NULL;
+    iErrorToneSequence = NULL;
+    }
+
+// ---------------------------------------------------------
+// CVCToneReader::ReadToneSequenceL
+// Reads the tone sequence from the Avkon resource file
+// ---------------------------------------------------------
+//
+HBufC8* CVCToneReader::ReadToneSequenceL( CAknSoundInfo* aInfo, TInt aSid, 
+                                              TInt* aTonePriority,
+                                              TMdaPriorityPreference* aTonePreference, 
+                                              TInt* aToneVolume )
+   {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::ReadToneSequenceL: aSid = %d"),aSid); 
+#endif
+	if (iAvkonAppUiBase)
+		{
+		iAvkonAppUiBase->KeySounds()->RequestSoundInfoL( aSid, *aInfo );	// Static access
+		}
+
+   *aTonePriority = aInfo->iPriority;
+   *aToneVolume = aInfo->iVolume;
+   *aTonePreference = (TMdaPriorityPreference)aInfo->iPreference;
+   return aInfo->iSequence;
+   }
+
+
+// ---------------------------------------------------------
+// CVCToneReader::TonePriority
+// Sets the tone priority 
+// ---------------------------------------------------------
+//
+TInt CVCToneReader::TonePriority(TInt aSid)
+   {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::TonePriority"));  
+#endif
+
+   TInt priority = -1;
+   switch (aSid)
+      {
+      case EAvkonSIDNameDiallerErrorTone:
+         priority = iErrorTonePriority;
+         break;
+
+      case EAvkonSIDNameDiallerAbortTone:
+         priority = iAbortTonePriority;
+         break;
+
+      default:
+         break;
+      }
+   return priority;
+   }
+
+// ---------------------------------------------------------
+// CVCToneReader::TonePriorityPreference
+// Sets the appropriate priority preference
+// ---------------------------------------------------------
+//
+TMdaPriorityPreference CVCToneReader::TonePriorityPreference(TInt aSid)
+   {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::TonePriorityPreference"));    
+#endif
+   TMdaPriorityPreference preference;
+   switch (aSid)
+      {
+      case EAvkonSIDNameDiallerErrorTone:
+         preference = iErrorTonePreference;
+         break;
+
+      case EAvkonSIDNameDiallerAbortTone:
+         preference = iAbortTonePreference;
+         break;
+
+      default:
+         preference = iErrorTonePreference;
+         break;
+      }
+   return preference;
+   }
+
+
+// ---------------------------------------------------------
+// CVCToneReader::ToneSequence
+// Sets the appropriate tone sequence
+// ---------------------------------------------------------
+//
+HBufC8* CVCToneReader::ToneSequence(TInt aSid)
+   {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::ToneSequence"));  
+#endif
+   HBufC8* sequence = NULL;
+
+   switch (aSid)
+      {
+      case EAvkonSIDNameDiallerErrorTone:
+         sequence = iErrorToneSequence;
+         break;
+
+      case EAvkonSIDNameDiallerAbortTone:
+         sequence = iAbortToneSequence;
+         break;
+
+      default:
+         break;
+      }
+   return sequence;
+   }
+
+
+
+// ---------------------------------------------------------
+// CVCToneReader::ToneVolume
+// Sets the appropriate tone volume
+// ---------------------------------------------------------
+//
+TInt CVCToneReader::ToneVolume(TInt aSid)
+   {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::ToneVolume"));    
+#endif
+   TInt volume = -1;
+
+   switch (aSid)
+      {
+      case EAvkonSIDNameDiallerErrorTone:
+         volume = iErrorToneVolume;
+         break;
+
+      case EAvkonSIDNameDiallerAbortTone:
+         volume = iAbortToneVolume;
+         break;
+
+      default:
+         break;
+      }
+   return volume;
+   }
+
+
+// ---------------------------------------------------------
+// CVCToneReader::PlayTone
+// Plays the appropriate tone
+// ---------------------------------------------------------
+//
+void CVCToneReader::PlayTone(MVCTonePlayer* aTonePlayer,TInt aSid)
+    {
+    iTonePlayer = aTonePlayer;
+    iTonePriority = TonePriority(aSid);
+    iTonePreference = TonePriorityPreference(aSid);
+    iToneVolume = ToneVolume(aSid);
+
+    iToneUtility->PrepareToPlayDesSequence(ToneSequence(aSid)->Des());
+    }
+
+
+// ---------------------------------------------------------
+// CVCToneReader::MatoPrepareComplete
+// Callback from the CMdaToneUtility when tone preparation is 
+// complete
+// ---------------------------------------------------------
+//
+void CVCToneReader::MatoPrepareComplete(TInt aError)
+    {
+   	if (aError == KErrNone)
+      	{
+      	iToneUtility->SetPriority(iTonePriority, iTonePreference);
+      	iToneUtility->SetVolume(iToneVolume);
+      	iToneUtility->Play();
+      	}
+      else
+      	{
+      	if (iTonePlayer)
+    		{
+    		iTonePlayer->MntpToneError();
+    		}
+      	}
+	}
+    
+
+// ---------------------------------------------------------
+// CVCToneReader::MatoPlayComplete
+// Callback from the CMdaToneUtility when the tone playing
+// is complete
+// ---------------------------------------------------------
+//
+void CVCToneReader::MatoPlayComplete(TInt /*aError*/)
+    {
+#ifdef _DEBUG
+   RDebug::Print(_L("CVCToneReader::MatoPlayComplete")); 
+#endif
+    if (iTonePlayer)
+    	{
+    	iTonePlayer->MntpToneComplete();
+    	}
+    }
+
+
+//  End of File  
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/bmarm/voiceuirecognitionu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	E32Dll__F10TDllReason @ 1 NONAME R3UNUSED ; E32Dll(TDllReason)
+	ExecuteLD__23CVoiceRecognitionDialog @ 2 NONAME R3UNUSED ; CVoiceRecognitionDialog::ExecuteLD(void)
+	NewLC__11CVoiceRecog @ 3 NONAME R3UNUSED ; CVoiceRecog::NewLC(void)
+	NewL__11CVoiceRecog @ 4 NONAME R3UNUSED ; CVoiceRecog::NewL(void)
+	"_._23CVoiceRecognitionDialog" @ 5 NONAME R3UNUSED ; CVoiceRecognitionDialog::~CVoiceRecognitionDialog(void)
+	__23CVoiceRecognitionDialog @ 6 NONAME R3UNUSED ; CVoiceRecognitionDialog::CVoiceRecognitionDialog(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/bwins/voiceuirecognitionu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	??0CVoiceRecognitionDialog@@QAE@XZ @ 1 NONAME ; public: __thiscall CVoiceRecognitionDialog::CVoiceRecognitionDialog(void)
+	??1CVoiceRecognitionDialog@@UAE@XZ @ 2 NONAME ; public: virtual __thiscall CVoiceRecognitionDialog::~CVoiceRecognitionDialog(void)
+	?E32Dll@@YAHW4TDllReason@@@Z @ 3 NONAME ; int __cdecl E32Dll(enum TDllReason)
+	?ExecuteLD@CVoiceRecognitionDialog@@QAEHXZ @ 4 NONAME ; public: int __thiscall CVoiceRecognitionDialog::ExecuteLD(void)
+	?NewL@CVoiceRecog@@SAPAV1@XZ @ 5 NONAME ; public: static class CVoiceRecog * __cdecl CVoiceRecog::NewL(void)
+	?NewLC@CVoiceRecog@@SAPAV1@XZ @ 6 NONAME ; public: static class CVoiceRecog * __cdecl CVoiceRecog::NewLC(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/bwinscw/voiceuirecognitionu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,7 @@
+EXPORTS
+	??0CVoiceRecognitionDialog@@QAE@XZ @ 1 NONAME ; CVoiceRecognitionDialog::CVoiceRecognitionDialog(void)
+	??1CVoiceRecognitionDialog@@UAE@XZ @ 2 NONAME ; CVoiceRecognitionDialog::~CVoiceRecognitionDialog(void)
+	?ExecuteLD@CVoiceRecognitionDialog@@QAEHXZ @ 3 NONAME ; int CVoiceRecognitionDialog::ExecuteLD(void)
+	?NewL@CVoiceRecog@@SAPAV1@XZ @ 4 NONAME ; class CVoiceRecog * CVoiceRecog::NewL(void)
+	?NewLC@CVoiceRecog@@SAPAV1@XZ @ 5 NONAME ; class CVoiceRecog * CVoiceRecog::NewLC(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/bwinscw/voiceuivoicerecognitionau.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	??0CVoiceRecognitionDialog@@QAE@XZ @ 1 NONAME ; CVoiceRecognitionDialog::CVoiceRecognitionDialog(void)
+	??1CVoiceRecognitionDialog@@UAE@XZ @ 2 NONAME ; CVoiceRecognitionDialog::~CVoiceRecognitionDialog(void)
+	?ExecuteLD@CVoiceRecognitionDialog@@QAEHXZ @ 3 NONAME ; int CVoiceRecognitionDialog::ExecuteLD(void)
+	?NewL@CVoiceRecog@@SAPAV1@XZ @ 4 NONAME ; class CVoiceRecog * CVoiceRecog::NewL(void)
+	?NewLC@CVoiceRecog@@SAPAV1@XZ @ 5 NONAME ; class CVoiceRecog * CVoiceRecog::NewLC(void)
+	?Cancel@CVoiceRecognitionDialog@@QAEXXZ @ 6 NONAME ; void CVoiceRecognitionDialog::Cancel(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/bwinscw/voiceuivoicerecognitionu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,7 @@
+EXPORTS
+	??0CVoiceRecognitionDialog@@QAE@XZ @ 1 NONAME ; CVoiceRecognitionDialog::CVoiceRecognitionDialog(void)
+	??1CVoiceRecognitionDialog@@UAE@XZ @ 2 NONAME ; CVoiceRecognitionDialog::~CVoiceRecognitionDialog(void)
+	?ExecuteLD@CVoiceRecognitionDialog@@QAEHXZ @ 3 NONAME ; int CVoiceRecognitionDialog::ExecuteLD(void)
+	?NewL@CVoiceRecog@@SAPAV1@XZ @ 4 NONAME ; class CVoiceRecog * CVoiceRecog::NewL(void)
+	?NewLC@CVoiceRecog@@SAPAV1@XZ @ 5 NONAME ; class CVoiceRecog * CVoiceRecog::NewLC(void)
+
Binary file voiceui/voiceuivoicerecognition/data/btnamediallerstarttone.wav has changed
Binary file voiceui/voiceuivoicerecognition/data/namediallerconfirmtone.wav has changed
Binary file voiceui/voiceuivoicerecognition/data/namediallerstarttone.wav has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/data/vuivoicerecognition.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,447 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+NAME RAPI
+
+#include <eikon.rh>
+#include <EIKCORE.rsg>
+#include <avkon.rsg>    
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <avkon.loc>
+#include <badef.rh>
+#include <appinfo.rh>
+#include <AvkonIcons.hrh>
+#include <vuivoicerecognition.loc>
+#include <data_caging_paths_strings.hrh>
+
+#include "vuivoicerecognition.hrh"
+
+// CONSTANTS
+#define KVoiceStartSoundFile           "z:\\system\\sounds\\digital\\namediallerstarttone.wav"
+#define KVoiceConfirmationSoundFile    "z:\\system\\sounds\\digital\\namediallerconfirmtone.wav"
+#define KVoiceBTStartSoundFile         "z:\\system\\sounds\\digital\\btnamediallerstarttone.wav"
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf = r_main_view_title; }
+
+RESOURCE EIK_APP_INFO
+    {
+    status_pane = r_main_status_pane;
+    }
+
+//-----------------------------------------------------------------------------
+//   
+//    r_main_status_pane
+//    Status pane for main view.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE STATUS_PANE_APP_MODEL r_main_status_pane
+    {
+    //Set status pane as empty to fix layouts
+    layout = R_AVKON_STATUS_PANE_LAYOUT_EMPTY;
+    panes =
+        {
+        SPANE_PANE
+            {
+            id = EEikStatusPaneUidTitle;
+            type = EAknCtTitlePane;
+            resource = r_main_view_title;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//   
+//    r_localisable_app_info
+//    menu captions and application icon
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
+    {
+    short_caption = qtn_sivc_appl_grid;
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = qtn_sivc_appl_list;
+        number_of_icons = 1;
+        icon_file = APP_BITMAP_DIR"\\vuivoicerecognition_aif.mif";
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//   
+//    r_main_view_title
+//    Main view's title.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE TITLE_PANE r_main_view_title
+    {
+    txt = qtn_sivc_title;
+    }
+
+//----------------------------------------------------
+//
+//      r_softkeys_select_quit__select
+//        N-Best list cba buttons
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_softkeys_select_quit__select
+    {
+    buttons =
+        {
+        CBA_BUTTON { id=EVoiceTagSoftKeySelect; txt=text_softkey_select; },
+        CBA_BUTTON { id=EVoiceTagSoftKeyQuit;   txt=text_softkey_quit; },
+        CBA_BUTTON { id=EVoiceTagSoftKeySelect; txt=qtn_msk_select; }
+        };
+    }
+    
+//----------------------------------------------------
+//
+//      r_softkeys_select_quit__select
+//        N-Best list cba buttons
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_softkeys_options_quit__select
+    {
+    buttons =
+        {
+        CBA_BUTTON { id=EAknSoftkeyOptions;     txt=text_softkey_option; },
+        CBA_BUTTON { id=EVoiceTagSoftKeyQuit;   txt=text_softkey_quit; },
+        CBA_BUTTON { id=EVoiceTagSoftKeySelect; txt=qtn_msk_select; }
+        };
+    }
+
+//----------------------------------------------------
+//
+//      r_softkeys_next_cancel__next
+//        Tutorial message cba buttons
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_softkeys_next_cancel__next
+    {
+    buttons =
+        {
+        CBA_BUTTON { id=EVoiceInfoSoftKeyNext;    txt=qtn_vc_softkey_next; },
+        CBA_BUTTON { id=EVoiceInfoSoftKeyCancel;  txt=text_softkey_cancel; },
+        CBA_BUTTON { id=EVoiceInfoSoftKeyNext;    txt=qtn_vc_softkey_next; }
+        };
+    }
+
+//----------------------------------------------------
+//
+//      r_softkeys_activate_cancel__activate
+//        Tutorial message cba buttons
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_softkeys_activate_cancel__activate
+    {
+    buttons =
+        {
+        CBA_BUTTON { id=EVoiceInfoSoftKeyActivate; txt=qtn_vc_softkey_activate; },
+        CBA_BUTTON { id=EVoiceInfoSoftKeyCancel;   txt=text_softkey_cancel; },
+        CBA_BUTTON { id=EVoiceInfoSoftKeyActivate; txt=qtn_vc_softkey_activate; }
+        };
+    }
+    
+//----------------------------------------------------
+//
+//      r_softkeys_ok_cancel__ok
+//        Verification query cba buttons
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_softkeys_ok_cancel__ok
+    {
+    buttons =
+        {
+        CBA_BUTTON { id=EVoiceTagSoftKeySelect;   txt=text_softkey_ok; },
+        CBA_BUTTON { id=EVoiceTagSoftKeyCancel;   txt=text_softkey_cancel; },
+        CBA_BUTTON { id=EVoiceTagSoftKeySelect;   txt=text_softkey_ok; }
+        };
+    }
+
+//----------------------------------------------------
+//
+//      r_progressnote
+//        Speak now progress dialog
+//
+//----------------------------------------------------
+//    
+RESOURCE DIALOG r_progressnote
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_QUIT;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EProgressDialogId;
+            control = AVKON_NOTE
+                {
+                layout = EProgressLayout;
+                };
+            }
+        };
+    }
+    
+//----------------------------------------------------
+//
+//      r_message_query
+//        Tutorial message dialog
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_message_query
+{
+   flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+   buttons = r_softkeys_select_quit__select;
+   items=
+   {
+      DLG_LINE 
+      {
+         type = EAknCtPopupHeadingPane;
+         id = EAknMessageQueryHeaderId;
+         itemflags = EEikDlgItemNonFocusing;
+         control = AVKON_HEADING
+         {
+         };
+      },
+      DLG_LINE
+      {
+         type = EAknCtMessageQuery;
+         id = EAknMessageQueryContentId;
+         control = AVKON_MESSAGE_QUERY
+         {
+         };
+      }
+   };
+}
+
+// ---------------------------------------------------------
+//   
+//   r_nbest_options_menu
+//   Menu title definition
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_BAR r_nbest_options_menu
+    {
+    titles =
+        {
+        MENU_TITLE 
+            {
+            menu_pane = r_nbest_menu_pane;
+            }
+        };
+    }
+    
+// ---------------------------------------------------------
+//   
+//   r_nbest_menu_pane
+//   Menu for "Options"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_nbest_menu_pane
+    {
+    items = 
+        {
+        MENU_ITEM 
+            {    
+            command = EVoiceTagSoftKeySelect;  txt = qtn_vc_options_select;
+            },
+        MENU_ITEM 
+            {
+            command = EVoiceTagSoftKeyOpen;    txt = qtn_vc_nbest_options_open_contact;
+            },
+        MENU_ITEM 
+            {
+            command = EVoiceTagSoftKeyQuit;    txt = qtn_vc_nbest_options_quit;
+            }
+        };
+    }
+
+//----------------------------------------------------
+//
+//      r_nbest_popup_list
+//        N-Best List query dialog
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_nbest_popup_list
+    {
+    flags = EGeneralQueryFlags;
+    softkeys = r_softkeys_select_quit__select;
+    items = 
+        {
+        AVKON_LIST_QUERY_DLG_LINE 
+            {
+            type = EAknCtListQueryControl;
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtDoubleGraphicPopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST;
+                heading = qtn_vc_nbest_list_header;
+                };            
+            }
+        };
+    }
+    
+RESOURCE ARRAY r_verification_query_item
+    {
+    items =
+        {
+        LBUF { txt = qtn_vc_verification_select; },
+        LBUF { txt = qtn_vc_verification_other; },
+        LBUF { txt = qtn_vc_verification_cancel; }
+        };
+    }
+    
+//----------------------------------------------------
+//
+//      r_verification_query
+//        Verification query dialog
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_verification_query
+    {
+    flags = EGeneralQueryFlags;
+    softkeys = r_softkeys_ok_cancel__ok;
+    items = 
+        {
+        AVKON_LIST_QUERY_DLG_LINE 
+            {
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    array_id = r_verification_query_item;
+                    };
+                heading = " ";
+                };
+            }
+        };
+    }
+
+
+//----------------------------------------------------
+//
+//      r_nbest_row_format
+//        Row format for N-Best List listbox
+//
+//----------------------------------------------------
+//
+RESOURCE TBUF r_nbest_row_format
+    {
+    buf = "%U\t%U\t";
+    }
+
+
+//----------------------------------------------------
+//   
+//    r_voice_start_sound_path
+//    Path to a sound file to play when starting voice dialing
+//
+//----------------------------------------------------
+//
+RESOURCE TBUF r_voice_start_sound_path
+    {
+    buf = KVoiceStartSoundFile;
+    }
+
+//----------------------------------------------------
+//   
+//    r_voice_bt_start_sound_path
+//    Path to a sound file to play when starting voice dialing from bluetooth accessory
+//
+//----------------------------------------------------
+//
+RESOURCE TBUF r_voice_bt_start_sound_path
+    {
+    buf = KVoiceBTStartSoundFile;
+    }
+    
+//----------------------------------------------------
+//   
+//    r_voice_confirmation_sound_path
+//    Path to a sound file to play when starting an application
+//
+//----------------------------------------------------
+//
+RESOURCE TBUF r_voice_confirmation_sound_path
+    {
+    buf = KVoiceConfirmationSoundFile;
+    }
+
+RESOURCE TBUF   r_text_voice_system_error       { buf = text_voice_system_error; }
+RESOURCE TBUF   r_text_voice_no_matches         { buf = text_voice_no_matches; }
+RESOURCE TBUF   r_text_call_in_progress         { buf = text_call_in_progress; }
+RESOURCE TBUF   r_text_voice_no_tag             { buf = text_voice_no_tag; }
+
+RESOURCE TBUF   r_text_voice_speak_now          { buf = text_voice_speak_now; }      
+RESOURCE TBUF   r_qan_vc_tts_dialling           { buf = qan_vc_tts_dialling; }
+
+RESOURCE TBUF   r_qtn_vc_nbest_list_header      { buf = qtn_vc_nbest_list_header; }
+
+RESOURCE TBUF   r_qan_vc_verification_query     { buf = qan_vc_verification_query; }
+RESOURCE TBUF   r_qan_vc_verification_select    { buf = qan_vc_verification_select; }
+RESOURCE TBUF   r_qan_vc_verification_other     { buf = qan_vc_verification_other; }
+RESOURCE TBUF   r_qan_vc_verification_cancel    { buf = qan_vc_verification_cancel; }
+
+RESOURCE TBUF   r_qtn_vc_memory_low             { buf = qtn_err_eikon_mem; }
+
+// SIND Demo
+RESOURCE TBUF   r_text_sind_tutorial_page_intro_title        { buf = qtn_vc_tutorial_page1_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_intro_text_up      { buf = qtn_vc_tutorial_page1_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_intro_text_down    { buf = qtn_vc_tutorial_page1_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_page_command_title      { buf = qtn_vc_tutorial_page2_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_command_text_up    { buf = qtn_vc_tutorial_page2_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_command_text_down  { buf = qtn_vc_tutorial_page2_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_page_dial_title         { buf = qtn_vc_tutorial_page3_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_dial_text_up       { buf = qtn_vc_tutorial_page3_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_dial_text_down     { buf = qtn_vc_tutorial_page3_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_page_other_title        { buf = qtn_vc_tutorial_page4_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_other_text_up      { buf = qtn_vc_tutorial_page4_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_other_text_down    { buf = qtn_vc_tutorial_page4_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_page_try_title          { buf = qtn_vc_tutorial_page5_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_try_text_up        { buf = qtn_vc_tutorial_page5_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_try_text_down      { buf = qtn_vc_tutorial_page5_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_page_best_title         { buf = qtn_vc_tutorial_page_results_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_best_text_up       { buf = qtn_vc_tutorial_page6_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_best_text_down     { buf = qtn_vc_tutorial_page6_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_page_activation_title   { buf = qtn_vc_tutorial_page7_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_activation_text    { buf = qtn_vc_tutorial_page7_text; }
+RESOURCE TBUF   r_text_sind_tutorial_page_error_title        { buf = qtn_vc_tutorial_page_error_title; }
+RESOURCE TBUF   r_text_sind_tutorial_page_error_text_up      { buf = qtn_vc_tutorial_page_error_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_page_error_text_down    { buf = qtn_vc_tutorial_page_error_text_down; }
+RESOURCE TBUF   r_text_sind_tutorial_first_time_text_up      { buf = qtn_vc_tutorial_first_time1_text_up; }
+RESOURCE TBUF   r_text_sind_tutorial_first_time_text_down    { buf = qtn_vc_tutorial_first_time1_text_down; }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/data/vuivoicerecognition_caption.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <apcaptionfile.rh>
+#include <vuivoicerecognition.loc>
+
+RESOURCE CAPTION_DATA
+    {
+    caption = qtn_sivc_appl_list;
+    shortcaption = qtn_sivc_appl_grid;
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/data/vuivoicerecognition_reg.rss	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+#include <vuivoicerecognition.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x101F8543 // Define your application UID here
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "vuivoicerecognition";
+    localisable_resource_file = APP_RESOURCE_DIR"\\vuivoicerecognition";
+    localisable_resource_id = R_LOCALISABLE_APP_INFO;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/eabi/voiceuirecognitionu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+EXPORTS
+	_ZN11CVoiceRecog4NewLEv @ 1 NONAME
+	_ZN11CVoiceRecog5NewLCEv @ 2 NONAME
+	_ZN23CVoiceRecognitionDialog9ExecuteLDEv @ 3 NONAME
+	_ZN23CVoiceRecognitionDialogC1Ev @ 4 NONAME
+	_ZN23CVoiceRecognitionDialogC2Ev @ 5 NONAME
+	_ZN23CVoiceRecognitionDialogD0Ev @ 6 NONAME
+	_ZN23CVoiceRecognitionDialogD1Ev @ 7 NONAME
+	_ZN23CVoiceRecognitionDialogD2Ev @ 8 NONAME
+	_ZTI11CVoiceRecog @ 9 NONAME ; #<TI>#
+	_ZTI16CNBestListDialog @ 10 NONAME ; #<TI>#
+	_ZTI16CRecogToneReader @ 11 NONAME ; #<TI>#
+	_ZTI21CGlobalProgressDialog @ 12 NONAME ; #<TI>#
+	_ZTI22CVoiceRecognitionTimer @ 13 NONAME ; #<TI>#
+	_ZTI23CVoiceRecogContextCheck @ 14 NONAME ; #<TI>#
+	_ZTI23CVoiceRecognitionDialog @ 15 NONAME ; #<TI>#
+	_ZTI25CVoiceRecogPlaybackDialog @ 16 NONAME ; #<TI>#
+	_ZTI32CVoiceRecognitionDialogExtension @ 17 NONAME ; #<TI>#
+	_ZTI33CVoiceRecogAccessoryButtonMonitor @ 18 NONAME ; #<TI>#
+	_ZTV11CVoiceRecog @ 19 NONAME ; #<VT>#
+	_ZTV16CNBestListDialog @ 20 NONAME ; #<VT>#
+	_ZTV16CRecogToneReader @ 21 NONAME ; #<VT>#
+	_ZTV21CGlobalProgressDialog @ 22 NONAME ; #<VT>#
+	_ZTV22CVoiceRecognitionTimer @ 23 NONAME ; #<VT>#
+	_ZTV23CVoiceRecogContextCheck @ 24 NONAME ; #<VT>#
+	_ZTV23CVoiceRecognitionDialog @ 25 NONAME ; #<VT>#
+	_ZTV25CVoiceRecogPlaybackDialog @ 26 NONAME ; #<VT>#
+	_ZTV32CVoiceRecognitionDialogExtension @ 27 NONAME ; #<VT>#
+	_ZTV33CVoiceRecogAccessoryButtonMonitor @ 28 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionasu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+EXPORTS
+	_ZN11CVoiceRecog4NewLEv @ 1 NONAME
+	_ZN11CVoiceRecog5NewLCEv @ 2 NONAME
+	_ZN23CVoiceRecognitionDialog9ExecuteLDEv @ 3 NONAME
+	_ZN23CVoiceRecognitionDialogC1Ev @ 4 NONAME
+	_ZN23CVoiceRecognitionDialogC2Ev @ 5 NONAME
+	_ZN23CVoiceRecognitionDialogD0Ev @ 6 NONAME
+	_ZN23CVoiceRecognitionDialogD1Ev @ 7 NONAME
+	_ZN23CVoiceRecognitionDialogD2Ev @ 8 NONAME
+	_ZTI11CVoiceRecog @ 9 NONAME ; #<TI>#
+	_ZTI16CRecogToneReader @ 10 NONAME ; #<TI>#
+	_ZTI16CVoiceKeyWatcher @ 11 NONAME ; #<TI>#
+	_ZTI21CGlobalProgressDialog @ 12 NONAME ; #<TI>#
+	_ZTI23CVoiceRecognitionDialog @ 13 NONAME ; #<TI>#
+	_ZTI25CVoiceRecogPlaybackDialog @ 14 NONAME ; #<TI>#
+	_ZTI33CVoiceRecogAccessoryButtonMonitor @ 15 NONAME ; #<TI>#
+	_ZTV11CVoiceRecog @ 16 NONAME ; #<VT>#
+	_ZTV16CRecogToneReader @ 17 NONAME ; #<VT>#
+	_ZTV16CVoiceKeyWatcher @ 18 NONAME ; #<VT>#
+	_ZTV21CGlobalProgressDialog @ 19 NONAME ; #<VT>#
+	_ZTV23CVoiceRecognitionDialog @ 20 NONAME ; #<VT>#
+	_ZTV25CVoiceRecogPlaybackDialog @ 21 NONAME ; #<VT>#
+	_ZTV33CVoiceRecogAccessoryButtonMonitor @ 22 NONAME ; #<VT>#
+	_ZTI19CVoiceRecogTagCheck @ 23 NONAME ; #<TI>#
+	_ZTV19CVoiceRecogTagCheck @ 24 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionau.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,15 @@
+EXPORTS
+	_ZN11CVoiceRecog4NewLEv @ 1 NONAME
+	_ZN11CVoiceRecog5NewLCEv @ 2 NONAME
+	_ZN23CVoiceRecognitionDialog6CancelEv @ 3 NONAME
+	_ZN23CVoiceRecognitionDialog9ExecuteLDEv @ 4 NONAME
+	_ZN23CVoiceRecognitionDialogC1Ev @ 5 NONAME
+	_ZN23CVoiceRecognitionDialogC2Ev @ 6 NONAME
+	_ZN23CVoiceRecognitionDialogD0Ev @ 7 NONAME
+	_ZN23CVoiceRecognitionDialogD1Ev @ 8 NONAME
+	_ZN23CVoiceRecognitionDialogD2Ev @ 9 NONAME
+	_ZTI11CVoiceRecog @ 10 NONAME ; #<TI>#
+	_ZTI23CVoiceRecognitionDialog @ 11 NONAME ; #<TI>#
+	_ZTV11CVoiceRecog @ 12 NONAME ; #<VT>#
+	_ZTV23CVoiceRecognitionDialog @ 13 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionsu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,26 @@
+EXPORTS
+	_ZN11CVoiceRecog4NewLEv @ 1 NONAME
+	_ZN11CVoiceRecog5NewLCEv @ 2 NONAME
+	_ZN23CVoiceRecognitionDialog9ExecuteLDEv @ 3 NONAME
+	_ZN23CVoiceRecognitionDialogC1Ev @ 4 NONAME
+	_ZN23CVoiceRecognitionDialogC2Ev @ 5 NONAME
+	_ZN23CVoiceRecognitionDialogD0Ev @ 6 NONAME
+	_ZN23CVoiceRecognitionDialogD1Ev @ 7 NONAME
+	_ZN23CVoiceRecognitionDialogD2Ev @ 8 NONAME
+	_ZTI11CVoiceRecog @ 9 NONAME ; #<TI>#
+	_ZTI16CRecogToneReader @ 10 NONAME ; #<TI>#
+	_ZTI16CVoiceKeyWatcher @ 11 NONAME ; #<TI>#
+	_ZTI21CGlobalProgressDialog @ 12 NONAME ; #<TI>#
+	_ZTI23CVoiceRecognitionDialog @ 13 NONAME ; #<TI>#
+	_ZTI25CVoiceRecogPlaybackDialog @ 14 NONAME ; #<TI>#
+	_ZTI31CVoiceRecogHeadsetButtonMonitor @ 15 NONAME ; #<TI>#
+	_ZTV11CVoiceRecog @ 16 NONAME ; #<VT>#
+	_ZTV16CRecogToneReader @ 17 NONAME ; #<VT>#
+	_ZTV16CVoiceKeyWatcher @ 18 NONAME ; #<VT>#
+	_ZTV21CGlobalProgressDialog @ 19 NONAME ; #<VT>#
+	_ZTV23CVoiceRecognitionDialog @ 20 NONAME ; #<VT>#
+	_ZTV25CVoiceRecogPlaybackDialog @ 21 NONAME ; #<VT>#
+	_ZTV31CVoiceRecogHeadsetButtonMonitor @ 22 NONAME ; #<VT>#
+	_ZTI19CVoiceRecogTagCheck @ 23 NONAME ; #<TI>#
+	_ZTV19CVoiceRecogTagCheck @ 24 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/eabi/voiceuivoicerecognitionu.def	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,30 @@
+EXPORTS
+	_ZN11CVoiceRecog4NewLEv @ 1 NONAME
+	_ZN11CVoiceRecog5NewLCEv @ 2 NONAME
+	_ZN23CVoiceRecognitionDialog9ExecuteLDEv @ 3 NONAME
+	_ZN23CVoiceRecognitionDialogC1Ev @ 4 NONAME
+	_ZN23CVoiceRecognitionDialogC2Ev @ 5 NONAME
+	_ZN23CVoiceRecognitionDialogD0Ev @ 6 NONAME
+	_ZN23CVoiceRecognitionDialogD1Ev @ 7 NONAME
+	_ZN23CVoiceRecognitionDialogD2Ev @ 8 NONAME
+	_ZTI11CVoiceRecog @ 9 NONAME ; #<TI>#
+	_ZTI16CNBestListDialog @ 10 NONAME ; #<TI>#
+	_ZTI16CRecogToneReader @ 11 NONAME ; #<TI>#
+	_ZTI21CGlobalProgressDialog @ 12 NONAME ; #<TI>#
+	_ZTI22CVoiceRecognitionTimer @ 13 NONAME ; #<TI>#
+	_ZTI23CVoiceRecogContextCheck @ 14 NONAME ; #<TI>#
+	_ZTI23CVoiceRecognitionDialog @ 15 NONAME ; #<TI>#
+	_ZTI25CVoiceRecogPlaybackDialog @ 16 NONAME ; #<TI>#
+	_ZTI31CVoiceRecogHeadsetButtonMonitor @ 17 NONAME ; #<TI>#
+	_ZTI32CVoiceRecognitionDialogExtension @ 18 NONAME ; #<TI>#
+	_ZTV11CVoiceRecog @ 19 NONAME ; #<VT>#
+	_ZTV16CNBestListDialog @ 20 NONAME ; #<VT>#
+	_ZTV16CRecogToneReader @ 21 NONAME ; #<VT>#
+	_ZTV21CGlobalProgressDialog @ 22 NONAME ; #<VT>#
+	_ZTV22CVoiceRecognitionTimer @ 23 NONAME ; #<VT>#
+	_ZTV23CVoiceRecogContextCheck @ 24 NONAME ; #<VT>#
+	_ZTV23CVoiceRecognitionDialog @ 25 NONAME ; #<VT>#
+	_ZTV25CVoiceRecogPlaybackDialog @ 26 NONAME ; #<VT>#
+	_ZTV31CVoiceRecogHeadsetButtonMonitor @ 27 NONAME ; #<VT>#
+	_ZTV32CVoiceRecognitionDialogExtension @ 28 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/group/bld.inf	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information for VoiceUiRecognition
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+#include "exports.inc"
+
+PRJ_MMPFILES
+
+vuivoicerecognition.mmp
+vuivoicerecognitionwrapper.mmp
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE vuivoicerecognition_aif.mif
+OPTION SOURCES -c8,8 qgn_menu_sivc
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/group/exports.inc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* ==============================================================================
+*        %name: exports.inc %
+*     %version: be1sido#18.2.20 %
+*      Part of: VoiceUI / VoiceUiNameDialer
+*  Description: VoiceUiNameDialer exports
+*
+*  Copyright (C) 2006-2007 Nokia Corporation.
+*  This material, including documentation and any related 
+*  computer programs, is protected by copyright controlled by 
+*  Nokia Corporation. All rights are reserved. Copying, 
+*  including reproducing, storing,  adapting or translating, any 
+*  or all of this material requires the prior written consent of 
+*  Nokia Corporation. This material also contains confidential 
+*  information which may not be disclosed to others without the 
+*  prior written consent of Nokia Corporation.
+*
+* ============================================================================
+*/
+
+#include <platform_paths.hrh>
+
+../data/namediallerstarttone.wav  /epoc32/release/wins/urel/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/wins/udeb/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/winscw/urel/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/winscw/udeb/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/thumb/urel/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/thumb/udeb/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/armv5/urel/z/system/sounds/digital/namediallerstarttone.wav
+../data/namediallerstarttone.wav  /epoc32/release/armv5/udeb/z/system/sounds/digital/namediallerstarttone.wav
+
+../data/namediallerconfirmtone.wav  /epoc32/release/wins/urel/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/wins/udeb/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/winscw/urel/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/winscw/udeb/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/thumb/urel/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/thumb/udeb/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/armv5/urel/z/system/sounds/digital/namediallerconfirmtone.wav
+../data/namediallerconfirmtone.wav  /epoc32/release/armv5/udeb/z/system/sounds/digital/namediallerconfirmtone.wav
+
+../data/btnamediallerstarttone.wav  /epoc32/release/winscw/urel/z/system/sounds/digital/btnamediallerstarttone.wav
+../data/btnamediallerstarttone.wav  /epoc32/release/winscw/udeb/z/system/sounds/digital/btnamediallerstarttone.wav
+../data/btnamediallerstarttone.wav  /epoc32/release/armv5/urel/z/system/sounds/digital/btnamediallerstarttone.wav
+../data/btnamediallerstarttone.wav  /epoc32/release/armv5/udeb/z/system/sounds/digital/btnamediallerstarttone.wav
+
+../loc/vuivoicerecognition.loc      APP_LAYER_LOC_EXPORT_PATH(vuivoicerecognition.loc)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/group/vui_icons_aif_scalable_dc.mk	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:  Icon makefile
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\vuivoicerecognition_aif.mif
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) \
+		/c8,8 qgn_menu_sivc.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/group/vuivoicerecognition.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP file for VoiceUiRecognition.exe
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          vuivoicerecognition.exe
+EPOCSTACKSIZE   0x5000
+TARGETTYPE      exe
+uid             0x100039CE 0x101F8543
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_APPLICATION MultiMediaDD PowerMgmt NetworkControl
+
+SOURCEPATH      ../data
+START RESOURCE  vuivoicerecognition.rss
+HEADER
+TARGETPATH      APP_RESOURCE_DIR
+LANGUAGE_IDS
+END
+
+
+START RESOURCE  vuivoicerecognition_reg.rss
+DEPENDS vuivoicerecognition.rsg
+TARGETPATH      /private/10003a3f/apps
+END
+
+SOURCEPATH      ../src
+SOURCE          vuicapp.cpp
+SOURCE          vuicdocument.cpp
+SOURCE          vuicappui.cpp
+SOURCE          vuicvoicerecogdialogimpl.cpp
+SOURCE          vuicglobalprogressdialog.cpp
+SOURCE          vuictoneplayer.cpp
+SOURCE          vuicnbestlistdialog.cpp
+SOURCE          vuicpropertyhandler.cpp
+SOURCE          vuictutorialmessagedialog.cpp
+SOURCE          vuictutorial.cpp
+SOURCE          vuicglobalnote.cpp
+SOURCE          vuicstate.cpp
+SOURCE          vuicprecheckstate.cpp
+SOURCE          vuiccontextcheckstate.cpp
+SOURCE          vuicverificationtrainingstate.cpp
+SOURCE          vuicinitstate.cpp
+SOURCE          vuicrecordstate.cpp
+SOURCE          vuicresultsstate.cpp
+SOURCE          vuiccontactresultsstate.cpp
+SOURCE          vuicverificationinitstate.cpp
+SOURCE          vuicverificationstate.cpp
+SOURCE          vuicplaystate.cpp
+SOURCE          vuicadaptstate.cpp
+SOURCE          vuicexecutestate.cpp
+SOURCE          vuictutorialstate.cpp
+SOURCE          vuicabortstate.cpp
+SOURCE          vuicerrorstate.cpp
+SOURCE          vuicexitstate.cpp
+SOURCE          vuicuimodel.cpp
+SOURCE          vuicdatastorage.cpp
+SOURCE          vuicttsplayer.cpp
+SOURCE          vuiclistquerydialog.cpp
+SOURCE          vuicverificationdialog.cpp
+SOURCE          vuicmessagequerydialog.cpp
+SOURCE          vuiccalldetector.cpp
+SOURCE          vuickeygrabber.cpp
+SOURCE          vuicfoldobserver.cpp
+SOURCE          vuicnotificationobserver.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../group
+USERINCLUDE     ../../rubydebug
+
+// This is a SYSTEMINCLUDE macro containing the applications
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+ 
+SYSTEMINCLUDE   /epoc32/include/mmf/common 
+SYSTEMINCLUDE   /epoc32/include/remcon
+
+#if defined(ARMCC)
+deffile ../eabi/voiceuivoicerecognitiona.def
+#elif defined( WINSCW )
+deffile ../bwinscw/voiceuivoicerecognitiona.def
+#elif defined( WINS )
+deffile ../BWINS/VoiceUiVoiceRecognitionA.DEF
+#else
+deffile ../BMARM/VoiceUiVoiceRecognitionA.DEF
+#endif
+
+LIBRARY         apparc.lib
+LIBRARY         euser.lib
+LIBRARY         cone.lib   
+LIBRARY         commonengine.lib
+LIBRARY         aknnotify.lib
+LIBRARY         apgrfx.lib
+
+LIBRARY         remconextensionapi.lib
+LIBRARY         remconinterfacebase.lib
+LIBRARY         remconcoreapi.lib
+
+LIBRARY         avkon.lib
+LIBRARY         eikcoctl.lib
+LIBRARY         eikdlg.lib
+LIBRARY         eikcore.lib
+LIBRARY         eikcdlg.lib
+LIBRARY         eikctl.lib 
+LIBRARY         aknicon.lib
+LIBRARY         efsrv.lib
+LIBRARY         mediaclientaudio.lib
+
+LIBRARY         nssvasapi.lib
+LIBRARY         featmgr.lib
+LIBRARY         aknskins.lib
+LIBRARY         egul.lib
+LIBRARY         bafl.lib
+LIBRARY         nssttsutility.lib
+LIBRARY         nssttscommon.lib
+LIBRARY         cdlengine.lib
+LIBRARY         centralrepository.lib
+LIBRARY         ws32.lib
+LIBRARY         ccaclient.lib
+LIBRARY         estor.lib
+LIBRARY         etel3rdparty.lib
+
+LIBRARY         VPbkEng.lib
+LIBRARY         ecom.lib 
+LIBRARY         accpolicy.lib
+LIBRARY         accclient.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/group/vuivoicerecognitionwrapper.mmp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP file for VoiceUiRecognition.dll
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          voiceuirecognition.dll
+TARGETTYPE      dll
+uid             0x1000008d 0x101F8543
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_GENERAL_DLL MultiMediaDD PowerMgmt NetworkControl
+
+SOURCEPATH      ../src
+SOURCE          vuicvoicerecog.cpp
+SOURCE          vuicvoicerecogdialog.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../rubydebug
+
+// This is a SYSTEMINCLUDE macro containing the applications
+// layer specific include directories
+APP_LAYER_SYSTEMINCLUDE
+
+#if defined(ARMCC)
+deffile ../eabi/voiceuivoicerecognitiona.def
+#elif defined( WINSCW )
+deffile ../bwinscw/voiceuivoicerecognitiona.def
+#elif defined( WINS )
+deffile ../BWINS/VoiceUiVoiceRecognitionA.DEF
+#else
+deffile ../BMARM/VoiceUiVoiceRecognitionA.DEF
+#endif
+
+LIBRARY         euser.lib
+LIBRARY         cone.lib
+LIBRARY         apgrfx.lib
+LIBRARY         apparc.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicabortstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICABORTSTATE_H
+#define VUICABORTSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CAbortState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CAbortState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CAbortState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CAbortState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+    private:    // Functions
+                
+    private:    // Data
+};
+
+#endif  // VUICABORTSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicadaptstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICADAPTSTATE_H
+#define VUICADAPTSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+class MNssAdaptationItem;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CAdaptState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CAdaptState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CAdaptState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CAdaptState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+    private:    // Functions
+                
+    private:    // Data
+    
+        // Adaptation item
+        MNssAdaptationItem*                 iAdaptationItem;
+};
+
+#endif  // VUICADAPTSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicapp.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICAPP_H
+#define VUICAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidVoiceUi = { 0x101F8543 };
+
+// CLASS DECLARATION
+
+/**
+* CApp application class.
+* Provides factory to create concrete document object.
+*/
+NONSHARABLE_CLASS( CApp ) : public CAknApplication
+    {
+    
+    private:
+
+        /**
+        * From CApaApplication
+        * @see CApaApplication for more information
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication
+        * @see CApaApplication for more information
+        */
+        TUid AppDllUid() const;
+  
+    };
+
+#endif  // VUICAPP_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicappui.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICAPPUI_H
+#define VUICAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknappui.h>
+
+#include "vuimvoicerecogdialogcallback.h"
+#include "vuimcalldetectorobserver.h"
+#include "vuimkeycallback.h"
+
+// FORWARD DECLARATIONS
+class CVoiceRecognitionDialogImpl;
+class CCallDetector;
+class CKeyGrabber;
+class CFoldObserver;
+class CNotificationObserver;
+
+// CLASS DECLARATION
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+* - view architecture
+* - status pane
+*/
+NONSHARABLE_CLASS( CAppUi ) : public CAknAppUi,
+                              public MVoiceRecognitionDialogCallback,
+                              public MCallDetectorObserver,
+                              public MKeyCallback
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Symbian C++ default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CAppUi();
+        
+    public: // Functions from base classes
+
+        /**
+        * From MVoiceRecognitionDialogCallback
+        *
+        * @see MVoiceRecognitionDialogCallback for more information
+        */
+        void DialogDismissed();
+        
+        /**
+        * From MCallDetectorObserver
+        *
+        * @see MCallDetectorObserver for more information
+        */
+        void CallDetectedL();
+        
+        /**
+        * From MKeyCallback
+        *
+        * @see MKeyCallback for more information
+        */
+        void HandleKeypressL( TInt aSoftkey );
+
+    public: // New Functions
+
+    private: // Functions from base classes
+
+        /**
+        * From CEikAppUi
+        *
+        * @see CEikAppUi for more information
+        */
+        void HandleCommandL( TInt aCommand );
+        
+        /**
+        * From CEikAppUi
+        *
+        * @see CEikAppUi for more information
+        */
+        void PrepareToExit( );
+        
+    private: // New functions
+        
+        /**
+         * Handles command line parameters.
+         * @param aCommandLine CApaCommandLine object
+         */
+        TBool ProcessCommandParametersL( CApaCommandLine& aCommandLine );    
+    
+    private: // data
+        
+        // Recognition dialog
+        CVoiceRecognitionDialogImpl*    iRecognitionDialog;
+        
+        // Call detector
+        CCallDetector*                  iCallDetector;
+        
+        // Key grabber
+        CKeyGrabber*                    iKeyGrabber;
+        
+        // Fold observer
+        CFoldObserver*                  iFoldObserver;
+        
+        // Soft notification observer
+        CNotificationObserver*          iNotificationObserver;
+    };
+
+#endif  // VUICAPPUI_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuiccalldetector.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICCALLDETECTOR_H
+#define VUICCALLDETECTOR_H
+
+#include <e32base.h>
+#include <e32property.h>
+
+class MCallDetectorObserver;
+
+/**
+ *  Detector for incoming call
+ */
+NONSHARABLE_CLASS( CCallDetector ) : public CActive
+    {
+
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CCallDetector* NewL( MCallDetectorObserver* aObserver );
+
+        /**
+        * Destructor.
+        */
+        ~CCallDetector();
+        
+    public: // New functions
+
+        /**
+        * Request call notifications
+        *
+        */
+        void RequestNotification();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CCallDetector( MCallDetectorObserver* aObserver );
+
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL();
+    
+        /**
+        * From CActive
+        * @see CActive for more information
+        */
+        void RunL();
+        
+        /**
+        * From CActive
+        * @see CActive for more information
+        */
+        void DoCancel();
+
+    private:
+
+        // Call observer
+        MCallDetectorObserver*          iObserver;
+        
+        RProperty                       iTsyProperty;
+    };
+
+#endif // VUICCALLDETECTOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuiccontactresultsstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICCONTACTRESULTSSTATE_H
+#define VUICCONTACTRESULTSSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+class CNBestListDialog;
+class CDesC16ArrayFlat;
+class MNssTag;
+class CNssVASDBMgr;
+class MNssTagMgr;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CContactResultsState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CContactResultsState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CContactResultsState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CContactResultsState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+        /**
+        * Handles timed event
+        */
+        void DoTimedEventL();
+        
+    private:    // Functions        
+        
+        /**
+        * Handles keypress event
+        * @return ETrue if event was handled else EFalse
+        */
+        TBool HandleKeypressL();
+        
+        /**
+        * Plays currently selected name from the n-best list with TTS
+        */
+        void PlaySelectedNameL();
+        
+        /**
+        * Creates contact info array
+        */
+        void CreateContactInfoArrayL();
+        
+        /**
+        * Compares given tag and currently selected tag names
+        * @param aTag Tag that is used in comparison
+        * @return ETrue if names match else EFalse
+        */
+        TBool CompareContactNamesL( MNssTag* aTag );
+        
+        /**
+        * Checks if given tag exists in taglist
+        * @param aTag Tag that is searched
+        * @return ETrue if tag exists else EFalse
+        */
+        TBool CheckIfAlreadyAdded( MNssTag* aTag );
+        
+        /**
+        * Creates new items array. Ownership is transferred to caller.
+        * @return Items array     
+        */
+        CDesC16ArrayFlat* CreateItemsArrayL();
+       
+        /**
+        * Fills buffer with dial tag information
+        * @param aTag Tag containing all needed information
+        * @param aBuffer Buffer to be filled
+        */
+        void FillDialContextBufferL( MNssTag* aTag, TDes& aBuffer );
+       
+        /**
+        * Gets the right icon for contact
+        * @param aIconId The type of contacts icon
+        * @return Icon type   
+        */
+        TPtrC GetContactIconType( TFieldType aIconId );
+        
+        /**
+        * Selects currently active tag from n-best list
+        */
+        void SelectTag();
+                
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            EInitialized,
+            ECompleted
+            };
+    
+        // N-best list dialog
+        CNBestListDialog*           iNBestListDialog;
+        
+        // Stores a keypress event from HandleEventL
+        TInt                        iKeypress;
+        
+        // For handling internal state logics
+        TInternalState              iInternalState;
+        
+        // For storing copies of tag pointers
+        CArrayPtrFlat<MNssTag>*     iTagList;
+        
+        // Vas stuff for handling context operations
+        CNssVASDBMgr*               iNssVasDbManager;
+        MNssTagMgr*                 iNssTagManager;
+    };
+
+#endif  // VUICCONTACTRESULTSSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuiccontextcheckstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICCONTEXTCHECKSTATE_H
+#define VUICCONTEXTCHECKSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+class CNssVASDBMgr;
+class MNssTagMgr;
+class MNssContextMgr;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CContextCheckState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CContextCheckState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CContextCheckState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CContextCheckState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+
+    private:    // Functions
+    
+        /**
+        * Checks if UI language has changed and sets the language to undefined if changed
+        * @return ETrue if language has changed else EFalse
+        */
+        TBool LanguageChangedL();
+                
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            ECommandsReady,
+            EDialReady,
+            EVerificationReady
+            };
+    
+        // Vas stuff for handling context operations
+        CNssVASDBMgr*           iVasDbManager;
+        MNssTagMgr*             iTagManager;
+        MNssContextMgr*         iContextManager;
+        
+        // For handling internal state logics
+        TInternalState          iInternalState;
+        
+        // Number of found voice tags
+        TInt                    iTagCount;
+};
+
+#endif  // VUICCONTEXTCHECKSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicdatastorage.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,340 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICDATASTORAGE_H
+#define VUICDATASTORAGE_H
+
+// INCLUDES
+#include <e32base.h>
+
+#include <nssvasapi.h>
+
+#include <vuivoicerecogdefs.h>
+
+// FORWARD DECLARATIONS
+class CVoiceRecognitionDialogImpl;
+class CNssRecognitionHandlerBuilder;
+class MNssRecognitionHandler;
+class CTonePlayer;
+class CPropertyHandler;
+class CTutorial;
+class CTTSPlayer;
+class MVasBasePbkHandler;
+
+// CONSTANTS
+
+const TInt KResetMode = -1;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CDataStorage ) : public CBase
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CDataStorage* NewL( CVoiceRecognitionDialogImpl* aVoiceRecognitionImpl );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDataStorage();
+                                
+    public:     // New functions
+        
+        /**
+        * Stores recognition handler builder pointer
+        * @param aRecognitionHandlerBuilder Pointer to be stored
+        */
+        void SetRecognitionHandlerBuilder( CNssRecognitionHandlerBuilder* aRecognitionHandlerBuilder );
+        
+        /**
+        * Stores recognition handler pointer
+        * @param aRecognitionHandler Pointer to be stored
+        */
+        void SetRecognitionHandler( MNssRecognitionHandler* aRecognitionHandler );
+        
+        /**
+        * Stores recognition handler builder pointer
+        * @param aRecognitionHandlerBuilder Pointer to be stored
+        */
+        void SetVerificationRecognitionHandlerBuilder( CNssRecognitionHandlerBuilder* aRecognitionHandlerBuilder );
+        
+        /**
+        * Stores recognition handler pointer
+        * @param aRecognitionHandler Pointer to be stored
+        */
+        void SetVerificationRecognitionHandler( MNssRecognitionHandler* aRecognitionHandler );
+                       
+        /**
+        * Stores additional tag list pointer
+        * @param aAdditionalTagList Pointer to be stored
+        */
+        void SetAdditionalTagList( CArrayPtrFlat<MNssTag>* aAdditionalTagList );
+        
+        /**
+        * Stores tag list pointer
+        * @param aTagList Pointer to be stored
+        */
+        void SetCompleteTagList( CArrayPtrFlat<MNssTag>* aCompleteTagList );
+        
+        /**
+        * Stores tag pointer
+        * @param aTag Pointer to be stored
+        * @param aDestroyIfExists Destroys old tag if one exists
+        */
+        void SetTag( MNssTag* aTag, TBool aDestroyIfExists );
+        
+        /**
+        * Stores context pointer
+        * @param aContext Pointer to be stored
+        */
+        void SetContext( MNssContext* aContext );
+        
+        /**
+        * Stores adaptation state
+        * @param aAdaptationEnabled ETrue to enable adaptation, else EFalse
+        */
+        void SetAdaptationEnabled( const TBool aAdaptationEnabled );
+        
+        /**
+        * Stores play duration
+        * @param aPlayDuration Play duration in milliseconds
+        */
+        void SetPlayDuration( const TTimeIntervalMicroSeconds& aPlayDuration );
+        
+        /**
+        * Stores verification mode
+        * @param aMode One of TVuiVerificationMode values or if not given the
+        * value is reseted
+        */
+        void SetVerificationMode( const TInt aMode = KResetMode );
+        
+        /**
+        * Sets verification try count
+        * @param aCount Number of tries left
+        */
+        void SetVerificationTryCount( const TInt aCount );
+        
+        /**
+        * Sets flag if device lock mode is enabled
+        * @param aDeviceLockMode Flag value
+        */
+        void SetDeviceLockMode( const TBool aDeviceLockMode );
+                
+        /**
+        * Returns RecognitionDialogImpl
+        * @return Pointer to RecognitionDialogImpl object
+        */
+        CVoiceRecognitionDialogImpl* VoiceRecognitionImpl() const;
+        
+        /**
+        * Returns recognition handler builder
+        * @return Pointer to recognition handler builder object
+        */
+        CNssRecognitionHandlerBuilder* RecognitionHandlerBuilder() const;
+        
+        /**
+        * Returns recognition handler
+        * @return Pointer to recognition handler object
+        */
+        MNssRecognitionHandler* RecognitionHandler() const;
+        
+        /**
+        * Returns recognition handler builder
+        * @return Pointer to recognition handler builder object
+        */
+        CNssRecognitionHandlerBuilder* VerificationRecognitionHandlerBuilder() const;
+        
+        /**
+        * Returns recognition handler
+        * @return Pointer to recognition handler object
+        */
+        MNssRecognitionHandler* VerificationRecognitionHandler() const;
+        
+        /**
+        * Returns tone player
+        * @return Pointer to tone player object
+        */
+        CTonePlayer* TonePlayer() const;
+        
+        /**
+        * Returns tts player
+        * @return Pointer to tts player object
+        */
+        CTTSPlayer* TtsPlayer() const;
+        
+        /**
+        * Returns phonebook handler
+        * @return Pointer to phonebook handler object
+        */
+        MVasBasePbkHandler* PbkHandler() const;
+                
+        /**
+        * Returns accessory button monitor
+        * @return Pointer to accessory button monitor object
+        */
+        CPropertyHandler* AccessoryButtonMonitor() const;   
+        
+        /**
+        * Returns tutorial
+        * @return Pointer to tutorial object
+        */
+        CTutorial* Tutorial() const;
+        
+        /**
+        * Returns additional tag list
+        * @return Pointer to tag list object
+        */
+        CArrayPtrFlat<MNssTag>* AdditionalTagList() const;
+        
+        /**
+        * Returns complete tag list
+        * @return Pointer to tag list object
+        */
+        CArrayPtrFlat<MNssTag>* CompleteTagList() const;
+        
+        /**
+        * Returns tag
+        * @return Pointer to tag object
+        */
+        MNssTag* Tag() const;
+        
+        /**
+        * Returns context 
+        * @return Pointer to context object
+        */
+        MNssContext* Context() const;
+        
+        /**
+        * Returns synthesizer mode
+        * @return Current synthesizer mode, either 0 or 1
+        */
+        TInt SynthesizerMode() const;
+        
+        /**
+        * Returns adaptation state
+        * @return Current adaptation state, either ETrue or EFalse
+        */
+        TBool AdaptationEnabled() const;
+        
+        /**
+        * Returns play duration
+        * @return Play duration in microseconds
+        */
+        TTimeIntervalMicroSeconds PlayDuration() const;
+        
+        /**
+        * Returns verification mode
+        * @return One of TVuiVerificationMode values
+        */
+        TInt VerificationMode() const;
+        
+        /**
+        * Returns verification try count
+        * @return Number of verification tries left
+        */
+        TInt VerificationTryCount() const;
+        
+        /**
+        * Returns if device lock mode is enabled
+        * @return ETrue if device lock mode is enabled else EFalse
+        */
+        TBool DeviceLockMode() const;
+         
+    private:    // Functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CDataStorage( CVoiceRecognitionDialogImpl* aVoiceRecognitionImpl );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+                
+    private:    // Data
+
+        // Main storage owner
+        CVoiceRecognitionDialogImpl*        iVoiceRecognitionImpl;
+        
+        // Recognition handler builder
+        CNssRecognitionHandlerBuilder*      iRecognitionHandlerBuilder;
+        
+        // Recognition handler
+        MNssRecognitionHandler*             iRecognitionHandler;
+        
+        // Recognition handler builder
+        CNssRecognitionHandlerBuilder*      iVerificationRecognitionHandlerBuilder;
+        
+        // Recognition handler
+        MNssRecognitionHandler*             iVerificationRecognitionHandler;
+               
+        // For playing tones
+        CTonePlayer*                        iTonePlayer;
+        
+        // For tts playback
+        CTTSPlayer*                         iTtsPlayer;
+        
+        // For phonebook handling
+        MVasBasePbkHandler*                 iPbkHandler;
+        
+        // For handling accessory buttons
+        CPropertyHandler*                   iAccessoryButtonMonitor;
+        
+        // Tutorial
+        CTutorial*                          iTutorial;
+        
+        // Received tag list includes tags for one contact
+        CArrayPtrFlat<MNssTag>*             iAdditionalTagList;
+        
+        // Received tag list includes recognition results
+        CArrayPtrFlat<MNssTag>*             iCompleteTagList;
+        
+        // One tag from tag list
+        MNssTag*                            iTag;
+        
+        // Received context
+        MNssContext*                        iContext;
+        
+        // TTS mode
+        TInt                                iSynthesizerMode;
+        
+        // Adaptation state
+        TBool                               iAdaptationEnabled;
+        
+        // Time of how long playback will take
+        TTimeIntervalMicroSeconds           iPlayDuration;
+        
+        // Automatic/manual/voice confirmation mode
+        TInt                                iVerificationMode;
+        
+        // Number of verification tries left
+        TInt                                iVerificationTryCount;
+        
+        // Device lock mode flag
+        TBool                               iDeviceLockMode;
+};
+
+#endif  // VUICDATASTORAGE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicdocument.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICDOCUMENT_H
+#define VUICDOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+* CDocument application class.
+*/
+NONSHARABLE_CLASS( CDocument ) : public CAknDocument
+    {
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDocument* NewL( CEikApplication& aApp );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDocument();
+        
+    private: // New Functions
+
+        /**
+        * C++ default constructor.
+        * @param aApp reference to application object.
+        */
+        CDocument( CEikApplication& aApp );
+        
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private: // Functions from base classes
+
+        /**
+        * From CEikDocument
+        * £see CEikDocument for more information
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif  // VUICDOCUMENT_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicerrorstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICERRORSTATE_H
+#define VUICERRORSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+#include "vuicglobalnote.h"
+
+// FORWARD DECLARATIONS
+
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CErrorState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CErrorState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel, TInt aError );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CErrorState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CErrorState( CDataStorage& aDataStorage, CUiModel& aUiModel, TInt aError );
+
+        /**
+        * Handles timed event
+        */
+        void DoTimedEventL();
+
+    private:    // Functions
+        
+        /**
+        * Returns which note should be shown
+        * @return One of enumeration values
+        */
+        CGlobalNote::TGlobalNoteState NoteType();
+        
+        /**
+        * Returns which tone should be played
+        * @return KErrNone if no tone should be player, otherwise one of tone enumerations
+        */
+        TInt ToneType();
+                
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            EInitialized,
+            EReady
+            };
+            
+        // For handling internal state logics
+        TInternalState      iInternalState;
+    
+        // Error value received in HandleEventL
+        TInt                iError;
+};
+
+#endif  // VUICERRORSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicexecutestate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICEXECUTESTATE_H
+#define VUICEXECUTESTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CExecuteState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CExecuteState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CExecuteState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CExecuteState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+    private:    // Functions
+                
+    private:    // Data
+
+};
+
+#endif  // VUICEXECUTESTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicexitstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICEXITSTATE_H
+#define VUICEXITSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CExitState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CExitState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CExitState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CExitState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+    private:    // Functions
+                
+    private:    // Data
+
+};
+
+#endif  // VUICEXITSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicfoldobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICFOLDOBSERVER_H
+#define VUICFOLDOBSERVER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+// FORWARD DECLARATIONS
+class MVoiceRecognitionDialogCallback;
+
+// CLASS DECLARATION
+/**
+* Fold state observer
+*
+*/
+NONSHARABLE_CLASS( CFoldObserver ) : public CActive
+{
+    public:     // Constructors and destructor
+
+/**
+        * Symbian two-phased constructor.
+        */
+        static CFoldObserver* NewL( MVoiceRecognitionDialogCallback* aCallback );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CFoldObserver();
+                                
+    public:     // From base classes
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void DoCancel();
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void RunL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CFoldObserver( MVoiceRecognitionDialogCallback* aCallback );
+                
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+
+    private:    // Data
+
+        // Callback observer
+        MVoiceRecognitionDialogCallback*    iCallback;
+
+        // Fold event
+        RProperty                           iFoldEvent;
+        
+        // Current fold status
+        TInt                                iFoldStatus;
+};
+
+#endif  // VUICFOLDOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicglobalnote.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handle showing of global notes
+*
+*/
+
+
+#ifndef VUICGLOBALNOTE_H
+#define VUICGLOBALNOTE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <AknGlobalNote.h>
+
+#include <secondarydisplay/vuisecondarydisplayapi.h>
+
+#include "vuivoiceicondefs.h"
+
+// CLASS DECLARATION
+/**
+* Handle showing of global notes
+*/
+NONSHARABLE_CLASS( CGlobalNote ) : public CBase
+{
+    public:     // Constructors and destructor
+       
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CGlobalNote* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CGlobalNote();
+        
+    public:     // Enumerations
+    
+        enum TGlobalNoteState
+            {
+            ECallInProgress,
+            ESystemError,
+            ENoTag,
+            ENoMatchPermanent,
+            ENotRecognizedPermanent,
+            ENoMemory
+            };
+                                
+    public:     // New functions
+    
+        /**
+        * Shows a message dialog
+        * @param
+        */
+        void DisplayGlobalNoteL( TGlobalNoteState aState );
+        
+        /**
+        * Shows a message dialog
+        */
+        void DismissGlobalNoteL();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CGlobalNote();
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL();
+                
+        /**
+        * Displays global note
+        * @param aNoteType Type of note
+        * @param aMsgId Message ID
+        * @param aDialog Cover ui dialog type
+        * @param aIcon Icon id
+        * @param aIconMask Icon mask id
+        */
+        void DisplayGlobalNoteL( TAknGlobalNoteType aNoteType, TInt aMsgId,
+                                 SecondaryDisplay::TVUISecondaryDisplayDialogs aDialog,
+                                 TMifAvkon aIcon = (TMifAvkon) 0, TMifAvkon aIconMask = (TMifAvkon) 0 );
+        /**
+        * Displays global note
+        * @param aNoteType Type of note
+        * @param aNoteText Text of the note
+        * @param aDialog Cover ui dialog type
+        * @param aIcon Icon id
+        * @param aIconMask Icon mask id
+        */
+        void DisplayGlobalNoteL( TAknGlobalNoteType aNoteType, HBufC* aNoteText,
+                                 SecondaryDisplay::TVUISecondaryDisplayDialogs aDialog,
+                                 TMifAvkon aIcon, TMifAvkon aIconMask );
+        
+    private:    // Data
+
+        // Note
+        CAknGlobalNote*         iNote;
+        
+        // Id of the currently shown note
+        TInt                    iNoteId;
+};
+
+#endif  // VUICGLOBALNOTE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicglobalprogressdialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the global progress dialog class
+*
+*/
+
+
+#ifndef VUICGLOBALPROGRESSDIALOG_H
+#define VUICGLOBALPROGRESSDIALOG_H
+
+//  INCLUDES
+#include <coecntrl.h>
+#include <AknProgressDialog.h>
+#include <AknsItemID.h>
+
+#include <secondarydisplay/vuisecondarydisplayapi.h>
+
+// FORWARD DECLARATIONS
+class MKeyCallback;
+
+// CLASS DECLARATION
+
+/**
+*  Displays progress dialog
+*/
+NONSHARABLE_CLASS( CGlobalProgressDialog ) : public CCoeControl,
+                                             public MProgressDialogCallback
+{
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CGlobalProgressDialog* NewLC();
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CGlobalProgressDialog* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CGlobalProgressDialog();
+
+    public: // New functions
+        
+        /**
+        * Sets the icon for this dialog
+        * since 2.0
+        * @param aIconFile File containing icon
+        * @param aIconId Icon ID
+        * @param aIconMaskId  Icon mask ID
+        */
+        void SetIconL( const TDesC& aIconFile, TInt aIconId = 0,
+                       TInt aIconMaskId = -1 );
+        /**
+        * Sets the image for the dialog
+        * since 2.0
+        * @param aImageFile Image filename
+        * @param aImageId Image ID
+        * @param aImageMaskId Image mask ID
+        */
+        void SetImageL( const TDesC& aImageFile, TInt aImageId = 0,
+                        TInt aImageMaskId = -1 );
+
+        /**
+        * Sets additional information to be sent to secondary display.
+        * Must be called before sending data to notifier to have effect.
+        *
+        * @param aCategory Category Uid
+        * @param aDialogIndex One of dialog indices
+        * @param aData Data to be sent to cover UI
+        */
+        void SetSecondaryDisplayDataL( TUid aCategory, TInt aDialogIndex,
+                                       const SecondaryDisplay::TMatchData* aData );
+
+        /**
+        * Shows the progress dialog
+        * since 2.0
+        * @param aPrompt Dialog prompt
+        * @param aIconText Text of the icon
+        * @param aSoftkeys Dialog soft keys
+        */
+        void ShowProgressDialogL( const TDesC& aPrompt, const TDesC& aIconText, TInt aSoftkeys = 0 );
+
+        /**
+        * Updates the progress dialog
+        * since 2.0
+        * @param aValue progress bar value
+        * @param aFinalValue progress bar final value
+        */
+        void UpdateProgressDialogL( TInt aValue, TInt aFinalValue );
+
+        /**
+        * Register for softkey callback
+        * since 2.0
+        * @param aKeyCallback Pointer to callback client
+        */
+        void RegisterForKeyCallback( MKeyCallback* aKeyCallback );
+
+        /**
+        * Sets skin ids for image and icon
+        * @param aImageId Image id
+        * @param aImageBitmapId Fallback bitmap id for the image
+        * @param aImageMaskId Fallback mask id for the image
+        * @param aIconId Icon id
+        */
+        void SetSkinIds( TAknsItemID aImageId, TInt aImageBitmapId,
+                         TInt aImageMaskId, TAknsItemID aIconId );
+      
+    public:     // Functions from base classes                                
+
+        /**
+        * From MProgressDialogCallback Handles keypresses and closing of the dialog 
+        * @see MProgressDialogCallback
+        */
+        void DialogDismissedL( TInt aButtonId );
+
+    private:
+
+        /**
+        * By default Symbian constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+        CGlobalProgressDialog();
+        
+        /**
+        * Called to complete the global progress dialog
+        * since 2.0
+        */
+        void ProcessFinished();
+
+    private:    // Data
+
+        enum TInternalState
+            {
+            EStarted,
+            ERunning,
+            EFinished
+            };
+            
+        // Progress dialog
+        CAknProgressDialog*         iProgressDialog;
+        
+        // Key observer
+        MKeyCallback*               iKeyCallback;
+        
+        // For handling internal logics
+        TInternalState              iInternalState;
+};
+
+#endif  // VUICGLOBALPROGRESSDIALOG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicinitstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICINITSTATE_H
+#define VUICINITSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+#include "voiceuibldvariant.hrh"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CInitState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CInitState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CInitState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CInitState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+    private:    // Functions
+    
+        /**
+        * Initializes recognition system
+        * @since 3.2
+        */
+        void InitializeL();
+        
+#ifndef __WINS__
+#ifdef __FULLDUPLEX_CHANGE
+        /**
+        * Starts sampling
+        * @since 3.2
+        */
+        void StartSamplingL();
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__
+
+        /**
+        * Starts recognition initialization
+        * @since 3.2
+        */
+        void RecognizeInitL();
+                
+    private:    // Data
+
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+#ifndef __WINS__            
+#ifdef __FULLDUPLEX_CHANGE
+            ESamplingStarted,
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__
+            EInitialized,
+            EReady
+            };
+
+        // For handling internal state logics
+        TInternalState      iInternalState;
+};
+
+#endif  // VUICINITSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuickeygrabber.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICKEYGRABBER_H
+#define VUICKEYGRABBER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <w32std.h>
+
+// FORWARD DECLARATIONS
+class MKeyCallback;
+
+// CLASS DECLARATION
+/**
+* 
+*
+*/
+NONSHARABLE_CLASS( CKeyGrabber ) : public CActive
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CKeyGrabber* NewL( MKeyCallback* aKeyObserver );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CKeyGrabber();
+                                
+    public:     // New functions    
+    
+    public:     // From base classes
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void DoCancel();
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void RunL();
+    
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CKeyGrabber( MKeyCallback* aKeyObserver );
+                
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+        
+    private:    // Data
+
+        // Key callback
+        MKeyCallback*                   iKeyObserver;
+
+        // Window group
+        RWindowGroup                    iWindowGroup;
+        
+        // Window server session
+        RWsSession                      iWsSession;
+        
+        // Camera key handle
+        TInt                            iCameraHandle;
+        
+        // Poc key handle
+        TInt                            iPocHandle;
+        
+        // Power key handle
+        TInt                            iPowerHandle;
+        
+        // Application key handle
+        TInt                            iApplicationHandle;
+
+};
+
+#endif  // VUICKEYGRABBER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuiclistquerydialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICLISTQUERYDIALOG_H
+#define VUICLISTQUERYDIALOG_H
+
+// INCLUDES
+#include <aknlistquerydialog.h>
+
+// CLASS DECLARATION
+/**
+* 
+*
+*/
+NONSHARABLE_CLASS( CListQueryDialog ) : public CAknListQueryDialog,
+										public MEikScrollBarObserver
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CListQueryDialog* NewL( TInt *aIndex,
+                                       CListQueryDialog** aSelf,
+                                       MEikCommandObserver* aObserver = NULL,
+                                       TInt aMenuTitleResourceId = NULL );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CListQueryDialog();
+                                
+    public:  // New functions
+    
+        /**
+        * Checks if menu is currently visible
+        * @return ETrue if menu is visible
+        */
+        TBool IsMenuVisible();
+        
+        /**
+        * Sets optional menu commands hidden or visible
+        * @param aHidden ETrue if commands should be hidden else EFalse
+        */
+        void SetCommandVisibility( TBool aHidden );
+    
+    protected:  // Functions from base classes
+    
+        /**
+        * From CAknListQueryDialog
+        * @see CAknListQueryDialog for more information.
+        */
+        void PostLayoutDynInitL();
+        
+        /**
+        * From CAknListQueryDialog
+        * @see CAknListQueryDialog for more information.
+        */
+        TBool OkToExitL( TInt aButtonId );
+        
+        /**
+        * From CAknListQueryDialog
+        * @see CAknListQueryDialog for more information.
+        */
+        void ProcessCommandL( TInt aCommandId );
+        
+        /**
+        * From CAknListQueryDialog
+        * @see CAknListQueryDialog for more information.
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+        
+        /**
+        * From CAknListQueryDialog
+        * @see CAknListQueryDialog for more information.
+        */
+        void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
+        
+        /**
+        * From MEikScrollBarObserver
+        * @see MEikScrollBarObserver for more information.
+        */
+        void HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType );
+                         
+    private:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CListQueryDialog( MEikCommandObserver* aObserver,
+                          TInt aMenuTitleResourceId,
+                          TInt *aIndex,
+                          CListQueryDialog** aSelf );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+    private:    // Data
+        
+        // State of optionally visible menu commands
+        TBool                   iCommandsHidden;
+        
+        // Menu command observer
+        MEikCommandObserver*    iObserver;
+        
+        // Options menu resource id
+        TInt                    iMenuResourceId;
+        
+        // Address of self pointer
+        CListQueryDialog**      iSelf;
+};
+
+#endif  // VUICLISTQUERYDIALOG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicmessagequerydialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICMESSAGEQUERYDIALOG_H
+#define VUICMESSAGEQUERYDIALOG_H
+
+// INCLUDES
+#include <aknmessagequerydialog.h>
+
+// CLASS DECLARATION
+/**
+* 
+*
+*/
+NONSHARABLE_CLASS( CMessageQueryDialog ) : public CAknMessageQueryDialog
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CMessageQueryDialog* NewL( CMessageQueryDialog** aSelf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CMessageQueryDialog();
+                                
+    public:  // New functions
+        
+    protected:  // Functions from base classes
+                             
+    private:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CMessageQueryDialog( CMessageQueryDialog** aSelf );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+    private:    // Data
+        
+        // Address of self pointer
+        CMessageQueryDialog**      iSelf;
+};
+
+#endif  // VUICMESSAGEQUERYDIALOG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicnbestlistdialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,196 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of class that shows the N-Best List
+*
+*/
+
+#ifndef VUICNBESTLISTDIALOG_H
+#define VUICNBESTLISTDIALOG_H
+
+//  INCLUDES
+#include <aknlists.h>
+#include <aknlistquerydialog.h>
+#include <AknMediatorObserver.h>
+
+// FORWARD DECLARATIONS
+class CAknIconArray;
+class CListQueryDialog;
+class MKeyCallback;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* The N-Best List Dialog
+* @lib VoiceUiRecognition.lib
+*/
+NONSHARABLE_CLASS( CNBestListDialog ) : public CCoeControl,
+                                        public MEikCommandObserver,
+                                        public MAknDialogMediatorObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CNBestListDialog* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CNBestListDialog();
+
+    public: // New functions
+
+        /**
+        * Registers given object as a key listener
+        */
+        void RegisterForKeyCallback( MKeyCallback* aKeyCallback );
+        
+        /**
+        * Creates N-Best List
+        * @param aItems Items that will be shown in the list. Takes ownership of the list.
+        * @param aHeader Optional header text for the list
+        */
+        void CreateNBestListPopupLC( CDesC16ArrayFlat* aItems,
+                                     const TDesC& aHeader = KNullDesC );
+
+        /**
+        * Shows N-Best List
+        * @return Key value that caused the dialog to be dismissed
+        */
+        TInt ShowNBestListPopupL();
+        
+        /**
+        * Sets n-best list softkeys
+        * @param aResourceId Softkey resource id
+        */
+        void SetSoftkeysL( TInt aResourceId );
+        
+        /**
+        * Sets optional commands hidder or visible
+        * @param aHidden ETrue if commands should be hidden else EFalse
+        */
+        void SetCommandsHidden( TBool aHidden );
+
+        /**
+        * Takes care of the headset short key presses. Replaces the list with new one
+        * or moves down one item in the list.
+        * @param aItems New items that will be shown in the list. Takes ownership of the list.
+        * @return EFalse if the end of the list is passed else ETrue
+        */
+        TBool HandleShortKeypressL( CDesC16ArrayFlat* aItems );
+        
+        /**
+        * Returns currently selected index
+        * @return Index of current n-best list selection
+        */
+        TInt SelectedIndex();
+        
+    public:     // Functions from base classes
+    
+        /**
+        * From CCoeControl Called when a key is pressed
+        * @see CCoeControl
+        */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+        
+        /**
+        * From MEikCommandObserver
+        * @see MEikCommandObserver for more information.
+        */
+        void ProcessCommandL( TInt aCommandId );
+        
+        /**
+        * From MAknDialogMediatorObserver
+        * @see MAknDialogMediatorObserver for more information.
+        */
+        TAknDialogMediatorObserverCommand MediatorCommandL( TUid aDomain, TUid aCategory, 
+                                                            TInt aCommandId,
+                                                            const TDesC8& aData ); 
+
+        /**
+        * From MAknDialogMediatorObserver
+        * @see MAknDialogMediatorObserver for more information.
+        */
+        void NotifyMediatorExit(); 
+
+    private:    // New functions
+
+        /**
+        * Converts key event to one of keypress enumeration values
+        * @param aKeyEvent Original key event
+        * @return One of keypress enumeration values
+        */
+        TInt ConvertKeyEventL( const TKeyEvent& aKeyEvent );
+
+        /**
+        * Creates new icon array. Ownership is transferred to caller.
+        * @return Icon array
+        */
+        CArrayPtr<CGulIcon>* CreateIconArrayL();
+
+        /**
+        * Load a possibly skinned icon (with mask) and append it to an 
+        * icon array.
+        * @param aArray    Icon array to add the icon to
+        * @param aID       Skin ID for the icon
+        * @param aBitmapId Id for the default icon in the MBM file
+        * @param aMaskId   Id for the default icon mask in the MBM file
+        */
+        static void AppendIconToArrayL( CAknIconArray* aArray,
+                                        const TAknsItemID& aID,
+                                        TInt aBitmapId,
+                                        TInt aMaskId );
+        
+        /**
+        * Creates and sets n-best list data to secondary display
+        * @param aItems New items that will be shown in the list. Takes ownership of the list.
+        */                                
+        void CreateAndSetSecondaryDisplayDataL( CDesC16ArrayFlat* aItems );
+                
+    private:    // Constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CNBestListDialog();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: //data
+    
+        // Dialog
+        CListQueryDialog*                   iDialog;
+        
+        // Key observer
+        MKeyCallback*                       iKeyCallback;
+        
+        // Index of currently selected item
+        TInt                                iCurrentIndex;
+        
+        // Number of tags in the list
+        TInt                                iTagCount;
+                
+        // Current CBA resource id
+        TInt                                iCba;
+    };
+
+#endif  // VUICNBESTLISTDIALOG_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicnotificationobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+#ifndef VUICNOTIFICATIONOBSERVER_H
+#define VUICNOTIFICATIONOBSERVER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+*
+*
+*/
+NONSHARABLE_CLASS( CNotificationObserver ) : public CActive
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CNotificationObserver* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CNotificationObserver();
+                                
+    public:     // From base classes
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void DoCancel();
+    
+        /**
+        * From CActive 
+        * @see CActive for more information
+        */
+        void RunL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CNotificationObserver();
+                
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+
+    private:    // Data
+
+        // Fold event
+        RProperty                           iNotificationState;
+        
+        // Current fold status
+        TInt                                iNotificationStatus;
+};
+
+#endif  // VUICNOTIFICATIONOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicplaystate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICPLAYSTATE_H
+#define VUICPLAYSTATE_H
+
+// INCLUDES
+#include <AknsItemID.h>
+
+#include <cntdef.h> 
+
+#include <nssttsutility.h>
+
+#include <vuivoicerecogdefs.h>
+
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+class CGlobalProgressDialog;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CPlayState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CPlayState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CPlayState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CPlayState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+        /**
+        * Handles timed event
+        */
+        void DoTimedEventL();
+
+    private:    // Functions
+    
+        /**
+        * Formats given name to fit one line
+        * @param aName Name to be formatted
+        */
+        void FormatName( TDes& aName );
+    
+        /**
+        * Plays voice tag
+        */
+        void PlayVoiceTagL();
+        
+        /**
+        * Fetches and formats data that will be shown while playing
+        * @param aName Name to be used
+        * @param aPhoneNumber Phone number to be used
+        * @param aFieldType Field type to be used
+        */
+        void FormatDataL( TDes& aName, TDes& aPhoneNumber, TFieldType& aFieldType );
+        
+        /**
+        * Shows the play dialog
+        * @param aName Name that will be shown
+        * @param aPhoneNumber Phone number that will be shown
+        * @param aFieldType Type of the shown field
+        */
+        void ShowPlaydialogL( const TDesC& aName, const TDesC& aPhoneNumber,
+                              const TFieldType aFieldType );
+    
+        /**
+        * Determines icon information according to the given type
+        * @param aType Type to be used
+        * @param aIcon Selected icon
+        * @param aIconMask Selected icon mask
+        * @param aIconId Selected icon id
+        */
+        void GetDialogIcon( const TFieldType& aType, TInt& aIcon,
+                            TInt& aIconMask, TAknsItemID& aIconId );
+                 
+    private:    // Data
+
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            EInitialized,
+            ECompleted
+            };
+        
+        // Dialog
+        CGlobalProgressDialog*          iProgressDialog;
+        
+        // For handling internal state logics
+        TInternalState                  iInternalState;
+        
+        // Used to count timer ticks
+        TInt                            iTickCount;
+        
+        // Timer data model
+        VTimerModel                     iTModel;
+        
+        // Playback length
+        TInt                            iPlaybackDelay;
+};
+
+#endif  // VUICPLAYSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicprecheckstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICPRECHECKSTATE_H
+#define VUICPRECHECKSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CPrecheckState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CPrecheckState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CPrecheckState();
+                                
+    public:     // New functions
+        
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CPrecheckState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+    private:    // Functions
+            
+        /**
+        * Checks auto lock value
+        * @return Auto lock value or KErrNotFound
+        */
+        TInt GetAutoLockValue();
+        
+        /**
+        * Checks if call is active
+        * @return Call state or KErrNotFound
+        */
+        TInt CheckCallState();
+        
+        /**
+        * Checks if video call is active
+        * @return ETrue if video call else EFalse
+        */
+        TBool IsVideoCall();
+        
+        /**
+        * Checks if "lockphone" dialog is active
+        * @return ETrue if lockphone dialog else EFalse
+        */
+        TBool IsLockPhoneDialogL();
+                
+    private:    // Data
+
+};
+
+#endif  // VUICPRECHECKSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicpropertyhandler.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Active object for subscribing to Publish & Suscribe properties 
+*
+*/
+
+
+#ifndef VUICPROPERTYHANDLER_H
+#define VUICPROPERTYHANDLER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+// FORWARDS
+class CVoiceRecognitionDialogImpl;
+
+// CLASS DECLARATION
+
+/**
+* Active object for subscribing to Publish & Suscribe properties
+*/
+NONSHARABLE_CLASS( CPropertyHandler ) : public CActive
+    {
+    public:  // Constructors and destructor
+        /**
+        * Symbian two-phased constructor.
+        * @param aCategory Category of the property to watch
+        * @param aKey      Key UID of the property to watch
+        * @param aCallback Callback to get notifications about changes
+        */
+        static CPropertyHandler* NewL( TUid aFirstCategory,
+                                       TUint aFirstKey,
+                                       TUid aSecondCategory,
+                                       TUint aSecondkey);
+
+        // Destructor
+        virtual ~CPropertyHandler();
+
+    public:  // New functions
+        
+        /**
+        * Method to handle the deregistration of monitoring accessories
+        * @param 
+        */  
+        void Register( CVoiceRecognitionDialogImpl* aRecogObserver );
+
+        /**
+        * Method to handle the deregistration of monitoring accessories
+        * @param 
+        */  
+        void DeRegister( CVoiceRecognitionDialogImpl* aRecogObserver );
+
+    private: // Functions from base classes
+
+        /**
+        * From CActive.
+        * Handle a change event.
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * Cancel the request to receive events.
+        */
+        void DoCancel();
+
+    private: // New functions
+
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL( TUid aFirstCategory,
+                         TUint aFirstKey,
+                         TUid aSecondCategory,
+                         TUint aSecondKey );
+
+        /**
+        * C++ constructor.
+        */
+        CPropertyHandler();
+
+    private:    // Data
+
+        RProperty                       iProperty;
+        TCallBack                       iCallback;
+        TBool                           iRequestIssued;
+        CVoiceRecognitionDialogImpl*    iRecogObserver;
+        TUid                            iFirstCategory;
+        TUint                           iFirstKey;
+    };
+
+#endif    // VUICPROPERTYHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicrecordstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICRECORDSTATE_H
+#define VUICRECORDSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+#include <vuivoicerecogdefs.h>
+
+// FORWARD DECLARATIONS
+class CGlobalProgressDialog;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CRecordState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CRecordState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CRecordState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CRecordState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Handles timed event
+        */
+        void DoTimedEventL();
+
+    private:    // Functions
+                
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            ERecording,
+            EStopped,
+            EFinished
+            };
+
+        // Record progressdialog
+        CGlobalProgressDialog*          iProgressDialog;
+        
+        // For handling internal state logics
+        TInternalState                  iInternalState;
+        
+        // Used to count timer ticks
+        TInt                            iTickCount;
+        
+        // Timer data model
+        VTimerModel                     iTModel;
+};
+
+#endif  // VUICRECORDSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicresultsstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICRESULTSSTATE_H
+#define VUICRESULTSSTATE_H
+
+// INCLUDES
+#include <cntdef.h> 
+#include <mccaconnection.h>
+
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+class CNBestListDialog;
+class CDesC16ArrayFlat;
+class MNssTag;
+class MCCAConnection;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CResultsState ) : public CState,
+                                     public MCCAObserver
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CResultsState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CResultsState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+        
+    public:
+        
+        /**
+        * From MCCAObserver
+        * @see MCCAObserver for more information
+        */
+        void CCASimpleNotifyL( TNotifyType aType, TInt aReason );
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CResultsState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+        /**
+        * Handles timed event
+        */
+        void DoTimedEventL();
+        
+    private:    // Functions        
+        
+        /**
+        * Handles keypress event
+        * @return ETrue if event was handled else EFalse
+        */
+        TBool HandleKeypressL();
+        
+        /**
+        * Plays currently selected name from the n-best list with TTS
+        */
+        void PlaySelectedNameL();
+        
+        /**
+        * Changes options menu commands visibility if necessary
+        */
+        void CheckOptionsCommands();
+        
+        /**
+        * Creates a contact array.
+        */
+        void CreateContactArrayL();
+        
+        /**
+        * Updates contact array.
+        * @return ETrue if array was updated else EFalse
+        */
+        TBool UpdateContactArray();
+        
+        /**
+        * Checks if given tag exists in taglist
+        * @param aTag Tag that is searched
+        * @return ETrue if tag exists else EFalse
+        */
+        TBool CheckIfAlreadyAdded( MNssTag* aTag );
+        
+        /**
+        * Creates new items array. Ownership is transferred to caller.
+        * @return Items array     
+        */
+        CDesC16ArrayFlat* CreateItemsArrayL();
+       
+        /**
+        * Fills buffer with dial tag information
+        * @param aTag Tag containing all needed information
+        * @param aBuffer Buffer to be filled
+        */
+        void FillDialContextBufferL( MNssTag* aTag, TDes& aBuffer );
+        
+        /**
+        * Fills buffer with command tag information
+        * @param aTag Tag containing all needed information
+        * @param aBuffer Buffer to be filled
+        */
+        void FillCommandContextBuffer( MNssTag* aTag, TDes& aBuffer );
+       
+        /**
+        * Gets the right icon for contact
+        * @param aFieldType The type of contacts field
+        * @return Icon type   
+        */
+        TPtrC GetContactIconType( TFieldType aFieldType );
+        
+        /**
+        * Selects currently active tag from n-best list
+        */
+        void SelectTag();
+        
+        /**
+        * Opens phonebook info view of the selected contact
+        */
+        void OpenPhonebookContactL();
+               
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            EInitialized,
+            ECompleted
+            };
+    
+        // N-best list dialog
+        CNBestListDialog*           iNBestListDialog;
+        
+        // Stores a keypress event from HandleEventL
+        TInt                        iKeypress;
+        
+        // For handling internal state logics
+        TInternalState              iInternalState;
+                
+        // For storing copies of tag pointers
+        CArrayPtrFlat<MNssTag>*     iTagList;
+        
+        MCCAConnection*             iConnection;
+    };
+
+#endif  // VUICRESULTSSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for voice ui states
+*
+*/
+
+
+#ifndef VUICSTATE_H
+#define VUICSTATE_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CDataStorage;
+class CUiModel;
+
+// CLASS DECLARATION
+/**
+* Abstract base class for different states
+*
+*/
+NONSHARABLE_CLASS( CState ) : public CBase
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Destructor.
+        */
+        virtual ~CState();
+                                
+    public:     // New functions    
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent ) = 0;
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL() = 0;
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+                
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+        /**
+        * Returns the data storage
+        * @return Reference to DataStorage
+        */
+        CDataStorage& DataStorage() const;
+         
+        /**
+        * Returns the ui model
+        * @return Reference to UiModel
+        */     
+        CUiModel& UiModel() const;
+        
+        /**
+        * Starts progress timer
+        * @param aEventHandler Object which will handle timed event
+        * @param aDelay Delay before first timed event
+        * @param aInterval Interval between timed events
+        */
+        void StartTimerL( CState& aEventHandler, TInt aDelay, TInt aInterval );
+        
+        /**
+        * Deletes progress timer
+        */
+        void StopTimer();
+       
+        /**
+        * Callback for timed event
+        * @param aObject Contains this pointer
+        * @return KErrNone
+        */
+        static TInt OnTimedEvent( TAny* aObject );
+        
+        /**
+        * Handles timed event
+        */
+        virtual void DoTimedEventL();
+        
+        /**
+        * Brings the application to foreground
+        */
+        void BringToForeground();
+        
+    private:    // Data
+
+        // Data storage
+        CDataStorage*     iDataStorage;
+        
+        // Data model
+        CUiModel*         iUiModel;
+        
+        // Timer for timed events
+        CPeriodic*        iTimer;
+};
+
+#endif  // VUICSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuictoneplayer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the class that handles tone playing for the 
+*               VoiceUIRecognition
+*
+*/
+
+
+#ifndef VUICTONEPLAYER_H
+#define VUICTONEPLAYER_H
+
+// INCLUDES
+#include <mdaaudiosampleplayer.h>
+
+
+// CONSTANTS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CMdaAudioPlayerUtility;
+
+// CLASS DECLARATION
+
+/**
+*  Initializes and plays tones
+*/
+NONSHARABLE_CLASS( CTonePlayer ) : public CBase,
+                                   public MMdaAudioPlayerCallback
+    {
+    public:  // Constructors and destructor
+
+         /**
+        * Two-phased constructor.
+        */
+        static CTonePlayer* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTonePlayer();
+
+    public: // New functions
+
+        /**
+        * Sets the observer
+        * @param aObserver The class requesting the tone callbacks
+        */
+        void RegisterObserver( MMdaAudioPlayerCallback* aObserver );
+
+        /**
+        * Performs initialization for playing tones
+        * @param aSid The sound ID
+        */
+        void InitToneL( TInt aSid );
+
+        /**
+        * Plays initialized tone
+        * @param aSid The sound ID
+        */
+        void PlayTone( TInt aSid );
+        
+        /**
+        * Check Bt Accessory Status
+        * @
+        */
+        void ChekcAccesoryStatusL();
+
+    public: // Functions from base classes
+
+        /**
+        * From MMdaAudioPlayerCallback.
+        * @see MMdaAudioPlayerCallback for more information.
+        */
+        void MapcInitComplete( TInt aError, 
+                               const TTimeIntervalMicroSeconds& aDuration );
+
+        /**
+        * From MMdaAudioPlayerCallback
+        * @see MMdaAudioPlayerCallback for more information.
+        */
+        void MapcPlayComplete( TInt aError );
+        
+    private:    // Constructors & Destructor
+
+        /**
+        * By default constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+        CTonePlayer();
+
+    private:    // New functions
+        
+        /**
+        * Returns scaled volume value
+        * @return Volume value, range [0 - MaxVolume]
+        */
+        TInt ScaledVolume();
+
+    private:    // Data
+        
+        // Audio player
+        CMdaAudioPlayerUtility*         iAudioPlayer;
+
+        // Playback observer
+        MMdaAudioPlayerCallback*        iObserver;
+
+        // Start sound path
+        HBufC*                          iStartSound;
+        
+        // Bluetooth start sound path
+        HBufC*                          iBtStartSound;
+        
+        // Confirmation sound path
+        HBufC*                          iConfirmationSound;
+
+        // Volume
+        TInt                            iVolume;
+        
+        //BT Accessory flag
+        TBool                           iBTAcc;
+        };
+
+#endif      // VUICTONEPLAYER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicttsplayer.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICTTSPLAYER_H
+#define VUICTTSPLAYER_H
+
+// INCLUDES
+#include <e32base.h>
+
+#include <nssttsutility.h>
+
+// FORWARD DECLARATIONS
+class MTtsClientUtilityObserver;
+
+// CONSTANTS
+const TInt KMaxSegments = 6;
+
+// CLASS DECLARATION
+/**
+* 
+*
+*/
+NONSHARABLE_CLASS( CTTSPlayer ) : public CBase
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CTTSPlayer* NewL( MTtsClientUtilityObserver* aObserver );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTTSPlayer();
+                                
+    public:     // New functions
+    
+        /**
+        * Starts the playback
+        * @param aText Complete text to be played
+        * @param aPosition First possible index of the segment
+        * @param aMaxLength Maximum possible length of the segment
+        * @param aSegment Text to be segmented from aText
+        */
+        void PlayL( const TDesC& aText, TInt aPosition = 0,
+                    TInt aMaxLength = 0, const TDesC& aSegment = KNullDesC );
+        
+        /**
+        * Starts the playback
+        * @param aText Start of the text to be played
+        * @param aPosition First possible index of the segment
+        * @param aMaxLength Maximum possible length of the segment
+        * @param aSegment Text to be segmented from aText
+        * @param aNewSegment1 New segment to be added to end of text
+        * @param aNewSegment2 New segment to be added to end of text
+        * @param aNewSegment3 New segment to be added to end of text
+        */
+        void PlayL( const TDesC& aText, TInt aPosition,
+                    TInt aMaxLength, const TDesC& aSegment,
+                    const TDesC& aNewSegment1,
+                    const TDesC& aNewSegment2 = KNullDesC,
+                    const TDesC& aNewSegment3 = KNullDesC );
+        
+        /**
+        * Stops the playback
+        */
+        void Stop();
+             
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CTTSPlayer( MTtsClientUtilityObserver* aObserver );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+    private:    // Data
+    
+        /**
+        * Creates segments from given text
+        * @param aText Complete text to be played
+        * @param aPosition First possible index of the segment
+        * @param aMaxLength Maximum possible length of the segment
+        * @param aSegment Text to be segmented from aText
+        */
+        void CreateSegmentsL( const TDesC& aText, TInt aPosition,
+                              TInt aMaxLength, const TDesC& aSegment );
+    
+    struct TTtsData
+        {
+        // TTS speech styles
+        TTtsStyle* iStyle[KMaxSegments];
+
+        // TTS speech style handles
+        TTtsStyleID* iStyleId[KMaxSegments];
+
+        // TTS speech segments
+        TTtsSegment* iSegment[KMaxSegments];
+
+        // TTS player
+        CTtsUtility* iTts;
+
+        // Parsed text
+        CTtsParsedText* iParsedText;
+
+        // Initializes everything to zero
+        TTtsData();
+        };
+        
+    // Play observer
+    MTtsClientUtilityObserver*      iObserver;
+    
+    // TTS Data
+    TTtsData*                       iTtsData;
+};
+
+#endif  // VUICTTSPLAYER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuictutorial.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles tutorial mode resources and dialog showing
+*
+*/
+
+
+#ifndef VUICTUTORIAL_H
+#define VUICTUTORIAL_H
+
+// INCLUDES
+#include "vuictutorialmessagedialog.h"
+
+
+// CLASS DECLARATION
+/**
+* Handles tutorial mode resources and dialog showing
+*/
+NONSHARABLE_CLASS( CTutorial ) : public CBase
+{
+    public:     // Constructors and destructor
+       
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CTutorial* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTutorial();
+        
+    public:     // Enumerations
+    
+        enum TTutorialState
+            {
+            EIntroState,
+            ECommandState,
+            EDialState,
+            EOtherState,
+            ETryState,
+            EBestState,
+            EActivationState,
+            EErrorState,
+            EFinishedState            
+            };
+                                
+    public:     // New functions
+    
+        /**
+        * Creates a message dialog
+        */
+        void CreateMessageL();
+        
+        /**
+        * Creates and shows a message dialog
+        * @return Keycode of the pressed key
+        */
+        TInt CreateAndShowMessageL();
+        
+        /**
+        * Shows a message dialog
+        * @param aDeviceLockMode ETrue to set tutorial in device lock mode
+        * @return Keycode of the pressed key
+        */
+        TInt ShowMessageL( TBool aDeviceLockMode = EFalse );
+        
+        /**
+        * Destroys created message dialog
+        */
+        void DestroyMessage();
+        
+        /**
+        * Returns the current state of the tutorial
+        * @return One of the TTutorialState types
+        */
+        TTutorialState GetTutorialState();
+        
+        /**
+        * Sets the next shown message to be an error message
+        */
+        void ErrorState();
+                                
+    private:
+
+        /**
+        * Check's if the tutorial mode is enabled
+        * @return ETrue if tutorial mode is enabled else EFalse
+        */
+        TBool IsTutorialModeEnabled();
+        
+        /**
+        * Sets the first time mode off
+        */
+        void DisableFirstTimeMode();
+
+        /**
+        * C++ default constructor.
+        */
+        CTutorial();
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL();
+                       
+        /**
+        * Loads tutorial and first time mode settings from CenRep
+        */
+        void LoadSettingsL();
+
+        /**
+        * Saves tutorial and first time mode settings to CenRep
+        */
+        void SaveSettingsL();
+        
+    private:    // Data
+    
+        // Actual tutorial mode
+        TBool                       iTutorialMode;
+        
+        // First time tutorial mode
+        TBool                       iFirstTimeMode;
+        
+        // For handling internal logics
+        TTutorialState              iState;
+        
+        // Message dialog
+        CTutorialMessageDialog*     iDlg;
+};
+
+#endif  // VUICTUTORIAL_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuictutorialmessagedialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles the dialog used in tutorial mode
+*
+*/
+
+
+#ifndef VUICTUTORIALMESSAGEDIALOG_H
+#define VUICTUTORIALMESSAGEDIALOG_H
+
+// INCLUDES
+#include <coecntrl.h>
+
+#include <secondarydisplay/vuisecondarydisplayapi.h>
+
+// FORWARD DECLARATIONS
+class CMessageQueryDialog;
+
+// CLASS DECLARATION
+/**
+* Handles the dialog used in tutorial mode
+*/
+NONSHARABLE_CLASS( CTutorialMessageDialog ) : public CCoeControl
+{
+    public:     // Constructors and destructor
+        
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CTutorialMessageDialog* NewL();
+        
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CTutorialMessageDialog* NewLC();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTutorialMessageDialog();
+        
+        
+    public:     // New functions
+    
+        /**
+        * Shows a message dialog
+        * @param aDialogResourceId  Resource id of the dialog
+        * @param aHeaderId          Resource id of header text
+        * @param aMessagePart1Id    Resource id of message text part 1
+        * @param aMessagePart2Id    Resource id of message text part 2
+        * @param aCommandResourceId Resource id of the softkeys
+        * @param aDialog            Secondary display dialog id
+        * @return Keycode of the pressed key
+        */
+        TInt ShowMessageDialogL( TInt aDialogResourceId,
+                                 TInt aHeaderId,
+                                 TInt aMessagePart1Id,
+                                 TInt aMessagePart2Id,
+                                 TInt aCommandResourceId,
+                                 SecondaryDisplay::TVUISecondaryDisplayDialogs aDialog =
+                                    SecondaryDisplay::ECmdVoiceNoNote );
+                                
+    public:     // Functions from base classes                               
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTutorialMessageDialog();
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL();
+        
+        /**
+        * Concatenates given strings and inserts a space between the strings
+        * @param aString1 First string
+        * @param aString2 Second string
+        * @return Concatenated string
+        */
+        HBufC* ConcatenateLC( const TDesC& aString1, const TDesC& aString2 );
+        
+    private:    // Data
+        
+        // Message dialog
+        CMessageQueryDialog*        iDlg;
+        
+        // Current command set
+        TInt                        iCommands;
+};
+
+#endif  // VUICTUTORIALMESSAGEDIALOG_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuictutorialstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICTUTORIALSTATE_H
+#define VUICTUTORIALSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+#include "vuictutorial.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CTutorialState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CTutorialState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTutorialState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CTutorialState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+
+    private:    // Functions
+                
+    private:    // Data
+
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            EInitialized,
+            ECompleted
+            };
+
+        // For checking current tutorial state
+        CTutorial::TTutorialState       iCurrentTutorialState;
+        
+        // For handling internal state logics
+        TInternalState                  iInternalState;
+};
+
+#endif  // VUICTUTORIALSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicuimodel.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICUIMODEL_H
+#define VUICUIMODEL_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CGlobalNote;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CUiModel ) : public CBase
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CUiModel* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CUiModel();
+                                
+    public:     // New functions
+    
+        /**
+        * Returns note
+        * @return Reference to note object
+        */
+        CGlobalNote& Note() const;
+             
+    private:    // Functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CUiModel();
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+                
+    private:    // Data
+    
+        // Note
+        CGlobalNote*                iNote;
+};
+
+#endif  // VUICUIMODEL_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicverificationdialog.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the voice verification dialog
+*
+*/
+
+#ifndef VUICVERIFICATIONDIALOG_H
+#define VUICVERIFICATIONDIALOG_H
+
+//  INCLUDES
+#include <aknlists.h>
+#include <aknlistquerydialog.h>
+#include <AknMediatorObserver.h>
+
+#include <secondarydisplay/vuisecondarydisplayapi.h>
+
+// FORWARD DECLARATIONS
+class CListQueryDialog;
+class MKeyCallback;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Voice verification dialog
+*/
+NONSHARABLE_CLASS( CVerificationDialog ) : public CCoeControl,
+                                           public MAknDialogMediatorObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CVerificationDialog* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVerificationDialog();
+
+    public: // New functions
+
+        /**
+        * Registers given object as a key listener
+        */
+        void RegisterForKeyCallback( MKeyCallback* aKeyCallback );
+        
+        /**
+        * Creates verification query
+        * @param aHeader Optional header text for the list
+        */
+        void CreateVerificationPopupLC( const TDesC& aHeader );
+
+        /**
+        * Shows verification query
+        * @return Key value that caused the dialog to be dismissed
+        */
+        TInt ShowVerificationPopupL();
+                       
+        /**
+        * Returns selected command based on the selection id.
+        * @param aId Selection id
+        * @return Command id or KErrGeneral
+        */
+        TInt SelectedCommand( TInt aId );
+        
+    public:     // Functions from base classes
+    
+        /**
+        * From CCoeControl Called when a key is pressed
+        * @see CCoeControl
+        */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+        
+        /**
+        * From MAknDialogMediatorObserver
+        * @see MAknDialogMediatorObserver for more information.
+        */
+        TAknDialogMediatorObserverCommand MediatorCommandL( TUid aDomain, TUid aCategory, 
+                                                            TInt aCommandId,
+                                                            const TDesC8& aData ); 
+
+        /**
+        * From MAknDialogMediatorObserver
+        * @see MAknDialogMediatorObserver for more information.
+        */
+        void NotifyMediatorExit(); 
+
+    private:    // New functions
+
+        /**
+        * Converts key event to one of keypress enumeration values
+        * @param aKeyEvent Original key event
+        * @return One of keypress enumeration values
+        */
+        TInt ConvertKeyEventL( const TKeyEvent& aKeyEvent );
+        
+        /**
+        * Sets data for secondary display
+        * @param aData Data to be send to secondary display
+        */
+        void SetSecondaryDisplayDataL( SecondaryDisplay::TVerificationData& aData );
+                
+    private:    // Constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CVerificationDialog();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: //data
+    
+        // Dialog
+        CListQueryDialog*                   iDialog;
+        
+        // Key observer
+        MKeyCallback*                       iKeyCallback;
+        
+        // Index of currently selected item
+        TInt                                iCurrentIndex;
+    };
+
+#endif  // VUICVERIFICATIONDIALOG_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicverificationinitstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICVERIFICATIONINITSTATE_H
+#define VUICVERIFICATIONINITSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+#include "voiceuibldvariant.hrh"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CVerificationInitState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CVerificationInitState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVerificationInitState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CVerificationInitState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+    private:    // Functions
+    
+        /**
+        * Initializes recognition system
+        * @since 3.2
+        */
+        void InitializeL();
+        
+#ifdef __FULLDUPLEX_CHANGE
+        /**
+        * Starts sampling
+        * @since 3.2
+        */
+        void StartSamplingL();
+#endif // __FULLDUPLEX_CHANGE
+        
+        /**
+        * Starts recognition initialization
+        * @since 3.2
+        */
+        void RecognizeInitL();
+                
+    private:    // Data
+
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+#ifdef __FULLDUPLEX_CHANGE
+            ESamplingStarted,
+#endif // __FULLDUPLEX_CHANGE
+            EInitialized,
+            EReady
+            };
+
+        // For handling internal state logics
+        TInternalState      iInternalState;
+};
+
+#endif  // VUICVERIFICATIONINITSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicverificationstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICVERIFICATIONSTATE_H
+#define VUICVERIFICATIONSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+class CVerificationDialog;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CVerificationState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CVerificationState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVerificationState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CVerificationState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+        
+    private:    // Functions        
+        
+        /**
+        * Handles keypress event
+        * @return ETrue if event was handled else EFalse
+        */
+        TBool HandleKeypressL();
+        
+        /**
+        * Plays prompt with name from recognition results with TTS
+        */
+        void PlayPromptL();      
+
+        /**
+        * Selects first tag from recognition results
+        */
+        void SelectTag();
+        
+        /**
+        * Selects command by position id
+        * @return Command id or KErrGeneral
+        */
+        TInt SelectCommandById();
+   
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            ETtsInitialized,
+            ETtsCompleted,
+            EStartCompleted,
+            ERecordStarted,
+            ERecordEnded,
+            ECompleted
+            };
+    
+        // Verification dialog
+        CVerificationDialog*        iVerificationDialog;
+        
+        // Stores a keypress event from HandleEventL
+        TInt                        iKeypress;
+        
+        // For handling internal state logics
+        TInternalState              iInternalState;
+        
+        // Tag index
+        TInt                        iTagIndex;
+    };
+
+#endif  // VUICVERIFICATIONSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicverificationtrainingstate.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUICVERIFICATIONTRAININGSTATE_H
+#define VUICVERIFICATIONTRAININGSTATE_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+class CNssVASDBMgr;
+class MNssTagMgr;
+class MNssContextMgr;
+class MNssTag;
+class CNssTrainingParameters;
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+NONSHARABLE_CLASS( CVerificationTrainingState ) : public CState
+{
+    public:     // Constructors and destructor
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CVerificationTrainingState* NewL( CDataStorage& aDataStorage, CUiModel& aUiModel );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVerificationTrainingState();
+                                
+    public:     // New functions
+    
+        /**
+        * Handles received event
+        * @param Event to be handled
+        */
+        virtual void HandleEventL( TInt aEvent );
+        
+        /**
+        * Executes the state functionality
+        */
+        virtual void ExecuteL();
+         
+    protected:  // New functions
+        
+        /**
+        * C++ default constructor.
+        */
+        CVerificationTrainingState( CDataStorage& aDataStorage, CUiModel& aUiModel );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        virtual void ConstructL();
+
+    private:    // Functions
+    
+        /**
+        * Creates voice tags for verification commands
+        */
+        void CreateTagsL();
+        
+        /**
+        * Constructs command training parameters
+        */
+        void ConstructTrainingParametersL();
+        
+        /**
+        * Trains verification commands voice tags
+        */
+        void TrainTagsL();
+    
+        /**
+        * Saves verification commands voice tags
+        */
+        void SaveTagsL();
+        
+        /**
+        * Saves current UI language
+        */
+        void SaveLanguage();
+                
+    private:    // Data
+    
+        enum TInternalState
+            {
+            ENotStarted,
+            EStarted,
+            EContextDeleted,
+            EContextReady,
+            ECommandsTrained,
+            ECommandsSaved
+            };
+    
+        // Vas stuff for handling context operations
+        CNssVASDBMgr*           iVasDbManager;
+        MNssTagMgr*             iTagManager;
+        MNssContextMgr*         iContextManager;
+        
+        // Training parameters
+        CNssTrainingParameters* iTrainingParameters;
+        
+        // For handling internal state logics
+        TInternalState          iInternalState;
+        
+        // Created voice tags
+        RPointerArray<MNssTag>* iTags;
+        
+        // Number of expected callbacks
+        TInt                    iExpectedCallbacks;
+};
+
+#endif  // VUICVERIFICATIONTRAININGSTATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuicvoicerecogdialogimpl.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,262 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition of the dialog displayed when a recognition is in progress     :
+*
+*/
+
+
+#ifndef VUICVOICERECOGDIALOGIMPL_H
+#define VUICVOICERECOGDIALOGIMPL_H
+
+//  INCLUDES
+#include <nssvasapi.h>
+#include <nssttsutility.h> 
+
+#include "vuimkeycallback.h"
+
+#include "voiceuibldvariant.hrh"
+
+// FORWARD DECLARATIONS
+class CState;
+class CDataStorage;
+class CUiModel;
+class MVoiceRecognitionDialogCallback;
+
+// CLASS DECLARATION
+/**
+* The voice recognition dialog
+* @lib VoiceUiRecognition.lib
+*/
+NONSHARABLE_CLASS( CVoiceRecognitionDialogImpl ) : public CActive,
+                                                   public MKeyCallback,
+                                                   public MNssRecognizeInitCompleteHandler,
+                                                   public MNssRecognizeEventHandler,
+                                                   public MNssAdaptationEventHandler,
+                                                   public MTtsClientUtilityObserver,
+                                                   public MNssGetContextClient,
+                                                   public MNssGetTagClient,
+                                                   public MNssSaveContextClient,
+                                                   public MNssTrainTextEventHandler,
+                                                   public MNssSaveTagClient,
+                                                   public MNssDeleteContextClient
+    {
+
+    public:  // Constructors and Destructors
+
+        /**
+        * Symbian two-phased constructor.
+        */
+        static CVoiceRecognitionDialogImpl* NewL( MVoiceRecognitionDialogCallback* aObserver );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CVoiceRecognitionDialogImpl();
+
+    public:  // New functions
+    
+        /**
+        * Executes the dialog
+        */
+        void ExecuteL();
+
+        /**
+        * Only calls will be allowed if device is locked
+        */
+        void SetOnlyCallsAllowed();
+        
+        /**
+        * Handles property value change event.
+        * @param aValue New property value
+        */
+        void HandlePropertyValueChange( TInt aValue );
+        
+        /**
+        * Sets the next state
+        * @param aNextState State which will be activated. Has no effect if value is NULL
+        */
+        void ChangeState( CState* aNextState );
+        
+        /**
+        * Stops voice recognition
+        */
+        void Exit();
+
+    protected:  // Functions from base classes
+      
+        /**
+        * From MNssRecognizeInitCompleteHandler Called when recognition initialization is complete
+        * @see MNssRecognizeInitCompleteHandler
+        */
+        void HandleRecognizeInitComplete( TNssRecognizeInitError aErrorCode );
+
+#ifndef __WINS__          
+#ifdef __FULLDUPLEX_CHANGE
+        /**
+        * From MNssRecognizeInitCompleteHandler Called when presampling startup is complete
+        * @see MNssRecognizeInitCompleteHandler
+        */
+        void HandlePreSamplingStarted( TInt aErrorCode );
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__  
+
+        /**
+        * From MNssRecognizeEventHandler Called when recording has started
+        * @see MNssRecognizeEventHandler
+        */
+        void HandleRecordStarted();
+
+        /**
+        * From MNssRecognizeEventHandler Called when end-of-utterance is detected
+        * @see MNssRecognizeEventHandler
+        */
+        void HandleEouDetected();
+
+        /**
+        * From MNssRecognizeEventHandler Called when recognition is completed
+        * @see MNssRecognizeEventHandler
+        */
+        void HandleRecognizeComplete( CArrayPtrFlat<MNssTag>* aTagList,
+                                      TNssRecognizeError aErrorCode  );
+
+        /**
+        * From MKeyCallback Called when a softkey is pressed
+        * @see MKeyCallback
+        */
+        void HandleKeypressL( TInt aSoftkey );
+
+        /**
+        * From MNssAdaptationEventHandler Called when
+        * Adaptation is successful
+        * @see MNssAdaptationEventHandler for more information
+        */
+        void HandleAdaptComplete( TInt aErrorCode );
+        
+        /**
+        * From MMdaAudioPlayerCallback.
+        * @see MMdaAudioPlayerCallback for more information.
+        */
+        void MapcInitComplete( TInt aError, 
+                               const TTimeIntervalMicroSeconds& aDuration );
+
+        /**
+        * From MMdaAudioPlayerCallback
+        * @see MMdaAudioPlayerCallback for more information.
+        */
+        void MapcPlayComplete( TInt aError );
+
+        /**
+        * From MTtsClientUtilityObserver
+        * @see MTtsClientUtilityObserver for more information.
+        */
+        void MapcCustomCommandEvent( TInt aEvent, TInt aError );
+
+        /**
+        * From MGetContextClient
+        * @see MGetContextClient for more information
+        */        
+        void GetContextCompleted( MNssContext* aContext, TInt aErrorCode );
+
+        /**
+        * From MGetContextClient
+        * @see MGetContextClient for more information
+        */        
+        void GetContextListCompleted( MNssContextListArray *aContextList, TInt aErrorCode  );
+        
+        /**
+        * From MNssGetTagClient
+        * @see MNssGetTagClient for more information
+        */  
+        void GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode );
+        
+        /**
+        * From MNssSaveContextClient
+        * @see MNssSaveContextClient for more information
+        */
+        void SaveContextCompleted( TInt aErrorCode );
+
+        /**
+        * From MNssTrainTextEventHandler
+        * @see MNssTrainTextEventHandler for more information
+        */       
+        void HandleTrainComplete( TInt aErrorCode );
+        
+        /**
+        * From MNssSaveTagClient
+        * @see MNssSaveTagClient for more information
+        */  
+        void SaveTagCompleted( TInt aErrorCode );
+        
+        /**
+        * From MNssDeleteContextClient
+        * @see MNssDeleteContextClient for more information
+        */ 
+        void DeleteContextCompleted( TInt aErrorCode );
+
+    private: // Functions from base classes
+
+        /**
+        * From CActive.
+        * Handle a change event.
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * Cancel the request to receive events.
+        */
+        void DoCancel();
+
+    private:  // New functions
+    
+        /**
+        * C++ default constructor.
+        */
+        CVoiceRecognitionDialogImpl( MVoiceRecognitionDialogCallback* aObserver );
+        
+        /**
+        * Symbian OS 2nd phase constructor.
+        */
+        void ConstructL();
+        
+        /**
+        * Checks if the state can be changed and waits until possible.
+        */
+        void CheckState();
+
+    private:    // Data
+
+        // For storing various things needed in different states
+        CDataStorage*                       iDataStorage;
+        
+        // For storing global UI things
+        CUiModel*                           iUiModel;
+        
+        // Current state
+        CState*                             iState;
+        
+        // Next active state
+        CState*                             iNextState;
+        
+        // Mutex
+        RMutex                              iMutex;
+        
+        // Dialog observer
+        MVoiceRecognitionDialogCallback*    iObserver;
+   };
+
+#endif    // VUICVOICERECOGDIALOGIMPL_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuimcalldetectorobserver.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUIMCALLDETECTOROBSERVER_H
+#define VUIMCALLDETECTOROBSERVER_H
+
+/**
+ *  Observer for call detector
+ */
+class MCallDetectorObserver
+    {
+    public:
+
+        virtual void CallDetectedL() = 0;
+
+    };
+
+#endif // VUIMCALLDETECTOROBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuimkeycallback.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Callback for a key press
+*
+*/
+
+#ifndef VUIMKEYCALLBACK_H
+#define VUIMKEYCALLBACK_H
+
+/**
+* Callback for a key press
+* @lib VoiceUiRecognition.lib
+*/
+class MKeyCallback
+    {
+    public:
+        virtual void HandleKeypressL( TInt aSoftkey ) = 0;
+    };
+
+#endif    // VUIMKEYCALLBACK_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuimvoicerecogdialogcallback.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef VUIMVOICERECOGDIALOGCALLBACK_H
+#define VUIMVOICERECOGDIALOGCALLBACK_H
+
+// INCLUDES
+#include "vuicstate.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+* COMMENT
+*/
+class MVoiceRecognitionDialogCallback
+    {
+    public:
+        /**
+        * Called when the dialog is dismissed.
+        */
+        virtual void DialogDismissed() = 0;
+    };
+
+#endif  // VUIMVOICERECOGDIALOGCALLBACK_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuivoiceicondefs.h	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Icon definitions
+*
+*/
+
+
+#ifndef VUIVOICEICONDEFS_H
+#define VUIVOICEICONDEFS_H
+
+#include <avkon.mbg>
+#include <AknsConstants.h>
+#include <voiceui.mbg>
+
+const TInt KSindNumberOfIcons = 11;
+
+// Icon resource indices for different icons
+_LIT( KIconPhone,        "0" );
+//_LIT( KIconHome,         "1" );
+//_LIT( KIconWork,         "2" );
+_LIT( KIconMobile,       "3" );
+_LIT( KIconFax,          "4" );
+_LIT( KIconEmail,        "5" );
+_LIT( KIconBlank,        "6" );
+_LIT( KIconProfile,      "7" );
+_LIT( KIconApplication,  "8" );
+_LIT( KIconVideo,        "9" );
+_LIT( KIconVoip,        "10" );
+
+enum TIconId
+    {
+    EIconPhone,
+    EIconHome,
+    EIconWork,
+    EIconMobile,
+    EIconFax,
+    EIconEmail,
+    EIconBlank,
+    EIconProfile,
+    EIconApplication,
+    EIconVideo,
+    EIconVoip
+    };
+
+static const TInt KBitmapId[] = 
+    {
+    EMbmAvkonQgn_prop_nrtyp_phone,
+    EMbmAvkonQgn_prop_nrtyp_home,
+    EMbmAvkonQgn_prop_nrtyp_work,
+    EMbmAvkonQgn_prop_nrtyp_mobile,
+    EMbmAvkonQgn_prop_nrtyp_fax,
+    EMbmAvkonQgn_prop_nrtyp_email,
+    EMbmAvkonQgn_stat_bt_blank,
+    EMbmVoiceuiQgn_prop_profiles_small,
+    EMbmVoiceuiQgn_prop_fmgr_file_apps,
+    EMbmAvkonQgn_prop_nrtyp_video,
+    EMbmAvkonQgn_prop_nrtyp_voip
+    };
+    
+static const TInt KMaskId[] = 
+    {
+    EMbmAvkonQgn_prop_nrtyp_phone_mask,
+    EMbmAvkonQgn_prop_nrtyp_home_mask,
+    EMbmAvkonQgn_prop_nrtyp_work_mask,
+    EMbmAvkonQgn_prop_nrtyp_mobile_mask,
+    EMbmAvkonQgn_prop_nrtyp_fax_mask,
+    EMbmAvkonQgn_prop_nrtyp_email_mask,
+    EMbmAvkonQgn_stat_bt_uni_blank,
+    EMbmVoiceuiQgn_prop_profiles_small_mask,
+    EMbmVoiceuiQgn_prop_fmgr_file_apps_mask,
+    EMbmAvkonQgn_prop_nrtyp_video_mask,
+    EMbmAvkonQgn_prop_nrtyp_voip_mask
+    };
+       
+static const TAknsItemID* const KIconId[] = 
+    {
+    &KAknsIIDQgnPropNrtypPhone,
+    &KAknsIIDQgnPropNrtypHome,
+    &KAknsIIDQgnPropNrtypWork,
+    &KAknsIIDQgnPropNrtypMobile,
+    &KAknsIIDQgnPropNrtypFax,
+    &KAknsIIDQgnPropNrtypEmail,
+    &KAknsIIDQgnStatBtBlank,
+    &KAknsIIDQgnPropProfilesSmall,
+    &KAknsIIDQgnPropFmgrFileApps,
+    &KAknsIIDQgnPropNrtypVideo,
+    &KAknsIIDQgnPropNrtypVoip
+    };
+
+#endif	// VUIVOICEICONDEFS_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/inc/vuivoicerecognition.hrh	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Enumerations
+*
+*/
+
+
+#ifndef VUIVOICERECOGNITION_HRH
+#define VUIVOICERECOGNITION_HRH
+
+enum VTCommand
+    {
+    EVoiceTagSoftKeyStart=1,
+    EVoiceTagSoftKeyCancel,
+    EVoiceTagSoftKeySelect,
+    EVoiceTagSoftKeyDirectSelect,
+    EVoiceTagSoftKeyHelp,
+    EVoiceTagSoftKeyOpen,
+    EVoiceTagSoftKeyQuit,
+    EVoiceTagSoftKeyOther
+    };
+    
+enum VICommand
+    {
+    EVoiceInfoSoftKeyNext=1,
+    EVoiceInfoSoftKeyActivate,
+    EVoiceInfoSoftKeyCancel,
+    EVoiceInfoSoftkeyOther
+    };
+
+
+enum DialogControlId
+    {
+    EAddVoiceTagNote=100,
+    EVoicePlaybackProgressNoteId,
+    EVoiceDialProgressNoteId,
+    EVoiceTagAddConfirmationId,
+    EVoiceTagChangeConfirmationId,
+    EPhoneBusyId,
+    ENoVoiceTagId,
+    EVoiceQueryNoteId,
+    EVoiceDialGeneralErrorId,
+    EVoiceDialNotRecognizedId,
+    EVoiceDialNoSpeechId,
+    EVoiceTagErrorInRecogId,
+    ENoteDialogId,
+    EProgressDialogId
+    };
+
+enum TVoiceErrorId
+    {
+    EVoiceNoMatchFound = 5000
+    };
+
+#endif  // VUIVOICERECOGNITION_HRH
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/loc/vuivoicerecognition.loc	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,390 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localisation strings for Voice Recognition UI
+*
+*/
+
+
+// LOCALISATION STRINGS
+
+// d: Error message before launching Voice Dialing.
+// d: Shown if number of saved voice tags was 0.
+// l: popup_note_window/opt2
+// r: 3.1
+//
+#define text_voice_no_tag		        "No voice tags\nsaved"
+
+// d: Text message after failed recognition.
+// d: Shown if recorded speech didn't match to any voice tag.
+// l: popup_note_window/opt2
+// r: 3.1
+//
+#define text_voice_no_matches           "No match found"
+
+// d: Text message during recognition.
+// d: Shown when user is expected to say a name of the contact or an application.
+// l: popup_note_wait_window
+// r: 3.1
+//
+#define text_voice_speak_now            "Please speak now"
+
+// d: Error message before launching Voice Dialing.
+// d: Shown if phone is busy when starting Voice Dialing.
+// l: popup_note_window/opt2
+// r: 3.1
+//
+#define text_call_in_progress           "Call in progress"
+
+// d: Error message after recognition.
+// d: Shown if some other error than "No match found" occurred during recognition
+// l: popup_note_window/opt2
+// r: 3.1
+//
+#define text_voice_system_error         "Voice system error"	
+
+// d: Information message that's played using Text to speech synthesizer.
+// d: %U is the name of the contact being called.
+// d: For example "Dialling Adam" or "Dialling John Smith"
+// l: none
+// r: 3.2
+//
+#define qan_vc_tts_dialling             "Dialling %U"
+
+// d: Title for VoiceUi tutorial page 1.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page1_title     "Voice commanding"
+
+// d: Text for VoiceUi tutorial page 1.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page1_text_up   "This tutorial shows how voice commanding is used. You can safely practice different voice commands, no actions are carried out in this demo.\nVoice commanding can be activated by a long press of the Voice key or the Right soft key, depending on the device configuration. Right soft key starts voice commands only in idle view. A compatible accessory button can also be used. Next, you will hear a voice dial audio prompt that indicates the start of voice commanding."
+
+// d: Text for VoiceUi tutorial page 1.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page1_text_down   ""
+
+// d: Title for VoiceUi tutorial page 2.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page2_title     "Voice commanding"
+
+// d: Text for VoiceUi tutorial page 2.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page2_text_up   "You may speak immediately after the prompt playback has finished. You have five seconds time to say the name or the command.\nPractical hints: Say the command as naturally as possible. A short pause between the audio prompt and your speech improves the recognition accuracy. Speak with firm voice, do not whisper or shout."
+
+// d: Text for VoiceUi tutorial page 2.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page2_text_down   ""
+
+// d: Title for VoiceUi tutorial page 3.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page3_title     "Extended commands"
+
+// d: Text for VoiceUi tutorial page 3.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page3_text_up   "You can dial any contact in your phonebook by voice. Just say the name as it is written in phonebook, including the given and family name, in the order that is natural in your UI language. If you have specified a nick name for the contact, you can also say that name.\nIn addition to plain name, you can say the contact name followed by extension word such as mobile, home or message. More information of all the contact extension commands can be found in phonebook or in the phone manual."
+
+// d: Text for VoiceUi tutorial page 3.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page3_text_down   ""
+
+// d: Title for VoiceUi tutorial page 4.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page4_title     "Launching applications"
+
+// d: Text for VoiceUi tutorial page 4.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page4_text_up   "You can also activate applications and profiles by voice. To see the active applications go to Voice Commands application.\nIn Voice Commands application you may adjust voice UI settings, listen to the voice commands and edit the voice commands for specific applications."
+
+// d: Text for VoiceUi tutorial page 4.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page4_text_down   ""
+
+// d: Title for VoiceUi tutorial page 5.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page5_title     "Activate voice commanding"
+
+// d: Text for VoiceUi tutorial page 5.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page5_text_up   "Now, pressing \"Activate\" will start voice dialing. No commands are executed in this Tutorial, so you can for example try how to voice dial phonebook contacts.\nThe voice dial audio prompt is played again and you may speak after it has finished."
+
+// d: Text for VoiceUi tutorial page 5.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page5_text_down   ""
+
+// d: Title for VoiceUi tutorial page 6.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page_results_title "Recognition results"
+
+// d: Text for VoiceUi tutorial page 6.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page6_text_up   "The recognition is complete and the phone will show you the list of results. If the first item in the list is correct, you do not need to do anything. With default settings phone will automatically execute the command or place a call.\nIf the result is wrong, you may browse result list down and change the command or name to the correct one. If your command is not in the list, please re-try or check the command in question from voice commands application or from the phonebook. Notice that selecting the correct result is important since the recognition system will adjust its parameters to match your voice. Selecting wrong result will not improve the recognition accuracy."
+
+// d: Text for VoiceUi tutorial page 6.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page6_text_down   ""
+
+// d: Title for VoiceUi tutorial page 7.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page7_title     "Command execution"
+
+// d: Text for VoiceUi tutorial page 7.
+// d:
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page7_text      "You have selected a result and it is now executed. For more information on the voice dialing functionality, please see Voice Commands application help or the phone manual."
+
+// d: Title for VoiceUi tutorial error page.
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_tutorial_page_error_title "Error or no voice command given"
+
+// d: Text for VoiceUi tutorial error page.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page_error_text_up "This view can result in two cases. Either, you did not say anything or you said something that did not match to the voice recognition system.\nPlease re-try or verify that the command exists. Also, if you said something valid, you may adjust the sensitivity of the speech recognizer in Voice Commands->Settings->Sensitivity."
+
+// d: Text for VoiceUi tutorial error page.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_page_error_text_down ""
+
+// d: Text for VoiceUi tutorial first time page.
+// d: Upper text part
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_first_time1_text_up "To dial, say the full name of any phonebook contact. Alternatively, say the name of an application or profile to activate it.\nYou can say full name or nickname to dial. See Voice Commands for list of all other commands. Press "Activate" and give command. After activating once, this info does not appear again."
+
+// d: Text for VoiceUi tutorial first time page.
+// d: Optional lower text part if all of the text won't fit to upper part
+// d: Should be used at least with following languages:
+// d: Russian, Thai, Bulgarian, Farsi, Greek, Hindi, Ukrainian
+// l: none
+// r: 3.2
+//
+#define qtn_vc_tutorial_first_time1_text_down ""
+
+// d: Command text associated to a softkey in the control pane.
+// d: Changes current view to next view.
+// l: control_pane_t1
+// r: 3.2
+//
+#define qtn_vc_softkey_next     "Next"
+
+// d: Command text associated to a softkey in the control pane.
+// d: Activates voice dialing.
+// l: control_pane_t1
+// r: 3.2
+//
+#define qtn_vc_softkey_activate         "Activate"
+
+// d: Heading for n-best list
+// d:
+// l: heading_pane_t1
+// r: 3.2
+//
+#define qtn_vc_nbest_list_header        "Recognition results"
+
+// d: Command in options menu.
+// d: Selects currently active item.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_options_select           "Select"
+
+// d: Command in options menu.
+// d: Opens next view with more phone numbers from selected contact.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_nbest_options_more       "More numbers"
+
+// d: Command in options menu.
+// d: Opens phonebook view with information of selected contact.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_nbest_options_open_contact "Open contact"
+
+// d: Command in options menu.
+// d: Quits VoiceUi.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_nbest_options_quit       "Quit"
+
+// d: Prompt played with Text to speech synthesizer.
+// d: %U is the name of the recognized contact.
+// d: For example "John Smith, select, other, cancel"
+// d: Select, Other and Cancel are commands that user can select.
+// d: Last character may not be any unspoken character like ? or , or .
+// l: none
+// r: 3.2
+//
+#define qan_vc_verification_query       "%U, select, other, cancel"
+
+// d: Command name shown in list query dialog.
+// d: Activates currently selected item.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_verification_select      "Select"
+
+// d: Spoken command that user can say.
+// d: Text must match to "Select" in qan_vc_verification_query 
+// l: none
+// r: 3.2
+//
+#define qan_vc_verification_select      "Select"
+
+// d: Command name shown in list query dialog.
+// d: Moves selection to next item.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_verification_other       "Other"
+
+// d: Spoken command that user can say.
+// d: Text must match to "Other" in qan_vc_verification_query 
+// l: none
+// r: 3.2
+//
+#define qan_vc_verification_other       "Other"
+
+// d: Command name shown in list query dialog.
+// d: Cancels Voice Dialing.
+// l: list_single_pane_t1_cp2
+// r: 3.2
+//
+#define qtn_vc_verification_cancel      "Cancel"
+
+// d: Spoken command that user can say.
+// d: Text must match to "Cancel" in qan_vc_verification_query 
+// l: none
+// r: 3.2
+//
+#define qan_vc_verification_cancel      "Cancel"
+
+// d: Title pane text for VoiceUi application
+// l: title_pane_t1
+// r: 5.0
+//
+#define qtn_sivc_title                  "Speech recognizer"
+
+// d: VoiceUi application name in Application shell grid layout
+// l: cell_app_pane_t1
+// r: 5.0
+//
+#define qtn_sivc_appl_grid              "Speech recognizer"
+
+// d: VoiceUi application name in Application shell list layout
+// l: list_single_large_graphic_pane_t1_cp2
+// r: 5.0
+//
+#define qtn_sivc_appl_list              "Speech recognizer"
+
+// d: String for Phone settings / Standby mode settings list
+// l: list_set_graphic_pane_t1
+// r: 5.0
+//
+#define qtn_sivc_shortcut_list          "Speech recognizer"
+
+// d: RSK/LSK string for idle shortcut
+// l: control_pane_t1/opt3
+// r: 5.0
+//
+#define qtn_sivc_idle_sk                "Speech recognizer"
+
+// d: MSK string for idle shortcut
+// l: control_pane_t3/opt3
+// r: 5.0
+//
+#define qtn_sivc_idle_msk               "Speech recognizer"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicabortstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+
+#include "vuicstate.h"
+#include "vuicabortstate.h"
+#include "vuicexitstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuictoneplayer.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CAbortState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAbortState* CAbortState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CAbortState* self = new (ELeave) CAbortState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CAbortState::~CAbortState()
+    {
+    RUBY_DEBUG0( "CAbortState::~CAbortState START" );
+    
+    RUBY_DEBUG0( "CAbortState::~CAbortState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CAbortState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CAbortState::HandleEventL( TInt /*aEvent*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CAbortState::HandleEventL" );
+
+    CState* nextState = CExitState::NewL( DataStorage(), UiModel() );
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CAbortState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CAbortState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CAbortState::ExecuteL" );
+
+    DataStorage().TonePlayer()->PlayTone( EAvkonSIDNameDiallerAbortTone );
+    }
+
+// ---------------------------------------------------------
+// CAbortState::CAbortState
+// ---------------------------------------------------------
+//              
+CAbortState::CAbortState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel )
+    {
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicadaptstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <nssvasmadaptationitem.h>
+
+#include "vuicstate.h"
+#include "vuicadaptstate.h"
+#include "vuicexecutestate.h"
+#include "vuicabortstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CAdaptState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CAdaptState* CAdaptState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CAdaptState* self = new (ELeave) CAdaptState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CAdaptState::~CAdaptState()
+    {
+    RUBY_DEBUG0( "CAdaptState::~CAdaptState START" );
+    
+    delete iAdaptationItem;
+        
+    RUBY_DEBUG0( "CAdaptState::~CAdaptState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CAdaptState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CAdaptState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CAdaptState::HandleEventL" );
+
+    CState* nextState = NULL;
+    
+    switch( aEvent )
+        {
+        case EShortKeypress:
+        case ELongKeypress:
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+            
+            nextState = CExecuteState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CAdaptState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CAdaptState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CAdaptState::ExecuteL" );
+    
+    if ( DataStorage().AdaptationEnabled() )
+        {
+        iAdaptationItem = DataStorage().RecognitionHandler()->GetAdaptationItemL();
+
+        iAdaptationItem->AdaptL( DataStorage().VoiceRecognitionImpl(),
+                                 *DataStorage().Tag() );
+        }
+    else
+        {
+        HandleEventL( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------
+// CAdaptState::CAdaptState
+// ---------------------------------------------------------
+//              
+CAdaptState::CAdaptState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel )
+    {
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicapp.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The Voice Recognition application
+*
+*/
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+
+#include "vuicapp.h"
+#include "vuicdocument.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CApp::AppDllUid() const
+    {
+    return KUidVoiceUi;
+    }
+
+   
+// ---------------------------------------------------------
+// CApp::CreateDocumentL()
+// Creates CVCDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CApp::CreateDocumentL()
+    {
+    return CDocument::NewL( *this );
+    }
+
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CApp;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicappui.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,204 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The Voice Recognition Application Ui
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <e32property.h>
+#include <ScreensaverInternalPSKeys.h>
+#include <coreapplicationuisdomainpskeys.h>
+
+#include <vuivoicerecogdefs.h>
+
+#include "vuicappui.h"
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "vuiccalldetector.h"
+#include "vuickeygrabber.h"
+#include "vuicfoldobserver.h"
+#include "vuicnotificationobserver.h"
+
+#include "rubydebug.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------------------------
+// CAppUi::ConstructL()
+// ----------------------------------------------------------------------------
+//
+void CAppUi::ConstructL()
+    {
+    SetFullScreenApp( EFalse );
+
+    BaseConstructL( EAknEnableSkin | EAknEnableMSK );
+    
+    // Sets up TLS, must be done before FeatureManager is used.
+    FeatureManager::InitializeLibL();
+    
+    RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 1 );
+    RProperty::Set( KPSUidScreenSaver, KScreenSaverNoPowerSaveMode, 1 );
+    RProperty::Set( KPSUidCoreApplicationUIs, KLightsControl, ELightsOn );
+    
+    iNotificationObserver = CNotificationObserver::NewL();
+    
+    iCallDetector = CCallDetector::NewL( this );
+    iCallDetector->RequestNotification();
+    
+    iKeyGrabber = CKeyGrabber::NewL( this );
+    
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+	    {
+        iFoldObserver = CFoldObserver::NewL( this );
+        }
+    
+    SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | CAknAppUiBase::EDisableSendKeyLong );
+    
+    iEikonEnv->SetAutoForwarding( ETrue );
+    
+    iRecognitionDialog = CVoiceRecognitionDialogImpl::NewL( this );
+    
+    iRecognitionDialog->ExecuteL();
+    }
+
+// ----------------------------------------------------------------------------
+// CAppUi::~CAppUi()
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CAppUi::~CAppUi() 
+    {
+    RProperty::Set( KPSUidScreenSaver, KScreenSaverNoPowerSaveMode, 0 );
+    RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 0 );
+
+    FeatureManager::UnInitializeLib();
+    
+    delete iRecognitionDialog;
+    
+    delete iNotificationObserver;
+    
+    delete iKeyGrabber;
+    delete iFoldObserver;
+    
+    if ( iCallDetector )
+        {
+        iCallDetector->Cancel();
+        delete iCallDetector;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CAppUi::DialogDismissed
+// ----------------------------------------------------------------------------
+//
+void CAppUi::DialogDismissed()
+    {
+    RUBY_DEBUG0( "CAppUi::DialogDismissed START" );
+    
+    TRAPD( error, HandleCommandL( EAknSoftkeyExit ) );
+    if ( error != KErrNone )
+        {
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CAppUi::DialogDismissed EXIT" );
+    }
+
+// ----------------------------------------------------------------------------
+// CAppUi::DialogDismissedL
+// ----------------------------------------------------------------------------
+//    
+void CAppUi::CallDetectedL()
+    {
+    RUBY_DEBUG_BLOCK( "CAppUi::CallDetectedL" );
+    
+    HandleCommandL( EAknSoftkeyExit );
+    }
+
+// ----------------------------------------------------------------------------
+// CAppUi::HandleKeypressL
+// ----------------------------------------------------------------------------
+//     
+void CAppUi::HandleKeypressL( TInt /*aSoftkey*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CAppUi::HandleKeypressL" );
+    
+    HandleCommandL( EAknSoftkeyExit );
+    }
+
+// ----------------------------------------------------------------------------
+// CAppUi::HandleCommandL
+// ----------------------------------------------------------------------------
+//
+void CAppUi::HandleCommandL( TInt aCommand )
+    {
+    RUBY_DEBUG_BLOCK( "CAppUi::HandleCommandL" );
+    
+    switch ( aCommand )
+        {
+        // Both exit commands should do the same thing
+        case EEikCmdExit:
+        case EAknSoftkeyExit:
+            {
+            Exit();
+            break;
+            }
+            
+        default:
+            {
+            CAknAppUi::HandleCommandL( aCommand );
+            break;              
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAppUi::ProcessCommandParametersL
+// -----------------------------------------------------------------------------
+//         
+TBool CAppUi::ProcessCommandParametersL( CApaCommandLine& aCommandLine )
+    {
+    RUBY_DEBUG_BLOCK( "CAppUi::ProcessCommandParametersL" );
+
+    TPtrC8 argumentPtr( aCommandLine.TailEnd() );
+    
+    if ( argumentPtr.Length() && !argumentPtr.Compare( KVoiceUiMode ) )
+        {
+        iEikonEnv->SetAutoForwarding( EFalse );
+        iRecognitionDialog->SetOnlyCallsAllowed();
+        }
+
+    return ETrue;
+    }
+    
+// ----------------------------------------------------------------------------
+// CAppUi::PrepareToExit
+// ----------------------------------------------------------------------------
+//
+void CAppUi::PrepareToExit( )
+    {
+    RUBY_DEBUG0( "CAppUi::PrepareToExit START" );
+
+    delete iRecognitionDialog;
+    iRecognitionDialog = NULL;
+    
+    CAknAppUi::PrepareToExit();
+    	 
+	RUBY_DEBUG0( "CAppUi::PrepareToExit Exit" );
+    } 
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuiccalldetector.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <ctsydomainpskeys.h>
+
+#include "vuiccalldetector.h"
+#include "vuimcalldetectorobserver.h"
+
+#include "rubydebug.h"
+
+// ---------------------------------------------------------------------------
+// CCallDetector::NewL
+//
+// ---------------------------------------------------------------------------
+//
+CCallDetector* CCallDetector::NewL( MCallDetectorObserver* aObserver )
+    {
+    RUBY_DEBUG_BLOCK( "CCallDetector::NewL" );
+    
+    CCallDetector* self = new( ELeave ) CCallDetector( aObserver );        
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );    
+    return self;
+    }
+    
+// ---------------------------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------------------------
+//
+CCallDetector::~CCallDetector()
+    {
+    RUBY_DEBUG0( "CCallDetector::~CCallDetector" );
+    
+    Cancel();
+    iTsyProperty.Close();
+    }
+    
+// ---------------------------------------------------------------------------
+// CCallDetector::RequestNotification
+// 
+// ---------------------------------------------------------------------------
+// 
+void CCallDetector::RequestNotification()
+    {
+    RUBY_DEBUG0( "CCallDetector::RequestNotification" );
+    
+    iTsyProperty.Subscribe( iStatus );
+    SetActive();
+    }
+    
+// ---------------------------------------------------------------------------
+// Constructor
+//
+// ---------------------------------------------------------------------------
+//
+CCallDetector::CCallDetector( MCallDetectorObserver* aObserver )
+ : CActive( EPriorityStandard ), iObserver( aObserver )
+    {
+    }
+   
+// ---------------------------------------------------------------------------
+// CCallDetector::ConstructL
+//
+// ---------------------------------------------------------------------------
+//
+void CCallDetector::ConstructL()
+    {
+    User::LeaveIfError( iTsyProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState ) );
+    CActiveScheduler::Add( this );
+    }
+    
+// ---------------------------------------------------------------------------
+// CCallDetector::RunL
+// Called when the voice line status changes.
+// ---------------------------------------------------------------------------
+//
+void CCallDetector::RunL()
+    {
+    TInt status = iStatus.Int();
+    
+    RequestNotification();
+    
+    if ( status == KErrNone )
+        {
+        TInt status;
+        iTsyProperty.Get( status );
+        
+        if ( status != EPSCTsyCallStateNone )
+            {
+            iObserver->CallDetectedL();
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CCallDetector::DoCancel
+//
+// ---------------------------------------------------------------------------
+//
+void CCallDetector::DoCancel()
+    {
+    RUBY_DEBUG0( "CCallDetector::DoCancel" );
+
+    iTsyProperty.Cancel();
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuiccontactresultsstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,638 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <CPbkViewState.h>
+#include <PbkUID.h>
+#include <StringLoader.h>
+
+#include <vasmbasepbkhandler.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicstate.h"
+#include "vuiccontactresultsstate.h"
+#include "vuicplaystate.h"
+#include "vuicabortstate.h"
+#include "vuicerrorstate.h"
+#include "vuicexitstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuicnbestlistdialog.h"
+#include "vuicttsplayer.h"
+#include "vuivoiceicondefs.h"
+
+#include "rubydebug.h"
+
+// Constants
+_LIT( KTab, "\t" );
+_LIT( KStringPosition, "%U" );
+    
+// -----------------------------------------------------------------------------
+// CContactResultsState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CContactResultsState* CContactResultsState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CContactResultsState* self = new (ELeave) CContactResultsState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CContactResultsState::~CContactResultsState()
+    {
+    RUBY_DEBUG0( "CContactResultsState::~CContactResultsState START" );
+    
+    DataStorage().TtsPlayer()->Stop();
+    
+    delete iNBestListDialog;
+    
+    delete iTagList; // Only copies of pointers, do not reset and destroy
+    
+    DataStorage().SetAdditionalTagList( NULL ); // Reset for next time
+    
+    delete iNssVasDbManager;
+    iNssTagManager = NULL;
+    
+    RUBY_DEBUG0( "CContactResultsState::~CContactResultsState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CContactResultsState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CContactResultsState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == ENotStarted )
+                {
+                nextState = this;
+                }
+            else if ( iInternalState == EStarted )
+                {
+                iInternalState = EInitialized;
+                nextState = this;
+                }
+            else if ( iInternalState == EInitialized )
+                {
+                iInternalState = ECompleted;
+                nextState = this;
+                }
+            break;
+            
+        case EVoiceTagSoftKeySelect:
+        
+            nextState = CPlayState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        case EAknSoftkeyQuit:
+        case EAknSoftkeyNo:
+        case EVoiceTagSoftKeyQuit:
+        case EEndCallKeypress:
+        case ELongKeypress:
+        
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case EShortKeypress:
+        case EUpKeypress:
+        case EDownKeypress:
+        case ESelectKeypress:
+        case EDirectSelectKeypress:
+        case EDragKeypress:
+        case EScrollKeypress:
+        
+            iKeypress = aEvent;
+            nextState = this;
+            break;
+            
+        default:
+            
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CContactResultsState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::ExecuteL" );
+
+    if ( HandleKeypressL() )
+        {
+        iKeypress = ENoKeypress;
+        }
+    else if ( iInternalState == EInitialized )
+        {
+        // If automatic confirmation or device lock is on then start the timer
+        if ( DataStorage().VerificationMode() == EAutomatic ||
+             DataStorage().DeviceLockMode() )
+            {
+            TInt timeoutValue = DataStorage().PlayDuration().Int64();
+            if ( timeoutValue < KTimeoutMicroseconds )
+                {
+                timeoutValue = KTimeoutMicroseconds;
+                }
+        
+            StartTimerL( *this, timeoutValue, timeoutValue );
+            }
+        }
+    else if ( iInternalState == ECompleted )
+        {
+        DataStorage().TtsPlayer()->Stop();
+        }
+    else
+        {
+        if ( !DataStorage().AdditionalTagList() )
+            {
+            if ( iNssTagManager->GetTagList( DataStorage().VoiceRecognitionImpl(),
+                                             DataStorage().Tag()->Context(),
+                                             DataStorage().Tag()->RRD()->IntArray()->At( KVasContactIdRrdLocation ),
+                                             KVasContactIdRrdLocation ) != KErrNone )
+                {
+                HandleEventL( KErrGeneral );
+                }
+            }
+        else
+            {
+            iInternalState = EStarted;
+            
+            TInt returnValue = KErrNoResults;
+
+            // Get the name for the n-best list title
+            HBufC* name = DataStorage().Tag()->SpeechItem()->PartialTextL( KNameTrainingIndex );
+            CleanupStack::PushL( name );
+            
+            CreateContactInfoArrayL();
+            
+            if ( iTagList->Count() != KErrNone )
+                {
+                iNBestListDialog = CNBestListDialog::NewL();
+                iNBestListDialog->CreateNBestListPopupLC( CreateItemsArrayL(), *name );
+    
+                PlaySelectedNameL();
+                BringToForeground();
+    
+                iNBestListDialog->RegisterForKeyCallback( DataStorage().VoiceRecognitionImpl() );            
+                returnValue = iNBestListDialog->ShowNBestListPopupL(); // Pops things pushed in CreateNBestListPopupLC
+                }
+            CleanupStack::PopAndDestroy( name );
+            
+            if ( returnValue != KErrNone )
+                {
+                iInternalState = ECompleted;
+                
+                SelectTag();
+                
+                HandleEventL( returnValue );
+                }
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::CContactResultsState
+// ---------------------------------------------------------
+//              
+CContactResultsState::CContactResultsState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iKeypress( ENoKeypress ),
+   iInternalState( ENotStarted )
+    {
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::ConstructL
+// ---------------------------------------------------------
+//           
+void CContactResultsState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::ConstructL" );
+    
+    CState::ConstructL();
+    
+    iNssVasDbManager = CNssVASDBMgr::NewL();
+    iNssVasDbManager->InitializeL();
+    iNssTagManager = iNssVasDbManager->GetTagMgr();
+   
+    DataStorage().SetVerificationMode();
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::DoTimedEventL
+// ---------------------------------------------------------
+//
+void CContactResultsState::DoTimedEventL()
+   {   
+   SelectTag();
+   
+   HandleEventL( EVoiceTagSoftKeySelect );
+   }
+
+// ---------------------------------------------------------
+// CContactResultsState::HandleKeypressL
+// ---------------------------------------------------------
+//           
+TBool CContactResultsState::HandleKeypressL()
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::HandleKeypressL" );
+    
+    TBool handled = ETrue;
+    
+    if ( iKeypress == EShortKeypress )
+        {       
+        if ( iNBestListDialog->HandleShortKeypressL( NULL ) )
+            {
+            iInternalState = EStarted;
+            
+            PlaySelectedNameL();
+            }
+        else
+            {
+            HandleEventL( KErrNoResults );
+            }
+        }
+    else if ( iKeypress == EUpKeypress || iKeypress == EDownKeypress ||
+              iKeypress == EDragKeypress )
+        {
+        iInternalState = EStarted;
+        
+        PlaySelectedNameL();
+        }
+    else if ( iKeypress == EScrollKeypress )
+        {
+        StopTimer();
+        }
+    else if ( iKeypress == ESelectKeypress || iKeypress == EDirectSelectKeypress )
+        {        
+        if ( !DataStorage().Tag() )
+            {
+            SelectTag();
+    
+            HandleEventL( EVoiceTagSoftKeySelect );
+            }
+        }
+    else
+        {
+        handled = EFalse;
+        }
+    
+    return handled;
+    }
+    
+// ---------------------------------------------------------------------------
+// CContactResultsState::PlaySelectedNameL
+// ---------------------------------------------------------------------------
+//
+void CContactResultsState::PlaySelectedNameL()
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::PlaySelectedNameL" );
+
+    // if TTS is used
+    if ( ( DataStorage().SynthesizerMode() != KErrNone ||
+         DataStorage().DeviceLockMode() ) &&
+         iTagList->Count() > 0 )
+        {
+        TInt index = iNBestListDialog->SelectedIndex();        
+        MNssTag* tag = iTagList->At( index );
+            
+        if ( tag->Context()->ContextName() == KVoiceDialContext &&
+             tag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial )
+            {
+            HBufC* ttsText = StringLoader::LoadLC( R_QAN_VC_TTS_DIALLING );
+            
+            TInt position = ttsText->FindC( KStringPosition );
+            User::LeaveIfError( position );            
+            
+            CleanupStack::PopAndDestroy( ttsText );
+            
+            ttsText = StringLoader::LoadLC( R_QAN_VC_TTS_DIALLING,
+                                            tag->SpeechItem()->Text() );
+                                                   
+            HBufC* text = tag->SpeechItem()->PartialTextL( KNameTrainingIndex );        
+            CleanupStack::PushL( text ); 
+            
+            DataStorage().TtsPlayer()->PlayL( *ttsText, position,
+                                              tag->SpeechItem()->Text().Length() , *text );
+            
+            CleanupStack::PopAndDestroy( text );
+            CleanupStack::PopAndDestroy( ttsText );
+            }
+        else if ( tag->Context()->ContextName() == KVoiceDialContext )
+            {           
+            HBufC* text = tag->SpeechItem()->PartialTextL( KNameTrainingIndex );        
+            CleanupStack::PushL( text ); 
+        
+            DataStorage().TtsPlayer()->PlayL( tag->SpeechItem()->Text(), 0,
+                                              tag->SpeechItem()->Text().Length(), *text );
+
+            CleanupStack::PopAndDestroy( text );
+            }
+        }
+    else
+        {
+        DataStorage().SetPlayDuration( KTimeoutMicroseconds );
+        HandleEventL( KErrNone );
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CContactResultsState::CreateContactInfoArrayL
+// ---------------------------------------------------------------------------
+//
+void CContactResultsState::CreateContactInfoArrayL()
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::CreateContactInfoArrayL" );
+    
+    CArrayPtrFlat<MNssTag>* completeTagList = DataStorage().CompleteTagList();
+    CArrayPtrFlat<MNssTag>* additionalTags = DataStorage().AdditionalTagList();
+    
+    iTagList = new ( ELeave ) CArrayPtrFlat<MNssTag>( KSindMaxResults );
+    
+    iTagList->AppendL( DataStorage().Tag() );
+    
+    // Add all commands from selected contact to taglist
+    for ( TInt i = 0; i < completeTagList->Count(); ++i )
+        {
+        MNssTag* tag = completeTagList->At( i );
+        
+        if ( tag->Context()->ContextName() == KVoiceDialContext &&
+             ( !DataStorage().DeviceLockMode() || tag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) &&
+             tag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) ==
+             DataStorage().Tag()->RRD()->IntArray()->At( KVasContactIdRrdLocation ) &&
+             CompareContactNamesL( tag ) )
+            {
+            // Add tag to list
+            iTagList->AppendL( tag );
+            }
+        }
+    
+    // Add all additional commands from selected contact to taglist if not added already    
+    for ( TInt i = 0; i < additionalTags->Count(); ++i )
+        {
+        MNssTag* tag = additionalTags->At( i );
+        
+        if ( !CheckIfAlreadyAdded( tag ) && CompareContactNamesL( tag ) &&
+             ( !DataStorage().DeviceLockMode() || tag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) )
+            {
+            // Add tag to list
+            iTagList->AppendL( tag );
+            }
+        }
+        
+    // Add selected tag back to tag list
+    completeTagList->AppendL( DataStorage().Tag() );
+    
+    // Clear selected tag    
+    DataStorage().SetTag( NULL, EFalse );
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::CompareContactNamesL
+// ---------------------------------------------------------
+//     
+TBool CContactResultsState::CompareContactNamesL( MNssTag* aTag )
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::CompareContactNamesL" );
+    
+    TBool returnValue = EFalse;
+    
+    HBufC* firstName = DataStorage().Tag()->SpeechItem()->PartialTextL( KNameTrainingIndex );
+    CleanupStack::PushL( firstName );
+    
+    HBufC* secondName = aTag->SpeechItem()->PartialTextL( KNameTrainingIndex );
+    CleanupStack::PushL( secondName );
+    
+    returnValue = ( *firstName == *secondName );
+        
+    CleanupStack::PopAndDestroy( secondName );
+    CleanupStack::PopAndDestroy( firstName );
+    
+    return returnValue;
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::CheckIfAlreadyAdded
+// ---------------------------------------------------------
+//    
+TBool CContactResultsState::CheckIfAlreadyAdded( MNssTag* aTag )
+    {
+    RUBY_DEBUG0( "CContactResultsState::CheckIfAlreadyAdded START" );
+    
+    TBool returnValue = EFalse;
+
+    for ( TInt i = 0; i < iTagList->Count(); ++i )
+        {
+        if ( aTag->SpeechItem()->RawText() ==
+             iTagList->At( i )->SpeechItem()->RawText() ||
+             aTag->SpeechItem()->RawText() ==
+             DataStorage().Tag()->SpeechItem()->RawText() )
+            {
+            returnValue = ETrue;
+            
+            break;
+            }
+        }
+    
+    RUBY_DEBUG0( "CContactResultsState::CheckIfAlreadyAdded EXIT" );
+    
+    return returnValue;
+    }
+    
+// ---------------------------------------------------------------------------
+// CContactResultsState::CreateItemsArrayLC
+// ---------------------------------------------------------------------------
+//    
+CDesC16ArrayFlat* CContactResultsState::CreateItemsArrayL()
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::CreateItemsArrayL" );
+        
+    TInt count = iTagList->Count();
+           
+    CDesC16ArrayFlat* items = new ( ELeave ) CDesC16ArrayFlat( KSindMaxResults );
+    CleanupStack::PushL( items );
+
+    TFullName buffer;
+    
+    for ( TInt i = 0; i < count; ++i )
+        {
+        MNssTag* tag = iTagList->At( i );        
+        
+        FillDialContextBufferL( tag, buffer );
+            
+        items->AppendL( buffer );
+        }
+        
+    CleanupStack::Pop( items );
+    
+    return items;
+    }
+
+// ---------------------------------------------------------
+// CContactResultsState::FillDialContextBufferL
+// ---------------------------------------------------------
+//
+void CContactResultsState::FillDialContextBufferL( MNssTag* aTag, TDes& aBuffer )
+    {
+    RUBY_DEBUG_BLOCK( "CContactResultsState::FillDialContextBufferL" );
+    
+    TPtrC type = KNullDesC();
+    
+    DataStorage().PbkHandler()->FindContactFieldL( aTag );
+                           
+    TBufC<KMaxFieldLength> phoneNumber = DataStorage().PbkHandler()->TextL();
+    type.Set( GetContactIconType( DataStorage().PbkHandler()->FieldTypeL() ) );
+
+    aBuffer.Zero();
+    aBuffer.Append( type );
+    aBuffer.Append( KTab );
+    
+    HBufC* label = NULL;
+        
+    TRAPD( error, label = aTag->SpeechItem()->PartialTextL( KExtensionTrainingIndex ) );
+    if ( error == KErrNone || error == KErrNotFound )
+        {
+        // If there is no extension then the phonebook label is shown
+        if ( label )
+            {
+            CleanupStack::PushL( label );
+    
+            aBuffer.Append( *label );
+    
+            CleanupStack::PopAndDestroy( label );
+            }
+        else
+            {
+            aBuffer.Append( DataStorage().PbkHandler()->LabelL() );
+            }
+        }
+    else
+        {
+        User::Leave( error );
+        }
+        
+    aBuffer.Append( KTab );
+    aBuffer.Append( phoneNumber );
+    }
+    
+// ---------------------------------------------------------
+// CContactResultsState::GetContactIconType
+// ---------------------------------------------------------
+//
+TPtrC CContactResultsState::GetContactIconType( TFieldType aFieldType )
+    {
+    RUBY_DEBUG0( "CContactResultsState::GetContactIconType START" );
+    
+    TPtrC type;
+    // select a phone type
+    if ( aFieldType == KUidContactFieldVCardMapVOICE )
+        {
+        type.Set( KIconPhone );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapCELL )
+        {
+        type.Set( KIconMobile );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapFAX )
+        {
+        type.Set( KIconFax );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapEMAILINTERNET )
+        {
+        type.Set( KIconEmail );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapVIDEO )
+        {
+        type.Set( KIconVideo );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapVOIP )
+        {
+        type.Set( KIconVoip );
+        }
+    else
+        {
+        type.Set( KIconBlank );
+        }
+
+    RUBY_DEBUG0( "CContactResultsState::GetContactIconType EXIT" );
+    
+    return type;
+    }
+    
+// ---------------------------------------------------------
+// CContactResultsState::SelectTag
+// ---------------------------------------------------------
+//   
+void CContactResultsState::SelectTag()
+    {
+    RUBY_DEBUG0( "CContactResultsState::SelectTag START" );
+    
+    if ( iTagList->Count() > 0 )
+        {
+        DataStorage().SetTag( iTagList->At( iNBestListDialog->SelectedIndex() ), ETrue );
+            
+        // Remove selected item from the complete taglist
+        for ( TInt i = 0; i < DataStorage().CompleteTagList()->Count(); ++i )
+            {
+            if ( DataStorage().CompleteTagList()->At( i ) ==
+                 DataStorage().Tag() )
+                {
+                DataStorage().CompleteTagList()->Delete( i );
+                break;
+                }
+            }
+            
+        // Remove selected item from the additional taglist
+        for ( TInt i = 0; i < DataStorage().AdditionalTagList()->Count(); ++i )
+            {
+            if ( DataStorage().AdditionalTagList()->At( i ) ==
+                 DataStorage().Tag() )
+                {
+                // Disable adaptation since tag is not from recognition results
+                DataStorage().SetAdaptationEnabled( EFalse );
+                
+                DataStorage().AdditionalTagList()->Delete( i );
+                break;
+                }
+            }
+        }
+        
+    RUBY_DEBUG0( "CContactResultsState::SelectTag EXIT" );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuiccontextcheckstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,237 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <centralrepository.h>
+
+#include <srsfdomaincrkeys.h>
+
+#include "vuicstate.h"
+#include "vuiccontextcheckstate.h"
+#include "vuicverificationtrainingstate.h"
+#include "vuictutorialstate.h"
+#include "vuicexitstate.h"
+#include "vuicerrorstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "rubydebug.h"
+
+static const TInt KUndefinedLanguage = -1;
+    
+// -----------------------------------------------------------------------------
+// CContextCheckState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CContextCheckState* CContextCheckState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CContextCheckState* self = new (ELeave) CContextCheckState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CContextCheckState::~CContextCheckState()
+    {
+    RUBY_DEBUG0( "CContextCheckState::~CContextCheckState START" );
+    
+    delete iVasDbManager;
+    iContextManager = NULL;
+    iTagManager = NULL;
+    
+    RUBY_DEBUG0( "CContextCheckState::~CContextCheckState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CContextCheckState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CContextCheckState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CContextCheckState::HandleEventL" );
+
+    CState* nextState = NULL;
+    
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+                iInternalState = ECommandsReady;
+                nextState = this;
+                }
+            else if ( iInternalState == ECommandsReady )
+                {
+                iInternalState = EDialReady;
+                nextState = this;
+                }
+            else if ( iInternalState == EDialReady )
+                {
+                iInternalState = EVerificationReady;
+                nextState = this;
+                }
+            else
+                {
+                nextState = CTutorialState::NewL( DataStorage(), UiModel() );
+                }
+            break;
+            
+        case KErrNoVerificationTrained:
+        
+            nextState = CVerificationTrainingState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        case KErrNotReady:
+        
+            nextState = CExitState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        default:
+            
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CContextCheckState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CContextCheckState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CContextCheckState::ExecuteL" );
+
+    if ( iInternalState == ENotStarted )
+        {
+        iInternalState = EStarted;
+        
+        // Get voice command context
+        if ( iContextManager->GetContext( DataStorage().VoiceRecognitionImpl(),
+                                          KVoiceCommandContext ) != KErrNone )
+            {
+            HandleEventL( KErrNotReady );
+            }
+        }
+    else if ( iInternalState == ECommandsReady )
+        {
+        // Get voice command context tag count
+        iTagCount += iTagManager->TagCount( DataStorage().Context() );
+        
+        // Get voice dial context
+        if ( iContextManager->GetContext( DataStorage().VoiceRecognitionImpl(),
+                                          KVoiceDialContext ) != KErrNone )
+            {
+            HandleEventL( KErrNotReady );
+            }
+        }
+    else if ( iInternalState == EDialReady )
+        {
+        // Get voice dial context tag count
+        iTagCount += iTagManager->TagCount( DataStorage().Context() );
+        
+        // Check if any tags were found
+        if ( !iTagCount )
+            {
+            HandleEventL( KErrNoContacts );
+            }
+            
+        // Get voice verification context
+        if ( iContextManager->GetContext( DataStorage().VoiceRecognitionImpl(),
+                                          KVoiceVerificationContext ) != KErrNone )
+            {
+            HandleEventL( KErrNoVerificationTrained );
+            }
+        }
+    else if ( iInternalState == EVerificationReady )
+        {
+        // Get voice verification context tag count
+        iTagCount = iTagManager->TagCount( DataStorage().Context() );
+        
+        // Check if any tags were found or has UI language changed
+        if ( !iTagCount || LanguageChangedL() )
+            {
+            HandleEventL( KErrNoVerificationTrained );
+            }
+        else
+            {
+            HandleEventL( KErrNone );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CContextCheckState::CContextCheckState
+// ---------------------------------------------------------
+//              
+CContextCheckState::CContextCheckState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted ),
+   iTagCount( 0 )
+    {
+    }
+
+// ---------------------------------------------------------
+// CContextCheckState::ConstructL
+// ---------------------------------------------------------
+//           
+void CContextCheckState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CContextCheckState::ConstructL" );
+    
+    CState::ConstructL();
+    
+    iVasDbManager = CNssVASDBMgr::NewL();
+    iVasDbManager->InitializeL();
+    iTagManager = iVasDbManager->GetTagMgr();
+    iContextManager = iVasDbManager->GetContextMgr();   
+    }
+    
+// ---------------------------------------------------------
+// CContextCheckState::LanguageChangedL
+// ---------------------------------------------------------
+//           
+TBool CContextCheckState::LanguageChangedL()
+    {
+    RUBY_DEBUG_BLOCK( "CContextCheckState::LanguageChangedL" );
+    
+    TBool changed = EFalse;
+    TInt language = KUndefinedLanguage;
+    
+    CRepository* client = CRepository::NewLC( KCRUidSRSFSettings );
+    client->Get( KSRSFVoiceUiLanguage, language );
+    
+    if ( language != User::Language() )
+        {
+        client->Set( KSRSFVoiceUiLanguage, KUndefinedLanguage );
+        changed = ETrue;
+        }
+        
+    CleanupStack::PopAndDestroy( client );
+    
+    return changed;
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicdatastorage.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,566 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <centralrepository.h>
+#include <vcommanddomaincrkeys.h>
+#include <voiceuidomainpskeys.h>
+
+#include <vascvpbkhandler.h>
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuictoneplayer.h"
+#include "vuicpropertyhandler.h"
+#include "vuictutorial.h"
+#include "vuicttsplayer.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDataStorage* CDataStorage::NewL( CVoiceRecognitionDialogImpl* aVoiceRecognitionImpl )
+    {
+    RUBY_DEBUG_BLOCK( "CDataStorage::NewL" );
+    
+    CDataStorage* self = new (ELeave) CDataStorage( aVoiceRecognitionImpl );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }    
+    
+// Destructor       
+CDataStorage::~CDataStorage()
+    {
+    RUBY_DEBUG0( "CDataStorage::~CDataStorage START" );
+    
+    if ( iTonePlayer )
+        {
+        iTonePlayer->RegisterObserver( NULL );
+        }
+    delete iTonePlayer;
+    
+    delete iPbkHandler;
+    
+    delete iTtsPlayer;
+    
+    delete iRecognitionHandlerBuilder;             // Deletes also iRecognitionHandler
+    delete iVerificationRecognitionHandlerBuilder; // Deletes also iVerificationRecognitionHandler
+    delete iAccessoryButtonMonitor;
+    delete iTutorial;
+    
+    // Contains original tags
+    if ( iAdditionalTagList )
+        {
+        iAdditionalTagList->ResetAndDestroy();
+        }
+    delete iAdditionalTagList;
+    
+    // Contains original tags
+    if ( iCompleteTagList )
+        {
+        iCompleteTagList->ResetAndDestroy();
+        }
+    delete iCompleteTagList;
+    
+    delete iTag;
+    delete iContext;
+    
+    RUBY_DEBUG0( "CDataStorage::~CDataStorage EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetRecognitionHandlerBuilder
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetRecognitionHandlerBuilder( CNssRecognitionHandlerBuilder* aRecognitionHandlerBuilder )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetRecognitionHandlerBuilder START" );
+    
+    if ( iRecognitionHandlerBuilder && iRecognitionHandlerBuilder != aRecognitionHandlerBuilder )
+        {
+        delete iRecognitionHandlerBuilder; // Deletes also iRecognitionHandler
+        iRecognitionHandler = NULL;
+        }
+    
+    iRecognitionHandlerBuilder = aRecognitionHandlerBuilder;
+    
+    RUBY_DEBUG0( "CDataStorage::SetRecognitionHandlerBuilder EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::SetRecognitionHandler
+// -----------------------------------------------------------------------------
+//        
+void CDataStorage::SetRecognitionHandler( MNssRecognitionHandler* aRecognitionHandler )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetRecognitionHandler START" );
+        
+    iRecognitionHandler = aRecognitionHandler;
+    
+    RUBY_DEBUG0( "CDataStorage::SetRecognitionHandler EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetVerificationRecognitionHandlerBuilder
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetVerificationRecognitionHandlerBuilder( CNssRecognitionHandlerBuilder* aRecognitionHandlerBuilder )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandlerBuilder START" );
+    
+    if ( iVerificationRecognitionHandlerBuilder && iVerificationRecognitionHandlerBuilder != aRecognitionHandlerBuilder )
+        {
+        delete iVerificationRecognitionHandlerBuilder; // Deletes also iRecognitionHandler
+        iVerificationRecognitionHandler = NULL;
+        }
+    
+    iVerificationRecognitionHandlerBuilder = aRecognitionHandlerBuilder;
+    
+    RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandlerBuilder EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::SetVerificationRecognitionHandler
+// -----------------------------------------------------------------------------
+//        
+void CDataStorage::SetVerificationRecognitionHandler( MNssRecognitionHandler* aRecognitionHandler )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandler START" );
+        
+    iVerificationRecognitionHandler = aRecognitionHandler;
+    
+    RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandler EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetAdditionalTagList
+// -----------------------------------------------------------------------------
+//    
+void CDataStorage::SetAdditionalTagList( CArrayPtrFlat<MNssTag>* aAdditionalTagList )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetAdditionalTagList START" );
+    
+    if ( iAdditionalTagList && iAdditionalTagList != aAdditionalTagList )
+        {
+        iAdditionalTagList->ResetAndDestroy();
+        delete iAdditionalTagList;
+        }
+    
+    iAdditionalTagList = aAdditionalTagList;
+    
+    RUBY_DEBUG0( "CDataStorage::SetAdditionalTagList EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetCompleteTagList
+// -----------------------------------------------------------------------------
+//    
+void CDataStorage::SetCompleteTagList( CArrayPtrFlat<MNssTag>* aCompleteTagList )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetCompleteTagList START" );
+    
+    if ( iCompleteTagList && iCompleteTagList != aCompleteTagList )
+        {
+        iCompleteTagList->ResetAndDestroy();
+        delete iCompleteTagList;
+        }
+    
+    iCompleteTagList = aCompleteTagList;
+    
+    RUBY_DEBUG0( "CDataStorage::SetCompleteTagList EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetTag
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetTag( MNssTag* aTag, TBool aDestroyIfExists )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetTag START" );
+    
+    if ( iTag && aDestroyIfExists && iTag != aTag )
+        {
+        delete iTag;
+        }
+    
+    iTag = aTag;
+    
+    RUBY_DEBUG0( "CDataStorage::SetTag EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetContext
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetContext( MNssContext* aContext )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetContext START" );
+    
+    if ( iContext && iContext != aContext )
+        {
+        delete iContext;
+        }
+    
+    iContext = aContext;
+    
+    RUBY_DEBUG0( "CDataStorage::SetContext EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::SetAdaptationEnabled
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetAdaptationEnabled( const TBool aAdaptationEnabled )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetAdaptationEnabled START" );
+    
+    iAdaptationEnabled = aAdaptationEnabled;
+    
+    RUBY_DEBUG0( "CDataStorage::SetAdaptationEnabled EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::SetPlayDuration
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetPlayDuration( const TTimeIntervalMicroSeconds& aPlayDuration )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetPlayDuration START" );
+    
+    iPlayDuration = aPlayDuration;
+    
+    RUBY_DEBUG0( "CDataStorage::SetPlayDuration EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetVerificationMode
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetVerificationMode( const TInt aMode )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetVerificationMode START" );
+    
+    if ( aMode == KResetMode )
+        {
+        TRAP_IGNORE( 
+            CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+            client->Get( KVCVerification, iVerificationMode );
+            CleanupStack::PopAndDestroy( client ) );
+        }
+    else
+        {
+        iVerificationMode = aMode;
+        }
+    
+    RUBY_DEBUG0( "CDataStorage::SetVerificationMode EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::SetVerificationTryCount
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetVerificationTryCount( const TInt aCount )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetVerificationTryCount START" );
+    
+    iVerificationTryCount = aCount;
+    
+    RUBY_DEBUG0( "CDataStorage::SetVerificationTryCount EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::SetDeviceLockMode
+// -----------------------------------------------------------------------------
+//
+void CDataStorage::SetDeviceLockMode( const TBool aDeviceLockMode )
+    {
+    RUBY_DEBUG0( "CDataStorage::SetDeviceLockMode START" );
+    
+    iDeviceLockMode = aDeviceLockMode;
+    
+    RUBY_DEBUG0( "CDataStorage::SetDeviceLockMode EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::VoiceRecognitionImpl
+// -----------------------------------------------------------------------------
+//
+CVoiceRecognitionDialogImpl* CDataStorage::VoiceRecognitionImpl() const
+    {
+    RUBY_DEBUG0( "CDataStorage::VoiceRecognitionImpl" );
+    
+    return iVoiceRecognitionImpl;
+    }
+      
+// -----------------------------------------------------------------------------
+// CDataStorage::RecognitionHandlerBuilder
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandlerBuilder* CDataStorage::RecognitionHandlerBuilder() const
+    {
+    RUBY_DEBUG0( "CDataStorage::RecognitionHandlerBuilder" );
+    
+    return iRecognitionHandlerBuilder;
+    }
+       
+// -----------------------------------------------------------------------------
+// CDataStorage::RecognitionHandler
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler* CDataStorage::RecognitionHandler() const
+    {
+    RUBY_DEBUG0( "CDataStorage::RecognitionHandler" );
+    
+    return iRecognitionHandler;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::VerificationRecognitionHandlerBuilder
+// -----------------------------------------------------------------------------
+//
+CNssRecognitionHandlerBuilder* CDataStorage::VerificationRecognitionHandlerBuilder() const
+    {
+    RUBY_DEBUG0( "CDataStorage::VerificationRecognitionHandlerBuilder" );
+    
+    return iVerificationRecognitionHandlerBuilder;
+    }
+       
+// -----------------------------------------------------------------------------
+// CDataStorage::VerificationRecognitionHandler
+// -----------------------------------------------------------------------------
+//
+MNssRecognitionHandler* CDataStorage::VerificationRecognitionHandler() const
+    {
+    RUBY_DEBUG0( "CDataStorage::VerificationRecognitionHandler" );
+    
+    return iVerificationRecognitionHandler;
+    }
+      
+// -----------------------------------------------------------------------------
+// CDataStorage::TonePlayer
+// -----------------------------------------------------------------------------
+//
+CTonePlayer* CDataStorage::TonePlayer() const
+    {
+    RUBY_DEBUG0( "CDataStorage::TonePlayer" );
+    
+    return iTonePlayer;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::TtsPlayer
+// -----------------------------------------------------------------------------
+//
+CTTSPlayer* CDataStorage::TtsPlayer() const
+    {
+    RUBY_DEBUG0( "CDataStorage::TtsPlayer" );
+    
+    return iTtsPlayer;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::PbkHandler
+// -----------------------------------------------------------------------------
+//
+MVasBasePbkHandler* CDataStorage::PbkHandler() const
+    {
+    RUBY_DEBUG0( "CDataStorage::PbkHandler" );
+    
+    return iPbkHandler;
+    }
+      
+// -----------------------------------------------------------------------------
+// CDataStorage::AccessoryButtonMonitor
+// -----------------------------------------------------------------------------
+//
+CPropertyHandler* CDataStorage::AccessoryButtonMonitor() const
+    {
+    RUBY_DEBUG0( "CDataStorage::AccessoryButtonMonitor" );
+    
+    return iAccessoryButtonMonitor;
+    }
+        
+// -----------------------------------------------------------------------------
+// CDataStorage::Tutorial
+// -----------------------------------------------------------------------------
+//
+CTutorial* CDataStorage::Tutorial() const
+    {
+    RUBY_DEBUG0( "CDataStorage::Tutorial" );
+    
+    return iTutorial;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::AdditionalTagList
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<MNssTag>* CDataStorage::AdditionalTagList() const
+    {
+    RUBY_DEBUG0( "CDataStorage::AdditionalTagList" );
+    
+    return iAdditionalTagList;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::CompleteTagList
+// -----------------------------------------------------------------------------
+//
+CArrayPtrFlat<MNssTag>* CDataStorage::CompleteTagList() const
+    {
+    RUBY_DEBUG0( "CDataStorage::CompleteTagList" );
+    
+    return iCompleteTagList;
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::Tag
+// -----------------------------------------------------------------------------
+//
+MNssTag* CDataStorage::Tag() const
+    {
+    RUBY_DEBUG0( "CDataStorage::Tag" );
+    
+    return iTag;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::Context
+// -----------------------------------------------------------------------------
+//
+MNssContext* CDataStorage::Context() const
+    {
+    RUBY_DEBUG0( "CDataStorage::Context" );
+    
+    return iContext;
+    }
+        
+// -----------------------------------------------------------------------------
+// CDataStorage::SynthesizerMode
+// -----------------------------------------------------------------------------
+//
+TInt CDataStorage::SynthesizerMode() const
+    {
+    RUBY_DEBUG0( "CDataStorage::SynthesizerMode" );
+    
+    return iSynthesizerMode;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::AdaptationEnabled
+// -----------------------------------------------------------------------------
+//
+TBool CDataStorage::AdaptationEnabled() const
+    {
+    RUBY_DEBUG0( "CDataStorage::AdaptationEnabled" );
+    
+    return iAdaptationEnabled;
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::PlayDuration
+// -----------------------------------------------------------------------------
+//    
+TTimeIntervalMicroSeconds CDataStorage::PlayDuration() const
+    {
+    RUBY_DEBUG0( "CDataStorage::PlayDuration" );
+    
+    return iPlayDuration;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::VerificationMode
+// -----------------------------------------------------------------------------
+//    
+TInt CDataStorage::VerificationMode() const
+    {
+    RUBY_DEBUG0( "CDataStorage::VerificationMode" );
+    
+    return iVerificationMode;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDataStorage::VerificationTryCount
+// -----------------------------------------------------------------------------
+//    
+TInt CDataStorage::VerificationTryCount() const
+    {
+    RUBY_DEBUG0( "CDataStorage::VerificationTryCount" );
+    
+    return iVerificationTryCount;
+    }
+
+// -----------------------------------------------------------------------------
+// CDataStorage::DeviceLockMode
+// -----------------------------------------------------------------------------
+//    
+TBool CDataStorage::DeviceLockMode() const
+    {
+    RUBY_DEBUG0( "CDataStorage::DeviceLockMode" );
+    
+    return iDeviceLockMode;
+    }
+    
+// ---------------------------------------------------------
+// CDataStorage::CDataStorage
+// ---------------------------------------------------------
+//              
+CDataStorage::CDataStorage( CVoiceRecognitionDialogImpl* aVoiceRecognitionImpl )
+ : iVoiceRecognitionImpl( aVoiceRecognitionImpl ), iDeviceLockMode( EFalse )
+    {
+    }
+
+// ---------------------------------------------------------
+// CDataStorage::ConstructL
+// ---------------------------------------------------------
+//           
+void CDataStorage::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CDataStorage::ConstructL" );
+
+    iTonePlayer = CTonePlayer::NewL();
+    iTonePlayer->RegisterObserver( iVoiceRecognitionImpl );
+    
+    iPbkHandler = CVasVPbkHandler::NewL();
+    
+    iTtsPlayer = CTTSPlayer::NewL( iVoiceRecognitionImpl );
+
+    iAccessoryButtonMonitor = CPropertyHandler::NewL( KPSUidVoiceUiAccMonitor,
+                                                      KVoiceUiOpenKey,
+                                                      KPSUidVoiceUiAccMonitor,
+                                                      KVoiceUiAccessoryEvent );
+        
+    iTutorial = CTutorial::NewL();
+
+    TRAP_IGNORE( 
+        CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+        client->Get( KVCSynthesizer, iSynthesizerMode );
+        client->Get( KVCVerification, iVerificationMode );
+        CleanupStack::PopAndDestroy( client ) );
+
+    iVerificationTryCount = KVerificationTries;
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicdocument.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The Voice Recognition application document
+*
+*/
+
+
+// INCLUDE FILES
+#include "vuicdocument.h"
+#include "vuicappui.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// Constructor
+CDocument::CDocument( CEikApplication& aApp )
+ : CAknDocument( aApp )    
+    {
+    }
+
+// Destructor
+CDocument::~CDocument()
+    {
+    }
+
+// Default constructor can leave.
+void CDocument::ConstructL()
+    {
+    }
+
+// Two-phased constructor.
+CDocument* CDocument::NewL( CEikApplication& aApp )
+    {
+    CDocument* self = new (ELeave) CDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CDocument::CreateAppUiL()
+// Constructs CAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CDocument::CreateAppUiL()
+    {
+    return new (ELeave) CAppUi;
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicerrorstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,273 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <StringLoader.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicstate.h"
+#include "vuicerrorstate.h"
+#include "vuictutorialstate.h"
+#include "vuicexitstate.h"
+
+#include "vuicdatastorage.h"
+#include "vuicuimodel.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuictoneplayer.h"
+#include "vuicttsplayer.h"
+#include "vuicglobalnote.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CErrorState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CErrorState* CErrorState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel, TInt aError )
+    {
+    CErrorState* self = new (ELeave) CErrorState( aDataStorage, aUiModel, aError );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CErrorState::~CErrorState()
+    {
+    RUBY_DEBUG0( "CErrorState::~CErrorState START" );
+    
+    DataStorage().TtsPlayer()->Stop();
+    
+    RUBY_DEBUG0( "CErrorState::~CErrorState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CErrorState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CErrorState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CErrorState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+            
+            if ( iInternalState == EStarted )
+                {
+                iInternalState = EInitialized;
+                nextState = this;
+                }
+            break;
+        
+        case KErrNoMatch:
+        
+            nextState = CTutorialState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        default:
+        
+            nextState = CExitState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CErrorState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CErrorState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CErrorState::ExecuteL" );
+    
+    if ( iInternalState == ENotStarted )
+        {
+        if ( !DataStorage().DeviceLockMode() )
+            {
+            UiModel().Note().DisplayGlobalNoteL( NoteType() );
+            }
+        
+        iInternalState = EStarted;
+        
+        TInt toneType = ToneType();
+    
+        if ( toneType == EVoiceNoMatchFound )
+            {
+            HBufC* ttsText = StringLoader::LoadLC( R_TEXT_VOICE_NO_MATCHES );
+
+            DataStorage().TtsPlayer()->PlayL( *ttsText );
+            
+            CleanupStack::PopAndDestroy( ttsText );
+            }
+        else if ( toneType != KErrNone )
+            {
+            DataStorage().SetPlayDuration( 0 );
+            DataStorage().TonePlayer()->PlayTone( toneType );
+            }
+        else
+            {
+            DataStorage().SetPlayDuration( 0 );
+            HandleEventL( toneType );
+            }
+        }
+    else if ( iInternalState == EInitialized )
+        {
+        TInt timeoutValue = DataStorage().PlayDuration().Int64();
+        if ( timeoutValue < KErrorMessageTimeoutMicroseconds )
+            {
+            timeoutValue = KErrorMessageTimeoutMicroseconds;
+            }
+        
+        StartTimerL( *this, timeoutValue, timeoutValue );
+        iInternalState = EReady;
+        }    
+    }
+
+// ---------------------------------------------------------
+// CErrorState::CErrorState
+// ---------------------------------------------------------
+//              
+CErrorState::CErrorState( CDataStorage& aDataStorage, CUiModel& aUiModel, TInt aError )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted ), iError( aError )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CErrorState::DoTimedEventL
+// ---------------------------------------------------------
+//      
+void CErrorState::DoTimedEventL()
+    {
+    RUBY_DEBUG_BLOCK( "CErrorState::DoTimedEventL" );
+    
+    // Dismiss error message dialog
+    UiModel().Note().DismissGlobalNoteL();
+    
+    DataStorage().Tutorial()->ErrorState();
+    
+    HandleEventL( iError );
+    }
+    
+// ---------------------------------------------------------
+// CErrorState::NoteType
+// ---------------------------------------------------------
+//      
+CGlobalNote::TGlobalNoteState CErrorState::NoteType()
+    {
+    RUBY_DEBUG0( "CErrorState::NoteType START" );
+    
+    CGlobalNote::TGlobalNoteState type;
+    
+    switch( iError )
+        {
+        case KErrNoMatch:
+        case KErrNoResults:
+            {
+            type = CGlobalNote::ENoMatchPermanent;
+            break;
+            }
+        case KErrCallInProgress:
+            {
+            type = CGlobalNote::ECallInProgress;
+            break;
+            }
+        case KErrNoContacts:
+            {
+            type = CGlobalNote::ENoTag;
+            break;
+            }
+        case KErrInit:
+            {
+            type = CGlobalNote::ESystemError;
+            break;
+            }
+        case KErrNoMemory:
+            {
+            type = CGlobalNote::ENoMemory;
+            break;
+            }
+        default:
+            {
+            type = CGlobalNote::ENotRecognizedPermanent;
+            break;
+            }
+        }
+        
+    RUBY_DEBUG0( "CErrorState::NoteType EXIT" );
+    
+    return type;
+    }
+    
+// ---------------------------------------------------------
+// CErrorState::ToneType
+// ---------------------------------------------------------
+//      
+TInt CErrorState::ToneType()
+    {
+    RUBY_DEBUG0( "CErrorState::ToneType START" );
+    
+    TInt type;
+    
+    switch( iError )
+        {
+        case KErrNoMatch:
+        case KErrNoResults:
+            {
+            // if TTS is used
+            if ( DataStorage().SynthesizerMode() != KErrNone ||
+                 DataStorage().DeviceLockMode() )
+                {
+                type = EVoiceNoMatchFound;
+                }
+            else
+                {
+                type = EAvkonSIDNameDiallerAbortTone;
+                }
+            break;
+            }
+        case KErrCallInProgress:
+            {
+            // No tone should be played
+            type = KErrNone;
+            break;
+            }
+        default:
+            {
+            type = EAvkonSIDNameDiallerErrorTone;
+            break;
+            }
+        }  
+    
+    RUBY_DEBUG0( "CErrorState::ToneType EXIT" );
+    
+    return type;
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicexecutestate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "vuicstate.h"
+#include "vuicexecutestate.h"
+#include "vuicexitstate.h"
+#include "vuicabortstate.h"
+
+#include "vuicdatastorage.h"
+#include "vuicuimodel.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuicglobalnote.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CExecuteState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CExecuteState* CExecuteState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CExecuteState* self = new (ELeave) CExecuteState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CExecuteState::~CExecuteState()
+    {
+    RUBY_DEBUG0( "CExecuteState::~CExecuteState START" );
+    
+    RUBY_DEBUG0( "CExecuteState::~CExecuteState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CExecuteState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CExecuteState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CExecuteState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case EShortKeypress:
+        case ELongKeypress:
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+        
+            nextState = CExitState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CExecuteState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CExecuteState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CExecuteState::ExecuteL" );
+            
+    // Activate the selected voice tag
+    MNssRecognitionHandler::TNssRecognitionResult result =
+        DataStorage().RecognitionHandler()->SelectTagL( DataStorage().Tag() );
+
+    if ( result != MNssRecognitionHandler::EVasErrorNone )
+        {
+        if ( !DataStorage().DeviceLockMode() )
+            {
+            UiModel().Note().DisplayGlobalNoteL( CGlobalNote::ESystemError );
+            }
+        }
+
+    HandleEventL( KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CExecuteState::CExecuteState
+// ---------------------------------------------------------
+//              
+CExecuteState::CExecuteState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel )
+    {
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicexitstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "vuicstate.h"
+#include "vuicexitstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CExitState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CExitState* CExitState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CExitState* self = new (ELeave) CExitState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CExitState::~CExitState()
+    {
+    RUBY_DEBUG0( "CExitState::~CExitState START" );
+        
+    RUBY_DEBUG0( "CExitState::~CExitState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CExitState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CExitState::HandleEventL( TInt /*aEvent*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CExitState::HandleEventL" );
+    }
+
+// ---------------------------------------------------------
+// CExitState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CExitState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CExitState::ExecuteL" );
+
+    DataStorage().VoiceRecognitionImpl()->Exit();
+    }
+
+// ---------------------------------------------------------
+// CExitState::CExitState
+// ---------------------------------------------------------
+//              
+CExitState::CExitState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel )
+    {
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicfoldobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <hwrmdomainpskeys.h>
+
+#include "vuimvoicerecogdialogcallback.h"
+
+#include "vuicfoldobserver.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CFoldObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CFoldObserver* CFoldObserver::NewL( MVoiceRecognitionDialogCallback* aCallback )
+    {
+    CFoldObserver* self = new (ELeave) CFoldObserver( aCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    } 
+
+// Destructor       
+CFoldObserver::~CFoldObserver()
+    {
+    RUBY_DEBUG0( "CFoldObserver::~CFoldObserver START" );
+    
+    Cancel();
+    iFoldEvent.Close();
+    
+    RUBY_DEBUG0( "CFoldObserver::~CFoldObserver EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CFoldObserver::DoCancel
+// ---------------------------------------------------------
+// 
+void CFoldObserver::DoCancel()
+    {
+    RUBY_DEBUG0( "CFoldObserver::DoCancel START" );
+    
+    iFoldEvent.Cancel();
+    
+    RUBY_DEBUG0( "CFoldObserver::DoCancel EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CFoldObserver::RunL
+// ---------------------------------------------------------
+//     
+void CFoldObserver::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CFoldObserver::RunL" );
+    
+    TInt status = iStatus.Int();
+    
+    iFoldEvent.Subscribe( iStatus );
+    SetActive();
+    
+    if ( status == KErrNone )
+        {
+        TInt newFoldStatus;
+        iFoldEvent.Get( newFoldStatus );
+        
+        if ( newFoldStatus == EPSHWRMFlipClosed && newFoldStatus != iFoldStatus )
+            {
+            iCallback->DialogDismissed();
+            }
+        iFoldStatus = newFoldStatus;
+        }
+    }
+
+// ---------------------------------------------------------
+// CFoldObserver::CFoldObserver
+// ---------------------------------------------------------
+//              
+CFoldObserver::CFoldObserver( MVoiceRecognitionDialogCallback* aCallback )
+ : CActive( EPriorityStandard ), iCallback( aCallback )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CFoldObserver::ConstructL
+// ---------------------------------------------------------
+//           
+void CFoldObserver::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CFoldObserver::ConstructL" );
+    
+    User::LeaveIfError( iFoldEvent.Attach( KPSUidHWRM, KHWRMFlipStatus ) );
+    CActiveScheduler::Add( this );
+    
+    iFoldEvent.Get( iFoldStatus );
+    
+    iFoldEvent.Subscribe( iStatus );
+    SetActive();
+    }    
+
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicglobalnote.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles tutorial mode resources and dialog showing
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <avkon.hrh>
+
+#include <aknSDData.h>
+
+#include <StringLoader.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicglobalnote.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CGlobalNote::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CGlobalNote* CGlobalNote::NewL()
+    {
+    CGlobalNote* self = new (ELeave) CGlobalNote();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// Destructor       
+CGlobalNote::~CGlobalNote()
+    {
+    RUBY_DEBUG0( "CGlobalNote::~CGlobalNote START" );
+    
+    TRAP_IGNORE( DismissGlobalNoteL() );
+    
+    delete iNote;
+    
+    RUBY_DEBUG0( "CGlobalNote::~CGlobalNote EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CGlobalNote::DisplayGlobalNoteL
+// -----------------------------------------------------------------------------
+//
+void CGlobalNote::DisplayGlobalNoteL( TGlobalNoteState aState )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalNote::DisplayGlobalNoteL" );
+    
+    switch( aState )
+        {
+        case ECallInProgress:
+            DisplayGlobalNoteL( EAknGlobalInformationNote, R_TEXT_CALL_IN_PROGRESS,
+                                SecondaryDisplay::ECmdShowCallInProgressNote );
+            break;
+            
+        case ESystemError:
+            DisplayGlobalNoteL( EAknGlobalErrorNote, R_TEXT_VOICE_SYSTEM_ERROR,
+                                SecondaryDisplay::ECmdShowVoiceSystemErrorNote );
+            break;
+
+        case ENoTag:
+            DisplayGlobalNoteL( EAknGlobalInformationNote, R_TEXT_VOICE_NO_TAG,
+                                SecondaryDisplay::ECmdShowVoiceNoTagNote );
+            break;
+
+        case ENoMatchPermanent:
+            DisplayGlobalNoteL( EAknGlobalPermanentNote, R_TEXT_VOICE_NO_MATCHES,
+                                SecondaryDisplay::ECmdShowVoiceNoMatchesNote,
+                                EMbmAvkonQgn_note_voice,
+                                EMbmAvkonQgn_note_voice_mask );
+            break;
+
+        case ENotRecognizedPermanent:
+            DisplayGlobalNoteL( EAknGlobalPermanentNote, R_TEXT_VOICE_SYSTEM_ERROR,
+                                SecondaryDisplay::ECmdShowVoiceNotRecognizedNote,
+                                EMbmAvkonQgn_note_error,
+                                EMbmAvkonQgn_note_error_mask );
+            break;
+            
+        case ENoMemory:
+            DisplayGlobalNoteL( EAknGlobalErrorNote, R_QTN_VC_MEMORY_LOW,
+                                SecondaryDisplay::ECmdVoiceNoNote );
+            break;
+        default:
+            RUBY_ERROR0( "CGlobalNote::DisplayGlobalNoteL - Invalid state" );
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CGlobalNote::DismissGlobalNoteL
+// -----------------------------------------------------------------------------
+//
+void CGlobalNote::DismissGlobalNoteL()
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalNote::DismissGlobalNoteL" );
+                
+    // Dismiss message dialog
+    iNote->CancelNoteL( iNoteId );
+    }
+
+// -----------------------------------------------------------------------------
+// CGlobalNote::CGlobalNote
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CGlobalNote::CGlobalNote()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CGlobalNote::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CGlobalNote::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalNote::ConstructL" );
+
+    iNote = CAknGlobalNote::NewL();
+    }
+    
+// ---------------------------------------------------------
+// CGlobalNote::DisplayGlobalNoteL
+// Displays a global note
+// ---------------------------------------------------------
+//
+void CGlobalNote::DisplayGlobalNoteL( TAknGlobalNoteType aNoteType,
+                                      TInt aMsgId,
+                                      SecondaryDisplay::TVUISecondaryDisplayDialogs aDialog,
+                                      TMifAvkon aIcon,
+                                      TMifAvkon aIconMask )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalNote::DisplayGlobalNoteL" );
+    
+    HBufC* noteText = StringLoader::LoadLC( aMsgId, CCoeEnv::Static() );    
+    DisplayGlobalNoteL( aNoteType, noteText, aDialog, aIcon, aIconMask );
+    CleanupStack::PopAndDestroy( noteText );
+    }
+
+
+// ---------------------------------------------------------
+// CGlobalNote::DisplayGlobalNoteL
+// Displays a global note
+// ---------------------------------------------------------
+//
+void CGlobalNote::DisplayGlobalNoteL( TAknGlobalNoteType aNoteType,
+                                      HBufC* aNoteText,
+                                      SecondaryDisplay::TVUISecondaryDisplayDialogs aDialog,
+                                      TMifAvkon aIcon,
+                                      TMifAvkon aIconMask )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalNote::DisplayGlobalNoteL" );
+
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+         aDialog != SecondaryDisplay::ECmdVoiceNoNote )
+        {
+        CAknSDData* sddata = CAknSDData::NewL( SecondaryDisplay::KCatVoiceUi,
+                                               aDialog,
+                                               KNullDesC8 );
+        iNote->SetSecondaryDisplayData( sddata );
+        }
+    
+    if ( aIcon && aIconMask )
+        {
+        iNote->SetGraphic( aIcon, aIconMask );
+        }
+    
+    iNote->SetTone( EAvkonSIDNoSound );
+    iNoteId = iNote->ShowNoteL( aNoteType, *aNoteText );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicglobalprogressdialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,414 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles the global progress dialog for voice recognition
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <data_caging_path_literals.hrh>
+
+#include <AknProgressDialog.h>
+#include <AknsItemID.h>
+#include <eikprogi.h>
+#include <eikbtgpc.h>
+#include <eikimage.h> 
+#include <AknsUtils.h> 
+
+#include <AknMediatorFacade.h>
+
+#include <SecondaryDisplay/AknSecondaryDisplayDefs.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicglobalprogressdialog.h"
+#include "vuimkeycallback.h"
+
+#include "vuivoiceicondefs.h"
+
+#include "rubydebug.h"
+
+_LIT( KNewLine, "\n" );
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CGlobalProgressDialog::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CGlobalProgressDialog* CGlobalProgressDialog::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::NewL" );
+    
+    CGlobalProgressDialog* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CGlobalProgressDialog::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CGlobalProgressDialog* CGlobalProgressDialog::NewLC()
+    { 
+    CGlobalProgressDialog* self = new ( ELeave ) CGlobalProgressDialog();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// Destructor
+CGlobalProgressDialog::~CGlobalProgressDialog()
+    {
+    RUBY_DEBUG0( "CGlobalProgressDialog::~CGlobalProgressDialog START" );
+   
+    RegisterForKeyCallback( NULL );
+    
+    if ( iInternalState == EStarted || iInternalState == ERunning )
+        {
+        if ( iProgressDialog )
+            {
+            iProgressDialog->MakeVisible( EFalse );
+            }        
+        delete iProgressDialog;
+        }
+    
+    RUBY_DEBUG0( "CGlobalProgressDialog::~CGlobalProgressDialog EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::RegisterForKeyCallback
+// Register for callback to receive notification when a softkey 
+// is pressed
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::RegisterForKeyCallback( MKeyCallback* aKeyCallback )
+    {
+    RUBY_DEBUG0( "CGlobalProgressDialog::RegisterForKeyCallback START" );
+    
+    if ( iInternalState != EFinished )
+        {
+        if ( aKeyCallback )
+            {
+            iProgressDialog->SetCallback( this );
+            }
+        else
+            {
+            iProgressDialog->SetCallback( NULL );
+            }
+        }
+    iKeyCallback = aKeyCallback;
+    
+    RUBY_DEBUG0( "CGlobalProgressDialog::RegisterForKeyCallback EXIT" );
+    }            
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::SetIconL
+// Set icon on the dialog
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::SetIconL( const TDesC& aIconFile,
+                                      TInt aIconId, TInt aIconMaskId )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::SetIconL" );
+    
+    // If icon should be left bland do not set it at all
+    if ( aIconId != EMbmAvkonQgn_stat_bt_blank )
+        {
+        CEikImage* image = new ( ELeave ) CEikImage();
+        CleanupStack::PushL( image );
+        
+        image->CreatePictureFromFileL( aIconFile, aIconId, aIconMaskId );
+   
+        iProgressDialog->SetIconL( image ); // ownership of the image is transferred to dialog
+        
+        CleanupStack::Pop( image );
+        }
+    }
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::SetImageL
+// Set image on the dialog
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::SetImageL( const TDesC& aImageFile, TInt aImageId,
+                                       TInt aImageMaskId )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::SetImageL" );
+    
+    CEikImage* image = new ( ELeave ) CEikImage();
+    CleanupStack::PushL( image );
+    
+    image->CreatePictureFromFileL( aImageFile, aImageId, aImageMaskId );
+      
+    iProgressDialog->SetImageL( image ); // ownership of the image is transferred to dialog
+    
+    CleanupStack::Pop( image );
+    }
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::SetSecondaryDisplayDataL
+// Sets additional information to be sent to secondary display
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::SetSecondaryDisplayDataL( TUid aCategory, TInt aDialogIndex,
+                                                      const SecondaryDisplay::TMatchData* aData )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::SetSecondaryDisplayDataL" );
+   
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+        {
+        iProgressDialog->PublishDialogL( aDialogIndex, aCategory );
+   
+        if ( aData )
+            {
+            // fetch akn utility for mediator support, \oem\aknmediatorfacade.h
+            CAknMediatorFacade* covercl = AknMediatorFacade( iProgressDialog );
+
+            if ( covercl )
+                {
+                covercl->BufStream() << aData->iType;
+                covercl->BufStream() << aData->iName;
+                covercl->BufStream() << aData->iNumber;
+                covercl->BufStream().CommitL(); // no more data to send so commit buf
+                }
+            }
+        }   
+   }
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::ShowProgressDialogL
+// Shows progress dialog
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::ShowProgressDialogL( const TDesC& aPrompt, const TDesC& aIconText, TInt aSoftkeys )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::ShowProgressDialogL" );
+    
+    iProgressDialog->PrepareLC( R_PROGRESSNOTE );
+   
+    HBufC* string = HBufC::NewLC( aPrompt.Length() + aIconText.Length() + KNewLine.iTypeLength );
+            
+    string->Des() = aPrompt;
+    string->Des() += KNewLine;
+    string->Des() += aIconText;
+   
+    iProgressDialog->SetTextL( *string );
+   
+    CleanupStack::PopAndDestroy( string );
+   
+    CEikButtonGroupContainer* cba = &iProgressDialog->ButtonGroupContainer();
+    cba->SetCommandSetL( aSoftkeys );
+
+    iProgressDialog->RunLD();
+
+    iInternalState = ERunning;
+    }
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::UpdateProgressDialogL
+// Updates the progress dialog
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::UpdateProgressDialogL( TInt aValue, TInt aFinalValue )
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::UpdateProgressDialogL" );
+    
+    if ( iProgressDialog )
+        {
+        CEikProgressInfo* progressInfo = iProgressDialog->GetProgressInfoL();
+        progressInfo->SetFinalValue( aFinalValue );   	
+        progressInfo->SetAndDraw( aValue );
+            
+        if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+            {
+            CAknMediatorFacade* coverData = AknMediatorFacade( iProgressDialog );
+            if( coverData )
+                {
+                coverData->ResetBuffer();
+                coverData->BufStream().WriteInt32L( EAknGlobalPDialogValuesUpdate );
+                coverData->BufStream().WriteInt32L( aValue );
+                coverData->BufStream().WriteInt32L( aFinalValue );
+                coverData->BufStream().CommitL();
+                coverData->PostUpdatedDataL();
+                }
+            }
+        }
+   	}
+
+// ---------------------------------------------------------
+// CGlobalProgressDialog::SetSkinIds
+// Set skin ids on the dialog
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::SetSkinIds( TAknsItemID aImageId, TInt aImageBitmapId,
+                                        TInt aImageMaskId, TAknsItemID aIconId )
+    {
+    RUBY_DEBUG0( "CGlobalProgressDialog::SetSkinIds START" );
+    
+    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+    CEikImage* image = NULL;
+    CFbsBitmap* bitmap = NULL;
+    CFbsBitmap* mask = NULL;
+    TBuf<KMaxFileName> fileName = AknIconUtils::AvkonIconFileName();
+    
+    if ( skin )
+        {
+        TRAP_IGNORE(
+            AknsUtils::CreateIconL( skin, aImageId, bitmap, mask, fileName,
+                                    aImageBitmapId, aImageMaskId );
+            CleanupStack::PushL( bitmap );
+            CleanupStack::PushL( mask );
+            
+            image = new ( ELeave ) CEikImage();
+            CleanupStack::PushL( image );
+            
+            image->SetBitmap( bitmap ); // ownership of the bitmap is transferred to image
+            image->SetMask( mask ); // ownership of the mask is transferred to image
+        
+            iProgressDialog->SetImageL( image ); // ownership of the image is transferred to dialog
+            
+            CleanupStack::Pop( image );
+            CleanupStack::Pop( mask );
+            CleanupStack::Pop( bitmap );
+            );
+
+        TInt iconId = 0;
+        for ( ; iconId < KSindNumberOfIcons; ++iconId )
+            {
+            if ( aIconId == *KIconId[ iconId ] )
+                {
+                break;
+                }
+            }
+            
+        if ( aIconId == *KIconId[ EIconProfile ] || aIconId == *KIconId[ EIconApplication ] )
+            {
+            TRAP_IGNORE(
+                TParse* fp = new ( ELeave ) TParse();
+                CleanupStack::PushL( fp );
+                User::LeaveIfError( fp->Set( KDirAndFile, &KDC_BITMAP_DIR, NULL ) );
+
+                fileName = fp->FullName();
+                CleanupStack::PopAndDestroy( fp );
+                );
+            }
+        
+        // Don't set blank icon
+        if ( aIconId != KAknsIIDQgnStatBtBlank )
+            {
+            ASSERT ( iconId < KSindNumberOfIcons );
+            TRAP_IGNORE(
+                AknsUtils::CreateIconL( skin, aIconId, bitmap, mask, fileName,
+                                        KBitmapId[ iconId ], KMaskId[ iconId ] );
+                CleanupStack::PushL( bitmap );
+                CleanupStack::PushL( mask );
+                
+                image = new ( ELeave ) CEikImage();
+                CleanupStack::PushL( image );
+                
+                image->SetBitmap( bitmap ); // ownership of the bitmap is transferred to image
+                image->SetMask( mask ); // ownership of the mask is transferred to image
+            
+                iProgressDialog->SetIconL( image ); // ownership of the image is transferred to dialog
+                
+                CleanupStack::Pop( image );
+                CleanupStack::Pop( mask );
+                CleanupStack::Pop( bitmap );
+                );
+            }
+        }
+    RUBY_DEBUG0( "CGlobalProgressDialog::SetSkinIds EXIT" );
+    }
+   
+// ---------------------------------------------------------
+// CGlobalProgressDialog::DialogDismissedL
+//
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::DialogDismissedL( TInt aButtonId )
+    {
+    RUBY_DEBUG0( "CGlobalProgressDialog::DialogDismissedL START" );
+        
+    // Enter key selection returns EAknSoftkeyOk
+    if ( aButtonId == EAknSoftkeyOk )
+        {
+        aButtonId = EVoiceTagSoftKeyOther;
+        }
+        
+    if ( iInternalState == ERunning && iKeyCallback )
+        {
+        iInternalState = EFinished;
+        iProgressDialog->SetCallback( NULL );
+        iKeyCallback->HandleKeypressL( aButtonId );
+        }
+    
+    RUBY_DEBUG0( "CGlobalProgressDialog::DialogDismissedL EXIT" );
+    }    
+
+// -----------------------------------------------------------------------------
+// CGlobalProgressDialog::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CGlobalProgressDialog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::ConstructL" );
+      
+    iProgressDialog = new ( ELeave ) CAknProgressDialog(
+        ( REINTERPRET_CAST( CEikDialog**, &iProgressDialog ) ), ETrue );
+        
+    iProgressDialog->SetGloballyCapturing( ETrue );
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CGlobalProgressDialog::CGlobalProgressDialog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CGlobalProgressDialog::CGlobalProgressDialog()
+ : iInternalState( EStarted )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CGlobalProgressDialog::ProcessFinished
+// Stops the progress dialog
+// ---------------------------------------------------------
+//
+void CGlobalProgressDialog::ProcessFinished()
+    {
+    RUBY_DEBUG0( "CGlobalProgressDialog::ProcessFinished START" );
+    
+    if ( iInternalState == ERunning )
+        {
+        iInternalState = EFinished;
+        iProgressDialog->SetCallback( NULL );
+        TRAP_IGNORE( iProgressDialog->ProcessFinishedL() );
+        }
+    
+    RUBY_DEBUG0( "CGlobalProgressDialog::ProcessFinished EXIT" );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicinitstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+
+#include <vasmbasepbkhandler.h>
+
+#include "vuicstate.h"
+#include "vuicinitstate.h"
+#include "vuicrecordstate.h"
+#include "vuicabortstate.h"
+#include "vuicerrorstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuictoneplayer.h"
+#include "vuicpropertyhandler.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+
+    
+// -----------------------------------------------------------------------------
+// CInitState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CInitState* CInitState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CInitState* self = new (ELeave) CInitState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CInitState::~CInitState()
+    {
+    RUBY_DEBUG0( "CInitState::~CInitState START" );
+    
+    if ( iInternalState != EReady )
+        {
+        DataStorage().RecognitionHandler()->Cancel();
+        }
+    
+    RUBY_DEBUG0( "CInitState::~CInitState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CInitState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CInitState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CInitState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+#ifndef __WINS__                  
+#ifdef __FULLDUPLEX_CHANGE
+                iInternalState = ESamplingStarted;
+                nextState = this;
+                }
+            else if ( iInternalState == ESamplingStarted )
+                {
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__  
+                iInternalState = EInitialized;
+                }
+            else if ( iInternalState == EInitialized )
+                {
+                iInternalState = EReady;
+                nextState = this;
+                }
+            else
+                {
+                nextState = CRecordState::NewL( DataStorage(), UiModel() );
+                }
+            break;
+        
+        case KErrInit:
+        case KErrNoContacts:
+        
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+            
+        case KErrNoMemory:
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+            
+        case ELongKeypress:
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+        
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CInitState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CInitState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CInitState::ExecuteL" );
+    
+    if ( iInternalState == ENotStarted )
+        {
+        // Initialize recognition system
+        InitializeL();
+        iInternalState = EStarted;
+
+#ifndef __WINS__          
+#ifdef __FULLDUPLEX_CHANGE
+        // Initialize sampling
+        StartSamplingL();
+        }
+    else if ( iInternalState == ESamplingStarted )
+        {
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__  
+        // Initialize phonebook handler
+        TRAPD( error, DataStorage().PbkHandler()->InitializeL() );
+        if ( error == KErrNoMemory )
+            {
+            HandleEventL ( KErrNoMemory );
+            }
+        else
+            {
+            if ( error != KErrAlreadyExists )
+                {
+                User::LeaveIfError( error );
+                }
+            
+            // Initialize start tone
+            DataStorage().TonePlayer()->InitToneL( EAvkonSIDNameDiallerStartTone );
+    
+            // Initialize recognition
+            RecognizeInitL();
+            }
+        }
+    else
+        {
+        // Play the starting tone
+        DataStorage().TonePlayer()->PlayTone( EAvkonSIDNameDiallerStartTone ); 
+        }
+    }
+
+// ---------------------------------------------------------
+// CInitState::CInitState
+// ---------------------------------------------------------
+//              
+CInitState::CInitState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CInitState::InitializeL
+// ---------------------------------------------------------
+//
+void CInitState::InitializeL()
+    {
+    RUBY_DEBUG_BLOCK( "CInitState::InitializeL" );
+
+    DataStorage().AccessoryButtonMonitor()->Register( DataStorage().VoiceRecognitionImpl() );
+
+    CNssRecognitionHandlerBuilder* builder = CNssRecognitionHandlerBuilder::NewL();
+    DataStorage().SetRecognitionHandlerBuilder( builder );    
+    builder->InitializeL();
+      
+    DataStorage().SetRecognitionHandler( builder->GetRecognitionHandler() );
+    }
+
+#ifndef __WINS__      
+#ifdef __FULLDUPLEX_CHANGE
+// ---------------------------------------------------------
+// CInitState::StartSamplingL
+// ---------------------------------------------------------
+//
+void CInitState::StartSamplingL()
+    {
+    RUBY_DEBUG_BLOCK( "CInitState::StartSamplingL" );
+    
+    MNssRecognitionHandler* handler = DataStorage().RecognitionHandler(); 
+    User::LeaveIfError(
+        handler->PreStartSampling( DataStorage().VoiceRecognitionImpl() ) );
+    }
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__  
+        
+// ---------------------------------------------------------
+// CInitState::RecognizeInitL
+// ---------------------------------------------------------
+//
+void CInitState::RecognizeInitL()
+    {
+    RUBY_DEBUG_BLOCK( "CInitState::RecognizeInitL" );
+    
+    TInt numResults = KSindMaxResults * 3;
+
+    if ( DataStorage().VerificationMode() == EVoice )
+        {
+        numResults = KVerificationResults;
+        }
+
+    MNssRecognitionHandler* handler = DataStorage().RecognitionHandler();
+    User::LeaveIfError(
+        handler->RecognizeInitL( DataStorage().VoiceRecognitionImpl(), numResults ) );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuickeygrabber.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <eikon.hrh>
+#include <apgwgnam.h>
+
+#include "vuickeygrabber.h"
+
+#include "vuimkeycallback.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CKeyGrabber::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CKeyGrabber* CKeyGrabber::NewL( MKeyCallback* aKeyObserver )
+    {
+    CKeyGrabber* self = new (ELeave) CKeyGrabber( aKeyObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }   
+    
+// ---------------------------------------------------------
+// CKeyGrabber::~CKeyGrabber
+// ---------------------------------------------------------
+//       
+CKeyGrabber::~CKeyGrabber()
+    {
+    Cancel();
+
+    iWindowGroup.Close();
+    
+    iWsSession.Close();
+    }
+
+// ---------------------------------------------------------
+// CKeyGrabber::DoCancel
+// ---------------------------------------------------------
+// 
+void CKeyGrabber::DoCancel()
+    {
+    RUBY_DEBUG0( "CKeyGrabber::DoCancel START" );
+    
+    iWsSession.EventReadyCancel();
+    
+    iWindowGroup.CancelCaptureKey( iCameraHandle );
+    iWindowGroup.CancelCaptureKey( iPocHandle );
+    iWindowGroup.CancelCaptureKey( iPowerHandle );
+    iWindowGroup.CancelCaptureKey( iApplicationHandle );
+    
+    RUBY_DEBUG0( "CKeyGrabber::DoCancel EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CKeyGrabber::RunL
+// ---------------------------------------------------------
+//     
+void CKeyGrabber::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CKeyGrabber::RunL" );
+    
+    if ( iStatus.Int() == KErrNone )
+        {
+        TWsEvent event;
+        iWsSession.GetEvent( event );
+        
+        iWsSession.EventReady( &iStatus );
+        SetActive();
+        
+        //fix for ESLI-7YSA3 we terminate Vcommand when received EKeyNull.
+        if ( event.Key()->iCode == EKeyNull )
+        	iKeyObserver->HandleKeypressL( event.Key()->iCode );
+        if ( event.Key()->iCode == EKeyCamera ||
+             event.Key()->iCode == EKeyPoC ||
+             event.Key()->iCode == EKeyPowerOff ||
+             event.Key()->iCode == EKeyApplication )
+            {
+            iWsSession.SendEventToOneWindowGroupsPerClient( event );
+
+            iKeyObserver->HandleKeypressL( event.Key()->iCode );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CKeyGrabber::CKeyGrabber
+// ---------------------------------------------------------
+//              
+CKeyGrabber::CKeyGrabber( MKeyCallback* aKeyObserver )
+ : CActive( EPriorityStandard ), iKeyObserver( aKeyObserver )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CKeyGrabber::ConstructL
+// ---------------------------------------------------------
+//           
+void CKeyGrabber::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CKeyGrabber::ConstructL" );
+
+    User::LeaveIfError( iWsSession.Connect() );
+
+    iWindowGroup = RWindowGroup ( iWsSession );
+    iWindowGroup.Construct( (TUint32) &iWindowGroup, EFalse );
+    
+    User::LeaveIfError( iCameraHandle = iWindowGroup.CaptureKey( EKeyCamera, 0, 0 ) );
+    User::LeaveIfError( iPocHandle = iWindowGroup.CaptureKey( EKeyPoC, 0, 0 ) );
+    User::LeaveIfError( iPowerHandle = iWindowGroup.CaptureKey( EKeyPowerOff, 0, 0 ) );
+    User::LeaveIfError( iApplicationHandle = iWindowGroup.CaptureKey( EKeyApplication, 0, 0 ) );
+    
+    iWindowGroup.SetOrdinalPosition( -1 );
+    iWindowGroup.EnableReceiptOfFocus( EFalse );
+    
+    CApaWindowGroupName* name = CApaWindowGroupName::NewLC( iWsSession );
+    name->SetHidden( ETrue );
+    name->SetWindowGroupName( iWindowGroup );
+    CleanupStack::PopAndDestroy( name );
+
+    iWsSession.EventReady( &iStatus );
+    
+    CActiveScheduler::Add( this );
+    SetActive();
+    }
+
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuiclistquerydialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,284 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+
+#include <vuivoicerecognition.rsg>
+#include <vuivoicerecogdefs.h>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuiclistquerydialog.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CListQueryDialog::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CListQueryDialog* CListQueryDialog::NewL( TInt *aIndex,
+                                          CListQueryDialog** aSelf,
+                                          MEikCommandObserver* aObserver,
+                                          TInt aMenuTitleResourceId )
+    {
+    CListQueryDialog* self = new (ELeave) CListQueryDialog( aObserver,
+                                                            aMenuTitleResourceId,
+                                                            aIndex, aSelf );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }   
+    
+// Destructor       
+CListQueryDialog::~CListQueryDialog()
+    {
+    RUBY_DEBUG0( "CListQueryDialog::~CListQueryDialog START" );
+
+    MakeVisible( EFalse );
+
+    if ( iSelf )
+        {
+        *iSelf = NULL;
+        iSelf = NULL;
+        }
+
+    RUBY_DEBUG0( "CListQueryDialog::~CListQueryDialog EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::IsMenuVisible
+// ---------------------------------------------------------
+// 
+TBool CListQueryDialog::IsMenuVisible()
+    {
+    RUBY_DEBUG0( "CListQueryDialog::IsMenuVisible" );
+    return MenuShowing();
+    }
+    
+// ---------------------------------------------------------
+// CListQueryDialog::SetCommandVisibility
+// ---------------------------------------------------------
+// 
+void CListQueryDialog::SetCommandVisibility( TBool aHidden )
+    {
+    RUBY_DEBUG0( "CListQueryDialog::SetCommandVisibility" );
+    iCommandsHidden = aHidden;
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::PostLayoutDynInitL
+// ---------------------------------------------------------
+// 
+void CListQueryDialog::PostLayoutDynInitL()
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::PostLayoutDynInitL" );
+  
+    if ( iObserver && iMenuResourceId )
+        {
+        if ( iMenuBar )
+            {
+            iMenuBar->TitleArray()->ResetAndDestroy();
+            iMenuBar->SetMenuTitleResourceId( iMenuResourceId );
+            iMenuBar->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper );
+            }
+        else
+            {
+            CEikMenuBar* menuBar = new ( ELeave ) CEikMenuBar();
+            CleanupStack::PushL( menuBar );
+        
+            menuBar->ConstructL( this, NULL, iMenuResourceId );
+            menuBar->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper );
+        
+            iEikonEnv->EikAppUi()->AddToStackL( menuBar,
+                                                ECoeStackPriorityMenu,
+                                                ECoeStackFlagRefusesFocus);
+        
+            iMenuBar = menuBar;
+            CleanupStack::Pop( menuBar ); // now owned by this Dialog.
+    		}
+        }
+    
+    // Set scrollbar observer so that touch scrolling can be observed
+    ListBox()->ScrollBarFrame()->SetScrollBarFrameObserver( this );
+    
+    CAknDialog::PostLayoutDynInitL();
+    }
+        
+// ---------------------------------------------------------
+// CListQueryDialog::OkToExitL
+// ---------------------------------------------------------
+// 
+TBool CListQueryDialog::OkToExitL( TInt aButtonId )
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::OkToExitL" );
+    
+    TBool returnValue = CAknListQueryDialog::OkToExitL( aButtonId );
+
+    switch( aButtonId )
+        {
+        case EAknSoftkeyOptions:
+            {            
+            DisplayMenuL();
+            
+            returnValue = EFalse;
+            
+            if ( iObserver )
+                {
+                iObserver->ProcessCommandL( EAknSoftkeyOptions );
+                }
+            
+            break;
+            }
+            
+        case EVoiceTagSoftKeySelect:
+            {
+            returnValue = ETrue;
+            
+            break;
+            }
+
+        default:
+            {
+            break;
+            }
+        }
+    return returnValue;
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::ProcessCommandL
+// ---------------------------------------------------------
+//      
+void CListQueryDialog::ProcessCommandL( TInt aCommandId )
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::ProcessCommandL" );
+    
+    if ( !iObserver )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    iObserver->ProcessCommandL( aCommandId );
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::DynInitMenuPaneL
+// ---------------------------------------------------------
+//     
+void CListQueryDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::DynInitMenuPaneL" );
+    
+    if ( aMenuPane && aResourceId == R_NBEST_MENU_PANE )
+        {
+        aMenuPane->SetItemDimmed( EVoiceTagSoftKeyOpen, iCommandsHidden );
+        }
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::HandleListBoxEventL
+// ---------------------------------------------------------
+//
+void CListQueryDialog::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType )
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::HandleListBoxEventL" );
+    
+    TBool forwardEvent = ETrue;
+    
+    if ( aEventType == EEventItemClicked )
+        {
+        if ( iObserver )
+            {
+            forwardEvent = EFalse;
+            iObserver->ProcessCommandL( EDragKeypress );
+            }
+        }    
+    else if ( aEventType == EEventItemDraggingActioned )
+        {
+        if ( iObserver )
+            {
+            iObserver->ProcessCommandL( EDragKeypress );
+            }
+        }
+    else if ( aEventType == EEventItemDoubleClicked )
+        {
+        if ( iObserver )
+            {
+            forwardEvent = EFalse;
+            iObserver->ProcessCommandL( EVoiceTagSoftKeySelect );
+            }
+        }
+    else if ( aEventType == EEventFlickStopped )
+        {
+        if ( iObserver )
+            {
+            iObserver->ProcessCommandL( EDragKeypress );
+            }
+        }
+        
+    if ( forwardEvent )
+        {
+        CAknListQueryDialog::HandleListBoxEventL( aListBox, aEventType );
+        }
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::HandleScrollEventL
+// ---------------------------------------------------------
+// 
+void CListQueryDialog::HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType )
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::HandleScrollEventL" );
+    
+    if ( aEventType == EEikScrollThumbDragVert )
+        {
+        if ( iObserver )
+            {
+            iObserver->ProcessCommandL( EScrollKeypress );
+            }
+        }
+    
+    ListBox()->HandleScrollEventL( aScrollBar, aEventType );
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::CListQueryDialog
+// ---------------------------------------------------------
+//              
+CListQueryDialog::CListQueryDialog( MEikCommandObserver* aObserver,
+                                    TInt aMenuTitleResourceId,
+                                    TInt *aIndex, CListQueryDialog** aSelf )
+ : CAknListQueryDialog( aIndex ), iObserver( aObserver),
+   iMenuResourceId( aMenuTitleResourceId ), iSelf( aSelf )
+    {
+    }
+
+// ---------------------------------------------------------
+// CListQueryDialog::ConstructL
+// ---------------------------------------------------------
+//           
+void CListQueryDialog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CListQueryDialog::ConstructL" );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicmessagequerydialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "vuicmessagequerydialog.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CMessageQueryDialog::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CMessageQueryDialog* CMessageQueryDialog::NewL( CMessageQueryDialog** aSelf )
+    {
+    CMessageQueryDialog* self = new (ELeave) CMessageQueryDialog( aSelf );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }   
+    
+// Destructor       
+CMessageQueryDialog::~CMessageQueryDialog()
+    {
+    RUBY_DEBUG0( "CMessageQueryDialog::~CMessageQueryDialog START" );
+
+    MakeVisible( EFalse );
+
+    if ( iSelf )
+        {
+        *iSelf = NULL;
+        iSelf = NULL;
+        }
+
+    RUBY_DEBUG0( "CMessageQueryDialog::~CMessageQueryDialog EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CMessageQueryDialog::CMessageQueryDialog
+// ---------------------------------------------------------
+//              
+CMessageQueryDialog::CMessageQueryDialog( CMessageQueryDialog** aSelf )
+ : CAknMessageQueryDialog(), iSelf( aSelf )
+    {
+    }
+
+// ---------------------------------------------------------
+// CMessageQueryDialog::ConstructL
+// ---------------------------------------------------------
+//           
+void CMessageQueryDialog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CMessageQueryDialog::ConstructL" );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicnbestlistdialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,616 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CNBestListDialog
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <aknPopup.h>
+#include <data_caging_path_literals.hrh>
+
+#include <AknIconArray.h>
+
+#include <AknMediatorFacade.h>
+
+#include <secondarydisplay/vuisecondarydisplayapi.h>
+#include <SecondaryDisplay/AknSecondaryDisplayDefs.h>
+
+#include <vuivoicerecognition.rsg>
+#include <vuivoicerecogdefs.h>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuiclistquerydialog.h"
+#include "vuicnbestlistdialog.h"
+
+#include "vuimkeycallback.h"
+
+#include "vuivoiceicondefs.h"
+
+#include "rubydebug.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CNBestListDialog::CNBestListDialog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CNBestListDialog::CNBestListDialog() 
+ : iCurrentIndex( 0 ), iTagCount( 0 ),
+   iCba( R_SOFTKEYS_SELECT_QUIT__SELECT )
+    {
+    }
+
+
+// Destructor
+CNBestListDialog::~CNBestListDialog()
+    {
+    RUBY_DEBUG0( "CNBestListDialog::~CNBestListDialog START" );
+     
+    RegisterForKeyCallback( NULL );
+    
+    delete iDialog;
+    iDialog = NULL;
+    
+    iEikonEnv->EikAppUi()->RemoveFromStack( this );
+        
+    RUBY_DEBUG0( "CNBestListDialog::~CNBestListDialog EXIT" );          
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNBestListDialog::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CNBestListDialog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::ConstructL" );
+      
+    iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityAlert );
+    }
+
+
+// ---------------------------------------------------------
+// CNBestListDialog::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CNBestListDialog* CNBestListDialog::NewL()                                                           
+    {
+    CNBestListDialog* self = new (ELeave) CNBestListDialog();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CNBestListDialog::RegisterForKeyCallback
+// -----------------------------------------------------------------------------
+//
+void CNBestListDialog::RegisterForKeyCallback( MKeyCallback* aKeyCallback )
+    {
+    iKeyCallback = aKeyCallback;
+    }
+
+// ---------------------------------------------------------
+// TKeyResponse CNBestListDialog::OfferKeyEventL
+// ---------------------------------------------------------
+//
+TKeyResponse CNBestListDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode /*aType*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::OfferKeyEventL" );
+
+    TKeyResponse keyStatus = EKeyWasNotConsumed;
+
+    TInt event = ConvertKeyEventL( aKeyEvent );
+    
+    // Check if event should be ignored
+    if ( iDialog && iDialog->IsMenuVisible() )
+        {
+        switch( event )
+            {
+            case EVoiceTagSoftKeyQuit:
+                {
+                break;
+                }
+            
+            default:
+                {
+                event = ENoKeypress;
+                break;
+                }
+            }
+        }
+
+    if ( event != ENoKeypress )
+        {
+        switch( event )
+            {
+            case ESelectKeypress:
+            case EDirectSelectKeypress:
+                {                   
+                keyStatus = EKeyWasConsumed;
+                break;
+                }
+            
+            case EUpKeypress:
+                {
+                --iCurrentIndex;
+                if ( iCurrentIndex <= -1 )
+                    {
+                    iCurrentIndex = iTagCount - 1;    
+                    }
+                break;
+                }
+                        
+            case EDownKeypress:
+                {
+                ++iCurrentIndex;
+                if ( iCurrentIndex >= iTagCount )
+                    {
+                    iCurrentIndex = 0;
+                    }
+                break;
+                }
+               
+            case EVoiceTagSoftKeyQuit:
+                {
+                iEikonEnv->EikAppUi()->RemoveFromStack( this );
+                break;
+                }
+                                        
+            default:
+                break;            
+            }
+         
+         if ( iKeyCallback )
+             {
+             iKeyCallback->HandleKeypressL( event );
+             }
+         }
+         
+    return keyStatus;
+    }
+    
+// ---------------------------------------------------------
+// CNBestListDialog::ProcessCommandL
+// ---------------------------------------------------------
+//      
+void CNBestListDialog::ProcessCommandL( TInt aCommandId )
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::ProcessCommandL" );
+    
+    TInt event = KErrNone;
+    
+    if ( aCommandId == EVoiceTagSoftKeySelect )
+        {
+        event = ESelectKeypress;
+        }
+    else if ( aCommandId == EVoiceTagSoftKeyOpen )
+        {
+        event = EOpenKeypress;
+        }
+    else if ( aCommandId == EVoiceTagSoftKeyQuit )
+        {
+        event = EVoiceTagSoftKeyQuit;
+        }
+    else if ( aCommandId == EAknSoftkeyOptions )
+        {
+        event = EOptionsKeypress;
+        }
+    else if ( aCommandId == EDragKeypress )
+        {
+        event = EDragKeypress;
+        
+        // Don't forward keypress if current index hasn't changed
+        if ( iCurrentIndex == iDialog->ListBox()->CurrentItemIndex() )
+            {
+            return;
+            }
+
+        iCurrentIndex = iDialog->ListBox()->CurrentItemIndex();
+        }
+    else if ( aCommandId == EScrollKeypress )
+        {
+        event = EScrollKeypress;
+        }
+                    
+    iKeyCallback->HandleKeypressL( event );
+    }
+
+// ---------------------------------------------------------------------------
+// CNBestListDialog::MediatorCommandL
+// ---------------------------------------------------------------------------
+//
+TAknDialogMediatorObserverCommand CNBestListDialog::MediatorCommandL( TUid /*aDomain*/, 
+                                                                      TUid aCategory, 
+                                                                      TInt aCommandId, 
+                                                                      const TDesC8& aData )
+    { 
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::MediatorCommandL" );
+    
+    TAknDialogMediatorObserverCommand retValue = EHandleAsNormal;
+    
+    if ( aCategory == SecondaryDisplay::KCatVoiceUi && 
+         aCommandId == SecondaryDisplay::ECmdShowNBestListQuery )
+        {
+        if ( aData.Length() == sizeof( SAknDialogFeedback ) ) 
+            {
+            const SAknDialogFeedback& params = 
+                reinterpret_cast<const SAknDialogFeedback&>( *( aData.Ptr() ) );
+            
+            if ( params.iKey.iCode == EKeyCBA1 )
+                {
+                // LSK should select current selection
+                iKeyCallback->HandleKeypressL( ESelectKeypress );
+                
+                retValue = EDoNothingWithThisCommand;
+                }
+            }
+        else
+            {
+            SAknIntegerUpdate* params = (SAknIntegerUpdate*) &aData;
+        
+            if ( params->iCmd == EAknListQueryUpdateSelection )
+                {
+                iCurrentIndex = params->iId;
+                iDialog->ListControl()->Listbox()->SetCurrentItemIndexAndDraw( iCurrentIndex );
+
+                // Just send EUpKeypress or EDownKeypress event to notify that selection
+                // has changed
+                iKeyCallback->HandleKeypressL( EDownKeypress );
+                }
+            }
+        }
+    return retValue; 
+    } 
+
+// ---------------------------------------------------------------------------
+// CNBestListDialog::NotifyMediatorExit
+// ---------------------------------------------------------------------------
+//
+void CNBestListDialog::NotifyMediatorExit() 
+    { 
+    RUBY_DEBUG0( "CNBestListDialog::NotifyMediatorExit" );
+    // Do nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CNBestListDialog::CreateNBestListPopupLC
+// -----------------------------------------------------------------------------
+//
+void CNBestListDialog::CreateNBestListPopupLC( CDesC16ArrayFlat* aItems,
+                                               const TDesC& aHeader )
+    {
+    RUBY_DEBUG0( "CNBestListDialog::ShowNBestListPopupLC START" );
+       
+    iDialog = CListQueryDialog::NewL( &iCurrentIndex, &iDialog, this, R_NBEST_OPTIONS_MENU );
+    iDialog->PrepareLC( R_NBEST_POPUP_LIST );
+    
+    if ( aHeader != KNullDesC )
+        {
+        iDialog->QueryHeading()->SetTextL( aHeader );
+        }
+
+    iDialog->SetOwnershipType( ELbmOwnsItemArray );
+    iDialog->SetItemTextArray( aItems );
+    
+    iDialog->ListControl()->Listbox()->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
+        
+    iTagCount = aItems->Count();
+    
+    CreateAndSetSecondaryDisplayDataL( aItems );
+        
+    // Create icon array
+    CArrayPtr<CGulIcon>* icons = CreateIconArrayL();    
+    iDialog->SetIconArrayL( icons );
+    
+    RUBY_DEBUG0( "CNBestListDialog::ShowNBestListPopupLC EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CNBestListDialog::ShowNBestListPopupL
+// -----------------------------------------------------------------------------
+//
+TInt CNBestListDialog::ShowNBestListPopupL()
+    {
+    RUBY_DEBUG0( "CNBestListDialog::ShowNBestListPopupL START" );
+
+    // Show N-Best List
+    TInt returnValue = iDialog->RunLD();
+    
+    // Touch selection returns EAknSoftkeyOk
+    if ( returnValue == EAknSoftkeyOk )
+        {
+        returnValue = EVoiceTagSoftKeySelect;
+        }
+            
+    RUBY_DEBUG0( "CNBestListDialog::ShowNBestListPopupL EXIT" );
+
+    return returnValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CNBestListDialog::SetSoftkeys
+// -----------------------------------------------------------------------------
+//    
+void CNBestListDialog::SetSoftkeysL( TInt aResourceId )
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::SetSoftkeysL" );
+    
+    iCba = aResourceId;
+    
+    // Set softkey labels
+    CEikButtonGroupContainer* cba = &iDialog->ButtonGroupContainer();
+    cba->SetCommandSetL( aResourceId );
+    cba->DrawDeferred();
+    }
+    
+// -----------------------------------------------------------------------------
+// CNBestListDialog::SetCommandsHidden
+// -----------------------------------------------------------------------------
+//    
+void CNBestListDialog::SetCommandsHidden( TBool aHidden )
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::SetCommandsHidden" );
+    
+    iDialog->SetCommandVisibility( aHidden );
+    }
+    
+// -----------------------------------------------------------------------------
+// CNBestListDialog::ConvertKeyEventL
+// -----------------------------------------------------------------------------
+// 
+TInt CNBestListDialog::ConvertKeyEventL( const TKeyEvent& aKeyEvent )
+    {
+    TInt event = ENoKeypress;
+    
+    switch( aKeyEvent.iCode )
+        {
+        case EKeyNo:
+        case EKeyEscape:
+            {
+            event = EVoiceTagSoftKeyQuit;
+            break;
+            }
+
+        case EKeyDevice3:
+            {
+            event = ESelectKeypress;
+            break;
+            }
+            
+        case EKeyYes:
+            {
+            event = EDirectSelectKeypress;
+            break;
+            }
+
+        case EKeyUpArrow:
+            {
+            event = EUpKeypress;
+            break;
+            }
+                        
+        case EKeyDownArrow:
+            {
+            event = EDownKeypress;
+            break;
+            }
+                                        
+        default:
+            {
+            event = ENoKeypress;
+            break;            
+            }
+        }
+            
+    return event;
+    }
+    
+// ---------------------------------------------------------
+// CNBestListDialog::CreateIconArrayL
+// Creates new icon array
+// ---------------------------------------------------------
+//
+CArrayPtr<CGulIcon>* CNBestListDialog::CreateIconArrayL()
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::CreateIconArrayL" );
+    
+    CAknIconArray* icons = new ( ELeave ) CAknIconArray( KSindNumberOfIcons );
+    CleanupStack::PushL( icons );
+
+    // 0. Phone
+    // 1. Home
+    // 2. Work
+    // 3. Mobile
+    // 4. Fax
+    // 5. Pager
+    // 6. Blank
+    // 7. Profile
+    // 8. Application or function
+    // 9. Video call icon
+    //10. VoIP icon
+    
+    for ( int i = 0; i < KSindNumberOfIcons; ++i )
+        {
+        AppendIconToArrayL( icons, *KIconId[ i ], KBitmapId[ i ], KMaskId[ i ] );
+        }
+        
+    CleanupStack::Pop( icons );
+    return icons;
+    }
+
+
+// ---------------------------------------------------------
+// CNBestListDialog::AppendIconToArrayL
+// ---------------------------------------------------------
+//
+void CNBestListDialog::AppendIconToArrayL( CAknIconArray* aArray,
+                                           const TAknsItemID& aID,
+                                           TInt aBitmapId,
+                                           TInt aMaskId )
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::AppendIconToArrayL" );
+
+    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+
+    CFbsBitmap* bitmap = NULL;
+    CFbsBitmap* mask = NULL;
+    TBuf<KMaxFileName> fileName = AknIconUtils::AvkonIconFileName();
+    
+    if ( aID == *KIconId[ EIconProfile ] || aID == *KIconId[ EIconApplication ] )
+        {
+        TParse* fp = new ( ELeave ) TParse();
+        CleanupStack::PushL( fp );
+        User::LeaveIfError( fp->Set( KDirAndFile, &KDC_BITMAP_DIR, NULL ) );
+
+        fileName = fp->FullName();
+        CleanupStack::PopAndDestroy( fp );
+        }
+
+    AknsUtils::CreateIconL( skin, aID, bitmap, mask, fileName,
+                            aBitmapId, aMaskId );
+    CleanupStack::PushL( bitmap );
+    CleanupStack::PushL( mask );
+
+    CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
+    icon->SetBitmapsOwnedExternally( EFalse );
+
+    // icon now owns the bitmaps, no need to keep on cleanup stack.
+    CleanupStack::Pop( mask );
+    CleanupStack::Pop( bitmap );
+    bitmap = NULL;
+    mask = NULL;
+
+    CleanupStack::PushL( icon );
+    aArray->AppendL( icon );
+
+    // aArray now owns the icon, no need to delete.
+    CleanupStack::Pop( icon );
+    }
+
+// ---------------------------------------------------------
+// CNBestListDialog::CreateAndSetSecondaryDisplayDataL
+// ---------------------------------------------------------
+//    
+void CNBestListDialog::CreateAndSetSecondaryDisplayDataL( CDesC16ArrayFlat* aItems )
+    {
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::CreateAndSetSecondaryDisplayDataL" );
+
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+        {        
+        // Create dummy id list (needed for list query automation)
+        CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
+        CleanupStack::PushL( array );
+        for( TInt i = 0; i < iTagCount; ++i )
+            {
+            array->AppendL( i );
+            }
+
+        // Publish to secondary display
+        iDialog->PublishDialogL( SecondaryDisplay::ECmdShowNBestListQuery,
+                                 SecondaryDisplay::KCatVoiceUi,
+                                 array );
+                                 
+        iDialog->SetMediatorObserver( this );
+        
+        CleanupStack::Pop( array ); // Dialog takes ownership of array
+
+        // Generate n-best data for secondary display
+        CAknMediatorFacade* covercl = AknMediatorFacade( iDialog );
+        if( covercl )
+            {
+            // Current index
+            covercl->BufStream().WriteInt32L( iCurrentIndex );
+
+            // Item count and items
+            covercl->BufStream().WriteInt32L( iTagCount );
+            for( TInt i = 0; i < iTagCount; ++i )
+                {
+                TPtrC16 item = aItems->MdcaPoint( i );
+                covercl->BufStream().WriteInt32L( item.Length() );
+                covercl->BufStream().WriteL( item, item.Length() );
+                }
+
+            covercl->BufStream().CommitL(); // no more data to send so commit buf
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CNBestListDialog::HandleShortKeypressL
+// ---------------------------------------------------------
+//
+TBool CNBestListDialog::HandleShortKeypressL( CDesC16ArrayFlat* aItems )
+    {        
+    RUBY_DEBUG_BLOCK( "CNBestListDialog::HandleShortKeypressL" );
+
+    TBool returnValue = ETrue;
+
+    if ( aItems )
+        {
+        iDialog->SetItemTextArray( aItems );        
+        iDialog->ListControl()->Listbox()->SetCurrentItemIndexAndDraw( iCurrentIndex );
+        
+        CreateAndSetSecondaryDisplayDataL( aItems );
+        }
+    else
+        {
+        ++iCurrentIndex;
+        if ( iCurrentIndex == iTagCount )
+            {    
+            returnValue = EFalse;
+            }
+
+        if ( returnValue ) 
+            {
+            // Move focus to the current item
+            TKeyEvent keyEvent;
+            keyEvent.iRepeats = 0;
+            keyEvent.iCode = EKeyDownArrow;
+        
+            iDialog->OfferKeyEventL( keyEvent, EEventKey );
+            }
+        }
+    
+    return returnValue;                
+    }
+    
+// ---------------------------------------------------------------------------
+// CNBestListDialog::SelectedIndex
+// ---------------------------------------------------------------------------
+//    
+TInt CNBestListDialog::SelectedIndex()
+    {
+    RUBY_DEBUG1( "CNBestListDialog::SelectedIndex - index = %d", iCurrentIndex );
+    
+    TInt index = iCurrentIndex;
+    
+    if ( index < 0 )
+        {
+        index = 0;
+        }
+    
+    return index;
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicnotificationobserver.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CNBestListDialog
+*
+*/
+
+// INCLUDE FILES
+#include "vuicnotificationobserver.h"
+
+#include <avkondomainpskeys.h>
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CNotificationObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CNotificationObserver* CNotificationObserver::NewL()
+    {
+    CNotificationObserver* self = new (ELeave) CNotificationObserver();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    } 
+
+// Destructor       
+CNotificationObserver::~CNotificationObserver()
+    {
+    RUBY_DEBUG0( "CNotificationObserver::~CNotificationObserver START" );
+    
+    Cancel();
+    
+    iNotificationState.Set( iNotificationStatus );
+    
+    iNotificationState.Close();
+    
+    RUBY_DEBUG0( "CNotificationObserver::~CNotificationObserver EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CNotificationObserver::DoCancel
+// ---------------------------------------------------------
+// 
+void CNotificationObserver::DoCancel()
+    {
+    RUBY_DEBUG0( "CNotificationObserver::DoCancel START" );
+    
+    iNotificationState.Cancel();
+    
+    RUBY_DEBUG0( "CNotificationObserver::DoCancel EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CNotificationObserver::RunL
+// ---------------------------------------------------------
+//     
+void CNotificationObserver::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CNotificationObserver::RunL" );
+    
+    TInt status = iStatus.Int();
+    
+    if ( status == KErrNone )
+        {
+        iNotificationState.Get( iNotificationStatus );
+        
+        if ( iNotificationStatus )
+            {
+            iNotificationState.Set( 0 );
+            }
+        }
+        
+    iNotificationState.Subscribe( iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CNotificationObserver::CNotificationObserver
+// ---------------------------------------------------------
+//              
+CNotificationObserver::CNotificationObserver()
+ : CActive( EPriorityStandard )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CNotificationObserver::ConstructL
+// ---------------------------------------------------------
+//           
+void CNotificationObserver::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CNotificationObserver::ConstructL" );
+    
+    User::LeaveIfError( iNotificationState.Attach( KPSUidAvkonDomain, KAknNotificationsInIdleAllowed ) );
+    CActiveScheduler::Add( this );
+    
+    iNotificationState.Get( iNotificationStatus );
+    
+    if ( iNotificationStatus )
+        {
+        iNotificationState.Set( 0 );
+        }
+    
+    iNotificationState.Subscribe( iStatus );
+    SetActive();
+    }    
+
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicplaystate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,492 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <aknappui.h>
+#include <AknUtils.h> 
+#include <AknIconUtils.h> 
+#include <cntdef.h>
+#include <AknsConstants.h>
+#include <StringLoader.h>
+#include <AudioPreference.h>
+
+#include <vasmbasepbkhandler.h>
+
+#include <secondarydisplay/vuisecondarydisplayapi.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicstate.h"
+#include "vuicplaystate.h"
+#include "vuictutorialstate.h"
+#include "vuicresultsstate.h"
+#include "vuicverificationinitstate.h"
+#include "vuicabortstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuicpropertyhandler.h"
+#include "vuictoneplayer.h"
+#include "vuicttsplayer.h"
+#include "vuicglobalprogressdialog.h"
+#include "vuivoiceicondefs.h"
+
+#include "rubydebug.h"
+
+// Constants
+_LIT( KStringPosition, "%U" );
+
+// -----------------------------------------------------------------------------
+// CPlayState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CPlayState* CPlayState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CPlayState* self = new (ELeave) CPlayState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CPlayState::~CPlayState()
+    {
+    RUBY_DEBUG0( "CPlayState::~CPlayState START" );
+    
+    DataStorage().TtsPlayer()->Stop();
+    
+    delete iProgressDialog;
+    
+    RUBY_DEBUG0( "CPlayState::~CPlayState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CPlayState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CPlayState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CPlayState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+                iInternalState = EInitialized;
+                nextState = this;
+                }
+            else if ( iInternalState == EInitialized )
+                {
+                iInternalState = ECompleted;
+                nextState = this;
+                }
+            break;
+        
+        case KErrPathNotFound:
+        
+            // Ignore mysterious path not found error when loading confirmation tone
+            if ( iInternalState == EStarted )
+                {
+                nextState = CTutorialState::NewL( DataStorage(), UiModel() );
+                }
+            break;
+        
+        case EVoiceTagSoftKeySelect:
+        
+            nextState = CTutorialState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        case EShortKeypress:
+        case EVoiceTagSoftKeyOther:
+        case EAknSoftkeyOther:
+        case EAknSoftkeyDone:
+        case EStdKeyDevice2:
+        
+            if ( iInternalState != EStarted )
+                {
+                if ( DataStorage().VerificationMode() != EVoice )
+                    {
+                    nextState = CResultsState::NewL( DataStorage(), UiModel() );
+                    }
+                else
+                    {
+                    if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext &&
+                         DataStorage().Tag()->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial )
+                        {
+                        nextState = CVerificationInitState::NewL( DataStorage(), UiModel() );
+                        }
+                    }
+                }
+            break;
+            
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+        
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CPlayState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CPlayState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CPlayState::ExecuteL" );
+
+    if ( iInternalState == ENotStarted )
+        {
+        TBuf<KMaxFieldLength> phoneNumber;        
+        TFieldType fieldType;        
+        TName name;
+        
+        iInternalState = EStarted;
+
+        if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext )
+            {
+            if ( DataStorage().VerificationMode() == EVoice &&
+                 DataStorage().Tag()->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial )
+                {
+                FormatDataL( name, phoneNumber, fieldType );
+
+                ShowPlaydialogL( name, phoneNumber, fieldType );
+                }
+            else
+                {
+                TRAP_IGNORE( HandleEventL( EVoiceTagSoftKeySelect ) );
+                }
+            }
+        else
+            {
+            DataStorage().TonePlayer()->InitToneL( EAvkonSIDConfirmationTone );
+            }                
+        }
+    else if ( iInternalState == EInitialized )
+        {
+        if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext &&
+             DataStorage().Tag()->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial )
+            {
+            iTModel.iFinalValue = DataStorage().PlayDuration().Int64() / KKRecogInterval + 4 * KRecogDelay;
+            StartTimerL( *this, KRecogDelay, KKRecogInterval * iTModel.iHundreths );
+            }
+        else
+            {
+            DataStorage().TonePlayer()->PlayTone( EAvkonSIDConfirmationTone );
+            }
+        }
+    else  if ( iInternalState == ECompleted )
+        {
+        if ( DataStorage().Tag()->Context()->ContextName() != KVoiceDialContext ||
+             DataStorage().Tag()->RRD()->IntArray()->At( KVasExtensionRrdLocation ) != EDial )
+            {
+            TRAP_IGNORE( HandleEventL( EVoiceTagSoftKeySelect ) );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CPlayState::CPlayState
+// ---------------------------------------------------------
+//              
+CPlayState::CPlayState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted ),
+   iTickCount( 0 ), iPlaybackDelay( KPlaybackTimeout )
+    {
+    iTModel.iFinalValue = KRecogFinal;
+    iTModel.iHundreths = KRecogInterval;
+    iTModel.iIncrement = KRecogIncrement;
+    iTModel.iRunning = EFalse;
+    }
+
+// ---------------------------------------------------------
+// CPlayState::ConstructL
+// ---------------------------------------------------------
+//           
+void CPlayState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CPlayState::ConstructL" );
+    
+    CState::ConstructL();
+    }
+    
+// ---------------------------------------------------------
+// CPlayState::DoTimedEventL
+// ---------------------------------------------------------
+//
+void CPlayState::DoTimedEventL()
+    {
+    if ( ( ++iTickCount < iTModel.iFinalValue + iPlaybackDelay ) && iProgressDialog )
+        {
+        iProgressDialog->UpdateProgressDialogL( iTickCount, iTModel.iFinalValue ); 
+        }
+    else 
+        {
+        HandleEventL( EVoiceTagSoftKeySelect );
+        } 
+    }
+    
+// ---------------------------------------------------------
+// CPlayState::FormatName
+// ---------------------------------------------------------
+//           
+void CPlayState::FormatName( TDes& aName )
+    {
+    RUBY_DEBUG0( "CPlayState::FormatName START" );
+    
+    const CFont* font = CEikonEnv::Static()->NormalFont();
+    if ( AknLayoutUtils::Variant() == EApacVariant )
+        {
+        font = ApacPlain16();
+        }
+
+    TRect rect = iAvkonAppUi->ClientRect();
+    TAknLayoutText layoutText;
+    layoutText.LayoutText( rect, AKN_LAYOUT_TEXT_Wait_or_progress_note_pop_up_window_texts_Line_1(0,0,0) );
+    TInt maxWidth = layoutText.TextRect().Width();
+
+    AknTextUtils::ClipToFit( aName, *font, maxWidth, AknTextUtils::EClipFromEnd );
+    
+    RUBY_DEBUG0( "CPlayState::FormatName EXIT" );
+    }     
+    
+// ---------------------------------------------------------------------------
+// CPlayState::PlayVoiceTagL
+// ---------------------------------------------------------------------------
+//
+void CPlayState::PlayVoiceTagL()
+    {
+    RUBY_DEBUG_BLOCK( "CPlayState::PlayVoiceTagL" );
+    
+    // if TTS is used
+    if ( DataStorage().SynthesizerMode() != KErrNone ||
+         DataStorage().DeviceLockMode() )
+        {            
+        // Add text "dialling" in front of the name if using voice dialing
+        if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext &&
+             DataStorage().Tag()->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial )
+            {
+            HBufC* ttsText = StringLoader::LoadLC( R_QAN_VC_TTS_DIALLING );
+            
+            TInt position = ttsText->FindC( KStringPosition );
+            User::LeaveIfError( position );            
+            
+            CleanupStack::PopAndDestroy( ttsText );
+                                                   
+            ttsText = StringLoader::LoadLC( R_QAN_VC_TTS_DIALLING,
+                                            DataStorage().Tag()->SpeechItem()->Text() );
+                                                   
+            HBufC* text = DataStorage().Tag()->SpeechItem()->PartialTextL( KNameTrainingIndex );        
+            CleanupStack::PushL( text ); 
+            
+            DataStorage().TtsPlayer()->PlayL( *ttsText, position,
+                                              DataStorage().Tag()->SpeechItem()->Text().Length(),
+                                              *text );
+            
+            CleanupStack::PopAndDestroy( text );
+            CleanupStack::PopAndDestroy( ttsText );
+            }
+        else if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext )
+            {           
+            HBufC* text = DataStorage().Tag()->SpeechItem()->PartialTextL( KNameTrainingIndex );        
+            CleanupStack::PushL( text ); 
+        
+            DataStorage().TtsPlayer()->PlayL( DataStorage().Tag()->SpeechItem()->Text(), 0,
+                                              DataStorage().Tag()->SpeechItem()->Text().Length(),
+                                              *text );
+
+            CleanupStack::PopAndDestroy( text );
+            }
+        else
+            {            
+            DataStorage().TtsPlayer()->PlayL( DataStorage().Tag()->SpeechItem()->Text() );
+            }
+        }
+    else
+        {
+        // Set playback delay so that dialog will be dismissed immediately when
+        // progess bar reaches final value
+        iPlaybackDelay = 1;
+                
+        // Show playback dialog without TTS.
+        DataStorage().SetPlayDuration( KTimeoutMicroseconds );
+        HandleEventL( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPlayState::FormatDataL
+// ---------------------------------------------------------------------------
+//
+void CPlayState::FormatDataL( TDes& aName, TDes& aPhoneNumber, TFieldType& aFieldType )
+    {
+    RUBY_DEBUG_BLOCK( "CPlayState::FormatDataL" );
+    
+    TPtrC phoneNumber( KNullDesC );
+    aPhoneNumber = (TDes&) phoneNumber;
+        
+    aFieldType = KNullUid;
+    
+    aName.Zero();
+        
+    if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext )
+        {
+        HBufC* name = DataStorage().Tag()->SpeechItem()->PartialTextL( KNameTrainingIndex );
+        CleanupStack::PushL( name );
+        
+        aName.Copy( *name );
+            
+        CleanupStack::PopAndDestroy( name );
+        
+        // Format name so that it fits on one line
+        FormatName( aName );
+ 
+        DataStorage().PbkHandler()->FindContactFieldL( DataStorage().Tag() );
+
+        // Format phone number
+        phoneNumber.Set( DataStorage().PbkHandler()->TextL() );
+        aPhoneNumber = (TDes&) phoneNumber;
+        AknTextUtils::LanguageSpecificNumberConversion( aPhoneNumber );
+ 
+        aFieldType = DataStorage().PbkHandler()->FieldTypeL();      
+        }
+    else
+        {
+        aName.Copy( DataStorage().Tag()->SpeechItem()->Text() );
+        }
+    }  
+
+// ---------------------------------------------------------------------------
+// CPlayState::ShowPlaydialogL
+// ---------------------------------------------------------------------------
+//
+void CPlayState::ShowPlaydialogL( const TDesC& aName, const TDesC& aPhoneNumber,
+                                  const TFieldType aFieldType )
+    {
+    RUBY_DEBUG_BLOCK( "CPlayState::ShowPlaydialogL" );
+    
+    // Get icon information
+    TInt iconId;
+    TInt iconMaskId;
+    TAknsItemID iconSkinId;
+    GetDialogIcon( aFieldType, iconId, iconMaskId, iconSkinId );
+
+    iProgressDialog = CGlobalProgressDialog::NewL();
+
+    // Set icon, image and skin for the playback dialog
+    iProgressDialog->SetIconL( AknIconUtils::AvkonIconFileName(),
+                               iconId, iconMaskId );
+    
+    iProgressDialog->SetImageL( AknIconUtils::AvkonIconFileName(),
+                                EMbmAvkonQgn_note_voice_found,
+                                EMbmAvkonQgn_note_voice_found_mask );
+
+    iProgressDialog->SetSkinIds( KAknsIIDQgnNoteVoiceFound, EMbmAvkonQgn_note_voice_found,
+                                 EMbmAvkonQgn_note_voice_found_mask, iconSkinId );
+   
+    iProgressDialog->RegisterForKeyCallback( DataStorage().VoiceRecognitionImpl() );
+        
+    // Package dialog data for coverui
+    SecondaryDisplay::TMatchData matchData;
+    matchData.iType = aFieldType;
+    matchData.iName.Append( aName );
+    matchData.iNumber.Append( aPhoneNumber );
+
+    // Publish the data for the secondary display
+    iProgressDialog->SetSecondaryDisplayDataL( SecondaryDisplay::KCatVoiceUi,
+                                               SecondaryDisplay::ECmdShowMatchedItemNote,
+                                               &matchData );
+                                               
+    BringToForeground();
+
+    iProgressDialog->ShowProgressDialogL( aName, aPhoneNumber, R_AVKON_SOFTKEYS_OTHER_QUIT );
+           
+    // Play selected name using TTS
+    PlayVoiceTagL();
+    }    
+    
+// ---------------------------------------------------------
+// CPlayState::GetDialogIcon
+// Chooses appropriate dialog icon
+// ---------------------------------------------------------
+//
+void CPlayState::GetDialogIcon( const TFieldType& aType, TInt& aIcon,
+                                TInt& aIconMask, TAknsItemID& aIconId )
+   {   
+   // select a phone type bitmap
+   if ( aType == KUidContactFieldVCardMapVOICE )
+      {
+      aIcon = KBitmapId[ EIconPhone ];
+      aIconMask = KMaskId[ EIconPhone ];
+      aIconId = *KIconId[ EIconPhone ];
+      }
+   else if ( aType == KUidContactFieldVCardMapCELL )
+      {
+      aIcon = KBitmapId[ EIconMobile ];
+      aIconMask = KMaskId[ EIconMobile ];
+      aIconId = *KIconId[ EIconMobile ];
+      }
+   else if ( aType == KUidContactFieldVCardMapFAX )
+      {
+      aIcon = KBitmapId[ EIconFax ];
+      aIconMask = KMaskId[ EIconFax ];
+      aIconId = *KIconId[ EIconFax ];
+      }
+   else if ( aType == KUidContactFieldVCardMapEMAILINTERNET )
+      {
+      aIcon = KBitmapId[ EIconEmail ];
+      aIconMask = KMaskId[ EIconEmail ];
+      aIconId = *KIconId[ EIconEmail ];
+      }
+   else if ( aType == KUidContactFieldVCardMapVIDEO )
+      {
+      aIcon = KBitmapId[ EIconVideo ];
+      aIconMask = KMaskId[ EIconVideo ];
+      aIconId = *KIconId[ EIconVideo ];
+      }
+   else if ( aType == KUidContactFieldVCardMapVOIP )
+      {
+      aIcon = KBitmapId[ EIconVoip ];
+      aIconMask = KMaskId[ EIconVoip ];
+      aIconId = *KIconId[ EIconVoip ];
+      }   
+   else
+      {
+      aIcon = KBitmapId[ EIconBlank ];
+      aIconMask = KMaskId[ EIconBlank ];
+      aIconId = *KIconId[ EIconBlank ];
+      }
+   }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicprecheckstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,228 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <coreapplicationuisdomainpskeys.h>
+#include <ctsydomainpskeys.h>
+#include <PSVariables.h>        // Property values
+#include <apgwgnam.h> 
+#include <coemain.h>
+#include <coedef.h>
+
+#include "vuicstate.h"
+#include "vuicprecheckstate.h"
+#include "vuiccontextcheckstate.h"
+#include "vuicexitstate.h"
+#include "vuicerrorstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "rubydebug.h"
+    
+//fix for the error ECWG-7WDA9G
+const TUid KAknnfysrvUid = {0x10281ef2};
+// -----------------------------------------------------------------------------
+// CPrecheckState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CPrecheckState* CPrecheckState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CPrecheckState* self = new (ELeave) CPrecheckState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CPrecheckState::~CPrecheckState()
+    {
+    RUBY_DEBUG0( "CPrecheckState::~CPrecheckState START" );
+    
+    RUBY_DEBUG0( "CPrecheckState::~CPrecheckState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CPrecheckState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CPrecheckState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CPrecheckState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            nextState = CContextCheckState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case KErrGeneral:
+        
+            nextState = CExitState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        default:
+        
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CPrecheckState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CPrecheckState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CPrecheckState::ExecuteL" );
+    
+    TInt error = KErrNone;
+
+    // Check if autolock is on
+    if ( GetAutoLockValue() > EAutolockOff )
+        {
+        if ( !DataStorage().DeviceLockMode() )
+            {
+            error = KErrGeneral;
+            }
+        }
+    else
+        {
+        DataStorage().SetDeviceLockMode( EFalse );
+        }
+		
+	// Check if lockphone dialog is active
+    if ( IsLockPhoneDialogL() )
+    	{
+    	error = KErrGeneral;
+    	}
+
+    // Check if phone or video call is currently active
+    TInt state = CheckCallState();
+    if ( ( state != EPSCTsyCallStateNone &&
+           state != EPSCTsyCallStateUninitialized &&
+           state != KErrUnknown ) || IsVideoCall() )
+        {
+        error = KErrCallInProgress;
+        }
+
+    HandleEventL( error );
+    }
+
+// ---------------------------------------------------------
+// CPrecheckState::CPrecheckState
+// ---------------------------------------------------------
+//              
+CPrecheckState::CPrecheckState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel )
+    {
+    }
+   
+// ---------------------------------------------------------
+// CPrecheckState::GetAutoLockValue
+// ---------------------------------------------------------
+//
+TInt CPrecheckState::GetAutoLockValue()
+    {
+    RUBY_DEBUG0( "CPrecheckState::GetAutoLockValue START" );
+  
+    TInt autoLockValue;
+    TInt err = RProperty::Get( KPSUidCoreApplicationUIs,
+                               KCoreAppUIsAutolockStatus,
+                               autoLockValue );
+    if ( err == KErrNotFound )
+        {
+        autoLockValue = KErrNotFound;
+        }
+        
+    RUBY_DEBUG0( "CPrecheckState::GetAutoLockValue EXIT" );
+    
+    return autoLockValue;
+    }
+    
+// ---------------------------------------------------------
+// CPrecheckState::CheckCallState
+// ---------------------------------------------------------
+//
+TInt CPrecheckState::CheckCallState()
+    {
+    RUBY_DEBUG0( "CPrecheckState::CheckCallState START" );
+    
+    TInt callState;
+    TInt err = RProperty::Get( KPSUidCtsyCallInformation,
+                               KCTsyCallState,
+                               callState );
+    if ( err == KErrNotFound )
+        {
+        callState = KErrNotFound;
+        }
+    
+    RUBY_DEBUG0( "CPrecheckState::CheckCallState EXIT" );
+    
+    return callState;    
+    }    
+    
+// -----------------------------------------------------------------------------
+// CPrecheckState::IsVideoCall 
+// -----------------------------------------------------------------------------
+//
+TBool CPrecheckState::IsVideoCall() 
+    {
+    RUBY_DEBUG0( "CPrecheckState::IsVideoCall START" );
+    
+    TInt callType;
+    RProperty::Get( KPSUidCtsyCallInformation,
+                    KCTsyCallType, 
+                    callType );// Ignore errors  
+
+    RUBY_DEBUG0( "CPrecheckState::IsVideoCall EXIT" );
+
+    return callType == EPSCTsyCallTypeH324Multimedia;
+    }    
+
+// -----------------------------------------------------------------------------
+// CPrecheckState::IsLockPhoneDialogL
+// -----------------------------------------------------------------------------
+//
+TBool CPrecheckState::IsLockPhoneDialogL()
+	{
+	//fix for the error ECWG-7WDA9G,if we found the first windows is "lockphone" dialog we will terminate the App.
+	TBool islock = EFalse;
+	RWsSession &ws = CCoeEnv::Static()->WsSession();
+	TInt wgId = ws.GetFocusWindowGroup(); 
+	CApaWindowGroupName *WindowsGroupName = CApaWindowGroupName::NewLC( ws, wgId );
+	if ( ( KAknnfysrvUid == WindowsGroupName->AppUid() ) && 
+	      ( ws.GetWindowGroupOrdinalPriority( wgId ) >= ECoeWinPriorityAlwaysAtFront ) )
+	    {
+	    islock = ETrue;
+	    }
+	CleanupStack::PopAndDestroy( WindowsGroupName );
+	return islock;
+	}
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicpropertyhandler.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Active object for subscribing to Publish & Suscribe properties
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <voiceuidomainpskeys.h>
+
+#include <vuivoicerecogdefs.h>
+
+#include "vuicpropertyhandler.h"
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "rubydebug.h"
+
+// ---------------------------------------------------------
+// CPropertyHandler::NewL
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------
+//
+CPropertyHandler* CPropertyHandler::NewL( TUid aFirstCategory,
+                                          TUint aFirstKey, 
+                                          TUid aSecondCategory,
+                                          TUint aSecondKey )
+    {
+    RUBY_DEBUG_BLOCK( "CPropertyHandler::NewL" );
+    
+    CPropertyHandler* self = new ( ELeave ) CPropertyHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFirstCategory, aFirstKey, 
+                      aSecondCategory, aSecondKey );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------
+// CPropertyHandler::CPropertyHandler
+// C++ constructor
+// ---------------------------------------------------------
+//
+CPropertyHandler::CPropertyHandler()
+    : CActive( EPriorityStandard )
+    {
+    }
+
+// ---------------------------------------------------------
+// CPropertyHandler::ConstructL
+// Symbian OS 2nd phase constructor
+// ---------------------------------------------------------
+//
+void CPropertyHandler::ConstructL( TUid aFirstCategory, TUint aFirstKey, 
+                                   TUid aSecondCategory, TUint aSecondKey )
+    {
+    RUBY_DEBUG_BLOCK( "CPropertyHandler::ConstructL" );   
+ 
+    iFirstCategory = aFirstCategory;
+    iFirstKey = aFirstKey;
+    
+    /*****************************
+    * KPSUidVoiceUiAccMonitor
+    ******************************/
+
+    
+    TInt err = iProperty.Define( iFirstCategory, iFirstKey,
+                                 RProperty::EInt );
+    
+    RUBY_DEBUG1( "CPropertyHandler::ConstructL - aFirstCategory err[%d]", err );
+   
+    if ( err == KErrNone || err == KErrAlreadyExists )
+        {
+        // Set VoiceUI P&S key to ON
+        User::LeaveIfError( iProperty.Set( iFirstCategory, iFirstKey, 
+                                           KVoiceUiIsOpen ) );
+        }
+
+        TInt error = iProperty.Define( aSecondCategory, aSecondKey,
+                                       RProperty::EInt );
+    
+    RUBY_DEBUG1( "CPropertyHandler::ConstructL - aSecondCategory err[%d]", err );
+     
+    if ( error == KErrNone || error == KErrAlreadyExists )
+        {
+        // Start to listen RemCon events
+        User::LeaveIfError( iProperty.Attach( aSecondCategory, aSecondKey ) );
+        }
+    
+    CActiveScheduler::Add( this );
+    // Initial subscription and process current property value
+    RunL();
+
+    iRequestIssued = ETrue;
+    }
+
+// Destructor
+CPropertyHandler::~CPropertyHandler()
+    {
+    RUBY_DEBUG0( "CPropertyHandler::~CPropertyHandler START" );
+
+    // Set VoiceUI P&S key to OFF
+    iProperty.Set( iFirstCategory, iFirstKey, KVoiceUiIsClose );
+    
+    Cancel();
+    iProperty.Close();
+
+    RUBY_DEBUG0( "CPropertyHandler::~CPropertyHandler EXIT" );
+    }
+
+
+// ---------------------------------------------------------
+// CPropertyHandler::DoCancel   
+// Cancel the request to receive events
+// ---------------------------------------------------------
+//
+void CPropertyHandler::DoCancel()
+    {
+    RUBY_DEBUG0( "CPropertyHandler::DoCancel START" );
+    
+    iProperty.Cancel();
+    
+    RUBY_DEBUG0( "CPropertyHandler::DoCancel EXIT" );
+    }
+
+
+// ---------------------------------------------------------
+// CPropertyHandler::RunL
+// Handle a change event.
+// ---------------------------------------------------------
+//
+void CPropertyHandler::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CPropertyHandler::RunL" ); 
+    
+    // Resubscribe before processing new value to prevent missing updates
+    iProperty.Subscribe( iStatus );
+    SetActive();
+
+    if ( iRequestIssued && iRecogObserver )
+        {
+        RUBY_DEBUG0( "CPropertyHandler::RunL - Call HandlePropertyValueChange for RecogObserver" );
+        
+        TInt value = 0;
+        iProperty.Get( value );
+        
+        iRecogObserver->HandlePropertyValueChange( value );
+        }
+    else
+        {
+        RUBY_DEBUG0( "CPropertyHandler::RunL - Pass" );
+        }
+             
+    }
+
+// -----------------------------------------------------------------------------
+// CPropertyHandler::Register
+// -----------------------------------------------------------------------------
+//
+void CPropertyHandler::Register( CVoiceRecognitionDialogImpl* aRecogObserver )
+    {
+    RUBY_DEBUG0( "CPropertyHandler::Register START" );
+
+    if ( aRecogObserver )
+        {
+        iRecogObserver = aRecogObserver;
+        }
+        
+    RUBY_DEBUG0( "CPropertyHandler::Register EXIT" );        
+    }
+
+// -----------------------------------------------------------------------------
+// CPropertyHandler::DeRegister
+// -----------------------------------------------------------------------------
+//
+void CPropertyHandler::DeRegister( CVoiceRecognitionDialogImpl* aRecogObserver )
+    {
+    RUBY_DEBUG0( "CPropertyHandler::DeRegister START" );
+
+    if ( aRecogObserver )
+        {
+        iRecogObserver = NULL;
+        }
+        
+    RUBY_DEBUG0( "CPropertyHandler::DeRegister EXIT" );
+    }    
+    
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicrecordstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <avkon.rsg>
+#include <AknIconUtils.h>
+#include <StringLoader.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuicstate.h"
+#include "vuicrecordstate.h"
+#include "vuictutorialstate.h"
+#include "vuicabortstate.h"
+#include "vuicerrorstate.h"
+
+#include "vuicdatastorage.h"
+#include "vuicuimodel.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuicglobalprogressdialog.h"
+
+#include "vuivoiceicondefs.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CRecordState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRecordState* CRecordState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CRecordState* self = new (ELeave) CRecordState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CRecordState::~CRecordState()
+    {
+    RUBY_DEBUG0( "CRecordState::~CRecordState START" );
+    
+    // If recording has not ended we should cancel recording
+    if ( iInternalState != EFinished )
+        {
+        DataStorage().RecognitionHandler()->Cancel();
+        }        
+
+    delete iProgressDialog;
+    
+    RUBY_DEBUG0( "CRecordState::~CRecordState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CRecordState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CRecordState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CRecordState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+                iInternalState = ERecording;
+                nextState = this;
+                }
+            else if ( iInternalState == ERecording )
+                {
+                iInternalState = EStopped;
+                }
+            else if ( iInternalState == EStopped )
+                {
+                iInternalState = EFinished;
+                nextState = CTutorialState::NewL( DataStorage(), UiModel() );
+                }
+            break;
+            
+        case KErrNoMatch:
+        case KErrRecogFailed:
+        case KErrNoSpeech:
+        case KErrTooEarly:
+        case KErrTooLong:
+        case KErrTooShort:
+        case KErrGeneral:
+        
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+            
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+        
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CRecordState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CRecordState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CRecordState::ExecuteL" );
+    
+    if ( iInternalState == ENotStarted )
+        {
+        // Show the "Speak now" prompt and start the voice recording
+        MNssRecognitionHandler* handler = DataStorage().RecognitionHandler();
+        User::LeaveIfError( handler->Recognize( DataStorage().VoiceRecognitionImpl() ) );
+    
+        iProgressDialog = CGlobalProgressDialog::NewL();
+   
+        iProgressDialog->SetImageL( AknIconUtils::AvkonIconFileName(),
+                                    EMbmAvkonQgn_note_voice,
+                                    EMbmAvkonQgn_note_voice_mask );
+                                    
+        iProgressDialog->SetSkinIds( KAknsIIDQgnNoteVoice, EMbmAvkonQgn_note_voice,
+                                     EMbmAvkonQgn_note_voice_mask, KAknsIIDQgnStatBtBlank );
+
+        iProgressDialog->RegisterForKeyCallback( DataStorage().VoiceRecognitionImpl() );     
+        
+        iProgressDialog->SetSecondaryDisplayDataL( SecondaryDisplay::KCatVoiceUi,
+                                                   SecondaryDisplay::ECmdShowVoiceSpeakNowNote,
+                                                   NULL );
+                                                   
+        BringToForeground();
+
+        HBufC* speakMsg = StringLoader::LoadLC( R_TEXT_VOICE_SPEAK_NOW );
+        iProgressDialog->ShowProgressDialogL( *speakMsg, KNullDesC, R_AVKON_SOFTKEYS_QUIT );
+        CleanupStack::PopAndDestroy( speakMsg );
+        
+        iInternalState = EStarted;
+        }
+    else if ( iInternalState == ERecording )
+        {
+        StartTimerL( *this, KRecogDelay, KKRecogInterval * iTModel.iHundreths );
+        }
+    }
+
+// ---------------------------------------------------------
+// CRecordState::CRecordState
+// ---------------------------------------------------------
+//              
+CRecordState::CRecordState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted ),
+   iTickCount( 0 )
+    {    
+    iTModel.iFinalValue = KRecogFinal;
+    iTModel.iHundreths = KRecogInterval;
+    iTModel.iIncrement = KRecogIncrement;
+    iTModel.iRunning = EFalse;
+    }
+    
+// ---------------------------------------------------------
+// CRecordState::DoTimedEventL
+// ---------------------------------------------------------
+//
+void CRecordState::DoTimedEventL()
+   {
+   if ( ( ++iTickCount != iTModel.iFinalValue + 1 ) && iProgressDialog )
+      {
+      iProgressDialog->UpdateProgressDialogL( iTickCount, iTModel.iFinalValue ); 
+      }
+   else
+      {
+      StopTimer();
+      }
+   }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicresultsstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,778 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <ccafactory.h>
+#include <mccaparameter.h>
+#include <mccaconnection.h>
+
+#include <vasmbasepbkhandler.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicstate.h"
+#include "vuicresultsstate.h"
+#include "vuicplaystate.h"
+#include "vuiccontactresultsstate.h"
+#include "vuicabortstate.h"
+#include "vuicerrorstate.h"
+#include "vuicexitstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuicnbestlistdialog.h"
+#include "vuicttsplayer.h"
+#include "vuivoiceicondefs.h"
+
+#include <CVPbkContactStoreUriArray.h>
+#include <CVPbkContactManager.h>
+#include <VPbkContactStoreUris.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <CVPbkContactIdConverter.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkContactStoreList.h>
+
+#include "rubydebug.h"
+
+_LIT( KTab, "\t" );
+    
+// -----------------------------------------------------------------------------
+// CResultsState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CResultsState* CResultsState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CResultsState* self = new (ELeave) CResultsState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CResultsState::~CResultsState()
+    {
+    RUBY_DEBUG0( "CResultsState::~CResultsState START" );
+    
+    DataStorage().TtsPlayer()->Stop();
+    
+    delete iNBestListDialog;
+    
+    delete iTagList; // Only copies of pointers, do not reset and destroy
+    
+    if ( iConnection )
+        {
+        iConnection->Close();
+        }
+    
+    RUBY_DEBUG0( "CResultsState::~CResultsState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CResultsState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CResultsState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+                iInternalState = EInitialized;
+                }
+            else if ( iInternalState == EInitialized )
+                {
+                iInternalState = ECompleted;
+                nextState = this;
+                }                
+            break;
+                    
+        case EVoiceTagSoftKeySelect:
+            
+            if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext )
+                {
+                nextState = CContactResultsState::NewL( DataStorage(), UiModel() );
+                }
+            else
+                {
+                nextState = CPlayState::NewL( DataStorage(), UiModel() );
+                }
+            break;
+            
+        case EVoiceTagSoftKeyDirectSelect:
+
+            nextState = CPlayState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case EAknSoftkeyQuit:
+        case EAknSoftkeyNo:
+        case EVoiceTagSoftKeyQuit:
+        case EEndCallKeypress:
+        case ELongKeypress:
+
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case EShortKeypress:
+        case EUpKeypress:
+        case EDownKeypress:
+        case ESelectKeypress:
+        case EDirectSelectKeypress:
+        case EOptionsKeypress:
+        case EOpenKeypress:
+        case EDragKeypress:
+        case EScrollKeypress:
+        
+            iKeypress = aEvent;
+            nextState = this;
+            break;
+        
+        case EAknSoftkeyOpen:
+        
+            nextState = CExitState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        default:
+            
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CResultsState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CResultsState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::ExecuteL" );
+
+    if ( HandleKeypressL() )
+        {
+        iKeypress = ENoKeypress;
+        }
+    else if ( iInternalState == ECompleted )
+        {
+        DataStorage().TtsPlayer()->Stop();
+        }
+    else
+        {
+        TInt returnValue = KErrNoResults;
+        
+        if ( DataStorage().CompleteTagList()->Count() != KErrNone )
+            {
+            iInternalState = EStarted;
+            
+            CreateContactArrayL();
+            
+            if ( iTagList->Count() != KErrNone )
+                {
+                iNBestListDialog = CNBestListDialog::NewL();
+                
+                CDesC16ArrayFlat* items = NULL;
+                TRAPD( error, items = CreateItemsArrayL() );
+                
+                if ( !error )
+                    {
+                    iNBestListDialog->CreateNBestListPopupLC( items );
+                    iNBestListDialog->SetSoftkeysL( R_SOFTKEYS_OPTIONS_QUIT__SELECT );
+                
+                    CheckOptionsCommands();
+                    PlaySelectedNameL();
+                    BringToForeground();
+                    
+                    // If automatic confirmation or device lock is on then start the timer
+                    if ( DataStorage().VerificationMode() == EAutomatic ||
+                         DataStorage().DeviceLockMode() )
+                        {
+                        StartTimerL( *this, KTimeoutMicroseconds, KTimeoutMicroseconds );
+                        }
+    
+                    iNBestListDialog->RegisterForKeyCallback( DataStorage().VoiceRecognitionImpl() );        
+                    returnValue = iNBestListDialog->ShowNBestListPopupL(); // Pops things pushed in CreateNBestListPopupLC
+                    RUBY_DEBUG1( "CResultsState::ExecuteL - N-Best list returns [%d]", returnValue );
+                    }
+                else if ( error != KErrNotFound )
+                    {
+                    User::Leave( error );
+                    }
+                }
+            }
+        
+        if ( returnValue != KErrNone )
+            {
+            iInternalState = ECompleted;
+            
+            SelectTag();
+            
+            HandleEventL( returnValue );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CResultsState::CResultsState
+// ---------------------------------------------------------
+//     
+void CResultsState::CCASimpleNotifyL( TNotifyType /*aType*/, TInt /*aReason*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::CCASimpleNotifyL" );
+        
+    HandleEventL( EAknSoftkeyOpen );
+    }
+
+// ---------------------------------------------------------
+// CResultsState::CResultsState
+// ---------------------------------------------------------
+//              
+CResultsState::CResultsState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iKeypress( ENoKeypress ),
+   iInternalState( ENotStarted )
+    {
+    }
+
+// ---------------------------------------------------------
+// CResultsState::ConstructL
+// ---------------------------------------------------------
+//           
+void CResultsState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::ConstructL" );
+    
+    CState::ConstructL();
+    
+    DataStorage().SetAdaptationEnabled( ETrue );
+    }
+    
+// ---------------------------------------------------------
+// CResultsState::DoTimedEventL
+// ---------------------------------------------------------
+//
+void CResultsState::DoTimedEventL()
+   {
+   RUBY_DEBUG_BLOCK( "CResultsState::DoTimedEventL" );
+   
+   SelectTag();
+   
+   HandleEventL( EVoiceTagSoftKeySelect );
+   }
+    
+// ---------------------------------------------------------
+// CResultsState::HandleKeypressL
+// ---------------------------------------------------------
+//           
+TBool CResultsState::HandleKeypressL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::HandleKeypressL" );
+    
+    TBool handled = ETrue;
+    
+    if ( iKeypress == EShortKeypress )
+        {
+        CDesC16ArrayFlat* items = NULL;
+        
+        if ( UpdateContactArray() )
+            {
+            items = CreateItemsArrayL();
+            }
+        
+        if ( iNBestListDialog->HandleShortKeypressL( items ) )
+            {
+            iInternalState = EStarted;
+        
+            CheckOptionsCommands();
+            PlaySelectedNameL();
+            
+            // If automatic confirmation or device lock is on then start the timer
+            if ( DataStorage().VerificationMode() == EAutomatic ||
+                 DataStorage().DeviceLockMode() )
+                {
+                StartTimerL( *this, KTimeoutMicroseconds, KTimeoutMicroseconds );
+                }
+            }
+        else
+            {
+            HandleEventL( KErrNoResults );
+            }
+        }
+    else if ( iKeypress == EUpKeypress || iKeypress == EDownKeypress ||
+              iKeypress == EDragKeypress )
+        {
+        iInternalState = EStarted;
+        
+        CheckOptionsCommands();
+        PlaySelectedNameL();
+        
+        // If automatic confirmation or device lock is on then start the timer
+        if ( DataStorage().VerificationMode() == EAutomatic ||
+                DataStorage().DeviceLockMode() )
+            {
+            StartTimerL( *this, KTimeoutMicroseconds, KTimeoutMicroseconds );
+            }
+        }
+    else if ( iKeypress == EScrollKeypress )
+        {
+        StopTimer();
+        }
+    else if ( iKeypress == ESelectKeypress )
+        {        
+        if ( !DataStorage().Tag() )
+            {
+            SelectTag();
+    
+            HandleEventL( EVoiceTagSoftKeySelect );
+            }
+        }
+    else if ( iKeypress == EDirectSelectKeypress )
+        {        
+        if ( !DataStorage().Tag() )
+            {
+            SelectTag();
+    
+            HandleEventL( EVoiceTagSoftKeyDirectSelect );
+            }
+        }
+    else if ( iKeypress == EOptionsKeypress )
+        {        
+        StopTimer();
+        DataStorage().SetVerificationMode( EManual );
+        }
+    else if ( iKeypress == EOpenKeypress )
+        {       
+        OpenPhonebookContactL();
+        }
+    else
+        {
+        handled = EFalse;
+        }
+    
+    return handled;
+    }
+    
+// ---------------------------------------------------------------------------
+// CResultsState::PlaySelectedNameL
+// ---------------------------------------------------------------------------
+//
+void CResultsState::PlaySelectedNameL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::PlaySelectedNameL" );
+
+    // if TTS is used
+    if ( ( DataStorage().SynthesizerMode() != KErrNone ||
+         DataStorage().DeviceLockMode() ) &&
+         iTagList->Count() > 0 )
+        {
+        TInt index = iNBestListDialog->SelectedIndex();
+        HBufC* text = NULL;
+                    
+        if ( iTagList->At( index )->Context()->ContextName() == KVoiceDialContext )
+            {
+            text = iTagList->At( index )->SpeechItem()->PartialTextL( KNameTrainingIndex );
+            }
+        else
+            {
+            text = HBufC::NewL( 0 );
+            }
+
+        CleanupStack::PushL( text );        
+                
+        DataStorage().TtsPlayer()->PlayL( iTagList->At( index )->SpeechItem()->Text(), 0,
+                                          iTagList->At( index )->SpeechItem()->Text().Length(),
+                                          *text );
+
+        CleanupStack::PopAndDestroy( text );
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CResultsState::CheckOptionsCommands
+// ---------------------------------------------------------------------------
+//
+void CResultsState::CheckOptionsCommands()
+    {
+    RUBY_DEBUG0( "CResultsState::CheckOptionsCommands START" );
+
+    if ( iTagList->Count() > 0 )
+        {
+        TBool hidden = ETrue;
+        
+        TInt index = iNBestListDialog->SelectedIndex();
+        if ( iTagList->At( index )->Context()->ContextName() == KVoiceDialContext )
+            {
+            hidden = EFalse;
+            }
+        iNBestListDialog->SetCommandsHidden( hidden );
+        }
+    RUBY_DEBUG0( "CResultsState::CheckOptionsCommands EXIT" );
+    }
+    
+// ---------------------------------------------------------------------------
+// CResultsState::CreateContactArrayL
+// ---------------------------------------------------------------------------
+//
+void CResultsState::CreateContactArrayL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::CreateContactArrayL" );
+    
+    CArrayPtrFlat<MNssTag>* completeTagList = DataStorage().CompleteTagList();
+    
+    iTagList = new ( ELeave ) CArrayPtrFlat<MNssTag>( KSindMaxResults );
+    
+    // Add commands to taglist
+    for ( TInt i = 0; i < completeTagList->Count() && iTagList->Count() < KSindMaxResults; ++i )
+        {
+        MNssTag* tag = completeTagList->At( i );
+        
+        if ( tag->Context()->ContextName() == KVoiceDialContext &&
+             ( !DataStorage().DeviceLockMode() || tag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) )
+            {   
+            if ( !CheckIfAlreadyAdded( tag ) )
+                {
+                iTagList->AppendL( tag );            
+                }
+            }
+        else if ( !DataStorage().DeviceLockMode() )
+            {
+            iTagList->AppendL( tag );
+            }
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CResultsState::UpdateContactArray
+// ---------------------------------------------------------------------------
+//
+TBool CResultsState::UpdateContactArray()
+    {
+    RUBY_DEBUG0( "CResultsState::UpdateContactArray START" );
+    
+    MNssTag* tag = iTagList->At( iNBestListDialog->SelectedIndex() );
+        
+    TBool currentTagFound = EFalse;
+    TBool updated = EFalse;
+                        
+    if ( tag->Context()->ContextName() == KVoiceDialContext )
+        {  
+        for ( TInt i = 0; i < DataStorage().CompleteTagList()->Count(); ++i )
+            {
+            MNssTag* newTag = DataStorage().CompleteTagList()->At( i );
+            
+            if ( newTag->Context()->ContextName() == KVoiceDialContext &&
+                 ( !DataStorage().DeviceLockMode() || newTag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) &&
+                 tag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) ==
+                 newTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) )
+                {
+                if ( currentTagFound )
+                    {
+                    iTagList->At( iNBestListDialog->SelectedIndex() ) = newTag;
+                    updated = ETrue;
+                    break;
+                    }   
+                else if ( tag->SpeechItem()->RawText() == newTag->SpeechItem()->RawText() )
+                    {
+                    currentTagFound = ETrue;
+                    }
+                }
+            }
+        }
+        
+    RUBY_DEBUG0( "CResultsState::UpdateContactArray EXIT" );
+        
+    return updated;
+    }
+    
+// ---------------------------------------------------------
+// CResultsState::CheckIfAlreadyAdded
+// ---------------------------------------------------------
+//    
+TBool CResultsState::CheckIfAlreadyAdded( MNssTag* aTag )
+    {
+    RUBY_DEBUG0( "CResultsState::CheckIfAlreadyAdded START" );
+    
+    TBool returnValue = EFalse;
+
+    for ( TInt i = 0; i < iTagList->Count(); ++i )
+        {
+        if ( aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) ==
+             iTagList->At( i )->RRD()->IntArray()->At( KVasContactIdRrdLocation ) )
+            {
+            returnValue = ETrue;
+            
+            break;
+            }
+        }
+    
+    RUBY_DEBUG0( "CResultsState::CheckIfAlreadyAdded EXIT" );
+    
+    return returnValue;
+    }
+    
+// ---------------------------------------------------------------------------
+// CResultsState::CreateItemsArrayLC
+// ---------------------------------------------------------------------------
+//    
+CDesC16ArrayFlat* CResultsState::CreateItemsArrayL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::CreateItemsArrayL" );
+    
+    TInt count = iTagList->Count();
+            
+    CDesC16ArrayFlat* items = new ( ELeave ) CDesC16ArrayFlat( KSindMaxResults );
+    CleanupStack::PushL( items );
+
+    TName buffer;
+    
+    for ( TInt i = 0; i < count; ++i )
+        {
+        MNssTag* tag = iTagList->At( i );
+        
+        if ( tag->Context()->ContextName() == KVoiceDialContext )
+            {            
+            FillDialContextBufferL( tag, buffer );
+            
+            items->AppendL( buffer );
+            }
+        else
+            {                      
+            FillCommandContextBuffer( tag, buffer );
+            
+            items->AppendL( buffer );
+            }
+        }
+        
+    CleanupStack::Pop( items );
+    
+    return items;
+    }
+
+// ---------------------------------------------------------
+// CResultsState::FillDialContextBufferL
+// ---------------------------------------------------------
+//
+void CResultsState::FillDialContextBufferL( MNssTag* aTag, TDes& aBuffer )
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::FillDialContextBufferL" );
+    
+    TPtrC type = KNullDesC();
+    
+    DataStorage().PbkHandler()->FindContactFieldL( aTag );
+        
+    type.Set( GetContactIconType( DataStorage().PbkHandler()->FieldTypeL() ) );
+
+    // Get the actual name only        
+    HBufC* name = aTag->SpeechItem()->PartialTextL( KNameTrainingIndex );
+    CleanupStack::PushL( name );
+
+    aBuffer.Zero();
+    aBuffer.Append( type );
+    aBuffer.Append( KTab );
+    aBuffer.Append( *name );
+    aBuffer.Append( KTab );
+    
+    HBufC* label = NULL;
+        
+    TRAPD( error, label = aTag->SpeechItem()->PartialTextL( KExtensionTrainingIndex ) );
+    if ( error == KErrNone || error == KErrNotFound )
+        {
+        // If there is no extension then the phonebook label is shown
+        if ( label )
+            {
+            CleanupStack::PushL( label );
+    
+            aBuffer.Append( *label );
+    
+            CleanupStack::PopAndDestroy( label );
+            }
+        else
+            {
+            aBuffer.Append( DataStorage().PbkHandler()->LabelL() );
+            }
+        }
+    else
+        {
+        User::Leave( error );
+        }
+
+    CleanupStack::PopAndDestroy( name );
+    }
+
+// ---------------------------------------------------------
+// CResultsState::FillCommandContextBuffer
+// ---------------------------------------------------------
+//    
+void CResultsState::FillCommandContextBuffer( MNssTag* aTag, TDes& aBuffer )
+    {
+    RUBY_DEBUG0( "CResultsState::FillCommandContextBuffer START" );
+    
+    aBuffer.Zero();
+    
+    if ( aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) >= KProfileValue )
+        {
+        aBuffer.Append( KIconProfile );
+        }
+    else
+        {
+        aBuffer.Append( KIconApplication );
+        }
+            
+    aBuffer.Append( KTab );
+    aBuffer.Append( aTag->SpeechItem()->Text() );
+    
+    RUBY_DEBUG0( "CResultsState::FillCommandContextBuffer EXIT" );
+    }
+        
+// ---------------------------------------------------------
+// CResultsState::GetContactIconType
+// ---------------------------------------------------------
+//
+TPtrC CResultsState::GetContactIconType( TFieldType aFieldType )
+    {
+    RUBY_DEBUG0( "CResultsState::GetContactIconType START" );
+    
+    TPtrC type;
+    // select a phone type
+    if ( aFieldType == KUidContactFieldVCardMapVOICE )
+        {
+        type.Set( KIconPhone );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapCELL )
+        {
+        type.Set( KIconMobile );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapFAX )
+        {
+        type.Set( KIconFax );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapEMAILINTERNET )
+        {
+        type.Set( KIconEmail );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapVIDEO )
+        {
+        type.Set( KIconVideo );
+        }
+    else if ( aFieldType == KUidContactFieldVCardMapVOIP )
+        {
+        type.Set( KIconVoip );
+        }
+    else
+        {
+        type.Set( KIconBlank );
+        }
+
+    RUBY_DEBUG0( "CResultsState::GetContactIconType EXIT" );
+    
+    return type;
+    }
+    
+// ---------------------------------------------------------
+// CResultsState::SelectTag
+// ---------------------------------------------------------
+//   
+void CResultsState::SelectTag()
+    {
+    RUBY_DEBUG0( "CResultsState::SelectTag START" );
+    
+    if ( iTagList && iTagList->Count() > 0 )
+        {
+        DataStorage().SetTag( iTagList->At( iNBestListDialog->SelectedIndex() ), ETrue );
+       
+        // Remove selected item from the complete taglist
+        for ( TInt i = 0; i < DataStorage().CompleteTagList()->Count(); ++i )
+            {
+            if ( DataStorage().CompleteTagList()->At( i ) ==
+                 DataStorage().Tag() )
+                {
+                DataStorage().CompleteTagList()->Delete( i );
+                break;
+                }
+            }
+        }
+        
+    RUBY_DEBUG0( "CResultsState::SelectTag EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CResultsState::OpenPhonebookContactL
+// ---------------------------------------------------------
+//      
+void CResultsState::OpenPhonebookContactL()
+    {
+    RUBY_DEBUG_BLOCK( "CResultsState::OpenPhonebookContactL" );
+    
+    SelectTag();
+    
+    if ( iConnection )
+        {
+        iConnection->Close();
+        }
+    iConnection = TCCAFactory::NewConnectionL();
+
+    MCCAParameter* parameter = TCCAFactory::NewParameterL();
+    CleanupClosePushL( *parameter );
+
+    parameter->SetConnectionFlag( MCCAParameter::ENormal );
+    parameter->SetContactDataFlag( MCCAParameter::EContactLink );
+        
+    // Create a Contact Manager and bind it with the default contact database 
+    CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL();
+    CleanupStack::PushL( uriArray );
+    
+    TVPbkContactStoreUriPtr uri( VPbkContactStoreUris::DefaultCntDbUri() );
+    uriArray->AppendL( uri );  
+    
+    CVPbkContactManager* contactManager = CVPbkContactManager::NewL(*uriArray);
+    CleanupStack::PushL( contactManager );
+    
+    // Find Contacts Model store URI from the contact manager (copied from Phonebook app)
+    MVPbkContactStore* defaultStore = contactManager->ContactStoresL().Find( uri );
+    User::LeaveIfNull( defaultStore );
+    
+    // Create a ContactIdConverter object for the ContactId-to-ContactLink conversion 
+    CVPbkContactIdConverter* idConverter = CVPbkContactIdConverter::NewL( *defaultStore );
+    CleanupStack::PushL( idConverter );
+    
+    MVPbkContactLink* link = idConverter->IdentifierToLinkLC(
+            DataStorage().Tag()->RRD()->IntArray()->At( KVasContactIdRrdLocation ));
+    
+    HBufC8*  link8  = link->PackLC(); 
+    HBufC16* link16 = HBufC16::NewLC( link8->Length() );
+    link16->Des().Copy( *link8 );
+
+    parameter->SetContactDataL( link16->Des() );
+
+    iConnection->LaunchAppL( *parameter, this );
+    
+    CleanupStack::PopAndDestroy(6,uriArray);    
+    CleanupStack::Pop();//parameter
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <apgtask.h>
+#include <coemain.h>
+
+#include "vuicstate.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+const TUid KVoiceUiUid = { 0x101F8543 };
+    
+// Destructor       
+CState::~CState()
+    {
+    RUBY_DEBUG0( "CState::~CState START" );
+    
+    StopTimer();
+    
+    RUBY_DEBUG0( "CState::~CState EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CState::CState
+// ---------------------------------------------------------
+//              
+CState::CState(  CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : iDataStorage( &aDataStorage ), iUiModel( &aUiModel )    
+    {
+    }
+    
+// ---------------------------------------------------------
+// CState::ConstructL
+// ---------------------------------------------------------
+//           
+void CState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CState::ConstructL" );
+    }    
+
+// ---------------------------------------------------------
+// CState::DataStorage
+// ---------------------------------------------------------
+//     
+CDataStorage& CState::DataStorage() const
+    {
+    return *iDataStorage;
+    }
+
+// ---------------------------------------------------------
+// CState::UiModel
+// ---------------------------------------------------------
+//       
+CUiModel& CState::UiModel() const
+    {
+    return *iUiModel;
+    }
+    
+// ---------------------------------------------------------
+// CState::StartTimerL
+// Starts timer
+// ---------------------------------------------------------
+//
+void CState::StartTimerL( CState& aEventHandler, TInt aDelay, TInt aInterval )
+    {
+    RUBY_DEBUG0( "CState::StartTimerL START" );
+
+    StopTimer();
+
+    iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+    TTimeIntervalMicroSeconds32 delay( aDelay );
+    TTimeIntervalMicroSeconds32 interval( aInterval );
+    iTimer->Start( delay, interval, TCallBack( OnTimedEvent, &aEventHandler ) );
+    
+    RUBY_DEBUG0( "CState::StartTimerL EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CState::StopTimer
+// Stops timer
+// ---------------------------------------------------------
+//
+void CState::StopTimer()
+    {
+    RUBY_DEBUG0( "CState::StopTimer START" );
+
+    if ( iTimer )
+        {
+        if ( iTimer->IsActive() )
+            {
+            iTimer->Cancel();
+            }
+        delete iTimer;
+        iTimer = NULL;
+        }
+        
+    RUBY_DEBUG0( "CState::StopTimer EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CState::OnTimedEvent
+// ---------------------------------------------------------
+//
+TInt CState::OnTimedEvent( TAny* aObject )
+   {
+   TRAP_IGNORE( ( (CState*) aObject )->DoTimedEventL() );
+   return KErrNone;
+   }
+   
+// ---------------------------------------------------------
+// CState::DoTimedEventL
+// ---------------------------------------------------------
+//
+void CState::DoTimedEventL()
+   {   
+   }
+
+// ---------------------------------------------------------
+// CState::BringToForeground
+// ---------------------------------------------------------
+//   
+void CState::BringToForeground()
+    {
+    TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
+    TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUid );
+    
+    if ( apaTask.Exists() )
+        {
+        apaTask.BringToForeground();
+        }
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuictoneplayer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,308 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles the tone playing for the VoiceUIRecognition
+*
+*/
+
+
+// INCLUDE FILES
+#include <aknsoundsystem.h>
+#include <aknappui.h>
+#include <AccessoryServer.h>        //RAccessoryServer
+#include <AccessoryConnection.h>    //RAccessoryConnection
+
+#include <centralrepository.h>
+
+#include <StringLoader.h>
+#include <AudioPreference.h>
+
+#include <srsfdomaincrkeys.h>
+
+#include <vuivoicerecognition.rsg>
+#include "vuictoneplayer.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+
+// Maximum value of the volume setting in Central Repository
+const TInt KMaxRepositoryVolume = 10;
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTonePlayer* CTonePlayer::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CTonePlayer* CTonePlayer::NewL()
+    {
+    CTonePlayer* self = new (ELeave) CTonePlayer;    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// Destructor
+CTonePlayer::~CTonePlayer()
+    {
+    RUBY_DEBUG0( "CTonePlayer::~CTonePlayer START" );
+
+    if ( iAudioPlayer )
+        {
+        iAudioPlayer->Close();
+        delete iAudioPlayer;
+        }
+
+    delete iStartSound;
+    delete iConfirmationSound;
+    delete iBtStartSound;
+
+    iObserver = NULL;
+    
+    RUBY_DEBUG0( "CTonePlayer::~CTonePlayer EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CTonePlayer::CTonePlayer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTonePlayer::CTonePlayer()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTonePlayer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTonePlayer::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CTonePlayer::ConstructL" );
+
+    iAudioPlayer = CMdaAudioPlayerUtility::NewL( *this,
+                                                 KAudioPriorityVoiceDial, 
+                                                 TMdaPriorityPreference( KAudioPrefVoiceStarting ) );
+
+    iVolume = KErrGeneral;
+    
+    CRepository* client = CRepository::NewLC( KCRUidSRSFSettings );
+    client->Get( KSRSFPlaybackVolume, iVolume );
+    CleanupStack::PopAndDestroy( client );
+
+    iStartSound = StringLoader::LoadL( R_VOICE_START_SOUND_PATH );
+    iConfirmationSound = StringLoader::LoadL( R_VOICE_CONFIRMATION_SOUND_PATH );
+    iBtStartSound = StringLoader::LoadL( R_VOICE_BT_START_SOUND_PATH );
+    iBTAcc = EFalse;
+    
+    ChekcAccesoryStatusL();
+    }
+  
+ // ---------------------------------------------------------
+// CTonePlayer::RegisterObserver
+// Sets the observer
+// ---------------------------------------------------------
+//  
+void CTonePlayer::RegisterObserver( MMdaAudioPlayerCallback* aObserver )
+    {
+    RUBY_DEBUG0( "CTonePlayer::RegisterObserver START" );
+    
+    iObserver = aObserver;
+    
+    RUBY_DEBUG0( "CTonePlayer::RegisterObserver EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CTonePlayer::InitToneL
+// Perform initialization for Playing the appropriate tone
+// ---------------------------------------------------------
+//
+void CTonePlayer::InitToneL( TInt aSid )
+   {
+    RUBY_DEBUG_BLOCK( "CTonePlayer::PlayToneInitL" );
+    
+    iAudioPlayer->Stop();
+    iAudioPlayer->Close();
+
+    if ( aSid == EAvkonSIDNameDiallerStartTone )
+        {
+        RUBY_DEBUG0( "CTonePlayer::InitToneL - case: EAvkonSIDNameDiallerStartTone" );
+        TInt err = KErrNone;
+        if ( iBTAcc )
+            {
+            TRAP( err, iAudioPlayer->OpenFileL( *iBtStartSound ) );
+            }
+        else
+            {
+            TRAP( err, iAudioPlayer->OpenFileL( *iStartSound ) );
+            }
+        if ( err )
+            {
+            RUBY_ERROR1( "CTonePlayer::InitToneL - err [%d]", err );
+                    
+            // Cannot play sound, but observer still needs to be notified
+            iObserver->MapcInitComplete( err, 0 );
+            }
+        }
+    else if ( aSid == EAvkonSIDConfirmationTone )
+        {
+        RUBY_DEBUG0( "CTonePlayer::InitToneL - case: EAvkonSIDConfirmationTone" );
+
+        TRAPD( err, iAudioPlayer->OpenFileL( *iConfirmationSound ) );
+        if ( err )
+            {
+            RUBY_ERROR1( "CTonePlayer::InitToneL - err [%d]", err );
+                    
+            // Cannot play sound, but observer still needs to be notified
+            iObserver->MapcInitComplete( err, 0 );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CTonePlayer::PlayTone
+// Plays the appropriate tone
+// ---------------------------------------------------------
+//
+void CTonePlayer::PlayTone( TInt aSid )
+    {
+    RUBY_DEBUG0( "CTonePlayer::PlayTone START" );
+    
+    switch ( aSid )
+        {
+        case EAvkonSIDNameDiallerStartTone:
+        case EAvkonSIDConfirmationTone:
+            {
+            iAudioPlayer->SetVolume( ScaledVolume() );
+            iAudioPlayer->Play();
+            break;
+            }
+            
+        case EAvkonSIDNameDiallerAbortTone:
+        case EAvkonSIDNameDiallerErrorTone:
+            {
+            if ( iAvkonAppUiBase )
+                {               
+                iAudioPlayer->Stop();
+                iAudioPlayer->Close();
+                
+                iAvkonAppUiBase->KeySounds()->PlaySound( aSid );
+                }
+
+            MapcPlayComplete( KErrNone );
+            break;
+            }
+        
+        default:
+            break;
+        }
+    
+    RUBY_DEBUG0( "CTonePlayer::PlayTone EXIT" );
+    }
+
+// ---------------------------------------------------------------------------
+// CTonePlayer::MapcInitComplete
+// CMdaAudioPlayerUtility initialization complete
+// ---------------------------------------------------------------------------
+//
+void CTonePlayer::MapcInitComplete( TInt aError,
+                                    const TTimeIntervalMicroSeconds& aDuration )
+    {
+    RUBY_DEBUG0( "CTonePlayer::MapcInitComplete START" );
+
+    iObserver->MapcInitComplete( aError, aDuration );
+    
+    RUBY_DEBUG0( "CTonePlayer::MapcInitComplete EXIT" );
+    }
+
+// ---------------------------------------------------------------------------
+// CTonePlayer::MapcPlayComplete
+// Playback complete, notify observer
+// ---------------------------------------------------------------------------
+//
+void CTonePlayer::MapcPlayComplete( TInt aError )
+    {
+    RUBY_DEBUG0( "CTonePlayer::MapcPlayComplete START" );
+
+    iAudioPlayer->Stop();
+    iAudioPlayer->Close();
+    iObserver->MapcPlayComplete( aError );
+
+    RUBY_DEBUG0( "CTonePlayer::MapcPlayComplete EXIT" );
+    }
+
+// ---------------------------------------------------------------------------
+// CTonePlayer::ScaledVolume
+// ---------------------------------------------------------------------------
+//    
+TInt CTonePlayer::ScaledVolume()
+    {
+    TInt volume = iAudioPlayer->MaxVolume();
+    if ( iVolume >= 0 )
+        {
+        // Scale value
+        volume = ( iVolume * volume ) / KMaxRepositoryVolume;
+        }
+        
+    return volume;
+    }
+
+// ---------------------------------------------------------
+// CTonePlayer::ChekcAccesoryStatus
+// ---------------------------------------------------------
+//  
+void CTonePlayer::ChekcAccesoryStatusL()
+    {    
+    // Connection to the accessory server
+    RAccessoryServer accessoryServer;    
+    // Subsession for server
+    RAccessoryConnection accessoryConnection;    
+    //Generic ID array for accessories
+    TAccPolGenericIDArray accessoryArray;
+    
+    TInt err = KErrNone;
+    //connect to accessory server
+    err = accessoryServer.Connect();
+    if ( err == KErrNone )
+        {
+        //create subsession to accessory server
+        err = accessoryConnection.CreateSubSession( accessoryServer );
+        if ( err == KErrNone )
+            {
+            accessoryConnection.GetAccessoryConnectionStatus( accessoryArray );
+            
+            TAccPolGenericID genId;
+            for ( TInt i = 0; i < accessoryArray.Count(); i++ )
+                {
+                genId = accessoryArray.GetGenericIDL( i );
+
+                if ( genId.PhysicalConnectionCaps( KPCBluetooth ) && 
+                    ( genId.DeviceTypeCaps( KDTHeadset ) || genId.DeviceTypeCaps( KDTCarKit ) ) )
+                    {
+                    iBTAcc = ETrue;
+                    }
+                }
+            }
+        }
+
+    accessoryConnection.CloseSubSession();
+    accessoryServer.Close();
+    }
+
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicttsplayer.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,294 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "vuicttsplayer.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+const TInt KMaxBasicSegments = 3;
+const TInt KMaxEnhancedSegments = 3;
+    
+// -----------------------------------------------------------------------------
+// CTTSPlayer::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTTSPlayer* CTTSPlayer::NewL( MTtsClientUtilityObserver* aObserver )
+    {
+    CTTSPlayer* self = new (ELeave) CTTSPlayer( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }   
+   
+// Destructor       
+CTTSPlayer::~CTTSPlayer()
+    {
+    RUBY_DEBUG0( "CTTSPlayer::~CTTSPlayer START" );
+    
+    Stop();
+    
+    RUBY_DEBUG0( "CTTSPlayer::~CTTSPlayer EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CTTSPlayer::PlayL
+// ---------------------------------------------------------
+//      
+void CTTSPlayer::PlayL( const TDesC& aText, TInt aPosition,
+                        TInt aMaxLength, const TDesC& aSegment )
+    {
+    RUBY_DEBUG_BLOCK( "CTTSPlayer::PlayL" );
+    
+    Stop();
+    
+    CreateSegmentsL( aText, aPosition, aMaxLength, aSegment );
+    
+    iTtsData->iParsedText->SetTextL( aText );
+        
+    // Opens and plays the parsed text
+    iTtsData->iTts->OpenAndPlayParsedTextL( *iTtsData->iParsedText );    
+    }
+
+// ---------------------------------------------------------
+// CTTSPlayer::PlayL
+// ---------------------------------------------------------
+//      
+void CTTSPlayer::PlayL( const TDesC& aText, TInt aPosition,
+                        TInt aMaxLength, const TDesC& aSegment,
+                        const TDesC& aNewSegment1, const TDesC& aNewSegment2,
+                        const TDesC& aNewSegment3  )
+    {
+    RUBY_DEBUG_BLOCK( "CTTSPlayer::PlayL" );
+    
+    Stop();
+    
+    HBufC* text = HBufC::NewLC( aText.Length() + aNewSegment1.Length() +
+                                aNewSegment2.Length() + aNewSegment3.Length() );
+    
+    TPtr textPtr = text->Des();
+    textPtr.Append( aText );
+                                  
+    CreateSegmentsL( *text, aPosition, aMaxLength, aSegment );
+    
+    for ( int i = KMaxBasicSegments; i < KMaxBasicSegments + KMaxEnhancedSegments; ++i )
+        {
+        iTtsData->iStyle[i] = new (ELeave) TTtsStyle();
+        iTtsData->iStyleId[i] = new (ELeave) TTtsStyleID( 0 );
+        iTtsData->iSegment[i] = new (ELeave) TTtsSegment( 0 );
+        
+        iTtsData->iStyle[i]->iLanguage = User::Language();
+        
+        *(iTtsData->iStyleId[i]) = iTtsData->iTts->AddStyleL( *(iTtsData->iStyle[i]) );
+    
+        iTtsData->iSegment[i]->SetStyleID( *(iTtsData->iStyleId[i]) );
+        }
+    
+    TInt location = KErrNone;
+    
+    textPtr.Append( aNewSegment1 );
+        
+    iTtsData->iSegment[3]->SetTextPtr( text->Mid( location, aNewSegment1.Length() ) );
+
+    iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[3]) );
+        
+    if ( aNewSegment2 != KNullDesC )
+        {
+        location = text->Length();
+        textPtr.Append( aNewSegment2 );
+        
+        iTtsData->iSegment[4]->SetTextPtr( text->Mid( location, aNewSegment2.Length() ) );
+
+        iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[4]) );
+        }
+        
+    if ( aNewSegment3 != KNullDesC )
+        {
+        location = text->Length();
+        textPtr.Append( aNewSegment3 );
+        
+        iTtsData->iSegment[5]->SetTextPtr( text->Mid( location, aNewSegment3.Length() ) );
+
+        iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[5]) );
+        }
+        
+    iTtsData->iParsedText->SetTextL( *text );
+           
+    // Opens and plays the parsed text
+    iTtsData->iTts->OpenAndPlayParsedTextL( *iTtsData->iParsedText );
+    
+    CleanupStack::PopAndDestroy( text );
+    }
+
+// ---------------------------------------------------------
+// CTTSPlayer::Stop
+// ---------------------------------------------------------
+//          
+void CTTSPlayer::Stop()
+    {
+    RUBY_DEBUG0( "CTTSPlayer::Stop START" );
+        
+    if ( iTtsData )
+        {
+        if ( iTtsData->iTts )
+            {
+            iTtsData->iTts->Stop();
+            iTtsData->iTts->Close();
+            }
+
+        delete iTtsData->iParsedText;
+        iTtsData->iParsedText = NULL;
+
+        delete iTtsData->iTts;
+        iTtsData->iTts = NULL;
+        
+        for ( int i = 0; i < KMaxSegments; ++i )
+            {
+            delete iTtsData->iStyle[i];
+            delete iTtsData->iStyleId[i];
+            delete iTtsData->iSegment[i];
+            }
+
+        delete iTtsData;
+        iTtsData = NULL;
+        }
+    
+    RUBY_DEBUG0( "CTTSPlayer::Stop EXIT" );  
+    }
+
+// ---------------------------------------------------------
+// CTTSPlayer::CTTSPlayer
+// ---------------------------------------------------------
+//              
+CTTSPlayer::CTTSPlayer( MTtsClientUtilityObserver* aObserver )
+ : iObserver( aObserver )
+    {
+    }
+
+// ---------------------------------------------------------
+// CTTSPlayer::ConstructL
+// ---------------------------------------------------------
+//           
+void CTTSPlayer::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CTTSPlayer::ConstructL" );
+    }
+
+// ---------------------------------------------------------
+// CTTSPlayer::CreateSegmentsL
+// ---------------------------------------------------------
+//      
+void CTTSPlayer::CreateSegmentsL( const TDesC& aText, TInt aPosition,
+                                  TInt aMaxLength, const TDesC& aSegment )
+    {
+    RUBY_DEBUG_BLOCK( "CTTSPlayer::CreateSegmentsL" );
+    
+    TInt leftLength = aText.Length();
+    TInt midLength = KErrNone;
+    TInt rightLength = KErrNone;
+    
+    TInt location = KErrNotFound;    
+    if ( aSegment != KNullDesC )
+        {
+        location = aText.Right( aText.Length() - aPosition ).FindC( aSegment ) + aPosition;
+        
+        if ( location != aPosition )
+            {
+            location = aPosition + aMaxLength - aSegment.Length();
+            }
+        
+        // Calculate segment lengths
+        if ( location == KErrNone )
+            {
+            leftLength = aSegment.Length();
+            rightLength = aText.Length() - aSegment.Length();
+            }
+        else if ( location + aSegment.Length() < aText.Length() )
+            {
+            leftLength = location;
+            midLength = aSegment.Length();
+            rightLength = aText.Length() - location - aSegment.Length();
+            }
+        else if ( location != KErrNotFound )
+            {
+            leftLength = aText.Length() - aSegment.Length();
+            rightLength = aSegment.Length();
+            }
+        }
+    
+    iTtsData = new (ELeave) TTtsData;
+    
+    iTtsData->iTts = CTtsUtility::NewL( *iObserver );
+    
+    iTtsData->iParsedText = CTtsParsedText::NewL();
+
+    for ( int i = 0; i < KMaxBasicSegments; ++i )
+        {
+        iTtsData->iStyle[i] = new (ELeave) TTtsStyle();
+        iTtsData->iStyleId[i] = new (ELeave) TTtsStyleID( 0 );
+        iTtsData->iSegment[i] = new (ELeave) TTtsSegment( 0 );
+        
+        iTtsData->iStyle[i]->iLanguage = User::Language();
+        
+        *(iTtsData->iStyleId[i]) = iTtsData->iTts->AddStyleL( *(iTtsData->iStyle[i]) );
+    
+        iTtsData->iSegment[i]->SetStyleID( *(iTtsData->iStyleId[i]) );
+        }
+    
+    // Create segments
+    iTtsData->iSegment[0]->SetTextPtr( aText.Left( leftLength ) );
+
+    iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[0]) );
+
+    if ( midLength != KErrNone )
+        {
+        iTtsData->iSegment[1]->SetTextPtr( aText.Mid( location, midLength ) );
+        iTtsData->iSegment[2]->SetTextPtr( aText.Right( rightLength ) );
+
+        iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[1]) );
+        iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[2]) );
+        }
+    else if ( rightLength != KErrNone )
+        {
+        iTtsData->iSegment[1]->SetTextPtr( aText.Right( rightLength ) );
+
+        iTtsData->iParsedText->AddSegmentL( *(iTtsData->iSegment[1]) );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CTTSPlayer::TTtsData
+// Initializes everything to zero.
+// -----------------------------------------------------------------------------
+//
+CTTSPlayer::TTtsData::TTtsData() 
+ : iTts( NULL ), iParsedText( NULL )
+    {
+    for ( int i = 0; i < KMaxSegments; ++i )
+        {
+        iStyle[i] = NULL;
+        iStyleId[i] = NULL;
+        iSegment[i] = NULL;
+        }
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuictutorial.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,374 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles tutorial mode resources and dialog showing
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <avkon.rsg>
+#include <avkon.hrh>
+#include <centralrepository.h>
+#include <vcommanddomaincrkeys.h>
+#include <e32property.h>
+#include <ScreensaverInternalPSKeys.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuictutorial.h"
+#include "vuictutorialmessagedialog.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CTutorial::InstanceL
+// -----------------------------------------------------------------------------
+//
+CTutorial* CTutorial::NewL()
+    {
+    CTutorial* self = new ( ELeave ) CTutorial();
+    CleanupStack::PushL( self ); 
+    self->ConstructL(); 
+    CleanupStack::Pop( self ); 
+    return self; 
+    }
+    
+// Destructor       
+CTutorial::~CTutorial()
+    {
+    RUBY_DEBUG0( "CTutorial::~CTutorial START" );
+    
+    // Save tutorial mode settings before exiting
+    TRAP_IGNORE( SaveSettingsL() );
+    
+    DestroyMessage();
+    
+    RUBY_DEBUG0( "CTutorial::~CTutorial EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::CreateMessageL
+// -----------------------------------------------------------------------------
+//
+void CTutorial::CreateMessageL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorial::CreateMessageL" );
+    
+    if ( iDlg )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+       
+    iDlg = CTutorialMessageDialog::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::CreateAndShowMessageL
+// -----------------------------------------------------------------------------
+//
+TInt CTutorial::CreateAndShowMessageL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorial::CreateAndShowMessageL" );
+    
+    CreateMessageL();
+    return ShowMessageL();
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::ShowMessageL
+// -----------------------------------------------------------------------------
+//
+TInt CTutorial::ShowMessageL( TBool aDeviceLockMode )
+    {
+    RUBY_DEBUG_BLOCK( "CTutorial::ShowMessageL" );
+    
+    TInt returnValue = KErrGeneral;    
+    
+    switch( iState )
+        {
+        case EIntroState:
+            
+            if ( IsTutorialModeEnabled() && iTutorialMode )
+                {
+                iState = ECommandState;
+                returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TITLE,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TEXT_UP,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TEXT_DOWN,
+                                                        R_SOFTKEYS_NEXT_CANCEL__NEXT );
+                }
+            else if ( IsTutorialModeEnabled() && !aDeviceLockMode )
+                {
+                iState = ETryState;
+                returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TITLE,
+                                                        R_TEXT_SIND_TUTORIAL_FIRST_TIME_TEXT_UP,
+                                                        R_TEXT_SIND_TUTORIAL_FIRST_TIME_TEXT_DOWN,
+                                                        R_SOFTKEYS_ACTIVATE_CANCEL__ACTIVATE,
+                                                        SecondaryDisplay::ECmdShowFirstTimeActivationQuery );
+                if ( returnValue == EVoiceInfoSoftKeyActivate )
+                    {
+                    DisableFirstTimeMode();
+                    }
+                }
+            else 
+                {
+                iState = ETryState;
+                }
+            break;
+            
+        case ECommandState:
+            
+            iState = EDialState;
+            returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_COMMAND_TITLE,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_COMMAND_TEXT_UP,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_COMMAND_TEXT_DOWN,
+                                                    R_SOFTKEYS_NEXT_CANCEL__NEXT );
+            break;
+            
+        case EDialState:
+            
+            iState = EOtherState;
+            returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_DIAL_TITLE,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_DIAL_TEXT_UP,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_DIAL_TEXT_DOWN,
+                                                    R_SOFTKEYS_NEXT_CANCEL__NEXT );
+            break;
+
+        case EOtherState:
+            
+            iState = ETryState;
+            returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_OTHER_TITLE,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_OTHER_TEXT_UP,
+                                                    R_TEXT_SIND_TUTORIAL_PAGE_OTHER_TEXT_DOWN,
+                                                    R_SOFTKEYS_NEXT_CANCEL__NEXT );
+            break;
+
+        case ETryState:
+            
+            iState = EBestState;
+            if ( IsTutorialModeEnabled() && !aDeviceLockMode )
+                {
+                returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_TRY_TITLE,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_TRY_TEXT_UP,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_TRY_TEXT_DOWN,
+                                                        R_SOFTKEYS_ACTIVATE_CANCEL__ACTIVATE );
+                }
+            break;
+
+        case EBestState:
+            
+            iState = EActivationState;
+            if ( IsTutorialModeEnabled() && !aDeviceLockMode )
+                {
+                returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_BEST_TITLE,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_BEST_TEXT_UP,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_BEST_TEXT_DOWN,
+                                                        R_SOFTKEYS_NEXT_CANCEL__NEXT );
+                }
+            break;
+
+        case EActivationState:
+            
+            iState = EFinishedState;
+            if ( IsTutorialModeEnabled() && !aDeviceLockMode )
+                {
+                returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_ACTIVATION_TITLE,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_ACTIVATION_TEXT,
+                                                        KErrNone,
+                                                        R_AVKON_SOFTKEYS_QUIT );
+                }
+            break;
+
+        case EErrorState:
+            
+            iState = EFinishedState;
+            if ( IsTutorialModeEnabled() && !aDeviceLockMode )
+                {
+                returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_ERROR_TITLE,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_ERROR_TEXT_UP,
+                                                        R_TEXT_SIND_TUTORIAL_PAGE_ERROR_TEXT_DOWN,
+                                                        R_SOFTKEYS_NEXT_CANCEL__NEXT );
+                if ( returnValue == EVoiceInfoSoftKeyNext )
+                    {
+                    iState = ETryState;
+                    }
+                }
+            break;
+            
+        default:
+            returnValue = KErrCancel;
+            break;
+        }
+        
+        if ( returnValue == EVoiceInfoSoftKeyCancel || returnValue == EAknSoftkeyQuit )
+            {
+            iTutorialMode = EFalse;
+            returnValue = KErrCancel;
+            }
+        else if ( returnValue == KErrNone )
+            {
+            // Return general error because dialog has been canceled without any keypress
+            returnValue = KErrGeneral;
+            }
+        else if ( returnValue != KErrCancel )
+            {
+            returnValue = KErrNone;
+            }
+        
+    return returnValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::DestroyMessage
+// -----------------------------------------------------------------------------
+//
+void CTutorial::DestroyMessage()
+    {
+    RUBY_DEBUG0( "CTutorial::DestroyMessage START" );
+    
+    if ( iDlg )
+        {
+        delete iDlg;
+        iDlg = NULL;
+        }
+    
+    RUBY_DEBUG0( "CTutorial::DestroyMessage EXIT" );    
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::GetTutorialState
+// -----------------------------------------------------------------------------
+//
+CTutorial::TTutorialState CTutorial::GetTutorialState()
+    {
+    RUBY_DEBUG0( "CTutorial::GetTutorialState" );
+    return iState;
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::ShowError
+// -----------------------------------------------------------------------------
+//
+void CTutorial::ErrorState()
+    {
+    RUBY_DEBUG0( "CTutorial::ErrorState" );
+    iState = EErrorState;
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::IsTutorialModeEnabled
+// -----------------------------------------------------------------------------
+//
+TBool CTutorial::IsTutorialModeEnabled()
+    {
+    RUBY_DEBUG0( "CTutorial::IsTutorialModeEnabled" );
+    return iTutorialMode || iFirstTimeMode;
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::DisableTutorialMode
+// -----------------------------------------------------------------------------
+//
+void CTutorial::DisableFirstTimeMode()
+    {
+    RUBY_DEBUG0( "CTutorial::DisableFirstTimeMode" );
+    if ( !iTutorialMode )
+        {
+        iFirstTimeMode = EFalse;
+        
+        TRAP_IGNORE( SaveSettingsL() );
+        }    
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorial::CTutorial
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTutorial::CTutorial()
+ : iTutorialMode( EFalse ), iFirstTimeMode( EFalse ), iState( EIntroState )
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorialMessageDialog::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTutorial::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorial::ConstructL" );
+    
+    LoadSettingsL();
+    }
+
+// ---------------------------------------------------------------------------
+// CTutorial::LoadSettingsL
+// ---------------------------------------------------------------------------
+//
+void CTutorial::LoadSettingsL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorial::LoadSettingsL" );
+    
+    CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+    
+    User::LeaveIfError( client->Get( KVuiDemoFirstTime,
+                                     iFirstTimeMode ) );
+    
+    User::LeaveIfError( client->Get( KVuiDemoMode,
+                                     iTutorialMode ) );
+
+    CleanupStack::PopAndDestroy( client );
+    
+    if ( iTutorialMode )
+        {
+        //Allow screensaver if in tutorial mode
+        RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 0 );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CTutorial::SaveSettingsL
+// ---------------------------------------------------------------------------
+//
+void CTutorial::SaveSettingsL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorial::SaveSettingsL" );
+    
+    CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
+
+    User::LeaveIfError( client->Set( KVuiDemoFirstTime,
+                                     iFirstTimeMode ) );
+                        
+    User::LeaveIfError( client->Set( KVuiDemoMode,
+                                     EFalse ) );
+
+    CleanupStack::PopAndDestroy( client );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuictutorialmessagedialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handles dialog used in tutorial mode
+*
+*/
+
+
+// INCLUDE FILES 
+#include <featmgr.h>
+
+#include <StringLoader.h>
+
+#include <AknNotifierController.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuictutorialmessagedialog.h"
+#include "vuicpropertyhandler.h"
+#include "vuicmessagequerydialog.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+_LIT( KSpace, " " );
+
+// ---------------------------------------------------------
+// CTutorialMessageDialog::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CTutorialMessageDialog* CTutorialMessageDialog::NewL()
+    {
+    CTutorialMessageDialog* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------
+// CTutorialMessageDialog::NewLC
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CTutorialMessageDialog* CTutorialMessageDialog::NewLC()
+    {
+    CTutorialMessageDialog* self = new (ELeave) CTutorialMessageDialog();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// Destructor       
+CTutorialMessageDialog::~CTutorialMessageDialog()
+    {    
+    delete iDlg;
+    }        
+
+// ---------------------------------------------------------
+// CTutorialMessageDialog::ShowMessageDialogL
+// ---------------------------------------------------------
+//
+TInt CTutorialMessageDialog::ShowMessageDialogL( TInt aDialogResourceId,
+                                                 TInt aHeaderId,
+                                                 TInt aMessagePart1Id,
+                                                 TInt aMessagePart2Id,
+                                                 TInt aCommandResourceId,
+                                                 SecondaryDisplay::TVUISecondaryDisplayDialogs aDialog )
+    {
+    RUBY_DEBUG_BLOCK( "CTutorialMessageDialog::ShowMessageDialogL" );
+    
+    // Load resources
+    HBufC* header = StringLoader::LoadLC( aHeaderId );        
+    HBufC* part1 = StringLoader::LoadLC( aMessagePart1Id );
+    HBufC* part2 = NULL;
+    HBufC* message = part1;
+    
+    if ( aMessagePart2Id )
+        {
+        part2 = StringLoader::LoadLC( aMessagePart2Id );
+        message = ConcatenateLC( *part1, *part2 );
+        }
+        
+    // Create dialog
+    iDlg = CMessageQueryDialog::NewL( &iDlg );
+    
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+         aDialog != SecondaryDisplay::ECmdVoiceNoNote )
+	    {
+        // Initializes cover support
+        iDlg->PublishDialogL( aDialog, SecondaryDisplay::KCatVoiceUi );
+        }
+    
+    iDlg->PrepareLC( aDialogResourceId ); 
+        
+    // Set softkey labels
+    CEikButtonGroupContainer* cba = &iDlg->ButtonGroupContainer();
+    cba->SetCommandSetL( aCommandResourceId );
+    iCommands = aCommandResourceId;
+    
+    // Set message & header texts
+    iDlg->SetMessageTextL( *message );
+    iDlg->QueryHeading()->SetTextL( *header );   
+    
+    // Show dialog and block until dialog is dismissed
+    // RunLD pops iDlg (pushed in PrepareLC) from CleanupStack
+    TInt returnValue = iDlg->RunLD();
+    
+    // Enter selection returns EAknSoftkeyOk
+    if ( returnValue == EAknSoftkeyOk )
+        {
+        if ( aCommandResourceId == R_SOFTKEYS_NEXT_CANCEL__NEXT )
+            {
+            returnValue = EVoiceInfoSoftKeyNext;
+            }
+        else if ( aCommandResourceId == R_SOFTKEYS_ACTIVATE_CANCEL__ACTIVATE )
+            {
+            returnValue = EVoiceInfoSoftKeyActivate;
+            }
+        else
+            {
+            returnValue = EAknSoftkeyQuit;
+            }
+        }
+    
+    // Cleanup resources
+    if ( aMessagePart2Id )
+        {
+        CleanupStack::PopAndDestroy( message );
+        CleanupStack::PopAndDestroy( part2 );
+        }
+    CleanupStack::PopAndDestroy( part1 );
+    CleanupStack::PopAndDestroy( header );
+      
+    return returnValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CTutorialMessageDialog::CTutorialMessageDialog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTutorialMessageDialog::CTutorialMessageDialog()
+    {
+    // Nothing
+    }
+    
+// -----------------------------------------------------------------------------
+// CTutorialMessageDialog::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTutorialMessageDialog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorialMessageDialog::ConstructL" );
+    }
+
+// ---------------------------------------------------------
+// CTutorialMessageDialog::ConcatenateLC
+// ---------------------------------------------------------
+//    
+HBufC* CTutorialMessageDialog::ConcatenateLC( const TDesC& aString1,
+                                              const TDesC& aString2 )
+    {
+    HBufC* string = NULL;
+    if ( aString2.Length() )
+        {
+        string = HBufC::NewLC( aString1.Length() + aString2.Length() + KSpace.iTypeLength );
+        string->Des() = aString1;
+        string->Des() += KSpace;
+        string->Des() += aString2;
+        }
+    else
+        {
+        string = HBufC::NewLC( aString1.Length() );
+        string->Des() = aString1;
+        }
+    return string;
+    }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuictutorialstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,196 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+
+#include "vuicstate.h"
+#include "vuictutorialstate.h"
+#include "vuicinitstate.h"
+#include "vuicresultsstate.h"
+#include "vuicverificationinitstate.h"
+#include "vuicadaptstate.h"
+#include "vuicexitstate.h"
+#include "vuicabortstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuictoneplayer.h"
+#include "vuictutorial.h"
+
+#include "rubydebug.h"
+
+// Constants
+    
+// -----------------------------------------------------------------------------
+// CTutorialState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTutorialState* CTutorialState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CTutorialState* self = new (ELeave) CTutorialState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CTutorialState::~CTutorialState()
+    {
+    RUBY_DEBUG0( "CTutorialState::~CTutorialState START" );
+    
+    DataStorage().Tutorial()->DestroyMessage();
+    
+    RUBY_DEBUG0( "CTutorialState::~CTutorialState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CTutorialState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CTutorialState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CTutorialState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iCurrentTutorialState == CTutorial::ETryState )
+                {
+                nextState = CInitState::NewL( DataStorage(), UiModel() );
+                }
+            else if ( iCurrentTutorialState == CTutorial::EBestState )
+                {
+                if ( DataStorage().VerificationMode() != EVoice )
+                    {
+                    nextState = CResultsState::NewL( DataStorage(), UiModel() );
+                    }
+                else
+                    {
+                    nextState = CVerificationInitState::NewL( DataStorage(), UiModel() );
+                    }
+                }
+            else if ( iCurrentTutorialState == CTutorial::EActivationState )
+                {
+                nextState = CAdaptState::NewL( DataStorage(), UiModel() );
+                }
+            else if ( iInternalState == EStarted )
+                {
+                iInternalState = EInitialized;
+                nextState = this;            
+                }
+            else if ( iInternalState == EInitialized )
+                {
+                iInternalState = ECompleted;
+                }
+            else
+                {
+                nextState = this;
+                }
+            break;
+            
+        case KErrCancel:
+        
+            nextState = CExitState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        case EShortKeypress:
+        case ELongKeypress:
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+        
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CTutorialState::ExecuteL
+// ---------------------------------------------------------
+//
+void CTutorialState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorialState::ExecuteL" );
+    
+    iCurrentTutorialState = DataStorage().Tutorial()->GetTutorialState();
+    
+    if ( iCurrentTutorialState == CTutorial::ECommandState )
+        {
+        if ( iInternalState == ENotStarted )
+            {
+            // Initialize start tone
+            DataStorage().TonePlayer()->InitToneL( EAvkonSIDNameDiallerStartTone );
+            iInternalState = EStarted;
+            }
+        else
+            {
+            // Play the starting tone
+            DataStorage().TonePlayer()->PlayTone( EAvkonSIDNameDiallerStartTone );
+            }                
+        }
+        
+    if ( iInternalState != EStarted )
+        {
+        BringToForeground();
+
+        TInt returnValue = DataStorage().Tutorial()->ShowMessageL( DataStorage().DeviceLockMode() );
+        
+        if ( returnValue != KErrGeneral )
+            {
+            HandleEventL( returnValue );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CTutorialState::CTutorialState
+// ---------------------------------------------------------
+//              
+CTutorialState::CTutorialState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iCurrentTutorialState( CTutorial::EIntroState ),
+   iInternalState( ENotStarted )
+    {
+    }
+
+// ---------------------------------------------------------
+// CTutorialState::ConstructL
+// ---------------------------------------------------------
+//           
+void CTutorialState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CTutorialState::ConstructL" );
+    
+    CState::ConstructL();
+    
+    DataStorage().Tutorial()->CreateMessageL();
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicuimodel.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "vuicuimodel.h"
+#include "vuicglobalnote.h"
+
+#include "rubydebug.h"
+
+// -----------------------------------------------------------------------------
+// CUiModel::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUiModel* CUiModel::NewL()
+    {
+    RUBY_DEBUG_BLOCK( "CUiModel::NewL" );
+    
+    CUiModel* self = new (ELeave) CUiModel();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    } 
+
+// Destructor       
+CUiModel::~CUiModel()
+    {
+    RUBY_DEBUG0( "CUiModel::~CUiModel START" );
+    
+    delete iNote;   
+    
+    RUBY_DEBUG0( "CUiModel::~CUiModel EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CUiModel::Note
+// ---------------------------------------------------------
+//  
+CGlobalNote& CUiModel::Note() const
+    {
+    RUBY_DEBUG0( "CUiModel::Note" );
+    
+    return *iNote;
+    }
+
+// ---------------------------------------------------------
+// CUiModel::CUiModel
+// ---------------------------------------------------------
+//              
+CUiModel::CUiModel()
+    {
+    }
+
+// ---------------------------------------------------------
+// CUiModel::ConstructL
+// ---------------------------------------------------------
+//           
+void CUiModel::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CUiModel::ConstructL" );
+
+    iNote = CGlobalNote::NewL();
+    }
+
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicverificationdialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,390 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <featmgr.h>
+
+#include <AknMediatorFacade.h>
+
+#include <SecondaryDisplay/AknSecondaryDisplayDefs.h>
+
+#include <vuivoicerecognition.rsg>
+#include <vuivoicerecogdefs.h>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuiclistquerydialog.h"
+#include "vuicverificationdialog.h"
+
+#include "vuimkeycallback.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CVerificationDialog::CVerificationDialog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVerificationDialog::CVerificationDialog() 
+ : iCurrentIndex( 0 )
+    {
+    }
+
+
+// Destructor
+CVerificationDialog::~CVerificationDialog()
+    {
+    RUBY_DEBUG0( "CVerificationDialog::~CVerificationDialog START" );
+     
+    RegisterForKeyCallback( NULL );
+    
+    delete iDialog;
+    iDialog = NULL;
+    
+    iEikonEnv->EikAppUi()->RemoveFromStack( this );
+        
+    RUBY_DEBUG0( "CVerificationDialog::~CVerificationDialog EXIT" );          
+    }
+
+
+// -----------------------------------------------------------------------------
+// CVerificationDialog::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVerificationDialog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationDialog::ConstructL" );
+      
+    iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityAlert );
+    }
+
+
+// ---------------------------------------------------------
+// CVerificationDialog::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CVerificationDialog* CVerificationDialog::NewL()                                                           
+    {
+    CVerificationDialog* self = new (ELeave) CVerificationDialog();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CVerificationDialog::RegisterForKeyCallback
+// -----------------------------------------------------------------------------
+//
+void CVerificationDialog::RegisterForKeyCallback( MKeyCallback* aKeyCallback )
+    {
+    iKeyCallback = aKeyCallback;
+    }
+
+// ---------------------------------------------------------
+// TKeyResponse CVerificationDialog::OfferKeyEventL
+// ---------------------------------------------------------
+//
+TKeyResponse CVerificationDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode /*aType*/ )
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationDialog::OfferKeyEventL" );
+
+    TKeyResponse keyStatus = EKeyWasNotConsumed;
+
+    TInt event = ConvertKeyEventL( aKeyEvent );
+    
+    if ( event != ENoKeypress )
+        {
+        switch( event )
+            {
+            case ESelectKeypress:
+                {                   
+                keyStatus = EKeyWasConsumed;
+                break;
+                }
+            
+            case EUpKeypress:
+                {
+                --iCurrentIndex;
+                if ( iCurrentIndex <= -1 )
+                    {
+                    iCurrentIndex = KVerificationCommands - 1;    
+                    }
+                break;
+                }
+                        
+            case EDownKeypress:
+                {
+                ++iCurrentIndex;
+                if ( iCurrentIndex >= KVerificationCommands )
+                    {
+                    iCurrentIndex = 0;
+                    }
+                break;
+                }
+                
+            case EVoiceTagSoftKeyCancel:
+                {
+                iEikonEnv->EikAppUi()->RemoveFromStack( this );
+                break;
+                }
+        
+            default:
+                break;            
+            }
+         
+         if ( iKeyCallback )
+             {
+             iKeyCallback->HandleKeypressL( event );
+            }
+         }
+         
+    return keyStatus;
+    }
+    
+// ---------------------------------------------------------------------------
+// CVerificationDialog::MediatorCommandL
+// ---------------------------------------------------------------------------
+//
+TAknDialogMediatorObserverCommand CVerificationDialog::MediatorCommandL( TUid /*aDomain*/, 
+                                                                         TUid aCategory, 
+                                                                         TInt aCommandId, 
+                                                                         const TDesC8& aData )
+    { 
+    RUBY_DEBUG_BLOCK( "CVerificationDialog::MediatorCommandL" );
+    
+    TAknDialogMediatorObserverCommand retValue = EHandleAsNormal;
+    
+    if ( aCategory == SecondaryDisplay::KCatVoiceUi && 
+         aCommandId == SecondaryDisplay::ECmdShowVoiceVerificationQuery )
+        {
+        if ( aData.Length() == sizeof( SAknDialogFeedback ) ) 
+            {
+            const SAknDialogFeedback& params = 
+                reinterpret_cast<const SAknDialogFeedback&>( *( aData.Ptr() ) );
+            
+            if ( params.iKey.iCode == EKeyCBA1 )
+                {
+                // LSK should select current selection
+                iKeyCallback->HandleKeypressL( ESelectKeypress );
+                
+                retValue = EDoNothingWithThisCommand;
+                }
+            }
+        else
+            {
+            SAknIntegerUpdate* params = (SAknIntegerUpdate*) &aData;
+        
+            if ( params->iCmd == EAknListQueryUpdateSelection )
+                {
+                iCurrentIndex = params->iId;
+                iDialog->ListControl()->Listbox()->SetCurrentItemIndexAndDraw( iCurrentIndex );
+
+                // Just send EUpKeypress or EDownKeypress event to notify that selection
+                // has changed
+                iKeyCallback->HandleKeypressL( EDownKeypress );
+                }
+            }
+        }
+    return retValue;
+    } 
+
+// ---------------------------------------------------------------------------
+// CVerificationDialog::NotifyMediatorExit
+// ---------------------------------------------------------------------------
+//
+void CVerificationDialog::NotifyMediatorExit() 
+    { 
+    RUBY_DEBUG0( "CVerificationDialog::NotifyMediatorExit" );
+    // Do nothing
+    } 
+
+// -----------------------------------------------------------------------------
+// CVerificationDialog::CreateVerificationPopupLC
+// -----------------------------------------------------------------------------
+//
+void CVerificationDialog::CreateVerificationPopupLC( const TDesC& aHeader )
+    {
+    RUBY_DEBUG0( "CVerificationDialog::CreateVerificationPopupLC START" );
+       
+    iDialog = CListQueryDialog::NewL( &iCurrentIndex, &iDialog );
+    iDialog->PrepareLC( R_VERIFICATION_QUERY );
+    
+    iDialog->QueryHeading()->SetTextL( aHeader );
+    
+    SecondaryDisplay::TVerificationData data;
+    data.iName.Append( aHeader );
+    
+    SetSecondaryDisplayDataL( data );
+    
+    RUBY_DEBUG0( "CVerificationDialog::CreateVerificationPopupLC EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVerificationDialog::ShowVerificationPopupL
+// -----------------------------------------------------------------------------
+//
+TInt CVerificationDialog::ShowVerificationPopupL()
+    {
+    RUBY_DEBUG0( "CVerificationDialog::ShowVerificationPopupL START" );
+
+    // Show verification dialog
+    TInt returnValue = iDialog->RunLD();
+    
+    // Touch selection returns EAknSoftkeyOk
+    if ( returnValue == EAknSoftkeyOk )
+        {
+        returnValue = EVoiceTagSoftKeySelect;
+        }
+            
+    RUBY_DEBUG0( "CVerificationDialog::ShowVerificationPopupL EXIT" );
+
+    return returnValue;
+    }
+        
+// -----------------------------------------------------------------------------
+// CVerificationDialog::ConvertKeyEventL
+// -----------------------------------------------------------------------------
+// 
+TInt CVerificationDialog::ConvertKeyEventL( const TKeyEvent& aKeyEvent )
+    {
+    TInt event = ENoKeypress;
+    
+    switch( aKeyEvent.iCode )
+        {
+        case EKeyNo:
+        case EKeyEscape:
+            {
+            event = EVoiceTagSoftKeyCancel;
+            break;
+            }
+
+        case EKeyDevice3:
+        case EKeyYes:
+            {
+            event = ESelectKeypress;
+            break;
+            }
+
+        case EKeyUpArrow:
+            {
+            event = EUpKeypress;
+            break;
+            }
+                        
+        case EKeyDownArrow:
+            {
+            event = EDownKeypress;
+            break;
+            }
+                                        
+        default:
+            {
+            event = ENoKeypress;
+            break;            
+            }
+        }
+    return event;
+    }
+    
+// ---------------------------------------------------------------------------
+// CVerificationDialog::SelectedCommand
+// ---------------------------------------------------------------------------
+//    
+TInt CVerificationDialog::SelectedCommand( TInt aId )
+    {
+    RUBY_DEBUG0( "CVerificationDialog::SelectedCommand START" );
+    
+    TInt command;
+    TInt index = iCurrentIndex;
+    
+    if ( aId != KErrGeneral )
+        {
+        index = aId;
+        }
+        
+    switch( index )
+        {
+        case 0:
+            command = EVoiceTagSoftKeySelect;
+            break;
+
+        case 1:
+            command = EVoiceTagSoftKeyOther;
+            break;
+
+        case 2:
+            command = EVoiceTagSoftKeyCancel;
+            break;
+                                        
+        default:
+            command = KErrGeneral;
+            break;            
+        }
+    
+    RUBY_DEBUG0( "CVerificationDialog::SelectedCommand EXIT" );
+    
+    return command;
+    }
+    
+// ---------------------------------------------------------
+// CVerificationDialog::SetSecondaryDisplayDataL
+// Sets additional information to be sent to secondary display
+// ---------------------------------------------------------
+//
+void CVerificationDialog::SetSecondaryDisplayDataL( SecondaryDisplay::TVerificationData& aData )
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationDialog::SetSecondaryDisplayDataL" );
+   
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+        {
+        // Create dummy id list (needed for list query automation)
+        CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
+        CleanupStack::PushL( array );
+        for( TInt i = 0; i < 3; ++i )
+            {
+            array->AppendL( i );
+            }
+            
+        iDialog->PublishDialogL( SecondaryDisplay::ECmdShowVoiceVerificationQuery,
+                                 SecondaryDisplay::KCatVoiceUi,
+                                 array );
+                                 
+        iDialog->SetMediatorObserver( this );
+        
+        CleanupStack::Pop( array ); // Dialog takes ownership of array
+   
+        // fetch akn utility for mediator support, \oem\aknmediatorfacade.h
+        CAknMediatorFacade* covercl = AknMediatorFacade( iDialog );
+
+        if ( covercl )
+            {
+            covercl->BufStream() << aData.iName;
+            covercl->BufStream().CommitL(); // no more data to send so commit buf
+            }
+        }
+    }
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicverificationinitstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,217 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+
+#include "vuicstate.h"
+#include "vuicverificationinitstate.h"
+#include "vuicverificationstate.h"
+#include "vuicabortstate.h"
+#include "vuicerrorstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuictoneplayer.h"
+
+#include "rubydebug.h"
+
+// CONSTANTS
+
+    
+// -----------------------------------------------------------------------------
+// CVerificationInitState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVerificationInitState* CVerificationInitState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CVerificationInitState* self = new (ELeave) CVerificationInitState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CVerificationInitState::~CVerificationInitState()
+    {
+    RUBY_DEBUG0( "CVerificationInitState::~CVerificationInitState START" );
+    
+    if ( iInternalState != EReady )
+        {
+        DataStorage().VerificationRecognitionHandler()->Cancel();
+        }
+    
+    RUBY_DEBUG0( "CVerificationInitState::~CVerificationInitState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CVerificationInitState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CVerificationInitState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationInitState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+#ifndef __WINS__
+#ifdef __FULLDUPLEX_CHANGE
+                iInternalState = ESamplingStarted;
+                nextState = this;
+                }
+            else if ( iInternalState == ESamplingStarted )
+                {
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__ 
+
+                iInternalState = EInitialized;
+                }
+            else
+                {
+                nextState = CVerificationState::NewL( DataStorage(), UiModel() );
+                iInternalState = EReady;
+                }
+            break;
+        
+        case KErrInit:
+        
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+            
+        case EShortKeypress:
+        case ELongKeypress:
+        case EEndCallKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+        
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CVerificationInitState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CVerificationInitState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationInitState::ExecuteL" );
+    
+    if ( iInternalState == ENotStarted )
+        {
+        // Initialize recognition system
+        InitializeL();
+        iInternalState = EStarted;
+        
+#ifndef __WINS__
+#ifdef __FULLDUPLEX_CHANGE
+        // Initialize sampling
+        StartSamplingL();
+        }
+    else if ( iInternalState == ESamplingStarted )
+        {
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__ 
+
+        // Initialize start tone
+        DataStorage().TonePlayer()->InitToneL( EAvkonSIDNameDiallerStartTone );
+
+        // Initialize recognition
+        RecognizeInitL();
+        }
+    }
+
+// ---------------------------------------------------------
+// CVerificationInitState::CVerificationInitState
+// ---------------------------------------------------------
+//              
+CVerificationInitState::CVerificationInitState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CVerificationInitState::InitializeL
+// ---------------------------------------------------------
+//
+void CVerificationInitState::InitializeL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationInitState::InitializeL" );
+        
+    CNssRecognitionHandlerBuilder* builder = CNssRecognitionHandlerBuilder::NewL();
+    DataStorage().SetVerificationRecognitionHandlerBuilder( builder );    
+    builder->InitializeL();
+   
+    DataStorage().SetVerificationRecognitionHandler( builder->GetRecognitionHandler() );
+    }
+
+#ifndef __WINS__
+#ifdef __FULLDUPLEX_CHANGE
+// ---------------------------------------------------------
+// CVerificationInitState::StartSamplingL
+// ---------------------------------------------------------
+//
+void CVerificationInitState::StartSamplingL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationInitState::StartSamplingL" );
+    
+    MNssRecognitionHandler* handler = DataStorage().VerificationRecognitionHandler(); 
+    User::LeaveIfError(
+        handler->PreStartSampling( DataStorage().VoiceRecognitionImpl() ) );
+    }
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__ 
+
+// ---------------------------------------------------------
+// CVerificationInitState::RecognizeInitL
+// ---------------------------------------------------------
+//
+void CVerificationInitState::RecognizeInitL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationInitState::RecognizeInitL" );
+    
+    // Content of this array may not be destroyed here. In case of a Leave content
+    // will be destroyed in DataStorage.
+    CArrayPtrFlat<MNssContext>* array = new (ELeave) CArrayPtrFlat<MNssContext>( 1 );
+    CleanupDeletePushL( array );
+        
+    array->AppendL( DataStorage().Context() );
+
+    MNssRecognitionHandler* handler = DataStorage().VerificationRecognitionHandler();
+    User::LeaveIfError(
+        handler->RecognizeInitL( DataStorage().VoiceRecognitionImpl(), *array, 1 ) );
+                                 
+    CleanupStack::PopAndDestroy( array );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicverificationstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,402 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <StringLoader.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicstate.h"
+#include "vuicverificationstate.h"
+#include "vuicverificationinitstate.h"
+#include "vuicplaystate.h"
+#include "vuicabortstate.h"
+#include "vuicerrorstate.h"
+#include "vuicexitstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+#include "vuicverificationdialog.h"
+#include "vuicttsplayer.h"
+#include "vuictoneplayer.h"
+
+#include "rubydebug.h"
+    
+// -----------------------------------------------------------------------------
+// CVerificationState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVerificationState* CVerificationState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CVerificationState* self = new (ELeave) CVerificationState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CVerificationState::~CVerificationState()
+    {
+    RUBY_DEBUG0( "CVerificationState::~CVerificationState START" );
+    
+    if ( DataStorage().TtsPlayer() )
+        {
+        DataStorage().TtsPlayer()->Stop();
+        }
+    
+    // If recording has not ended we should cancel recording
+    if ( iInternalState != ECompleted &&
+         DataStorage().VerificationRecognitionHandler() )
+        {
+        DataStorage().VerificationRecognitionHandler()->Cancel();
+        }
+        
+    delete iVerificationDialog;
+    
+    RUBY_DEBUG0( "CVerificationState::~CVerificationState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CVerificationState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CVerificationState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationState::HandleEventL" );
+
+    CState* nextState = NULL;
+
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+                iInternalState = ETtsInitialized;
+                }
+            else if ( iInternalState == ETtsInitialized )
+                {
+                iInternalState = ETtsCompleted;
+                nextState = this;
+                }
+            else if ( iInternalState == ETtsCompleted )
+                {
+                iInternalState = EStartCompleted;
+                nextState = this;
+                }
+            else if ( iInternalState == EStartCompleted )
+                {
+                iInternalState = ERecordStarted;
+                }
+            else if ( iInternalState == ERecordStarted )
+                {
+                iInternalState = ERecordEnded;
+                }
+            else if ( iInternalState == ERecordEnded )
+                {
+                iInternalState = ECompleted;
+                nextState = this;
+                }
+            break;
+        
+        case EVoiceTagSoftKeySelect:
+            
+            nextState = CPlayState::NewL( DataStorage(), UiModel() );
+            break;
+            
+        case KErrNoMatch:
+        case KErrRecogFailed:
+        case KErrNoSpeech:
+        case KErrTooEarly:
+        case KErrTooLong:
+        case KErrTooShort:
+        
+            DataStorage().SetVerificationTryCount( DataStorage().VerificationTryCount() - 1 );
+            nextState = CVerificationInitState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case EVoiceTagSoftKeyOther:
+            
+            nextState = CVerificationInitState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case EVoiceTagSoftKeyCancel:
+        case EEndCallKeypress:
+        case ELongKeypress:
+        case KErrNoResults:
+
+            nextState = CAbortState::NewL( DataStorage(), UiModel() );
+            break;
+        
+        case EShortKeypress:
+        case ESelectKeypress:
+        
+            iKeypress = aEvent;
+            nextState = this;
+            break;
+            
+        case EUpKeypress:
+        case EDownKeypress:
+        
+            // Do nothing
+            break;
+            
+        default:
+            
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CVerificationState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CVerificationState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationState::ExecuteL" );
+
+    if ( HandleKeypressL() )
+        {
+        iKeypress = ENoKeypress;
+        }
+    else if ( iInternalState == ETtsCompleted )
+        {
+        DataStorage().TtsPlayer()->Stop();
+        
+        // Play the starting tone
+        DataStorage().TonePlayer()->PlayTone( EAvkonSIDNameDiallerStartTone ); 
+        }
+    else if ( iInternalState == EStartCompleted )
+        {
+        MNssRecognitionHandler* handler = DataStorage().VerificationRecognitionHandler();
+        User::LeaveIfError( handler->Recognize( DataStorage().VoiceRecognitionImpl() ) );
+        }
+    else if ( iInternalState == ECompleted )
+        {
+        SelectTag();
+        
+        DataStorage().SetVerificationTryCount( KVerificationTries );
+        
+        HandleEventL( SelectCommandById() );
+        }
+    else
+        {
+        TInt returnValue = KErrNoResults;
+        
+        if ( DataStorage().CompleteTagList()->Count() != KErrNone &&
+             DataStorage().VerificationTryCount() > KErrNone )
+            {
+            iInternalState = EStarted;
+
+            MNssTag* selectedTag = NULL;
+            for ( int i = 0; i < DataStorage().CompleteTagList()->Count(); ++i )
+                {
+                MNssTag* tag = DataStorage().CompleteTagList()->At( i );
+                if ( !DataStorage().DeviceLockMode() ||
+                     ( tag->Context()->ContextName() == KVoiceDialContext &&
+                     tag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) )
+                    {
+                    iTagIndex = i;
+                    selectedTag = tag;
+                    break;
+                    }
+                }
+                     
+            if ( selectedTag )
+                {
+                HBufC* header = selectedTag->SpeechItem()->Text().AllocLC();
+                                
+                iVerificationDialog = CVerificationDialog::NewL();
+                iVerificationDialog->CreateVerificationPopupLC( *header );
+                
+                PlayPromptL();
+                BringToForeground();
+    
+                iVerificationDialog->RegisterForKeyCallback( DataStorage().VoiceRecognitionImpl() );            
+                returnValue = iVerificationDialog->ShowVerificationPopupL(); // Pops things pushed in CreateVerificationPopupLC
+                RUBY_DEBUG1( "CVerificationState::ExecuteL - Verification dialog returns [%d]", returnValue );
+                
+                CleanupStack::PopAndDestroy( header );
+                }
+            }
+        
+        if ( returnValue != KErrNone )
+            {           
+            SelectTag();
+            
+            DataStorage().SetVerificationTryCount( KVerificationTries );
+            
+            if ( returnValue == EVoiceTagSoftKeySelect )
+                {
+                HandleEventL( SelectCommandById() );
+                }
+            else
+                {
+                HandleEventL( returnValue );
+                }            
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CVerificationState::CVerificationState
+// ---------------------------------------------------------
+//              
+CVerificationState::CVerificationState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iKeypress( ENoKeypress ),
+   iInternalState( ENotStarted )
+    {
+    }
+
+// ---------------------------------------------------------
+// CVerificationState::ConstructL
+// ---------------------------------------------------------
+//           
+void CVerificationState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationState::ConstructL" );
+    
+    CState::ConstructL();
+    
+    DataStorage().SetAdaptationEnabled( ETrue );
+    }
+    
+// ---------------------------------------------------------
+// CVerificationState::HandleKeypressL
+// ---------------------------------------------------------
+//           
+TBool CVerificationState::HandleKeypressL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationState::HandleKeypressL" );
+    
+    TBool handled = ETrue;
+    
+    if ( iKeypress == EShortKeypress )
+        {
+        SelectTag();
+
+        HandleEventL( EVoiceTagSoftKeySelect );
+        }
+    else if ( iKeypress == ESelectKeypress )
+        {        
+        SelectTag();
+        
+        DataStorage().SetVerificationTryCount( KVerificationTries );
+        
+        HandleEventL( SelectCommandById() );
+        }
+    else
+        {
+        handled = EFalse;
+        }
+    
+    return handled;
+    }
+    
+// ---------------------------------------------------------------------------
+// CVerificationState::PlayPromptL
+// ---------------------------------------------------------------------------
+//
+void CVerificationState::PlayPromptL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationState::PlayPromptL" );
+
+    // if TTS is used
+    if ( DataStorage().SynthesizerMode() != KErrNone ||
+         DataStorage().DeviceLockMode() )
+        {
+        HBufC* text = NULL;
+                                  
+        if ( DataStorage().CompleteTagList()->At( iTagIndex )->Context()->ContextName() == KVoiceDialContext )
+            {
+            text = DataStorage().CompleteTagList()->At( iTagIndex )->SpeechItem()->PartialTextL( KNameTrainingIndex );
+            }
+        else
+            {
+            text = HBufC::NewL( 0 );
+            }
+
+        CleanupStack::PushL( text );
+        
+        HBufC* select = StringLoader::LoadLC( R_QAN_VC_VERIFICATION_SELECT );
+        HBufC* other = StringLoader::LoadLC( R_QAN_VC_VERIFICATION_OTHER );
+        HBufC* cancel = StringLoader::LoadLC( R_QAN_VC_VERIFICATION_CANCEL );
+                
+        DataStorage().TtsPlayer()->PlayL(
+            DataStorage().CompleteTagList()->At( iTagIndex )->SpeechItem()->Text(), 0,
+            DataStorage().CompleteTagList()->At( iTagIndex )->SpeechItem()->Text().Length(),
+            *text, *select, *other, *cancel );
+
+        CleanupStack::PopAndDestroy( cancel );
+        CleanupStack::PopAndDestroy( other );
+        CleanupStack::PopAndDestroy( select );
+        CleanupStack::PopAndDestroy( text );
+        }
+    }
+    
+// ---------------------------------------------------------
+// CVerificationState::SelectTag
+// ---------------------------------------------------------
+//   
+void CVerificationState::SelectTag()
+    {
+    RUBY_DEBUG0( "CVerificationState::SelectTag START" );
+    
+    if ( DataStorage().CompleteTagList()->Count() > KErrNone )
+        {
+        DataStorage().SetTag( DataStorage().CompleteTagList()->At( iTagIndex ), ETrue );
+    
+        DataStorage().CompleteTagList()->Delete( iTagIndex );
+        }
+        
+    RUBY_DEBUG0( "CVerificationState::SelectTag EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVerificationState::SelectTag
+// ---------------------------------------------------------
+//       
+TInt CVerificationState::SelectCommandById()
+    {
+    RUBY_DEBUG0( "CVerificationState::SelectCommandById START" );
+    
+    TInt index = KErrGeneral;
+    
+    if ( DataStorage().AdditionalTagList() &&
+         DataStorage().AdditionalTagList()->Count() > KErrNone )
+        {
+        index = DataStorage().AdditionalTagList()->At( 0 )->RRD()->IntArray()->At( 0 );
+        DataStorage().SetAdditionalTagList( NULL );
+        }
+        
+    RUBY_DEBUG0( "CVerificationState::SelectCommandById EXIT" );
+    
+    return iVerificationDialog->SelectedCommand( index );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicverificationtrainingstate.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,340 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <StringLoader.h>
+#include <centralrepository.h>
+
+#include <nssvasctrainingparameters.h>
+
+#include <srsfdomaincrkeys.h>
+
+#include <vuivoicerecognition.rsg>
+
+#include "vuicstate.h"
+#include "vuicverificationtrainingstate.h"
+#include "vuictutorialstate.h"
+#include "vuicerrorstate.h"
+
+#include "vuicdatastorage.h"
+
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "rubydebug.h"
+
+// Constants
+
+static const TInt KCommandIds[] = 
+    {
+    R_QAN_VC_VERIFICATION_SELECT,
+    R_QAN_VC_VERIFICATION_OTHER,
+    R_QAN_VC_VERIFICATION_CANCEL
+    };
+    
+// -----------------------------------------------------------------------------
+// CVerificationTrainingState::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVerificationTrainingState* CVerificationTrainingState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
+    {
+    CVerificationTrainingState* self = new (ELeave) CVerificationTrainingState( aDataStorage, aUiModel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }       
+    
+// Destructor       
+CVerificationTrainingState::~CVerificationTrainingState()
+    {
+    RUBY_DEBUG0( "CVerificationTrainingState::~CVerificationTrainingState START" );
+    
+    delete iVasDbManager;
+    iContextManager = NULL;
+    iTagManager = NULL;
+    
+    if ( iTags )
+        {
+        iTags->ResetAndDestroy();
+        }
+    delete iTags;
+    
+    delete iTrainingParameters;
+    
+    SaveLanguage();
+    
+    RUBY_DEBUG0( "CVerificationTrainingState::~CVerificationTrainingState EXIT" );
+    }
+    
+// ---------------------------------------------------------
+// CVerificationTrainingState::HandleEventL
+// ---------------------------------------------------------
+//       
+void CVerificationTrainingState::HandleEventL( TInt aEvent )
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::HandleEventL" );
+
+    CState* nextState = NULL;
+    
+    switch( aEvent )
+        {
+        case KErrNone:
+        
+            if ( iInternalState == EStarted )
+                {
+                nextState = this;
+                iInternalState = EContextDeleted;
+                }
+            else if ( iInternalState == EContextDeleted )
+                {
+                nextState = this;
+                iInternalState = EContextReady;
+                }
+            else if ( iInternalState == EContextReady )
+                {
+                --iExpectedCallbacks;
+                
+                if ( iExpectedCallbacks == KErrNone )
+                    {
+                    nextState = this;
+                    iInternalState = ECommandsTrained;
+                    }
+                }
+            else
+                {
+                --iExpectedCallbacks;
+                
+                if ( iExpectedCallbacks == KErrNone )
+                    {
+                    nextState = CTutorialState::NewL( DataStorage(), UiModel() );
+                    iInternalState = ECommandsSaved;
+                    }
+                }
+            break;
+            
+        default:
+            
+            nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
+            break;
+        }
+
+    DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
+    }
+
+// ---------------------------------------------------------
+// CVerificationTrainingState::ExecuteL
+// ---------------------------------------------------------
+//       
+void CVerificationTrainingState::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::ExecuteL" );
+    
+    if ( iInternalState == ENotStarted )
+        {
+        iInternalState = EStarted;
+        
+        // Delete context if already exists
+        if ( DataStorage().Context()->ContextName() == KVoiceVerificationContext )
+            {
+            if ( iContextManager->DeleteContext( DataStorage().VoiceRecognitionImpl(),
+                                                 DataStorage().Context() ) != KErrNone )
+                {
+                RUBY_ERROR0( "CVerificationTrainingState::ExecuteL - DeleteContext call failed" );
+                HandleEventL( KErrGeneral );
+                }
+            }
+        else 
+            {
+            HandleEventL( KErrNone );
+            }
+        }
+    else if ( iInternalState == EContextDeleted )
+        {
+        // Create new context
+        MNssContext* vasContext = iContextManager->CreateContextL();
+        DataStorage().SetContext( vasContext );
+            
+        vasContext->SetNameL( KVoiceVerificationContext );
+        vasContext->SetGlobal( EFalse );
+    
+        if ( iContextManager->SaveContext( DataStorage().VoiceRecognitionImpl(),
+                                           vasContext ) != KErrNone )
+            {
+            RUBY_ERROR0( "CVerificationTrainingState::ExecuteL - SaveContext call failed" );
+            HandleEventL( KErrGeneral );
+            }
+        }
+    else if ( iInternalState == EContextReady )
+        { 
+        TrainTagsL();        
+        }
+     else if ( iInternalState == ECommandsTrained )
+        {
+        SaveTagsL();
+        }
+    }
+
+// ---------------------------------------------------------
+// CVerificationTrainingState::CVerificationTrainingState
+// ---------------------------------------------------------
+//              
+CVerificationTrainingState::CVerificationTrainingState( CDataStorage& aDataStorage, CUiModel& aUiModel )
+ : CState( aDataStorage, aUiModel ), iInternalState( ENotStarted ), iTags(),
+   iExpectedCallbacks( 0 )
+    {
+    }
+
+// ---------------------------------------------------------
+// CVerificationTrainingState::ConstructL
+// ---------------------------------------------------------
+//           
+void CVerificationTrainingState::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::ConstructL" );
+    
+    CState::ConstructL();
+    
+    iVasDbManager = CNssVASDBMgr::NewL();
+    iVasDbManager->InitializeL();
+    iTagManager = iVasDbManager->GetTagMgr();
+    iContextManager = iVasDbManager->GetContextMgr();   
+    }
+    
+// ---------------------------------------------------------
+// CVerificationTrainingState::CreateTagsL
+// ---------------------------------------------------------
+//  
+void CVerificationTrainingState::CreateTagsL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::CreateTagsL" );
+    
+    iTags = new ( ELeave ) RPointerArray<MNssTag>;
+ 
+    for ( int i = 0; i < KVerificationCommands; ++i )
+        {
+        iTags->Append( iTagManager->CreateTagL( DataStorage().Context() ) );
+        }
+    }
+    
+// ---------------------------------------------------------
+// CVerificationTrainingState::ConstructTrainingParametersL
+// ---------------------------------------------------------
+//  
+void CVerificationTrainingState::ConstructTrainingParametersL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::ConstructTrainingParametersL" );
+    
+    RArray<TLanguage>* languageArray = new ( ELeave ) RArray<TLanguage>;
+    CleanupDeletePushL( languageArray ); // Protect [allocated on the heap] array itself
+    CleanupClosePushL( *languageArray );  // Protect the array elements
+    
+    // Always generate a pronunciation in UI language
+    User::LeaveIfError( languageArray->Append( User::Language() ) );
+    
+    iTrainingParameters = CNssTrainingParameters::NewL();
+    
+    iTrainingParameters->SetLanguages( languageArray );
+    
+    // For array elements pushed via CleanupClosePushL
+    CleanupStack::Pop( languageArray );
+    CleanupStack::Pop( languageArray ); 
+    }
+    
+// ---------------------------------------------------------
+// CVerificationTrainingState::TrainTagsL
+// ---------------------------------------------------------
+//  
+void CVerificationTrainingState::TrainTagsL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::TrainTagsL" );
+    
+    CreateTagsL();
+    
+    ConstructTrainingParametersL();
+    
+    iExpectedCallbacks = KVerificationCommands;
+    
+    for ( int i = 0; i < KVerificationCommands; ++i )
+        {
+        HBufC* text = StringLoader::LoadLC( KCommandIds[ i ] );    
+        
+        MNssSpeechItem* speechItem = static_cast<MNssTag*>( (*iTags)[ i ] )->SpeechItem();
+        speechItem->SetTextL( *text );
+        
+        CleanupStack::PopAndDestroy( text );
+        
+        MNssRRD* rrd = static_cast<MNssTag*>( (*iTags)[ i ] )->RRD();
+        
+        rrd->IntArray()->AppendL( i );
+            
+        MNssSpeechItem::TNssSpeechItemResult result = 
+		    speechItem->TrainTextL( DataStorage().VoiceRecognitionImpl(),
+		                            iTrainingParameters );
+    
+        if ( result != MNssSpeechItem::EVasErrorNone )
+            {
+            RUBY_ERROR1( "CVerificationTrainingState::TrainTagsL - Training start failed with the nss code [%d]", result );
+
+            HandleEventL( KErrGeneral );
+            }
+        }
+    }
+    
+// ---------------------------------------------------------
+// CVerificationTrainingState::SaveTagsL
+// ---------------------------------------------------------
+//  
+void CVerificationTrainingState::SaveTagsL()
+    {
+    RUBY_DEBUG_BLOCK( "CVerificationTrainingState::SaveTagsL" );
+    
+    iExpectedCallbacks = KVerificationCommands;
+    
+    for ( int i = 0; i < KVerificationCommands; ++i )
+        {
+        TInt result = 
+            iTagManager->SaveTag( DataStorage().VoiceRecognitionImpl(),
+                                  static_cast<MNssTag*>( (*iTags)[ i ] ) );
+        if ( result != KErrNone ) 
+            {
+            RUBY_ERROR1( "CVerificationTrainingState::SaveTagsL - Savetag start failed with the nss code [%d]", result );
+
+            HandleEventL( KErrGeneral );
+            }
+        }
+    }
+        
+// ---------------------------------------------------------
+// CVerificationTrainingState::SaveLanguage
+// ---------------------------------------------------------
+//           
+void CVerificationTrainingState::SaveLanguage()
+    {
+    RUBY_DEBUG0( "CVerificationTrainingState::SaveLanguage START" );
+    
+    TRAP_IGNORE(
+        CRepository* client = CRepository::NewLC( KCRUidSRSFSettings );    
+        client->Set( KSRSFVoiceUiLanguage, User::Language() );        
+        CleanupStack::PopAndDestroy( client ) );
+    
+    RUBY_DEBUG0( "CVerificationTrainingState::SaveLanguage EXIT" );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicvoicerecog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "vuicvoicerecog.h"
+
+#include "rubydebug.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CVoiceRecog::CVoiceRecog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVoiceRecog::CVoiceRecog()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CVoiceRecog::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVoiceRecog::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecog::ConstructL" );
+    }
+
+// ---------------------------------------------------------------------------
+// CVoiceRecog::NewLC
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CVoiceRecog* CVoiceRecog::NewLC()
+    {
+    CVoiceRecog* self = new (ELeave) CVoiceRecog();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CVoiceRecog::NewL
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CVoiceRecog* CVoiceRecog::NewL() 
+    {   
+    CVoiceRecog* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// Destructor
+CVoiceRecog::~CVoiceRecog()
+    {
+    RUBY_DEBUG0( "CVoiceRecog::~CVoiceRecog START" );
+
+    RUBY_DEBUG0( "CVoiceRecog::~CVoiceRecog EXIT" );  
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicvoicerecogdialog.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The Voice Recognition dialog for clients
+*
+*/
+
+
+// INCLUDE FILES
+#include <coemain.h>
+#include <apgcli.h>
+#include <apgtask.h>
+#include <apacmdln.h>
+
+#include "vuicvoicerecogdialog.h"
+
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialog::CVoiceRecognitionDialog
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CVoiceRecognitionDialog::CVoiceRecognitionDialog()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialog::CVoiceRecognitionDialog" );
+    // Nothing
+    }
+
+// Destructor
+EXPORT_C CVoiceRecognitionDialog::~CVoiceRecognitionDialog()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialog::~CVoiceRecognitionDialog START" );
+        
+    RUBY_DEBUG0( "CVoiceRecognitionDialog::~CVoiceRecognitionDialog EXIT" );
+    }
+
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialog::ExecuteLD
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CVoiceRecognitionDialog::ExecuteLD()
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialog::ExecuteLD" );
+    
+    TUid uid = { 0x101F8543 };
+
+    TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
+    TApaTask apaTask = apaTaskList.FindApp( uid );
+    
+    if ( apaTask.Exists() )
+        {
+        apaTask.BringToForeground();
+        }
+    else
+        {
+        RApaLsSession apaLsSession;
+        User::LeaveIfError( apaLsSession.Connect() );
+        
+        TApaAppInfo appInfo;
+        User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, uid ) );
+        
+        TFileName appName = appInfo.iFullName;
+        CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
+
+        apaCommandLine->SetExecutableNameL( appName );
+        apaCommandLine->SetCommandL( EApaCommandRun );
+        User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) );
+        CleanupStack::PopAndDestroy( apaCommandLine );
+    
+        apaLsSession.Close();
+        }
+        
+    delete this;
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialog::Cancel
+// ---------------------------------------------------------
+//
+EXPORT_C void CVoiceRecognitionDialog::Cancel()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialog::Cancel START" );
+    
+    delete this;
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialog::Cancel EXIT" );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voiceui/voiceuivoicerecognition/src/vuicvoicerecogdialogimpl.cpp	Wed Sep 01 12:29:17 2010 +0100
@@ -0,0 +1,721 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The Voice Recognition dialog implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+
+#include <voiceuidomainpskeys.h>
+
+#include "vuivoicerecognition.hrh"
+
+#include "vuicvoicerecogdialogimpl.h"
+
+#include "vuicpropertyhandler.h"
+
+#include "vuicdatastorage.h"
+#include "vuicuimodel.h"
+
+#include "vuicprecheckstate.h"
+
+#include "vuimvoicerecogdialogcallback.h"
+
+#include "rubydebug.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CVoiceRecognitionDialogImpl* CVoiceRecognitionDialogImpl::NewL( MVoiceRecognitionDialogCallback* aObserver )
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::NewL" );
+    
+    CVoiceRecognitionDialogImpl* self = new (ELeave) CVoiceRecognitionDialogImpl( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// Destructor
+CVoiceRecognitionDialogImpl::~CVoiceRecognitionDialogImpl()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::~CVoiceRecognitionDialogImpl START" );
+
+    iObserver = NULL;
+        
+    iMutex.Close();
+    
+    Cancel();
+
+    // If states are equal only one can be deleted       
+    if ( iState != iNextState )
+        {
+        delete iState;
+        delete iNextState;
+        }
+    else
+        {
+        delete iState;
+        }
+
+    delete iDataStorage;
+    delete iUiModel;    
+        
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::~CVoiceRecognitionDialogImpl EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::ExecuteL
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::ExecuteL()
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::ExecuteL" );
+
+    ChangeState( CPrecheckState::NewL( *iDataStorage, *iUiModel ) );
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::SetDeviceLockMode
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::SetOnlyCallsAllowed()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SetOnlyCallsAllowed START" );
+    
+    iDataStorage->SetDeviceLockMode( ETrue );
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SetOnlyCallsAllowed EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl( MVoiceRecognitionDialogCallback* aObserver )
+ : CActive( EPriorityStandard ), iObserver( aObserver )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl START" );
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::ConstructL()
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::ConstructL" );
+    
+    CActiveScheduler::Add( this );
+    
+    iDataStorage = CDataStorage::NewL( this );
+    
+    iUiModel = CUiModel::NewL();
+    
+    iMutex.CreateLocal();
+    }
+            
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::RunL
+// Handle a change event.
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::RunL()
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::RunL" );
+    
+    if ( iState != iNextState )
+        {
+        delete iState;
+        iState = iNextState;
+        }
+    iNextState = NULL;
+    
+    if ( iMutex.IsHeld() )
+        {
+        iMutex.Signal();
+        }
+    
+    TRAPD( error, iState->ExecuteL() );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::RunL - State execution failed with error [%d]", error );
+        Exit();
+        }
+    }
+        
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::DoCancel
+// Cancel the request to receive events.
+// ---------------------------------------------------------
+//        
+void CVoiceRecognitionDialogImpl::DoCancel()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DoCancel START" );
+
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DoCancel EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleKeypressL
+// Called when a key is pressed
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandleKeypressL( TInt aSoftkey )
+    {
+    RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::HandleKeypressL" );
+    
+    CheckState();
+    
+    TRAPD( error, iState->HandleEventL( aSoftkey ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleKeypressL - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete
+// Called when HandleRecognizeInit() completes
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete( TNssRecognizeInitError aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete START" );
+    
+    CheckState();
+       
+    TInt errorCode = KErrNone;
+    
+    if ( aErrorCode == MNssRecognizeInitCompleteHandler::EVasRecognizeInitFailed )
+        {
+        errorCode = KErrInit;
+        }
+    else if ( aErrorCode == MNssRecognizeInitCompleteHandler::EVasNoTagInContexts )
+        {
+        errorCode = KErrNoContacts;
+        }
+    else if ( aErrorCode != MNssRecognizeInitCompleteHandler::EVasErrorNone )
+        {
+        errorCode = KErrGeneral;
+        }
+    
+    TRAPD( error, iState->HandleEventL( errorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete - Event handling failed with error [%d]", error );
+        Exit();
+        }
+   
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete EXIT" );
+    }
+
+#ifndef __WINS__  
+#ifdef __FULLDUPLEX_CHANGE
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandlePreSamplingStarted
+// Called when HandlePreSamplingStarted() completes
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandlePreSamplingStarted( TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePreSamplingStarted START" );
+    
+    CheckState();
+          
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandlePreSamplingStarted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+   
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePreSamplingStarted EXIT" );
+    }
+#endif // __FULLDUPLEX_CHANGE
+#endif // __WINS__  
+   
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleRecordStarted
+// Called when recording has started
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandleRecordStarted()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecordStarted START" );
+    
+    CheckState();
+
+    TRAPD( error, iState->HandleEventL( KErrNone ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleRecordStarted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecordStarted EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleEouDetected
+// Called when end-of-utterance is detected
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandleEouDetected()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleEouDetected START" );
+    
+    CheckState();
+    
+    TRAPD( error, iState->HandleEventL( KErrNone ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleEouDetected - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleEouDetected EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleRecognizeComplete
+// Called when recognition ends
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandleRecognizeComplete( CArrayPtrFlat<MNssTag>* aTagList,
+                                                           TNssRecognizeError aErrorCode  )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeComplete START" );
+    
+    CheckState();
+
+    TInt errorCode = KErrNone;
+    
+    if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedNoMatch )
+        {
+        errorCode = KErrNoMatch;
+        }
+    else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognizeAccessDeny )
+        {
+        errorCode = KErrAbort;
+        }
+    else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognizeFailed )
+        {
+        errorCode = KErrRecogFailed;
+        }
+    else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedNoSpeech )
+        {
+        errorCode = KErrNoSpeech;
+        }
+    else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedTooEarly )
+        {
+        errorCode = KErrTooEarly;
+        }
+    else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedTooLong )
+        {
+        errorCode = KErrTooLong;
+        }
+    else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedTooShort )
+        {
+        errorCode = KErrTooShort;
+        }
+    else if ( aErrorCode != MNssRecognizeEventHandler::EVasErrorNone )
+        {
+        errorCode = KErrGeneral;
+        }
+
+    // If complete tag list has been set then results are voice verification results
+    // and should be put to additional tag list
+    if ( !iDataStorage->CompleteTagList() )
+        {
+        iDataStorage->SetCompleteTagList( aTagList );
+        }
+    else
+        {
+        iDataStorage->SetAdditionalTagList( aTagList );
+        }
+
+    TRAPD( error, iState->HandleEventL( errorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleRecognizeComplete - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeComplete EXIT" );
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleAdaptComplete
+// Called when the adaptation is complete
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandleAdaptComplete( TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleAdaptComplete START" );
+    
+    CheckState();
+      
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleAdaptComplete - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleAdaptComplete EXIT" );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::MapcInitComplete
+// CMdaAudioPlayerUtility initialization complete
+// ---------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::MapcInitComplete( TInt aError,
+                                                    const TTimeIntervalMicroSeconds& aDuration )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcInitComplete START" );
+    
+    CheckState();
+
+    iDataStorage->SetPlayDuration( aDuration );
+    
+    TRAPD( error, iState->HandleEventL( aError ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::MapcInitComplete - Event handling failed with error [%d]", error );
+        Exit();
+        }
+
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcInitComplete EXIT" );
+    }
+
+// ---------------------------------------------------------------------------
+// CVoiceRecogPlaybackDialog::MapcPlayComplete
+// Playback complete, notify observer
+// ---------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::MapcPlayComplete( TInt aError )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcPlayComplete START" );
+    
+    CheckState();
+ 
+    TRAPD( error, iState->HandleEventL( aError ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::MapcPlayComplete - Event handling failed with error [%d]", error );
+        Exit();
+        }
+        
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcPlayComplete EXIT" );
+    }
+    
+// ---------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::MapcCustomCommandEvent
+// Called when asynchronous custom command finishes.
+// ---------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::MapcCustomCommandEvent( TInt /*aEvent*/, TInt aError )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcCustomCommandEvent START" );
+    
+    CheckState();
+      
+    TRAPD( error, iState->HandleEventL( aError ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::MapcCustomCommandEvent - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcCustomCommandEvent EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::GetContextCompleted
+// -----------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::GetContextCompleted( MNssContext* aContext, TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextCompleted START" );
+    
+    CheckState();
+    
+    iDataStorage->SetContext( aContext );
+      
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::GetContextCompleted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextCompleted EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::GetContextListCompleted
+// -----------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::GetContextListCompleted( MNssContextListArray* /*aContextList*/,
+                                                           TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextListCompleted START" );
+    
+    CheckState();
+      
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::GetContextListCompleted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextListCompleted EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::GetTagListCompleted
+// -----------------------------------------------------------------------------
+//    
+void CVoiceRecognitionDialogImpl::GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetTagListCompleted START" );
+    
+    CheckState();
+
+    iDataStorage->SetAdditionalTagList( aTagList );
+
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::GetTagListCompleted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetTagListCompleted EXIT" );
+    }
+    
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::SaveContextCompleted
+// -----------------------------------------------------------------------------
+//  
+void CVoiceRecognitionDialogImpl::SaveContextCompleted( TInt aErrorCode )
+	{
+	RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveContextCompleted START" );
+	
+    CheckState();
+
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::SaveContextCompleted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveContextCompleted EXIT" );
+	}
+    
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::HandleTrainComplete
+// -----------------------------------------------------------------------------
+//       
+void CVoiceRecognitionDialogImpl::HandleTrainComplete( TInt aErrorCode )
+	{
+	RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleTrainComplete START" );
+    
+    CheckState();
+
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleTrainComplete - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleTrainComplete EXIT" );
+	}
+    
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::SaveTagCompleted
+// -----------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::SaveTagCompleted( TInt aErrorCode )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveTagCompleted START" );
+    
+    CheckState();
+
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::SaveTagCompleted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveTagCompleted EXIT" );
+    }
+
+// -----------------------------------------------------------------------------
+// CVoiceRecognitionDialogImpl::DeleteContextCompleted
+// -----------------------------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::DeleteContextCompleted( TInt aErrorCode )
+	{
+	RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DeleteContextCompleted START" );
+    
+    CheckState();
+
+    TRAPD( error, iState->HandleEventL( aErrorCode ) );
+    
+    if ( error != KErrNone )
+        {
+        RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::DeleteContextCompleted - Event handling failed with error [%d]", error );
+        Exit();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DeleteContextCompleted EXIT" );
+	}
+    
+// ----------------------------------------------------
+// CVoiceRecognitionDialog::HandlePropertyValueChange
+// Handle property value change event.
+// ----------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::HandlePropertyValueChange( TInt aValue )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePropertyValueChange START" );
+    
+    CheckState();
+   
+    switch( aValue )
+        {
+        // Short press of a headset key
+        case KVoiceUiShortPressEvent:
+            {
+            TRAP_IGNORE( iState->HandleEventL( EShortKeypress ) );
+            break;
+            }
+
+        // Long press of a headset key
+        case KVoiceUiLongPressEvent:
+            {
+            TRAP_IGNORE( iState->HandleEventL( ELongKeypress ) );
+            break;
+            }
+
+        default:
+            {
+            // pass
+            break;
+            }
+        }
+
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePropertyValueChange EXIT" );         
+    }
+       
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::ChangeState
+// Change current state and set object active
+// ---------------------------------------------------------
+//  
+void CVoiceRecognitionDialogImpl::ChangeState( CState* aNextState )
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::ChangeState START" ); 
+    
+    if ( aNextState )
+        {
+        CheckState();
+        
+        iNextState = aNextState;
+        
+        if ( !IsActive() )
+            {
+            TRequestStatus* pRS = &iStatus;
+            User::RequestComplete( pRS, KErrNone );
+            SetActive();
+            }        
+        }       
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::ChangeState EXIT" ); 
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::CheckState
+// Check if state can be changed and if it can't starts waiting
+// ---------------------------------------------------------
+//      
+void CVoiceRecognitionDialogImpl::CheckState()
+    {
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CheckState START" ); 
+    
+    if ( iNextState )
+        {
+        RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CheckState - Start waiting" );
+        iMutex.Wait();
+        }
+    
+    RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CheckState EXIT" ); 
+    }
+
+// ---------------------------------------------------------
+// CVoiceRecognitionDialogImpl::Exit
+// 
+// ---------------------------------------------------------
+//
+void CVoiceRecognitionDialogImpl::Exit()
+    {
+    if ( iObserver )
+        {
+        iObserver->DialogDismissed();
+        
+        iObserver = NULL;
+        }
+    }
+
+// End of File