os/mm/mmdevicefw/speechrecogsupport/ASR/src/SpeechRecognitionCustomCommandParser.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
#include <mmf/common/speechrecognitioncustomcommandparser.h>
sl@0
    18
#include "SpeechRecognitionCustomCommandCommon.h"
sl@0
    19
sl@0
    20
const TInt KExpandSize = 10;
sl@0
    21
sl@0
    22
sl@0
    23
EXPORT_C CSpeechRecognitionCustomCommandParser* CSpeechRecognitionCustomCommandParser::NewL(
sl@0
    24
							MSpeechRecognitionCustomCommandImplementor& aImplementor)
sl@0
    25
	{
sl@0
    26
	CSpeechRecognitionCustomCommandParser* self = new (ELeave) CSpeechRecognitionCustomCommandParser(aImplementor);
sl@0
    27
	return self;
sl@0
    28
	}
sl@0
    29
sl@0
    30
EXPORT_C CSpeechRecognitionCustomCommandParser::~CSpeechRecognitionCustomCommandParser()
sl@0
    31
	{
sl@0
    32
	iPronunciationIDs.Close();
sl@0
    33
	iRuleIDs.Close();
sl@0
    34
	iModelIDs.Close();
sl@0
    35
	iModelBankIDs.Close();
sl@0
    36
	iGrammarIDs.Close();
sl@0
    37
	iLexiconIDs.Close();
sl@0
    38
	delete iResultSet;
sl@0
    39
	delete iResultCopyBuffer;	
sl@0
    40
	}
sl@0
    41
sl@0
    42
void CSpeechRecognitionCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
sl@0
    43
	{
sl@0
    44
	TInt err;
sl@0
    45
	if (aMessage.Destination().InterfaceId() == KUidInterfaceSpeechRecognition)
sl@0
    46
		{
sl@0
    47
		TRAP(err, DoHandleRequestL(aMessage));
sl@0
    48
		aMessage.Complete(err);
sl@0
    49
		}
sl@0
    50
	else
sl@0
    51
		aMessage.Complete(KErrNotSupported);
sl@0
    52
	}
sl@0
    53
sl@0
    54
sl@0
    55
CSpeechRecognitionCustomCommandParser::CSpeechRecognitionCustomCommandParser(MSpeechRecognitionCustomCommandImplementor& aImplementor)
sl@0
    56
	: CMMFCustomCommandParserBase(KUidInterfaceSpeechRecognition), iImplementor(aImplementor)
sl@0
    57
	{
sl@0
    58
	
sl@0
    59
	}
sl@0
    60
sl@0
    61
void CSpeechRecognitionCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
sl@0
    62
	{	
sl@0
    63
	TPckgBuf<TInt> pckgSize;
sl@0
    64
	
sl@0
    65
	switch (aMessage.Function())
sl@0
    66
		{
sl@0
    67
		case ESrAddPronunciation:
sl@0
    68
			DoAddPronunciationL(aMessage);
sl@0
    69
			break;
sl@0
    70
		case ESrAddRule:
sl@0
    71
			DoAddRuleL(aMessage);
sl@0
    72
			break;
sl@0
    73
		case ESrCancel:
sl@0
    74
			DoCancel();
sl@0
    75
			break;
sl@0
    76
		case ESrCommitChanges:
sl@0
    77
			DoCommitChangesL();
sl@0
    78
			break;
sl@0
    79
		case ESrCreateGrammar:
sl@0
    80
			DoCreateGrammarL(aMessage);
sl@0
    81
			break;
sl@0
    82
		case ESrCreateLexicon:
sl@0
    83
			DoCreateLexiconL(aMessage);
sl@0
    84
			break;
sl@0
    85
		case ESrCreateModelBank:
sl@0
    86
			DoCreateModelBankL(aMessage);
sl@0
    87
			break;
sl@0
    88
		case ESrEndRecSession:
sl@0
    89
			DoEndRecSessionL();
sl@0
    90
			break;
sl@0
    91
		case ESrGetAllModelIDs:
sl@0
    92
			DoGetAllModelIDsL(aMessage);
sl@0
    93
			break;
sl@0
    94
		case ESrGetAllPronunciationIDs:
sl@0
    95
			DoGetAllPronunciationIDsL(aMessage);
sl@0
    96
			break;
sl@0
    97
		case ESrGetAllRuleIDs:
sl@0
    98
			DoGetAllRuleIDsL(aMessage);
sl@0
    99
			break;
sl@0
   100
		case ESrGetAllModelBankIDs:
sl@0
   101
			DoGetAllModelBankIDsL();
sl@0
   102
			break;
sl@0
   103
		case ESrGetAllLexiconIDs:
sl@0
   104
			DoGetAllLexiconIDsL();
sl@0
   105
			break;
sl@0
   106
		case ESrGetAllGrammarIDs:
sl@0
   107
			DoGetAllGrammarIDsL();
sl@0
   108
			break;
sl@0
   109
		case ESrGetAllClientModelBankIDs:
sl@0
   110
			DoGetAllClientModelBankIDsL();
sl@0
   111
			break;
sl@0
   112
		case ESrGetAllClientLexiconIDs:
sl@0
   113
			DoGetAllClientLexiconIDsL();
sl@0
   114
			break;
sl@0
   115
		case ESrGetAllClientGrammarIDs:
sl@0
   116
			DoGetAllClientGrammarIDsL();
sl@0
   117
			break;
sl@0
   118
		case ESrGetAvailableStorage:
sl@0
   119
			DoGetAvailableStorageL(aMessage);
sl@0
   120
			break;
sl@0
   121
		case ESrGetEngineProperties:
sl@0
   122
			DoGetEnginePropertiesL(aMessage);
sl@0
   123
			break;
sl@0
   124
		case ESrGetModelCount:
sl@0
   125
			DoGetModelCountL(aMessage);
sl@0
   126
			break;
sl@0
   127
		case ESrGetRuleValidity:
sl@0
   128
			DoGetRuleValidityL(aMessage);
sl@0
   129
			break;
sl@0
   130
		case ESrUtteranceDuration:
sl@0
   131
			DoGetUtteranceDurationL(aMessage);
sl@0
   132
			break;
sl@0
   133
		case ESrLoadGrammar:
sl@0
   134
			DoLoadGrammarL(aMessage);
sl@0
   135
			break;
sl@0
   136
		case ESrLoadLexicon:
sl@0
   137
			DoLoadLexiconL(aMessage);
sl@0
   138
			break;
sl@0
   139
		case ESrLoadModels:
sl@0
   140
			DoLoadModelsL(aMessage);
sl@0
   141
			break;
sl@0
   142
		case ESrPlayUtterance:
sl@0
   143
			DoPlayUtteranceL(aMessage);
sl@0
   144
			break;
sl@0
   145
		case ESrRecognize:
sl@0
   146
			DoRecognizeL(aMessage);
sl@0
   147
			break;
sl@0
   148
		case ESrRecord:
sl@0
   149
			DoRecordL(aMessage);
sl@0
   150
			break;
sl@0
   151
		case ESrRemoveGrammar:
sl@0
   152
			DoRemoveGrammarL(aMessage);
sl@0
   153
			break;
sl@0
   154
		case ESrRemoveLexicon:
sl@0
   155
			DoRemoveLexiconL(aMessage);
sl@0
   156
			break;
sl@0
   157
		case ESrRemoveModelBank:
sl@0
   158
			DoRemoveModelBankL(aMessage);
sl@0
   159
			break;
sl@0
   160
		case ESrRemoveModel:
sl@0
   161
			DoRemoveModelL(aMessage);
sl@0
   162
			break;
sl@0
   163
		case ESrRemovePronunciation:
sl@0
   164
			DoRemovePronunciationL(aMessage);
sl@0
   165
			break;
sl@0
   166
		case ESrRemoveRule:
sl@0
   167
			DoRemoveRuleL(aMessage);
sl@0
   168
			break;
sl@0
   169
		case ESrStartRecSession:
sl@0
   170
			DoStartRecSessionL(aMessage);
sl@0
   171
			break;
sl@0
   172
		case ESrTrain:
sl@0
   173
			DoTrainL(aMessage);
sl@0
   174
			break;
sl@0
   175
		case ESrUnloadRule:
sl@0
   176
			DoUnloadRuleL(aMessage);
sl@0
   177
			break;
sl@0
   178
		case ESrLoadEngineParameters:
sl@0
   179
			DoLoadEngineParametersL(aMessage);
sl@0
   180
			break;
sl@0
   181
		case ESrGetPronunciationIDArraySize:
sl@0
   182
			pckgSize() = iPronunciationIDs.Count();
sl@0
   183
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   184
			break;
sl@0
   185
		case ESrGetPronunciationIDArrayContents:
sl@0
   186
			DoCopyPronunciationIDArrayL(aMessage);
sl@0
   187
			break;
sl@0
   188
		case ESrGetRuleIDArraySize:
sl@0
   189
			pckgSize() = iRuleIDs.Count();
sl@0
   190
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   191
			break;
sl@0
   192
		case ESrGetRuleIDArrayContents:
sl@0
   193
			DoCopyRuleIDArrayL(aMessage);			
sl@0
   194
			break;
sl@0
   195
		case ESrGetModelIDArraySize:
sl@0
   196
			pckgSize() = iModelIDs.Count();
sl@0
   197
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   198
			break;
sl@0
   199
		case ESrGetModelIDArrayContents:
sl@0
   200
			DoCopyModelIDArrayL(aMessage);
sl@0
   201
			break;
sl@0
   202
		case ESrGetLexiconIDArraySize:
sl@0
   203
			pckgSize() = iLexiconIDs.Count();
sl@0
   204
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   205
			break;
sl@0
   206
		case ESrGetLexiconIDArrayContents:
sl@0
   207
			DoCopyLexiconIDArrayL(aMessage);
sl@0
   208
			break;
sl@0
   209
		case ESrGetGrammarIDArraySize:
sl@0
   210
			pckgSize() = iGrammarIDs.Count();
sl@0
   211
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   212
			break;
sl@0
   213
		case ESrGetGrammarIDArrayContents:
sl@0
   214
			DoCopyGrammarIDArrayL(aMessage);			
sl@0
   215
			break;
sl@0
   216
		case ESrGetModelBankIDArraySize:
sl@0
   217
			pckgSize() = iModelBankIDs.Count();
sl@0
   218
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   219
			break;
sl@0
   220
		case ESrGetModelBankIDArrayContents:
sl@0
   221
			DoCopyModelBankIDArrayL(aMessage);
sl@0
   222
			break;
sl@0
   223
		case ESrGetClientResultSetSize:
sl@0
   224
			DoExternalizeResultSetL();
sl@0
   225
			pckgSize() = iResultCopyBuffer->Size();
sl@0
   226
			aMessage.WriteDataToClientL(pckgSize);
sl@0
   227
			break;
sl@0
   228
		case ESrGetClientResultSet:
sl@0
   229
			DoCopyResultSetL(aMessage);
sl@0
   230
			break;
sl@0
   231
		case ESrSetClientUid:
sl@0
   232
			DoSetClientUidL(aMessage);
sl@0
   233
			break;
sl@0
   234
		default:
sl@0
   235
			User::Leave(KErrNotSupported);
sl@0
   236
			break;
sl@0
   237
		}
sl@0
   238
	}
sl@0
   239
sl@0
   240
void CSpeechRecognitionCustomCommandParser::DoAddPronunciationL(TMMFMessage& aMessage)
sl@0
   241
	{
sl@0
   242
	TSrsAddPronunciationPckg pckg;
sl@0
   243
	aMessage.ReadData1FromClientL(pckg);
sl@0
   244
	iImplementor.MSrAddPronunciationL(pckg().iLexiconID, pckg().iModelBankID, pckg().iModelID, *pckg().iPronunciationID);
sl@0
   245
	}
sl@0
   246
	
sl@0
   247
void CSpeechRecognitionCustomCommandParser::DoAddRuleL(TMMFMessage& aMessage)
sl@0
   248
	{
sl@0
   249
	TSrsAddRulePckg pckg;
sl@0
   250
	aMessage.ReadData1FromClientL(pckg);
sl@0
   251
	iImplementor.MSrAddRuleL(pckg().iGrammarID, pckg().iLexiconID, pckg().iPronunciationID, *pckg().iRuleID);
sl@0
   252
	}
sl@0
   253
sl@0
   254
void CSpeechRecognitionCustomCommandParser::DoCancel()
sl@0
   255
	{
sl@0
   256
	iImplementor.MSrCancel();
sl@0
   257
	}
sl@0
   258
sl@0
   259
void CSpeechRecognitionCustomCommandParser::DoCommitChangesL()
sl@0
   260
	{
sl@0
   261
	iImplementor.MSrCommitChangesL();
sl@0
   262
	}
sl@0
   263
sl@0
   264
void CSpeechRecognitionCustomCommandParser::DoCreateGrammarL(TMMFMessage& aMessage)
sl@0
   265
	{
sl@0
   266
	TSrsGrammarIDPtrPckg pckg;
sl@0
   267
	aMessage.ReadData1FromClientL(pckg);
sl@0
   268
	iImplementor.MSrCreateGrammarL(*pckg());
sl@0
   269
	}
sl@0
   270
sl@0
   271
void CSpeechRecognitionCustomCommandParser::DoCreateLexiconL(TMMFMessage& aMessage)
sl@0
   272
	{
sl@0
   273
	TSrsLexiconIDPtrPckg pckg;
sl@0
   274
	aMessage.ReadData1FromClientL(pckg);
sl@0
   275
	iImplementor.MSrCreateLexiconL(*pckg());
sl@0
   276
	}
sl@0
   277
sl@0
   278
void CSpeechRecognitionCustomCommandParser::DoCreateModelBankL(TMMFMessage& aMessage)
sl@0
   279
	{
sl@0
   280
	TSrsModelBankIDPtrPckg pckg;
sl@0
   281
	aMessage.ReadData1FromClientL(pckg);
sl@0
   282
	iImplementor.MSrCreateModelBankL(*pckg());
sl@0
   283
	}
sl@0
   284
sl@0
   285
void CSpeechRecognitionCustomCommandParser::DoEndRecSessionL()
sl@0
   286
	{
sl@0
   287
	iImplementor.MSrEndRecSessionL();
sl@0
   288
	}
sl@0
   289
sl@0
   290
void CSpeechRecognitionCustomCommandParser::DoGetAllModelIDsL(TMMFMessage& aMessage)
sl@0
   291
	{
sl@0
   292
	TSrsModelBankIDPckg pckgModelBank;
sl@0
   293
	iModelIDs.Reset();
sl@0
   294
	aMessage.ReadData1FromClientL(pckgModelBank);
sl@0
   295
	iImplementor.MSrGetAllModelIDsL(pckgModelBank(), iModelIDs);
sl@0
   296
	}
sl@0
   297
sl@0
   298
void CSpeechRecognitionCustomCommandParser::DoGetAllPronunciationIDsL(TMMFMessage& aMessage)
sl@0
   299
	{
sl@0
   300
	TSrsLexiconIDPckg pckgLexicon;
sl@0
   301
	iPronunciationIDs.Reset();
sl@0
   302
	aMessage.ReadData1FromClientL(pckgLexicon);
sl@0
   303
	iImplementor.MSrGetAllPronunciationIDsL(pckgLexicon(), iPronunciationIDs);
sl@0
   304
	}
sl@0
   305
sl@0
   306
void CSpeechRecognitionCustomCommandParser::DoGetAllRuleIDsL(TMMFMessage& aMessage)
sl@0
   307
	{
sl@0
   308
	TSrsGrammarIDPckg pckgGrammar;
sl@0
   309
	iRuleIDs.Reset();
sl@0
   310
	aMessage.ReadData1FromClientL(pckgGrammar);
sl@0
   311
	iImplementor.MSrGetAllRuleIDsL(pckgGrammar(), iRuleIDs);
sl@0
   312
	}
sl@0
   313
sl@0
   314
void CSpeechRecognitionCustomCommandParser::DoGetAllModelBankIDsL()
sl@0
   315
	{
sl@0
   316
	iModelBankIDs.Reset();
sl@0
   317
	iImplementor.MSrGetAllModelBankIDsL(iModelBankIDs);
sl@0
   318
	}
sl@0
   319
sl@0
   320
void CSpeechRecognitionCustomCommandParser::DoGetAllLexiconIDsL()
sl@0
   321
	{
sl@0
   322
	iLexiconIDs.Reset();
sl@0
   323
	iImplementor.MSrGetAllLexiconIDsL(iLexiconIDs);
sl@0
   324
	}
sl@0
   325
sl@0
   326
void CSpeechRecognitionCustomCommandParser::DoGetAllGrammarIDsL()
sl@0
   327
	{
sl@0
   328
	iGrammarIDs.Reset();
sl@0
   329
	iImplementor.MSrGetAllGrammarIDsL(iGrammarIDs);
sl@0
   330
	}
sl@0
   331
	
sl@0
   332
	
sl@0
   333
void CSpeechRecognitionCustomCommandParser::DoGetAllClientModelBankIDsL()
sl@0
   334
	{
sl@0
   335
	iModelBankIDs.Reset();
sl@0
   336
	iImplementor.MSrGetAllClientModelBankIDsL(iModelBankIDs);
sl@0
   337
	}
sl@0
   338
sl@0
   339
void CSpeechRecognitionCustomCommandParser::DoGetAllClientLexiconIDsL()
sl@0
   340
	{
sl@0
   341
	iLexiconIDs.Reset();
sl@0
   342
	iImplementor.MSrGetAllClientLexiconIDsL(iLexiconIDs);
sl@0
   343
	}
sl@0
   344
sl@0
   345
void CSpeechRecognitionCustomCommandParser::DoGetAllClientGrammarIDsL()
sl@0
   346
	{
sl@0
   347
	iGrammarIDs.Reset();
sl@0
   348
	iImplementor.MSrGetAllClientGrammarIDsL(iGrammarIDs);
sl@0
   349
	}
sl@0
   350
sl@0
   351
sl@0
   352
void CSpeechRecognitionCustomCommandParser::DoGetAvailableStorageL(TMMFMessage& aMessage)
sl@0
   353
	{
sl@0
   354
	TSrsIntPtrPckg pckg;
sl@0
   355
	aMessage.ReadData1FromClientL(pckg);
sl@0
   356
	iImplementor.MSrGetAvailableStorageL(*pckg());
sl@0
   357
	}
sl@0
   358
sl@0
   359
sl@0
   360
void CSpeechRecognitionCustomCommandParser::DoGetModelCountL(TMMFMessage& aMessage)
sl@0
   361
	{
sl@0
   362
	TSrsModelBankIDPckg pckgModelBank;
sl@0
   363
	TSrsIntPtrPckg pckgResult;
sl@0
   364
	aMessage.ReadData1FromClientL(pckgModelBank);
sl@0
   365
	aMessage.ReadData2FromClientL(pckgResult);
sl@0
   366
	iImplementor.MSrGetModelCountL(pckgModelBank(),*pckgResult());
sl@0
   367
	}
sl@0
   368
sl@0
   369
void CSpeechRecognitionCustomCommandParser::DoGetRuleValidityL(TMMFMessage& aMessage)
sl@0
   370
	{
sl@0
   371
	TSrsRuleValidityPckg pckg;
sl@0
   372
	aMessage.ReadData1FromClientL(pckg);
sl@0
   373
	iImplementor.MSrGetRuleValidityL(pckg().iGrammarID, pckg().iRuleID, *pckg().iRuleValid);
sl@0
   374
	}
sl@0
   375
sl@0
   376
void CSpeechRecognitionCustomCommandParser::DoGetUtteranceDurationL(TMMFMessage& aMessage)
sl@0
   377
	{
sl@0
   378
	TSrsGetUtteranceDurationPckg pckg;
sl@0
   379
	aMessage.ReadData1FromClientL(pckg);
sl@0
   380
	iImplementor.MSrGetUtteranceDurationL(pckg().iModelBankID, pckg().iModelID, *pckg().iDuration);
sl@0
   381
	}
sl@0
   382
sl@0
   383
void CSpeechRecognitionCustomCommandParser::DoLoadGrammarL(TMMFMessage& aMessage)
sl@0
   384
	{
sl@0
   385
	TSrsGrammarIDPckg pckg;
sl@0
   386
	aMessage.ReadData1FromClientL(pckg);
sl@0
   387
	iImplementor.MSrLoadGrammarL(pckg());
sl@0
   388
	}
sl@0
   389
sl@0
   390
void CSpeechRecognitionCustomCommandParser::DoLoadLexiconL(TMMFMessage& aMessage)
sl@0
   391
	{
sl@0
   392
	TSrsLexiconIDPckg pckg;
sl@0
   393
	aMessage.ReadData1FromClientL(pckg);
sl@0
   394
	iImplementor.MSrLoadLexiconL(pckg());
sl@0
   395
	}
sl@0
   396
sl@0
   397
void CSpeechRecognitionCustomCommandParser::DoLoadModelsL(TMMFMessage& aMessage)
sl@0
   398
	{
sl@0
   399
	TSrsModelBankIDPckg pckg;
sl@0
   400
	aMessage.ReadData1FromClientL(pckg);
sl@0
   401
	iImplementor.MSrLoadModelsL(pckg());
sl@0
   402
	}
sl@0
   403
sl@0
   404
void CSpeechRecognitionCustomCommandParser::DoPlayUtteranceL(TMMFMessage& aMessage)
sl@0
   405
	{
sl@0
   406
	TSrsPlayUtterancePckg pckg;
sl@0
   407
	aMessage.ReadData1FromClientL(pckg);
sl@0
   408
	iImplementor.MSrPlayUtteranceL(pckg().iModelBankID, pckg().iModelID);
sl@0
   409
	}
sl@0
   410
	
sl@0
   411
void CSpeechRecognitionCustomCommandParser::DoSetClientUidL(TMMFMessage& aMessage)
sl@0
   412
	{
sl@0
   413
	TSrsUidPckg pckg;
sl@0
   414
	aMessage.ReadData1FromClientL(pckg);
sl@0
   415
	iImplementor.MSrSetClientUid(pckg());
sl@0
   416
	}
sl@0
   417
sl@0
   418
sl@0
   419
void CSpeechRecognitionCustomCommandParser::DoRecognizeL(TMMFMessage& aMessage)
sl@0
   420
	{
sl@0
   421
	if (iResultSet)
sl@0
   422
		User::Leave(KErrInUse);
sl@0
   423
sl@0
   424
	TInt size;
sl@0
   425
	size = User::LeaveIfError(aMessage.SizeOfData1FromClient());
sl@0
   426
	HBufC8* dataBuffer = HBufC8::NewLC(size);
sl@0
   427
	TPtr8 buf = dataBuffer->Des();
sl@0
   428
	aMessage.ReadData1FromClientL(buf);
sl@0
   429
	RDesReadStream stream(buf);
sl@0
   430
	CleanupClosePushL(stream);
sl@0
   431
	iResultSet = CSDClientResultSet::NewL();
sl@0
   432
	TInt err = KErrNone;
sl@0
   433
	TRAP(err, iResultSet->InternalizeL(stream));
sl@0
   434
	if (err == KErrNone)
sl@0
   435
		{
sl@0
   436
		TRAP(err, iImplementor.MSrRecognizeL(*iResultSet));
sl@0
   437
		}
sl@0
   438
	if (err!=KErrNone)
sl@0
   439
		{
sl@0
   440
		delete iResultSet;
sl@0
   441
		iResultSet = NULL;
sl@0
   442
		User::Leave(err);
sl@0
   443
		}
sl@0
   444
	CleanupStack::PopAndDestroy(2, dataBuffer);//dataBuffer, stream
sl@0
   445
	}
sl@0
   446
sl@0
   447
void CSpeechRecognitionCustomCommandParser::DoRecordL(TMMFMessage& aMessage)
sl@0
   448
	{
sl@0
   449
	TSrsTimeIntervalMicroSeconds32Pckg pckg;
sl@0
   450
	aMessage.ReadData1FromClientL(pckg);
sl@0
   451
	iImplementor.MSrRecordL(pckg());
sl@0
   452
	}
sl@0
   453
sl@0
   454
void CSpeechRecognitionCustomCommandParser::DoRemoveGrammarL(TMMFMessage& aMessage)
sl@0
   455
	{
sl@0
   456
	TSrsGrammarIDPckg pckg;
sl@0
   457
	aMessage.ReadData1FromClientL(pckg);
sl@0
   458
	iImplementor.MSrRemoveGrammarL(pckg());
sl@0
   459
	}
sl@0
   460
sl@0
   461
void CSpeechRecognitionCustomCommandParser::DoRemoveLexiconL(TMMFMessage& aMessage)
sl@0
   462
	{
sl@0
   463
	TSrsLexiconIDPckg pckg;
sl@0
   464
	aMessage.ReadData1FromClientL(pckg);
sl@0
   465
	iImplementor.MSrRemoveLexiconL(pckg());
sl@0
   466
	}
sl@0
   467
sl@0
   468
void CSpeechRecognitionCustomCommandParser::DoRemoveModelBankL(TMMFMessage& aMessage)
sl@0
   469
	{
sl@0
   470
	TSrsModelBankIDPckg pckg;
sl@0
   471
	aMessage.ReadData1FromClientL(pckg);
sl@0
   472
	iImplementor.MSrRemoveModelBankL(pckg());
sl@0
   473
	}
sl@0
   474
sl@0
   475
void CSpeechRecognitionCustomCommandParser::DoRemoveModelL(TMMFMessage& aMessage)
sl@0
   476
	{
sl@0
   477
	TSrsModelBankIDPckg pckgModelBankID;
sl@0
   478
	TSrsModelIDPckg pckgModelID;
sl@0
   479
	aMessage.ReadData1FromClientL(pckgModelBankID);
sl@0
   480
	aMessage.ReadData2FromClientL(pckgModelID);
sl@0
   481
	iImplementor.MSrRemoveModelL(pckgModelBankID(), pckgModelID());
sl@0
   482
	}
sl@0
   483
sl@0
   484
void CSpeechRecognitionCustomCommandParser::DoRemovePronunciationL(TMMFMessage& aMessage)
sl@0
   485
	{
sl@0
   486
	TSrsLexiconIDPckg pckgLexicon;
sl@0
   487
	TSrsPronunciationIDPckg pckgPronunciation;
sl@0
   488
	aMessage.ReadData1FromClientL(pckgLexicon);
sl@0
   489
	aMessage.ReadData2FromClientL(pckgPronunciation);
sl@0
   490
	iImplementor.MSrRemovePronunciationL(pckgLexicon(), pckgPronunciation());
sl@0
   491
	}
sl@0
   492
sl@0
   493
void CSpeechRecognitionCustomCommandParser::DoRemoveRuleL(TMMFMessage& aMessage)
sl@0
   494
	{
sl@0
   495
	TSrsGrammarIDPckg pckgGrammar;
sl@0
   496
	TSrsRuleIDPckg pckgRule;
sl@0
   497
	aMessage.ReadData1FromClientL(pckgGrammar);
sl@0
   498
	aMessage.ReadData2FromClientL(pckgRule);
sl@0
   499
	iImplementor.MSrRemoveRuleL(pckgGrammar(), pckgRule());
sl@0
   500
	}
sl@0
   501
sl@0
   502
void CSpeechRecognitionCustomCommandParser::DoStartRecSessionL(TMMFMessage& aMessage)
sl@0
   503
	{
sl@0
   504
	TSrsRecognitionModePckg pckg;
sl@0
   505
	aMessage.ReadData1FromClientL(pckg);
sl@0
   506
	iImplementor.MSrStartRecSessionL(pckg());
sl@0
   507
	}
sl@0
   508
sl@0
   509
void CSpeechRecognitionCustomCommandParser::DoTrainL(TMMFMessage& aMessage)
sl@0
   510
	{
sl@0
   511
	TSrsModelBankIDPckg pckgModelBankID;
sl@0
   512
	TSrsModelIDPtrPckg pckgModelIDPtr;
sl@0
   513
	aMessage.ReadData1FromClientL(pckgModelBankID);
sl@0
   514
	aMessage.ReadData2FromClientL(pckgModelIDPtr);
sl@0
   515
	iImplementor.MSrTrainL(pckgModelBankID(),*pckgModelIDPtr());
sl@0
   516
	}
sl@0
   517
sl@0
   518
void CSpeechRecognitionCustomCommandParser::DoUnloadRuleL(TMMFMessage& aMessage)
sl@0
   519
	{
sl@0
   520
	TSrsGrammarIDPckg pckgGrammar;
sl@0
   521
	TSrsRuleIDPckg pckgRule;
sl@0
   522
	aMessage.ReadData1FromClientL(pckgGrammar);
sl@0
   523
	aMessage.ReadData2FromClientL(pckgRule);
sl@0
   524
	iImplementor.MSrUnloadRuleL(pckgGrammar(), pckgRule());
sl@0
   525
	}
sl@0
   526
sl@0
   527
void CSpeechRecognitionCustomCommandParser::DoLoadEngineParametersL(TMMFMessage& aMessage)
sl@0
   528
	{
sl@0
   529
	RArray<TInt> parameters;
sl@0
   530
	RArray<TInt> values;
sl@0
   531
	CleanupClosePushL(parameters);
sl@0
   532
	CleanupClosePushL(values);
sl@0
   533
	DoExtractIntArrayFromData1L(aMessage, parameters);
sl@0
   534
	DoExtractIntArrayFromData2L(aMessage, values);
sl@0
   535
	iImplementor.MSrLoadEngineParametersL(parameters,values);
sl@0
   536
	CleanupStack::PopAndDestroy(2, &parameters); // parameters, values
sl@0
   537
	}
sl@0
   538
	
sl@0
   539
void CSpeechRecognitionCustomCommandParser::DoGetEnginePropertiesL(TMMFMessage& aMessage)
sl@0
   540
	{
sl@0
   541
	RArray<TInt> propertyIDs;
sl@0
   542
	RArray<TInt> propertyValues;
sl@0
   543
	CleanupClosePushL(propertyIDs);
sl@0
   544
	CleanupClosePushL(propertyValues);
sl@0
   545
	DoExtractIntArrayFromData1L(aMessage, propertyIDs);
sl@0
   546
	
sl@0
   547
	iImplementor.MSrGetEnginePropertiesL(propertyIDs,propertyValues);
sl@0
   548
	// the custom command is aware of the size of the result, so it can copy the data back directly
sl@0
   549
	DoCopyIntArrayL(aMessage, propertyValues);	
sl@0
   550
	CleanupStack::PopAndDestroy(2, &propertyIDs); // property IDs, property values
sl@0
   551
	}
sl@0
   552
sl@0
   553
	
sl@0
   554
void CSpeechRecognitionCustomCommandParser::DoCopyPronunciationIDArrayL(TMMFMessage& aMessage)
sl@0
   555
	{
sl@0
   556
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   557
	CleanupStack::PushL(dataBuffer);
sl@0
   558
	RBufWriteStream stream;
sl@0
   559
	stream.Open(*dataBuffer);
sl@0
   560
	CleanupClosePushL(stream);
sl@0
   561
	for (TInt i=0;i<iPronunciationIDs.Count();i++)
sl@0
   562
		stream.WriteUint32L(iPronunciationIDs[i]);
sl@0
   563
sl@0
   564
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   565
	
sl@0
   566
	iPronunciationIDs.Close();
sl@0
   567
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   568
	}
sl@0
   569
void CSpeechRecognitionCustomCommandParser::DoCopyModelIDArrayL(TMMFMessage& aMessage)
sl@0
   570
	{
sl@0
   571
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   572
	CleanupStack::PushL(dataBuffer);
sl@0
   573
	RBufWriteStream stream;
sl@0
   574
	stream.Open(*dataBuffer);
sl@0
   575
	CleanupClosePushL(stream);
sl@0
   576
	for (TInt i=0;i<iModelIDs.Count();i++)
sl@0
   577
		stream.WriteUint32L(iModelIDs[i]);
sl@0
   578
sl@0
   579
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   580
	
sl@0
   581
	iModelIDs.Close();
sl@0
   582
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   583
	}
sl@0
   584
sl@0
   585
void CSpeechRecognitionCustomCommandParser::DoCopyRuleIDArrayL(TMMFMessage& aMessage)
sl@0
   586
	{
sl@0
   587
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   588
	CleanupStack::PushL(dataBuffer);
sl@0
   589
	RBufWriteStream stream;
sl@0
   590
	stream.Open(*dataBuffer);
sl@0
   591
	CleanupClosePushL(stream);
sl@0
   592
	for (TInt i=0;i<iRuleIDs.Count();i++)
sl@0
   593
		stream.WriteUint32L(iRuleIDs[i]);
sl@0
   594
sl@0
   595
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   596
	
sl@0
   597
	iRuleIDs.Close();
sl@0
   598
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   599
	}
sl@0
   600
sl@0
   601
//------------------------------------------------------------------------------------------------------------------
sl@0
   602
sl@0
   603
void CSpeechRecognitionCustomCommandParser::DoCopyLexiconIDArrayL(TMMFMessage& aMessage)
sl@0
   604
	{
sl@0
   605
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   606
	CleanupStack::PushL(dataBuffer);
sl@0
   607
	RBufWriteStream stream;
sl@0
   608
	stream.Open(*dataBuffer);
sl@0
   609
	CleanupClosePushL(stream);
sl@0
   610
	for (TInt i=0;i<iLexiconIDs.Count();i++)
sl@0
   611
		stream.WriteUint32L(iLexiconIDs[i]);
sl@0
   612
sl@0
   613
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   614
	
sl@0
   615
	iLexiconIDs.Close();
sl@0
   616
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   617
	}
sl@0
   618
void CSpeechRecognitionCustomCommandParser::DoCopyModelBankIDArrayL(TMMFMessage& aMessage)
sl@0
   619
	{
sl@0
   620
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   621
	CleanupStack::PushL(dataBuffer);
sl@0
   622
	RBufWriteStream stream;
sl@0
   623
	stream.Open(*dataBuffer);
sl@0
   624
	CleanupClosePushL(stream);
sl@0
   625
	for (TInt i=0;i<iModelBankIDs.Count();i++)
sl@0
   626
		stream.WriteUint32L(iModelBankIDs[i]);
sl@0
   627
sl@0
   628
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   629
	
sl@0
   630
	iModelBankIDs.Close();
sl@0
   631
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   632
	}
sl@0
   633
sl@0
   634
void CSpeechRecognitionCustomCommandParser::DoCopyGrammarIDArrayL(TMMFMessage& aMessage)
sl@0
   635
	{
sl@0
   636
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   637
	CleanupStack::PushL(dataBuffer);
sl@0
   638
	RBufWriteStream stream;
sl@0
   639
	stream.Open(*dataBuffer);
sl@0
   640
	CleanupClosePushL(stream);
sl@0
   641
	for (TInt i=0;i<iGrammarIDs.Count();i++)
sl@0
   642
		stream.WriteUint32L(iGrammarIDs[i]);
sl@0
   643
sl@0
   644
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   645
	
sl@0
   646
	iGrammarIDs.Close();
sl@0
   647
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   648
	}
sl@0
   649
sl@0
   650
sl@0
   651
//--------------------------------------------------------------------------------------------------------------------
sl@0
   652
sl@0
   653
	
sl@0
   654
void CSpeechRecognitionCustomCommandParser::DoCopyIntArrayL(TMMFMessage& aMessage, const RArray<TInt>& aArray)
sl@0
   655
	{
sl@0
   656
	CBufFlat* dataBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   657
	CleanupStack::PushL(dataBuffer);
sl@0
   658
	RBufWriteStream stream;
sl@0
   659
	stream.Open(*dataBuffer);
sl@0
   660
	CleanupClosePushL(stream);
sl@0
   661
	for (TInt i=0;i<aArray.Count();i++)
sl@0
   662
		stream.WriteUint32L(aArray[i]);
sl@0
   663
sl@0
   664
	aMessage.WriteDataToClientL(dataBuffer->Ptr(0));
sl@0
   665
	CleanupStack::PopAndDestroy(2, dataBuffer); //dataBuffer, stream
sl@0
   666
	}
sl@0
   667
	
sl@0
   668
void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData1L(TMMFMessage& aMessage, RArray<TInt>& aArray)
sl@0
   669
	{
sl@0
   670
	TInt size = User::LeaveIfError(aMessage.SizeOfData1FromClient());
sl@0
   671
	HBufC8* buf = HBufC8::NewL(size);
sl@0
   672
	CleanupStack::PushL(buf);
sl@0
   673
	TPtr8 ptr = buf->Des();
sl@0
   674
	aMessage.ReadData1FromClientL(ptr);
sl@0
   675
	DoExtractIntArrayL(ptr,aArray);
sl@0
   676
	CleanupStack::PopAndDestroy(buf);
sl@0
   677
	}
sl@0
   678
	
sl@0
   679
void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayFromData2L(TMMFMessage& aMessage, RArray<TInt>& aArray)
sl@0
   680
	{
sl@0
   681
	TInt size = User::LeaveIfError(aMessage.SizeOfData2FromClient());
sl@0
   682
	HBufC8* buf = HBufC8::NewL(size);
sl@0
   683
	CleanupStack::PushL(buf);
sl@0
   684
	TPtr8 ptr = buf->Des();
sl@0
   685
	aMessage.ReadData2FromClientL(ptr);
sl@0
   686
	DoExtractIntArrayL(ptr,aArray);
sl@0
   687
	CleanupStack::PopAndDestroy(buf);
sl@0
   688
	}
sl@0
   689
sl@0
   690
	
sl@0
   691
void CSpeechRecognitionCustomCommandParser::DoExtractIntArrayL(TDes8& aDescriptor, RArray<TInt>& aArray)
sl@0
   692
	{
sl@0
   693
	RDesReadStream stream(aDescriptor);
sl@0
   694
	CleanupClosePushL(stream);
sl@0
   695
	
sl@0
   696
	TInt numberElements;
sl@0
   697
	numberElements = stream.ReadInt32L();
sl@0
   698
sl@0
   699
	for (TInt i=0; i<numberElements; i++)
sl@0
   700
		{
sl@0
   701
		User::LeaveIfError(aArray.Append(stream.ReadInt32L()));
sl@0
   702
		}
sl@0
   703
	CleanupStack::PopAndDestroy(&stream); //stream
sl@0
   704
	}
sl@0
   705
sl@0
   706
	
sl@0
   707
void CSpeechRecognitionCustomCommandParser::DoExternalizeResultSetL()
sl@0
   708
	{
sl@0
   709
	ASSERT(iResultSet);
sl@0
   710
	iResultCopyBuffer = CBufFlat::NewL(KExpandSize);
sl@0
   711
	RBufWriteStream stream;
sl@0
   712
	stream.Open(*iResultCopyBuffer);
sl@0
   713
	CleanupClosePushL(stream);
sl@0
   714
	iResultSet->ExternalizeL(stream);
sl@0
   715
	delete iResultSet;
sl@0
   716
	iResultSet = NULL;
sl@0
   717
	CleanupStack::PopAndDestroy(&stream); //stream
sl@0
   718
	}
sl@0
   719
void CSpeechRecognitionCustomCommandParser::DoCopyResultSetL(TMMFMessage& aMessage)
sl@0
   720
	{
sl@0
   721
	aMessage.WriteDataToClientL(iResultCopyBuffer->Ptr(0));
sl@0
   722
	delete iResultCopyBuffer;
sl@0
   723
	iResultCopyBuffer = NULL;
sl@0
   724
	}