1 /* |
|
2 * Copyright (c) 2007-2010 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: Base class for all views used in the Camera application* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include "CamAppUi.h" |
|
21 #include "CamViewBase.h" |
|
22 #include "CamContainerBase.h" |
|
23 #include "CamStandbyContainer.h" |
|
24 #include "CamUtility.h" |
|
25 #include "CamPanic.h" |
|
26 #include <eikmenub.h> |
|
27 |
|
28 |
|
29 #include <StringLoader.h> |
|
30 #include <AknQueryDialog.h> |
|
31 #include <aknnotewrappers.h> |
|
32 |
|
33 #include <cameraapp.rsg> |
|
34 #include <vgacamsettings.rsg> |
|
35 #include <akntoolbar.h> |
|
36 |
|
37 #include "CamUtility.h" |
|
38 #include <AknWaitDialog.h> |
|
39 #include "CamWaitDialog.h" |
|
40 #include "CamCommandHandlerAo.h" |
|
41 #include "CameraUiConfigManager.h" |
|
42 #include "CamNaviProgressBarModel.h" |
|
43 |
|
44 |
|
45 static const TRect KCamCbaHiddenRect = TRect(640,640,640,640); |
|
46 |
|
47 |
|
48 // ========================= MEMBER FUNCTIONS ================================ |
|
49 |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CCamViewBase destructor |
|
53 // |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CCamViewBase::~CCamViewBase() |
|
57 { |
|
58 PRINT( _L("Camera => ~CCamViewBase" )) |
|
59 if ( iStandbyContainer ) |
|
60 { |
|
61 CAknViewAppUi* appUi = AppUi(); |
|
62 |
|
63 if ( appUi ) |
|
64 { |
|
65 appUi->RemoveFromStack( iStandbyContainer ); |
|
66 } |
|
67 |
|
68 delete iStandbyContainer; |
|
69 iStandbyContainer = NULL; |
|
70 } |
|
71 |
|
72 delete iContainer; |
|
73 iContainer = NULL; |
|
74 |
|
75 delete iCommandHandlerAo; |
|
76 iCommandHandlerAo = NULL; |
|
77 |
|
78 PRINT( _L("Camera <= ~CCamViewBase" )) |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CCamViewBase::HandleFocusLossL |
|
83 // Handle focus loss |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CCamViewBase::HandleFocusLossL() |
|
87 { |
|
88 // intentionally doing nothing |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // HandleAppEvent <<virtual>> |
|
93 // |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void |
|
97 CCamViewBase::HandleAppEvent( const TCamAppEvent& aEvent ) |
|
98 { |
|
99 PRINT1( _L("Camera => CCamViewBase::HandleAppEvent, event:%d"), aEvent ); |
|
100 if( iContainer ) |
|
101 { |
|
102 iContainer->HandleAppEvent( aEvent ); |
|
103 } |
|
104 PRINT( _L("Camera <= CCamViewBase::HandleAppEvent") ); |
|
105 } |
|
106 |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CCamViewBase::PrepareForModeChange |
|
110 // Prepare for mode change |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CCamViewBase::PrepareForModeChange() |
|
114 { |
|
115 // intentionally doing nothing |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CCamViewBase::HandleCommandL |
|
120 // Handle commands |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CCamViewBase::HandleCommandL( TInt aCommand ) |
|
124 { |
|
125 PRINT( _L("Camera => CCamViewBase::HandleCommandL")) |
|
126 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() ); |
|
127 |
|
128 switch(aCommand) |
|
129 { |
|
130 case ECamCmdInternalExit: |
|
131 { |
|
132 TInt standbyError = KErrNone; |
|
133 if ( iStandbyModeActive && iStandbyContainer ) |
|
134 { |
|
135 standbyError = iStandbyContainer->GetStandbyError(); |
|
136 ExitStandbyModeL(); |
|
137 } |
|
138 |
|
139 if ( standbyError != KErrNone ) |
|
140 { |
|
141 AppUi()->HandleCommandL( EEikCmdExit ); |
|
142 } |
|
143 else |
|
144 { |
|
145 AppUi()->HandleCommandL( aCommand ); |
|
146 } |
|
147 |
|
148 // dismiss menu - if open |
|
149 StopDisplayingMenuBar(); |
|
150 } |
|
151 break; |
|
152 |
|
153 case ECamCmdRedrawScreen: |
|
154 { |
|
155 if( iContainer ) |
|
156 { |
|
157 iContainer->DrawDeferred(); |
|
158 } |
|
159 } |
|
160 break; |
|
161 |
|
162 case ECamCmdRedrawVideoTime: |
|
163 { |
|
164 if( iContainer ) |
|
165 { |
|
166 if(appUi) |
|
167 { |
|
168 iContainer->DrawNow( appUi->NaviProgressBarModel()->ProgPaneRect() ); |
|
169 } |
|
170 else |
|
171 { |
|
172 iContainer->DrawDeferred(); |
|
173 } |
|
174 } |
|
175 } |
|
176 break; |
|
177 |
|
178 case ECamCmdRedrawZoom: |
|
179 { |
|
180 if( iContainer ) |
|
181 { |
|
182 if(appUi) |
|
183 { |
|
184 iContainer->DrawNow( appUi->ZoomPane()->Rect() ); |
|
185 } |
|
186 else |
|
187 { |
|
188 PRINT( _L("Camera <> CCamViewBase::HandleCommandL ECamCmdRedrawZoom zoomRect")) |
|
189 iContainer->DrawDeferred(); |
|
190 } |
|
191 } |
|
192 } |
|
193 break; |
|
194 |
|
195 default: |
|
196 { |
|
197 AppUi()->HandleCommandL( aCommand ); |
|
198 break; |
|
199 } |
|
200 } |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CCamViewBase::HandleForegroundEventL |
|
205 // Handle foreground event |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CCamViewBase::HandleForegroundEventL( TBool /*aForeground*/ ) |
|
209 { |
|
210 PRINT( _L("CCamViewBase::HandleForegroundEventL") ); |
|
211 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() ); |
|
212 iEmbedded = appUi->IsEmbedded(); |
|
213 PRINT1( _L("CCamViewBase::HandleForegroundEventL embedded %d"), iEmbedded ); |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // CCamViewBase::DoActivateL |
|
218 // Activate this view |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void |
|
222 CCamViewBase::DoActivateL( const TVwsViewId& /*aPostvViewId*/, |
|
223 TUid aCustomMessageId, |
|
224 const TDesC8& /*aCustomMessage*/ ) |
|
225 { |
|
226 PRINT( _L("Camera => CCamViewBase::DoActivateL")); |
|
227 |
|
228 CCamContainerBase::DestroyActivePalette(); |
|
229 |
|
230 |
|
231 if(ECamViewMessageDeactivateFirst == aCustomMessageId.iUid) |
|
232 { |
|
233 PRINT( _L("CCamViewBase::DoActivateL call deactivate")); |
|
234 TBool wasCameraUser = IsCameraUser(); |
|
235 |
|
236 PrepareDeactivate(); |
|
237 // since we still use it |
|
238 if( wasCameraUser ) |
|
239 { |
|
240 IncrementCameraUsers(); |
|
241 } |
|
242 } |
|
243 |
|
244 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() ); |
|
245 iEmbedded = appUi->IsEmbedded(); |
|
246 |
|
247 PRINT1( _L("CCamViewBase::DoActivateL Embedded %d"), iEmbedded); |
|
248 if ( !iContainer ) |
|
249 { |
|
250 CreateContainerL(); |
|
251 |
|
252 if( iTempContainer ) |
|
253 { |
|
254 AppUi()->RemoveFromStack( iTempContainer ); |
|
255 } |
|
256 AppUi()->AddToStackL( *this, iContainer ); |
|
257 iContainer->ActivateL(); |
|
258 } |
|
259 PostDeactivate(); |
|
260 |
|
261 SetTitlePaneTextL(); |
|
262 |
|
263 TInt orientation; |
|
264 TCamPsiKey queryValue = ECamPsiOrientation; |
|
265 CCameraUiConfigManager* configManager = iController.UiConfigManagerPtr(); |
|
266 |
|
267 if ( configManager && configManager->IsSecondaryCameraSupported() ) |
|
268 { |
|
269 if ( appUi->IsSecondCameraEnabled() && !appUi->IsQwerty2ndCamera() ) // if front camera is active |
|
270 { |
|
271 queryValue = ECamPsiSecondaryCameraOrientation; |
|
272 } |
|
273 else // back camera is active |
|
274 { |
|
275 queryValue = ECamPsiPrimaryCameraOrientation; |
|
276 } |
|
277 } |
|
278 |
|
279 CamUtility::GetPsiInt( queryValue, orientation ); |
|
280 |
|
281 AppUi()->SetOrientationL( ( CAknAppUiBase::TAppUiOrientation ) orientation ); |
|
282 |
|
283 TCamOrientation camOrientation = appUi->CamOrientation(); |
|
284 |
|
285 // if in camcorder mode need to show navi-ctr |
|
286 if( camOrientation == ECamOrientationCamcorder || |
|
287 camOrientation == ECamOrientationCamcorderLeft || |
|
288 camOrientation == ECamOrientationPortrait ) |
|
289 { |
|
290 iContainer->SetupNaviPanesL( CCamContainerBase::ECamPaneCounter ); |
|
291 } |
|
292 PRINT( _L("Camera <= CCamViewBase::DoActivateL")); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CCamViewBase::DoDeactivate |
|
297 // Deactivate this view |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CCamViewBase::DoDeactivate() |
|
301 { |
|
302 PRINT( _L("Camera => CCamViewBase::DoDeactivate" )) |
|
303 // Both standard container and standby container should be deactivated |
|
304 if ( iStandbyContainer ) // implies IsInStandbyMode |
|
305 { |
|
306 AppUi()->RemoveFromStack( iStandbyContainer ); |
|
307 delete iStandbyContainer; |
|
308 iStandbyContainer = NULL; |
|
309 SetStandbyModeActive( EFalse ); |
|
310 } |
|
311 |
|
312 if ( iContainer ) |
|
313 { |
|
314 AppUi()->RemoveFromStack( iContainer ); |
|
315 delete iContainer; |
|
316 iContainer = NULL; |
|
317 } |
|
318 |
|
319 PRINT( _L("Camera <= CCamViewBase::DoDeactivate" )) |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // CCamViewBase::PrepareDeactivate |
|
324 // Prepare deactivation of this view |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 void CCamViewBase::PrepareDeactivate() |
|
328 { |
|
329 PRINT( _L("Camera => CCamViewBase::PrepareDeactivate" )); |
|
330 // Both standard container and standby container should be deactivated |
|
331 // Store them for temporal variables until new containers have been |
|
332 // created. |
|
333 if ( iStandbyContainer ) // implies IsInStandbyMode |
|
334 { |
|
335 AppUi()->RemoveFromStack( iStandbyContainer ); |
|
336 iTempStandbyContainer=iStandbyContainer; |
|
337 iStandbyContainer = NULL; |
|
338 SetStandbyModeActive( EFalse ); |
|
339 } |
|
340 |
|
341 if ( iContainer ) |
|
342 { |
|
343 iTempContainer=iContainer; |
|
344 iContainer = NULL; |
|
345 } |
|
346 PRINT( _L("Camera <= CCamViewBase::PrepareDeactivate" )); |
|
347 } |
|
348 |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // CCamViewBase::PostDeactivate |
|
352 // Completed prepared deactivation of this view |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 void CCamViewBase::PostDeactivate() |
|
356 { |
|
357 PRINT( _L("Camera => CCamViewBase::PostDeactivate" )); |
|
358 // Both standard container and standby container should be deactivated |
|
359 if ( iTempStandbyContainer ) // implies IsInStandbyMode |
|
360 { |
|
361 delete iTempStandbyContainer; |
|
362 iTempStandbyContainer = NULL; |
|
363 } |
|
364 |
|
365 if ( iTempContainer ) |
|
366 { |
|
367 delete iTempContainer; |
|
368 iTempContainer = NULL; |
|
369 } |
|
370 PRINT( _L("Camera <= CCamViewBase::PostDeactivate" )); |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------------------------- |
|
374 // CCamViewBase::CCamViewBase |
|
375 // C++ constructor |
|
376 // --------------------------------------------------------------------------- |
|
377 // |
|
378 CCamViewBase::CCamViewBase( CCamAppController& aController ) |
|
379 : iController( aController ) |
|
380 { |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------------------------- |
|
384 // CCamViewBase::UpdateCbaL |
|
385 // Update softkeys to reflect current state |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 void CCamViewBase::UpdateCbaL() |
|
389 { |
|
390 } |
|
391 |
|
392 |
|
393 // ---------------------------------------------------- |
|
394 // CCamViewBase::BlankSoftKeysL |
|
395 // Blank the softkeys |
|
396 // ---------------------------------------------------- |
|
397 // |
|
398 void CCamViewBase::BlankSoftkeysL() |
|
399 { |
|
400 // blank the cba |
|
401 SetSoftKeysL( R_CAM_SOFTKEYS_BLANK ); |
|
402 } |
|
403 |
|
404 |
|
405 |
|
406 // --------------------------------------------------------------------------- |
|
407 // CCamViewBase::SwitchToStandbyModeL |
|
408 // Switches to standby mode |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 void CCamViewBase::SwitchToStandbyModeL( TCamAppViewIds aViewId, TInt aError ) |
|
412 { |
|
413 PRINT( _L("Camera => CCamViewBase::SwitchToStandbyModeL") ); |
|
414 // check if already in standby mode |
|
415 if( iStandbyModeActive ) |
|
416 { |
|
417 PRINT( _L("Camera <= CCamViewBase::SwitchToStandbyModeL: already in standby") ); |
|
418 return; |
|
419 } |
|
420 |
|
421 StatusPane()->MakeVisible( ETrue ); |
|
422 delete iStandbyContainer; |
|
423 iStandbyContainer = NULL; |
|
424 iStandbyContainer = CCamStandbyContainer::NewL( AppUi()->ClientRect(), |
|
425 *this, iController, aError ); |
|
426 // dismiss menu - if open |
|
427 StopDisplayingMenuBar(); |
|
428 |
|
429 // save options menu id for reactivation |
|
430 if ( aViewId == ECamViewIdStillPreCapture ) |
|
431 { |
|
432 if ( iEmbedded ) |
|
433 { |
|
434 iPreviousMenuResourceId = ROID(R_CAM_STILL_EMBEDDED_PRE_CAPTURE_MENUBAR_ID); |
|
435 } |
|
436 else |
|
437 { |
|
438 iPreviousMenuResourceId = ROID(R_CAM_STILL_PRE_CAPTURE_MENUBAR_ID); |
|
439 } |
|
440 } |
|
441 else if ( aViewId == ECamViewIdVideoPreCapture ) |
|
442 { |
|
443 if ( iEmbedded ) |
|
444 { |
|
445 iPreviousMenuResourceId = ROID(R_CAM_VIDEO_EMBEDDED_PRE_CAPTURE_MENUBAR_ID); |
|
446 } |
|
447 else |
|
448 { |
|
449 iPreviousMenuResourceId = ROID(R_CAM_VIDEO_PRE_CAPTURE_MENUBAR_ID); |
|
450 } |
|
451 } |
|
452 else if ( aViewId == ECamViewIdVideoSettings ) |
|
453 { |
|
454 iPreviousMenuResourceId = ROID(R_CAM_SETTINGS_LIST_MENUBAR_ID); |
|
455 } |
|
456 else if ( aViewId == ECamViewIdPhotoSettings ) |
|
457 { |
|
458 iPreviousMenuResourceId = ROID(R_CAM_SETTINGS_LIST_MENUBAR_ID); |
|
459 } |
|
460 else |
|
461 { |
|
462 // remove Lint error |
|
463 } |
|
464 |
|
465 // activate standby container and deactivate current container |
|
466 iStandbyContainer->SetMopParent( this ); |
|
467 |
|
468 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() ); |
|
469 appUi->AddToStackL( *this, iStandbyContainer ); |
|
470 iStandbyContainer->ActivateL(); |
|
471 appUi->RemoveFromStack( iContainer ); |
|
472 iContainer->MakeVisible( EFalse ); |
|
473 iStandbyContainer->MakeVisible( ETrue ); |
|
474 iStandbyContainer->DrawNow(); |
|
475 |
|
476 UnsetCourtesySoftKeysL(); |
|
477 |
|
478 // update softkeys |
|
479 if ( !appUi->IsConstructionComplete() ) |
|
480 { |
|
481 BlankSoftkeysL(); |
|
482 } |
|
483 else if ( appUi->StandbyStatus() == KErrInUse || |
|
484 appUi->StandbyStatus() == KErrPermissionDenied || |
|
485 appUi->StandbyStatus() == KErrAccessDenied ) |
|
486 { |
|
487 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT ); |
|
488 } |
|
489 else if ( iEmbedded ) |
|
490 { |
|
491 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_BACK__CONTINUE ); |
|
492 } |
|
493 else |
|
494 { |
|
495 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__CONTINUE ); |
|
496 if( Cba() && !appUi->IsRecoverableStatus() ) |
|
497 { |
|
498 Cba()->MakeCommandVisible( ECamCmdExitStandby, EFalse ); |
|
499 } |
|
500 } |
|
501 |
|
502 // change options menu |
|
503 CEikMenuBar* menuBar = MenuBar(); |
|
504 if ( menuBar ) |
|
505 { |
|
506 menuBar->SetMenuTitleResourceId( R_CAM_STANDBY_MENUBAR ); |
|
507 } |
|
508 |
|
509 // if ( iStandbyError != KErrNone ) |
|
510 if ( appUi->StandbyStatus() != KErrNone && appUi->IsRecoverableStatus()) |
|
511 { |
|
512 // stop idle timer - non recoverable error |
|
513 iController.StopIdleTimer(); |
|
514 } |
|
515 |
|
516 SetStandbyModeActive(ETrue); |
|
517 |
|
518 UpdateCbaL(); |
|
519 if ( Cba() ) |
|
520 { |
|
521 Cba()->DrawNow(); |
|
522 } |
|
523 |
|
524 |
|
525 // Release the camera hardware |
|
526 iController.ReleaseCamera(); |
|
527 |
|
528 |
|
529 // cancel self timer mode if active |
|
530 if ( appUi->SelfTimerEnabled() ) |
|
531 { |
|
532 appUi->SelfTimerEnableL( ECamSelfTimerDisabled ); |
|
533 } |
|
534 PRINT( _L("Camera <= CCamViewBase::SwitchToStandbyModeL") ); |
|
535 } |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // CCamViewBase::ExitStandbyModeL |
|
539 // Exits standby mode |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 void CCamViewBase::ExitStandbyModeL() |
|
543 { |
|
544 PRINT( _L("Camera => CCamViewBase::ExitStandbyModeL") ); |
|
545 if ( !iStandbyModeActive ) |
|
546 { |
|
547 return; |
|
548 } |
|
549 |
|
550 // delete standby container and reactivate previous container |
|
551 TRAPD( err, AppUi()->AddToStackL( *this, iContainer ) ) |
|
552 iStandbyContainer->MakeVisible( EFalse ); |
|
553 AppUi()->RemoveFromStack( iStandbyContainer ); |
|
554 delete iStandbyContainer; |
|
555 iStandbyContainer = NULL; |
|
556 User::LeaveIfError( err ); |
|
557 |
|
558 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() ); |
|
559 |
|
560 |
|
561 iContainer->MakeVisible( ETrue ); |
|
562 SetStandbyModeActive( EFalse ); |
|
563 |
|
564 if ( appUi->IsSecondCameraEnabled() && !appUi->IsQwerty2ndCamera() ) |
|
565 { |
|
566 StatusPane()->MakeVisible( ETrue ); |
|
567 } |
|
568 else |
|
569 { |
|
570 StatusPane()->MakeVisible( EFalse ); |
|
571 } |
|
572 |
|
573 CCameraUiConfigManager* configManager = iController.UiConfigManagerPtr(); |
|
574 if ( !( configManager && configManager->IsUIOrientationOverrideSupported() ) ) |
|
575 { |
|
576 appUi->RaisePreCaptureCourtesyUI(ETrue); |
|
577 } |
|
578 |
|
579 if ( iPreviousMenuResourceId == ROID(R_CAM_SETTINGS_LIST_MENUBAR_ID) |
|
580 || iPreviousMenuResourceId == ROID(R_CAM_STILL_EMBEDDED_PRE_CAPTURE_MENUBAR_ID) |
|
581 || iPreviousMenuResourceId == ROID(R_CAM_VIDEO_EMBEDDED_PRE_CAPTURE_MENUBAR_ID)) |
|
582 { |
|
583 if ( iController.CaptureModeTransitionInProgress() ) |
|
584 { |
|
585 SetSoftKeysL( R_AVKON_SOFTKEYS_BACK ); |
|
586 } |
|
587 else |
|
588 { |
|
589 SetSoftKeysL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
590 } |
|
591 } |
|
592 else |
|
593 { |
|
594 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT ); |
|
595 } |
|
596 |
|
597 // restore options menu |
|
598 CEikMenuBar* menuBar = MenuBar(); |
|
599 if ( menuBar ) |
|
600 { |
|
601 menuBar->SetMenuTitleResourceId( iPreviousMenuResourceId ); |
|
602 } |
|
603 |
|
604 //SetStandbyModeActive(EFalse); |
|
605 SetTitlePaneTextL(); |
|
606 |
|
607 // restart idle timer |
|
608 iController.StartIdleTimer(); |
|
609 PRINT( _L("Camera <= CCamViewBase::ExitStandbyModeL") ); |
|
610 } |
|
611 |
|
612 |
|
613 // --------------------------------------------------------------------------- |
|
614 // ExitAllModesL <<virtual>> |
|
615 // --------------------------------------------------------------------------- |
|
616 // |
|
617 void |
|
618 CCamViewBase::ExitAllModesL() |
|
619 { |
|
620 // Empty default implementation. |
|
621 } |
|
622 |
|
623 |
|
624 // --------------------------------------------------------------------------- |
|
625 // CCamViewBase::GetHelpContext |
|
626 // Called to identify the help context for this view |
|
627 // --------------------------------------------------------------------------- |
|
628 // |
|
629 void CCamViewBase::GetHelpContext( TCoeHelpContext& /*aContext*/ ) const |
|
630 { |
|
631 // No context |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // CCamViewBase::QueryRenameL |
|
636 // Switches orientation if required - calls DoQueryRenameL |
|
637 // --------------------------------------------------------------------------- |
|
638 // |
|
639 void CCamViewBase::QueryRenameL( TCamCameraMode aMode ) |
|
640 { |
|
641 // Ensure application is in editing orientation |
|
642 TInt error = KErrNone; |
|
643 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() ); |
|
644 TInt editingOrientation = CAknAppUiBase::EAppUiOrientationUnspecified; |
|
645 |
|
646 error = CamUtility::GetPsiInt( ECamPsiOrientation, editingOrientation ); |
|
647 |
|
648 if ( !error ) |
|
649 { |
|
650 appUi->SwitchOrientationIfRequiredL( editingOrientation ); |
|
651 } |
|
652 // Trap this to make sure the orientation is reverted back to normal |
|
653 TRAPD( leaveErr, DoQueryRenameL( aMode ) ) |
|
654 appUi->SwitchOrientationIfRequiredL( CAknAppUiBase::EAppUiOrientationUnspecified ); |
|
655 User::LeaveIfError( leaveErr ); |
|
656 } |
|
657 |
|
658 // --------------------------------------------------------------------------- |
|
659 // CCamViewBase:DoQueryRenameL |
|
660 // Show rename query and rename file. |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 void CCamViewBase::DoQueryRenameL( TCamCameraMode aMode ) |
|
664 { |
|
665 TBool done = EFalse; |
|
666 HBufC* lastFilePath = HBufC::NewLC( iController.CurrentFullFileName().Length() ); |
|
667 TBuf<KMaxNameBaseLengthPlusNumbering> filename( iController.CurrentImageName() ); |
|
668 |
|
669 // Repeat until successfully renamed or cancelled |
|
670 while ( !done ) |
|
671 { |
|
672 // Show rename query |
|
673 if ( ShowRenameQueryL( filename, aMode ) ) |
|
674 { |
|
675 // Try to rename file |
|
676 TRAPD( err, done = RenameCurrentFileL( filename, aMode ) ); |
|
677 if ( KErrAlreadyExists == err ) |
|
678 { |
|
679 // File exists -> show overwrite confirmation query |
|
680 if ( ShowOverwriteConfirmationQueryL( filename ) ) |
|
681 { |
|
682 // Yes, overwrite |
|
683 TPtr lastFilePathPtr = lastFilePath->Des(); |
|
684 lastFilePathPtr = iController.CurrentFullFileName(); |
|
685 TParsePtr parseptr( lastFilePathPtr ); |
|
686 TFileName fullpath = parseptr.DriveAndPath(); |
|
687 fullpath.Append( filename ); |
|
688 fullpath.Append( parseptr.Ext() ); |
|
689 |
|
690 // Delete the file that gets overwritten. |
|
691 if ( ECamControllerVideo != aMode ) |
|
692 { |
|
693 CamUtility::DeleteStillImageL( fullpath ); |
|
694 } |
|
695 else |
|
696 { |
|
697 CamUtility::DeleteVideoL( fullpath ); |
|
698 } |
|
699 |
|
700 // Rename |
|
701 RenameCurrentFileL( filename, aMode ); |
|
702 done = ETrue; |
|
703 } |
|
704 else // No, don't overwrite |
|
705 { |
|
706 // Generate a suitable suggestion for an unique name |
|
707 TInt key = ( ECamControllerVideo == aMode ) |
|
708 ? ECamSettingItemVideoNumber |
|
709 : ECamSettingItemPhotoNumber; |
|
710 TInt fileNameCounter = iController.IntegerSettingValue( key ); |
|
711 |
|
712 TParsePtrC parse( iController.CurrentFullFileName() ); |
|
713 TFileName filePath = parse.DriveAndPath(); |
|
714 |
|
715 const TUint KMax3Digits = 999; |
|
716 |
|
717 //if 0 < fileNameCounter <= 999, formatted file name like "Photo001", the length of number part ("001") is fixed 3 |
|
718 const TUint KFixedNumberLength = 3; |
|
719 |
|
720 TBool exceedMaxFileNameLength = EFalse; |
|
721 //if 0 < fileNameCounter <= 999, formatted file name like "Photo001" |
|
722 if ( fileNameCounter > 0 && |
|
723 fileNameCounter <= KMax3Digits && |
|
724 filename.Length() + KFixedNumberLength > filename.MaxLength() ) |
|
725 { |
|
726 exceedMaxFileNameLength = ETrue; |
|
727 } |
|
728 //if fileNameCounter > 999, formatted file name like "Photo1234" |
|
729 else if ( fileNameCounter > KMax3Digits ) |
|
730 { |
|
731 _LIT( KCamNameFormatFileNameCounter, "%d" ); |
|
732 TBuf<KMaxNameBaseLengthPlusNumbering> strFileNameCounter; |
|
733 strFileNameCounter.Format( KCamNameFormatFileNameCounter, fileNameCounter ); |
|
734 if ( filename.Length() + strFileNameCounter.Length() > filename.MaxLength() ) |
|
735 { |
|
736 exceedMaxFileNameLength = ETrue; |
|
737 } |
|
738 } |
|
739 |
|
740 if ( !exceedMaxFileNameLength ) |
|
741 { |
|
742 CamUtility::GetUniqueNameL( filePath, filename, fileNameCounter, parse.Ext() ); |
|
743 } |
|
744 |
|
745 |
|
746 } |
|
747 } |
|
748 else |
|
749 { |
|
750 // If unknown error |
|
751 User::LeaveIfError( err ); |
|
752 } |
|
753 } |
|
754 else |
|
755 { |
|
756 // User cancelled (ShowRenameQueryL() returned false) |
|
757 done = ETrue; |
|
758 } |
|
759 } |
|
760 CleanupStack::PopAndDestroy(); // lastFilePath |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // CCamViewBase::ShowOverwriteConfirmationQueryL |
|
765 // Show an overwrite confirmation query. This is used |
|
766 // when trying to overwrite a file using rename. |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 TBool CCamViewBase::ShowOverwriteConfirmationQueryL( |
|
770 const TDesC& aFilename ) |
|
771 { |
|
772 HBufC* prompt = StringLoader::LoadLC( R_QTN_FLDR_OVERWRITE_QUERY, |
|
773 aFilename, CEikonEnv::Static() ); |
|
774 |
|
775 CAknQueryDialog* overwriteQuery = |
|
776 new ( ELeave ) CAknQueryDialog( *prompt ); |
|
777 TBool result = overwriteQuery->ExecuteLD( R_CAM_OVERWRITE_QUERY ); |
|
778 |
|
779 CleanupStack::PopAndDestroy(); // prompt |
|
780 |
|
781 return result; |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------------------------- |
|
785 // CCamViewBase::ShowRenameQueryL |
|
786 // Show rename query. |
|
787 // --------------------------------------------------------------------------- |
|
788 // |
|
789 TBool CCamViewBase::ShowRenameQueryL( TDes& aFilename, TCamCameraMode aMode ) |
|
790 { |
|
791 TBool done = EFalse; |
|
792 TBool res = ETrue; |
|
793 |
|
794 while ( !done ) |
|
795 { |
|
796 // Show data query |
|
797 HBufC* prompt = NULL; |
|
798 if ( ECamControllerVideo == aMode ) |
|
799 { |
|
800 prompt = |
|
801 StringLoader::LoadLC( R_CAM_QUERY_VIDEO_NAME ); |
|
802 } |
|
803 else |
|
804 { |
|
805 prompt = |
|
806 StringLoader::LoadLC( R_CAM_QUERY_IMAGE_NAME ); |
|
807 } |
|
808 |
|
809 CAknTextQueryDialog* nameQuery = |
|
810 CAknTextQueryDialog::NewL( aFilename ); |
|
811 nameQuery->SetMaxLength( KMaxNameBaseLengthPlusNumbering ); |
|
812 nameQuery->PrepareLC( R_CAM_RENAME_QUERY ); |
|
813 nameQuery->SetPromptL( *prompt ); |
|
814 |
|
815 TBool dialogRes = ( nameQuery->RunLD() == EAknSoftkeyOk ); |
|
816 if ( dialogRes ) |
|
817 { |
|
818 if ( !IsNewNameValidL( aFilename ) ) |
|
819 { |
|
820 // New name is not valid for another reason. |
|
821 // In practise, the user has attempted to overwrite |
|
822 // an image already existing in the burst grid. |
|
823 |
|
824 HBufC* text = StringLoader::LoadLC( |
|
825 R_QTN_FLDR_CANT_RENAME_ITEM, |
|
826 iController.CurrentImageName() ); |
|
827 |
|
828 CAknNoteWrapper* note = new ( ELeave ) CAknNoteWrapper(); |
|
829 note->ExecuteLD( R_CAM_UNABLE_TO_RENAME, *text ); |
|
830 |
|
831 CleanupStack::PopAndDestroy(); // text |
|
832 |
|
833 // Don't show dialog again |
|
834 res = EFalse; |
|
835 done = ETrue; |
|
836 } |
|
837 else if ( CamUtility::CheckFileNameValidityL( aFilename ) ) |
|
838 { |
|
839 // New file name seems ok |
|
840 res = ETrue; |
|
841 done = ETrue; |
|
842 } |
|
843 else |
|
844 { |
|
845 // File name is not suitable, ask again |
|
846 } |
|
847 } |
|
848 else |
|
849 { |
|
850 // User cancelled rename |
|
851 res = EFalse; |
|
852 done = ETrue; |
|
853 } |
|
854 |
|
855 CleanupStack::PopAndDestroy(); // prompt |
|
856 } |
|
857 |
|
858 return res; |
|
859 } |
|
860 |
|
861 // --------------------------------------------------------------------------- |
|
862 // CCamViewBase::IsNewNameValidL |
|
863 // Check if renaming to the given name is valid. |
|
864 // --------------------------------------------------------------------------- |
|
865 // |
|
866 TBool CCamViewBase::IsNewNameValidL( const TDesC& /* aFilename */ ) |
|
867 { |
|
868 // This should be overridden in derived classes if needed |
|
869 return ETrue; |
|
870 } |
|
871 |
|
872 // --------------------------------------------------------------------------- |
|
873 // CCamViewBase::RenameCurrentFileL |
|
874 // Renames the current capture array file. |
|
875 // --------------------------------------------------------------------------- |
|
876 // |
|
877 TBool |
|
878 CCamViewBase::RenameCurrentFileL( const TDesC& aNewName, |
|
879 TCamCameraMode aMode ) |
|
880 { |
|
881 return iController.RenameCurrentFileL( aNewName, aMode ); |
|
882 } |
|
883 |
|
884 // --------------------------------------------------------------------------- |
|
885 // CCamViewBase::Container |
|
886 // Returns the currently used container in the view. |
|
887 // --------------------------------------------------------------------------- |
|
888 // |
|
889 CCamContainerBase* CCamViewBase::Container() |
|
890 { |
|
891 if ( iStandbyContainer ) |
|
892 { |
|
893 return iStandbyContainer; |
|
894 } |
|
895 else |
|
896 { |
|
897 return iContainer; |
|
898 } |
|
899 } |
|
900 |
|
901 // --------------------------------------------------------------------------- |
|
902 // CCamViewBase::SetSoftKeysL |
|
903 // Sets the softkeys to the specified Resource ID |
|
904 // --------------------------------------------------------------------------- |
|
905 // |
|
906 void CCamViewBase::SetSoftKeysL(TInt aResource) |
|
907 { |
|
908 PRINT1( _L("Camera => CCamViewBase::SetSoftKeysL SoftKeys:0x%x"), aResource ); |
|
909 |
|
910 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() ); |
|
911 // If courtesy softkeys are enabled, check whether the UI can be drawn without being explicitly raised |
|
912 // (rare, but possible: e.g. when video recording starts |
|
913 if(aResource == R_CAM_SOFTKEYS_BLANK && |
|
914 appUi->IsSecondCameraEnabled() && |
|
915 !appUi->IsQwerty2ndCamera()) |
|
916 { |
|
917 aResource = R_CAM_SOFTKEYS_BLANK_SECONDARY; |
|
918 } |
|
919 if ( iCourtesySoftkeys ) |
|
920 { |
|
921 if ( appUi ) |
|
922 { |
|
923 if ( (IsPreCapture() && appUi->DrawPreCaptureCourtesyUI()) |
|
924 || (IsPostCapture() && appUi->DrawPostCaptureCourtesyUI()) ) |
|
925 { |
|
926 // Disable the courtesy softkeys, otherwise nothing will be drawn when the rest of the |
|
927 // courtesy UI has been turned back on |
|
928 iCourtesySoftkeys = EFalse; |
|
929 |
|
930 //when disabling the courtesy softkeys, Cba should be recovered to be visible |
|
931 Cba()->MakeVisible( ETrue ); |
|
932 } |
|
933 } |
|
934 } |
|
935 |
|
936 if ( iCourtesySoftkeys || !Cba() ) |
|
937 { |
|
938 // If the courtesy (blank) softkeys are being shown, make a note of what to change back to. |
|
939 iPreviousCbaResource = aResource; |
|
940 } |
|
941 else if ( iCurrentCbaResource != aResource ) |
|
942 { |
|
943 iPreviousCbaResource = iCurrentCbaResource; |
|
944 iCurrentCbaResource = aResource; |
|
945 |
|
946 Cba()->SetCommandSetL( aResource ); |
|
947 Cba()->DrawDeferred(); |
|
948 |
|
949 } |
|
950 |
|
951 PRINT( _L("Camera <= CCamViewBase::SetSoftKeysL") ); |
|
952 } |
|
953 |
|
954 |
|
955 // --------------------------------------------------------------------------- |
|
956 // CCamViewBase::SetCourtesySoftKeysL |
|
957 // Blanks the softkeys for the Courtesy UI Off state. |
|
958 // --------------------------------------------------------------------------- |
|
959 // |
|
960 void CCamViewBase::SetCourtesySoftKeysL() |
|
961 { |
|
962 if ( !iCourtesySoftkeys ) |
|
963 { |
|
964 Cba()->MakeVisible( EFalse ); |
|
965 iPreviousCbaResource = iCurrentCbaResource; |
|
966 iCourtesySoftkeys = ETrue; |
|
967 } |
|
968 } |
|
969 |
|
970 // --------------------------------------------------------------------------- |
|
971 // CCamViewBase::UnsetCourtesySoftKeysL |
|
972 // Returns the softkeys to their previous state after UI has been turned back on |
|
973 // --------------------------------------------------------------------------- |
|
974 // |
|
975 void CCamViewBase::UnsetCourtesySoftKeysL() |
|
976 { |
|
977 if ( iCourtesySoftkeys ) |
|
978 { |
|
979 iCourtesySoftkeys = EFalse; |
|
980 SetSoftKeysL(iPreviousCbaResource); |
|
981 Cba()->MakeVisible( ETrue ); |
|
982 } |
|
983 } |
|
984 |
|
985 // --------------------------------------------------------------------------- |
|
986 // CCamViewBase::IsPreCapture |
|
987 // Returns whether the view is a precapture view |
|
988 // --------------------------------------------------------------------------- |
|
989 // |
|
990 TBool CCamViewBase::IsPreCapture() |
|
991 { |
|
992 return EFalse; |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------------------------- |
|
996 // CCamViewBase::IsPostCapture |
|
997 // Returns whether the view is a postcapture view |
|
998 // --------------------------------------------------------------------------- |
|
999 // |
|
1000 TBool CCamViewBase::IsPostCapture() |
|
1001 { |
|
1002 return EFalse; |
|
1003 } |
|
1004 |
|
1005 // --------------------------------------------------------------------------- |
|
1006 // CCamViewBase::IsBurstPostCapture |
|
1007 // Returns whether the view is a burst mode postcapture view |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // |
|
1010 TBool CCamViewBase::IsBurstPostCapture() |
|
1011 { |
|
1012 return EFalse; |
|
1013 } |
|
1014 |
|
1015 |
|
1016 // --------------------------------------------------------------------------- |
|
1017 // CCamViewBase::IsInStandbyMode |
|
1018 // Returns whether the view is in standby mode |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // |
|
1021 TBool CCamViewBase::IsInStandbyMode() |
|
1022 { |
|
1023 return iStandbyModeActive; |
|
1024 } |
|
1025 |
|
1026 |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // CCamViewBase::SetStandbyModeActive |
|
1029 // Sets the iStandbyModeActive flag |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // |
|
1032 void CCamViewBase::SetStandbyModeActive(TBool aActive) |
|
1033 { |
|
1034 // This should be the only place iStandbyModeActive is set! |
|
1035 // We need to inform the AppUi |
|
1036 iStandbyModeActive = aActive; |
|
1037 if( iController.IsAppUiAvailable() ) |
|
1038 { |
|
1039 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() ); |
|
1040 |
|
1041 if ( appUi) |
|
1042 { |
|
1043 if ( aActive ) |
|
1044 { |
|
1045 appUi->SetPreCaptureMode(ECamPreCapStandby); |
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 appUi->SetPreCaptureMode(ECamPreCapViewfinder); |
|
1050 } |
|
1051 } |
|
1052 } |
|
1053 } |
|
1054 |
|
1055 |
|
1056 // --------------------------------------------------------------------------- |
|
1057 // CCamViewBase::IncrementCameraUsers |
|
1058 // |
|
1059 // --------------------------------------------------------------------------- |
|
1060 // |
|
1061 void |
|
1062 CCamViewBase::IncrementCameraUsers() |
|
1063 { |
|
1064 if( !iIncEngineCount ) |
|
1065 { |
|
1066 PRINT( _L("Camera == CCamViewBase::IncrementCameraUsers - incrementing") ); |
|
1067 iIncEngineCount = ETrue; |
|
1068 iController.IncCameraUsers(); |
|
1069 } |
|
1070 else |
|
1071 { |
|
1072 PRINT( _L("Camera == CCamViewBase::IncrementCameraUsers - already incremented, skipping") ); |
|
1073 } |
|
1074 } |
|
1075 |
|
1076 |
|
1077 // --------------------------------------------------------------------------- |
|
1078 // CCamViewBase::DecrementCameraUsers |
|
1079 // |
|
1080 // --------------------------------------------------------------------------- |
|
1081 // |
|
1082 void |
|
1083 CCamViewBase::DecrementCameraUsers() |
|
1084 { |
|
1085 if( iIncEngineCount ) |
|
1086 { |
|
1087 PRINT( _L("Camera == CCamViewBase::DecrementCameraUsers - decrementing") ); |
|
1088 iIncEngineCount = EFalse; |
|
1089 iController.DecCameraUsers(); |
|
1090 } |
|
1091 else |
|
1092 { |
|
1093 PRINT( _L("Camera == CCamViewBase::DecrementCameraUsers - not using camera, skipped") ); |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // CCamViewBase::IsCameraUser |
|
1100 // |
|
1101 // --------------------------------------------------------------------------- |
|
1102 // |
|
1103 TBool |
|
1104 CCamViewBase::IsCameraUser() const |
|
1105 { |
|
1106 return iIncEngineCount; |
|
1107 } |
|
1108 |
|
1109 |
|
1110 |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // CCamViewBase::RedrawAPArea |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 void CCamViewBase::RedrawAPArea(const TRect& aArea) |
|
1115 { |
|
1116 if ( iContainer ) |
|
1117 { |
|
1118 iContainer->Redraw(aArea); |
|
1119 } |
|
1120 } |
|
1121 |
|
1122 |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // CCamViewBase::ViewCba |
|
1125 // ----------------------------------------------------------------------------- |
|
1126 CEikButtonGroupContainer* CCamViewBase::ViewCba() |
|
1127 { |
|
1128 return Cba(); |
|
1129 } |
|
1130 |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // CCamViewBase::UpdateToolbarIconsL |
|
1133 // |
|
1134 void CCamViewBase::UpdateToolbarIconsL() |
|
1135 { |
|
1136 |
|
1137 } |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // CCamViewBase::HandleCommandAoL |
|
1140 // ----------------------------------------------------------------------------- |
|
1141 |
|
1142 void CCamViewBase::HandleCommandAoL( TInt aCommand ) |
|
1143 { |
|
1144 if ( !iCommandHandlerAo ) |
|
1145 { |
|
1146 iCommandHandlerAo = CCamCommandHandlerAo::NewL( this ); |
|
1147 } |
|
1148 iCommandHandlerAo->HandleCommandL( aCommand ); |
|
1149 } |
|
1150 |
|
1151 // ----------------------------------------------------------------------------- |
|
1152 // CCamViewBase::SetStandbyStatusL |
|
1153 // ----------------------------------------------------------------------------- |
|
1154 |
|
1155 void CCamViewBase::SetStandbyStatusL( TInt aError ) |
|
1156 { |
|
1157 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() ); |
|
1158 __ASSERT_DEBUG( appUi, CamPanic( ECamPanicNullPointer ) ); |
|
1159 if( iStandbyModeActive ) |
|
1160 { |
|
1161 appUi->SetStandbyStatus( aError ); |
|
1162 iStandbyContainer->SetStandbyErrorL( aError ); |
|
1163 if ( aError == KErrInUse || |
|
1164 aError == KErrPermissionDenied || |
|
1165 aError == KErrAccessDenied ) |
|
1166 { |
|
1167 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT ); |
|
1168 } |
|
1169 else if ( iEmbedded ) |
|
1170 { |
|
1171 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_BACK__CONTINUE ); |
|
1172 } |
|
1173 else |
|
1174 { |
|
1175 SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__CONTINUE ); |
|
1176 if( Cba() && !appUi->IsRecoverableStatus() ) |
|
1177 { |
|
1178 Cba()->MakeCommandVisible( ECamCmdExitStandby, EFalse ); |
|
1179 } |
|
1180 else |
|
1181 { |
|
1182 Cba()->MakeCommandVisible( ECamCmdExitStandby, ETrue ); |
|
1183 } |
|
1184 } |
|
1185 } |
|
1186 } |
|
1187 // End of File |
|