1 /* |
|
2 * Copyright (c) 2002 - 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: |
|
15 * This class is the data model and state machine of the Recorder View. |
|
16 * The state machine is defined by a VR_STATEMACHINE resource structure. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <bldvariant.hrh> |
|
24 #include <e32cmn.h> |
|
25 #include <ctsydomainpskeys.h> |
|
26 #include <UsbWatcherInternalPSKeys.h> |
|
27 #include <usbpersonalityids.h> |
|
28 #include <barsread.h> |
|
29 #include <eikenv.h> |
|
30 #include <eikappui.h> |
|
31 #include <avkon.rsg> |
|
32 #include <StringLoader.h> |
|
33 #include <bautils.h> |
|
34 #include <avkon.hrh> // Key definitions |
|
35 #include <AknGlobalNote.h> |
|
36 #include <sendui.h> |
|
37 #include <AknLayoutDef.h> |
|
38 #include <AknUtils.h> |
|
39 #include <featmgr.h> |
|
40 #include <data_caging_path_literals.hrh> |
|
41 #include <CMessageData.h> |
|
42 |
|
43 #include <featmgr.h> // Feature manager |
|
44 #include <SendUiConsts.h> // Disable e-mail |
|
45 #include "MessagingDomainCRKeys.h" // Disable e-mail variation flag |
|
46 |
|
47 #include <centralrepository.h> // link against centralrepository.lib |
|
48 #include "VoiceRecorderInternalCRKeys.h" |
|
49 |
|
50 #include <voicerecorder.rsg> |
|
51 #include "CVRMemo.h" |
|
52 #include "TVRState.h" |
|
53 #include "CVRMdaRecorder.h" |
|
54 #include "VRConsts.h" |
|
55 #include "CVRSystemEventHandler.h" |
|
56 #include "CVRUSBEventHandler.h" |
|
57 #include "VRUtils.h" |
|
58 #include "CVRRecViewModel.h" |
|
59 #include <csxhelp/vorec.hlp.hrh> |
|
60 |
|
61 |
|
62 // CONSTANTS |
|
63 const TInt KAllowInCallRecording( 1 ); |
|
64 |
|
65 // Shown if maximum recording time is not known |
|
66 _LIT( KVRBeforeFirstEstimateLabel, "--:--:--" ); |
|
67 // MMS/High text is inserted here |
|
68 _LIT( placeForQuality, "%U" ); |
|
69 |
|
70 |
|
71 // ================= MEMBER FUNCTIONS ======================================== |
|
72 // --------------------------------------------------------------------------- |
|
73 // CVRRecViewModel::CVRRecViewModel |
|
74 // |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CVRRecViewModel::CVRRecViewModel() |
|
78 : iStateArray( 2 ), |
|
79 iLabelSets( 2 ), |
|
80 iPreviousCallState( EPSCTsyCallStateNone ), |
|
81 iCanHandleCommands( ETrue ), |
|
82 iCBAEnabled( ETrue ) |
|
83 { |
|
84 } |
|
85 |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CVRRecViewModel::~CVRRecViewModel |
|
89 // |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 CVRRecViewModel::~CVRRecViewModel() |
|
93 { |
|
94 // It might be possible to make this method leaving and put it |
|
95 // somewhere else than destructor |
|
96 SaveVolumeSettings(); |
|
97 iLabelSets.ResetAndDestroy(); |
|
98 iStateArray.Reset(); |
|
99 |
|
100 delete[] iLabelLayoutLinks; |
|
101 delete iMemo; |
|
102 delete iRecorder; |
|
103 if ( iGlobalNote && iIsNoteLaunched ) |
|
104 { |
|
105 // nothing much to do but ignore. |
|
106 TRAP_IGNORE( iGlobalNote->CancelNoteL( iNoteId ) ); |
|
107 } |
|
108 |
|
109 delete iGlobalNote; |
|
110 |
|
111 if (iCurrentCallHandler) |
|
112 { |
|
113 delete iCurrentCallHandler; |
|
114 } |
|
115 |
|
116 delete iCurrentUSBHandler; |
|
117 |
|
118 } |
|
119 |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CVRRecViewModel::ConstructFromResourceL |
|
123 // |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CVRRecViewModel::ConstructFromResourceL( TResourceReader& aReader ) |
|
127 { |
|
128 |
|
129 TRAP_IGNORE( iCurrentCallHandler = CVRSystemEventHandler::NewL() ); |
|
130 iCurrentCallHandler->Listen( KPSUidCtsyCallInformation, KCTsyCallState, |
|
131 this ); |
|
132 |
|
133 // for USB |
|
134 iCurrentUSBHandler = CVRUSBEventHandler::NewL(); |
|
135 iCurrentUSBHandler->Listen( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, |
|
136 this ); |
|
137 |
|
138 |
|
139 if ( FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ) && |
|
140 FeatureManager::FeatureSupported( |
|
141 KFeatureIdApplicationControllableAudioRouting ) ) |
|
142 { |
|
143 ReadDefaultSpeakerL(); |
|
144 } |
|
145 else |
|
146 { |
|
147 iIhfState = ETrue; |
|
148 } |
|
149 |
|
150 LoadVolumeSettingsL(); |
|
151 // Connecting and initialization: |
|
152 CRepository* myRepSession = CRepository::NewLC( KCRUidVoiceRecorder ); |
|
153 |
|
154 // Get the values from the repository |
|
155 User::LeaveIfError( myRepSession->Get( KVRDefaultAudioFormat, |
|
156 iVRAudioFormat ) ); |
|
157 |
|
158 User::LeaveIfError( myRepSession->Get( KVRAllowInCallRecording, |
|
159 iVRAllowInCallRecording ) ); |
|
160 CleanupStack::PopAndDestroy( myRepSession ); |
|
161 |
|
162 iGlobalNote = CAknGlobalNote::NewL(); |
|
163 |
|
164 iMemo = new( ELeave ) CVRMemo; |
|
165 iMemo->ConstructL( iVRAudioFormat ); |
|
166 |
|
167 TInt numLabelSets( aReader.ReadInt16() ); |
|
168 TInt i; |
|
169 |
|
170 for ( i = 0; i < numLabelSets; i++ ) |
|
171 { |
|
172 CDesCArray* labelSet; |
|
173 TInt numLabels( aReader.ReadInt16() ); |
|
174 |
|
175 if ( numLabels > 0 ) |
|
176 { |
|
177 // TResourceReader re-reads the length, have to rewind |
|
178 aReader.Rewind( sizeof( TInt16 ) ); |
|
179 labelSet = aReader.ReadDesCArrayL(); |
|
180 } |
|
181 else |
|
182 { |
|
183 // create an empty array "by hand", |
|
184 // TResourceReader is not able to do this |
|
185 labelSet = new( ELeave ) CDesCArrayFlat( 1 ); |
|
186 } |
|
187 |
|
188 CleanupStack::PushL( labelSet ); |
|
189 iLabelSets.AppendL( labelSet ); |
|
190 CleanupStack::Pop( labelSet); |
|
191 } |
|
192 |
|
193 TInt linkCount( aReader.ReadInt16() ); |
|
194 iLabelLayoutLinks = new( ELeave ) TVRLabelLayoutLink[ linkCount ]; |
|
195 for ( i = 0; i < linkCount; i++ ) |
|
196 { |
|
197 iLabelLayoutLinks[ i ].ReadFromResource( aReader ); |
|
198 } |
|
199 |
|
200 TInt numUiStates( aReader.ReadInt16() ); |
|
201 |
|
202 TVRState uistate; |
|
203 for ( i = 0; i < numUiStates; i++ ) |
|
204 { |
|
205 uistate.ReadFromResource( aReader ); |
|
206 uistate.iId = i; |
|
207 iStateArray.AppendL( uistate ); |
|
208 } |
|
209 |
|
210 iState = &iStateArray.At( 0 ); |
|
211 |
|
212 TInt numContexts( aReader.ReadInt16() ); |
|
213 for ( i = 0; i < numContexts; i++ ) |
|
214 { |
|
215 TInt id( aReader.ReadInt8() ); |
|
216 TVRContext* context = &iContexts[ id ]; |
|
217 context->iValid = ETrue; |
|
218 context->iInitialTransition.iCommandId = aReader.ReadUint8(); |
|
219 context->iInitialTransition.iNewState = aReader.ReadUint8(); |
|
220 context->iInitialTransition.iFunctionId = aReader.ReadUint8(); |
|
221 context->iInitialTransition.iValid = ETrue; |
|
222 |
|
223 |
|
224 TInt numStates( aReader.ReadInt16() ); |
|
225 for ( TInt j = 0; j < numStates; j++ ) |
|
226 { |
|
227 TInt id( aReader.ReadInt8() ); |
|
228 TVRContext::TState* state = &context->iStates[ id ]; |
|
229 state->iValid = ETrue; |
|
230 TInt numTransitions( aReader.ReadInt16() ); |
|
231 __ASSERT_DEBUG( numTransitions <= KVRMaxTransitions, |
|
232 User::Panic( KVRPanic, EPanicTooManyTransitions ) ); |
|
233 |
|
234 for ( TInt k = 0; k < numTransitions; k++ ) |
|
235 { |
|
236 TVRContext::TTransition* trans = &state->iTransitions[ k ]; |
|
237 trans->iCommandId = aReader.ReadUint8(); |
|
238 trans->iNewState = aReader.ReadUint8(); |
|
239 trans->iFunctionId = aReader.ReadUint8(); |
|
240 trans->iValid = ETrue; |
|
241 } |
|
242 } |
|
243 } |
|
244 |
|
245 StringLoader::Load( iDateUsualWithZero, R_QTN_DATE_USUAL_WITH_ZERO ); |
|
246 StringLoader::Load( iTimeUsualWithZero, R_QTN_TIME_USUAL_WITH_ZERO ); |
|
247 StringLoader::Load( iTimeDuratLong, R_QTN_TIME_DURAT_LONG ); |
|
248 StringLoader::Load( iTimeDuratMinSecWithZero, |
|
249 R_QTN_TIME_DURAT_MIN_SEC_WITH_ZERO ); |
|
250 |
|
251 |
|
252 |
|
253 } |
|
254 |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CVRRecViewModel::ProcessKeyEventL |
|
258 // |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 TBool CVRRecViewModel::ProcessKeyEventL( const TKeyEvent& aKeyEvent, |
|
262 const TEventCode aType ) |
|
263 { |
|
264 TBool retval( EFalse ); |
|
265 if ( aType != EEventKey ) |
|
266 { |
|
267 return retval; |
|
268 } |
|
269 |
|
270 switch ( aKeyEvent.iCode ) |
|
271 { |
|
272 case EKeyPhoneEnd: |
|
273 { |
|
274 TInt currentState( iCurrentCallHandler->StateL(KPSUidCtsyCallInformation, KCTsyCallState) ); |
|
275 |
|
276 if ( ( currentState != EPSCTsyCallStateNone ) ) |
|
277 { |
|
278 HandleCommandL( ECmdDisconnectCall ); |
|
279 retval = EKeyWasNotConsumed; |
|
280 } |
|
281 else |
|
282 { |
|
283 // Voice recorder wasn't here =), retval stays EFalse |
|
284 iIsEndKey = ETrue; |
|
285 |
|
286 // Exit if app is not fully initialized |
|
287 if ( !iContextEntered ) |
|
288 { |
|
289 CEikonEnv::Static()->EikAppUi()-> |
|
290 HandleCommandL( EEikCmdExit ); |
|
291 } |
|
292 } |
|
293 break; |
|
294 } |
|
295 case EKeyBackspace: |
|
296 { |
|
297 HandleCommandL( ECmdDelete ); |
|
298 retval = ETrue; |
|
299 break; |
|
300 } |
|
301 case EKeyYes: |
|
302 { |
|
303 if( aKeyEvent.iRepeats > 0 ) |
|
304 { |
|
305 if( VisualStateId() == EStateRecording || |
|
306 VisualStateId() == EStatePlaying ) |
|
307 { |
|
308 HandleCommandL( ECmdPause ); |
|
309 } |
|
310 } |
|
311 break; |
|
312 } |
|
313 case EKeySide: |
|
314 { |
|
315 retval = ETrue; |
|
316 |
|
317 if ( aKeyEvent.iRepeats ) |
|
318 { |
|
319 switch ( iState->iId ) |
|
320 { |
|
321 case EStateIdle: |
|
322 { |
|
323 HandleCommandL( ECmdPlay ); |
|
324 break; |
|
325 } |
|
326 case EStateRecording: |
|
327 case EStateRecordEmbedded: |
|
328 case EStateRecordingPaused: |
|
329 case EStatePlaying: |
|
330 case EStatePlayingPaused: |
|
331 { |
|
332 HandleCommandL( ECmdStop ); |
|
333 break; |
|
334 } |
|
335 case EStateDeleted: |
|
336 default: |
|
337 { |
|
338 retval = EFalse; |
|
339 break; |
|
340 } |
|
341 } |
|
342 } |
|
343 else |
|
344 { |
|
345 switch ( iState->iId ) |
|
346 { |
|
347 case EStateIdle: |
|
348 case EStateDeleted: |
|
349 case EStateRecordingPaused: |
|
350 { |
|
351 HandleCommandL( ECmdRecord ); |
|
352 break; |
|
353 } |
|
354 case EStateRecording: |
|
355 case EStateRecordEmbedded: |
|
356 case EStatePlaying: |
|
357 { |
|
358 HandleCommandL( ECmdPause ); |
|
359 break; |
|
360 } |
|
361 case EStatePlayingPaused: |
|
362 { |
|
363 HandleCommandL( ECmdPlay ); |
|
364 break; |
|
365 } |
|
366 default: |
|
367 { |
|
368 retval = EFalse; |
|
369 break; |
|
370 } |
|
371 } |
|
372 } |
|
373 break; |
|
374 } |
|
375 default: |
|
376 { |
|
377 break; |
|
378 } |
|
379 } |
|
380 return retval; |
|
381 } |
|
382 |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // CVRRecViewModel::HandleCommandL |
|
386 // |
|
387 // --------------------------------------------------------------------------- |
|
388 // |
|
389 void CVRRecViewModel::HandleCommandL( TInt aCommandId ) |
|
390 { |
|
391 // This command must be acceptable all times. |
|
392 if ( aCommandId == ECmdCancelNote ) |
|
393 { |
|
394 if ( iIsNoteLaunched ) |
|
395 { |
|
396 // nothing much to do but ignore. |
|
397 TRAP_IGNORE( iGlobalNote->CancelNoteL( iNoteId ) ); |
|
398 } |
|
399 return; |
|
400 } |
|
401 |
|
402 if ( !CanAcceptCommands() ) |
|
403 { |
|
404 return; |
|
405 } |
|
406 |
|
407 if ( !CanHandleCommands() ) |
|
408 { |
|
409 return; |
|
410 } |
|
411 if ( EStateRecording == iState->iId && ECmdRecord == aCommandId || |
|
412 EStateRecording == iState->iId && ECmdRename == aCommandId ) |
|
413 { |
|
414 return; |
|
415 } |
|
416 |
|
417 switch ( aCommandId ) |
|
418 { |
|
419 case ECmdHelp: |
|
420 { |
|
421 CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId ); |
|
422 break; |
|
423 } |
|
424 case EEikCmdExit: |
|
425 { |
|
426 CEikonEnv::Static()->EikAppUi()->HandleCommandL( EAknSoftkeyExit); |
|
427 break; |
|
428 } |
|
429 |
|
430 case EAknSoftkeyExit: |
|
431 { |
|
432 CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId ); |
|
433 break; |
|
434 } |
|
435 case ECmdSendVia: |
|
436 { |
|
437 CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId ); |
|
438 break; |
|
439 } |
|
440 case ECmdSaveAttachment: |
|
441 { |
|
442 __ASSERT_DEBUG( iRecorder, User::Panic( KVRPanic, KErrNotFound ) ); |
|
443 iRecorder->DetachMemo(); |
|
444 // Save permanently but do not remove the original |
|
445 |
|
446 HBufC* label = StringLoader::LoadLC( R_VR_SAVE_WAITNOTE_LABEL ); |
|
447 |
|
448 iIsNoteLaunched = ETrue; |
|
449 iMemo->SavePermanentlyL( iGlobalNote, iNoteId, *label, ETrue ); |
|
450 |
|
451 if ( iStateInfoObserver ) |
|
452 { |
|
453 iStateInfoObserver->Update(); |
|
454 } |
|
455 iRecorder->AttachToMemoL( iMemo ); |
|
456 |
|
457 // Remove the waitnote |
|
458 iGlobalNote->CancelNoteL( iNoteId ); |
|
459 iIsNoteLaunched = EFalse; |
|
460 |
|
461 CleanupStack::PopAndDestroy( label ); |
|
462 break; |
|
463 } |
|
464 // FLOWTHROUGH |
|
465 // in case of end key, different command must be given to state |
|
466 // machine - recview gives ECmdAutoStopInterrupted |
|
467 case ECmdAutoStopInterrupted: |
|
468 { |
|
469 if ( iIsEndKey ) |
|
470 { |
|
471 aCommandId = ECmdEndKey; |
|
472 iIsEndKey = EFalse; |
|
473 } |
|
474 } |
|
475 // Other commands are given to the state machine |
|
476 default: |
|
477 { |
|
478 TVRContext::TTransition transition; |
|
479 GetTransition( transition, aCommandId ); |
|
480 TBool functionOK( ETrue ); |
|
481 TRAPD( err, functionOK = |
|
482 CallFunctionByIdL( transition.iFunctionId ) ); |
|
483 |
|
484 if ( err != KErrNone ) |
|
485 { |
|
486 // This is done to enable button events |
|
487 iCanHandleCommands = ETrue; |
|
488 } |
|
489 |
|
490 // We may have detached memo and we must reattach |
|
491 if ( err == KErrInUse ) |
|
492 { |
|
493 __ASSERT_DEBUG( iRecorder, |
|
494 User::Panic( KVRPanic, KErrNotFound ) ); |
|
495 iRecorder->AttachToMemoL( iMemo ); |
|
496 } |
|
497 |
|
498 if ( err == KErrNotReady && iIsNoteLaunched && iGlobalNote ) |
|
499 { |
|
500 // nothing much to do but ignore. |
|
501 TRAP_IGNORE( iGlobalNote->CancelNoteL( iNoteId ) ); |
|
502 } |
|
503 |
|
504 // If the disk gets full while saving, the next state is deleted |
|
505 if ( err == KErrDiskFull || err == KErrArgument ) |
|
506 { |
|
507 if ( iContext == EContextRecordNewNormal || |
|
508 iContext == EContextNormal || |
|
509 iContext == EContextEmptyNormal ) |
|
510 { |
|
511 ChangeState( EStateDeleted, ETrue ); |
|
512 } |
|
513 else |
|
514 { |
|
515 // In record new embedded context the UI is left in |
|
516 // idle state, so the memo must be attached |
|
517 // (EFunctionOK detaches it) |
|
518 __ASSERT_DEBUG( iRecorder, |
|
519 User::Panic( KVRPanic, KErrNotFound ) ); |
|
520 if(!dynamic_cast<CVRMdaRecorder*>(iRecorder)->IsAttachedToMemo()) |
|
521 { |
|
522 iRecorder->AttachToMemoL( iMemo ); |
|
523 } |
|
524 } |
|
525 |
|
526 if ( err == KErrDiskFull ) |
|
527 { |
|
528 // Maybe an error note should be shown |
|
529 return; |
|
530 } |
|
531 |
|
532 // Propagate to the error handler to show a note. |
|
533 User::Leave( err ); |
|
534 } |
|
535 else |
|
536 { |
|
537 // The LeaveIfError must be here because CallFunctionByIdL |
|
538 // might have called Exit() (leaving with -1002) and the |
|
539 // framework might be half-dead leading to access violation, |
|
540 // if the UI state is changed |
|
541 User::LeaveIfError( err ); |
|
542 if ( functionOK ) |
|
543 { |
|
544 // If the in-call recording disabling feature is active, |
|
545 // then the state of the UI will have to reflect that |
|
546 TUint newState(transition.iNewState); |
|
547 |
|
548 if ( iVRAllowInCallRecording != KAllowInCallRecording ) |
|
549 { |
|
550 TInt currentState( iCurrentCallHandler->StateL( KPSUidCtsyCallInformation, KCTsyCallState ) ); |
|
551 |
|
552 if ( currentState != EPSCTsyCallStateNone ) |
|
553 { |
|
554 currentState = iCurrentCallHandler->StateL( |
|
555 KPSUidCtsyCallInformation, KCTsyCallType ); |
|
556 |
|
557 switch ( currentState ) |
|
558 { |
|
559 case EPSCTsyCallTypeCSVoice: |
|
560 case EPSCTsyCallTypeHSCSD: |
|
561 case EPSCTsyCallTypeH324Multimedia: |
|
562 case EPSCTsyCallTypeVoIP: |
|
563 { |
|
564 newState = EStateDisableButtons; |
|
565 break; |
|
566 } |
|
567 default: |
|
568 { |
|
569 break; |
|
570 } |
|
571 } |
|
572 |
|
573 } |
|
574 } |
|
575 |
|
576 // Function didn't want to cancel the state change |
|
577 ChangeState( newState ); |
|
578 } |
|
579 } |
|
580 |
|
581 break; |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // CVRRecViewModel::GetTransition |
|
589 // |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 void CVRRecViewModel::GetTransition( TVRContext::TTransition& aTransition, |
|
593 TUint aCommandId ) const |
|
594 { |
|
595 __ASSERT_DEBUG( iContexts[ iContext ].iValid, User::Panic( KVRPanic, |
|
596 EPanicInvalidContext ) ); |
|
597 __ASSERT_DEBUG( iContexts[ iContext ].iStates[ iState->iId ].iValid, |
|
598 User::Panic( KVRPanic, EPanicInvalidState ) ); |
|
599 |
|
600 const TVRContext::TState* state = |
|
601 &(iContexts[ iContext ].iStates[ iState->iId ]); |
|
602 for ( TInt i = 0; i < KVRMaxTransitions; i++ ) |
|
603 { |
|
604 const TVRContext::TTransition* transition = &state->iTransitions[ i ]; |
|
605 if ( ( transition->iCommandId == aCommandId ) && |
|
606 ( transition->iValid ) ) |
|
607 { |
|
608 aTransition = *transition; |
|
609 return; |
|
610 } |
|
611 } |
|
612 |
|
613 User::Panic( KVRPanic, EPanicInvalidTransition ); |
|
614 } |
|
615 |
|
616 |
|
617 // --------------------------------------------------------------------------- |
|
618 // CVRRecViewModel::GetTransition |
|
619 // |
|
620 // --------------------------------------------------------------------------- |
|
621 // |
|
622 void CVRRecViewModel::GetTransition( |
|
623 TVRContext::TTransition& aTransition ) const |
|
624 { |
|
625 aTransition = iContexts[ iContext ].iInitialTransition; |
|
626 } |
|
627 |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // CVRRecViewModel::ChangeState |
|
631 // |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 void CVRRecViewModel::ChangeState( TUint aNewState, TBool aForced ) |
|
635 { |
|
636 if ( !aForced ) |
|
637 { |
|
638 if ( ( aNewState == iState->iId ) || ( aNewState == EStateInitial ) ) |
|
639 { |
|
640 return; |
|
641 } |
|
642 } |
|
643 |
|
644 iState = &iStateArray.At( aNewState ); |
|
645 |
|
646 if ( iStateInfoObserver ) |
|
647 { |
|
648 iStateInfoObserver->Update(); |
|
649 } |
|
650 if ( iButtonPanelObserver ) |
|
651 { |
|
652 iResetButtons = ETrue; |
|
653 iButtonPanelObserver->Update( EVRUpdateStateChange ); |
|
654 } |
|
655 if ( iDecoratorObserver ) |
|
656 { |
|
657 iDecoratorObserver->Update(); |
|
658 } |
|
659 } |
|
660 |
|
661 |
|
662 // --------------------------------------------------------------------------- |
|
663 // CVRRecViewModel::EnterContextL |
|
664 // |
|
665 // --------------------------------------------------------------------------- |
|
666 // |
|
667 void CVRRecViewModel::EnterContextL( const TVRRecViewContexts& aContext ) |
|
668 { |
|
669 iContextEntered = EFalse; |
|
670 if ( iRecorder ) |
|
671 { |
|
672 delete iRecorder; |
|
673 iRecorder = NULL; |
|
674 } |
|
675 |
|
676 CVRMdaRecorder* recorder = new( ELeave ) CVRMdaRecorder(); |
|
677 CleanupStack::PushL( recorder ); |
|
678 recorder->ConstructL(); |
|
679 CleanupStack::Pop(); |
|
680 iRecorder = recorder; |
|
681 |
|
682 iRecorder->RegisterObserver( iStateInfoObserver ); |
|
683 iRecorder->SetAutoStopObserver( this ); |
|
684 |
|
685 LeaveContext(); |
|
686 iContext = aContext; |
|
687 |
|
688 iRecorder->AttachToMemoL(iMemo); |
|
689 |
|
690 TVRContext::TTransition transition; |
|
691 GetTransition( transition ); |
|
692 |
|
693 ChangeState( transition.iNewState, ETrue ); |
|
694 CallFunctionByIdL( transition.iFunctionId ); |
|
695 |
|
696 iContextEntered = ETrue; |
|
697 } |
|
698 |
|
699 |
|
700 // --------------------------------------------------------------------------- |
|
701 // CVRRecViewModel::LeaveContext |
|
702 // |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 void CVRRecViewModel::LeaveContext() |
|
706 { |
|
707 iContextEntered = EFalse; |
|
708 if( iRecorder ) |
|
709 { |
|
710 iRecorder->UnregisterObserver( iStateInfoObserver ); |
|
711 iRecorder->UnregisterObserver( iButtonPanelObserver ); |
|
712 |
|
713 iRecorder->DetachMemo(); |
|
714 |
|
715 iRecorder->RegisterObserver( iStateInfoObserver ); |
|
716 iRecorder->RegisterObserver( iButtonPanelObserver ); |
|
717 } |
|
718 } |
|
719 |
|
720 |
|
721 // --------------------------------------------------------------------------- |
|
722 // CVRRecViewModel::CbaResourceId |
|
723 // |
|
724 // --------------------------------------------------------------------------- |
|
725 // |
|
726 TInt CVRRecViewModel::CbaResourceId() const |
|
727 { |
|
728 return iState->iCbaResourceId; |
|
729 } |
|
730 |
|
731 |
|
732 // --------------------------------------------------------------------------- |
|
733 // CVRRecViewModel::GetHelpContext |
|
734 // |
|
735 // --------------------------------------------------------------------------- |
|
736 // |
|
737 void CVRRecViewModel::GetHelpContext( TCoeHelpContext& aContext ) const |
|
738 { |
|
739 if (FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
740 { |
|
741 if ( iState->iId == EStateDeleted ) |
|
742 { |
|
743 aContext.iContext = KVOREC_HLP_EMPTY_RECORDER; |
|
744 } |
|
745 else |
|
746 { |
|
747 aContext.iContext = KVOREC_HLP_MAIN; |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 // --------------------------------------------------------------------------- |
|
753 // CVRRecViewModel::SetDecoratorObserver |
|
754 // |
|
755 // --------------------------------------------------------------------------- |
|
756 // |
|
757 void CVRRecViewModel::SetDecoratorObserver( MVRObserver* aObserver ) |
|
758 { |
|
759 iDecoratorObserver = aObserver; |
|
760 } |
|
761 |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // CVRRecViewModel::MenuBarResourceId |
|
765 // |
|
766 // --------------------------------------------------------------------------- |
|
767 // |
|
768 TInt CVRRecViewModel::MenuBarResourceId() const |
|
769 { |
|
770 return iState->iMenubarResourceId; |
|
771 } |
|
772 |
|
773 |
|
774 // --------------------------------------------------------------------------- |
|
775 // CVRRecViewModel::ButtonCount |
|
776 // |
|
777 // --------------------------------------------------------------------------- |
|
778 // |
|
779 TInt CVRRecViewModel::ButtonCount() const |
|
780 { |
|
781 |
|
782 return iState->iButtonCount; |
|
783 } |
|
784 |
|
785 |
|
786 // --------------------------------------------------------------------------- |
|
787 // CVRRecViewModel::CBAEnabled |
|
788 // from MVRDecoratorModel |
|
789 // --------------------------------------------------------------------------- |
|
790 // |
|
791 TBool CVRRecViewModel::CBAEnabled() const |
|
792 { |
|
793 return iCBAEnabled; |
|
794 } |
|
795 |
|
796 |
|
797 // --------------------------------------------------------------------------- |
|
798 // CVRRecViewModel::ButtonState |
|
799 // Checks and returns whether the state of the button should be in active or |
|
800 // dimmed state. aButtonId tells the index of the button to be checked. Few |
|
801 // special cases (end and the beginning of the clip) can be handled here. |
|
802 // --------------------------------------------------------------------------- |
|
803 // |
|
804 TInt CVRRecViewModel::ButtonState( TInt aButtonId ) const |
|
805 { |
|
806 // Disable rewind button if there's nothing to rewind |
|
807 if ( aButtonId == EButtonRewind && |
|
808 ( Position().Int64() / KVRSecondAsMicroSeconds ) < 1 ) |
|
809 { |
|
810 return EDimmed; |
|
811 } |
|
812 |
|
813 // Disable forward button if position is at the end or the length of the |
|
814 // clip is smaller than 1 |
|
815 if ( aButtonId == EButtonForward && ( Position() == Duration() || |
|
816 ( Duration().Int64() / KVRSecondAsMicroSeconds ) < 1 ) ) |
|
817 { |
|
818 return EDimmed; |
|
819 } |
|
820 |
|
821 // Jeffery: the following ifs are temperary. they need to be removed after "Pause" is supported in plugin |
|
822 #ifdef __AAC_ENCODER_PLUGIN |
|
823 if ( iState->iId == EStateRecording && aButtonId == EButtonRecord && iMemo->Quality() == EQualityHigh) |
|
824 { |
|
825 return EDimmed; |
|
826 } |
|
827 #endif |
|
828 |
|
829 return iState->ButtonState( aButtonId ); |
|
830 } |
|
831 |
|
832 |
|
833 // --------------------------------------------------------------------------- |
|
834 // CVRRecViewModel::CommandId |
|
835 // |
|
836 // --------------------------------------------------------------------------- |
|
837 // |
|
838 TInt CVRRecViewModel::CommandId( TInt aButtonId ) const |
|
839 { |
|
840 return iState->ButtonCommandId( aButtonId ); |
|
841 } |
|
842 |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // CVRRecViewModel::InitialFocusButtonId |
|
846 // |
|
847 // --------------------------------------------------------------------------- |
|
848 // |
|
849 TInt CVRRecViewModel::InitialFocusButtonId() const |
|
850 { |
|
851 return iState->iFocusButtonId; |
|
852 } |
|
853 |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // CVRRecViewModel::SetButtonPanelObserver |
|
857 // |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 void CVRRecViewModel::SetButtonPanelObserver( MVRObserver* aObserver ) |
|
861 { |
|
862 if ( iRecorder ) |
|
863 { |
|
864 if ( iButtonPanelObserver ) |
|
865 { |
|
866 iRecorder->RegisterObserver( aObserver ); |
|
867 } |
|
868 else |
|
869 { |
|
870 iRecorder->UnregisterObserver( iButtonPanelObserver ); |
|
871 } |
|
872 } |
|
873 |
|
874 iButtonPanelObserver = aObserver; |
|
875 } |
|
876 |
|
877 |
|
878 // --------------------------------------------------------------------------- |
|
879 // CVRRecViewModel::ResetNeeded |
|
880 // |
|
881 // --------------------------------------------------------------------------- |
|
882 // |
|
883 TBool CVRRecViewModel::ResetNeeded() |
|
884 { |
|
885 if ( iResetButtons ) |
|
886 { |
|
887 iResetButtons = EFalse; |
|
888 return ETrue; |
|
889 } |
|
890 |
|
891 return iResetButtons; // EFalse always |
|
892 } |
|
893 |
|
894 |
|
895 // --------------------------------------------------------------------------- |
|
896 // CVRRecViewModel::VisualStateId() |
|
897 // Returns the id of VR current (visual) state |
|
898 // --------------------------------------------------------------------------- |
|
899 // |
|
900 TUint CVRRecViewModel::VisualStateId() const |
|
901 { |
|
902 return iState->iStateId; |
|
903 } |
|
904 |
|
905 |
|
906 // --------------------------------------------------------------------------- |
|
907 // CVRRecViewModel::CanHandleCommands() |
|
908 // Returns ETrue if model can handle new commands, EFalse otherwise |
|
909 // --------------------------------------------------------------------------- |
|
910 // |
|
911 TBool CVRRecViewModel::CanHandleCommands() const |
|
912 { |
|
913 return iCanHandleCommands; |
|
914 } |
|
915 |
|
916 |
|
917 // --------------------------------------------------------------------------- |
|
918 // CVRRecViewModel::Duration |
|
919 // |
|
920 // --------------------------------------------------------------------------- |
|
921 // |
|
922 TTimeIntervalMicroSeconds CVRRecViewModel::Duration() const |
|
923 { |
|
924 if ( ( iState->iId == EStateRecording ) || |
|
925 ( iState->iId == EStateRecordingPaused ) ) |
|
926 { |
|
927 return iMemo->MaxDuration(); |
|
928 } |
|
929 return iMemo->Duration(); |
|
930 } |
|
931 |
|
932 |
|
933 // --------------------------------------------------------------------------- |
|
934 // CVRRecViewModel::Position |
|
935 // |
|
936 // --------------------------------------------------------------------------- |
|
937 // |
|
938 TTimeIntervalMicroSeconds CVRRecViewModel::Position() const |
|
939 { |
|
940 if ( ( iState->iId == EStateRecording ) || |
|
941 ( iState->iId == EStateRecordingPaused ) ) |
|
942 { |
|
943 return iMemo->Duration(); |
|
944 } |
|
945 return iMemo->Position(); |
|
946 } |
|
947 |
|
948 |
|
949 // --------------------------------------------------------------------------- |
|
950 // CVRRecViewModel::GetLabel |
|
951 // Non-leaving version |
|
952 // --------------------------------------------------------------------------- |
|
953 // |
|
954 void CVRRecViewModel::GetLabel( TDes& aName, TInt aLabelIndex ) const |
|
955 { |
|
956 TRAP_IGNORE( GetLabelL( aName, aLabelIndex ) ); |
|
957 } |
|
958 |
|
959 |
|
960 // --------------------------------------------------------------------------- |
|
961 // CVRRecViewModel::GetLabelL |
|
962 // |
|
963 // --------------------------------------------------------------------------- |
|
964 // |
|
965 void CVRRecViewModel::GetLabelL( TDes& aName, TInt aLabelIndex ) const |
|
966 { |
|
967 if ( !iMemo->IsValid() ) |
|
968 { |
|
969 aName.SetLength( 0 ); |
|
970 return; |
|
971 } |
|
972 |
|
973 CDesCArray* labels = iLabelSets.At( iState->iLabelSetId ); |
|
974 User::LeaveIfNull( labels ); |
|
975 |
|
976 if ( aLabelIndex < labels->Count() ) |
|
977 { |
|
978 TInt index = aLabelIndex; |
|
979 |
|
980 TBuf< VRLABELMAXLENGTH > formatStr( |
|
981 labels->MdcaPoint( index ) ); |
|
982 TBuf< VRLABELMAXLENGTH > formattedTime; |
|
983 |
|
984 switch ( aLabelIndex ) |
|
985 { |
|
986 case ELabelMemoName: |
|
987 { |
|
988 //StringLoader::Format( aName, formatStr, -1, iMemo->Name() ); |
|
989 aName.Copy(iMemo->Name()); |
|
990 break; |
|
991 } |
|
992 case ELabelMemoDate: |
|
993 { |
|
994 iMemo->DateCreated().FormatL( formattedTime, |
|
995 iDateUsualWithZero ); |
|
996 StringLoader::Format( aName, formatStr, 0, formattedTime ); |
|
997 |
|
998 iMemo->DateCreated().FormatL( formattedTime, |
|
999 iTimeUsualWithZero ); |
|
1000 formatStr.Copy( aName ); |
|
1001 StringLoader::Format( aName, formatStr, 1, formattedTime ); |
|
1002 AknTextUtils::LanguageSpecificNumberConversion( aName ); |
|
1003 break; |
|
1004 } |
|
1005 case ELabelMemoQuality: |
|
1006 { |
|
1007 // Display empty row if feature is not on |
|
1008 if ( !VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
1009 { |
|
1010 aName.Copy( KNullDesC ); |
|
1011 break; |
|
1012 } |
|
1013 |
|
1014 aName.Copy( formatStr ); |
|
1015 break; |
|
1016 } |
|
1017 case ELabelQualityText: |
|
1018 { |
|
1019 // Display empty row if feature is not on |
|
1020 if ( !VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
1021 { |
|
1022 aName.Copy( KNullDesC ); |
|
1023 break; |
|
1024 } |
|
1025 |
|
1026 formatStr.Copy( placeForQuality ); |
|
1027 |
|
1028 switch( iMemo->Quality() ) |
|
1029 { |
|
1030 case EQualityMMSOptimized: |
|
1031 { |
|
1032 StringLoader::Load( formattedTime, R_VOREC_QUALITY_MMS_OPTIMIZED ); |
|
1033 StringLoader::Format( aName, formatStr, -1, formattedTime ); |
|
1034 break; |
|
1035 } |
|
1036 |
|
1037 // EQualityNormal is used only when mp4 is supported. In this case the file is saved as wav. |
|
1038 #ifdef __AAC_ENCODER_PLUGIN |
|
1039 case EQualityNormal: |
|
1040 { |
|
1041 StringLoader::Load( formattedTime, R_VOREC_QUALITY_NORMAL ); |
|
1042 StringLoader::Format( aName, formatStr, -1, formattedTime ); |
|
1043 break; |
|
1044 } |
|
1045 #endif |
|
1046 |
|
1047 case EQualityHigh: |
|
1048 { |
|
1049 StringLoader::Load( formattedTime, R_VOREC_QUALITY_HIGH ); |
|
1050 StringLoader::Format( aName, formatStr, -1, formattedTime ); |
|
1051 break; |
|
1052 } |
|
1053 default: |
|
1054 { |
|
1055 aName.Copy( KNullDesC ); |
|
1056 break; |
|
1057 } |
|
1058 } |
|
1059 break; |
|
1060 } |
|
1061 case ELabelBarMin: |
|
1062 { |
|
1063 aName.Copy( KNullDesC ); |
|
1064 break; |
|
1065 } |
|
1066 case ELabelBarMax: |
|
1067 { |
|
1068 // This label layout is nowadays taking automatically care of |
|
1069 // string mirroring in the case of mirrored layout. So use of |
|
1070 // AknLayoutUtils::LayoutMirrored() isn't needed anymore |
|
1071 |
|
1072 TTimeIntervalMicroSeconds max( 0 ); |
|
1073 if ( ( iState->iId == EStateRecording ) || |
|
1074 ( iState->iId == EStateRecordingPaused ) ) |
|
1075 { |
|
1076 max = iMemo->MaxDuration(); |
|
1077 } |
|
1078 else |
|
1079 { |
|
1080 max = iMemo->Duration().Int64(); |
|
1081 |
|
1082 if ( max.Int64() < 0 ) |
|
1083 { |
|
1084 max = 0; |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 TTime lengthAsTime( max.Int64() ); |
|
1089 TTime positionAsTime( iMemo->Position().Int64() ); |
|
1090 TBuf< VRLABELMAXLENGTH > formattedPosition; |
|
1091 |
|
1092 // current memo quality |
|
1093 TVRQuality quality( iMemo->Quality() ); |
|
1094 |
|
1095 // Show --:--:-- if estimate for maximum recording time is not |
|
1096 // known yet. Done only when memo quality is High |
|
1097 if ( ( ( iState->iId == EStateRecording ) || |
|
1098 ( iState->iId == EStateRecordingPaused )) && |
|
1099 ( Position() < KVRFirstEstimateTime ) && |
|
1100 ( quality == EQualityHigh ) && |
|
1101 ( max.Int64() < 0) ) |
|
1102 { |
|
1103 formattedTime.Append( KVRBeforeFirstEstimateLabel ); |
|
1104 } |
|
1105 // Show normal maximum time |
|
1106 else |
|
1107 { |
|
1108 // Show longer format if time is more than 1 hour |
|
1109 FormatTimeL( lengthAsTime, formattedTime ); |
|
1110 } |
|
1111 |
|
1112 // Show longer format if time is more than 1 hour |
|
1113 FormatTimeL( positionAsTime, formattedPosition ); |
|
1114 |
|
1115 StringLoader::Format( aName, formatStr, 0, formattedPosition ); |
|
1116 formatStr.Copy( aName ); |
|
1117 StringLoader::Format( aName, formatStr, 1, formattedTime ); |
|
1118 AknTextUtils::LanguageSpecificNumberConversion( aName ); |
|
1119 |
|
1120 break; |
|
1121 } |
|
1122 case ELabelStatus: |
|
1123 { |
|
1124 aName.Copy( iState->iStatus ); |
|
1125 break; |
|
1126 } |
|
1127 default: |
|
1128 { |
|
1129 break; |
|
1130 } |
|
1131 } |
|
1132 } |
|
1133 else |
|
1134 { |
|
1135 aName.SetLength( 0 ); |
|
1136 } |
|
1137 } |
|
1138 |
|
1139 |
|
1140 // --------------------------------------------------------------------------- |
|
1141 // CVRRecViewModel::ResourceIdForLabel |
|
1142 // |
|
1143 // --------------------------------------------------------------------------- |
|
1144 // |
|
1145 TInt CVRRecViewModel::ResourceIdForLabel( TInt aLabelIndex, |
|
1146 TAknLayoutId aLayout ) const |
|
1147 { |
|
1148 switch ( aLayout ) |
|
1149 { |
|
1150 case EAknLayoutIdELAF: |
|
1151 default: |
|
1152 return iLabelLayoutLinks[ aLabelIndex ].iEuroId; |
|
1153 |
|
1154 case EAknLayoutIdABRW: |
|
1155 return iLabelLayoutLinks[ aLabelIndex ].iArabicHebrewId; |
|
1156 |
|
1157 case EAknLayoutIdAPAC: |
|
1158 return iLabelLayoutLinks[ aLabelIndex ].iApacId; |
|
1159 |
|
1160 } |
|
1161 |
|
1162 } |
|
1163 |
|
1164 |
|
1165 // --------------------------------------------------------------------------- |
|
1166 // CVRRecViewModel::SetStateInfoObserver |
|
1167 // |
|
1168 // --------------------------------------------------------------------------- |
|
1169 // |
|
1170 void CVRRecViewModel::SetStateInfoObserver( MVRObserver* aObserver ) |
|
1171 { |
|
1172 iStateInfoObserver = aObserver; |
|
1173 if( iRecorder ) |
|
1174 { |
|
1175 iRecorder->RegisterObserver( iStateInfoObserver ); |
|
1176 } |
|
1177 } |
|
1178 |
|
1179 |
|
1180 // --------------------------------------------------------------------------- |
|
1181 // CVRRecViewModel::SetStateInfoPanelObserver |
|
1182 // Observes changes in state info panel |
|
1183 // --------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CVRRecViewModel::SetStateInfoPanelObserver( MVRStateInfoObserver* |
|
1186 aObserver ) |
|
1187 { |
|
1188 iStateInfoPanelObserver = aObserver; |
|
1189 } |
|
1190 |
|
1191 |
|
1192 // --------------------------------------------------------------------------- |
|
1193 // CVRRecViewModel::HasProgressBar |
|
1194 // |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // |
|
1197 TBool CVRRecViewModel::HasProgressBar() const |
|
1198 { |
|
1199 return iState->iHasProgressBar; |
|
1200 } |
|
1201 |
|
1202 |
|
1203 // --------------------------------------------------------------------------- |
|
1204 // CVRRecViewModel::GetSelectedFilesLC |
|
1205 // |
|
1206 // --------------------------------------------------------------------------- |
|
1207 // |
|
1208 MDesCArray* CVRRecViewModel::GetSelectedFilesLC() const |
|
1209 { |
|
1210 CDesCArray* array = new( ELeave ) CDesCArrayFlat( 1 ); // granularity = 1 |
|
1211 CleanupStack::PushL( array ); |
|
1212 array->AppendL( iMemo->Filename() ); |
|
1213 return array; |
|
1214 } |
|
1215 |
|
1216 |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // CVRRecViewModel::SetVolume |
|
1219 // |
|
1220 // --------------------------------------------------------------------------- |
|
1221 // |
|
1222 void CVRRecViewModel::SetVolume( TInt aStep, TInt aMaxSteps ) |
|
1223 { |
|
1224 iIhfVolume = aStep; |
|
1225 iRecorder->SetVolume( aStep, aMaxSteps ); |
|
1226 } |
|
1227 |
|
1228 |
|
1229 // --------------------------------------------------------------------------- |
|
1230 // CVRRecViewModel::SetMemoName |
|
1231 // |
|
1232 // --------------------------------------------------------------------------- |
|
1233 // |
|
1234 void CVRRecViewModel::SetMemoName( const TDesC& aFilename ) |
|
1235 { |
|
1236 iMemo->SetName( aFilename ); |
|
1237 } |
|
1238 |
|
1239 |
|
1240 // --------------------------------------------------------------------------- |
|
1241 // CVRRecViewModel::SetMemoNameNewL |
|
1242 // |
|
1243 // --------------------------------------------------------------------------- |
|
1244 // |
|
1245 void CVRRecViewModel::SetMemoNameNewL( TBool aEmbedded ) |
|
1246 { |
|
1247 iMemo->SetTemporaryNameL( aEmbedded ); |
|
1248 } |
|
1249 |
|
1250 |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // CVRRecViewModel::Filename |
|
1253 // |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // |
|
1256 const TDesC& CVRRecViewModel::Filename() const |
|
1257 { |
|
1258 return iMemo->Filename(); |
|
1259 } |
|
1260 |
|
1261 void CVRRecViewModel::SetSavingLocationL( const TDesC& aPath ) |
|
1262 { |
|
1263 iMemo->SetSavingLocationL( aPath ); |
|
1264 } |
|
1265 |
|
1266 |
|
1267 // --------------------------------------------------------------------------- |
|
1268 // CVRRecViewModel::Update |
|
1269 // |
|
1270 // --------------------------------------------------------------------------- |
|
1271 // |
|
1272 void CVRRecViewModel::Update( TVRUpdateCommand /*aCommand*/ ) |
|
1273 { |
|
1274 // Error is propagated to error handling method |
|
1275 TRAPD( err, HandleCommandL( ECmdAutoStopAtEnd ) ); |
|
1276 |
|
1277 // Ignore further errors |
|
1278 TRAP_IGNORE( HandleUpdateErrorL( err ) ); |
|
1279 } |
|
1280 |
|
1281 |
|
1282 // --------------------------------------------------------------------------- |
|
1283 // CVRRecViewModel::IsEmbedded |
|
1284 // |
|
1285 // --------------------------------------------------------------------------- |
|
1286 // |
|
1287 TBool CVRRecViewModel::IsEmbedded() const |
|
1288 { |
|
1289 return ( iContext == EContextRecordNewForRemote ) |
|
1290 || ( iContext == EContextViewer ); |
|
1291 } |
|
1292 |
|
1293 |
|
1294 // --------------------------------------------------------------------------- |
|
1295 // CVRRecViewModel::CanAcceptCommands |
|
1296 // |
|
1297 // --------------------------------------------------------------------------- |
|
1298 // |
|
1299 TBool CVRRecViewModel::CanAcceptCommands() const |
|
1300 { |
|
1301 return ( iContextEntered != EFalse ) && iRecorder->CanAcceptCommands(); |
|
1302 } |
|
1303 |
|
1304 |
|
1305 // --------------------------------------------------------------------------- |
|
1306 // CVRRecViewModel::SendViaL |
|
1307 // |
|
1308 // --------------------------------------------------------------------------- |
|
1309 // |
|
1310 void CVRRecViewModel::SendViaL( CSendUi* aSendUi ) |
|
1311 { |
|
1312 // Don't accept commands during sending operation |
|
1313 iContextEntered = EFalse; |
|
1314 |
|
1315 iRecorder->DetachMemo(); |
|
1316 // Detaching resets the clip position so button panel needs to be updated |
|
1317 iButtonPanelObserver->Update( EVRUpdatePositionChange ); |
|
1318 |
|
1319 TSendingCapabilities capabilities |
|
1320 (0, KVRSendUiMsgSize, TSendingCapabilities::ESupportsAttachments); |
|
1321 CMessageData* messageData = CMessageData::NewL(); |
|
1322 CleanupStack::PushL( messageData ); |
|
1323 |
|
1324 messageData->AppendAttachmentHandleL( iMemo->File() ); |
|
1325 |
|
1326 // Get an array of the services that should be dimmed |
|
1327 CArrayFixFlat< TUid >* servicesToDim = SendViaServicesToDimLC(); |
|
1328 |
|
1329 // For some reason this function leaves when 'NO' is selected in bluetooth |
|
1330 // case's activation question. If this is not Trapped iContextEntered stays |
|
1331 // EFalse and no commands can be executed |
|
1332 TRAPD( err, aSendUi->ShowQueryAndSendL( messageData, |
|
1333 capabilities, |
|
1334 servicesToDim ) ); |
|
1335 |
|
1336 CleanupStack::PopAndDestroy( servicesToDim ); |
|
1337 CleanupStack::PopAndDestroy( messageData ); |
|
1338 |
|
1339 iRecorder->AttachToMemoL( iMemo ); |
|
1340 |
|
1341 iContextEntered = ETrue; |
|
1342 |
|
1343 // This is done so we get possible "Feature not supported" |
|
1344 // infonote from the framework |
|
1345 User::LeaveIfError( err ); |
|
1346 } |
|
1347 |
|
1348 |
|
1349 // --------------------------------------------------------------------------- |
|
1350 // CVRRecViewModel::SendViaServicesToDimLC |
|
1351 // Generates an array of the services (Uids) that should be dimmed from Send |
|
1352 // via menu. Returns a pointer to that array. Configuration in Messaging |
|
1353 // central repository defines services to dim. |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // |
|
1356 CArrayFixFlat<TUid>* CVRRecViewModel::SendViaServicesToDimLC() |
|
1357 { |
|
1358 CArrayFixFlat< TUid >* servicesToDim = |
|
1359 new( ELeave ) CArrayFixFlat< TUid >( 1 ); |
|
1360 CleanupStack::PushL( servicesToDim ); |
|
1361 |
|
1362 CRepository* repository = |
|
1363 CRepository::NewL( KCRUidMuiuMessagingConfiguration ); |
|
1364 TInt configuration = 0; |
|
1365 if ( !repository->Get( KMuiuSendUiConfiguration, configuration ) ) |
|
1366 { |
|
1367 configuration = configuration & KMuiuEmailDisabledInMultimedia; |
|
1368 } |
|
1369 delete repository; |
|
1370 |
|
1371 if ( configuration ) |
|
1372 { |
|
1373 servicesToDim->AppendL( KSenduiMtmSmtpUid ); // normal email |
|
1374 servicesToDim->AppendL( KSenduiMtmSyncMLEmailUid ); // sync email |
|
1375 } |
|
1376 |
|
1377 return servicesToDim; |
|
1378 } |
|
1379 |
|
1380 |
|
1381 // --------------------------------------------------------------------------- |
|
1382 // CVRRecViewModel::CallFunctionByIdL |
|
1383 // |
|
1384 // --------------------------------------------------------------------------- |
|
1385 // |
|
1386 /* |
|
1387 IMPLEMENTATION NOTE: |
|
1388 This method needs refactoring with CVRMemo and CVRMdaRecorder. |
|
1389 Probably most of the logic should be transferred to CVRMemo. |
|
1390 */ |
|
1391 TBool CVRRecViewModel::CallFunctionByIdL( TInt aFunctionId ) |
|
1392 { |
|
1393 switch ( aFunctionId ) |
|
1394 { |
|
1395 case EFunctionPlay: |
|
1396 { |
|
1397 if ( VRUtils::UnsupportedCallTypeOngoing( ETrue ) || !dynamic_cast<CVRMdaRecorder*>(iRecorder)->IsAttachedToMemo()) |
|
1398 { |
|
1399 return EFalse; |
|
1400 } |
|
1401 |
|
1402 iIgnoreNextIhfChange = EFalse; |
|
1403 SetRecorderVolume(); |
|
1404 SetIHFIfCallNotActive( iIhfState ); |
|
1405 TInt mediaservErr( KErrNone ); |
|
1406 |
|
1407 // Don't accept CBA commands |
|
1408 iCBAEnabled = EFalse; |
|
1409 // Update CBAs |
|
1410 iDecoratorObserver->Update( EVRUpdateCBA ); |
|
1411 TRAPD( leaveErr, mediaservErr = iRecorder->PlayL() ); |
|
1412 |
|
1413 // Accept CBAs again. CBAs are updated when state is changed |
|
1414 iCBAEnabled = ETrue; |
|
1415 |
|
1416 if ( leaveErr == KErrNotReady ) |
|
1417 { |
|
1418 ShowNoteL( R_VR_CORRUPT_INFONOTE_LABEL, EAknGlobalErrorNote ); |
|
1419 return EFalse; |
|
1420 } |
|
1421 |
|
1422 if ( mediaservErr != KErrNone ) |
|
1423 { |
|
1424 // cancel the state change |
|
1425 // the error note is shown in CVRMdaRecorder |
|
1426 return EFalse; |
|
1427 } |
|
1428 User::LeaveIfError( leaveErr ); |
|
1429 break; |
|
1430 } |
|
1431 case EFunctionStop: |
|
1432 { |
|
1433 // Turn off the IHF after playing |
|
1434 SetIHFIfCallNotActive( EFalse ); |
|
1435 iRecorder->Stop(); |
|
1436 CheckIhfState(); |
|
1437 break; |
|
1438 } |
|
1439 case EFunctionStopWithNote: |
|
1440 { |
|
1441 // No need to do anything to IHF here since this is |
|
1442 // called after recording (IHF is not used) |
|
1443 iRecorder->Stop(); |
|
1444 ShowNoteL( R_VR_STOP_INFONOTE_LABEL, EAknGlobalInformationNote ); |
|
1445 break; |
|
1446 } |
|
1447 case EFunctionStopAndSave: |
|
1448 { |
|
1449 // No need to do anything to IHF here since this is |
|
1450 // called after recording (IHF is not used) |
|
1451 StopAndSaveL( 0 ); |
|
1452 break; |
|
1453 } |
|
1454 case EFunctionAutoStopAndSave: |
|
1455 { |
|
1456 // No need to do anything to IHF here since this is |
|
1457 // called after recording (IHF is not used) |
|
1458 StopAndSaveL( R_VR_STOP_INFONOTE_LABEL ); |
|
1459 break; |
|
1460 } |
|
1461 case EFunctionSilentStopAndSave: |
|
1462 { |
|
1463 // No need to do anything to IHF here since this is |
|
1464 // called after recording (IHF is not used) |
|
1465 StopAndSaveL( 0 ); |
|
1466 break; |
|
1467 } |
|
1468 |
|
1469 case EFunctionAutoStop: |
|
1470 { |
|
1471 // Turn off the IHF after playing |
|
1472 SetIHFIfCallNotActive( EFalse ); |
|
1473 iRecorder->Stop(); |
|
1474 CheckIhfState(); |
|
1475 break; |
|
1476 } |
|
1477 case EFunctionSaveBeforeExit: |
|
1478 { |
|
1479 StopAndCloseL( R_VR_STOP_SAVE_WAITNOTE_LABEL ); |
|
1480 break; |
|
1481 } |
|
1482 case EFunctionRecord: |
|
1483 { |
|
1484 if ( VRUtils::UnsupportedCallTypeOngoing( ETrue ) ) |
|
1485 { |
|
1486 return EFalse; |
|
1487 } |
|
1488 |
|
1489 //if ( iRecorder->RecordL() != KErrNone ) |
|
1490 // { |
|
1491 // return EFalse; |
|
1492 // } |
|
1493 |
|
1494 if(iCurrentCallHandler->StateL(KPSUidCtsyCallInformation,KCTsyCallState )==EPSCTsyCallStateConnected) |
|
1495 { |
|
1496 dynamic_cast<CVRMdaRecorder*>(iRecorder)->SetAudioInputL(CAudioInput::EVoiceCall); |
|
1497 dynamic_cast<CVRMdaRecorder*>(iRecorder)->ConfigSampleRateOfVoiceCallL(); |
|
1498 } |
|
1499 //Audioinput can't be changed after Record |
|
1500 if ( iRecorder->RecordL() != KErrNone ) |
|
1501 { |
|
1502 return EFalse; |
|
1503 } |
|
1504 break; |
|
1505 } |
|
1506 case EFunctionPause: |
|
1507 { |
|
1508 |
|
1509 iRecorder->Pause(); |
|
1510 // Turn off the IHF after playing |
|
1511 SetIHFIfCallNotActive( EFalse ); |
|
1512 break; |
|
1513 } |
|
1514 case EFunctionForward: |
|
1515 { |
|
1516 TInt result = iRecorder->ForwardL(); |
|
1517 |
|
1518 // The volume setting is lost when the media server client object |
|
1519 // is stopped. |
|
1520 SetRecorderVolume(); |
|
1521 |
|
1522 if ( result ) |
|
1523 { |
|
1524 return EFalse; |
|
1525 } |
|
1526 break; |
|
1527 } |
|
1528 case EFunctionRewind: |
|
1529 { |
|
1530 iRecorder->RewindL(); |
|
1531 if ( iButtonPanelObserver ) |
|
1532 { |
|
1533 iButtonPanelObserver->Update(); |
|
1534 } |
|
1535 |
|
1536 // The volume setting is lost when the media server client object |
|
1537 // is stopped |
|
1538 SetRecorderVolume(); |
|
1539 break; |
|
1540 } |
|
1541 case EFunctionRecordNew: |
|
1542 { |
|
1543 if ( VRUtils::UnsupportedCallTypeOngoing( ETrue ) ) |
|
1544 { |
|
1545 return EFalse; |
|
1546 } |
|
1547 |
|
1548 dynamic_cast<CVRMdaRecorder*>(iRecorder)->SetInRecordingFlag(ETrue); |
|
1549 |
|
1550 iCanHandleCommands = EFalse; |
|
1551 // Don't accept CBA commands |
|
1552 iCBAEnabled = EFalse; |
|
1553 // Update CBAs |
|
1554 iDecoratorObserver->Update( EVRUpdateCBA ); |
|
1555 |
|
1556 iRecorder->DetachMemo(); |
|
1557 |
|
1558 TRAPD( leaveErr1, SetMemoNameNewL( |
|
1559 iContext == EContextRecordNewForRemote ) ); |
|
1560 |
|
1561 // Can't attach if memo name couldn't be generated |
|
1562 TInt leaveErr2( KErrNone ); |
|
1563 if( !leaveErr1 ) |
|
1564 { |
|
1565 TRAP( leaveErr2, iRecorder->AttachToMemoL( iMemo ) ); |
|
1566 } |
|
1567 |
|
1568 TBool ifAttach = dynamic_cast <CVRMdaRecorder*>(iRecorder)->IsAttachedToMemo(); |
|
1569 |
|
1570 if ( leaveErr1 || leaveErr2 || !ifAttach) |
|
1571 { |
|
1572 iCanHandleCommands = ETrue; |
|
1573 iCBAEnabled = ETrue; |
|
1574 if ( leaveErr1 == KErrDiskFull || leaveErr2 == KErrDiskFull ) |
|
1575 { |
|
1576 if ( iMemo->StorageDrive() == EDriveF) |
|
1577 { |
|
1578 VRUtils::ShowMemoryFullConfirmationQuery(ETrue); |
|
1579 } |
|
1580 else |
|
1581 { |
|
1582 VRUtils::ShowMemoryFullConfirmationQuery(); |
|
1583 } |
|
1584 } |
|
1585 } |
|
1586 |
|
1587 User::LeaveIfError( leaveErr1 ); |
|
1588 User::LeaveIfError( leaveErr2 ); |
|
1589 if(!ifAttach) |
|
1590 { |
|
1591 User::Leave(KErrNotReady); |
|
1592 } |
|
1593 |
|
1594 // Indicates that a new memo is attached but not yet recording |
|
1595 // started -> handle can be reused and memo can be deleted in exit |
|
1596 iMemo->SetRecorded( EFalse ); |
|
1597 |
|
1598 TInt recError( KErrNone ); |
|
1599 |
|
1600 //TRAPD( recLeaveErr, recError = iRecorder->RecordL() ); |
|
1601 if(iCurrentCallHandler->StateL(KPSUidCtsyCallInformation,KCTsyCallState )==EPSCTsyCallStateConnected) |
|
1602 { |
|
1603 dynamic_cast<CVRMdaRecorder*>(iRecorder)->SetAudioInputL(CAudioInput::EVoiceCall); |
|
1604 dynamic_cast<CVRMdaRecorder*>(iRecorder)->ConfigSampleRateOfVoiceCallL(); |
|
1605 } |
|
1606 //Change for CS call:Audio input can't be changed after Record |
|
1607 TRAPD( recLeaveErr, recError = iRecorder->RecordL() ); |
|
1608 |
|
1609 if (GetInRecordingFlag()) |
|
1610 { |
|
1611 dynamic_cast<CVRMdaRecorder*>(iRecorder)->SetInRecordingFlag(EFalse); |
|
1612 } |
|
1613 |
|
1614 if ( recError != KErrNone || recLeaveErr ) |
|
1615 { |
|
1616 iCanHandleCommands = ETrue; |
|
1617 iCBAEnabled = ETrue; |
|
1618 if ( recLeaveErr ) |
|
1619 { |
|
1620 User::LeaveIfError( recLeaveErr ); |
|
1621 } |
|
1622 else |
|
1623 { |
|
1624 return EFalse; |
|
1625 } |
|
1626 } |
|
1627 |
|
1628 |
|
1629 iCanHandleCommands = ETrue; |
|
1630 // Accept CBAs again. CBAs are updated when state is changed |
|
1631 iCBAEnabled = ETrue; |
|
1632 break; |
|
1633 } |
|
1634 case EFunctionDelete: |
|
1635 { |
|
1636 iRecorder->DetachMemo(); |
|
1637 // Detaching resets the clip position so button panel |
|
1638 // needs to be updated |
|
1639 iButtonPanelObserver->Update( EVRUpdatePositionChange ); |
|
1640 if ( !iMemo->QueryAndDeleteL() ) |
|
1641 { |
|
1642 iRecorder->AttachToMemoL( iMemo ); |
|
1643 return EFalse; |
|
1644 } |
|
1645 break; |
|
1646 } |
|
1647 case EFunctionRename: |
|
1648 { |
|
1649 iRecorder->DetachMemo(); |
|
1650 // Detaching resets the clip position so button panel |
|
1651 // needs to be updated |
|
1652 iButtonPanelObserver->Update( EVRUpdatePositionChange ); |
|
1653 if ( iMemo->QueryAndRenameL() ) |
|
1654 { |
|
1655 if ( iStateInfoObserver ) |
|
1656 { |
|
1657 iStateInfoObserver->Update(); |
|
1658 } |
|
1659 } |
|
1660 iRecorder->AttachToMemoL( iMemo ); |
|
1661 break; |
|
1662 } |
|
1663 case EFunctionOk: |
|
1664 { |
|
1665 |
|
1666 HBufC* label = StringLoader::LoadLC( R_VR_SAVE_WAITNOTE_LABEL ); |
|
1667 |
|
1668 iRecorder->DetachMemo(); |
|
1669 iIsNoteLaunched = ETrue; |
|
1670 iMemo->SavePermanentlyL( iGlobalNote, iNoteId, *label ); |
|
1671 |
|
1672 CEikonEnv::Static()->EikAppUi()->HandleCommandL( |
|
1673 ECmdEmbeddedRecordingReady ); |
|
1674 |
|
1675 iGlobalNote->CancelNoteL( iNoteId ); |
|
1676 iIsNoteLaunched = EFalse; |
|
1677 #ifdef _DEBUG |
|
1678 RDebug::Print( _L( |
|
1679 "VoiceRecorder: CVRRecViewModel Note cancelled" ) ); |
|
1680 #endif |
|
1681 CleanupStack::PopAndDestroy( label ); |
|
1682 |
|
1683 HandleCommandL( EEikCmdExit ); |
|
1684 break; |
|
1685 } |
|
1686 case EFunctionCancel: |
|
1687 { |
|
1688 iRecorder->DetachMemo(); |
|
1689 iMemo->DeleteL(); |
|
1690 HandleCommandL( EEikCmdExit ); |
|
1691 break; |
|
1692 } |
|
1693 case EFunctionNop: |
|
1694 { |
|
1695 // dummy command, do nothing |
|
1696 break; |
|
1697 } |
|
1698 case EFunctionNRTStop: |
|
1699 { |
|
1700 // Turn off the IHF after playing |
|
1701 SetIHFIfCallNotActive( EFalse ); |
|
1702 |
|
1703 iRecorder->Stop(); |
|
1704 CheckIhfState(); |
|
1705 break; |
|
1706 } |
|
1707 case EFunctionNRTAutoStop: |
|
1708 { |
|
1709 // Turn off the IHF after playing |
|
1710 SetIHFIfCallNotActive( EFalse ); |
|
1711 CheckIhfState(); |
|
1712 break; |
|
1713 } |
|
1714 case EFunctionSetNewPosition: |
|
1715 { |
|
1716 TInt newValue( 0 ); |
|
1717 if ( iStateInfoPanelObserver ) |
|
1718 { |
|
1719 newValue = iStateInfoPanelObserver->ProgressBarPosition(); |
|
1720 } |
|
1721 |
|
1722 iRecorder->SetPositionL( newValue ); |
|
1723 |
|
1724 //Inform button Panel |
|
1725 if ( iButtonPanelObserver ) |
|
1726 { |
|
1727 iButtonPanelObserver->Update( EVRUpdateStateChange ); |
|
1728 } |
|
1729 break; |
|
1730 } |
|
1731 default: |
|
1732 { |
|
1733 User::Panic( KVRPanic, EPanicFunctionUnknown ); |
|
1734 break; |
|
1735 } |
|
1736 } |
|
1737 return ETrue; |
|
1738 } |
|
1739 |
|
1740 |
|
1741 // --------------------------------------------------------------------------- |
|
1742 // CVRRecViewModel::StopAndSaveL |
|
1743 // |
|
1744 // --------------------------------------------------------------------------- |
|
1745 // |
|
1746 void CVRRecViewModel::StopAndSaveL( TInt aResourceId ) |
|
1747 { |
|
1748 HBufC* label = NULL; |
|
1749 |
|
1750 // Don't show the note if aResourceId was not defined |
|
1751 if ( aResourceId ) |
|
1752 { |
|
1753 label = StringLoader::LoadLC( aResourceId ); |
|
1754 } |
|
1755 |
|
1756 iRecorder->DetachMemo(); |
|
1757 |
|
1758 if ( label ) |
|
1759 { |
|
1760 iIsNoteLaunched = ETrue; |
|
1761 if(iMemo) |
|
1762 { |
|
1763 iMemo->SavePermanentlyL( iGlobalNote, iNoteId, *label ); |
|
1764 } |
|
1765 |
|
1766 // There is no more note showing in SavePermanentlyL() -function |
|
1767 // the note is shown here |
|
1768 ShowNoteL( aResourceId, EAknGlobalInformationNote ); |
|
1769 } |
|
1770 else |
|
1771 { |
|
1772 iIsNoteLaunched = ETrue; |
|
1773 if(iMemo) |
|
1774 { |
|
1775 iMemo->SavePermanentlyL( iGlobalNote, iNoteId, KNullDesC ); |
|
1776 } |
|
1777 } |
|
1778 |
|
1779 TRAP_IGNORE(iRecorder->AttachToMemoL( iMemo )); |
|
1780 |
|
1781 iGlobalNote->CancelNoteL( iNoteId ); |
|
1782 iIsNoteLaunched = EFalse; |
|
1783 |
|
1784 if ( aResourceId ) |
|
1785 { |
|
1786 CleanupStack::PopAndDestroy( label ); |
|
1787 } |
|
1788 } |
|
1789 |
|
1790 |
|
1791 // --------------------------------------------------------------------------- |
|
1792 // CVRRecViewModel::StopAndCloseL |
|
1793 // |
|
1794 // --------------------------------------------------------------------------- |
|
1795 // |
|
1796 void CVRRecViewModel::StopAndCloseL( TInt aResourceId ) |
|
1797 { |
|
1798 HBufC* label = NULL; |
|
1799 |
|
1800 // Don't show the note if aResourceId was not defined |
|
1801 if ( aResourceId ) |
|
1802 { |
|
1803 label = StringLoader::LoadLC( aResourceId ); |
|
1804 } |
|
1805 |
|
1806 iRecorder->DetachMemo(); |
|
1807 |
|
1808 if ( label ) |
|
1809 { |
|
1810 iIsNoteLaunched = ETrue; |
|
1811 if(iMemo) |
|
1812 { |
|
1813 iMemo->SavePermanentlyL( iGlobalNote, iNoteId, *label ); |
|
1814 } |
|
1815 } |
|
1816 else |
|
1817 { |
|
1818 iIsNoteLaunched = ETrue; |
|
1819 if(iMemo) |
|
1820 { |
|
1821 iMemo->SavePermanentlyL( iGlobalNote, iNoteId, KNullDesC ); |
|
1822 } |
|
1823 } |
|
1824 |
|
1825 iGlobalNote->CancelNoteL( iNoteId ); |
|
1826 iIsNoteLaunched = EFalse; |
|
1827 |
|
1828 if ( aResourceId ) |
|
1829 { |
|
1830 CleanupStack::PopAndDestroy( label ); |
|
1831 } |
|
1832 } |
|
1833 |
|
1834 void CVRRecViewModel::ShowNoteL( TInt aResourceId, |
|
1835 TAknGlobalNoteType aNoteType ) |
|
1836 { |
|
1837 HBufC* label = StringLoader::LoadLC( aResourceId ); |
|
1838 iGlobalNote->ShowNoteL( aNoteType, *label ); |
|
1839 CleanupStack::PopAndDestroy( label ); |
|
1840 } |
|
1841 |
|
1842 |
|
1843 // --------------------------------------------------------------------------- |
|
1844 // CVRRecViewModel::GetVolumeControlState |
|
1845 // |
|
1846 // --------------------------------------------------------------------------- |
|
1847 // |
|
1848 void CVRRecViewModel::GetVolumeControlState( TVRVolumeControlState& aState, |
|
1849 TInt& aVolume ) |
|
1850 { |
|
1851 // ignored |
|
1852 TRAP_IGNORE( ReadDefaultSpeakerL() ); |
|
1853 if ( iState->iHasVolumeControl ) |
|
1854 { |
|
1855 if ( iIhfState ) |
|
1856 { |
|
1857 aState = EIhf; |
|
1858 |
|
1859 } |
|
1860 else |
|
1861 { |
|
1862 aState = EEarPiece; |
|
1863 } |
|
1864 aVolume = iIhfVolume; |
|
1865 } |
|
1866 else |
|
1867 { |
|
1868 aState = EDisabled; |
|
1869 } |
|
1870 } |
|
1871 |
|
1872 |
|
1873 // --------------------------------------------------------------------------- |
|
1874 // CVRRecViewModel::LoadVolumeSettingsL |
|
1875 // |
|
1876 // --------------------------------------------------------------------------- |
|
1877 // |
|
1878 void CVRRecViewModel::LoadVolumeSettingsL() |
|
1879 { |
|
1880 iIhfVolume = VRUtils::DefaultVolumeL( ESpeakerIhf ); |
|
1881 // Prevent using incorrect values |
|
1882 if ( iIhfVolume < KVRVolumeControlMin || |
|
1883 iIhfVolume > KVRVolumeControlMax ) |
|
1884 { |
|
1885 iIhfVolume = KVRDefaultVolume; |
|
1886 } |
|
1887 } |
|
1888 |
|
1889 |
|
1890 // --------------------------------------------------------------------------- |
|
1891 // CVRRecViewModel::SaveVolumeSettings |
|
1892 // |
|
1893 // --------------------------------------------------------------------------- |
|
1894 // |
|
1895 void CVRRecViewModel::SaveVolumeSettings() |
|
1896 { |
|
1897 // Ignore all errors, because this will be called in destructor. It isn't |
|
1898 // disastrous if new values aren't saved, the previous values will be there |
|
1899 TRAP_IGNORE( VRUtils::SetDefaultVolumeL( ESpeakerIhf, iIhfVolume ); ); |
|
1900 } |
|
1901 |
|
1902 |
|
1903 // --------------------------------------------------------------------------- |
|
1904 // CVRRecViewModel::HandleSystemEventL |
|
1905 // |
|
1906 // --------------------------------------------------------------------------- |
|
1907 // |
|
1908 void CVRRecViewModel::HandleSystemEventL() |
|
1909 { |
|
1910 // Fetch the changed value from Pubsub |
|
1911 TInt currentState( iCurrentCallHandler->StateL(KPSUidCtsyCallInformation, KCTsyCallState ) ); |
|
1912 |
|
1913 if ( !iActive ) |
|
1914 { |
|
1915 iPreviousCallState = currentState; |
|
1916 return; |
|
1917 } |
|
1918 |
|
1919 |
|
1920 // Actions to take when playing |
|
1921 if ( iState->iId == EStatePlaying ) |
|
1922 { |
|
1923 switch ( currentState ) |
|
1924 { |
|
1925 case EPSCTsyCallStateAlerting: |
|
1926 case EPSCTsyCallStateRinging: |
|
1927 case EPSCTsyCallStateAnswering: |
|
1928 { |
|
1929 HandleCommandL( ECmdAutoStopAtEnd ); |
|
1930 break; |
|
1931 } |
|
1932 default: |
|
1933 { |
|
1934 break; |
|
1935 } |
|
1936 } |
|
1937 } |
|
1938 |
|
1939 // Actions to take when recording |
|
1940 if ( iState->iId == EStateRecording ) |
|
1941 { |
|
1942 switch ( currentState ) |
|
1943 { |
|
1944 case EPSCTsyCallStateAlerting: |
|
1945 case EPSCTsyCallStateRinging: |
|
1946 case EPSCTsyCallStateAnswering: |
|
1947 case EPSCTsyCallStateDisconnecting: |
|
1948 { |
|
1949 HandleCommandL( ECmdAutoStopAtEnd ); |
|
1950 break; |
|
1951 } |
|
1952 case EPSCTsyCallStateNone: |
|
1953 { |
|
1954 if( iPreviousCallState == EPSCTsyCallStateConnected ) |
|
1955 { |
|
1956 dynamic_cast<CVRMdaRecorder*>(iRecorder)->SetAudioInputL(CAudioInput::EDefaultMic); |
|
1957 HandleCommandL( ECmdAutoStopAtEnd ); |
|
1958 } |
|
1959 break; |
|
1960 } |
|
1961 default: |
|
1962 { |
|
1963 break; |
|
1964 } |
|
1965 } |
|
1966 } |
|
1967 |
|
1968 if ( iState->iId == EStateIdle && |
|
1969 currentState == EPSCTsyCallStateNone ) |
|
1970 { |
|
1971 iIhfState = ETrue; |
|
1972 } |
|
1973 |
|
1974 /* ------------------------- |
|
1975 * Disable in-call recording |
|
1976 * ------------------------- |
|
1977 */ |
|
1978 if ( iVRAllowInCallRecording != KAllowInCallRecording ) |
|
1979 { |
|
1980 if (( iState->iId == EStateIdle || iState->iId == EStateDeleted ) && |
|
1981 currentState == EPSCTsyCallStateAnswering) |
|
1982 { |
|
1983 // Disable record button |
|
1984 ChangeState( EStateDisableButtons, ETrue ); |
|
1985 } |
|
1986 if (( iState->iId == EStateDisableButtons ) && |
|
1987 ((currentState == EPSCTsyCallStateDisconnecting)|| (currentState == EPSCTsyCallStateNone))) |
|
1988 { |
|
1989 if (iContext != EContextRecordNewForRemote) |
|
1990 { |
|
1991 // Enable record button |
|
1992 ChangeState( EStateDeleted, ETrue ); |
|
1993 } |
|
1994 else |
|
1995 { |
|
1996 if (!(iMemo->Duration() > TTimeIntervalMicroSeconds(0))) |
|
1997 { |
|
1998 ChangeState( EStateRecordEmbedded, ETrue ); |
|
1999 } |
|
2000 else |
|
2001 { |
|
2002 ChangeState( EStateIdleRecordEmbedded, ETrue ); |
|
2003 } |
|
2004 } |
|
2005 } |
|
2006 } |
|
2007 |
|
2008 iPreviousCallState = currentState; |
|
2009 } |
|
2010 |
|
2011 |
|
2012 // --------------------------------------------------------------------------- |
|
2013 // CVRRecViewModel::SetIHFIfCallNotActive |
|
2014 // |
|
2015 // --------------------------------------------------------------------------- |
|
2016 // |
|
2017 void CVRRecViewModel::SetIHFIfCallNotActive( TBool aIhf ) |
|
2018 { |
|
2019 if ( FeatureManager::FeatureSupported( |
|
2020 KFeatureIdApplicationControllableAudioRouting ) ) |
|
2021 { |
|
2022 TInt currentState( EPSCTsyCallStateNone ); |
|
2023 // Ignore the error, ihf is not set |
|
2024 TRAP_IGNORE( currentState = iCurrentCallHandler->StateL( |
|
2025 KPSUidCtsyCallInformation, KCTsyCallState ) ); |
|
2026 |
|
2027 if ( currentState == EPSCTsyCallStateNone ) |
|
2028 { |
|
2029 if ( iRecorder->SetIhf( aIhf ) == KErrNone ) |
|
2030 { |
|
2031 // So that the model knows that the next notify from shared |
|
2032 // data client is not a voice key activated IHF change. |
|
2033 iIgnoreNextIhfChange = ETrue; |
|
2034 } |
|
2035 } |
|
2036 } |
|
2037 } |
|
2038 |
|
2039 |
|
2040 // --------------------------------------------------------------------------- |
|
2041 // CVRRecViewModel::CheckIhfState |
|
2042 // |
|
2043 // --------------------------------------------------------------------------- |
|
2044 // |
|
2045 void CVRRecViewModel::CheckIhfState() |
|
2046 { |
|
2047 if ( FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ) && |
|
2048 FeatureManager::FeatureSupported( |
|
2049 KFeatureIdApplicationControllableAudioRouting ) ) |
|
2050 { |
|
2051 if ( iDefaultSpeaker == ESpeakerIhf ) |
|
2052 { |
|
2053 iIhfState = ETrue; |
|
2054 } |
|
2055 else |
|
2056 { |
|
2057 iIhfState = EFalse; |
|
2058 } |
|
2059 } |
|
2060 else |
|
2061 { |
|
2062 // IHF is default on phones with voice key |
|
2063 iIhfState = ETrue; |
|
2064 } |
|
2065 } |
|
2066 |
|
2067 |
|
2068 // --------------------------------------------------------------------------- |
|
2069 // CVRRecViewModel::SetRecorderVolume |
|
2070 // |
|
2071 // --------------------------------------------------------------------------- |
|
2072 // |
|
2073 void CVRRecViewModel::SetRecorderVolume() |
|
2074 { |
|
2075 TInt activeVolume = iIhfVolume; |
|
2076 iRecorder->SetVolume( activeVolume, KVRMaxVolumeSteps ); |
|
2077 } |
|
2078 |
|
2079 |
|
2080 // --------------------------------------------------------------------------- |
|
2081 // CVRRecViewModel::ActivateL |
|
2082 // |
|
2083 // --------------------------------------------------------------------------- |
|
2084 // |
|
2085 void CVRRecViewModel::ActivateL() |
|
2086 { |
|
2087 iActive = ETrue; |
|
2088 |
|
2089 if ( FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ) && |
|
2090 FeatureManager::FeatureSupported( |
|
2091 KFeatureIdApplicationControllableAudioRouting ) ) |
|
2092 { |
|
2093 // The user has visited another view and possibly altered the |
|
2094 // settings |
|
2095 ReadDefaultSpeakerL(); |
|
2096 } |
|
2097 |
|
2098 // If the in-call disable recording feature has been enabled, then check |
|
2099 // current status and enable/disable UI accordingly |
|
2100 if ( iVRAllowInCallRecording != KAllowInCallRecording ) |
|
2101 { |
|
2102 TInt currentState( iCurrentCallHandler->StateL( |
|
2103 KPSUidCtsyCallInformation, KCTsyCallState ) ); |
|
2104 if ( currentState != EPSCTsyCallStateNone ) |
|
2105 { |
|
2106 ChangeState (EStateDisableButtons, ETrue); |
|
2107 } |
|
2108 } |
|
2109 } |
|
2110 |
|
2111 |
|
2112 // --------------------------------------------------------------------------- |
|
2113 // CVRRecViewModel::Deactivate |
|
2114 // |
|
2115 // --------------------------------------------------------------------------- |
|
2116 // |
|
2117 void CVRRecViewModel::Deactivate() |
|
2118 { |
|
2119 iActive = EFalse; |
|
2120 } |
|
2121 |
|
2122 // --------------------------------------------------------------------------- |
|
2123 // CVRRecViewModel::ReadDefaultSpeakerL |
|
2124 // |
|
2125 // --------------------------------------------------------------------------- |
|
2126 // |
|
2127 void CVRRecViewModel::ReadDefaultSpeakerL() |
|
2128 { |
|
2129 iDefaultSpeaker = VRUtils::DefaultSpeakerL(); |
|
2130 |
|
2131 if ( iDefaultSpeaker == ESpeakerIhf ) |
|
2132 { |
|
2133 iIhfState = ETrue; |
|
2134 } |
|
2135 else |
|
2136 { |
|
2137 iIhfState = EFalse; |
|
2138 } |
|
2139 } |
|
2140 |
|
2141 |
|
2142 // --------------------------------------------------------------------------- |
|
2143 // CVRRecViewModel::TVRLabelLayoutLink::ReadFromResource |
|
2144 // |
|
2145 // --------------------------------------------------------------------------- |
|
2146 // |
|
2147 void CVRRecViewModel::TVRLabelLayoutLink::ReadFromResource |
|
2148 ( TResourceReader& aReader ) |
|
2149 { |
|
2150 iEuroId = aReader.ReadUint32(); |
|
2151 iApacId = aReader.ReadUint32(); |
|
2152 iArabicHebrewId = aReader.ReadUint32(); |
|
2153 } |
|
2154 |
|
2155 |
|
2156 // --------------------------------------------------------------------------- |
|
2157 // CVRRecViewModel::CanSetVolume |
|
2158 // |
|
2159 // --------------------------------------------------------------------------- |
|
2160 // |
|
2161 TBool CVRRecViewModel::CanSetVolume() |
|
2162 { |
|
2163 return ETrue; |
|
2164 } |
|
2165 |
|
2166 |
|
2167 // --------------------------------------------------------------------------- |
|
2168 // CVRRecViewModel::HandleUpdateErrorL |
|
2169 // |
|
2170 // --------------------------------------------------------------------------- |
|
2171 // |
|
2172 void CVRRecViewModel::HandleUpdateErrorL( TInt aErr ) |
|
2173 { |
|
2174 // Show error note. |
|
2175 if ( aErr == KErrDiskFull ) |
|
2176 { |
|
2177 |
|
2178 #ifndef RD_MULTIPLE_DRIVE |
|
2179 if ( VRUtils::MemoStoreL() == EMemoStorePhoneMemory ) |
|
2180 { |
|
2181 ShowNoteL( R_VR_MEMORY_WARNING, EAknGlobalWarningNote ); |
|
2182 } |
|
2183 else |
|
2184 { |
|
2185 ShowNoteL( R_VR_MEMORY_MMC_WARNING, EAknGlobalWarningNote ); |
|
2186 } |
|
2187 |
|
2188 //multiple drive |
|
2189 #else |
|
2190 if (VRUtils::MemoDriveL() == VRUtils::DefaultMemoDriveL()) |
|
2191 { |
|
2192 ShowNoteL( R_VR_MEMORY_WARNING, EAknGlobalWarningNote ); |
|
2193 } |
|
2194 else |
|
2195 { |
|
2196 ShowNoteL( R_VR_MEMORY_MMC_WARNING, EAknGlobalWarningNote ); |
|
2197 } |
|
2198 #endif |
|
2199 |
|
2200 |
|
2201 } |
|
2202 } |
|
2203 |
|
2204 |
|
2205 // --------------------------------------------------------------------------- |
|
2206 // CVRRecViewModel::MemoFileHandle |
|
2207 // |
|
2208 // --------------------------------------------------------------------------- |
|
2209 // |
|
2210 RFile& CVRRecViewModel::MemoFileHandle() |
|
2211 { |
|
2212 return iMemo->File(); |
|
2213 } |
|
2214 |
|
2215 |
|
2216 // --------------------------------------------------------------------------- |
|
2217 // CVRRecViewModel::SetFileHandle |
|
2218 // |
|
2219 // --------------------------------------------------------------------------- |
|
2220 // |
|
2221 void CVRRecViewModel::SetFileHandle( RFile& aFile ) |
|
2222 { |
|
2223 // Use app startup type as embbedding flag |
|
2224 iMemo->SetFileHandle( aFile, CEikonEnv::Static()->StartedAsServerApp() ); |
|
2225 if ( iRecorder ) |
|
2226 { |
|
2227 // First detach if already attached |
|
2228 iRecorder->DetachMemo(); |
|
2229 // The media server error will rise again somewhere where it's |
|
2230 // easier to handle if needed |
|
2231 TRAP_IGNORE( iRecorder->AttachToMemoL( iMemo ) ); |
|
2232 } |
|
2233 |
|
2234 } |
|
2235 |
|
2236 |
|
2237 // --------------------------------------------------------------------------- |
|
2238 // CVRRecViewModel::FormatTimeL |
|
2239 // |
|
2240 // --------------------------------------------------------------------------- |
|
2241 // |
|
2242 void CVRRecViewModel::FormatTimeL( const TTime& aTime, TDes& aString ) const |
|
2243 { |
|
2244 |
|
2245 // Show longer format if duration more than 1 hour |
|
2246 if ( aTime.DateTime().Hour() >= 1 ) |
|
2247 { |
|
2248 aTime.FormatL( aString, |
|
2249 iTimeDuratLong ); |
|
2250 } |
|
2251 else |
|
2252 { |
|
2253 aTime.FormatL( aString, |
|
2254 iTimeDuratMinSecWithZero ); |
|
2255 } |
|
2256 } |
|
2257 |
|
2258 // --------------------------------------------------------------------------- |
|
2259 // CVRRecViewModel::EnableVolumeControl |
|
2260 // Enables/Disables the navi pane Volume Control drawing in the VR current |
|
2261 // visual state |
|
2262 // --------------------------------------------------------------------------- |
|
2263 // |
|
2264 void CVRRecViewModel::EnableVolumeControl( TBool aVolumeControl ) |
|
2265 { |
|
2266 iState->iHasVolumeControl = aVolumeControl; |
|
2267 } |
|
2268 |
|
2269 // --------------------------------------------------------------------------- |
|
2270 // CVRRecViewModel::HasVolumeControl |
|
2271 // Returns ETrue if volume setting is enabled in this VoiceRecorder state. |
|
2272 // Otherwise returns EFalse |
|
2273 // --------------------------------------------------------------------------- |
|
2274 // |
|
2275 TBool CVRRecViewModel::HasVolumeControl() const |
|
2276 { |
|
2277 if( iState->iHasVolumeControl ) |
|
2278 { |
|
2279 return ETrue; |
|
2280 } |
|
2281 return EFalse; |
|
2282 } |
|
2283 |
|
2284 |
|
2285 // --------------------------------------------------------------------------- |
|
2286 // CVRRecViewModel::IncomingCall |
|
2287 // Returns ETrue if a phone call is coming. |
|
2288 // Otherwise returns EFalse |
|
2289 // --------------------------------------------------------------------------- |
|
2290 // |
|
2291 TBool CVRRecViewModel::IncomingCall() const |
|
2292 { |
|
2293 #ifdef _DEBUG |
|
2294 RDebug::Print( _L("CVRRecViewModel::IncomingCall enter") ); |
|
2295 #endif |
|
2296 |
|
2297 // Fetch the current value from Pubsub |
|
2298 TInt currentState = 0; |
|
2299 TRAP_IGNORE(currentState = iCurrentCallHandler->StateL( KPSUidCtsyCallInformation, KCTsyCallState )); |
|
2300 |
|
2301 if (currentState == EPSCTsyCallStateAlerting || |
|
2302 currentState == EPSCTsyCallStateRinging || |
|
2303 currentState == EPSCTsyCallStateAnswering ) |
|
2304 { |
|
2305 return ETrue; |
|
2306 } |
|
2307 else |
|
2308 { |
|
2309 return EFalse; |
|
2310 } |
|
2311 } |
|
2312 |
|
2313 |
|
2314 // --------------------------------------------------------------------------- |
|
2315 //Returns the active quality setting. |
|
2316 //return Quality setting of the active memo |
|
2317 // --------------------------------------------------------------------------- |
|
2318 TVRQuality CVRRecViewModel::Quality() const |
|
2319 { |
|
2320 return iMemo->Quality(); |
|
2321 } |
|
2322 |
|
2323 |
|
2324 // --------------------------------------------------------- |
|
2325 // GetInRecordingFlag |
|
2326 // |
|
2327 // --------------------------------------------------------- |
|
2328 // |
|
2329 TBool CVRRecViewModel::GetInRecordingFlag() |
|
2330 { |
|
2331 if(iRecorder) |
|
2332 { |
|
2333 return dynamic_cast<CVRMdaRecorder*>(iRecorder)->GetInRecordingFlag(); |
|
2334 } |
|
2335 else |
|
2336 { |
|
2337 return EFalse; |
|
2338 } |
|
2339 |
|
2340 } |
|
2341 |
|
2342 |
|
2343 // --------------------------------------------------------- |
|
2344 // GetIfStopCalled |
|
2345 // |
|
2346 // --------------------------------------------------------- |
|
2347 // |
|
2348 TBool CVRRecViewModel::GetIfStopCalled() |
|
2349 { |
|
2350 if(iRecorder) |
|
2351 { |
|
2352 return dynamic_cast<CVRMdaRecorder*>(iRecorder)->GetIfStopCalled(); |
|
2353 } |
|
2354 else |
|
2355 { |
|
2356 return EFalse; |
|
2357 } |
|
2358 |
|
2359 } |
|
2360 |
|
2361 |
|
2362 // --------------------------------------------------------- |
|
2363 // SetInRecordingFlag |
|
2364 // --------------------------------------------------------- |
|
2365 // |
|
2366 void CVRRecViewModel::SetInRecordingFlag(TBool aFlag) |
|
2367 { |
|
2368 if(iRecorder) |
|
2369 { |
|
2370 return dynamic_cast<CVRMdaRecorder*>(iRecorder)->SetInRecordingFlag(aFlag); |
|
2371 } |
|
2372 } |
|
2373 |
|
2374 |
|
2375 // --------------------------------------------------------------------------- |
|
2376 // CVRRecViewModel::HandleUSBEventL |
|
2377 // |
|
2378 // --------------------------------------------------------------------------- |
|
2379 // |
|
2380 void CVRRecViewModel::HandleUSBEventL() |
|
2381 { |
|
2382 // Fetch the changed value from Pubsub |
|
2383 TInt usbState( 0 ); |
|
2384 RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, usbState ); |
|
2385 if ( !iActive ) |
|
2386 { |
|
2387 return; |
|
2388 } |
|
2389 |
|
2390 // Actions to take when playing |
|
2391 if ( usbState == KUsbPersonalityIdMS ) |
|
2392 { |
|
2393 ShowNoteL( R_QTN_MEMC_VOREC_NOTE1, EAknGlobalInformationNote ); |
|
2394 // when not support multiple drives |
|
2395 #ifndef RD_MULTIPLE_DRIVE |
|
2396 if (iMemo->MemoStore() != EMemoStorePhoneMemory) |
|
2397 { |
|
2398 HandleCommandL( EEikCmdExit); |
|
2399 } |
|
2400 //multiple drive |
|
2401 #else |
|
2402 if (iMemo->StorageDrive() != VRUtils::DefaultMemoDriveL()) |
|
2403 { |
|
2404 |
|
2405 HandleCommandL( EEikCmdExit ); |
|
2406 } |
|
2407 #endif |
|
2408 } |
|
2409 |
|
2410 } |
|
2411 |
|
2412 |
|
2413 // End of file |
|