|
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: class handles profile array changes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 #include <MProEngProfileObserver.h> |
|
22 #include <MProEngEngine.h> |
|
23 #include <MProEngNotifyHandler.h> |
|
24 #include <MProEngProfileNameArrayObserver.h> |
|
25 |
|
26 #include <vcommandapi.h> |
|
27 |
|
28 class CDesC16ArrayFlat; |
|
29 |
|
30 |
|
31 /** |
|
32 * CVCommandProfileObserver handles profile array changes |
|
33 * { new profile, profile removed, profile name edited } |
|
34 * and syncs the voice commands database with the current profiles. |
|
35 * |
|
36 */ |
|
37 class CVCommandProfileObserver: public CBase, |
|
38 public MProEngProfileNameArrayObserver |
|
39 { |
|
40 |
|
41 public: // Constructors and destructor |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 * |
|
46 */ |
|
47 static CVCommandProfileObserver* NewL(); |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 * |
|
52 */ |
|
53 ~CVCommandProfileObserver(); |
|
54 |
|
55 |
|
56 public: // Functions from base classes |
|
57 |
|
58 /** |
|
59 * From MProEngProfileNameArrayObserver |
|
60 * |
|
61 * @return void |
|
62 */ |
|
63 void HandleProfileNameArrayModificationL(); |
|
64 |
|
65 /** |
|
66 * From MProEngProfileNameArrayObserver |
|
67 * |
|
68 * @param aError error code |
|
69 * @return void |
|
70 */ |
|
71 void HandleProfileNameArrayNotificationError( TInt aError ); |
|
72 |
|
73 |
|
74 private: |
|
75 |
|
76 /** |
|
77 * C++ default constructor. |
|
78 * |
|
79 */ |
|
80 CVCommandProfileObserver(); |
|
81 |
|
82 /** |
|
83 * By default Symbian 2nd phase constructor is private. |
|
84 * |
|
85 * @return void |
|
86 */ |
|
87 void ConstructL(); |
|
88 |
|
89 /** |
|
90 * Returns a list of voice commands. |
|
91 * |
|
92 * @return CVCommandArray& list of voice commands |
|
93 */ |
|
94 const CVCommandArray& ListVCommandsL(); |
|
95 |
|
96 /** |
|
97 * Loads profile folder name and profile tooltip text. |
|
98 * |
|
99 * @return void |
|
100 */ |
|
101 void LoadProfileDataL(); |
|
102 |
|
103 /** |
|
104 * Deletes iCommands member variable and thus forces it to be |
|
105 * reloaded when needed next time. |
|
106 * |
|
107 * @return void |
|
108 */ |
|
109 void DeleteCache(); |
|
110 |
|
111 /** |
|
112 * Adds a profile name change to Vcommand handler. |
|
113 * |
|
114 * @param aOldName old name of the profile |
|
115 * @param aNewName new name for the profile |
|
116 * @return void |
|
117 */ |
|
118 void EditProfileNameL( const TDesC& aOldName, const TDesC& aNewName ); |
|
119 |
|
120 /** |
|
121 * Adds a new profile to VCommand handler. |
|
122 * |
|
123 * @param aNewName Name of the profile to be added |
|
124 * @param aProfileId Id of the new profile |
|
125 * @param aCommit Set as EFalse if saving to Voice Command services is done |
|
126 * later with CommitAdditionsToVCommandServicesL |
|
127 * @return void |
|
128 */ |
|
129 void AddNewProfileL( const TDesC& aNewName, TInt aProfileId, TBool aCommit = ETrue ); |
|
130 |
|
131 /** |
|
132 * Adds new profiles to VCommand handler. |
|
133 * |
|
134 * @param aNames Names of the profiles to be added |
|
135 * @param aProfileNames Names of the existing profiles |
|
136 * @param aCommit Set as EFalse if saving to Voice Command services is done |
|
137 * later with CommitAdditionsToVCommandServicesL |
|
138 * @return void |
|
139 */ |
|
140 void AddNewProfilesL( const CDesC16ArrayFlat& aNames, |
|
141 const MProEngProfileNameArray& aProfileNames, |
|
142 TBool aCommit = ETrue ); |
|
143 |
|
144 /** |
|
145 * Creates a VCommand for the given profile attributes |
|
146 */ |
|
147 CVCommand* CreateProfileCommandL( const TDesC& profileName, TInt aProfileId ) const; |
|
148 |
|
149 /** |
|
150 * Removes a profile from VCommand handler. |
|
151 * |
|
152 * @param aName a name of the profile to be removed |
|
153 * @return void |
|
154 */ |
|
155 void RemoveProfileL( const TDesC& aName ); |
|
156 |
|
157 /** |
|
158 * Removes profiles from VCommand handler. |
|
159 * |
|
160 * @param aNames names of the profiles to be removed |
|
161 * @return void |
|
162 */ |
|
163 void RemoveProfilesL( const CDesC16ArrayFlat& aNames ); |
|
164 |
|
165 /** |
|
166 * Finds the profile index by name. |
|
167 * |
|
168 * @param aName name of a profile |
|
169 * @return TInt index to the vcommand profile, default is KErrNotFound |
|
170 */ |
|
171 TInt FindProfileIndexL( const TDesC& aName ); |
|
172 |
|
173 /** |
|
174 * Syncronizes the voice commands at VCommand Handler to equal |
|
175 * to the list of real profiles. This method is called when |
|
176 * profile observing is started. |
|
177 * |
|
178 * @return void |
|
179 */ |
|
180 void SyncVCommandProfilesL(); |
|
181 |
|
182 private: // Data |
|
183 |
|
184 MProEngEngine* iProfileEngine; // owned |
|
185 MProEngProfileNameArray* iNameArray; // owned |
|
186 |
|
187 MProEngNotifyHandler* iNotifyHandler; // owned |
|
188 |
|
189 CVCommandHandler* iService; // owned |
|
190 CVCommandArray* iCommands; // owned |
|
191 |
|
192 HBufC* iProfileFolder; // owned |
|
193 HBufC* iFolderTitle; // owned |
|
194 HBufC* iProfileTooltip; // owned |
|
195 |
|
196 // Command additions collected into an array |
|
197 RVCommandArray iAddedCommands; |
|
198 |
|
199 TBool iProfileUpdateError; |
|
200 |
|
201 }; |
|
202 |
|
203 |