os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionCustomCommandParser.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionCustomCommandParser.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,615 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __SPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H__
    1.20 +#define __SPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H__
    1.21 +
    1.22 +// INCLUDE FILES
    1.23 +#include <mmf/common/mmfcontroller.h>
    1.24 +#include <mmf/common/speechrecognitioncustomcommandimplementor.h>
    1.25 +#include <mmf/common/speechrecognitiondataclient.h>
    1.26 +
    1.27 +// CLASS DECLARATION
    1.28 +
    1.29 +/**
    1.30 +@publishedAll
    1.31 +@released
    1.32 +
    1.33 +This is the main class of Speech Recognition Custom Commands Parser.
    1.34 +
    1.35 +@since  8.0
    1.36 +*/
    1.37 +class CSpeechRecognitionCustomCommandParser : public CMMFCustomCommandParserBase
    1.38 +	{
    1.39 +public:
    1.40 +
    1.41 +	/**
    1.42 +	Factory function for creating this class.
    1.43 +
    1.44 +	@param  aImplementor
    1.45 +	        A reference to a custom commands implementor.
    1.46 +
    1.47 +	@return	A pointer to a CSpeechRecognitionCustomCommandParser object.
    1.48 +
    1.49 +    @since  8.0
    1.50 +	*/
    1.51 +	IMPORT_C static CSpeechRecognitionCustomCommandParser* NewL(
    1.52 +						MSpeechRecognitionCustomCommandImplementor&
    1.53 +						aImplementor);
    1.54 +
    1.55 +	/**
    1.56 +	Destructor.
    1.57 +
    1.58 +	@since  8.0
    1.59 +	*/
    1.60 +	IMPORT_C  ~CSpeechRecognitionCustomCommandParser();
    1.61 +
    1.62 +	/**
    1.63 +    @internalTechnology
    1.64 +
    1.65 +	Handles the request from the client.
    1.66 +
    1.67 +	@param  aMessage			
    1.68 +	        The message containing the information of the request.
    1.69 +
    1.70 +	@since  8.0
    1.71 +	*/
    1.72 +	void HandleRequest(TMMFMessage& aMessage);
    1.73 +
    1.74 +	private:
    1.75 +	/**
    1.76 +	C++ constructor for a CSpeechRecognitionCustomCommandParser class.
    1.77 +
    1.78 +	@param  aImplementor
    1.79 +	        A reference to a custom commands implementor.
    1.80 +
    1.81 +	@since  8.0
    1.82 +	*/
    1.83 +	CSpeechRecognitionCustomCommandParser(
    1.84 +		MSpeechRecognitionCustomCommandImplementor& aImplementor);
    1.85 +
    1.86 +	/**
    1.87 +	Private method to handle the request from the client.
    1.88 +
    1.89 +	@param  aMessage			
    1.90 +	        The message containing the information of the request.
    1.91 +
    1.92 +	@since  8.0
    1.93 +	*/
    1.94 +	void  DoHandleRequestL(TMMFMessage& aMessage);
    1.95 +
    1.96 +	/**
    1.97 +	Adds a new pronunciation for the given model into the specified lexicon.
    1.98 +
    1.99 +	@param  aMessage			
   1.100 +	        The message containing the information of the request.
   1.101 +
   1.102 +	@since  8.0
   1.103 +	*/
   1.104 +	void DoAddPronunciationL(TMMFMessage& aMessage);
   1.105 +
   1.106 +	/**
   1.107 +	Adds a new rule for the given pronunciation into the specified grammar.
   1.108 +
   1.109 +	@param  aMessage			
   1.110 +	        The message containing the information of the request.
   1.111 +
   1.112 +	@since  8.0
   1.113 +	*/
   1.114 +	void DoAddRuleL(TMMFMessage& aMessage);
   1.115 +
   1.116 +	/**
   1.117 +	Cancels the current operation.
   1.118 +
   1.119 +	@since  8.0
   1.120 +	*/
   1.121 +	void DoCancel();
   1.122 +
   1.123 +	/**
   1.124 +	Commits uncommitted database operations to the database.
   1.125 +
   1.126 +	@since  8.0
   1.127 +	*/
   1.128 +	void DoCommitChangesL();
   1.129 +
   1.130 +	/**
   1.131 +	Creates a new grammar.
   1.132 +
   1.133 +	@param  aMessage
   1.134 +	        A message containing the information of the request.
   1.135 +
   1.136 +	@since  8.0
   1.137 +	*/
   1.138 +	void DoCreateGrammarL(TMMFMessage& aMessage);
   1.139 +
   1.140 +	/**
   1.141 +	Creates a new lexicon.
   1.142 +
   1.143 +	@param  aMessage
   1.144 +	        The message containing the information of the request.
   1.145 +
   1.146 +	@since  8.0
   1.147 +	*/
   1.148 +	void DoCreateLexiconL(TMMFMessage& aMessage);
   1.149 +
   1.150 +	/**
   1.151 +	Creates a new model bank.
   1.152 +
   1.153 +	@param  aMessage
   1.154 +	        The message containing the information of the request.
   1.155 +
   1.156 +	@since  8.0
   1.157 +	*/
   1.158 +	void DoCreateModelBankL(TMMFMessage& aMessage);
   1.159 +
   1.160 +	/**
   1.161 +	Ends the current recognition session. Resources allocated for recognition are freed.
   1.162 +
   1.163 +	@since	8.0
   1.164 +	*/
   1.165 +	void DoEndRecSessionL();
   1.166 +
   1.167 +	/**
   1.168 +	Returns all grammar IDs that belong to the current client, whose UID was set with
   1.169 +	SetClientUid().
   1.170 +
   1.171 +	@since  8.0
   1.172 +	*/
   1.173 +	void DoGetAllClientGrammarIDsL();
   1.174 +
   1.175 +	/**
   1.176 +	Returns all lexicon IDs that belong to the current client, whose UID was set with
   1.177 +	SetClientUid().
   1.178 +
   1.179 +	@since  8.0
   1.180 +	*/
   1.181 +	void DoGetAllClientLexiconIDsL();
   1.182 +
   1.183 +	/**
   1.184 +	Returns all model bank IDs that belong to the current client, whose UID was set with
   1.185 +	SetClientUid().
   1.186 +
   1.187 +	@since  8.0
   1.188 +	*/
   1.189 +	void DoGetAllClientModelBankIDsL();
   1.190 +
   1.191 +	/**
   1.192 +	Returns all grammar IDs that exist (for all clients).
   1.193 +
   1.194 +	@return An error code indicating if the function call was successful. KErrNone on success, otherwise
   1.195 +	        another of the system-wide error codes.
   1.196 +
   1.197 +	@since  8.0
   1.198 +    */
   1.199 +	void DoGetAllGrammarIDsL();
   1.200 +
   1.201 +	/**
   1.202 +	Returns all lexicon IDs that exist (for all clients).
   1.203 +
   1.204 +	@since  8.0
   1.205 +    */
   1.206 +	void DoGetAllLexiconIDsL();
   1.207 +
   1.208 +	/**
   1.209 +	Returns all model bank IDs that exist (for all clients).
   1.210 +
   1.211 +	@since 8.0
   1.212 +    */
   1.213 +	void DoGetAllModelBankIDsL();
   1.214 +
   1.215 +	/**
   1.216 +	Returns all model IDs that exist in the specified model bank.
   1.217 +
   1.218 +	@param  aMessage				
   1.219 +	        The message containing the information of the request.
   1.220 +
   1.221 +	@since  8.0
   1.222 +	*/
   1.223 +	void DoGetAllModelIDsL(TMMFMessage& aMessage);
   1.224 +
   1.225 +	/**
   1.226 +	Returns all pronunciation IDs that exist in the specified lexicon.
   1.227 +
   1.228 +	@param  aMessage				
   1.229 +	        The message containing the information of the request.
   1.230 +
   1.231 +	@since  8.0
   1.232 +	*/
   1.233 +	void DoGetAllPronunciationIDsL(TMMFMessage& aMessage);
   1.234 +
   1.235 +	/**
   1.236 +	Returns all rule IDs that exist in the specified grammar.
   1.237 +
   1.238 +	@param  aMessage				
   1.239 +	        The message containing the information of the request.
   1.240 +
   1.241 +	@since  8.0
   1.242 +	*/
   1.243 +	void DoGetAllRuleIDsL(TMMFMessage& aMessage);
   1.244 +
   1.245 +	/**
   1.246 +	Returns the number of models available for training system wide, based on available disk space.
   1.247 +
   1.248 +	@param  aMessage				
   1.249 +	        The message containing the information of the request.
   1.250 +
   1.251 +	@since  8.0
   1.252 +	*/
   1.253 +	void DoGetAvailableStorageL(TMMFMessage& aMessage);
   1.254 +
   1.255 +	/**
   1.256 +	Returns the engine properties.
   1.257 +
   1.258 +	@param  aMessage				
   1.259 +	        The message containing the information of the request.
   1.260 +
   1.261 +	@since  8.0
   1.262 +	*/
   1.263 +	void DoGetEnginePropertiesL(TMMFMessage& aMessage);
   1.264 +
   1.265 +	/**
   1.266 +	Returns the number of models in the specified model bank.
   1.267 +
   1.268 +	@param  aMessage				
   1.269 +	        The message containing the information of the request.
   1.270 +
   1.271 +	@since  8.0
   1.272 +	*/
   1.273 +	void DoGetModelCountL(TMMFMessage& aMessage);
   1.274 +
   1.275 +	/**
   1.276 +	Checks if the rule is valid or not.
   1.277 +
   1.278 +	@param  aMessage				
   1.279 +	        The message containing the information of the request.
   1.280 +
   1.281 +	@since  8.0
   1.282 +	*/
   1.283 +	void DoGetRuleValidityL(TMMFMessage& aMessage);
   1.284 +
   1.285 +	/**
   1.286 +	Returns the duration of the utterance for the specified model.
   1.287 +
   1.288 +	@param  aMessage				
   1.289 +	        The message containing the information of the request.
   1.290 +
   1.291 +	@since  8.0
   1.292 +	*/
   1.293 +	void DoGetUtteranceDurationL(TMMFMessage& aMessage);
   1.294 +
   1.295 +	/**
   1.296 +	Loads the specified grammar into the recognizer; done prior to recognition.
   1.297 +
   1.298 +	@param  aMessage				
   1.299 +	        The message containing the information of the request.
   1.300 +
   1.301 +	@since  8.0
   1.302 +	*/
   1.303 +	void DoLoadGrammarL(TMMFMessage& aMessage);
   1.304 +
   1.305 +	/**
   1.306 +	Loads the specified lexicon into the recognizer; done prior to recognition.
   1.307 +
   1.308 +	@param  aMessage				
   1.309 +	        The message containing the information of the request.
   1.310 +
   1.311 +	@since  8.0
   1.312 +	*/
   1.313 +	void DoLoadLexiconL(TMMFMessage& aMessage);
   1.314 +
   1.315 +	/**
   1.316 +	Loads the specified model bank into the recognizer; done prior to recognition.
   1.317 +
   1.318 +	@param  aMessage				
   1.319 +	        The message containing the information of the request.
   1.320 +
   1.321 +	@since  8.0
   1.322 +	*/
   1.323 +	void DoLoadModelsL(TMMFMessage& aMessage);
   1.324 +
   1.325 +	/**
   1.326 +	Plays the previously trained utterance.
   1.327 +
   1.328 +	@param  aMessage				
   1.329 +	        The message containing the information of the request.
   1.330 +
   1.331 +	@since  8.0
   1.332 +	*/
   1.333 +	void DoPlayUtteranceL(TMMFMessage& aMessage);
   1.334 +
   1.335 +	/**
   1.336 +	Initiates recognition; performed following loading of model bank, lexicon, and grammar.
   1.337 +
   1.338 +	@param  aMessage				
   1.339 +	        The message containing the information of the request.
   1.340 +
   1.341 +	@since  8.0
   1.342 +	*/
   1.343 +	void DoRecognizeL(TMMFMessage& aMessage);
   1.344 +
   1.345 +	/**
   1.346 +	Records user utterance for training and recognition.
   1.347 +
   1.348 +	@param  aMessage				
   1.349 +	        The message containing the information of the request.
   1.350 +
   1.351 +	@since  8.0
   1.352 +	*/
   1.353 +	void DoRecordL(TMMFMessage& aMessage);
   1.354 +
   1.355 +	/**
   1.356 +	Removes the specified grammar from the permanent storage.
   1.357 +
   1.358 +	Removing a grammar will remove all rules within the grammar.
   1.359 +
   1.360 +	@param  aMessage				
   1.361 +	        The message containing the information of the request.
   1.362 +
   1.363 +	@since  8.0
   1.364 +	*/
   1.365 +	void DoRemoveGrammarL(TMMFMessage& aMessage);
   1.366 +
   1.367 +	/**
   1.368 +	Removes the specified lexicon from the permanent storage.
   1.369 +
   1.370 +	Removing a lexicon will remove all pronunciations within the lexicon.
   1.371 +
   1.372 +	@param  aMessage				
   1.373 +	        The message containing the information of the request.
   1.374 +
   1.375 +	@since  8.0
   1.376 +	*/
   1.377 +	void DoRemoveLexiconL(TMMFMessage& aMessage);
   1.378 +
   1.379 +	/**
   1.380 +	Removes the specified model bank from the permanent storage.
   1.381 +
   1.382 +	Removing a model bank will remove all models within the model bank.
   1.383 +
   1.384 +	@param  aMessage				
   1.385 +	        The message containing the information of the request.
   1.386 +
   1.387 +	@since  8.0
   1.388 +	*/
   1.389 +	void DoRemoveModelBankL(TMMFMessage& aMessage);
   1.390 +
   1.391 +	/**
   1.392 +	Removes the specified model from the specified model bank permanently.
   1.393 +
   1.394 +	@param  aMessage
   1.395 +	        The message containing the information of the request.
   1.396 +
   1.397 +	@since  8.0
   1.398 +	*/
   1.399 +	void DoRemoveModelL(TMMFMessage& aMessage);
   1.400 +
   1.401 +	/**
   1.402 +	Removes the specified pronunciation from the specified lexicon permanently.
   1.403 +
   1.404 +	@param  aMessage				
   1.405 +	        The message containing the information of the request.
   1.406 +
   1.407 +	@since  8.0
   1.408 +	*/
   1.409 +	void DoRemovePronunciationL(TMMFMessage& aMessage);
   1.410 +
   1.411 +	/**
   1.412 +	Removes the specified rule from the specified grammar permanently.
   1.413 +
   1.414 +	@param  aMessage				
   1.415 +	        The message containing the information of the request.
   1.416 +
   1.417 +	@since  8.0
   1.418 +	*/
   1.419 +	void DoRemoveRuleL(TMMFMessage& aMessage);
   1.420 +
   1.421 +	/**
   1.422 +	Sets the UID of the client.
   1.423 +
   1.424 +	@param  aMessage				
   1.425 +	        The message containing the information of the request.
   1.426 +
   1.427 +	@since  8.0
   1.428 +	*/
   1.429 +	void DoSetClientUidL(TMMFMessage& aMessage);
   1.430 +
   1.431 +	/**
   1.432 +	Starts a new recognition session.
   1.433 +
   1.434 +	@param  aMessage				
   1.435 +	        The message containing the information of the request.
   1.436 +
   1.437 +	@since  8.0
   1.438 +	*/
   1.439 +	void DoStartRecSessionL(TMMFMessage& aMessage);
   1.440 +
   1.441 +	/**
   1.442 +	Trains a new model into the specified model bank.
   1.443 +
   1.444 +	@param  aMessage				
   1.445 +	        The message containing the information of the request.
   1.446 +
   1.447 +	@since  8.0
   1.448 +	*/
   1.449 +	void DoTrainL(TMMFMessage& aMessage);
   1.450 +
   1.451 +	/**
   1.452 +	Unloads the specified rule from the specified grammar in temporary
   1.453 +	memory, previously loaded with LoadGrammarL().
   1.454 +
   1.455 +	The rule in the permanent storage remains intact.
   1.456 +
   1.457 +	@param  aMessage
   1.458 +	        The message containing the information of the request.
   1.459 +
   1.460 +	@since  8.0
   1.461 +	*/
   1.462 +	void DoUnloadRuleL(TMMFMessage& aMessage);
   1.463 +
   1.464 +	/**
   1.465 +	Loads the specified parameters into the engine.
   1.466 +
   1.467 +	@param  aMessage				
   1.468 +	        The message containing the information of the request.
   1.469 +
   1.470 +	@since  8.0
   1.471 +	*/
   1.472 +	void DoLoadEngineParametersL(TMMFMessage& aMessage);
   1.473 +
   1.474 +	/**
   1.475 +	Copies the pronunciation ID array stored by a previous GetAllPronunciationIDs call.
   1.476 +
   1.477 +	@param  aMessage
   1.478 +	        The message containing the information of the request.
   1.479 +
   1.480 +	@since  8.0
   1.481 +	*/
   1.482 +	void DoCopyPronunciationIDArrayL(TMMFMessage& aMessage);
   1.483 +
   1.484 +	/**
   1.485 +	Copy the model ID array stored by a previous GetAllModelIDs call.
   1.486 +
   1.487 +	@param  aMessage				
   1.488 +	        The message containing the information of the request.
   1.489 +
   1.490 +	@since  8.0
   1.491 +	*/
   1.492 +	void DoCopyModelIDArrayL(TMMFMessage& aMessage);
   1.493 +
   1.494 +	/**
   1.495 +	Copies the rule ID array stored by a previous GetAllRuleIDs call.
   1.496 +
   1.497 +	@param  aMessage				
   1.498 +	        The message containing the information of the request.
   1.499 +
   1.500 +	@since  8.0
   1.501 +	*/
   1.502 +	void DoCopyRuleIDArrayL(TMMFMessage& aMessage);
   1.503 +	/**
   1.504 +	Copies the grammar ID array stored by a previous GetAllGrammarIDs call.
   1.505 +
   1.506 +	@param  aMessage				
   1.507 +	        The message containing the information of the request.
   1.508 +
   1.509 +	@since  8.0
   1.510 +	*/
   1.511 +	void DoCopyGrammarIDArrayL(TMMFMessage& aMessage);
   1.512 +
   1.513 +	/**
   1.514 +	Copies the lexicon ID array stored by a previous GetAllLexiconIDs call.
   1.515 +
   1.516 +	@param  aMessage				
   1.517 +	        The message containing the information of the request.
   1.518 +
   1.519 +	@since  8.0
   1.520 +	*/
   1.521 +	void DoCopyLexiconIDArrayL(TMMFMessage& aMessage);
   1.522 +
   1.523 +	/**
   1.524 +	Copies the modelBank ID array stored by a previous GetAllModelBankIDs call.
   1.525 +
   1.526 +	@param  aMessage
   1.527 +	        The message containing the information of the request.
   1.528 +
   1.529 +	@since  8.0
   1.530 +	*/
   1.531 +	void DoCopyModelBankIDArrayL(TMMFMessage& aMessage);
   1.532 +
   1.533 +	/**
   1.534 +	Externalises the result set into a descriptor, so that it can be copied into an array.
   1.535 +	*/
   1.536 +	void DoExternalizeResultSetL();
   1.537 +
   1.538 +	/**
   1.539 +	Copies the previously externalised result set into a message. The message must be the same size as
   1.540 +	the stored externalized result set.
   1.541 +	*/
   1.542 +	void DoCopyResultSetL(TMMFMessage& aMessage);
   1.543 +
   1.544 +
   1.545 +	/**
   1.546 +	Extracts an array from first parameter of TMMFMessage.
   1.547 +
   1.548 +	@param  aMessage
   1.549 +	        The message to copy the array from.
   1.550 +	@param  aArray
   1.551 +	        The array to copy into.
   1.552 +
   1.553 +	@since  8.0
   1.554 +	*/
   1.555 +	void DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray<TInt>& aArray);
   1.556 +
   1.557 +	/**
   1.558 +	Extracts an array from second parameter of TMMFMessage.
   1.559 +
   1.560 +	@param  aMessage				
   1.561 +	        The message to copy array from.
   1.562 +	@param  aArray					
   1.563 +	        The array to copy into.
   1.564 +
   1.565 +	@since  8.0
   1.566 +	*/
   1.567 +	void DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray<TInt>& aArray);
   1.568 +
   1.569 +	/**
   1.570 +	Extracts an integer array from the descriptor.
   1.571 +
   1.572 +	@param  aDescriptor				
   1.573 +	        The descriptor containing an integer.
   1.574 +	@param  aArray
   1.575 +	        The array to copy into.
   1.576 +
   1.577 +	@since  8.0
   1.578 +	*/
   1.579 +	void DoExtractIntArrayL(TDes8& aDescriptor, RArray<TInt>& aArray);
   1.580 +
   1.581 +
   1.582 +
   1.583 +	/**
   1.584 +	Copies the specified integer array given into a TMMFMessage.
   1.585 +
   1.586 +	@param  aMessage
   1.587 +	        The message to copy the array into.
   1.588 +	@param  aArray
   1.589 +	        The array to copy from.
   1.590 +
   1.591 +	@since  8.0
   1.592 +	*/
   1.593 +	void DoCopyIntArrayL(TMMFMessage& aMessage, const RArray<TInt>& aArray);
   1.594 +
   1.595 +
   1.596 +private:
   1.597 +	// reference to the Custom Command Implementor class
   1.598 +	MSpeechRecognitionCustomCommandImplementor& iImplementor; 
   1.599 +
   1.600 +	RArray<TPronunciationID> iPronunciationIDs;
   1.601 +	RArray<TModelID> iModelIDs;
   1.602 +	RArray<TRuleID> iRuleIDs;
   1.603 +	
   1.604 +	RArray<TGrammarID> iGrammarIDs;
   1.605 +	RArray<TLexiconID> iLexiconIDs;
   1.606 +	RArray<TModelBankID> iModelBankIDs;
   1.607 +
   1.608 +
   1.609 +	CSDClientResultSet* iResultSet;
   1.610 +	CBufFlat* iResultCopyBuffer;
   1.611 +
   1.612 +//  Remove?
   1.613 +//	TAny* iReservedPtr_1;	// reserved for future expansion
   1.614 +//	TAny* iReservedPtr_2;	// reserved for future expansion
   1.615 +	};
   1.616 +#endif  // of __SPEECHRECOGNITIONCUSTOMCOMMANDPARSER_H__
   1.617 +
   1.618 +// End of file