srsf/sicc/src/nsssispeechrecognitioncustomcommandparser.cpp
changeset 13 57b735022c18
parent 1 b13cd05eeb2f
equal deleted inserted replaced
1:b13cd05eeb2f 13:57b735022c18
     1 /*
       
     2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This is the implementation of the server side for the
       
    15 *               speaker independent controller.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "srsfbldvariant.hrh"
       
    22 #include <e32std.h>
       
    23 #include <nsssispeechrecognitioncustomcommandparser.h>
       
    24 #include <nsssispeechrecognitioncustomcommands.h>
       
    25 #include "nsssispeechrecognitioncustomcommandcommon.h"
       
    26 #include "nsssicustomcommanddata.h"
       
    27 #include "rubydebug.h"
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CSISpeechRecognitionCustomCommandParser::CSISpeechRecognitionCustomCommandParser
       
    33 // C++ constructor.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CSISpeechRecognitionCustomCommandParser::CSISpeechRecognitionCustomCommandParser(
       
    37 	MSISpeechRecognitionCustomCommandImplementor& aImplementor) :
       
    38 	CMMFCustomCommandParserBase(KUidInterfaceSpeakerIndependent),
       
    39 	iImplementor(aImplementor),
       
    40     iAdaptationSet( 0 )
       
    41 	{
       
    42 	}
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSISpeechRecognitionCustomCommandParser::NewL
       
    46 // Two-phased constructor.
       
    47 // (other items were commented in a header).
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CSISpeechRecognitionCustomCommandParser* 
       
    51 			CSISpeechRecognitionCustomCommandParser::NewL(
       
    52 	MSISpeechRecognitionCustomCommandImplementor& aImplementor)
       
    53 	{
       
    54 	return new(ELeave) CSISpeechRecognitionCustomCommandParser(aImplementor);
       
    55 	
       
    56 	}
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSISpeechRecognitionCustomCommandParser::~CSISpeechRecognitionCustomCommandParser
       
    60 // Destructor for CSISpeechRecognitionCustomCommandParser class
       
    61 // (other items were commented in a header).
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C CSISpeechRecognitionCustomCommandParser::
       
    65 			~CSISpeechRecognitionCustomCommandParser()
       
    66 	{
       
    67 	
       
    68 	iPronunciationIDs.Close();
       
    69 	iRuleIDs.Close();
       
    70 	iModelIDs.Close();
       
    71 	iGrammarIDs.Close();
       
    72 	iLexiconIDs.Close();
       
    73 	iModelBankIDs.Close();
       
    74     iLanguageArray.Close();
       
    75     for ( TInt i = 0; i < iLanguageArrayArray.Count(); i++ )
       
    76         {
       
    77         iLanguageArrayArray[i].Close();
       
    78         }
       
    79     iLanguageArrayArray.Close();
       
    80 
       
    81 	delete iResultCopyBuffer;	
       
    82 	//delete iResultSet;
       
    83     delete iSIResultSet;
       
    84     delete iWordArray;
       
    85     delete iAdaptationSet;
       
    86 	}
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CSISpeechRecognitionCustomCommandParser::HandleRequest
       
    90 // Handles the client side request.
       
    91 // (other items were commented in a header).
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CSISpeechRecognitionCustomCommandParser::HandleRequest(
       
    95 	TMMFMessage& aMessage)
       
    96 	{
       
    97 	ASSERT(aMessage.Destination().InterfaceId() == 
       
    98 						KUidInterfaceSpeakerIndependent);
       
    99 	TRAPD(error, DoHandleRequestL(aMessage));
       
   100 	if(error)
       
   101 		aMessage.Complete(error);
       
   102 
       
   103 	}
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CSISpeechRecognitionCustomCommandParser::DoHandleRequestL
       
   107 // Decodes aMessage and calls the correct function. This function is trapped by
       
   108 // HandleRequest() and the leave code, if any, sent to the client.
       
   109 // (other items were commented in a header).
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CSISpeechRecognitionCustomCommandParser::DoHandleRequestL(
       
   113 	TMMFMessage& aMessage)
       
   114     {
       
   115     TPckgBuf<TInt> pckgSize;
       
   116     
       
   117     // call required function to do the requested operation
       
   118     switch( aMessage.Function() )
       
   119         {
       
   120         case ESrAddPronunciation:
       
   121             DoAddPronunciationL(aMessage);
       
   122             break;
       
   123             
       
   124         case ESrAddRule:
       
   125             DoAddRuleL(aMessage);
       
   126             break;
       
   127             
       
   128         case ESrCancel:
       
   129             DoCancel();
       
   130             break;
       
   131             
       
   132         case ESrCommitChanges:
       
   133             DoCommitChangesL();
       
   134             break;
       
   135             
       
   136         case ESrCreateGrammar:
       
   137             DoCreateGrammarL(aMessage);
       
   138             break;
       
   139             
       
   140         case ESrCreateLexicon:
       
   141             DoCreateLexiconL(aMessage);
       
   142             break;
       
   143             
       
   144         case ESrCreateModelBank:
       
   145             DoCreateModelBankL(aMessage);
       
   146             break;
       
   147             
       
   148         case ESrEndRecSession:
       
   149             DoEndRecSessionL();
       
   150             break;
       
   151             
       
   152         case ESrGetAllClientGrammarIDs:
       
   153             DoGetAllClientGrammarIDsL();
       
   154             break;
       
   155             
       
   156         case ESrGetAllClientLexiconIDs:
       
   157             DoGetAllClientLexiconIDsL();
       
   158             break;
       
   159             
       
   160         case ESrGetAllClientModelBankIDs:
       
   161             DoGetAllClientModelBankIDsL();
       
   162             break;
       
   163             
       
   164         case ESrGetAllGrammarIDs:
       
   165             DoGetAllGrammarIDsL();
       
   166             break;
       
   167             
       
   168         case ESrGetAllLexiconIDs:
       
   169             DoGetAllLexiconIDsL();
       
   170             break;
       
   171             
       
   172         case ESrGetAllModelBankIDs:
       
   173             DoGetAllModelBankIDsL();
       
   174             break;
       
   175             
       
   176         case ESrGetAllModelIDs:
       
   177             DoGetAllModelIDsL(aMessage);
       
   178             break;
       
   179             
       
   180         case ESrGetAllPronunciationIDs:
       
   181             DoGetAllPronunciationIDsL(aMessage);
       
   182             break;
       
   183             
       
   184         case ESrGetAllRuleIDs:
       
   185             DoGetAllRuleIDsL(aMessage);
       
   186             break;
       
   187             
       
   188         case ESrGetAvailableStorage:
       
   189             DoGetAvailableStorageL(aMessage);
       
   190             break;
       
   191             
       
   192         case ESrGetEngineProperties:
       
   193             DoGetEnginePropertiesL(aMessage);
       
   194             break;
       
   195             
       
   196         case ESrGetModelCount:
       
   197             DoGetModelCountL(aMessage);
       
   198             break;
       
   199             
       
   200         case ESrGetRuleValidity:
       
   201             DoGetRuleValidityL(aMessage);
       
   202             break;
       
   203             
       
   204         case ESrUtteranceDuration:
       
   205             DoGetUtteranceDurationL(aMessage);
       
   206             break;
       
   207             
       
   208         case ESrLoadGrammar:
       
   209             DoLoadGrammarL(aMessage);
       
   210             break;
       
   211             
       
   212         case ESrActivateGrammar:
       
   213             DoActivateGrammarL(aMessage);
       
   214             break;
       
   215             
       
   216         case ESrDeactivateGrammar:
       
   217             DoDeactivateGrammarL(aMessage);
       
   218             break;
       
   219             
       
   220         case ESrLoadLexicon:
       
   221             DoLoadLexiconL(aMessage);
       
   222             break;
       
   223             
       
   224         case ESrLoadModels:
       
   225             DoLoadModelsL(aMessage);
       
   226             break;
       
   227             
       
   228         case ESrPlayUtterance:
       
   229             DoPlayUtteranceL(aMessage);
       
   230             break;
       
   231             
       
   232         case ESrRecognize:
       
   233             DoRecognizeL(aMessage);
       
   234             break;
       
   235             
       
   236         case ESrRecord:
       
   237             DoRecordL(aMessage);
       
   238             break;
       
   239             
       
   240         case ESrRemoveGrammar:
       
   241             DoRemoveGrammarL(aMessage);
       
   242             break;
       
   243             
       
   244         case ESrRemoveLexicon:
       
   245             DoRemoveLexiconL(aMessage);
       
   246             break;
       
   247             
       
   248         case ESrRemoveModelBank:
       
   249             DoRemoveModelBankL(aMessage);
       
   250             break;
       
   251             
       
   252         case ESrRemoveModel:
       
   253             DoRemoveModelL(aMessage);
       
   254             break;
       
   255             
       
   256         case ESrRemovePronunciation:
       
   257             DoRemovePronunciationL(aMessage);
       
   258             break;
       
   259             
       
   260         case ESrRemoveRule:
       
   261             DoRemoveRuleL(aMessage);
       
   262             break;
       
   263             
       
   264         case ESrRemoveRules:
       
   265             RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoHandleRequestL. case ESrRemoveRules" );
       
   266             DoRemoveRulesL( aMessage );
       
   267             break;
       
   268             
       
   269         case ESrSetClientUid:
       
   270             DoSetClientUidL(aMessage);
       
   271             break;
       
   272             
       
   273         case ESrStartRecSession:
       
   274             DoStartRecSessionL(aMessage);
       
   275             break;
       
   276             
       
   277         case ESrTrain:
       
   278             DoTrainL(aMessage);
       
   279             break;
       
   280             
       
   281         case ESrUnloadRule:
       
   282             DoUnloadRuleL(aMessage);
       
   283             break;
       
   284             
       
   285         case ESrLoadEngineParameters:
       
   286             DoLoadEngineParametersL(aMessage);
       
   287             break;
       
   288             
       
   289         case ESrGetPronunciationIDArraySize:
       
   290             pckgSize() = iPronunciationIDs.Count();
       
   291             aMessage.WriteDataToClientL(pckgSize);
       
   292             break;
       
   293             
       
   294         case ESrGetPronunciationIDArrayContents:
       
   295             DoCopyPronunciationIDArrayL(aMessage);
       
   296             break;
       
   297             
       
   298         case ESrGetRuleIDArraySize:
       
   299             pckgSize() = iRuleIDs.Count();
       
   300             aMessage.WriteDataToClientL(pckgSize);
       
   301             break;
       
   302             
       
   303         case ESrGetRuleIDArrayContents:
       
   304             DoCopyRuleIDArrayL(aMessage);			
       
   305             break;
       
   306             
       
   307         case ESrGetModelIDArraySize:
       
   308             pckgSize() = iModelIDs.Count();
       
   309             aMessage.WriteDataToClientL(pckgSize);
       
   310             break;
       
   311             
       
   312         case ESrGetModelIDArrayContents:
       
   313             DoCopyModelIDArrayL(aMessage);
       
   314             break;
       
   315             
       
   316         case ESrGetGrammarIDArraySize:
       
   317             pckgSize() = iGrammarIDs.Count();
       
   318             aMessage.WriteDataToClientL(pckgSize);
       
   319             break;
       
   320             
       
   321         case ESrGetGrammarIDArrayContents:
       
   322             DoCopyGrammarIDArrayL(aMessage);
       
   323             break;
       
   324             
       
   325         case ESrGetLexiconIDArraySize:
       
   326             pckgSize() = iLexiconIDs.Count();
       
   327             aMessage.WriteDataToClientL(pckgSize);
       
   328             break;
       
   329             
       
   330         case ESrGetLexiconIDArrayContents:
       
   331             DoCopyLexiconIDArrayL(aMessage);
       
   332             break;
       
   333             
       
   334         case ESrGetModelBankIDArraySize:
       
   335             pckgSize() = iModelBankIDs.Count();
       
   336             aMessage.WriteDataToClientL(pckgSize);
       
   337             break;
       
   338             
       
   339         case ESrGetModelBankIDArrayContents:
       
   340             DoCopyModelBankIDArrayL(aMessage);
       
   341             break;
       
   342             
       
   343         case ESrGetClientResultSetSize:
       
   344             DoExternalizeResultSetL();
       
   345             pckgSize() = iResultCopyBuffer->Size();
       
   346             aMessage.WriteDataToClientL(pckgSize);
       
   347             break;
       
   348             
       
   349         case ESrGetClientResultSetSizeSI:
       
   350             DoExternalizeSIResultSetL();
       
   351             pckgSize() = iResultCopyBuffer->Size();
       
   352             aMessage.WriteDataToClientL(pckgSize);
       
   353             break;
       
   354             
       
   355         case ESrGetClientResultSet:
       
   356             DoCopyResultSetL(aMessage);
       
   357             break;
       
   358             
       
   359             // SI main requests
       
   360         case ESrAdapt:
       
   361             DoAdaptL( aMessage );
       
   362             break;
       
   363             
       
   364         case ESrAddPronunciationSI:
       
   365             DoAddPronunciationSIL( aMessage );
       
   366             break;
       
   367             
       
   368         case ESrAddRuleVariant:
       
   369             DoAddRuleVariantL( aMessage );
       
   370             break;
       
   371             
       
   372         case ESrAddVoiceTag:
       
   373             DoAddVoiceTagL( aMessage );
       
   374             break;
       
   375             
       
   376         case ESrAddVoiceTags:
       
   377             DoAddVoiceTagsL( aMessage );
       
   378             break;
       
   379             
       
   380         case ESrCreateRule:
       
   381             DoCreateRuleL( aMessage );
       
   382             break;
       
   383             
       
   384         case ESrEndRecord:
       
   385             DoEndRecordL( aMessage );
       
   386             break;
       
   387             
       
   388         case ESrRecognizeSI:
       
   389             DoRecognizeSIL( aMessage );
       
   390             break;
       
   391             
       
   392         case ESrUnloadGrammar:
       
   393             DoUnloadGrammarL( aMessage );
       
   394             break;
       
   395             
       
   396         case ESrAddSindeVoiceTag:
       
   397             DoAddSindeVoiceTagL( aMessage );
       
   398             break;
       
   399             
       
   400         case ESrAddSindeVoiceTags:
       
   401             DoAddSindeVoiceTagsL( aMessage );
       
   402             break;
       
   403             
       
   404         case ESrPreStartSampling:
       
   405             DoPreStartSamplingL( aMessage );
       
   406             break;
       
   407             
       
   408         default:
       
   409             RUBY_DEBUG1( "CSISpeechRecognitionCustomCommandParser::DoHandleRequestL. Unknown function [%d]. Leaving", aMessage.Function() );
       
   410             User::Leave(KErrNotSupported);
       
   411             
       
   412         }	// end of switch
       
   413     
       
   414     
       
   415     aMessage.Complete(KErrNone);
       
   416     
       
   417     }
       
   418 
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CSISpeechRecognitionCustomCommandParser::DoAddPronunciationL
       
   422 // Calls the controller plugin to add a pronunciation.
       
   423 // (other items were commented in a header).
       
   424 // -----------------------------------------------------------------------------
       
   425 void CSISpeechRecognitionCustomCommandParser::DoAddPronunciationL(
       
   426 	TMMFMessage& /*aMessage*/)
       
   427 	{
       
   428     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoAddPronunciationL is NOT supported" );
       
   429     User::Leave( KErrNotSupported );
       
   430 	}
       
   431 
       
   432 // -----------------------------------------------------------------------------
       
   433 // CSISpeechRecognitionCustomCommandParser::DoAddRuleL
       
   434 // Calls the controller plugin to add a rule.
       
   435 // (other items were commented in a header).
       
   436 // -----------------------------------------------------------------------------
       
   437 //
       
   438 void CSISpeechRecognitionCustomCommandParser::DoAddRuleL(
       
   439 	TMMFMessage& aMessage)
       
   440 	{
       
   441 
       
   442 	// Async
       
   443 	TSrsAddRulePckg pckg;
       
   444 	aMessage.ReadData1FromClientL(pckg);
       
   445 	TSrsAddRule srsAddRule = pckg();
       
   446 
       
   447 	iImplementor.MSrAddRuleL( srsAddRule.iGrammarID, srsAddRule.iLexiconID,
       
   448 							 srsAddRule.iPronunciationID, *srsAddRule.iRuleID );
       
   449 
       
   450 	}
       
   451 
       
   452 // -----------------------------------------------------------------------------
       
   453 // CSISpeechRecognitionCustomCommandParser::DoCancel
       
   454 // Calls the controller plugin to cancel the currect asynchronous operation.
       
   455 // (other items were commented in a header).
       
   456 // -----------------------------------------------------------------------------
       
   457 //
       
   458 void CSISpeechRecognitionCustomCommandParser::DoCancel()
       
   459 	{
       
   460 
       
   461 	iImplementor.MSrCancel();
       
   462 
       
   463 	}
       
   464 
       
   465 // -----------------------------------------------------------------------------
       
   466 // CSISpeechRecognitionCustomCommandParser::DoCommitChanges
       
   467 // Saves the current trained model into a permanent storage.
       
   468 // (other items were commented in a header).
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 void CSISpeechRecognitionCustomCommandParser::DoCommitChangesL()
       
   472 	{
       
   473 
       
   474 	iImplementor.MSrCommitChangesL();
       
   475 
       
   476 	}
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CSISpeechRecognitionCustomCommandParser::DoCreateGrammarL
       
   480 // Calls the controller plugin to create a grammar.
       
   481 // (other items were commented in a header).
       
   482 // -----------------------------------------------------------------------------
       
   483 //
       
   484 void CSISpeechRecognitionCustomCommandParser::DoCreateGrammarL(
       
   485 	TMMFMessage& aMessage)
       
   486 	{
       
   487 
       
   488 	TSrsGrammarIDPtrPckg srsGrammarIDPtrPckg;
       
   489 	aMessage.ReadData1FromClientL(srsGrammarIDPtrPckg);
       
   490 	TSIGrammarID* grammarID = srsGrammarIDPtrPckg();
       
   491 	iImplementor.MSrCreateGrammarL(*grammarID) ;
       
   492 
       
   493 	}
       
   494 
       
   495 // -----------------------------------------------------------------------------
       
   496 // CSISpeechRecognitionCustomCommandParser::DoCreateLexiconL
       
   497 // Calls the controller plugin to create a lexicon.
       
   498 // (other items were commented in a header).
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 void CSISpeechRecognitionCustomCommandParser::DoCreateLexiconL(
       
   502 	TMMFMessage& aMessage)
       
   503 	{
       
   504 
       
   505 	TSrsLexiconIDPtrPckg srsLexiconIDPtrPckg;
       
   506 	aMessage.ReadData1FromClientL(srsLexiconIDPtrPckg);
       
   507 	TSILexiconID* lexiconID = srsLexiconIDPtrPckg();
       
   508 	iImplementor.MSrCreateLexiconL(*lexiconID) ;
       
   509 
       
   510 	}
       
   511 
       
   512 // -----------------------------------------------------------------------------
       
   513 // CSISpeechRecognitionCustomCommandParser::DoCreateModelBankL
       
   514 // Calls the controller plugin to create a model bank.
       
   515 // (other items were commented in a header).
       
   516 // -----------------------------------------------------------------------------
       
   517 //
       
   518 void CSISpeechRecognitionCustomCommandParser::DoCreateModelBankL(
       
   519 	TMMFMessage& aMessage)
       
   520 	{
       
   521 
       
   522 	TSrsModelBankIDPtrPckg modelBankIDPtrPckg;
       
   523 	aMessage.ReadData1FromClientL(modelBankIDPtrPckg);
       
   524 	TSIModelBankID* modelBankID = modelBankIDPtrPckg();
       
   525 	iImplementor.MSrCreateModelBankL(*modelBankID);
       
   526 
       
   527 	}
       
   528 
       
   529 // -----------------------------------------------------------------------------
       
   530 // CSISpeechRecognitionCustomCommandParser::DoEndRecSessionL
       
   531 // Calls the controller plugin to end the current recognition session and free
       
   532 // the allocated resources.
       
   533 // (other items were commented in a header).
       
   534 // -----------------------------------------------------------------------------
       
   535 //
       
   536 void CSISpeechRecognitionCustomCommandParser::DoEndRecSessionL()
       
   537 	{
       
   538 
       
   539 	iImplementor.MSrEndRecSessionL();
       
   540 
       
   541 	}
       
   542 
       
   543 // -----------------------------------------------------------------------------
       
   544 // CSISpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL
       
   545 // Calls the controller plugin to get all client grammar IDs.
       
   546 // (other items were commented in a header).
       
   547 // -----------------------------------------------------------------------------
       
   548 //
       
   549 void CSISpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL()
       
   550 	{
       
   551 
       
   552 	// Async
       
   553 	iGrammarIDs.Reset();
       
   554 	iImplementor.MSrGetAllClientGrammarIDsL(iGrammarIDs);
       
   555 
       
   556 	}
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // CSISpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL
       
   560 // Calls the controller plugin to get all client lexicon IDs.
       
   561 // (other items were commented in a header).
       
   562 // -----------------------------------------------------------------------------
       
   563 //
       
   564 void CSISpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL()
       
   565 	{
       
   566 
       
   567 	// Async
       
   568 	iLexiconIDs.Reset();
       
   569 	iImplementor.MSrGetAllClientLexiconIDsL(iLexiconIDs);
       
   570 
       
   571 	}
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 // CSISpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL
       
   575 // Calls the controller plugin to get all client model bank IDs.
       
   576 // (other items were commented in a header).
       
   577 // -----------------------------------------------------------------------------
       
   578 //
       
   579 void CSISpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL()
       
   580 	{
       
   581 
       
   582 	// Async
       
   583 	iModelBankIDs.Reset();
       
   584 	iImplementor.MSrGetAllClientModelBankIDsL(iModelBankIDs);
       
   585 
       
   586 	}
       
   587 
       
   588 // -----------------------------------------------------------------------------
       
   589 // CSISpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL
       
   590 // Calls the controller plugin to get all grammar IDs for all clients.
       
   591 // (other items were commented in a header).
       
   592 // -----------------------------------------------------------------------------
       
   593 //
       
   594 void CSISpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL()
       
   595 	{
       
   596 
       
   597 	// Async
       
   598 	iGrammarIDs.Reset();
       
   599 	iImplementor.MSrGetAllGrammarIDsL(iGrammarIDs);
       
   600 	
       
   601 	}
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // CSISpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL
       
   605 // Calls the controller plugin to get all lexicon IDs for all clients.
       
   606 // (other items were commented in a header).
       
   607 // -----------------------------------------------------------------------------
       
   608 //
       
   609 void CSISpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL()
       
   610 	{	
       
   611 
       
   612 	// Async
       
   613 	iLexiconIDs.Reset();
       
   614 	iImplementor.MSrGetAllLexiconIDsL(iLexiconIDs);
       
   615 
       
   616 	}
       
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 // CSISpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL
       
   620 // Calls the controller plugin to get all model bank IDs.
       
   621 // (other items were commented in a header).
       
   622 // -----------------------------------------------------------------------------
       
   623 //
       
   624 void CSISpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL()
       
   625 	{
       
   626 
       
   627 	// Async
       
   628 	iModelBankIDs.Reset();
       
   629 	iImplementor.MSrGetAllModelBankIDsL(iModelBankIDs);
       
   630 
       
   631 	}
       
   632 
       
   633 // -----------------------------------------------------------------------------
       
   634 // CSISpeechRecognitionCustomCommandParser::DoGetAllModelIDsL
       
   635 // Calls the controller plugin to get all model IDs from a model bank.
       
   636 // (other items were commented in a header).
       
   637 // -----------------------------------------------------------------------------
       
   638 //
       
   639 void CSISpeechRecognitionCustomCommandParser::DoGetAllModelIDsL(
       
   640 	TMMFMessage& /*aMessage*/)
       
   641 	{
       
   642     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetAllModelIDsL is NOT supported" );
       
   643     User::Leave( KErrNotSupported );
       
   644 	}
       
   645 
       
   646 // -----------------------------------------------------------------------------
       
   647 // CSISpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL
       
   648 // Calls the controller plugin to get all pronunciation IDs from a lexicon.
       
   649 // (other items were commented in a header).
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 void CSISpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL(
       
   653 	TMMFMessage& aMessage)
       
   654 	{
       
   655 
       
   656 	// Async
       
   657 	TSrsLexiconIDPckg lexiconIDPckg;
       
   658 	iPronunciationIDs.Reset();
       
   659 	aMessage.ReadData1FromClientL(lexiconIDPckg);
       
   660 
       
   661 	iImplementor.MSrGetAllPronunciationIDsL(lexiconIDPckg(), iPronunciationIDs);
       
   662 
       
   663 	}
       
   664 
       
   665 // -----------------------------------------------------------------------------
       
   666 // CSISpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL
       
   667 // Calls the controller plugin to get all rule IDs from a grammar.
       
   668 // (other items were commented in a header).
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 void CSISpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL(
       
   672 	TMMFMessage& aMessage)
       
   673 	{
       
   674 
       
   675 	// Async
       
   676 	TSrsGrammarIDPckg grammarIDPckg;
       
   677 	iRuleIDs.Reset();
       
   678 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
   679 
       
   680 	iImplementor.MSrGetAllRuleIDsL(grammarIDPckg(), iRuleIDs);
       
   681 
       
   682 	}
       
   683 
       
   684 // -----------------------------------------------------------------------------
       
   685 // CSISpeechRecognitionCustomCommandParser::DoGetAvailableStorageL
       
   686 // Calls the controller plugin to get the available storage for training new 
       
   687 // models.
       
   688 // (other items were commented in a header).
       
   689 // -----------------------------------------------------------------------------
       
   690 //
       
   691 void CSISpeechRecognitionCustomCommandParser::DoGetAvailableStorageL(
       
   692 	TMMFMessage& /*aMessage*/)
       
   693 	{
       
   694     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetAvailableStorageL is NOT supported" );
       
   695     User::Leave( KErrNotSupported );
       
   696 	}
       
   697 
       
   698 // -----------------------------------------------------------------------------
       
   699 // CSISpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL
       
   700 // Calls the controller plugin to get the engine properties.
       
   701 // (other items were commented in a header).
       
   702 // -----------------------------------------------------------------------------
       
   703 //
       
   704 void CSISpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL(
       
   705 	TMMFMessage& aMessage)
       
   706 	{
       
   707 
       
   708 	RArray<TInt> propertyIDs;
       
   709 	RArray<TInt> propertyValues;
       
   710 	CleanupClosePushL(propertyIDs);
       
   711 	CleanupClosePushL(propertyValues);
       
   712 	DoExtractIntArrayFromData1L(aMessage, propertyIDs);
       
   713 	iImplementor.MSrGetEnginePropertiesL(propertyIDs,propertyValues);
       
   714 	// the custom command is aware of the size of the result, so it can copy the data back directly
       
   715 	DoCopyIntArrayL(aMessage, propertyValues);
       
   716 	CleanupStack::PopAndDestroy(2); //propertyIDs, propertyValues
       
   717 
       
   718 	}
       
   719 
       
   720 // -----------------------------------------------------------------------------
       
   721 // CSISpeechRecognitionCustomCommandParser::DoGetModelCountL
       
   722 // Calls the controller plugin to get the number of models in a model bank.
       
   723 // (other items were commented in a header).
       
   724 // -----------------------------------------------------------------------------
       
   725 //
       
   726 void CSISpeechRecognitionCustomCommandParser::DoGetModelCountL(
       
   727 	TMMFMessage& /*aMessage*/)
       
   728 	{
       
   729     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetModelCountL is NOT supported" );
       
   730     User::Leave( KErrNotSupported );
       
   731 	}
       
   732 
       
   733 
       
   734 // -----------------------------------------------------------------------------
       
   735 // CSISpeechRecognitionCustomCommandParser::DoGetRuleValidityL
       
   736 // Calls the controller plugin to determine if a rule is valid.
       
   737 // (other items were commented in a header).
       
   738 // -----------------------------------------------------------------------------
       
   739 //
       
   740 void CSISpeechRecognitionCustomCommandParser::DoGetRuleValidityL(
       
   741 	TMMFMessage& aMessage)
       
   742 	{
       
   743 
       
   744 	TSrsRuleValidityPckg srsRuleValidityPckg;
       
   745 	aMessage.ReadData1FromClientL(srsRuleValidityPckg);
       
   746 	TSrsRuleValidity srsRuleValidity = srsRuleValidityPckg();
       
   747 	iImplementor.MSrGetRuleValidityL( srsRuleValidity.iGrammarID, 
       
   748 				srsRuleValidity.iRuleID, *srsRuleValidity.iRuleValid );
       
   749 
       
   750 	}
       
   751 
       
   752 // -----------------------------------------------------------------------------
       
   753 // CSISpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL
       
   754 // Calls the controller plugin to get the utterance duration.
       
   755 // (other items were commented in a header).
       
   756 // -----------------------------------------------------------------------------
       
   757 //
       
   758 void CSISpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL(
       
   759 	TMMFMessage& /*aMessage*/)
       
   760 	{
       
   761     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL is NOT supported" );
       
   762     User::Leave( KErrNotSupported );
       
   763 	}
       
   764 
       
   765 // -----------------------------------------------------------------------------
       
   766 // CSISpeechRecognitionCustomCommandParser::DoLoadGrammarL
       
   767 // Calls the controller plugin to load the specified grammar.
       
   768 // (other items were commented in a header).
       
   769 // -----------------------------------------------------------------------------
       
   770 //
       
   771 void CSISpeechRecognitionCustomCommandParser::DoLoadGrammarL(
       
   772 	TMMFMessage& aMessage)
       
   773 	{
       
   774 
       
   775 	TSrsGrammarIDPckg grammarIDPckg;
       
   776 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
   777 	TSIGrammarID grammarID = grammarIDPckg();
       
   778 	iImplementor.MSrLoadGrammarL( grammarID );
       
   779 
       
   780 	}
       
   781 
       
   782 // -----------------------------------------------------------------------------
       
   783 // CSISpeechRecognitionCustomCommandParser::DoActivateGrammarL
       
   784 // Calls the controller plugin to activate the specified grammar.
       
   785 // (other items were commented in a header).
       
   786 // -----------------------------------------------------------------------------
       
   787 //
       
   788 void CSISpeechRecognitionCustomCommandParser::DoActivateGrammarL(
       
   789 	TMMFMessage& aMessage)
       
   790 	{
       
   791 
       
   792 	TSrsGrammarIDPckg grammarIDPckg;
       
   793 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
   794 	TSIGrammarID grammarID = grammarIDPckg();
       
   795 	iImplementor.MSrActivateGrammarL( grammarID );
       
   796 
       
   797 	}
       
   798 
       
   799 // -----------------------------------------------------------------------------
       
   800 // CSISpeechRecognitionCustomCommandParser::DoDeactivateGrammarL
       
   801 // Calls the controller plugin to deactivate the specified grammar.
       
   802 // (other items were commented in a header).
       
   803 // -----------------------------------------------------------------------------
       
   804 //
       
   805 void CSISpeechRecognitionCustomCommandParser::DoDeactivateGrammarL(
       
   806 	TMMFMessage& aMessage)
       
   807 	{
       
   808 
       
   809 	TSrsGrammarIDPckg grammarIDPckg;
       
   810 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
   811 	TSIGrammarID grammarID = grammarIDPckg();
       
   812 	iImplementor.MSrDeactivateGrammarL( grammarID );
       
   813 
       
   814 	}
       
   815 
       
   816 // -----------------------------------------------------------------------------
       
   817 // CSISpeechRecognitionCustomCommandParser::DoLoadLexiconL
       
   818 // Calls the controller plugin to load the specified lexican.
       
   819 // (other items were commented in a header).
       
   820 // -----------------------------------------------------------------------------
       
   821 //
       
   822 void CSISpeechRecognitionCustomCommandParser::DoLoadLexiconL(
       
   823 	TMMFMessage& aMessage)
       
   824 	{
       
   825 
       
   826 	TSrsLexiconIDPckg lexiconIDPckg;
       
   827 	aMessage.ReadData1FromClientL(lexiconIDPckg);
       
   828 	TSILexiconID lexiconID = lexiconIDPckg();
       
   829 	iImplementor.MSrLoadLexiconL(lexiconID);
       
   830 
       
   831 	}
       
   832 
       
   833 // -----------------------------------------------------------------------------
       
   834 // CSISpeechRecognitionCustomCommandParser::DoLoadModelsL
       
   835 // Calls the controller plugin to load all models from a model bank.
       
   836 // (other items were commented in a header).
       
   837 // -----------------------------------------------------------------------------
       
   838 //
       
   839 void CSISpeechRecognitionCustomCommandParser::DoLoadModelsL(
       
   840 	TMMFMessage& aMessage)
       
   841 	{
       
   842 
       
   843 	TSrsModelBankIDPckg modelBankIDPckg;
       
   844 	aMessage.ReadData1FromClientL(modelBankIDPckg);
       
   845 	TSIModelBankID modelBankID = modelBankIDPckg();
       
   846 	iImplementor.MSrLoadModelsL(modelBankID);
       
   847 
       
   848 	}
       
   849 
       
   850 // -----------------------------------------------------------------------------
       
   851 // CSISpeechRecognitionCustomCommandParser::DoPlayUtteranceL
       
   852 // Calls the controller plugin to play a previously recorded utterance.
       
   853 // (other items were commented in a header).
       
   854 // -----------------------------------------------------------------------------
       
   855 //
       
   856 void CSISpeechRecognitionCustomCommandParser::DoPlayUtteranceL(
       
   857 	TMMFMessage& /*aMessage*/)
       
   858 	{
       
   859     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoPlayUtteranceL is NOT supported" );
       
   860     User::Leave( KErrNotSupported );
       
   861 	}
       
   862 
       
   863 // -----------------------------------------------------------------------------
       
   864 // CSISpeechRecognitionCustomCommandParser::DoRecognizeL
       
   865 // Calls the controller plugin to recognize an utterance.
       
   866 // (other items were commented in a header).
       
   867 // -----------------------------------------------------------------------------
       
   868 //
       
   869 void CSISpeechRecognitionCustomCommandParser::DoRecognizeL(
       
   870 	TMMFMessage& /*aMessage*/)
       
   871 	{
       
   872     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoRecognizeL is NOT supported" );
       
   873     User::Leave( KErrNotSupported );
       
   874 	}
       
   875 
       
   876 // -----------------------------------------------------------------------------
       
   877 // CSISpeechRecognitionCustomCommandParser::DoRecordL
       
   878 // Calls the controller plugin to start recording an utterance for either 
       
   879 // training or recognition
       
   880 // (other items were commented in a header).
       
   881 // -----------------------------------------------------------------------------
       
   882 //
       
   883 void CSISpeechRecognitionCustomCommandParser::DoRecordL(
       
   884 	TMMFMessage& aMessage)
       
   885 	{
       
   886 
       
   887 	TSrsTimeIntervalMicroSeconds32Pckg pckg;
       
   888 	aMessage.ReadData1FromClientL(pckg);
       
   889 	TTimeIntervalMicroSeconds32 recordDuration = pckg();
       
   890 	iImplementor.MSrRecordL(recordDuration);
       
   891 
       
   892 	}
       
   893 
       
   894 // -----------------------------------------------------------------------------
       
   895 // CSISpeechRecognitionCustomCommandParser::DoPreStartSamplingL
       
   896 // Calls the controller plugin.
       
   897 // -----------------------------------------------------------------------------
       
   898 //
       
   899 void CSISpeechRecognitionCustomCommandParser::DoPreStartSamplingL(
       
   900     TMMFMessage& /*aMessage*/ )
       
   901     {
       
   902     iImplementor.MSrPreStartSamplingL();
       
   903     }
       
   904 
       
   905 // -----------------------------------------------------------------------------
       
   906 // CSISpeechRecognitionCustomCommandParser::DoRemoveGrammarL
       
   907 // Calls the controller plugin to remove a grammar.
       
   908 // (other items were commented in a header).
       
   909 // -----------------------------------------------------------------------------
       
   910 //
       
   911 void CSISpeechRecognitionCustomCommandParser::DoRemoveGrammarL(
       
   912 	TMMFMessage& aMessage)
       
   913 	{
       
   914 
       
   915 	TSrsGrammarIDPckg pckg;
       
   916 	aMessage.ReadData1FromClientL(pckg);
       
   917 	TSIGrammarID grammarID = pckg();
       
   918 	iImplementor.MSrRemoveGrammarL(grammarID);
       
   919 
       
   920 	}
       
   921 
       
   922 // -----------------------------------------------------------------------------
       
   923 // CSISpeechRecognitionCustomCommandParser::DoRemoveLexiconL
       
   924 // Calls the controller plugin to remove a lexicon.
       
   925 // (other items were commented in a header).
       
   926 // -----------------------------------------------------------------------------
       
   927 //
       
   928 void CSISpeechRecognitionCustomCommandParser::DoRemoveLexiconL(
       
   929 	TMMFMessage& aMessage)
       
   930 	{
       
   931 
       
   932 	TSrsLexiconIDPckg pckg;
       
   933 	aMessage.ReadData1FromClientL(pckg);
       
   934 	TSILexiconID lexiconID = pckg();
       
   935 	iImplementor.MSrRemoveLexiconL(lexiconID);
       
   936 
       
   937 	}
       
   938 
       
   939 // -----------------------------------------------------------------------------
       
   940 // CSISpeechRecognitionCustomCommandParser::DoRemoveModelBankL
       
   941 // Calls the controller plugin to remove a model bank and all associated models.
       
   942 // (other items were commented in a header).
       
   943 // -----------------------------------------------------------------------------
       
   944 //
       
   945 void CSISpeechRecognitionCustomCommandParser::DoRemoveModelBankL(
       
   946 	TMMFMessage& aMessage)
       
   947 	{
       
   948 
       
   949 	TSrsModelBankIDPckg pckg;
       
   950 	aMessage.ReadData1FromClientL(pckg);
       
   951 	TSIModelBankID modelBankID = pckg();
       
   952 	iImplementor.MSrRemoveModelBankL(modelBankID);
       
   953 
       
   954 	}
       
   955 
       
   956 // -----------------------------------------------------------------------------
       
   957 // CSISpeechRecognitionCustomCommandParser::DoRemoveModelL
       
   958 // Calls the controller plugin to remove a model from a model bank.
       
   959 // (other items were commented in a header).
       
   960 // -----------------------------------------------------------------------------
       
   961 //
       
   962 void CSISpeechRecognitionCustomCommandParser::DoRemoveModelL(
       
   963 	TMMFMessage& aMessage)
       
   964 	{
       
   965 
       
   966 	TSrsModelBankIDPckg modelBankIDPckg;
       
   967 	aMessage.ReadData1FromClientL(modelBankIDPckg);
       
   968 	TSIModelBankID modelBankID = modelBankIDPckg();
       
   969 	TSrsModelIDPckg modelIDPckg;
       
   970 	aMessage.ReadData2FromClientL(modelIDPckg);
       
   971 	TSIModelBankID modelID = modelIDPckg();
       
   972 	iImplementor.MSrRemoveModelL(modelBankID, modelID);
       
   973 
       
   974 	}
       
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 // CSISpeechRecognitionCustomCommandParser::DoRemovePronunciationL
       
   978 // Calls the controller plugin to remove a pronunciation.
       
   979 // (other items were commented in a header).
       
   980 // -----------------------------------------------------------------------------
       
   981 //
       
   982 void CSISpeechRecognitionCustomCommandParser::DoRemovePronunciationL(
       
   983 	TMMFMessage& aMessage)
       
   984 	{
       
   985 
       
   986 	TSrsLexiconIDPckg lexiconIDPckg;
       
   987 	aMessage.ReadData1FromClientL(lexiconIDPckg);
       
   988 	TSILexiconID lexiconID = lexiconIDPckg();
       
   989 	TSrsPronunciationIDPckg pronunciationIDPckg;
       
   990 	aMessage.ReadData2FromClientL(pronunciationIDPckg);
       
   991 	TSIPronunciationID pronunciationID = pronunciationIDPckg();
       
   992 	iImplementor.MSrRemovePronunciationL( lexiconID, pronunciationID );
       
   993 
       
   994 	}
       
   995 
       
   996 // -----------------------------------------------------------------------------
       
   997 // CSISpeechRecognitionCustomCommandParser::DoRemoveRuleL
       
   998 // Calls the controller plugin to remove a rule.
       
   999 // (other items were commented in a header).
       
  1000 // -----------------------------------------------------------------------------
       
  1001 //
       
  1002 void CSISpeechRecognitionCustomCommandParser::DoRemoveRuleL(
       
  1003 	TMMFMessage& aMessage)
       
  1004 	{
       
  1005 
       
  1006 	TSrsGrammarIDPckg grammarIDPckg;
       
  1007 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
  1008 	TSIGrammarID grammarID = grammarIDPckg();
       
  1009 	TSrsRuleIDPckg ruleIDPckg;
       
  1010 	aMessage.ReadData2FromClientL(ruleIDPckg);
       
  1011 	TSIRuleID ruleID = ruleIDPckg();
       
  1012 	iImplementor.MSrRemoveRuleL( grammarID, ruleID );
       
  1013 
       
  1014 	}
       
  1015 
       
  1016 // -----------------------------------------------------------------------------
       
  1017 // CSISpeechRecognitionCustomCommandParser::DoSetClientUid
       
  1018 // Sets the client's UID for data ownership identification.
       
  1019 // (other items were commented in a header).
       
  1020 // -----------------------------------------------------------------------------
       
  1021 //
       
  1022 void CSISpeechRecognitionCustomCommandParser::DoSetClientUidL(TMMFMessage& aMessage)
       
  1023 {
       
  1024     RUBY_DEBUG_BLOCK( "CSISpeechRecognitionCustomCommandParser::DoSetClientUidL" );
       
  1025 
       
  1026 	TSrsUidPckg pckg;
       
  1027 	aMessage.ReadData1FromClientL(pckg);
       
  1028 	TUid uid = pckg();
       
  1029 	iImplementor.MSrSetClientUid(uid);
       
  1030 
       
  1031 }
       
  1032 
       
  1033 // -----------------------------------------------------------------------------
       
  1034 // CSISpeechRecognitionCustomCommandParser::DoStartRecSessionL
       
  1035 // Calls the controller plugin to begin a recognition session.
       
  1036 // (other items were commented in a header).
       
  1037 // -----------------------------------------------------------------------------
       
  1038 //
       
  1039 void CSISpeechRecognitionCustomCommandParser::DoStartRecSessionL(
       
  1040 	TMMFMessage& aMessage)
       
  1041 	{
       
  1042 
       
  1043 	TSrsRecognitionModePckg pckg;
       
  1044 	aMessage.ReadData1FromClientL(pckg);
       
  1045 	TNSSRecognitionMode mode = pckg();
       
  1046 	iImplementor.MSrStartRecSessionL( mode );
       
  1047 
       
  1048 	}
       
  1049 
       
  1050 // -----------------------------------------------------------------------------
       
  1051 // CSISpeechRecognitionCustomCommandParser::DoTrainL
       
  1052 // Calls the controller plugin to begin a recognition session.
       
  1053 // (other items were commented in a header).
       
  1054 // -----------------------------------------------------------------------------
       
  1055 //
       
  1056 void CSISpeechRecognitionCustomCommandParser::DoTrainL(
       
  1057 	TMMFMessage& /*aMessage*/)
       
  1058 	{
       
  1059     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoTrainL is NOT supported" );
       
  1060     User::Leave( KErrNotSupported );
       
  1061 	}
       
  1062 
       
  1063 // -----------------------------------------------------------------------------
       
  1064 // CSISpeechRecognitionCustomCommandParser::DoUnloadRuleL
       
  1065 // Calls the controller plugin to add a rule.
       
  1066 // (other items were commented in a header).
       
  1067 // -----------------------------------------------------------------------------
       
  1068 //
       
  1069 void CSISpeechRecognitionCustomCommandParser::DoUnloadRuleL(
       
  1070 	TMMFMessage& aMessage)
       
  1071 	{
       
  1072 
       
  1073 	TSrsGrammarIDPckg grammarIDPckg;
       
  1074 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
  1075 	TSIGrammarID grammarID = grammarIDPckg();
       
  1076 	TSrsRuleIDPckg ruleIDPtrPckg;
       
  1077 	aMessage.ReadData2FromClientL(ruleIDPtrPckg);
       
  1078 	TSIRuleID ruleID = ruleIDPtrPckg();
       
  1079 
       
  1080 	iImplementor.MSrUnloadRuleL( grammarID, ruleID );
       
  1081 
       
  1082 	}
       
  1083 
       
  1084 // -----------------------------------------------------------------------------
       
  1085 // CSISpeechRecognitionCustomCommandParser::DoLoadEngineParametersL
       
  1086 // Calls the controller plugin to upload the parameters into the engine.
       
  1087 // (other items were commented in a header).
       
  1088 // -----------------------------------------------------------------------------
       
  1089 void CSISpeechRecognitionCustomCommandParser::DoLoadEngineParametersL(
       
  1090 	TMMFMessage& aMessage)
       
  1091 	{
       
  1092 
       
  1093 	RArray<TInt> parameters;
       
  1094 	RArray<TInt> values;
       
  1095 	CleanupClosePushL(parameters);
       
  1096 	CleanupClosePushL(values);
       
  1097 	DoExtractIntArrayFromData1L(aMessage, parameters);
       
  1098 	DoExtractIntArrayFromData2L(aMessage, values);
       
  1099 	iImplementor.MSrLoadEngineParametersL(parameters,values);
       
  1100 	CleanupStack::PopAndDestroy(2); // parameters, values
       
  1101 	
       
  1102 	}
       
  1103 
       
  1104 // ==================== SI Extensions ==========================================
       
  1105 
       
  1106 // -----------------------------------------------------------------------------
       
  1107 // CSISpeechRecognitionCustomCommandParser::DoAdaptL
       
  1108 // Adapts the acoustic models to a user's voice.
       
  1109 // (other items were commented in a header).
       
  1110 // -----------------------------------------------------------------------------
       
  1111 void CSISpeechRecognitionCustomCommandParser::DoAdaptL(
       
  1112     TMMFMessage& aMessage)
       
  1113     {
       
  1114     HBufC8* resultSetBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 1 );
       
  1115 
       
  1116     TPckgBuf<TInt> correctPckg;
       
  1117     aMessage.ReadData2FromClientL( correctPckg );
       
  1118 
       
  1119     RDesReadStream resultSetStream;
       
  1120     CleanupClosePushL( resultSetStream );
       
  1121     resultSetStream.Open( *resultSetBuf );
       
  1122 
       
  1123     if ( iAdaptationSet )
       
  1124         {
       
  1125         delete iAdaptationSet;
       
  1126         iAdaptationSet = 0;
       
  1127         }
       
  1128 
       
  1129     iAdaptationSet = CSIClientResultSet::NewL();
       
  1130     iAdaptationSet->InternalizeL( resultSetStream );
       
  1131 
       
  1132     iImplementor.MSrAdaptL( *iAdaptationSet, correctPckg() );
       
  1133 
       
  1134     CleanupStack::PopAndDestroy( &resultSetStream );
       
  1135     CleanupStack::PopAndDestroy( resultSetBuf );
       
  1136     }
       
  1137 
       
  1138 // -----------------------------------------------------------------------------
       
  1139 // CSISpeechRecognitionCustomCommandParser::DoAddPronunciationSIL
       
  1140 // Adds a speaker independent pronunciation
       
  1141 // (other items were commented in a header).
       
  1142 // -----------------------------------------------------------------------------
       
  1143 void CSISpeechRecognitionCustomCommandParser::DoAddPronunciationSIL(
       
  1144     TMMFMessage& aMessage)
       
  1145     {
       
  1146     TSrsAddPronunciationSIPckg pckg;
       
  1147     TSrsAddPronunciationSI* addPronunData;
       
  1148 
       
  1149     aMessage.ReadData1FromClientL( pckg );
       
  1150     addPronunData = &pckg();
       
  1151 
       
  1152     // Read the phrase to be trained.
       
  1153     HBufC8* textData = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
       
  1154 
       
  1155     // The phrase is in 8-bit descriptor, altough its structure is 16-bit Unicode.
       
  1156     // We make a 16-bit TPtr, which points to the same memory area.
       
  1157     TUint16* trainTextAddress = (TUint16*)textData->Ptr();
       
  1158     TInt     trainTextLength  = addPronunData->iTextLength;
       
  1159 
       
  1160     // Check against buffer overrun before making the descriptor.
       
  1161     TInt trainTextSize = 2 * trainTextLength;
       
  1162     if ( trainTextSize > textData->Size() )
       
  1163         {
       
  1164         User::Leave( KErrCorrupt );
       
  1165         }
       
  1166 
       
  1167     // Make the descriptor.
       
  1168     TPtrC16 trainText( trainTextAddress, trainTextLength );
       
  1169 
       
  1170     iImplementor.MSrAddPronunciationL(
       
  1171         addPronunData->iLexiconID,
       
  1172         trainText,
       
  1173         addPronunData->iLanguage,
       
  1174         *addPronunData->iPronunciationIDPtr );
       
  1175 
       
  1176     CleanupStack::PopAndDestroy( textData );
       
  1177     }
       
  1178 
       
  1179 // -----------------------------------------------------------------------------
       
  1180 // CSISpeechRecognitionCustomCommandParser::DoAddRuleVariantL
       
  1181 // Adds a rule variant
       
  1182 // (other items were commented in a header).
       
  1183 // -----------------------------------------------------------------------------
       
  1184 //
       
  1185 
       
  1186 void CSISpeechRecognitionCustomCommandParser::DoAddRuleVariantL(
       
  1187     TMMFMessage& aMessage)
       
  1188     {
       
  1189     TSrsAddRuleVariantPckg pckg;
       
  1190     TSrsAddRuleVariant* data;
       
  1191 
       
  1192     aMessage.ReadData1FromClientL( pckg );
       
  1193     data = &pckg();
       
  1194 
       
  1195     // Read the second parameter slot of aMessage.
       
  1196     HBufC8* pronunChunk = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
       
  1197     // Stack: pronunChunk
       
  1198 
       
  1199     RArray<TSIPronunciationID> pronunArray;
       
  1200     CleanupClosePushL( pronunArray ); // Stack: pronunChunk, pronunArray
       
  1201 
       
  1202     SICustomCommandData::InternalizePronunArrayL(
       
  1203         *pronunChunk,
       
  1204         data->iPronunIDCount,
       
  1205         pronunArray );
       
  1206 
       
  1207     iImplementor.MSrAddRuleVariantL(
       
  1208         data->iGrammarID,
       
  1209         data->iLexiconID,
       
  1210         pronunArray,
       
  1211         data->iRuleID,
       
  1212         *data->iRuleVariantID
       
  1213         );
       
  1214 
       
  1215     CleanupStack::PopAndDestroy( &pronunArray );
       
  1216     CleanupStack::PopAndDestroy( pronunChunk );
       
  1217     }
       
  1218 
       
  1219 // -----------------------------------------------------------------------------
       
  1220 // CSISpeechRecognitionCustomCommandParser::DoAddVoiceTag
       
  1221 // Adds a voice tag
       
  1222 // (other items were commented in a header).
       
  1223 // -----------------------------------------------------------------------------
       
  1224 void CSISpeechRecognitionCustomCommandParser::DoAddVoiceTagL(
       
  1225     TMMFMessage& aMessage)
       
  1226     {
       
  1227     if ( iWordArray != 0 )
       
  1228         {
       
  1229         delete iWordArray;
       
  1230         iWordArray = 0;
       
  1231         }
       
  1232 
       
  1233     TSrsAddVoiceTagPckg pckg;
       
  1234     TSrsAddVoiceTag *params = &pckg();
       
  1235 
       
  1236     aMessage.ReadData1FromClient( pckg );
       
  1237 
       
  1238     HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
       
  1239      // Stack: phraseBuf
       
  1240 
       
  1241     // !!!! Is it able to call ~MDesCArray, as MDesCArray is not derived from CBase?
       
  1242     iWordArray = SICustomCommandData::InternalizeDesCArrayL( *phraseBuf );
       
  1243 
       
  1244     iLanguageArray.Reset();
       
  1245     params->ListLanguagesL( iLanguageArray );
       
  1246 
       
  1247     iImplementor.MSrAddVoiceTagL(
       
  1248         *iWordArray, 
       
  1249         iLanguageArray, 
       
  1250         params->iLexiconID, 
       
  1251         params->iGrammarID, 
       
  1252         *params->iRuleID );
       
  1253 
       
  1254     CleanupStack::PopAndDestroy( phraseBuf );
       
  1255     }
       
  1256 
       
  1257 // -----------------------------------------------------------------------------
       
  1258 // CSISpeechRecognitionCustomCommandParser::DoAddVoiceTags
       
  1259 // Adds several voice tags
       
  1260 // -----------------------------------------------------------------------------
       
  1261 void CSISpeechRecognitionCustomCommandParser::DoAddVoiceTagsL(
       
  1262     TMMFMessage& aMessage)
       
  1263     {
       
  1264     RPointerArray<MDesCArray>* phraseArray = 0;
       
  1265     // The 2 parameter slots contain:
       
  1266     //  1. Headers: Various identifiers
       
  1267     //  2. Phrases: Recognition phrases in an array.
       
  1268 
       
  1269     // Header storage
       
  1270     TSrsAddVoiceTagPckg pckg;
       
  1271     TSrsAddVoiceTag *params = &pckg();
       
  1272 
       
  1273     // Phrase storage
       
  1274 
       
  1275     aMessage.ReadData1FromClient( pckg );
       
  1276     HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
       
  1277     // Stack: phraseBuf
       
  1278 
       
  1279     phraseArray = SICustomCommandData::InternalizeDesCArrayArrayL( *phraseBuf );
       
  1280     CleanupStack::PushL( phraseArray );
       
  1281 
       
  1282     iLanguageArray.Reset();
       
  1283     params->ListLanguagesL( iLanguageArray );
       
  1284 
       
  1285     CleanupStack::Pop( phraseArray );
       
  1286 
       
  1287     iImplementor.MSrAddVoiceTagsL(
       
  1288         phraseArray,
       
  1289         iLanguageArray,
       
  1290         params->iLexiconID,
       
  1291         params->iGrammarID,
       
  1292         iRuleIDs
       
  1293         );
       
  1294 
       
  1295     CleanupStack::PopAndDestroy( phraseBuf );
       
  1296     }
       
  1297 
       
  1298 #ifdef __SINDE_TRAINING
       
  1299 // -----------------------------------------------------------------------------
       
  1300 // CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL
       
  1301 // 
       
  1302 // -----------------------------------------------------------------------------
       
  1303 void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL( TMMFMessage& aMessage )
       
  1304     {
       
  1305     if ( iWordArray != NULL )
       
  1306         {
       
  1307         delete iWordArray;
       
  1308         iWordArray = NULL;
       
  1309         }
       
  1310 
       
  1311     TSrsAddSindeVoiceTagPckg pckg;
       
  1312     TSrsAddSindeVoiceTag *params = &pckg();
       
  1313 
       
  1314     aMessage.ReadData1FromClient( pckg );
       
  1315 
       
  1316     HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
       
  1317      // Stack: phraseBuf
       
  1318 
       
  1319     iWordArray = SICustomCommandData::InternalizeDesCArrayL( *phraseBuf );
       
  1320 
       
  1321     for ( TInt i = 0; i < iLanguageArrayArray.Count(); i++ )
       
  1322         {
       
  1323         iLanguageArrayArray[i].Close();
       
  1324         }
       
  1325     iLanguageArrayArray.Reset();
       
  1326     params->ListLanguagesL( iLanguageArrayArray );
       
  1327 
       
  1328     iImplementor.MSrAddSindeVoiceTagL( *iWordArray, 
       
  1329                                        iLanguageArrayArray, 
       
  1330                                        params->iLexiconID, 
       
  1331                                        params->iGrammarID, 
       
  1332                                        *params->iRuleID );
       
  1333 
       
  1334     CleanupStack::PopAndDestroy( phraseBuf );
       
  1335     }
       
  1336 
       
  1337 // -----------------------------------------------------------------------------
       
  1338 // CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL
       
  1339 //
       
  1340 // -----------------------------------------------------------------------------
       
  1341 void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL( TMMFMessage& aMessage )
       
  1342     {
       
  1343     RPointerArray<MDesCArray>* phraseArray = 0;
       
  1344     // The 2 parameter slots contain:
       
  1345     //  1. Headers: Various identifiers
       
  1346     //  2. Phrases: Recognition phrases in an array.
       
  1347 
       
  1348     // Header storage
       
  1349     TSrsAddSindeVoiceTagPckg pckg;
       
  1350     TSrsAddSindeVoiceTag *params = &pckg();
       
  1351 
       
  1352     // Phrase storage
       
  1353 
       
  1354     aMessage.ReadData1FromClient( pckg );
       
  1355     HBufC8* phraseBuf = SICustomCommandData::ReadMessageDataLC( aMessage, 2 );
       
  1356     // Stack: phraseBuf
       
  1357 
       
  1358     phraseArray = SICustomCommandData::InternalizeDesCArrayArrayL( *phraseBuf );
       
  1359     CleanupStack::PushL( phraseArray );
       
  1360 
       
  1361     for ( TInt i = 0; i < iLanguageArrayArray.Count(); i++ )
       
  1362         {
       
  1363         iLanguageArrayArray[i].Close();
       
  1364         }
       
  1365     iLanguageArrayArray.Reset();
       
  1366     params->ListLanguagesL( iLanguageArrayArray );
       
  1367 
       
  1368 
       
  1369     iImplementor.MSrAddSindeVoiceTagsL( phraseArray, iLanguageArrayArray,
       
  1370                                         params->iLexiconID, params->iGrammarID,
       
  1371                                         iRuleIDs );
       
  1372 
       
  1373     CleanupStack::Pop( phraseArray );
       
  1374     CleanupStack::PopAndDestroy( phraseBuf );
       
  1375     }
       
  1376 
       
  1377 #else // __SINDE_TRAINING
       
  1378 // -----------------------------------------------------------------------------
       
  1379 // CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL
       
  1380 // 
       
  1381 // -----------------------------------------------------------------------------
       
  1382 void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagL( TMMFMessage& /*aMessage*/ )
       
  1383     {
       
  1384     User::Leave( KErrNotSupported );
       
  1385     }
       
  1386 
       
  1387 // -----------------------------------------------------------------------------
       
  1388 // CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL
       
  1389 //
       
  1390 // -----------------------------------------------------------------------------
       
  1391 void CSISpeechRecognitionCustomCommandParser::DoAddSindeVoiceTagsL( TMMFMessage& /*aMessage*/ )
       
  1392     {
       
  1393     User::Leave( KErrNotSupported );
       
  1394     }
       
  1395 #endif // __SINDE_TRAINING
       
  1396 
       
  1397 // -----------------------------------------------------------------------------
       
  1398 // CSISpeechRecognitionCustomCommandParser::DoCreateRule
       
  1399 // Creates an empty rule
       
  1400 // (other items were commented in a header).
       
  1401 // -----------------------------------------------------------------------------
       
  1402 void CSISpeechRecognitionCustomCommandParser::DoCreateRuleL(
       
  1403     TMMFMessage& aMessage)
       
  1404     {
       
  1405     TSrsAddRulePckg pckg;
       
  1406     TSrsAddRule* params = &(pckg());
       
  1407 
       
  1408 	aMessage.ReadData1FromClientL(pckg);
       
  1409 
       
  1410     iImplementor.MSrCreateRuleL( params->iGrammarID, *params->iRuleID );
       
  1411     }
       
  1412 
       
  1413 // -----------------------------------------------------------------------------
       
  1414 // CSISpeechRecognitionCustomCommandParser::DoEndRecord
       
  1415 // Stops recognition
       
  1416 // (other items were commented in a header).
       
  1417 // -----------------------------------------------------------------------------
       
  1418 void CSISpeechRecognitionCustomCommandParser::DoEndRecordL(
       
  1419     TMMFMessage& /*aMessage*/)
       
  1420     {
       
  1421     iImplementor.MSrEndRecordL();
       
  1422     }
       
  1423 
       
  1424 // -----------------------------------------------------------------------------
       
  1425 // CSISpeechRecognitionCustomCommandParser::DoRecognizeSI
       
  1426 // Starts a speaker independent recognition
       
  1427 // (other items were commented in a header).
       
  1428 // -----------------------------------------------------------------------------
       
  1429 void CSISpeechRecognitionCustomCommandParser::DoRecognizeSIL(
       
  1430     TMMFMessage& aMessage)
       
  1431     {
       
  1432 	// remove any previous result set, if any
       
  1433 	if (iSIResultSet != NULL)
       
  1434 	{
       
  1435 		delete iSIResultSet;
       
  1436 		iSIResultSet = NULL;
       
  1437 	}
       
  1438 
       
  1439     // Read data chunk of CSIClientResultSet
       
  1440     HBufC8* dataBuffer = SICustomCommandData::ReadMessageDataLC( aMessage, 1 );
       
  1441 
       
  1442     // Set up stream
       
  1443 	RDesReadStream stream( *dataBuffer );
       
  1444 	CleanupClosePushL(stream);
       
  1445 
       
  1446     // Convert chunk to proper type
       
  1447 	iSIResultSet = CSIClientResultSet::NewL();
       
  1448 	iSIResultSet->InternalizeL(stream);
       
  1449 
       
  1450     // Recognize
       
  1451 	iImplementor.MSrRecognizeL(*iSIResultSet);
       
  1452 
       
  1453 	CleanupStack::PopAndDestroy(&stream);//stream
       
  1454     CleanupStack::PopAndDestroy(dataBuffer);//databuffer
       
  1455     }
       
  1456 
       
  1457 // -----------------------------------------------------------------------------
       
  1458 // CSISpeechRecognitionCustomCommandParser::DoUnloadGrammar
       
  1459 // Deactivates a grammar from the current recognition vocabulary
       
  1460 // (other items were commented in a header).
       
  1461 // -----------------------------------------------------------------------------
       
  1462 void CSISpeechRecognitionCustomCommandParser::DoUnloadGrammarL(
       
  1463     TMMFMessage& aMessage)
       
  1464     {
       
  1465 	TSrsGrammarIDPckg pckg;
       
  1466 	aMessage.ReadData1FromClientL(pckg);
       
  1467 	TSIGrammarID grammarID = pckg();
       
  1468 
       
  1469 	iImplementor.MSrUnloadGrammarL(grammarID);
       
  1470     }
       
  1471 
       
  1472 // ==================== SI Extensions end ======================================
       
  1473 
       
  1474 
       
  1475 // -----------------------------------------------------------------------------
       
  1476 // CSISpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL
       
  1477 // Copy the pronunciation IDs to the client.
       
  1478 // (other items were commented in a header).
       
  1479 // -----------------------------------------------------------------------------
       
  1480 void CSISpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL(
       
  1481 	TMMFMessage& aMessage)
       
  1482 	{
       
  1483 
       
  1484 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1485 	CleanupStack::PushL(dataCopyBuffer);
       
  1486 	RBufWriteStream stream;
       
  1487 	stream.Open(*dataCopyBuffer);
       
  1488 	CleanupClosePushL(stream);
       
  1489 	for (TInt i=0;i<iPronunciationIDs.Count();i++)
       
  1490 	{
       
  1491 		stream.WriteUint32L(iPronunciationIDs[i]);
       
  1492 	}
       
  1493 
       
  1494 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1495 	
       
  1496 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1497 	
       
  1498 	}
       
  1499 
       
  1500 // -----------------------------------------------------------------------------
       
  1501 // CSISpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL
       
  1502 // Copy the model IDs to the client.
       
  1503 // (other items were commented in a header).
       
  1504 // -----------------------------------------------------------------------------
       
  1505 void CSISpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL(
       
  1506 	TMMFMessage& aMessage)
       
  1507 	{
       
  1508 
       
  1509 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1510 	CleanupStack::PushL(dataCopyBuffer);
       
  1511 	RBufWriteStream stream;
       
  1512 	stream.Open(*dataCopyBuffer);
       
  1513 	CleanupClosePushL(stream);
       
  1514 	for (TInt i=0;i<iModelIDs.Count();i++)
       
  1515 	{
       
  1516 		stream.WriteUint32L(iModelIDs[i]);
       
  1517 	}
       
  1518 
       
  1519 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1520 	
       
  1521 //	iModelIDs.Close();
       
  1522 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1523 
       
  1524 	}
       
  1525 
       
  1526 // -----------------------------------------------------------------------------
       
  1527 // CSISpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL
       
  1528 // Copy the rule IDs to the client.
       
  1529 // (other items were commented in a header).
       
  1530 // -----------------------------------------------------------------------------
       
  1531 void CSISpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL(
       
  1532 	TMMFMessage& aMessage)
       
  1533 	{
       
  1534 
       
  1535 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1536 	CleanupStack::PushL(dataCopyBuffer);
       
  1537 	RBufWriteStream stream;
       
  1538 	stream.Open(*dataCopyBuffer);
       
  1539 	CleanupClosePushL(stream);
       
  1540 	for (TInt i=0;i<iRuleIDs.Count();i++)
       
  1541 	{
       
  1542 		stream.WriteUint32L(iRuleIDs[i]);
       
  1543 	}
       
  1544 
       
  1545 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1546 	
       
  1547 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1548 
       
  1549 	}
       
  1550 	
       
  1551 // -----------------------------------------------------------------------------
       
  1552 // CSISpeechRecognitionCustomCommandParser::DoRemoveRules
       
  1553 // Remove rules by their IDS
       
  1554 // (other items were commented in a header).
       
  1555 // -----------------------------------------------------------------------------
       
  1556 void CSISpeechRecognitionCustomCommandParser::DoRemoveRulesL( TMMFMessage& aMessage )
       
  1557 	{
       
  1558     RUBY_DEBUG_BLOCK( "CSISpeechRecognitionCustomCommandParser::DoRemoveRulesL" );
       
  1559 
       
  1560 	TSrsGrammarIDPckg grammarIDPckg;
       
  1561 	aMessage.ReadData1FromClientL(grammarIDPckg);
       
  1562 	TSIGrammarID grammarID = grammarIDPckg();
       
  1563 	RArray<TInt> ruleIDs;
       
  1564 	CleanupClosePushL( ruleIDs );
       
  1565 //	TMMFMessage& aMessage, 
       
  1566 //	RArray<TInt>& aArray)
       
  1567 	DoExtractIntArrayFromData2L(aMessage, ruleIDs);
       
  1568 
       
  1569 	
       
  1570 	iRuleIDs.Reset();
       
  1571 	for( TInt i = 0; i < ruleIDs.Count(); i++) 
       
  1572 		{
       
  1573 		iRuleIDs.Append(ruleIDs[i]);
       
  1574 		}
       
  1575 
       
  1576 	//iImplementor.MSrRemoveRulesL( grammarID, reinterpret_cast<RArray<TUint32>&> ( forwardedRuleIDs ) );
       
  1577     iImplementor.MSrRemoveRulesL( grammarID, iRuleIDs );
       
  1578 
       
  1579 	CleanupStack::PopAndDestroy();  // ruleIDs
       
  1580 	}
       
  1581 
       
  1582 
       
  1583 // -----------------------------------------------------------------------------
       
  1584 // CSISpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL
       
  1585 // Copy the grammar IDs to the client.
       
  1586 // (other items were commented in a header).
       
  1587 // -----------------------------------------------------------------------------
       
  1588 void CSISpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL(
       
  1589 	TMMFMessage& aMessage)
       
  1590 	{
       
  1591 
       
  1592 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1593 	CleanupStack::PushL(dataCopyBuffer);
       
  1594 	RBufWriteStream stream;
       
  1595 	stream.Open(*dataCopyBuffer);
       
  1596 	CleanupClosePushL(stream);
       
  1597 	for (TInt i=0;i<iGrammarIDs.Count();i++)
       
  1598 	{
       
  1599 		stream.WriteUint32L(iGrammarIDs[i]);
       
  1600 	}
       
  1601 
       
  1602 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1603 	
       
  1604 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1605 
       
  1606 	}
       
  1607 
       
  1608 // -----------------------------------------------------------------------------
       
  1609 // CSISpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL
       
  1610 // Copy the lexicon IDs to the client.
       
  1611 // (other items were commented in a header).
       
  1612 // -----------------------------------------------------------------------------
       
  1613 void CSISpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL(
       
  1614 	TMMFMessage& aMessage)
       
  1615 	{
       
  1616 
       
  1617 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1618 	CleanupStack::PushL(dataCopyBuffer);
       
  1619 	RBufWriteStream stream;
       
  1620 	stream.Open(*dataCopyBuffer);
       
  1621 	CleanupClosePushL(stream);
       
  1622 	for (TInt i=0;i<iLexiconIDs.Count();i++)
       
  1623 	{
       
  1624 		stream.WriteUint32L(iLexiconIDs[i]);
       
  1625 	}
       
  1626 
       
  1627 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1628 	
       
  1629 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1630 
       
  1631 	}
       
  1632 
       
  1633 // -----------------------------------------------------------------------------
       
  1634 // CSISpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL
       
  1635 // Copy the model bank IDs to the client.
       
  1636 // (other items were commented in a header).
       
  1637 // -----------------------------------------------------------------------------
       
  1638 void CSISpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL(
       
  1639 	TMMFMessage& aMessage)
       
  1640 	{
       
  1641 
       
  1642 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1643 	CleanupStack::PushL(dataCopyBuffer);
       
  1644 	RBufWriteStream stream;
       
  1645 	stream.Open(*dataCopyBuffer);
       
  1646 	CleanupClosePushL(stream);
       
  1647 	for (TInt i=0;i<iModelBankIDs.Count();i++)
       
  1648 	{
       
  1649 		stream.WriteUint32L(iModelBankIDs[i]);
       
  1650 	}
       
  1651 
       
  1652 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1653 	
       
  1654 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1655 
       
  1656 	}
       
  1657 
       
  1658 // -----------------------------------------------------------------------------
       
  1659 // CSISpeechRecognitionCustomCommandParser::DoExternalizeResultSetL
       
  1660 // Externalize the client result set. 
       
  1661 // (other items were commented in a header).
       
  1662 // -----------------------------------------------------------------------------
       
  1663 void CSISpeechRecognitionCustomCommandParser::DoExternalizeResultSetL()
       
  1664 	{
       
  1665     RUBY_DEBUG0( "CSISpeechRecognitionCustomCommandParser::DoExternalizeResultSetL is NOT supported" );
       
  1666 	User::Leave( KErrNotSupported );
       
  1667 	}
       
  1668 
       
  1669 // -----------------------------------------------------------------------------
       
  1670 // CSISpeechRecognitionCustomCommandParser::DoCopyResultSetL
       
  1671 // Copy the recognition result set to the client.
       
  1672 // (other items were commented in a header).
       
  1673 // -----------------------------------------------------------------------------
       
  1674 void CSISpeechRecognitionCustomCommandParser::DoCopyResultSetL(
       
  1675 	TMMFMessage& aMessage)
       
  1676 	{
       
  1677 
       
  1678 	// make sure we have a copy buffer available.
       
  1679 	if ( iResultCopyBuffer == NULL )
       
  1680 	{
       
  1681 		User::Leave(KErrNotReady);
       
  1682 	}
       
  1683 
       
  1684 	aMessage.WriteDataToClientL(iResultCopyBuffer->Ptr(0));
       
  1685 	delete iResultCopyBuffer;
       
  1686 	iResultCopyBuffer = NULL;
       
  1687 
       
  1688 	}
       
  1689 
       
  1690 // -----------------------------------------------------------------------------
       
  1691 // CSISpeechRecognitionCustomCommandParser::DoExternalizeSIResultSetL
       
  1692 // Externalize the client result set. 
       
  1693 // (other items were commented in a header).
       
  1694 // -----------------------------------------------------------------------------
       
  1695 void CSISpeechRecognitionCustomCommandParser::DoExternalizeSIResultSetL()
       
  1696 	{
       
  1697 
       
  1698 	// make sure we have a result set available.
       
  1699 	if ( iSIResultSet == NULL )
       
  1700 	{
       
  1701 		User::Leave(KErrNotReady);
       
  1702 	}
       
  1703 	
       
  1704 	// allocate the result copy buffer if needed.
       
  1705 	if (iResultCopyBuffer == NULL ) 
       
  1706 	{
       
  1707 		iResultCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1708 	}
       
  1709 	else
       
  1710 	{
       
  1711 		iResultCopyBuffer->Reset();	// use existing buffer, clear previous results
       
  1712 	}
       
  1713 
       
  1714 	RBufWriteStream stream;
       
  1715 	stream.Open(*iResultCopyBuffer);
       
  1716 	CleanupClosePushL(stream);
       
  1717 	iSIResultSet->ExternalizeL(stream);
       
  1718 	delete iSIResultSet; // the controller side version is no longer needed
       
  1719 	iSIResultSet = NULL;
       
  1720 	CleanupStack::PopAndDestroy(1); //stream
       
  1721 
       
  1722 	}
       
  1723 
       
  1724 // -----------------------------------------------------------------------------
       
  1725 // CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L
       
  1726 // Extract an integer array from client data 1.
       
  1727 // (other items were commented in a header).
       
  1728 // -----------------------------------------------------------------------------
       
  1729 void CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L(
       
  1730 	TMMFMessage& aMessage, 
       
  1731 	RArray<TInt>& aArray)
       
  1732 	{
       
  1733 	TInt size = aMessage.SizeOfData1FromClient();
       
  1734 	HBufC8* buf = HBufC8::NewL(size);
       
  1735 	CleanupStack::PushL(buf);
       
  1736 	TPtr8 ptr = buf->Des();
       
  1737 	aMessage.ReadData1FromClientL(ptr);
       
  1738 	DoExtractIntArrayL(ptr,aArray);
       
  1739 	CleanupStack::PopAndDestroy(buf);
       
  1740 	}
       
  1741 
       
  1742 // -----------------------------------------------------------------------------
       
  1743 // CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L
       
  1744 // Extract an integer array from client data 2.
       
  1745 // (other items were commented in a header).
       
  1746 // -----------------------------------------------------------------------------
       
  1747 void CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L(
       
  1748 	TMMFMessage& aMessage, 
       
  1749 	RArray<TInt>& aArray)
       
  1750 	{
       
  1751 	
       
  1752 	TInt size = aMessage.SizeOfData2FromClient();
       
  1753 	HBufC8* buf = HBufC8::NewL(size);
       
  1754 	CleanupStack::PushL(buf);
       
  1755 	TPtr8 ptr = buf->Des();
       
  1756 	aMessage.ReadData2FromClientL(ptr);
       
  1757 	DoExtractIntArrayL(ptr,aArray);
       
  1758 	CleanupStack::PopAndDestroy(buf);
       
  1759 	
       
  1760 	}
       
  1761 
       
  1762 // -----------------------------------------------------------------------------
       
  1763 // CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayL
       
  1764 // Extract an integer array from a descriptor into an RArray.
       
  1765 // (other items were commented in a header).
       
  1766 // -----------------------------------------------------------------------------	
       
  1767 void CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayL(
       
  1768 	TDes8& aDescriptor, 
       
  1769 	RArray<TInt>& aArray)
       
  1770 	{
       
  1771 
       
  1772 	RDesReadStream stream(aDescriptor);
       
  1773 	CleanupClosePushL(stream);
       
  1774 	
       
  1775 	TInt numberElements;
       
  1776 	numberElements = stream.ReadInt32L();
       
  1777 
       
  1778     TInt i( 0 );
       
  1779 	for ( i = 0; i<numberElements; i++)
       
  1780 		{
       
  1781 		User::LeaveIfError(aArray.Append(stream.ReadInt32L()));
       
  1782 		}
       
  1783 	CleanupStack::PopAndDestroy(); //stream
       
  1784 	
       
  1785 #ifdef _DEBUG
       
  1786         RUBY_DEBUG1( "CSISpeechRecognitionCustomCommandParser::DoExtractIntArrayL Read array of size [%d]", aArray.Count() );
       
  1787 
       
  1788 		for( i = 0; i < aArray.Count(); i++) 
       
  1789 			{
       
  1790 			RUBY_DEBUG2( "::DoExtractIntArrayL aArray[%d] = [%d]", i, aArray[i] );
       
  1791 			}
       
  1792 #endif
       
  1793 
       
  1794 	}
       
  1795 
       
  1796 // -----------------------------------------------------------------------------
       
  1797 // CSISpeechRecognitionCustomCommandParser::DoCopyIntArrayL
       
  1798 // Copy data from an RArray to the client.
       
  1799 // (other items were commented in a header).
       
  1800 // -----------------------------------------------------------------------------	
       
  1801 void CSISpeechRecognitionCustomCommandParser::DoCopyIntArrayL(
       
  1802 	TMMFMessage& aMessage, 
       
  1803 	const RArray<TInt>& aArray)
       
  1804 	{
       
  1805 
       
  1806 	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KExpandSize);
       
  1807 	CleanupStack::PushL(dataCopyBuffer);
       
  1808 	RBufWriteStream stream;
       
  1809 	stream.Open(*dataCopyBuffer);
       
  1810 	CleanupClosePushL(stream);
       
  1811 
       
  1812 	for (TInt i=0;i<aArray.Count();i++)
       
  1813 	{
       
  1814 		stream.WriteUint32L(aArray[i]);
       
  1815 	}
       
  1816 
       
  1817 	aMessage.WriteDataToClientL(dataCopyBuffer->Ptr(0));
       
  1818 	CleanupStack::PopAndDestroy(2); //stream,dataCopyBuffer
       
  1819 
       
  1820 	}
       
  1821 
       
  1822 
       
  1823 // End of file