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: CContextManager provides context processing for the client. CContextManager |
|
15 * implements the MNssContextMgr interface, and also provides additional methods for |
|
16 * use by internal VAS components. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef NSSVASCCONTEXTMGR_H |
|
22 #define NSSVASCCONTEXTMGR_H |
|
23 |
|
24 // INCLUDES |
|
25 // |
|
26 #include <e32std.h> |
|
27 #include <e32base.h> |
|
28 |
|
29 #include "nssvasmcontextmgr.h" |
|
30 #include "nssvasmcontext.h" |
|
31 #include "nssvasmgetcontextclient.h" |
|
32 #include "nssvasmdeletecontextclient.h" |
|
33 #include "nssvasmsavecontextclient.h" |
|
34 #include "nssvasmintercompcontextmgrclient.h" |
|
35 #include "nssvasmvasdatabaseclient.h" |
|
36 #include "nssvasmcoresrsdbeventhandler.h" |
|
37 #include "nssvascoreconstant.h" |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class CNssContextBuilder; |
|
41 class CNssVASDatabase; |
|
42 class MNssResetFactoryModelsClient; |
|
43 |
|
44 // CLASS DECLARATIONS |
|
45 /** |
|
46 * CContextMgr is the implementation class for MNssContextMgr interface. |
|
47 * @lib NssVASApi.lib |
|
48 * @since 2.8 |
|
49 */ |
|
50 class CNssContextMgr : |
|
51 public CActive, |
|
52 public MNssContextMgr, |
|
53 public MNssVASDatabaseClient, |
|
54 public MNssCoreSrsDBEventHandler |
|
55 { |
|
56 public: |
|
57 |
|
58 enum TNssCallBackState |
|
59 { |
|
60 ENone, |
|
61 EGetContextClientGetContext, |
|
62 EGetContextClientGetContextList, |
|
63 EDeleteContextClient, |
|
64 ESaveContextClient, |
|
65 ESaveClientDataClient, |
|
66 EInterCompContextMgrClientGetContext, |
|
67 EInterCompContextMgrClientGetContextList, |
|
68 EInterCompContextMgrClientGetGlobalContexts |
|
69 }; |
|
70 |
|
71 /** |
|
72 * |
|
73 * Destructor. |
|
74 */ |
|
75 ~CNssContextMgr(); |
|
76 |
|
77 /** |
|
78 * 2 Phase construction |
|
79 * @param aVASDatabase - Reference to the database. |
|
80 * @return void |
|
81 */ |
|
82 static CNssContextMgr* NewL(CNssVASDatabase* aVASDatabase); |
|
83 |
|
84 /** |
|
85 * 2 Phase construction |
|
86 * @param aVASDatabase - Reference to the database. |
|
87 * @return void |
|
88 */ |
|
89 static CNssContextMgr* NewLC(CNssVASDatabase* aVASDatabase); |
|
90 |
|
91 |
|
92 /** |
|
93 * Creates an empty context object |
|
94 * @since 2.8 |
|
95 * @param void |
|
96 * @return A reference to the context object |
|
97 */ |
|
98 MNssContext* CreateContextL(); |
|
99 |
|
100 |
|
101 /** |
|
102 * GetContext is called to retrieve a context from the VAS DB. |
|
103 * This method is asynchronous. A call back will be made to |
|
104 * either GetContextCompleted() or GetContextFailed() as |
|
105 * defined in the MNssGetContextClient interface. It also returns an |
|
106 * error code validating success of call to VAS DB. |
|
107 * @since 2.8 |
|
108 * |
|
109 * @param aContextClient - call back address |
|
110 * @param aName - name of context to retreive |
|
111 * @return - syncronous error code from function return |
|
112 */ |
|
113 TInt GetContext(MNssGetContextClient* aContextClient,const TDesC& aName); |
|
114 |
|
115 /** |
|
116 * GetContextList is called to retrieve a context list from the VAS DB. |
|
117 * This method is asynchronous. A call back will be made to |
|
118 * either GetContextListCompleted() or GetContextFailed() as |
|
119 * defined in the MNssGetContextClient interface. It also returns an |
|
120 * error code validating success of call to VAS DB. |
|
121 * @since 2.8 |
|
122 * |
|
123 * @param aContextClient - call back address |
|
124 * @param |
|
125 * @return - syncronous error code from function return |
|
126 */ |
|
127 TInt GetContextList(MNssGetContextClient* aContextClient); |
|
128 |
|
129 /** |
|
130 * DeleteContext is called to remove a context from the VAS DB. |
|
131 * This method is asynchronous. A call back will be made to |
|
132 * either DeleteContextCompleted() or DeleteContextFailed() as |
|
133 * defined in the MNssDeleteContextClient interface. It also returns an |
|
134 * error code validating success of call to VAS DB. |
|
135 * @since 2.8 |
|
136 * |
|
137 * @param aContextClient - call back address |
|
138 * @param aContext - context object to delete |
|
139 * @return syncronous error code from function return |
|
140 */ |
|
141 TInt DeleteContext(MNssDeleteContextClient* aContextClient, MNssContext* aContext); |
|
142 |
|
143 /** |
|
144 * SaveContext is called to store a context to the VAS DB. |
|
145 * This method is asynchronous. A call back will be made to |
|
146 * either SaveContextCompleted() or SaveContextFailed() as |
|
147 * defined in the MNssSaveContextClient interface. It also returns an |
|
148 * error code validating success of call to VAS DB. |
|
149 * @since 2.8 |
|
150 * |
|
151 * @param aContextClient - call back address |
|
152 * @param aContext - context object to save |
|
153 * @return - syncronous error code from function return |
|
154 */ |
|
155 TInt SaveContext( MNssSaveContextClient* aContextClient, MNssContext* aContext); |
|
156 |
|
157 /** |
|
158 * SaveClientData is called to save client-specific data about the context. |
|
159 * This method is asynchronous. A call back will be made to either |
|
160 * SaveContextCompleted or SaveContextFailed() as defined in the |
|
161 * MNssSaveContextClient interface. It also returns an error code validating |
|
162 * success of call to VAS DB. |
|
163 * |
|
164 * @from VasMNssContextMgr |
|
165 * @since 2.8 |
|
166 * @param aContext - the client data of this context will be updated. |
|
167 */ |
|
168 TInt SaveClientData( MNssContext* aContext ); |
|
169 |
|
170 /** |
|
171 * GetGlobalContexts is called to get the list of global contexts in VAS DB. |
|
172 * This method is synchronous (It used to be asynchronous before 2.8. A call |
|
173 * back was made to either GetGlobalContextsCompleted() or GetContextFailed() |
|
174 * as defined in the MNssInterCompContextMgrClient interface. It also returned an |
|
175 * error code validating success of call to VAS DB). This method is for use by |
|
176 * internal VAS components. |
|
177 * @since 2.8 |
|
178 * |
|
179 * @param aContextClient - call back address |
|
180 * @return - syncronous error code from function return |
|
181 */ |
|
182 TMNssContextList* GetGlobalContexts(); |
|
183 |
|
184 /** |
|
185 * Call back function from CVASDatabase, through interface MNssVASDatabaseClient |
|
186 * @since 2.8 |
|
187 * @param aContextList - list of contexts |
|
188 * @param aTagList - list of tags (not used by context manager) |
|
189 * @param aTagRefList - list of tag references |
|
190 * @param aCode - success status |
|
191 * @return |
|
192 */ |
|
193 void VASDatabaseComplete( CArrayPtrFlat<CNssContext>* aContextList, |
|
194 CArrayPtrFlat<CNssTag>* aTagList, |
|
195 CArrayPtrFlat<CNssTagReference>* aTagRefList, |
|
196 TNssVASDBClientReturnCode aCode); |
|
197 |
|
198 |
|
199 /** |
|
200 * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler |
|
201 * Called after saving to SRS DB is successful |
|
202 * @since 2.8 |
|
203 * @param |
|
204 * @return |
|
205 */ |
|
206 void HandleSaveSrsDBCompleted(); |
|
207 |
|
208 /** |
|
209 * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler |
|
210 * Called after deleting from SRS DB is successful |
|
211 * @since 2.8 |
|
212 * @param |
|
213 * @return |
|
214 */ |
|
215 void HandleDeleteSrsDBCompleted(); |
|
216 |
|
217 /** |
|
218 * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler |
|
219 * Called after deleting from SRS DB is successful |
|
220 * @since 2.8 |
|
221 * @param |
|
222 * @return |
|
223 */ |
|
224 void HandleResetSrsDBCompleted(); |
|
225 |
|
226 /** |
|
227 * Call back function from SRS DB, through interface MNssCoreSrsDBEventHandler |
|
228 * Called after saving or deleting to SRS DB is unsuccessful |
|
229 * @since 2.8 |
|
230 * @param aResult result code |
|
231 * @return |
|
232 */ |
|
233 void HandleSrsDBError(MNssCoreSrsDBEventHandler::TNssSrsDBResult aResult); |
|
234 |
|
235 /** |
|
236 * Determine if tag exists in the VAS Database for a context |
|
237 * @since 2.8 |
|
238 * @param context pointer |
|
239 * @return ETrue if a context exists, EFalse otherwise. |
|
240 */ |
|
241 TBool TagExist(CNssContext* aContext); |
|
242 |
|
243 /** |
|
244 * Cancel get context / get context list / get global contexts |
|
245 * @since 2.8 |
|
246 * @param none |
|
247 * @return none |
|
248 */ |
|
249 void CancelGetContext(); |
|
250 |
|
251 /** |
|
252 * Deletes the speaker adapted models and creates new, |
|
253 * speaker independent ones. Asynchronous. |
|
254 * @since 2.8 |
|
255 * @param aClient Callback to signal success or failure |
|
256 * @return symbian-wide error code |
|
257 */ |
|
258 TInt ResetFactoryModels( MNssResetFactoryModelsClient* aClient ); |
|
259 |
|
260 /** |
|
261 * Error handler if RunL leaves. |
|
262 * @from CActive |
|
263 * @since 2.8 |
|
264 * @param aClient Callback to signal success or failure |
|
265 * @return none |
|
266 */ |
|
267 TInt RunError(TInt aError); |
|
268 |
|
269 /** |
|
270 * Look at CActive documentation for exaplanation. |
|
271 * @from CActive |
|
272 * @since 2.8 |
|
273 * @param aClient Callback to signal success or failure |
|
274 * @return none |
|
275 */ |
|
276 void RunL(); |
|
277 |
|
278 /** |
|
279 * Look at CActive documentation for exaplanation. |
|
280 * @from CActive |
|
281 * @since 2.8 |
|
282 * @param none |
|
283 * @return none |
|
284 */ |
|
285 void DoCancel(); |
|
286 |
|
287 private: |
|
288 |
|
289 /** |
|
290 * C++ Constructor. |
|
291 */ |
|
292 CNssContextMgr(); |
|
293 |
|
294 /** |
|
295 * C++ overloaded Constructor. |
|
296 */ |
|
297 CNssContextMgr(CNssVASDatabase* aVASDatabase); |
|
298 |
|
299 /** |
|
300 * Symbian constructor |
|
301 */ |
|
302 void ConstructL(); |
|
303 |
|
304 /** |
|
305 * Utility function for CContext to MNssContext List conversion, and call back to client |
|
306 * @param aSourceList a CContext list |
|
307 * @return |
|
308 */ |
|
309 void CNssContextListToMNssContextListConvertorL(CArrayPtrFlat<CNssContext>* aSourceList); |
|
310 |
|
311 private: |
|
312 // VAS Database |
|
313 CNssVASDatabase* iVasDatabase; |
|
314 |
|
315 // context builder |
|
316 CNssContextBuilder* iContextBuilder; |
|
317 |
|
318 // internal state |
|
319 TNssCallBackState iState; |
|
320 |
|
321 // external get context client |
|
322 MNssGetContextClient* iGetContextClient; |
|
323 |
|
324 // external delete context client |
|
325 MNssDeleteContextClient* iDeleteContextClient; |
|
326 |
|
327 // external save context client |
|
328 MNssSaveContextClient* iSaveContextClient; |
|
329 |
|
330 // internal inter-component client |
|
331 MNssInterCompContextMgrClient* iInterCompContextMgrClient; |
|
332 |
|
333 // flag to denote if model bank and lexicon exist or not for |
|
334 // VAS has a single model bank and lexicon |
|
335 TBool iModelBankAndLexiconExist; |
|
336 |
|
337 // model bank id, if model bank exists; else its not a valid id |
|
338 TSIModelBankID iModelBankId; |
|
339 |
|
340 // lexicon id, if lexicon exists; else its not a valid id |
|
341 TUint32 iLexiconId; |
|
342 |
|
343 // local pointer to context, used to handle error conditions |
|
344 CNssContext* iLocalContext; |
|
345 |
|
346 // flag used to handle error conditions |
|
347 TBool iRecovery; |
|
348 |
|
349 // For GetContext: Stores the context list |
|
350 CArrayPtrFlat<CNssContext> *iContextList; |
|
351 |
|
352 // Callback for ResetFactoryModels |
|
353 MNssResetFactoryModelsClient* iResetClient; |
|
354 }; |
|
355 |
|
356 #endif // NSSVASCCONTEXTMGR_H |
|
357 |
|
358 // End of file |
|