|
1 /* |
|
2 * Copyright (c) 2005-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: Voice progress dialog. Progress bar for recording and playing. |
|
15 * Output routing feature for playing. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <StringLoader.h> |
|
22 #include <eikprogi.h> |
|
23 #include <audiomessage.mbg> |
|
24 #include <data_caging_path_literals.hrh> |
|
25 #include <aknnotewrappers.h> |
|
26 #include <aknsoundsystem.h> |
|
27 #include <akninputblock.h> |
|
28 #include <AknNaviObserver.h> |
|
29 #include <remconcoreapitarget.h> |
|
30 #include <remconinterfaceselector.h> |
|
31 #include <aknconsts.h> // KAknStandardKeyboardRepeatRate |
|
32 #include <featmgr.h> |
|
33 #include <PSVariables.h> // Property values |
|
34 #include <ctsydomainpskeys.h> |
|
35 #include <e32property.h> |
|
36 #include <ScreensaverInternalPSKeys.h> |
|
37 #include <audiomessage.rsg> |
|
38 #include <AknVolumePopup.h> |
|
39 #include "audiomessagerecorder.h" |
|
40 #include "audiomessage.hrh" |
|
41 #include "audiomessageprogressdialog.h" |
|
42 #include "amsvolobserver.h" |
|
43 #include "AudioMessageLogging.h" |
|
44 |
|
45 #ifdef RD_SCALABLE_UI_V2 |
|
46 #include <cmsvmimeheaders.h> |
|
47 #include "audiomessageappui.h" |
|
48 #endif |
|
49 |
|
50 _LIT( KAmsBitmapFileName, "audiomessage.mif" ); |
|
51 |
|
52 const TInt KVolumeFirstChangePeriod = KAknStandardKeyboardRepeatRate; |
|
53 const TInt KVolumeChangePeriod = KAknStandardKeyboardRepeatRate; |
|
54 const TInt KVolumeChangeUp = 1; |
|
55 const TInt KVolumeChangeDown = -1; |
|
56 const TInt KSecondAsMicroSeconds = 1000000; |
|
57 #ifdef __SERIES60_30__ |
|
58 const TInt KMinVol = 1; |
|
59 #else |
|
60 const TInt KMinVol = 0; |
|
61 #endif |
|
62 const TInt KMaxVol = 10; |
|
63 const TInt KFive = 5; |
|
64 const TInt KSeed = 1; |
|
65 const TUint KMaxMessageDurationInSeconds = 180; |
|
66 const TUint KMaxMessageDurationInSecondsSmall = 60; |
|
67 const TUint KBitsInByte = 8; |
|
68 |
|
69 // ======== MEMBER FUNCTIONS ======== |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // CAudioMessageProgressDialog::Constructor |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 CAudioMessageProgressDialog::CAudioMessageProgressDialog( CAudioMessageDocument& aDocument ): |
|
76 CAknProgressDialog( REINTERPRET_CAST( CEikDialog**, NULL ) ), |
|
77 iDocument( aDocument ) |
|
78 { |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CAudioMessageProgressDialog::NewL |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 CAudioMessageProgressDialog* CAudioMessageProgressDialog::NewL( |
|
86 const RFile& aFile, |
|
87 TInt aVolume, |
|
88 TBool aSpeakerEarpiece, |
|
89 TBool aRecorder, |
|
90 CAudioMessageDocument& aDocument ) |
|
91 { |
|
92 CAudioMessageProgressDialog * dlg = |
|
93 new( ELeave ) CAudioMessageProgressDialog( aDocument ); |
|
94 CleanupStack::PushL( dlg ); |
|
95 dlg->ConstructL( aFile, aVolume, aSpeakerEarpiece, aRecorder ); |
|
96 CleanupStack::Pop( dlg ); |
|
97 return dlg; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CAudioMessageProgressDialog::Destructor |
|
102 // --------------------------------------------------------- |
|
103 // |
|
104 CAudioMessageProgressDialog::~CAudioMessageProgressDialog() |
|
105 { |
|
106 // Allow screensaver again |
|
107 RProperty::Set(KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 0); |
|
108 |
|
109 if (iVolumeTimer) |
|
110 { |
|
111 iVolumeTimer->Cancel(); |
|
112 delete iVolumeTimer; |
|
113 } |
|
114 if ( iVolumePopup ) |
|
115 { |
|
116 iVolumePopup->CloseVolumePopup(); |
|
117 delete iVolumePopup; |
|
118 } |
|
119 |
|
120 delete iRecorder; |
|
121 delete iInterfaceSelector; |
|
122 delete iTimeDuratBase; |
|
123 delete iTextRecording; |
|
124 delete iTextPlaying; |
|
125 delete iTextPaused; |
|
126 |
|
127 delete iLengthMax; |
|
128 delete iLengthNow; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // CAudioMessageProgressDialog::ConstructL |
|
133 // --------------------------------------------------------- |
|
134 // |
|
135 void CAudioMessageProgressDialog::ConstructL( const RFile& aFile, |
|
136 TInt aVolume ,TBool aSpeakerEarpiece, TBool aRecorder) |
|
137 { |
|
138 iFlags = 0; |
|
139 iFinalValue = 0; |
|
140 iIncrement = KSeed; |
|
141 iVisibilityDelayOff = ETrue; |
|
142 iCurrentVolume = aVolume; |
|
143 if ( aRecorder ) |
|
144 { |
|
145 iFlags |= EAmsWorkingModeRecorder; |
|
146 } |
|
147 iTimeDuratBase = StringLoader::LoadL( R_QTN_TIME_DURAT_MIN_SEC ); |
|
148 iTextRecording = StringLoader::LoadL( R_AUDIOMESSAGE_PROGRESS_RECORDING ); |
|
149 iTextPlaying = StringLoader::LoadL( R_AUDIOMESSAGE_PROGRESS_PLAYING ); |
|
150 iTextPaused = StringLoader::LoadL( R_AUDIOMESSAGE_PROGRESS_PAUSED ); |
|
151 |
|
152 // Get supported features from feature manager. |
|
153 FeatureManager::InitializeLibL(); |
|
154 if ( FeatureManager::FeatureSupported( KFeatureIdAccessoryFw ) ) |
|
155 { |
|
156 iFlags |= EAmsSupportAudioOutput; |
|
157 } |
|
158 |
|
159 FeatureManager::UnInitializeLib(); |
|
160 |
|
161 iRecorder = CAudioMessageRecorder::NewL( aFile, ( iFlags & |
|
162 EAmsSupportAudioOutput ) ); |
|
163 iRecorder->SetObserver( this ); |
|
164 iRecorder->SetVol( aVolume ); |
|
165 |
|
166 if ( aSpeakerEarpiece ) |
|
167 { |
|
168 iFlags |= EAmsAudioOutputEarpiece; |
|
169 } |
|
170 |
|
171 iInterfaceSelector = CRemConInterfaceSelector::NewL(); |
|
172 |
|
173 // owned by iInterfaceSelector |
|
174 iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this ); |
|
175 iInterfaceSelector->OpenTargetL(); |
|
176 |
|
177 // Remote control server command repeat timer. |
|
178 iVolumeTimer = CPeriodic::NewL( EPriorityNormal ); |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 // Do not allow screensaver |
|
184 RProperty::Set(KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 1); |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CAudioMessageProgressDialog::PreLayoutDynInitL |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 void CAudioMessageProgressDialog::PreLayoutDynInitL() |
|
192 { |
|
193 AMSLOGGER_WRITE( "CAudioMessageProgressDialog::PreLayoutDynInitL()" ); |
|
194 //MakeVisible( EFalse ); |
|
195 RProperty property; |
|
196 TInt callState; |
|
197 CAknProgressDialog::PreLayoutDynInitL(); |
|
198 TInt finalValue = 0; |
|
199 TInt64 interval = 0; |
|
200 iProgressInfo = GetProgressInfoL(); |
|
201 iTickCount = 0; |
|
202 |
|
203 if ( iFlags & EAmsWorkingModeRecorder ) //rec |
|
204 { |
|
205 |
|
206 //Final value should be 3 min but it may be to big if message size is limited e.g. to |
|
207 //100kB. |
|
208 TInt dataRate(0); |
|
209 dataRate=iRecorder->GetBitRateL(); |
|
210 if ( dataRate == 0) |
|
211 { |
|
212 User::Leave( KErrGeneral ); |
|
213 } |
|
214 |
|
215 iFinalValue = ( iMaxMessageSize*KBitsInByte ) / dataRate; |
|
216 if( iFinalValue > KMaxMessageDurationInSeconds ) |
|
217 { |
|
218 iFinalValue = KMaxMessageDurationInSeconds; |
|
219 } |
|
220 else // iFinalValue < KMaxMessageDurationInSeconds |
|
221 { |
|
222 iFinalValue = KMaxMessageDurationInSecondsSmall; |
|
223 } |
|
224 |
|
225 iProgressInfo->SetFinalValue( (( iFinalValue ) * KFive)-KFive*3 ); |
|
226 iMaxDurationMicroSec = (( iFinalValue ) * KSecondAsMicroSeconds ); |
|
227 SetProgressIconL( EMbmAudiomessageQgn_indi_mms_audio_record, |
|
228 EMbmAudiomessageQgn_indi_mms_audio_record_mask ); |
|
229 UpdateProgressTextL( R_AUDIOMESSAGE_PROGRESS_RECORDING, 0 ); |
|
230 |
|
231 AMSLOGGER_WRITE( "CAudioMessageProgressDialog::PreLayoutDynInitL() done" ); |
|
232 } |
|
233 else //play |
|
234 { |
|
235 |
|
236 User::LeaveIfError( property.Attach(KPSUidCtsyCallInformation, KCTsyCallState) ); |
|
237 property.Get( callState ); |
|
238 property.Close(); |
|
239 |
|
240 iMaxDurationMicroSec = iRecorder->GetDuration(); |
|
241 interval = iMaxDurationMicroSec.Int64(); |
|
242 interval = interval / KSecondAsMicroSeconds; |
|
243 finalValue = ( ( I64INT( interval ) ) ); |
|
244 iFinalValue = finalValue; |
|
245 iProgressInfo->SetFinalValue(( ( finalValue ) * KFive)); |
|
246 // we don't want enable audiorouting if call in progress |
|
247 if ( ( iFlags & EAmsSupportAudioOutput ) && ( callState == EPSCTsyCallStateNone ) ) |
|
248 { |
|
249 iRecorder->InitializeAudioRoutingL(); |
|
250 if ( iFlags & EAmsAudioOutputEarpiece ) |
|
251 { |
|
252 ToEarpiece(); |
|
253 } |
|
254 else |
|
255 { |
|
256 ToLoudspeaker(); |
|
257 } |
|
258 } |
|
259 else |
|
260 { |
|
261 iNaviVolObserver->SetSpeakerOutput( iFlags & EAmsAudioOutputEarpiece ); |
|
262 SetSoftkeys( R_SOFTKEYS_TO_EMPTY_STOP ); |
|
263 } |
|
264 |
|
265 SetProgressIconL( EMbmAudiomessageQgn_indi_mms_audio_play, |
|
266 EMbmAudiomessageQgn_indi_mms_audio_play_mask ); |
|
267 UpdateProgressTextL( R_AUDIOMESSAGE_PROGRESS_PLAYING, 0 ); |
|
268 |
|
269 |
|
270 } |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // CAudioMessageProgressDialog::PostLayoutDynInitL |
|
275 // --------------------------------------------------------- |
|
276 // |
|
277 void CAudioMessageProgressDialog::PostLayoutDynInitL() |
|
278 { |
|
279 if ( iFlags & EAmsWorkingModeRecorder ) //rec |
|
280 { |
|
281 iRecorder->StartRecordingL(); |
|
282 } |
|
283 else |
|
284 { |
|
285 iRecorder->StartPlayingL(); |
|
286 //Select NULL as a owning control because the the popuu will be in correct place |
|
287 if ( !iVolumePopup ) |
|
288 { |
|
289 iVolumePopup = CAknVolumePopup::NewL( NULL, ETrue); |
|
290 iVolumePopup->SetObserver(this); |
|
291 iVolumePopup->SetRange( KMinVol, KMaxVol); |
|
292 iVolumePopup->SetValue( iNaviVolObserver->GetVolume() ); |
|
293 } |
|
294 iVolumePopup->ShowVolumePopupL(); |
|
295 } |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------- |
|
299 // CAudioMessageProgressDialog::Stop |
|
300 // --------------------------------------------------------- |
|
301 // |
|
302 void CAudioMessageProgressDialog::Stop() |
|
303 { |
|
304 if( !(iFlags & EAmsPause ) ) |
|
305 { |
|
306 iFlags |= EAmsWsEventStop; |
|
307 } |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // CAudioMessageProgressDialog::OkToExitL |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 TBool CAudioMessageProgressDialog::OkToExitL( TInt aButtonId ) |
|
315 { |
|
316 if ( ( iTickCount < KSeed ) && ( !(iFlags & EAmsSetExit ) ) ) |
|
317 { |
|
318 return EFalse; |
|
319 } |
|
320 |
|
321 CAknInputBlock* commandAbs = CAknInputBlock::NewLC(); |
|
322 |
|
323 TBool okToExit = EFalse; |
|
324 |
|
325 switch ( aButtonId ) |
|
326 { |
|
327 case EAmsFileEnd: |
|
328 //Added delay(0.5 secs) to ensure the progress display(playTime:totalTime) is shown completely |
|
329 User::After(500000); |
|
330 okToExit = ETrue; |
|
331 break; |
|
332 case EAmsSoftkeyStop: |
|
333 iRecorder->StopL(); |
|
334 okToExit = ETrue; |
|
335 break; |
|
336 case EAmsSoftkeyPause: |
|
337 PauseL(); |
|
338 break; |
|
339 case EAmsSoftkeyContinue: |
|
340 ContinueL(); |
|
341 break; |
|
342 case EAmsSoftkeyToLoudspeaker: |
|
343 ToLoudspeaker(); |
|
344 break; |
|
345 case EAmsSoftkeyToEarpiece: |
|
346 ToEarpiece(); |
|
347 break; |
|
348 case EEikBidCancel: |
|
349 iRecorder->StopL(); |
|
350 okToExit = ETrue; |
|
351 break; |
|
352 case EKeyEnd: |
|
353 iRecorder->StopL(); |
|
354 okToExit = ETrue; |
|
355 break; |
|
356 default: |
|
357 break; |
|
358 } |
|
359 |
|
360 CleanupStack::PopAndDestroy( commandAbs ); |
|
361 return okToExit; |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------- |
|
365 // CAudioMessageProgressDialog::DoTickL |
|
366 // Periodical timer tick |
|
367 // --------------------------------------------------------- |
|
368 // |
|
369 void CAudioMessageProgressDialog::DoTickL( TTimeIntervalMicroSeconds aCurrValue ) |
|
370 { |
|
371 //We must prevent screen saver. |
|
372 User::ResetInactivityTime(); |
|
373 //if ( ( aCurrValue.Int64() ) <= ( iFinalValue * KSecondAsMicroSeconds ) ) |
|
374 if ( ( aCurrValue.Int64() ) <= iMaxDurationMicroSec.Int64() ) |
|
375 { |
|
376 if ( !( iFlags & EAmsWorkingModeRecorder) |
|
377 || ( ( iFlags & EAmsWorkingModeRecorder) && ( iTickCount != 0 ) ) ) //rec |
|
378 { |
|
379 if ( !IsVisible() ) |
|
380 { |
|
381 MakeVisible( ETrue ); |
|
382 } |
|
383 //Let's do some corrective actions if the tick count jumps |
|
384 //It may occur if there is frequent UI action. |
|
385 //e.g. extremely continuos volume adjusting during play |
|
386 //The tick occurs at every 200000 microseconds |
|
387 //You could also use on SetAndDraw and not IncrementAndDraw but then |
|
388 //the progress bar does not update smoothly |
|
389 TInt temp ( aCurrValue.Int64()/KAmsDisplayUpdateDelay ); |
|
390 if ( temp > iIncrement+2 ) |
|
391 { |
|
392 iProgressInfo->SetAndDraw( temp ); |
|
393 } |
|
394 else |
|
395 { |
|
396 iProgressInfo->IncrementAndDraw( 1 ); |
|
397 } |
|
398 iIncrement=temp; |
|
399 } |
|
400 if ( ( !( iFlags & EAmsWorkingModeRecorder) ) && ( iTickCount == 0 )) |
|
401 { |
|
402 SetNaviVolL(); |
|
403 } |
|
404 iTickCount++; |
|
405 } |
|
406 else |
|
407 { |
|
408 if ( !( iFlags & EAmsWorkingModeRecorder) ) |
|
409 { |
|
410 //completely fill the progress bar before exiting after play. |
|
411 while( iTickCount <= ( iFinalValue * KFive ) ) |
|
412 { |
|
413 iProgressInfo->IncrementAndDraw( 1 ); |
|
414 iTickCount++; |
|
415 } |
|
416 } |
|
417 iFlags |= EAmsSetExit; |
|
418 } |
|
419 |
|
420 if ( iFlags & EAmsSetExit ) |
|
421 { |
|
422 iRecorder->StopL(); |
|
423 if ( iFlags & EAmsWorkingModeRecorder) |
|
424 { |
|
425 //ESCN-7MP97X: Application crashed when audio message was recorded upto max length |
|
426 // and user pressed some key on toolbar during screen transition. |
|
427 CEikButtonGroupContainer* cba; |
|
428 cba = CEikButtonGroupContainer::Current(); |
|
429 cba->MakeVisible(EFalse); |
|
430 this->MakeVisible(EFalse); |
|
431 ShowInformationNoteL( R_AUDIOMESSAGE_INFO_MAX_REC_TIME, ETrue ); |
|
432 } |
|
433 // Try to exit dialog cleanly. If that doesn't work, |
|
434 // then terminate anyway. |
|
435 TRAPD( err, TryExitL( EAmsFileEnd/*EAmsSoftkeyStop*/ ) ); |
|
436 if ( err != KErrNone ) |
|
437 { |
|
438 delete this; |
|
439 } |
|
440 |
|
441 } |
|
442 else if ( iFlags & EAmsWsEventStop ) |
|
443 { |
|
444 iRecorder->StopL(); |
|
445 TRAPD( err, TryExitL( EAmsSoftkeyStop ) ); |
|
446 if ( err != KErrNone ) |
|
447 { |
|
448 delete this; |
|
449 } |
|
450 iFlags &= ~EAmsWsEventStop; |
|
451 } |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------- |
|
455 // CAudioMessageProgressDialog::SetNaviVolL |
|
456 // Updates Navipane's volume state via AudioMessageAppUi |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 void CAudioMessageProgressDialog::SetNaviVolL() |
|
460 { |
|
461 iCurrentVolume = iRecorder->GetCurrentVolume(); |
|
462 iNaviVolObserver->UpdateNaviVol( iCurrentVolume ); |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------- |
|
466 // CAudioMessageProgressDialog::ShowInformationNoteL |
|
467 // --------------------------------------------------------- |
|
468 // |
|
469 void CAudioMessageProgressDialog::ShowInformationNoteL( TInt aResourceID, TBool aWaiting ) |
|
470 { |
|
471 HBufC* prompt = NULL; |
|
472 prompt = StringLoader::LoadLC( aResourceID, iCoeEnv ); |
|
473 CAknInformationNote* note = new ( ELeave ) |
|
474 CAknInformationNote( aWaiting ); |
|
475 note->ExecuteLD( *prompt ); |
|
476 CleanupStack::PopAndDestroy( prompt ); |
|
477 } |
|
478 |
|
479 // --------------------------------------------------------- |
|
480 // CAudioMessageProgressDialog::UpdateL |
|
481 // Updates Progress texts ("current sec / maximum sec" rec/play) |
|
482 // --------------------------------------------------------- |
|
483 // |
|
484 void CAudioMessageProgressDialog::UpdateL( TTimeIntervalMicroSeconds aCurrentDuration, TInt aErrorCode ) |
|
485 { |
|
486 //The following check is preventing a case where aCurrentDuration suddenly |
|
487 //drops to zero. There must be error in lower levels of software. There is nothing to do but |
|
488 //quit. It occurs e.g. in low memory situation. |
|
489 //If this check is not done the recording may continue undefined amount of time and the recording time |
|
490 //in the progress dialog stays zero. |
|
491 |
|
492 if ( aErrorCode != KErrNone |
|
493 || ( iTickCount > 1 && aCurrentDuration == 0 ) ) |
|
494 { |
|
495 AMSLOGGER_WRITE( "CAudioMessageProgressDialog::UpdateL() ERROR" ); |
|
496 |
|
497 TRAPD( err, TryExitL( EAmsFileEnd ) ); |
|
498 if ( err != KErrNone ) |
|
499 { |
|
500 AMSLOGGER_WRITE( "TryExitL FAILS" ); |
|
501 delete this; |
|
502 } |
|
503 } |
|
504 else |
|
505 { |
|
506 if ( iFlags & EAmsWorkingModeRecorder ) //rec |
|
507 { |
|
508 iDocument.SetDuration( aCurrentDuration ); |
|
509 } |
|
510 } |
|
511 |
|
512 |
|
513 if ( !(iFlags & EAmsSetExit) ) |
|
514 { |
|
515 if ( iFlags & EAmsWorkingModeRecorder )//recording in progress |
|
516 { |
|
517 UpdateProgressTextL( R_AUDIOMESSAGE_PROGRESS_RECORDING, aCurrentDuration ); |
|
518 } |
|
519 else//playing |
|
520 { |
|
521 UpdateProgressTextL( R_AUDIOMESSAGE_PROGRESS_PLAYING, aCurrentDuration ); |
|
522 } |
|
523 DoTickL( aCurrentDuration); |
|
524 } |
|
525 } |
|
526 |
|
527 // --------------------------------------------------------- |
|
528 // CAudioMessageProgressDialog::UpdateProgressTextL |
|
529 // Parses text strings to progress dialog |
|
530 // --------------------------------------------------------- |
|
531 // |
|
532 void CAudioMessageProgressDialog::UpdateProgressTextL( TInt aText, |
|
533 TTimeIntervalMicroSeconds aMicroSec ) |
|
534 { |
|
535 TInt strLength = 0; |
|
536 TTime currentLengthAsTime( aMicroSec.Int64() ); |
|
537 TTime maxLengthAsTime( iMaxDurationMicroSec.Int64() ); |
|
538 strLength = iTimeDuratBase->Length() ; |
|
539 |
|
540 if ( !iLengthNow ) |
|
541 { |
|
542 iLengthNow = HBufC::NewL( strLength ); |
|
543 } |
|
544 |
|
545 TPtr lnow(iLengthNow->Des()); |
|
546 currentLengthAsTime.FormatL( lnow, *iTimeDuratBase); |
|
547 |
|
548 if ( !iLengthMax) |
|
549 { |
|
550 iLengthMax = HBufC::NewL( strLength ); |
|
551 } |
|
552 |
|
553 TPtr lmax( iLengthMax->Des() ); |
|
554 maxLengthAsTime.FormatL( lmax, *iTimeDuratBase); |
|
555 |
|
556 HBufC* tempBuf = NULL; |
|
557 switch ( aText ) |
|
558 { |
|
559 case R_AUDIOMESSAGE_PROGRESS_PLAYING: |
|
560 tempBuf = iTextPlaying; |
|
561 break; |
|
562 case R_AUDIOMESSAGE_PROGRESS_RECORDING: |
|
563 tempBuf = iTextRecording; |
|
564 break; |
|
565 case R_AUDIOMESSAGE_PROGRESS_PAUSED: |
|
566 tempBuf = iTextPaused; |
|
567 break; |
|
568 // Coverty fix, Forward NULL; http://ousrv057/cov.cgi?cid=35851 |
|
569 default: |
|
570 tempBuf = iTextPlaying; |
|
571 break; |
|
572 } |
|
573 |
|
574 strLength += tempBuf->Length(); |
|
575 TPtr tempBuff( tempBuf->Des() ); |
|
576 HBufC* baseText = HBufC::NewLC( strLength ); |
|
577 TPtr baset( baseText->Des() ); |
|
578 HBufC* texts = HBufC::NewLC( strLength ); |
|
579 TPtr pText( texts->Des() ); |
|
580 |
|
581 StringLoader::Format( baset,tempBuff, 1, lmax ); |
|
582 StringLoader::Format( pText,baset, 0, lnow ); |
|
583 |
|
584 AknTextUtils::LanguageSpecificNumberConversion( pText ); |
|
585 |
|
586 this->SetTextL( pText ); |
|
587 |
|
588 CleanupStack::PopAndDestroy( texts ); |
|
589 CleanupStack::PopAndDestroy( baseText ); |
|
590 } |
|
591 |
|
592 // --------------------------------------------------------- |
|
593 // CAudioMessageProgressDialog::PauseL |
|
594 // --------------------------------------------------------- |
|
595 // |
|
596 void CAudioMessageProgressDialog::PauseL() |
|
597 { |
|
598 iFlags |= EAmsPause; |
|
599 iPausePosMicroSec = iRecorder->GetPosition().Int64(); |
|
600 iRecorder->Pause(); |
|
601 UpdateProgressTextL( R_AUDIOMESSAGE_PROGRESS_PAUSED, iPausePosMicroSec ); |
|
602 SetProgressIconL( EMbmAudiomessageQgn_indi_mms_audio_pause, |
|
603 EMbmAudiomessageQgn_indi_mms_audio_pause_mask ); |
|
604 SetSoftkeys( R_SOFTKEYS_CONTINUE_STOP ); |
|
605 } |
|
606 |
|
607 // --------------------------------------------------------- |
|
608 // CAudioMessageProgressDialog::ContinueL |
|
609 // --------------------------------------------------------- |
|
610 // |
|
611 void CAudioMessageProgressDialog::ContinueL() |
|
612 { |
|
613 iFlags &= ~EAmsPause; |
|
614 iRecorder->ContinueL(); |
|
615 UpdateProgressTextL( R_AUDIOMESSAGE_PROGRESS_PAUSED, iPausePosMicroSec ); |
|
616 SetProgressIconL( EMbmAudiomessageQgn_indi_mms_audio_record, |
|
617 EMbmAudiomessageQgn_indi_mms_audio_record_mask ); |
|
618 SetSoftkeys( R_SOFTKEYS_PAUSE_STOP ); |
|
619 } |
|
620 |
|
621 // --------------------------------------------------------- |
|
622 // CAudioMessageProgressDialog::SetSoftkeys |
|
623 // --------------------------------------------------------- |
|
624 // |
|
625 void CAudioMessageProgressDialog::SetSoftkeys( TInt aSk ) |
|
626 { |
|
627 CEikButtonGroupContainer* cba; |
|
628 cba = CEikButtonGroupContainer::Current(); |
|
629 TRAP_IGNORE( cba->SetCommandSetL( aSk ) ); |
|
630 cba->DrawNow(); |
|
631 } |
|
632 |
|
633 // --------------------------------------------------------- |
|
634 // CAudioMessageProgressDialog::SetProgressIconL |
|
635 // Sets play, rec and pause icon |
|
636 // --------------------------------------------------------- |
|
637 // |
|
638 void CAudioMessageProgressDialog::SetProgressIconL( TInt aIconId, TInt aIconMask ) |
|
639 { |
|
640 CEikImage* icon = NULL; |
|
641 icon = new ( ELeave ) CEikImage; |
|
642 CleanupStack::PushL( icon ); |
|
643 TParse fileParse; |
|
644 fileParse.Set( KAmsBitmapFileName, &KDC_APP_BITMAP_DIR, NULL ); |
|
645 icon->CreatePictureFromFileL( fileParse.FullName(), aIconId, aIconMask ); |
|
646 this->SetIconL( icon ); |
|
647 CleanupStack::Pop( icon ); |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------- |
|
651 // CAudioMessageProgressDialog::ToLoudspeaker |
|
652 // Sets audio route loudspeaker |
|
653 // --------------------------------------------------------- |
|
654 // |
|
655 void CAudioMessageProgressDialog::ToLoudspeaker() |
|
656 { |
|
657 iFlags &= ~EAmsAudioOutputEarpiece; |
|
658 if ( iRecorder->SetAudioOutput( ETrue ) == KErrNone ) |
|
659 { |
|
660 iNaviVolObserver->SetSpeakerOutput( iFlags & EAmsAudioOutputEarpiece ); |
|
661 SetSoftkeys( R_SOFTKEYS_TO_EARPIECE_STOP ); |
|
662 } |
|
663 else |
|
664 { |
|
665 iFlags |= EAmsAudioOutputEarpiece; |
|
666 } |
|
667 |
|
668 } |
|
669 |
|
670 // --------------------------------------------------------- |
|
671 // CAudioMessageProgressDialog::ToEarpiece |
|
672 // Sets audio route earpiece |
|
673 // --------------------------------------------------------- |
|
674 // |
|
675 void CAudioMessageProgressDialog::ToEarpiece() |
|
676 { |
|
677 iFlags |= EAmsAudioOutputEarpiece; |
|
678 |
|
679 if ( iRecorder->SetAudioOutput( EFalse ) == KErrNone) |
|
680 { |
|
681 iNaviVolObserver->SetSpeakerOutput( iFlags & EAmsAudioOutputEarpiece ); |
|
682 SetSoftkeys( R_SOFTKEYS_TO_LOUDSPEAKER_STOP ); |
|
683 } |
|
684 else |
|
685 { |
|
686 iFlags &= ~EAmsAudioOutputEarpiece; |
|
687 |
|
688 } |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------- |
|
692 // CAudioMessageProgressDialog::PlayingStops |
|
693 // --------------------------------------------------------- |
|
694 // |
|
695 void CAudioMessageProgressDialog::PlayingStops() |
|
696 { |
|
697 iFlags |= EAmsSetExit; |
|
698 TRAP_IGNORE( iRecorder->StopL()); |
|
699 // Try to exit dialog cleanly. If that doesn't work, |
|
700 // then terminate anyway. |
|
701 TRAPD( err, TryExitL( EAmsFileEnd ) ); |
|
702 if ( err != KErrNone ) |
|
703 { |
|
704 delete this; |
|
705 } |
|
706 } |
|
707 |
|
708 // --------------------------------------------------------- |
|
709 // CAudioMessageProgressDialog::OfferKeyEventL |
|
710 // --------------------------------------------------------- |
|
711 // |
|
712 TKeyResponse CAudioMessageProgressDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
713 TEventCode aType ) |
|
714 { |
|
715 if ( !(iFlags & EAmsWorkingModeRecorder ))//playing in progress |
|
716 { |
|
717 if ( ( aKeyEvent.iCode == EKeyLeftArrow ) ) |
|
718 { |
|
719 iChange = KVolumeChangeDown; |
|
720 DoChangeVolumeL(); |
|
721 return EKeyWasConsumed; |
|
722 } |
|
723 if ( ( aKeyEvent.iCode == EKeyRightArrow)) |
|
724 { |
|
725 iChange = KVolumeChangeUp; |
|
726 DoChangeVolumeL(); |
|
727 return EKeyWasConsumed; |
|
728 } |
|
729 if ( aKeyEvent.iCode == EKeyUpArrow ) |
|
730 { |
|
731 return EKeyWasConsumed; |
|
732 } |
|
733 if ( aKeyEvent.iCode == EKeyDownArrow) |
|
734 { |
|
735 return EKeyWasConsumed; |
|
736 } |
|
737 if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyOK ) |
|
738 { |
|
739 if ( !(iFlags & EAmsSupportAudioOutput) ) |
|
740 { |
|
741 iFlags |= EAmsWsEventStop; |
|
742 } |
|
743 else |
|
744 { |
|
745 if ( iFlags & EAmsAudioOutputEarpiece ) |
|
746 { |
|
747 ToLoudspeaker(); |
|
748 } |
|
749 else |
|
750 { |
|
751 ToEarpiece(); |
|
752 } |
|
753 } |
|
754 return EKeyWasConsumed; |
|
755 } |
|
756 |
|
757 } |
|
758 else if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyOK ) |
|
759 { |
|
760 if ( iFlags & EAmsPause ) |
|
761 { |
|
762 ContinueL(); |
|
763 } |
|
764 else |
|
765 { |
|
766 PauseL(); |
|
767 } |
|
768 return EKeyWasConsumed; |
|
769 } |
|
770 |
|
771 if ( aKeyEvent.iCode == EKeyUpArrow ) |
|
772 { |
|
773 return EKeyWasConsumed; |
|
774 } |
|
775 if ( aKeyEvent.iCode == EKeyDownArrow ) |
|
776 { |
|
777 return EKeyWasConsumed; |
|
778 } |
|
779 |
|
780 return CAknProgressDialog::OfferKeyEventL( aKeyEvent,aType ); |
|
781 } |
|
782 |
|
783 // --------------------------------------------------------- |
|
784 // CAudioMessageProgressDialog::SetNaviObserver |
|
785 // --------------------------------------------------------- |
|
786 // |
|
787 void CAudioMessageProgressDialog::SetNaviObserver( MAmsVolumeObserver* aObserver ) |
|
788 { |
|
789 iNaviVolObserver = aObserver; |
|
790 } |
|
791 |
|
792 // --------------------------------------------------------- |
|
793 // CAudioMessageProgressDialog::SetMaxMessageSize |
|
794 // --------------------------------------------------------- |
|
795 // |
|
796 void CAudioMessageProgressDialog::SetMaxMessageSize( TUint aSize ) |
|
797 { |
|
798 iMaxMessageSize = aSize; |
|
799 } |
|
800 |
|
801 // --------------------------------------------------------- |
|
802 // CAudioMessageProgressDialog::MrccatoCommand |
|
803 // Handles side volume key events. |
|
804 // --------------------------------------------------------- |
|
805 // |
|
806 void CAudioMessageProgressDialog::MrccatoCommand( TRemConCoreApiOperationId aOperationId, |
|
807 TRemConCoreApiButtonAction aButtonAct ) |
|
808 { |
|
809 if ( iFlags & EAmsWorkingModeRecorder ) |
|
810 { |
|
811 return; |
|
812 } |
|
813 |
|
814 TRequestStatus stat; |
|
815 |
|
816 switch ( aOperationId ) |
|
817 { |
|
818 case ERemConCoreApiVolumeDown: // Volume Down |
|
819 switch ( aButtonAct ) |
|
820 { |
|
821 case ERemConCoreApiButtonPress: |
|
822 // Volume up hold down for 0,6 seconds |
|
823 iChange = KVolumeChangeDown; |
|
824 iVolumeTimer->Cancel(); |
|
825 iVolumeTimer->Start( KVolumeFirstChangePeriod, |
|
826 KVolumeChangePeriod, |
|
827 TCallBack( ChangeVolume, this ) ); |
|
828 break; |
|
829 case ERemConCoreApiButtonRelease: |
|
830 iVolumeTimer->Cancel(); |
|
831 break; |
|
832 case ERemConCoreApiButtonClick: |
|
833 iChange = KVolumeChangeDown; |
|
834 TRAP_IGNORE( DoChangeVolumeL() ); |
|
835 |
|
836 break; |
|
837 default: |
|
838 // Never hits this |
|
839 break; |
|
840 } |
|
841 iCoreTarget->VolumeDownResponse(stat, KErrNone); |
|
842 break; |
|
843 case ERemConCoreApiVolumeUp: // Volume Up |
|
844 switch ( aButtonAct ) |
|
845 { |
|
846 case ERemConCoreApiButtonPress: |
|
847 // Volume down hold for 0,6 seconds |
|
848 iChange = KVolumeChangeUp; |
|
849 iVolumeTimer->Cancel(); |
|
850 iVolumeTimer->Start( KVolumeFirstChangePeriod, |
|
851 KVolumeChangePeriod, |
|
852 TCallBack( ChangeVolume, this ) ); |
|
853 |
|
854 break; |
|
855 case ERemConCoreApiButtonRelease: |
|
856 iVolumeTimer->Cancel(); |
|
857 break; |
|
858 case ERemConCoreApiButtonClick: |
|
859 iChange = KVolumeChangeUp; |
|
860 TRAP_IGNORE( DoChangeVolumeL() ); |
|
861 break; |
|
862 default: |
|
863 // Never hits this |
|
864 break; |
|
865 } |
|
866 iCoreTarget->VolumeUpResponse(stat, KErrNone); |
|
867 break; |
|
868 default : |
|
869 iCoreTarget->SendResponse( stat, aOperationId, KErrNone ); |
|
870 break; |
|
871 } |
|
872 User::WaitForRequest( stat ); |
|
873 |
|
874 } |
|
875 |
|
876 // --------------------------------------------------------- |
|
877 // CAudioMessageProgressDialog::ChangeVolume |
|
878 // --------------------------------------------------------- |
|
879 // |
|
880 TInt CAudioMessageProgressDialog::ChangeVolume( TAny* aObject ) |
|
881 { |
|
882 // cast, and call non-static function |
|
883 TRAP_IGNORE( static_cast<CAudioMessageProgressDialog*>( aObject )->DoChangeVolumeL( )); |
|
884 return KErrNone; |
|
885 } |
|
886 |
|
887 // --------------------------------------------------------- |
|
888 // CAudioMessageProgressDialog::DoChangeVolumeL |
|
889 // --------------------------------------------------------- |
|
890 // |
|
891 void CAudioMessageProgressDialog::DoChangeVolumeL( ) |
|
892 { |
|
893 if ( iChange == KVolumeChangeUp ) |
|
894 { |
|
895 if ( iCurrentVolume + KSeed > KMaxVol ) |
|
896 { |
|
897 iAvkonAppUi->KeySounds()->PlaySound( EAvkonSIDVolumeMaxTone ); |
|
898 } |
|
899 else |
|
900 { |
|
901 iCurrentVolume++; |
|
902 } |
|
903 iNaviVolObserver->UpdateNaviVol( iCurrentVolume ); |
|
904 iRecorder->IncrementVol(); |
|
905 } |
|
906 else |
|
907 { |
|
908 if ( iCurrentVolume - KSeed < KMinVol ) |
|
909 { |
|
910 iAvkonAppUi->KeySounds()->PlaySound( EAvkonSIDVolumeMinTone ); |
|
911 } |
|
912 else |
|
913 { |
|
914 iCurrentVolume--; |
|
915 } |
|
916 iNaviVolObserver->UpdateNaviVol( iCurrentVolume ); |
|
917 iRecorder->DecrementVol(); |
|
918 } |
|
919 iVolumePopup->SetValue( iCurrentVolume ); |
|
920 iVolumePopup->ShowVolumePopupL(); |
|
921 } |
|
922 |
|
923 |
|
924 #ifdef RD_SCALABLE_UI_V2 |
|
925 // ----------------------------------------------------------------------------- |
|
926 // handles the touch-ui related control events for the volume arrows |
|
927 // ----------------------------------------------------------------------------- |
|
928 // |
|
929 void CAudioMessageProgressDialog::HandleNaviDecoratorEventL( TInt aEventID ) |
|
930 { |
|
931 if( aEventID == EAknNaviDecoratorEventRightTabArrow ) |
|
932 { |
|
933 iChange = KVolumeChangeUp; |
|
934 DoChangeVolumeL(); |
|
935 } |
|
936 else // LeftTabArrow |
|
937 { |
|
938 iChange = KVolumeChangeDown; |
|
939 DoChangeVolumeL(); |
|
940 } |
|
941 } |
|
942 |
|
943 // ----------------------------------------------------------------------------- |
|
944 // handles the touch-ui related control events coming from the volume bar |
|
945 // ----------------------------------------------------------------------------- |
|
946 // |
|
947 void CAudioMessageProgressDialog::HandleControlEventL( |
|
948 CCoeControl* aControl, |
|
949 TCoeEvent aEventType ) |
|
950 { |
|
951 if((aControl == iVolumePopup) |
|
952 && ( aEventType == MCoeControlObserver::EEventStateChanged) |
|
953 ) |
|
954 { |
|
955 iCurrentVolume = iVolumePopup->Value(); |
|
956 iRecorder->SetVol( iCurrentVolume ); |
|
957 iNaviVolObserver->UpdateNaviVol( iCurrentVolume ); |
|
958 } |
|
959 } |
|
960 |
|
961 void CAudioMessageProgressDialog::SetVolCtrlObserver( MCoeControlObserver& aObserver ) |
|
962 { |
|
963 iVolCtrlObserver = &aObserver; |
|
964 } |
|
965 |
|
966 #else |
|
967 void CAudioMessageProgressDialog::HandleNaviDecoratorEventL( TInt /* aEventID */ ) |
|
968 { |
|
969 } |
|
970 |
|
971 void CAudioMessageProgressDialog::HandleControlEventL( CCoeControl* /*aControl*/, |
|
972 TCoeEvent /* aEventType */ ) |
|
973 { |
|
974 } |
|
975 void CAudioMessageProgressDialog::SetVolCtrlObserver( MCoeControlObserver& |
|
976 /*aObserver*/ ) |
|
977 { |
|
978 } |
|
979 |
|
980 #endif |