|
1 /* |
|
2 * Copyright (c) 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: Utility object to provide a VAS context |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CONTEXTPROVIDER_H |
|
21 #define CONTEXTPROVIDER_H |
|
22 |
|
23 #include "asyncworker.h" |
|
24 |
|
25 #include <nssvasmgetcontextclient.h> |
|
26 #include <nssvasmsavecontextclient.h> |
|
27 #include <nssvascvasdbmgr.h> |
|
28 |
|
29 class MNssContext; |
|
30 class MNssContextMgr; |
|
31 |
|
32 /** |
|
33 * Provides the access to the VAS context |
|
34 */ |
|
35 class CContextProvider : public CAsyncWorker, public MNssGetContextClient, |
|
36 public MNssSaveContextClient |
|
37 { |
|
38 public: |
|
39 static CContextProvider* NewL( CNssVASDBMgr& aVasDbManager ); |
|
40 static CContextProvider* NewLC( CNssVASDBMgr& aVasDbManager ); |
|
41 ~CContextProvider(); |
|
42 |
|
43 /** |
|
44 * Returns the VCommand VAS context. If it doesn't exists, |
|
45 * it is being created. client is responsible for the context deletion |
|
46 * |
|
47 * |
|
48 * @todo If support for different contexts is needed, |
|
49 * 1) Rename the method into GetContextLC; |
|
50 * 2) Add the optional |
|
51 * argument "const TDesC& aContextName = KVoiceCommandContext" |
|
52 */ |
|
53 MNssContext* GetVCommandContextLC(); |
|
54 |
|
55 public: |
|
56 |
|
57 // From MNssGetContextClient |
|
58 /** |
|
59 * Callback to indicate GetContext successed. |
|
60 * client has to delete the context after using the context. |
|
61 * @since 2.0 |
|
62 * @param aContext |
|
63 * @param aErrorCode KErrNone if getting of context was successfull |
|
64 * @return None |
|
65 */ |
|
66 virtual void GetContextCompleted( MNssContext* aContext, |
|
67 TInt aErrorCode ); |
|
68 |
|
69 /** |
|
70 * Callback to indicate GetContext successed. |
|
71 * client has to ResetAndDestroy() after using the list. |
|
72 * @since 2.0 |
|
73 * @param aContextList A list of contexts. |
|
74 * @param aErrorCode KErrNone if getting of context list was successfull |
|
75 * @return None |
|
76 */ |
|
77 virtual void GetContextListCompleted( |
|
78 MNssContextListArray *aContextList, TInt aErrorCode ); |
|
79 |
|
80 public: |
|
81 |
|
82 // From MNssSaveContextClient |
|
83 /** |
|
84 * Callback to indicate SaveContext successed. |
|
85 * @since 2.0 |
|
86 * @param aErrorCode KErrNone if saving of context was successfull |
|
87 * @return None |
|
88 */ |
|
89 virtual void SaveContextCompleted( TInt aErrorCode ); |
|
90 |
|
91 private: |
|
92 /** |
|
93 * Creates VCommand context. To be called during the GetVCommandContextLC |
|
94 * sequence |
|
95 */ |
|
96 MNssContext* CreateVCommandContextLC(); |
|
97 |
|
98 |
|
99 private: |
|
100 // VAS context manager. Not owned |
|
101 MNssContextMgr* iContextManager; |
|
102 |
|
103 // Temporary variable to be used with async callbacks |
|
104 MNssContext* iVasContext; |
|
105 |
|
106 // Extra waiter for the SaveContext operation |
|
107 CAsyncWorker* iSaveContextWaiter; |
|
108 }; |
|
109 |
|
110 |
|
111 #endif // CONTEXTPROVIDER_H |