|
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: Implementation of CVCPlaybackDialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include <StringLoader.h> |
|
23 #include <aknnotewrappers.h> |
|
24 #include <aknsoundsystem.h> |
|
25 #include <aknappui.h> |
|
26 #include <avkon.hrh> |
|
27 #include <vcommandapi.h> |
|
28 #include "vcplaybackdialog.h" |
|
29 #include "vcmodel.h" |
|
30 #include "rubydebug.h" |
|
31 |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CVCPlaybackDialog::CVCPlaybackDialog |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CVCPlaybackDialog::CVCPlaybackDialog( CVCommandHandler& aService, |
|
42 const CVCommandUiEntry& aCommand ) : |
|
43 CAknProgressDialog( NULL ), |
|
44 iService( aService ), |
|
45 iCommand( aCommand ) |
|
46 { |
|
47 iTModel.iFinalValue = KVoiceTagRecordLength; |
|
48 iTModel.iHundreths = KInterval; |
|
49 iTModel.iIncrement = KVoiceTagIncrement; |
|
50 iTModel.iRunning = EFalse; |
|
51 iVisibilityDelayOff = ETrue; |
|
52 } |
|
53 |
|
54 |
|
55 // Destructor |
|
56 CVCPlaybackDialog::~CVCPlaybackDialog() |
|
57 { |
|
58 if (iProgressBarTimer) |
|
59 { |
|
60 iProgressBarTimer->Cancel(); |
|
61 delete iProgressBarTimer; |
|
62 } |
|
63 if (iProgressInfo) |
|
64 { |
|
65 iProgressInfo = NULL; |
|
66 } |
|
67 } |
|
68 |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // CVCPlaybackDialog::PreLayoutDynInitL |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 void CVCPlaybackDialog::PreLayoutDynInitL() |
|
75 { |
|
76 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::PreLayoutDynInitL" ); |
|
77 |
|
78 HBufC* text = StringLoader::LoadLC( R_QTN_VC_PLAYING ); |
|
79 SetTextL( *text ); |
|
80 CleanupStack::PopAndDestroy( text ); |
|
81 |
|
82 ButtonGroupContainer().SetCommandSetL( R_SOFTKEYS_QUIT ); |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CVCPlaybackDialog::PostLayoutDynInitL |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CVCPlaybackDialog::PostLayoutDynInitL() |
|
91 { |
|
92 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::PostLayoutDynInitL" ); |
|
93 |
|
94 // FIrst check if a user edited command exists |
|
95 if( iCommand.AlternativeSpokenText().Length() > 0 ) |
|
96 { |
|
97 iCommand.PlayAlternativeSpokenTextL( iService, *this ); |
|
98 } |
|
99 else |
|
100 { |
|
101 iCommand.PlaySpokenTextL( iService, *this ); |
|
102 } |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // CVCPlaybackDialog::OkToExitL |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 TBool CVCPlaybackDialog::OkToExitL( TInt aButtonId ) |
|
111 { |
|
112 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::OkToExitL" ); |
|
113 |
|
114 // Finished playing |
|
115 if ( iExitWhenCalledBack ) |
|
116 { |
|
117 return ETrue; |
|
118 } |
|
119 |
|
120 if ( ( iTickCount < 1 ) && ( !iExitFlag ) ) |
|
121 { |
|
122 return EFalse; |
|
123 } |
|
124 |
|
125 // Check what button was pressed |
|
126 switch ( aButtonId ) |
|
127 { |
|
128 case EAknSoftkeyOk: |
|
129 break; |
|
130 |
|
131 case EKeyPhoneEnd: |
|
132 case EKeyApplication: |
|
133 case EAknSoftkeyQuit: |
|
134 { |
|
135 iOkToExit = ETrue; |
|
136 |
|
137 if ( iExitFlag ) |
|
138 { |
|
139 iCommand.CancelPlaybackL( iService ); |
|
140 } |
|
141 |
|
142 break; |
|
143 } |
|
144 |
|
145 //case EVCommandSoftKeyQuit: |
|
146 case EAknSoftkeyDone: |
|
147 { |
|
148 iOkToExit = ETrue; |
|
149 |
|
150 iCommand.CancelPlaybackL( iService ); |
|
151 |
|
152 break; |
|
153 } |
|
154 |
|
155 default: |
|
156 iOkToExit = EFalse; |
|
157 break; |
|
158 } |
|
159 |
|
160 return iOkToExit; |
|
161 } |
|
162 |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // CVCPlaybackDialog::OfferKeyEventL |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 TKeyResponse CVCPlaybackDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
169 TEventCode aType ) |
|
170 { |
|
171 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::OfferKeyEventL" ); |
|
172 |
|
173 // Only react to red and application key |
|
174 if ( aType == EEventKey ) |
|
175 { |
|
176 if ( aKeyEvent.iCode == EKeyApplication ) |
|
177 { |
|
178 iExitFlag = ETrue; |
|
179 TryExitL( EKeyApplication ); |
|
180 return EKeyWasConsumed; |
|
181 } |
|
182 else if ( aKeyEvent.iCode == EKeyPhoneEnd ) |
|
183 { |
|
184 iExitFlag = ETrue; |
|
185 TryExitL( EKeyPhoneEnd ); |
|
186 return EKeyWasConsumed; |
|
187 } |
|
188 } |
|
189 |
|
190 return EKeyWasConsumed; |
|
191 } |
|
192 |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // CVCPlaybackDialog::StartTimerL |
|
196 // --------------------------------------------------------- |
|
197 // |
|
198 void CVCPlaybackDialog::StartTimerL() |
|
199 { |
|
200 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::StartTimerL" ); |
|
201 |
|
202 iTickCount=0; |
|
203 iProgressBarTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
204 TTimeIntervalMicroSeconds32 delay( KDelay ); |
|
205 TTimeIntervalMicroSeconds32 interval( KMicroSecondsInterval*iTModel.iHundreths ); |
|
206 iProgressBarTimer->Start( delay,interval, TCallBack( OnTick, this ) ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // CVCPlaybackDialog::StopTimer |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 void CVCPlaybackDialog::StopTimer() |
|
214 { |
|
215 if ( iProgressBarTimer ) |
|
216 { |
|
217 iProgressBarTimer->Cancel(); |
|
218 delete iProgressBarTimer; |
|
219 iProgressBarTimer = NULL; |
|
220 } |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // CVCPlaybackDialog::OnTick |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 TInt CVCPlaybackDialog::OnTick( TAny* aObject ) |
|
228 { |
|
229 STATIC_CAST( CVCPlaybackDialog*, aObject )->DoTick(); |
|
230 return 1; // magic |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // CVCPlaybackDialog::DoTick |
|
235 // --------------------------------------------------------- |
|
236 // |
|
237 void CVCPlaybackDialog::DoTick() |
|
238 { |
|
239 if ( iTickCount != iTModel.iFinalValue+1 ) |
|
240 { |
|
241 iProgressInfo->IncrementAndDraw( iTModel.iIncrement ); |
|
242 iTickCount++; |
|
243 } |
|
244 |
|
245 if (iExitFlag) |
|
246 { |
|
247 RUBY_DEBUG0( "CVCPlaybackDialog::DoTick: Exit due to iExitFlag" ); |
|
248 StopTimer(); |
|
249 } |
|
250 } |
|
251 |
|
252 |
|
253 // --------------------------------------------------------- |
|
254 // CVCPlaybackDialog::DoHandlePlayErrorL |
|
255 // --------------------------------------------------------- |
|
256 // |
|
257 void CVCPlaybackDialog::DoHandlePlayErrorL( TNssPlayResult aResult ) |
|
258 { |
|
259 RUBY_DEBUG1( "CVCPlaybackDialog::DoHandlePlayErrorL: [%d]", aResult ); |
|
260 HandlePlayComplete( aResult ); |
|
261 } |
|
262 |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CVCPlaybackDialog::HandlePlayStarted |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 void CVCPlaybackDialog::HandlePlayStarted( |
|
269 TTimeIntervalMicroSeconds32 aDuration ) |
|
270 { |
|
271 TRAP_IGNORE( DoHandlePlayStartedL( aDuration ) ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------- |
|
275 // CVCPlaybackDialog::DoHandlePlayStartedL |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CVCPlaybackDialog::DoHandlePlayStartedL( |
|
279 TTimeIntervalMicroSeconds32 aDuration ) |
|
280 { |
|
281 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::DoHandlePlayStartedL" ); |
|
282 |
|
283 iTModel.iFinalValue = aDuration.Int()/KMicroSecondsInterval; |
|
284 iProgressInfo = GetProgressInfoL(); |
|
285 iProgressInfo->SetFinalValue( iTModel.iFinalValue ); |
|
286 StartTimerL(); |
|
287 } |
|
288 |
|
289 |
|
290 // --------------------------------------------------------- |
|
291 // CVCPlaybackDialog::HandlePlayComplete |
|
292 // --------------------------------------------------------- |
|
293 // |
|
294 #ifdef _DEBUG |
|
295 void CVCPlaybackDialog::HandlePlayComplete( TNssPlayResult aErrorCode ) |
|
296 #else |
|
297 void CVCPlaybackDialog::HandlePlayComplete( TNssPlayResult /*aErrorCode*/ ) |
|
298 #endif |
|
299 { |
|
300 RUBY_DEBUG1( "CVCPlaybackDialog::HandlePlayComplete: [%d]", aErrorCode ); |
|
301 iExitWhenCalledBack = ETrue; |
|
302 StopTimer(); |
|
303 TRAP_IGNORE( TryExitL( EAknSoftkeyOk) ); |
|
304 } |
|
305 |
|
306 |
|
307 // --------------------------------------------------------- |
|
308 // CVCPlaybackDialog::DisplayErrorNoteL |
|
309 // --------------------------------------------------------- |
|
310 // |
|
311 void CVCPlaybackDialog::DisplayErrorNoteL() |
|
312 { |
|
313 RUBY_DEBUG_BLOCKL( "CVCPlaybackDialog::DisplayErrorNoteL" ); |
|
314 |
|
315 iExitFlag = ETrue; |
|
316 iOkToExit = ETrue; |
|
317 HBufC* text = StringLoader::LoadLC( R_TEXT_VOICE_SYSTEM_ERROR ); |
|
318 CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue ); |
|
319 dlg->ExecuteLD( *text ); |
|
320 CleanupStack::PopAndDestroy( text ); |
|
321 } |
|
322 |
|
323 |
|
324 // End of File |