|
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: This class handles the tone playing for the Voice commands UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <avkon.hrh> |
|
21 #include <aknSoundinfo.h> |
|
22 #include "vctonereader.h" |
|
23 #include <eikcolib.h> |
|
24 #include <aknsoundsystem.h> |
|
25 #include <aknappui.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // |
|
34 CVCToneReader::CVCToneReader() |
|
35 { |
|
36 } |
|
37 |
|
38 // Default constructor can leave. |
|
39 void CVCToneReader::ConstructL() |
|
40 { |
|
41 #ifdef _DEBUG |
|
42 RDebug::Print(_L("CVCToneReader::ConstructL")); |
|
43 #endif |
|
44 |
|
45 iAbortInfo = CAknSoundInfo::NewL(); |
|
46 iErrorInfo = CAknSoundInfo::NewL(); |
|
47 |
|
48 iAbortToneSequence = ReadToneSequenceL(iAbortInfo, |
|
49 EAvkonSIDNameDiallerAbortTone, |
|
50 &iAbortTonePriority,&iAbortTonePreference, |
|
51 &iAbortToneVolume); |
|
52 |
|
53 iErrorToneSequence = ReadToneSequenceL(iErrorInfo, |
|
54 EAvkonSIDNameDiallerErrorTone, |
|
55 &iErrorTonePriority,&iErrorTonePreference, |
|
56 &iErrorToneVolume); |
|
57 |
|
58 iToneUtility = CMdaAudioToneUtility::NewL(*this); |
|
59 } |
|
60 |
|
61 // Two-phased constructor. |
|
62 CVCToneReader* CVCToneReader::NewL() |
|
63 { |
|
64 CVCToneReader* self = new ( ELeave ) CVCToneReader; |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // Destructor |
|
73 CVCToneReader::~CVCToneReader() |
|
74 { |
|
75 #ifdef _DEBUG |
|
76 RDebug::Print(_L("CVCToneReader::~CVCToneReader")); |
|
77 #endif |
|
78 |
|
79 delete iToneUtility; |
|
80 |
|
81 delete iAbortInfo; |
|
82 delete iErrorInfo; |
|
83 iAbortToneSequence = NULL; |
|
84 iErrorToneSequence = NULL; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CVCToneReader::ReadToneSequenceL |
|
89 // Reads the tone sequence from the Avkon resource file |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 HBufC8* CVCToneReader::ReadToneSequenceL( CAknSoundInfo* aInfo, TInt aSid, |
|
93 TInt* aTonePriority, |
|
94 TMdaPriorityPreference* aTonePreference, |
|
95 TInt* aToneVolume ) |
|
96 { |
|
97 #ifdef _DEBUG |
|
98 RDebug::Print(_L("CVCToneReader::ReadToneSequenceL: aSid = %d"),aSid); |
|
99 #endif |
|
100 if (iAvkonAppUiBase) |
|
101 { |
|
102 iAvkonAppUiBase->KeySounds()->RequestSoundInfoL( aSid, *aInfo ); // Static access |
|
103 } |
|
104 |
|
105 *aTonePriority = aInfo->iPriority; |
|
106 *aToneVolume = aInfo->iVolume; |
|
107 *aTonePreference = (TMdaPriorityPreference)aInfo->iPreference; |
|
108 return aInfo->iSequence; |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CVCToneReader::TonePriority |
|
114 // Sets the tone priority |
|
115 // --------------------------------------------------------- |
|
116 // |
|
117 TInt CVCToneReader::TonePriority(TInt aSid) |
|
118 { |
|
119 #ifdef _DEBUG |
|
120 RDebug::Print(_L("CVCToneReader::TonePriority")); |
|
121 #endif |
|
122 |
|
123 TInt priority = -1; |
|
124 switch (aSid) |
|
125 { |
|
126 case EAvkonSIDNameDiallerErrorTone: |
|
127 priority = iErrorTonePriority; |
|
128 break; |
|
129 |
|
130 case EAvkonSIDNameDiallerAbortTone: |
|
131 priority = iAbortTonePriority; |
|
132 break; |
|
133 |
|
134 default: |
|
135 break; |
|
136 } |
|
137 return priority; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CVCToneReader::TonePriorityPreference |
|
142 // Sets the appropriate priority preference |
|
143 // --------------------------------------------------------- |
|
144 // |
|
145 TMdaPriorityPreference CVCToneReader::TonePriorityPreference(TInt aSid) |
|
146 { |
|
147 #ifdef _DEBUG |
|
148 RDebug::Print(_L("CVCToneReader::TonePriorityPreference")); |
|
149 #endif |
|
150 TMdaPriorityPreference preference; |
|
151 switch (aSid) |
|
152 { |
|
153 case EAvkonSIDNameDiallerErrorTone: |
|
154 preference = iErrorTonePreference; |
|
155 break; |
|
156 |
|
157 case EAvkonSIDNameDiallerAbortTone: |
|
158 preference = iAbortTonePreference; |
|
159 break; |
|
160 |
|
161 default: |
|
162 preference = iErrorTonePreference; |
|
163 break; |
|
164 } |
|
165 return preference; |
|
166 } |
|
167 |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CVCToneReader::ToneSequence |
|
171 // Sets the appropriate tone sequence |
|
172 // --------------------------------------------------------- |
|
173 // |
|
174 HBufC8* CVCToneReader::ToneSequence(TInt aSid) |
|
175 { |
|
176 #ifdef _DEBUG |
|
177 RDebug::Print(_L("CVCToneReader::ToneSequence")); |
|
178 #endif |
|
179 HBufC8* sequence = NULL; |
|
180 |
|
181 switch (aSid) |
|
182 { |
|
183 case EAvkonSIDNameDiallerErrorTone: |
|
184 sequence = iErrorToneSequence; |
|
185 break; |
|
186 |
|
187 case EAvkonSIDNameDiallerAbortTone: |
|
188 sequence = iAbortToneSequence; |
|
189 break; |
|
190 |
|
191 default: |
|
192 break; |
|
193 } |
|
194 return sequence; |
|
195 } |
|
196 |
|
197 |
|
198 |
|
199 // --------------------------------------------------------- |
|
200 // CVCToneReader::ToneVolume |
|
201 // Sets the appropriate tone volume |
|
202 // --------------------------------------------------------- |
|
203 // |
|
204 TInt CVCToneReader::ToneVolume(TInt aSid) |
|
205 { |
|
206 #ifdef _DEBUG |
|
207 RDebug::Print(_L("CVCToneReader::ToneVolume")); |
|
208 #endif |
|
209 TInt volume = -1; |
|
210 |
|
211 switch (aSid) |
|
212 { |
|
213 case EAvkonSIDNameDiallerErrorTone: |
|
214 volume = iErrorToneVolume; |
|
215 break; |
|
216 |
|
217 case EAvkonSIDNameDiallerAbortTone: |
|
218 volume = iAbortToneVolume; |
|
219 break; |
|
220 |
|
221 default: |
|
222 break; |
|
223 } |
|
224 return volume; |
|
225 } |
|
226 |
|
227 |
|
228 // --------------------------------------------------------- |
|
229 // CVCToneReader::PlayTone |
|
230 // Plays the appropriate tone |
|
231 // --------------------------------------------------------- |
|
232 // |
|
233 void CVCToneReader::PlayTone(MVCTonePlayer* aTonePlayer,TInt aSid) |
|
234 { |
|
235 iTonePlayer = aTonePlayer; |
|
236 iTonePriority = TonePriority(aSid); |
|
237 iTonePreference = TonePriorityPreference(aSid); |
|
238 iToneVolume = ToneVolume(aSid); |
|
239 |
|
240 iToneUtility->PrepareToPlayDesSequence(ToneSequence(aSid)->Des()); |
|
241 } |
|
242 |
|
243 |
|
244 // --------------------------------------------------------- |
|
245 // CVCToneReader::MatoPrepareComplete |
|
246 // Callback from the CMdaToneUtility when tone preparation is |
|
247 // complete |
|
248 // --------------------------------------------------------- |
|
249 // |
|
250 void CVCToneReader::MatoPrepareComplete(TInt aError) |
|
251 { |
|
252 if (aError == KErrNone) |
|
253 { |
|
254 iToneUtility->SetPriority(iTonePriority, iTonePreference); |
|
255 iToneUtility->SetVolume(iToneVolume); |
|
256 iToneUtility->Play(); |
|
257 } |
|
258 else |
|
259 { |
|
260 if (iTonePlayer) |
|
261 { |
|
262 iTonePlayer->MntpToneError(); |
|
263 } |
|
264 } |
|
265 } |
|
266 |
|
267 |
|
268 // --------------------------------------------------------- |
|
269 // CVCToneReader::MatoPlayComplete |
|
270 // Callback from the CMdaToneUtility when the tone playing |
|
271 // is complete |
|
272 // --------------------------------------------------------- |
|
273 // |
|
274 void CVCToneReader::MatoPlayComplete(TInt /*aError*/) |
|
275 { |
|
276 #ifdef _DEBUG |
|
277 RDebug::Print(_L("CVCToneReader::MatoPlayComplete")); |
|
278 #endif |
|
279 if (iTonePlayer) |
|
280 { |
|
281 iTonePlayer->MntpToneComplete(); |
|
282 } |
|
283 } |
|
284 |
|
285 |
|
286 // End of File |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |