|
1 /* |
|
2 * Copyright (c) 2004-2006 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: CNssContextSrsPortal provides SRS related functionalities for |
|
15 * context processing. A context is saved in the SRS DB by creating |
|
16 * model bank, lexicon, and grammar into the SRS. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef NSSVASCCONTEXTSRSPORTAL_H |
|
22 #define NSSVASCCONTEXTSRSPORTAL_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "nssvassiutilitywrapper.h" |
|
26 #include <nsssispeechrecognitionutilityobserver.h> |
|
27 #include "nssvasccontext.h" |
|
28 #include "nssvasmcoresrsdbeventhandler.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CNssContext; |
|
32 |
|
33 //FORWARD DECLARATION |
|
34 class MNssSpeechRecognitionEvent; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * CNssContextSrsPortal is the interface to SRS. |
|
40 * @lib NssVASApi.lib |
|
41 * @since 2.8 |
|
42 */ |
|
43 class CNssContextSrsPortal: public CBase, public MSISpeechRecognitionUtilityObserver |
|
44 { |
|
45 |
|
46 public: |
|
47 |
|
48 // ENUMERATIONS |
|
49 enum TNssTerminationState |
|
50 { |
|
51 EVASTERMINATION_PENDING, |
|
52 EVASTERMINATION_NOT_PENDING |
|
53 }; |
|
54 |
|
55 public: |
|
56 |
|
57 /** |
|
58 * C++ constructor |
|
59 */ |
|
60 CNssContextSrsPortal(); |
|
61 |
|
62 /** |
|
63 * C++ destructor |
|
64 */ |
|
65 ~CNssContextSrsPortal(); |
|
66 |
|
67 public: // from MSpeechRecognitionEvent |
|
68 |
|
69 /** |
|
70 * overriding interface from MSpeechRecognitionUtilityObserver |
|
71 * @since 2.0 |
|
72 */ |
|
73 void MsruoEvent(TUid aEvent, TInt aResult); |
|
74 |
|
75 |
|
76 public: // for inter component use |
|
77 |
|
78 /** |
|
79 * Save a context to SRS. Asyncronous function. |
|
80 * @since 2.0 |
|
81 * @param aContext - context to be saved |
|
82 * @param aSrsDBEventHandler - call back address |
|
83 * @return none |
|
84 */ |
|
85 void BeginSaveContextL(CNssContext* aContext, MNssCoreSrsDBEventHandler* aSrsDBEventHandler); |
|
86 |
|
87 /** |
|
88 * Delete a context from SRS. Asyncronous function |
|
89 * @since 2.0 |
|
90 * @param aContext - context to be deleted |
|
91 * @param aSrsDBEventHandler - call back address |
|
92 * @return none |
|
93 */ |
|
94 void BeginDeleteContextL(CNssContext* aContext, MNssCoreSrsDBEventHandler* aSrsDBEventHandler); |
|
95 |
|
96 /** |
|
97 * Reset speaker adapted models: Remove a model bank and create a new one. |
|
98 * @since 2.8 |
|
99 * @param |
|
100 * @return none |
|
101 */ |
|
102 void BeginResetModelsL( TSIModelBankID aAdaptedModels, |
|
103 TSIModelBankID& aNewModels, MNssCoreSrsDBEventHandler* aSrsDBEventHandler ); |
|
104 |
|
105 /** |
|
106 * Commit a context from SRS. Syncronous function |
|
107 * @since 2.0 |
|
108 * @param |
|
109 * @return error code |
|
110 */ |
|
111 TInt CommitSaveContext(); |
|
112 |
|
113 /** |
|
114 * Don't commit a context from SRS. Syncronous function |
|
115 * @since 2.8 |
|
116 * @param |
|
117 * @return error code |
|
118 */ |
|
119 TInt RollbackSaveContext(); |
|
120 |
|
121 /** |
|
122 * Register context to the portal |
|
123 * @since 2.0 |
|
124 * @param |
|
125 * @return |
|
126 */ |
|
127 void Register(); |
|
128 |
|
129 /**Deregister context from portal |
|
130 * @since 2.0 |
|
131 * @param |
|
132 * @return |
|
133 */ |
|
134 void Deregister(); |
|
135 |
|
136 /** |
|
137 * Set portal state to termination pending, or not pending |
|
138 * @since 2.0 |
|
139 * @param aState - termination pending, or not. |
|
140 * @return |
|
141 */ |
|
142 void SetTerminationState(TNssTerminationState aState); |
|
143 |
|
144 /** |
|
145 * Returns context count, number of contexts registered with the portal |
|
146 * @since 2.0 |
|
147 * @param |
|
148 * @return count |
|
149 */ |
|
150 TInt ContextCount(); |
|
151 |
|
152 /** |
|
153 * Clean up the SRS after the SRS operation fail |
|
154 * @since 2.0 |
|
155 * @param |
|
156 * @return |
|
157 */ |
|
158 void CleanUp(TInt aResult); |
|
159 |
|
160 /** |
|
161 * Delete the SRS |
|
162 * @since 2.0 |
|
163 * @param |
|
164 * @return |
|
165 */ |
|
166 void DeleteSRS(); |
|
167 |
|
168 /** |
|
169 * Method to process the SRS DB error |
|
170 * @since 2.0 |
|
171 * @param aResult - the result value from SRS to indicate an error |
|
172 * @return - an error code to identify the DB error |
|
173 */ |
|
174 MNssCoreSrsDBEventHandler::TNssSrsDBResult DoSrsDBResult(TInt aResult); |
|
175 |
|
176 |
|
177 |
|
178 private: |
|
179 |
|
180 // a count of the number of contexts registered to the portal |
|
181 TInt iContextCount; |
|
182 |
|
183 // state denoting if the builder is destroyed or not |
|
184 TNssTerminationState iTerminationState; |
|
185 |
|
186 // instance of the SRS utility class |
|
187 CNssSiUtilityWrapper* iSpeechRecognitionUtility; |
|
188 |
|
189 // Pointer to SRS DB Event Handler object. |
|
190 MNssCoreSrsDBEventHandler* iSrsDBEventHandler; |
|
191 |
|
192 // model bank id, used internally for error handling |
|
193 TSIModelBankID iModelBankId; |
|
194 |
|
195 // lexicon id, used internally for error handling |
|
196 TSILexiconID iLexiconId; |
|
197 |
|
198 // grammar id, used internally for error handling |
|
199 TSIGrammarID iGrammarId; |
|
200 |
|
201 // local pointer to context, used internally for error handling |
|
202 CNssContext *iContext; |
|
203 |
|
204 // flag for recovery during error cases |
|
205 TBool iRecovery; |
|
206 |
|
207 // when resetting speaker adaptation, the new model bank ID is stored here. |
|
208 TSIModelBankID* iResetModelBankId; |
|
209 |
|
210 // states required for EDiskFull errors from SRS |
|
211 enum TState |
|
212 { |
|
213 EVASNone, |
|
214 EVASCreateModelBank, |
|
215 EVASCreateLexicon, |
|
216 EVASCreateGrammar, |
|
217 EVASRemoveModelBank, |
|
218 EVASRemoveLexicon, |
|
219 EVASRemoveGrammar, |
|
220 EVASResetRemoveModelBank, |
|
221 EVASResetCreateModelBank, |
|
222 EVasWaitForCommitChanges |
|
223 } iState; |
|
224 }; |
|
225 |
|
226 |
|
227 #endif // NSSVASCCONTEXTSRSPORTAL_H |
|
228 |
|
229 // End of File |