vtuis/videotelui/src/CVtUiAppUi.cpp
changeset 0 ed9695c8bcbe
child 1 4fbbce2c82ba
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2004 - 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of the CVtUiAppUi application UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "videotelui.hrh"
       
    22 #include    "CVtUiAppUi.h"
       
    23 #include    "CVtUiMainControl.h"
       
    24 #include    "CVtUiContextControl.h"
       
    25 #include    "CVtUiNumberEntryActivationControl.h"
       
    26 #include    "CVtUiNaviPane.h"
       
    27 #include    "VtUiLayout.h"
       
    28 #include    "MVtUiEngineCommandManager.h"
       
    29 #include    "CVtUiExecuteCmdDialog.h"
       
    30 #include    "CVtUiAllowVideoDialog.h"
       
    31 #include    "CVtUiBlankControl.h"
       
    32 #include    "VtUiLayout.h"
       
    33 #include    "VtUiUtility.h"
       
    34 #include    "VtUiPanic.h"
       
    35 #include    "CVtUiActivateBtHfDialog.h"
       
    36 #include    "CVtUiRemoteVideoControl.h"
       
    37 #include    <csxhelp/incl.hlp.hrh>
       
    38 
       
    39 
       
    40 #include    <aknincallbubblenotify.h>
       
    41 #include    <aknslayeredbackgroundcontrolcontext.h>
       
    42 #include    <aknutils.h>
       
    43 #include    <aknnavi.h>
       
    44 #include    <akntitle.h>
       
    45 #include    <akndlgshut.h>
       
    46 #include    <aknnotedialog.h>
       
    47 #include    <aknnotewrappers.h>
       
    48 #include    <akncontext.h>
       
    49 #include    <eikspane.h>
       
    50 #include    <eikmenup.h>
       
    51 #include    <eikmenub.h>
       
    52 #include    <apgcli.h>
       
    53 #include    <featmgr.h>
       
    54 #include    <videotelui.rsg>
       
    55 #include    <hlplch.h>
       
    56 #include    <apgwgnam.h>
       
    57 #include    <stringloader.h>
       
    58 #include    <akndef.h>
       
    59 #include    <aknconsts.h>
       
    60 
       
    61 
       
    62 #include    <e32property.h>
       
    63 #include    <ecom/ecom.h>
       
    64 #include    <coreapplicationuisdomainpskeys.h>
       
    65 #include    <uikoninternalpskeys.h>
       
    66 #include    <centralrepository.h>
       
    67 #include    <videotelephonyinternalcrkeys.h>
       
    68 #include    <settingsinternalcrkeys.h>
       
    69 #include    <e32property.h>
       
    70 #include    <telcommsinfopskeys.h>
       
    71 #include    <telinformationpskeys.h>
       
    72 #include    <activeidle2domainpskeys.h>
       
    73 #include 	<ctsydomainpskeys.h>
       
    74 
       
    75 #include    <aknquerydialog.h>
       
    76 #include 	<aknglobalnote.h>
       
    77 #include 	<aknsoundsystem.h>
       
    78 
       
    79 
       
    80 #include    <cvtlogger.h>
       
    81 #include    <cvtengmodel.h>
       
    82 #include    <mvtengeventobserver.h>
       
    83 #include    <mvtengcommandobserver.h>
       
    84 #include    <mvtengcommandhandler.h>
       
    85 #include    <mvtengframeobserver.h>
       
    86 #include    <mvtengaudio.h>
       
    87 #include    <mvtengsessioninfo.h>
       
    88 #include    <vtengevents.h>
       
    89 #include    <mvtengmedia.h>
       
    90 
       
    91 #include    "CVtUiBitmapManager.h"
       
    92 
       
    93 #include    <mgfetch.h>
       
    94 #include    <mmgfetchverifier.h>
       
    95 #include    <caf/manager.h>
       
    96 #include    <caf/virtualpathptr.h>
       
    97 
       
    98 #include    "cvtuifeaturemanager.h"
       
    99 #include    "cvtuicomponentmanager.h"
       
   100 #include    "cvtuicommandmanager.h"
       
   101 #include    "tvtuistates.h"
       
   102 #include    "cvtuimenus.h"
       
   103 #include    "cvtuisoftkeys.h"
       
   104 #include    "cvtuitoolbarbase.h"
       
   105 #include    "cvtuiwhitebalance.h"
       
   106 #include    "cvtuicolortone.h"
       
   107 #include    "cvtuibrightness.h"
       
   108 #include    "cvtuicontrast.h"
       
   109 #include    <remconinterfaceselector.h>
       
   110 #include    <remconcoreapitarget.h>
       
   111 #include    <remconcoreapitargetobserver.h>
       
   112 #include    "tvtuiwsevent.h"
       
   113 #include    "mvtuinumbersource.h"
       
   114 #include	"tVtuifeaturevariation.h"
       
   115 #include    "cvtuidialer.h"
       
   116 #include    "tvtuiappstates.h"
       
   117 #include    "cvtuivolume.h"
       
   118 #include    "cvtuizoom.h"
       
   119 #include    "cvtuivolumecontrol.h"
       
   120 
       
   121 using namespace ContentAccess;
       
   122 
       
   123 // CONSTANTS
       
   124 
       
   125 // Engine orientation to application orientation map
       
   126 const CVtUiAppUi::TAppUiOrientation engToAppOrientation[] = {
       
   127     CVtUiAppUi::EAppUiOrientationLandscape,
       
   128     CVtUiAppUi::EAppUiOrientationPortrait,
       
   129     CVtUiAppUi::EAppUiOrientationUnspecified };
       
   130 
       
   131 // Amount of help contexts.
       
   132 const TInt KVtUiHelpContextAmount = 1;
       
   133 
       
   134 // UID of Video Telephone application.
       
   135 const TUid KVtUiAppUid = { KVtUiAppUidValue };
       
   136 
       
   137 // Granularity of command observer array.
       
   138 const TInt KVtUiCommandObserverArrayGranularity = 5;
       
   139 
       
   140 // Default call index.
       
   141 const TInt KVtUiDefaultCallId = 1;
       
   142 
       
   143 // Control priority for the blank control. Above all other controls.
       
   144 const TInt KVtUiBlankControlPriority =
       
   145     ECoeStackPriorityEnvironmentFilter + 100;
       
   146 
       
   147 // Exit timeout.
       
   148 const TInt KVtUiExitTimeout = 10000000;
       
   149 
       
   150 // UID of the main telephone application
       
   151 const TUid KVtUiTelephoneUid = { 0x100058B3 };
       
   152 
       
   153 // Reset value for volume
       
   154 const TInt  KVolumeResetValue = -1;
       
   155 
       
   156 
       
   157 // Name of the EIKON server window group.
       
   158 _LIT( KVtUiEikonServer, "EikonServer" );
       
   159 
       
   160 // Name of the AknCapServer window group.
       
   161 _LIT( KVtUiAknCapServer, "*akncapserver*" );
       
   162 
       
   163 // Name of the AknNotifierServer window group.
       
   164 _LIT( KVtUiAknNotifierServer, "*aknnfysrv*" );
       
   165 
       
   166 // Volume repeat delay.
       
   167 const TInt KVtUiVolumeRepeatDelay = KAknStandardKeyboardRepeatRate;
       
   168 
       
   169 // Volume repeat long delay.
       
   170 const TInt KVtUiVolumeRepeatLongDelay = KAknKeyboardRepeatInitialDelay;
       
   171 
       
   172 // Start time for toolbar timer
       
   173 const TTimeIntervalMicroSeconds32 KStartTime( 600000 );
       
   174 
       
   175 // period time for toolbar timer
       
   176 const TTimeIntervalMicroSeconds32 KPeriodTime( 300000 );
       
   177 
       
   178 // The maximum frequency that user can swap image places.
       
   179 const TInt64 KVtUiMaxSwapImagesFreq( 1000000 );
       
   180 
       
   181 // Enumerates methods used in event handling. This enumeration MUST
       
   182 // match with methodArray local array.
       
   183 enum TVtUiHandleEvents
       
   184     {
       
   185     // Refresh states
       
   186     EVtUiRefreshStates =                    1 << 0,
       
   187     // Handle remote problem.
       
   188     EVtUiHandleVideoFrameRemoteProblem =    1 << 1,
       
   189     // Handle local problem.
       
   190     EVtUiHandleVideoFrameLocalProblem =     1 << 2,
       
   191     // Refresh navipane.
       
   192     EVtUiRefreshNaviPane =                  1 << 3,
       
   193     // Refresh softkeys.
       
   194     EVtUiRefreshSoftkeys =                  1 << 4,
       
   195     // Refresh blind icon status.
       
   196     EVtUiRefreshBlind =                     1 << 5,
       
   197     // Stop showing waiting image text.
       
   198     EVtUiStopWaitingImage =                 1 << 6,    
       
   199     // Rx resolution changed.
       
   200     EVtUiChangeRemoteVideoLayout =          1 << 7,
       
   201     // Show initializing image progress
       
   202     EVtUiShowImageInitializingProgress =    1 << 8,
       
   203     // Hide initializing image progress
       
   204     EVtUiHideImageInitializingProgress =    1 << 9,
       
   205     // Set camera orientation
       
   206     EVtUiSetOrientation =                   1 << 10,
       
   207     //Handle media status change
       
   208     EVtUiMediaStateChanged =                1 << 11,
       
   209     //Show decoding error note
       
   210     EVtUiShowDecodingError =                1 << 12,
       
   211     // Stop the white balance and color tone
       
   212     EVtUiStopWBOrColortone =                1 << 13,
       
   213     // refresh Menu
       
   214     EVtUiRefreshMenu =                      1 << 14,
       
   215     // Stop brightness and contrast slider
       
   216     EVtUiStopBrightnessOrContrast =         1 << 15,
       
   217     // refresh zoom popup
       
   218     EVtUiRefreshZoomPopup =       					1 << 16
       
   219     };
       
   220 
       
   221 // Enumerates states for CVtUiActiveExec.
       
   222 enum
       
   223     {
       
   224     // Operation finished. Must equal to zero.
       
   225     EVtUiAppUiNone,
       
   226 
       
   227     // Active execution states for iActiveExec:
       
   228 
       
   229     // Startup (prepare engine):
       
   230     EVtUiAppUiStartup = 100,                             // 100
       
   231     //     Close dialogs.
       
   232     EVtUiAppUiStartupCloseDialogs = EVtUiAppUiStartup,   // 100
       
   233     //     Initialise engine.
       
   234     EVtUiAppUiStartupInitEngine,                         // 101
       
   235     //     Prepare viewfinder.
       
   236     EVtUiAppUiStartupPrepareViewfinder,                  // 102
       
   237     //     Prepare remote render.
       
   238     EVtUiAppUiStartupPrepareRemoteRender,                // 103
       
   239     //     Remove blank.
       
   240     EVtUiAppUiStartupRemoveBlank,                        // 104
       
   241 
       
   242     // Shutdown (reset engine):
       
   243     EVtUiAppUiShutdown = 300,                            // 300
       
   244     //     Close dialogs.
       
   245     EVtUiAppUiShutdownCloseDialogs = EVtUiAppUiShutdown, // 300
       
   246     //     Hide application.
       
   247     EVtUiAppUiShutdownHideApplication,                   // 301
       
   248     //     Reset engine.
       
   249     EVtUiAppUiShutdownResetEngine,                       // 302
       
   250     //     Remove blank.
       
   251     EVtUiAppUiShutdownRemoveBlank,                       // 303
       
   252 
       
   253     // Answered:
       
   254     EVtUiAppUiAnswered = 500,                            // 500
       
   255     //     Show blank dialog.
       
   256     EVtUiAppUiAnsweredStart = EVtUiAppUiAnswered,        // 500
       
   257     //     Refresh navipane.
       
   258     EVtUiAppUiAnsweredRefreshNavi,                       // 501
       
   259     //     Refresh softkeys.
       
   260     EVtUiAppUiAnsweredRefreshSoftkeys,                   // 502
       
   261     //     Start remote render.
       
   262     EVtUiAppUiAnsweredStartRemoteRender,                 // 503
       
   263 
       
   264     //     Prepares camera
       
   265     EVtUiAppUiAnsweredCheckCamera,                       // 504
       
   266     //     Choose if it's needed to show query or directly activate camera.
       
   267     EVtUiAppUiAnsweredChoose,                            // 505
       
   268     //     Set still image as source.
       
   269     EVtUiAppUiAnsweredQuerySetupStill,                   // 506
       
   270     //     Set none as source.
       
   271     EVtUiAppUiAnsweredQuerySetupNone,                    // 507
       
   272     //     Start viewfinder.
       
   273     EVtUiAppUiAnsweredQuerySetupStart,                   // 508
       
   274     //     Show "allow video image" query.
       
   275     EVtUiAppUiAnsweredQueryShow,                         // 509
       
   276     //     Check if user allowed video image.
       
   277     EVtUiAppUiAnsweredQueryDecide,                       // 510
       
   278     //     Select camera as source.
       
   279     EVtUiAppUiAnsweredQuerySelectCamera,                 // 511
       
   280     //     Select still image as source.
       
   281     EVtUiAppUiAnsweredQuerySelectStill,                  // 512
       
   282     //     Select none as source.
       
   283     EVtUiAppUiAnsweredQuerySelectNone,                   // 513
       
   284     //     Start viewfinder.
       
   285     EVtUiAppUiAnsweredQueryStartViewfinder,              // 514
       
   286     //     Finish.
       
   287     EVtUiAppUiAnsweredQueryFinish,                       // 515
       
   288     //     Select camera as source.
       
   289     EVtUiAppUiAnsweredSelectCamera,                      // 516
       
   290     //     Select still image as source.
       
   291     EVtUiAppUiAnsweredSelectStill,                       // 517
       
   292     //     Select none as source.
       
   293     EVtUiAppUiAnsweredSelectNone,                        // 518
       
   294     //     Start viewfinder.
       
   295     EVtUiAppUiAnsweredStartViewfinder,                   // 519
       
   296     //     Finish.
       
   297     EVtUiAppUiAnsweredFinish,                            // 520
       
   298 
       
   299     //     Prepares camera
       
   300     EVtUiAppUiAnsweredDoPrepareCamera                   // 521
       
   301     };
       
   302 
       
   303 /**
       
   304 * Enumerates background layers
       
   305 */
       
   306 enum TVtUiBackgroundLayers
       
   307     {
       
   308     // Idle state background.
       
   309     EVtUiLayerBackground = 0,
       
   310     // Wallpaper layout.
       
   311     EVtUiLayerWallpaper = 1,
       
   312     // Amount of layers.
       
   313     EVtUiLayerCount = 2
       
   314     };
       
   315 
       
   316 // MODULE DATA STRUCTURES
       
   317 
       
   318 /**
       
   319 * Asynchronous command executor that does not use dialog for waiting the
       
   320 * execution completion.
       
   321 * @since Series 60 5.0
       
   322 */
       
   323 class CVtEngCmdExec : public CBase, private MVtEngCommandObserver
       
   324     {
       
   325 
       
   326 public:
       
   327     /**
       
   328     * Static constructor.
       
   329     */
       
   330     static CVtEngCmdExec* NewL( MVtEngCommandHandler& aCommandHandler,
       
   331         MVtUiEngineCommandManager& aCommandManager,
       
   332         CEikButtonGroupContainer& aCBA );
       
   333 
       
   334     /**
       
   335     * Executes given command asynchronously, waiting the command completion.
       
   336     */
       
   337     void ExecuteCmdLD( const TVtEngCommandId aCommandId );
       
   338 
       
   339     /**
       
   340     * Destructor.
       
   341     */
       
   342     ~CVtEngCmdExec();
       
   343 
       
   344 private: // from MVtEngCommandObserver
       
   345 
       
   346     /**
       
   347     * @see MVtEngCommandObserver::HandleVTCommandPerformedL
       
   348     */
       
   349     void HandleVTCommandPerformedL( TVtEngCommandId aCommand,
       
   350         const TInt aError );
       
   351 
       
   352 private:
       
   353 
       
   354     /**
       
   355     * Constructor.
       
   356     */
       
   357     CVtEngCmdExec( MVtEngCommandHandler& aCommandHandler,
       
   358         MVtUiEngineCommandManager& aCommandManager,
       
   359         CEikButtonGroupContainer& aCBA );
       
   360 
       
   361 private:
       
   362 
       
   363     CActiveSchedulerWait iWait;
       
   364 
       
   365     MVtEngCommandHandler& iCommandHandler;
       
   366 
       
   367     MVtUiEngineCommandManager& iCommandManager;
       
   368 
       
   369     TVtEngCommandId iCommandId;
       
   370 
       
   371     CEikButtonGroupContainer& iCBA;
       
   372 
       
   373     };
       
   374 
       
   375 // -----------------------------------------------------------------------------
       
   376 // CVtEngCmdExec::NewL
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 CVtEngCmdExec* CVtEngCmdExec::NewL( MVtEngCommandHandler& aCommandHandler,
       
   380     MVtUiEngineCommandManager& aCommandManager, CEikButtonGroupContainer& aCBA )
       
   381     {
       
   382     CVtEngCmdExec* self = new ( ELeave ) CVtEngCmdExec( aCommandHandler,
       
   383         aCommandManager, aCBA );
       
   384     return self;
       
   385     }
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 // CVtEngCmdExec::ExecuteCmdLD
       
   389 // -----------------------------------------------------------------------------
       
   390 //
       
   391 void CVtEngCmdExec::ExecuteCmdLD( const TVtEngCommandId aCommandId )
       
   392     {
       
   393     __VTPRINTENTER("CVtEngCmdExec::ExecuteCmdLD")
       
   394     CleanupStack::PushL( this );
       
   395     iCommandId = aCommandId;
       
   396     iCommandManager.AddObserverL( *this );
       
   397     iCommandHandler.ExecuteL( aCommandId, NULL );
       
   398     iCBA.SetCommandSetL( R_VIDEOTELUI_SOFTKEYS_EMPTY );
       
   399     iCBA.DrawNow();
       
   400     iWait.Start();
       
   401     CleanupStack::PopAndDestroy(); // this
       
   402     __VTPRINTEXIT("CVtEngCmdExec::ExecuteCmdLD")
       
   403     }
       
   404 
       
   405 // -----------------------------------------------------------------------------
       
   406 // CVtEngCmdExec::~CVtEngCmdExec
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 CVtEngCmdExec::~CVtEngCmdExec()
       
   410     {
       
   411     __VTPRINTENTER("CVtEngCmdExec::~CVtEngCmdExec")
       
   412     if ( iWait.IsStarted())
       
   413         {
       
   414         __VTPRINT(DEBUG_GEN, "CVtEngCmdExec::~CVtEngCmdExec AsyncStop")
       
   415         iWait.AsyncStop();
       
   416         }
       
   417     iCommandManager.RemoveObserver( *this );
       
   418     __VTPRINTEXIT("CVtEngCmdExec::~CVtEngCmdExec")
       
   419     }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CVtEngCmdExec::HandleVTCommandPerformedL
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 void CVtEngCmdExec::HandleVTCommandPerformedL( TVtEngCommandId aCommand,
       
   426         const TInt aError )
       
   427     {
       
   428     __VTPRINTENTER("CVtEngCmdExec::HandleVTCommandPerformedL")
       
   429     if ( iCommandId == aCommand )
       
   430         {
       
   431          if ( iWait.IsStarted())
       
   432             {
       
   433             __VTPRINT(DEBUG_GEN, "CVtEngCmdExec::HandleVTCommandPerformedL AsyncStop")
       
   434             iWait.AsyncStop();
       
   435             }
       
   436         else
       
   437             {
       
   438             // request already completed
       
   439             }
       
   440         }
       
   441     else
       
   442         {
       
   443         // wrong command ID
       
   444         }
       
   445     __VTPRINTEXIT("CVtEngCmdExec::HandleVTCommandPerformedL")
       
   446     }
       
   447 
       
   448 // -----------------------------------------------------------------------------
       
   449 // CVtEngCmdExec::CVtEngCmdExec
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 CVtEngCmdExec::CVtEngCmdExec( MVtEngCommandHandler& aCommandHandler,
       
   453     MVtUiEngineCommandManager& aCommandManager, CEikButtonGroupContainer& aCBA )
       
   454     : iCommandHandler( aCommandHandler ),
       
   455       iCommandManager( aCommandManager ), iCBA( aCBA )
       
   456     {
       
   457     }
       
   458     
       
   459 /**
       
   460 * Encapsulates all instances related to user interface.
       
   461 * @since Series 60 2.6
       
   462 */
       
   463 class CVtUiAppUi::CInstance
       
   464     : public CBase
       
   465     {
       
   466     public: // Constructors and destructors
       
   467 
       
   468         /**
       
   469         * Two-phased constructor.
       
   470         * @param aAppUi reference to application UI.
       
   471         */
       
   472         static CInstance* NewL( CVtUiAppUi& aAppUi );
       
   473 
       
   474         /**
       
   475         * Destructor.
       
   476         */
       
   477         ~CInstance();
       
   478 
       
   479         /**
       
   480         * Called when side volume key is pressed.
       
   481         */
       
   482         void VolumeKeyPressedL();
       
   483 
       
   484         /**
       
   485         * Create remote video control.
       
   486         */        
       
   487         void CreateRemoteVideoControl();
       
   488 
       
   489     private:
       
   490 
       
   491         /**
       
   492         * Constructor.
       
   493         */
       
   494         CInstance( CVtUiAppUi& aAppUi );
       
   495 
       
   496         /**
       
   497         * Symbian OS constructor.
       
   498         */
       
   499         void ConstructL();
       
   500 
       
   501         /**
       
   502         * Relayout controls.
       
   503         */
       
   504         void LayoutChanged();
       
   505 
       
   506     private:
       
   507 
       
   508         // Parent can access members.
       
   509         friend class CVtUiAppUi;
       
   510 
       
   511         // Ref to application UI.
       
   512         CVtUiAppUi& iAppUi;
       
   513 
       
   514         // Owned bitmap manager.
       
   515         CVtUiBitmapManager* iBitmapManager;
       
   516 
       
   517         // ETrue if iMainControl has been added to stack.
       
   518         TBool iMainControlInStack;
       
   519 
       
   520         // Owned main pane control.
       
   521         CVtUiMainControl* iMainControl;
       
   522 
       
   523         // ETrue if iContextControl has been added to stack.
       
   524         TBool iContextControlInStack;
       
   525 
       
   526         // Owned context pane control.
       
   527         CVtUiContextControl* iContextControl;
       
   528 
       
   529         // Owned remote video control.
       
   530         CVtUiRemoteVideoControl* iRemoteVideoControl;
       
   531         
       
   532         //ETrue if iRemoteVideoControl has been added to stack.
       
   533         TBool iRemoteVideoControlInStack;
       
   534 
       
   535         // Owned navi pane controller.
       
   536         CVtUiNaviPane* iNaviPane;
       
   537 
       
   538         // ETrue if number entry has been added to stack.
       
   539         TBool iNumberEntryInStack;
       
   540 
       
   541         // Owned number entry activation control.
       
   542         CVtUiNumberEntryActivationControl* iNumberEntryActivation;
       
   543 
       
   544     };
       
   545 
       
   546 /**
       
   547 * Encapsulates event handling.
       
   548 * @since Series 60 2.6
       
   549 */
       
   550 class CVtUiAppUi::CEventObserver
       
   551     : public CBase,
       
   552       public MVtUiEngineCommandManager,
       
   553       public MVtEngEventObserver,
       
   554       public MVtEngCommandObserver,
       
   555       public MVtEngFrameObserver,
       
   556       private MBeating,
       
   557       private MRemConCoreApiTargetObserver
       
   558     {
       
   559     public: // Constructors and destructors
       
   560 
       
   561         /**
       
   562         * Two-phased constructor.
       
   563         * @param aAppUi application UI.
       
   564         */
       
   565         static CEventObserver* NewL( CVtUiAppUi& aAppUi );
       
   566 
       
   567         /**
       
   568         * Destructor.
       
   569         */
       
   570         ~CEventObserver();
       
   571 
       
   572     public: // New functions
       
   573 
       
   574         /**
       
   575         * Returns engine model.
       
   576         * @return model instance.
       
   577         */
       
   578         inline CVtEngModel& Model();
       
   579         
       
   580         /**
       
   581         * Creates remote control framework session.
       
   582         */
       
   583         void CreateRemConSessionL();
       
   584 
       
   585         /**
       
   586         * Deletes remote control framework session.
       
   587         */
       
   588         void DeleteRemConSession();
       
   589 
       
   590         /**
       
   591         * Checks if command is supported by engine.
       
   592         * @param aCommandId command.
       
   593         * @return ETrue if supported, EFalse otherwise.
       
   594         */
       
   595         TBool CommandSupported( const TInt aCommandId ) const;
       
   596 
       
   597         /**
       
   598         * Checks if command is supported and synchronous.
       
   599         * @param aCommandId command.
       
   600         * @return ETrue if synchronous & supported, EFalse otherwise.
       
   601         */
       
   602         TBool CommandSupportedAndSynchronous(
       
   603             const TInt aCommandId ) const;
       
   604 
       
   605         /**
       
   606         * Starts heartbeat timer.
       
   607         */
       
   608         void StartBeatL();
       
   609 
       
   610         /**
       
   611         * Stops heartbeat timer.
       
   612         */
       
   613         void StopBeat();
       
   614 
       
   615         /**
       
   616         * Stops volume repeat handling timer.
       
   617         */
       
   618         void StopVolumeRepeatTimer();
       
   619         
       
   620         /**
       
   621         * Sends response to prepare.
       
   622         * @param aResult result code.
       
   623         */
       
   624         void SendPrepareResponse( const TInt aResult );
       
   625 
       
   626     public: // Functions from base classes
       
   627 
       
   628         /**
       
   629         * @see MVtUiCommandManager::AddObserverL.
       
   630         */
       
   631         virtual void AddObserverL( MVtEngCommandObserver& aObserver );
       
   632 
       
   633         /**
       
   634         * @see MVtUiCommandManager::RemoveObserver.
       
   635         */
       
   636         virtual void RemoveObserver( MVtEngCommandObserver& aObserver );
       
   637 
       
   638         /**
       
   639         * @see MVtEngEventObserver::HandleVtEventL.
       
   640         */
       
   641         virtual void HandleVtEventL( TInt aEvent );
       
   642 
       
   643         /**
       
   644         * @see MVtEngCommandObserver::HandleVTCommandPerformedL.
       
   645         */
       
   646         virtual void HandleVTCommandPerformedL(
       
   647             TVtEngCommandId aCommand,
       
   648             const TInt aError );
       
   649 
       
   650         /**
       
   651         * @see MVtEngFrameObserver::vtHandleFrameL.
       
   652         */
       
   653         virtual void vtHandleFrameL( TFrameType aType, CFbsBitmap* aBitmap );
       
   654 
       
   655         /**
       
   656         * @see MVtEngFrameObserver::vtSetFrame
       
   657         */
       
   658         virtual void vtSetFrame( TFrameType aType, CFbsBitmap* aBitmap );
       
   659 
       
   660         /**
       
   661         * @see MBeating::Beat.
       
   662         */
       
   663         virtual void Beat();
       
   664 
       
   665         /**
       
   666         * @see MBeating::Synchronize.
       
   667         */
       
   668         virtual void Synchronize();
       
   669 
       
   670 
       
   671     private:
       
   672 
       
   673         /**
       
   674         * Constructor.
       
   675         * @param aAppUi application UI.
       
   676         */
       
   677         CEventObserver( CVtUiAppUi& aAppUi );
       
   678 
       
   679         /**
       
   680         * Symbian OS constructor.
       
   681         */
       
   682         void ConstructL();
       
   683 
       
   684         /**
       
   685         * Executes CVtUiAppUi methods.
       
   686         * @param aBits sum of subset of TVtUiHandleEvents.
       
   687         */
       
   688         void DoExecuteL( TInt aBits );
       
   689         /**
       
   690         * Handles volume change.
       
   691         * @param aButtonAct button action.
       
   692         */
       
   693         void HandleVolumeChange(
       
   694             TRemConCoreApiButtonAction aButtonAct );
       
   695         /**
       
   696         * Handles mute change.
       
   697         * @param aButtonAct button action.
       
   698         */
       
   699         void HandleRemMuteChange(
       
   700             TRemConCoreApiButtonAction aButtonAct );
       
   701         /**
       
   702         * @see MRemConCoreApiTargetObserver::MrccatoCommand.
       
   703         */
       
   704         virtual void MrccatoCommand(
       
   705             TRemConCoreApiOperationId aOperationId,
       
   706             TRemConCoreApiButtonAction aButtonAct );
       
   707 
       
   708         /**
       
   709         * Callback function to handle volume repeat.
       
   710         * @param aAny pointer to an instance of this class.
       
   711         * @return KErrNone.
       
   712         */
       
   713         static TInt DoHandleVolumeRepeat( TAny* aAny );
       
   714 
       
   715     private:
       
   716 
       
   717         // Type definition for CVtUiAppUi member functions.
       
   718         typedef void (CVtUiAppUi::*TMethodL)();
       
   719 
       
   720         // Ref to application ui.
       
   721         CVtUiAppUi& iAppUi;
       
   722 
       
   723         // Engine model.
       
   724         CVtEngModel* iModel;
       
   725 
       
   726         // ETrue when command events are being sent.
       
   727         TBool iInCommandPerformed;
       
   728 
       
   729         // Owned array of observers.
       
   730         RPointerArray< MVtEngCommandObserver > iCommandObservers;
       
   731 
       
   732         // Owned heart beat timer to update call duration.
       
   733         CHeartbeat* iBeat;
       
   734         
       
   735 
       
   736         // Owned interface selector instance.
       
   737         CRemConInterfaceSelector* iRemConInterfaceSelector;
       
   738 
       
   739         // Pointer to target instance. Owned by iRemConInterfaceSelector.
       
   740         CRemConCoreApiTarget* iRemConCoreApiTarget;
       
   741 
       
   742         // Owned timer for volume repeat handling.
       
   743         CPeriodic* iRemConVolumeRepeatTimer;
       
   744 
       
   745         // Rencon operation id
       
   746         TRemConCoreApiOperationId iRCCAOperationId;
       
   747 
       
   748     };
       
   749 
       
   750 /**
       
   751 * Verifies objects fetched using media gallery. Only non DRM protected
       
   752 * objects are allowed.
       
   753 * @since Series 60 3.1
       
   754 */
       
   755 class CVtUiAppUi::CVtUiAppUiMGVerifier :
       
   756     public CBase,
       
   757     public MMGFetchVerifier
       
   758     {
       
   759     public:
       
   760 
       
   761     		/**
       
   762     		* Static constructor, pushes created instance into cleanup stack.
       
   763     		*/
       
   764         static CVtUiAppUiMGVerifier* NewLC(
       
   765             CVtUiAppUi& aAppUi, CCoeEnv& aCoeEnv );
       
   766 
       
   767     		/**
       
   768     		* Destructor.
       
   769     		*/
       
   770         ~CVtUiAppUiMGVerifier();
       
   771 
       
   772     public: // from MMGFetchVerifier
       
   773 
       
   774         /**
       
   775     		* @see MMGFetchVerifier::VerifySelectionL
       
   776     		*/
       
   777         TBool VerifySelectionL( const MDesCArray* aSelectedFiles );
       
   778 
       
   779     private:
       
   780 
       
   781     		/**
       
   782     		* 2nd constructor in two phase construction.
       
   783     		*/
       
   784         void ConstructL();
       
   785 
       
   786         /**
       
   787     		* Constructor.
       
   788     		*/
       
   789         CVtUiAppUiMGVerifier( CVtUiAppUi& aAppUi, CCoeEnv& aCoeEnv );
       
   790 
       
   791     private:
       
   792 
       
   793         // Reference to Application UI
       
   794         CVtUiAppUi& iAppUi;
       
   795 
       
   796         // Pointer to COE
       
   797         CCoeEnv* iCoeEnv;
       
   798 
       
   799         // Pointer to CManager which manages files and content access agents
       
   800         CManager* iManager;
       
   801     };
       
   802 
       
   803 // ============================ MEMBER FUNCTIONS ===============================
       
   804 
       
   805 // -----------------------------------------------------------------------------
       
   806 // CVtUiAppUi::CVtUiAppUi
       
   807 // C++ default constructor can NOT contain any code, that
       
   808 // might leave.
       
   809 // -----------------------------------------------------------------------------
       
   810 //
       
   811 CVtUiAppUi::CVtUiAppUi()
       
   812     : iRenderingMode( ERenderingModeDefault ),
       
   813       iLoudspeakerVolume( KVolumeResetValue ),
       
   814       iHandsetVolume( KVolumeResetValue ),
       
   815       iActiveCommands( 1 ),
       
   816       iLayoutChg( EFalse ),
       
   817       iDelayedCmd( 0 )
       
   818     {
       
   819     }
       
   820 
       
   821 // -----------------------------------------------------------------------------
       
   822 // CVtUiAppUi::ConstructL
       
   823 // Symbian 2nd phase constructor.
       
   824 // -----------------------------------------------------------------------------
       
   825 //
       
   826 void CVtUiAppUi::ConstructL()
       
   827     {
       
   828     VTLOGINIT
       
   829     __VTPRINTENTER( "VtUi.ConstructL" )
       
   830 
       
   831     FeatureManager::InitializeLibL();
       
   832     BaseConstructL( EAknEnableSkin | EAknEnableMSK );
       
   833 
       
   834     iCba = Cba();
       
   835     // Must be done before creating features
       
   836     iVTVariation.ReadL();
       
   837 
       
   838     iEventObserver = CEventObserver::NewL( *this );
       
   839     iUiStates = new ( ELeave ) TVtUiStates( iEventObserver->Model() );
       
   840     iUiStates->Update();
       
   841 		iUiStates->SetViewFindersInitialPlaceContextPane( ETrue );
       
   842 		
       
   843     TVtUiAppStateBase::SetInitialStateL( *this, *iUiStates );
       
   844 
       
   845     iCommandManager = CVtUiCommandManager::NewL( *iUiStates, *this );
       
   846 
       
   847     iComponentManager = CVtUiComponentManager::NewL();
       
   848 
       
   849     iFeatureManager = CVtUiFeatureManager::NewL( *this, *iUiStates,
       
   850          *iCommandManager, *iComponentManager );
       
   851 
       
   852     iInstance = CInstance::NewL( *this );
       
   853 
       
   854     CEikMenuBar* menu = iEikonEnv->AppUiFactory()->MenuBar();
       
   855     menu->SetContextMenuTitleResourceId( R_VIDEOTELUI_OK_MENUBAR );
       
   856 
       
   857 
       
   858 
       
   859     CEikonEnv& eikEnv = *( iEikonEnv );
       
   860     eikEnv.SetSystem( ETrue );
       
   861     eikEnv.WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
       
   862 
       
   863     iThisApplicationWgId = eikEnv.RootWin().Identifier();
       
   864     iEikonServerWgId =
       
   865         eikEnv.WsSession().FindWindowGroupIdentifier( 0, KVtUiEikonServer );
       
   866     iAknCapServerWgId =
       
   867     	eikEnv.WsSession().FindWindowGroupIdentifier( 0, KVtUiAknCapServer );
       
   868     iAknNfyServerWgId =
       
   869         eikEnv.WsSession().FindWindowGroupIdentifier( 0,
       
   870             KVtUiAknNotifierServer );
       
   871 
       
   872     __ASSERT_ALWAYS(
       
   873         iEikonServerWgId != KErrNotFound,
       
   874         VtUiPanic::Panic( EVtUiPanicEikonServerNotFound ) );
       
   875     (void)eikEnv.RootWin().EnableFocusChangeEvents();
       
   876 
       
   877 
       
   878     iUplinkWindow = iInstance->iContextControl;
       
   879     iDownlinkWindow = iInstance->iMainControl;
       
   880 
       
   881 
       
   882     if ( iCba )
       
   883         {
       
   884         CCoeControl* control = iCba->ButtonGroup()->AsControl();
       
   885         static_cast< CEikCba* >( control )->
       
   886             SetSkinBackgroundId( KAknsIIDQsnBgAreaControlIdle );
       
   887         }
       
   888 
       
   889     iBlankControl = new ( ELeave ) CVtUiBlankControl;
       
   890     iBlankControl->ConstructL( ClientRect() );
       
   891     AddToStackL(
       
   892         iBlankControl,
       
   893         KVtUiBlankControlPriority,
       
   894         ECoeStackFlagRefusesFocus );
       
   895 
       
   896     iUiStates->SetBlankControlAdded( ETrue );
       
   897 
       
   898     iActiveExec =
       
   899         new ( ELeave ) CVtUiActiveExec( CActive::EPriorityHigh );
       
   900     SetCallIdL( KVtUiDefaultCallId );
       
   901 
       
   902     iExitTimer = CPeriodic::NewL( CActive::EPriorityHigh );
       
   903     CheckEngineFunctionality();
       
   904 
       
   905     iAsyncCallback =
       
   906         new ( ELeave ) CAsyncCallBack (
       
   907             TCallBack( &AsyncViewFinderToMainPaneAndShare, this ),
       
   908             CActive::EPriorityStandard );
       
   909 
       
   910     iLayoutChangeCallback =
       
   911         new ( ELeave ) CAsyncCallBack(
       
   912             TCallBack( &DelayedHandleLayoutChanged, this ),
       
   913             CActive::EPriorityStandard );
       
   914 
       
   915     iCurrentCameraOrientation = MVtEngMedia::EOrientationObeyLayoutSwitch;
       
   916 
       
   917     GetCameraOrientations();
       
   918 
       
   919     SetInitialCameraOrientationL();
       
   920 
       
   921     iVolCtrl= new ( ELeave )CVtUiVolumeControl(
       
   922         Model().CommandHandler(),
       
   923         Model().Audio(),
       
   924         *iEventObserver,
       
   925         *iFeatureManager);
       
   926     iVolCtrl->ConstructL();
       
   927 
       
   928     iIncallBubble = CAknIncallBubble::NewL();
       
   929 
       
   930     iIsWaitingCallState = EFalse;
       
   931     
       
   932     __VTPRINTEXIT( "VtUi.ConstructL" )
       
   933     }
       
   934 
       
   935 // -----------------------------------------------------------------------------
       
   936 // CVtUiAppUi::~CVtUiAppUi
       
   937 // -----------------------------------------------------------------------------
       
   938 //
       
   939 CVtUiAppUi::~CVtUiAppUi()
       
   940     {
       
   941     __VTPRINTENTER( "VtUi.~" )
       
   942 
       
   943     iActiveCommands.Close();
       
   944 
       
   945     delete iLayoutChangeCallback;
       
   946     delete iAsyncCallback;
       
   947 
       
   948     if ( iUiStates && iUiStates->IsBlankControlAdded() )
       
   949         {
       
   950         RemoveFromStack( iBlankControl );
       
   951         }
       
   952     TInt lightsValue = 0;
       
   953     if ( RProperty::Get( KPSUidCoreApplicationUIs,
       
   954             KLightsVTForcedLightsOn, lightsValue ) == KErrNone )
       
   955         {
       
   956         if ( lightsValue == EForcedLightsOn )
       
   957             {
       
   958             __VTPRINT( DEBUG_GEN, "VtUi.~ Good night!" )
       
   959             (void) RProperty::Set(
       
   960                 KPSUidCoreApplicationUIs,
       
   961                 KLightsVTForcedLightsOn,
       
   962                 EForcedLightsOff );
       
   963             }
       
   964         }
       
   965     delete iActiveExec;
       
   966     delete iInstance;
       
   967     delete iBlankControl;
       
   968     // Delete volume control before its dependencies are deleted.
       
   969     delete iVolCtrl;
       
   970     delete iEventObserver;
       
   971     delete iExitTimer;
       
   972     // Featuremanager must be destructed
       
   973     // before componentmanager and commandmanager
       
   974     delete iFeatureManager;
       
   975     delete iComponentManager;
       
   976     delete iCommandManager;
       
   977     delete iUiStates;
       
   978 
       
   979     if ( iTbPeriodic )
       
   980         {
       
   981         iTbPeriodic->Cancel();
       
   982         }
       
   983     delete iTbPeriodic;
       
   984 
       
   985     if ( iIncallBubble )
       
   986         {
       
   987         TRAP_IGNORE( iIncallBubble->SetIncallBubbleAllowedInUsualL( ETrue ) )    
       
   988         }
       
   989     delete iIncallBubble;
       
   990 
       
   991     // Close all RComm sessions to prevent memory leaks.
       
   992     REComSession::FinalClose();
       
   993 
       
   994     FeatureManager::UnInitializeLib();
       
   995     __VTPRINTEXIT( "VtUi.~" )
       
   996     VTLOGUNINIT
       
   997     }
       
   998 
       
   999 // -----------------------------------------------------------
       
  1000 // CVtUiAppUi::SwitchLayoutToFlatStatusPaneL
       
  1001 // -----------------------------------------------------------
       
  1002 //
       
  1003 void CVtUiAppUi::SwitchLayoutToFlatStatusPaneL( TBool aSwitch )
       
  1004     {
       
  1005     __VTPRINTENTER( "VtUi.SwitchLayoutToFlatStatusPaneL" )
       
  1006     CEikStatusPane* statusPane = StatusPane();
       
  1007 
       
  1008     const TInt idleResId(
       
  1009         VtUiLayout::IsLandscapeOrientation() ?
       
  1010             R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL :
       
  1011                 R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
  1012 
       
  1013     const TBool isStatusPaneFlat(
       
  1014         ( statusPane->CurrentLayoutResId() ==
       
  1015             R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT ) ||
       
  1016         ( statusPane->CurrentLayoutResId() ==
       
  1017             R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT ) );
       
  1018 
       
  1019     if ( aSwitch )
       
  1020         {
       
  1021         if ( isStatusPaneFlat && VtUiLayout::IsLandscapeOrientation() )
       
  1022             {
       
  1023             __VTPRINT( DEBUG_GEN,
       
  1024                 "VtUi.SwitchLayoutToFlatStatusPaneL LAYOUT USUAL" );
       
  1025             NaviPaneL()->Pop();
       
  1026             statusPane->SwitchLayoutL( idleResId );
       
  1027             }
       
  1028         else if ( !isStatusPaneFlat && !VtUiLayout::IsLandscapeOrientation() )
       
  1029             {
       
  1030             __VTPRINT( DEBUG_GEN,
       
  1031                 "VtUi.SwitchLayoutToFlatStatusPaneL USUAL FLAT" );
       
  1032             NaviPaneL()->PushDefaultL();
       
  1033             statusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT );
       
  1034             }
       
  1035         }
       
  1036     else
       
  1037         {
       
  1038         if ( isStatusPaneFlat )
       
  1039             {
       
  1040             __VTPRINT( DEBUG_GEN,
       
  1041                 "VtUi.SwitchLayoutToFlatStatusPaneL LAYOUT IDLE" );
       
  1042             NaviPaneL()->Pop();
       
  1043             statusPane->SwitchLayoutL( idleResId );
       
  1044             }
       
  1045         }
       
  1046     // ApplyCurrentSettingsL is called whenever statuspane
       
  1047     // visibility status or pane layout changes.
       
  1048     statusPane->ApplyCurrentSettingsL();
       
  1049     statusPane->DrawNow();
       
  1050     // Make sure whole control is fully updated
       
  1051     iInstance->iMainControl->DrawNow();
       
  1052     __VTPRINTEXIT( "VtUi.SwitchLayoutToFlatStatusPaneL" )
       
  1053     }
       
  1054 
       
  1055 // -----------------------------------------------------------------------------
       
  1056 // CVtUiAppUi::RefreshL
       
  1057 // -----------------------------------------------------------------------------
       
  1058 //
       
  1059 void CVtUiAppUi::RefreshL()
       
  1060     {
       
  1061     __VTPRINTENTER( "VtUi.Refresh" )
       
  1062     RefreshBlind();
       
  1063     RefreshNaviPaneL();    
       
  1064     __VTPRINTEXIT( "VtUi.Refresh" )
       
  1065     }
       
  1066 
       
  1067 // -----------------------------------------------------------------------------
       
  1068 // CVtUiAppUi::RefreshNaviPaneL
       
  1069 // -----------------------------------------------------------------------------
       
  1070 //
       
  1071 void CVtUiAppUi::RefreshNaviPaneL()
       
  1072     {
       
  1073     // Update only if navi pane exists
       
  1074     if ( iInstance )
       
  1075         {
       
  1076         __VTPRINT( DEBUG_GEN, "VtUi.RefreshNavi" )
       
  1077         CVtUiNaviPane* navi = iInstance->iNaviPane;
       
  1078 
       
  1079         // Refresh muted state
       
  1080         MVtEngMedia& media = Model().Media();
       
  1081         TInt mediaAvail;
       
  1082         VtUiUtility::GetOutgoingMediaState( media, mediaAvail );
       
  1083         mediaAvail = ~mediaAvail;
       
  1084         navi->SetMuted( mediaAvail & MVtEngMedia::EMediaAudio );
       
  1085 
       
  1086         // Refresh call duration
       
  1087         MVtEngSessionInfo& session = Model().Session();
       
  1088         MVtEngSessionInfo::TDuration duration;
       
  1089         TBool enabled;
       
  1090         if ( session.GetDuration( duration, enabled ) != KErrNone )
       
  1091             {
       
  1092             enabled = EFalse;
       
  1093             }
       
  1094         navi->SetCallDuration( duration, enabled );
       
  1095 
       
  1096         // Update all changes
       
  1097         navi->CommitL();
       
  1098 
       
  1099         CheckBeatL( enabled );
       
  1100         }
       
  1101     }
       
  1102 
       
  1103 void CVtUiAppUi::StopBrightnessOrContrast()
       
  1104     {
       
  1105     
       
  1106     MVtUiFeature* br = iFeatureManager->GetFeatureById( EVtUiFeatureIdBrightness );
       
  1107     if ( br )
       
  1108         {
       
  1109         __VTPRINT( DEBUG_GEN, "VtUi.StopBrightness" )
       
  1110         if ( br->State() ==  MVtUiFeature::EActive )
       
  1111             {
       
  1112             __VTPRINT( DEBUG_GEN, "VtUi.StopBrightnessOrContrast br->STOP" )
       
  1113             br->Stop();
       
  1114             }
       
  1115         }
       
  1116     
       
  1117     MVtUiFeature* cr = iFeatureManager->GetFeatureById( EVtUiFeatureIdContrast );
       
  1118     if ( cr )
       
  1119         {
       
  1120         __VTPRINT( DEBUG_GEN, "VtUi.StopContrast" )
       
  1121         if ( cr->State() ==  MVtUiFeature::EActive )
       
  1122            {
       
  1123            __VTPRINT( DEBUG_GEN, "VtUi.StopBrightnessOrContrast cr->STOP" )
       
  1124            cr->Stop();
       
  1125            }
       
  1126         }
       
  1127     }
       
  1128 
       
  1129 // -----------------------------------------------------------------------------
       
  1130 // CVtUiAppUi::RefreshZoomPopupL()
       
  1131 // -----------------------------------------------------------------------------
       
  1132 //
       
  1133 void CVtUiAppUi::RefreshZoomPopupL()
       
  1134     {
       
  1135     CVtUiZoom* zm = static_cast< CVtUiZoom* >(
       
  1136             iFeatureManager->GetFeatureById( EVtUiFeatureIdZoom ) );
       
  1137     if( zm && iUiStates->IsZoomModeOn())
       
  1138         zm->RefreshL();
       
  1139     }
       
  1140 // -----------------------------------------------------------------------------
       
  1141 // CVtUiAppUi::RefreshMenuL()
       
  1142 // -----------------------------------------------------------------------------
       
  1143 //
       
  1144 void CVtUiAppUi::RefreshMenuL()
       
  1145     {
       
  1146     
       
  1147     CVtUiMenus* menus = static_cast< CVtUiMenus* >(
       
  1148             iFeatureManager->GetFeatureById( EVtUiFeatureIdMenu ) );
       
  1149     if ( menus )
       
  1150     {
       
  1151         iUiStates->Update();
       
  1152         __VTPRINT( DEBUG_GEN, "VtUi.RefreshMenuL" )
       
  1153         menus->RefreshL();
       
  1154         CAknAppUi::ProcessCommandL( EEikCmdCanceled ); // does not leave
       
  1155         }
       
  1156     }
       
  1157               
       
  1158 // -----------------------------------------------------------------------------
       
  1159 // CVtUiAppUi::RefreshSoftkeysL
       
  1160 // -----------------------------------------------------------------------------
       
  1161 //
       
  1162 void CVtUiAppUi::RefreshSoftkeysL()
       
  1163     {
       
  1164     if ( iUiStates->IsThisApplicationForeground() )
       
  1165         {
       
  1166         CVtUiSoftkeys* sk = static_cast< CVtUiSoftkeys* >(
       
  1167             iFeatureManager->GetFeatureById( EVtUiFeatureIdSoftkey ) );
       
  1168         if ( sk )
       
  1169             {
       
  1170             sk->RefreshL();
       
  1171             }
       
  1172         }
       
  1173     }
       
  1174 
       
  1175 // -----------------------------------------------------------------------------
       
  1176 // CVtUiAppUi::RefreshBlind
       
  1177 // -----------------------------------------------------------------------------
       
  1178 //
       
  1179 void CVtUiAppUi::RefreshBlind()
       
  1180     {
       
  1181     if ( iInstance && !iUiStates->IsDisableBlindSetting() )
       
  1182         {
       
  1183         __VTPRINTENTER( "VtUi.RefreshBlind" )
       
  1184         TInt avail;
       
  1185         MVtEngMedia& media = Model().Media();
       
  1186 
       
  1187         // Update blind flags.for outgoing media:
       
  1188         VtUiUtility::GetOutgoingMediaState( media, avail );
       
  1189         avail = ~avail;
       
  1190         TBool noVideo( avail & MVtEngMedia::EMediaVideo );
       
  1191         const TBool isFrozen( VtUiUtility::GetFreezeState ( media ) );
       
  1192         MVtEngMedia::TMediaSource source( MVtEngMedia::EMediaNone );
       
  1193         media.GetSource( source );
       
  1194         if ( noVideo && !isFrozen &&
       
  1195             ( source != MVtEngMedia::EMediaStillImage ) )
       
  1196             {
       
  1197             iUplinkWindow->SetStreamBitmap( NULL );
       
  1198             }
       
  1199 
       
  1200         iUplinkWindow->SetBlind( noVideo );
       
  1201         iUplinkWindow->SetWaiting( EFalse );
       
  1202 
       
  1203         if ( iUiStates->IsThisApplicationForeground() )
       
  1204             {
       
  1205             // Update blind flags for incoming media:
       
  1206             VtUiUtility::GetIncomingMediaState( media, avail );
       
  1207             avail = ~avail;
       
  1208             noVideo = ( avail & MVtEngMedia::EMediaVideo );
       
  1209             if ( noVideo )
       
  1210                 {
       
  1211                 iDownlinkWindow->SetStreamBitmap( NULL );
       
  1212                 }
       
  1213             iDownlinkWindow->SetBlind( noVideo );
       
  1214             }
       
  1215         iDownlinkWindow->SetWaiting( iUiStates->IsWaitingForFirstFrame() );
       
  1216         __VTPRINTEXIT( "VtUi.RefreshBlind" )
       
  1217         }
       
  1218     }
       
  1219 
       
  1220 // -----------------------------------------------------------------------------
       
  1221 // CVtUiAppUi::OpenNumberEntryL
       
  1222 // -----------------------------------------------------------------------------
       
  1223 //
       
  1224 TBool CVtUiAppUi::OpenNumberEntryL()
       
  1225     {
       
  1226     __VTPRINTENTER( "VtUi.OpenNumberEntryL" )
       
  1227 
       
  1228     CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
       
  1229     if ( IsDisplayingDialog() || ( menuBar && menuBar->IsDisplayed() ) )
       
  1230         {
       
  1231         __VTPRINTEXIT( "VtUi.OpenNumberEntryL" )
       
  1232         return EFalse;
       
  1233         }
       
  1234 
       
  1235     TInt error( KErrNotFound );
       
  1236 
       
  1237     MVtUiFeature* numberEntry =
       
  1238         iFeatureManager->GetFeatureById( EVtUiFeatureIdNumberEntry );
       
  1239 
       
  1240     MVtUiFeature* dialer =
       
  1241         iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer );
       
  1242 
       
  1243     const TBool dialerActive( dialer &&
       
  1244         ( dialer->State() == MVtUiFeature::EActive ) );
       
  1245 
       
  1246     if ( numberEntry && !dialerActive )
       
  1247         {
       
  1248         TRAP( error, numberEntry->StartL() );
       
  1249         }
       
  1250 
       
  1251     const TBool result( !error );
       
  1252 
       
  1253     if ( result )
       
  1254         {
       
  1255         __VTPRINT( DEBUG_GEN, "VtUi.NumberEntry.StopZ" )
       
  1256         RefreshSoftkeysL();
       
  1257         }
       
  1258 
       
  1259     __VTPRINTEXITR( "VtUi.OpenNumberEntryL %d", result )
       
  1260     return result;
       
  1261     }
       
  1262 
       
  1263 // -----------------------------------------------------------------------------
       
  1264 // CVtUiAppUi::HandlePhoneSendKeyL
       
  1265 // Handles EKeyPhoneSend key events.
       
  1266 // -----------------------------------------------------------------------------
       
  1267 //
       
  1268 TKeyResponse CVtUiAppUi::HandlePhoneSendKeyL( const TKeyEvent& /*aKeyEvent*/,
       
  1269     TEventCode aType )
       
  1270     {
       
  1271     __VTPRINTENTER( "VtUi.HandlePhoneSendKeyL" )
       
  1272     CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
       
  1273     if ( !( IsDisplayingDialog() || ( menuBar && menuBar->IsDisplayed() ) ) )
       
  1274         {
       
  1275         const TBool isNumberSource( iUiStates->IsNumberEntryOpen() ||
       
  1276             iUiStates->IsDialerOpen() );
       
  1277         if ( ( aType == EEventKey ) && isNumberSource )
       
  1278             {
       
  1279             ProcessCommandL( EVtUiCmdDialEmergency );
       
  1280             }
       
  1281         }
       
  1282     __VTPRINTEXIT( "VtUi.HandlePhoneSendKeyL" )
       
  1283     return EKeyWasConsumed;
       
  1284     }
       
  1285 
       
  1286 // -----------------------------------------------------------------------------
       
  1287 // CVtUiAppUi::StartDtmfTone
       
  1288 // -----------------------------------------------------------------------------
       
  1289 //
       
  1290 void CVtUiAppUi::StartDtmfTone( const TChar& aTone )
       
  1291     {
       
  1292     // should be called only through current application state
       
  1293     iDtmfTone = aTone;
       
  1294     __VTPRINT2( DEBUG_GEN, "VtUi.DTMF.Start.%d", iDtmfTone() )
       
  1295     if ( Execute( KVtEngStartDtmfTone, &iDtmfTone ) != KErrNone )
       
  1296         {
       
  1297         iDtmfTone = 0;
       
  1298         }
       
  1299     }
       
  1300 
       
  1301 // -----------------------------------------------------------------------------
       
  1302 // CVtUiAppUi::StopDtmfTone
       
  1303 // -----------------------------------------------------------------------------
       
  1304 //
       
  1305 void CVtUiAppUi::StopDtmfTone()
       
  1306     {
       
  1307     // should be called only through current application state
       
  1308     if ( iDtmfTone() )
       
  1309         {
       
  1310         __VTPRINT( DEBUG_GEN, "VtUi.DTMF.STOP" )
       
  1311         (void) Execute( KVtEngStopDtmfTone, NULL );
       
  1312         iDtmfTone = 0;
       
  1313         }
       
  1314     }
       
  1315 
       
  1316 // -----------------------------------------------------------------------------
       
  1317 // CVtUiAppUi::HandleWsEventL
       
  1318 // -----------------------------------------------------------------------------
       
  1319 //
       
  1320 void CVtUiAppUi::HandleWsEventL(
       
  1321         const TWsEvent& aEvent,
       
  1322         CCoeControl* aDestination )
       
  1323     {
       
  1324     __VTPRINTENTER( "VtUi.HandleWsEventL" )
       
  1325     const TInt type = aEvent.Type();
       
  1326     __VTPRINT2( DEBUG_GEN, "VtUi.HandleWsEventL type = %d", type );
       
  1327 
       
  1328     // Zoom-in and Zoom-out keys need specific handling because keyup and
       
  1329     // keydown events cannot be checked from iCode field of TKeyEvent
       
  1330     if ( PreHandleKeyEventL( aEvent ) )
       
  1331         {
       
  1332         __VTPRINTEXIT( "VtUi.HandleWsEventL (PreHandleKeyEventL)" )
       
  1333         return;
       
  1334         }
       
  1335 
       
  1336     // Zoom mode is dismissed if some interrupting event happens prior timeout.
       
  1337     // Zoom mode can be interrupted with a  keypress i.e. any keypress, except
       
  1338     // keys that are reserved for adjusting zoom dismiss zoom mode. Also any
       
  1339     // system event e.g. note or waiting call dismiss zoom mode.
       
  1340     if ( iUiStates->IsZoomModeOn() )
       
  1341         {
       
  1342         if ( ProcessWsEventIfZoomModeIsActiveL( aEvent ) )
       
  1343             {
       
  1344             __VTPRINTEXIT( "VtUi.HandleWsEventL (IsZoomModeOn)" )
       
  1345             return;
       
  1346             }
       
  1347         }
       
  1348     // Zoom mode can be also activated with up and down arrow keys.
       
  1349     switch ( type )
       
  1350         {
       
  1351         case EEventKey:
       
  1352         case EEventKeyUp:
       
  1353         case EEventKeyDown:
       
  1354             {
       
  1355             const TKeyEvent* keyEvent = aEvent.Key();
       
  1356             const TBool isHwZoomKey(
       
  1357                 keyEvent->iCode == EKeyZoomIn ||
       
  1358                 keyEvent->iCode == EKeyZoomOut );
       
  1359             const TBool isZoomKey(
       
  1360                 keyEvent->iScanCode == EStdKeyUpArrow ||
       
  1361                 keyEvent->iScanCode == EStdKeyDownArrow ||
       
  1362                 isHwZoomKey );
       
  1363 
       
  1364             // Zoom mode can be also activated with up and down arrow keys.
       
  1365             if ( isZoomKey )
       
  1366                 {
       
  1367                 const TBool isZoomAllowed(
       
  1368                     !iEikonEnv->AppUiFactory()->MenuBar()->IsDisplayed() &&
       
  1369                     !iUiStates->MediaState().IsSharing() &&
       
  1370                     !iUiStates->MediaState().IsFrozen() &&
       
  1371                     !iUiStates->IsSelectingShare() &&
       
  1372                     VtUiUtility::IsZoomAllowed( Model().Media() ) &&
       
  1373                     !( iUiStates->IsNumberEntryOpen() && ShowNumberEntry() ) &&
       
  1374                     //there must not be the command which may switch provider to None
       
  1375                     !IsActiveCommand( EVtUiCmdDisableVideo )&&
       
  1376                     !IsActiveCommand( EVtUiCmdDisableBoth )&&
       
  1377                     !IsActiveCommand( EVtUiCmdUsePrimaryCamera )&&
       
  1378                     !IsActiveCommand( EVtUiCmdUseSecondaryCamera) );
       
  1379 
       
  1380                 if ( isZoomAllowed )
       
  1381                     {
       
  1382                      // If menu is open, toolbar is available, video is frozen,
       
  1383                      // sharing is on or user is selecting a file to be shared
       
  1384                      // do not set zoom mode on. If HW zoom key was pressed,
       
  1385                      // then zoom mode is activated even if toolbar is present.
       
  1386                     if ( isHwZoomKey || !iUiStates->IsToolbarAvailable() )
       
  1387                         {
       
  1388                         SetZoomModeL( ETrue );
       
  1389                         }
       
  1390                     }
       
  1391                 }
       
  1392             }
       
  1393             break;
       
  1394         default:
       
  1395             break;
       
  1396         }
       
  1397 
       
  1398     TBool partialForeGroundlost( EFalse );
       
  1399     switch ( type )
       
  1400         {
       
  1401         // Enter new rendering mode
       
  1402         case EVtUiWsEventBeginRenderingMode:
       
  1403             {
       
  1404             const TVtUiWsEvent< TRenderingMode >& event(
       
  1405                static_cast< const TVtUiWsEvent< TRenderingMode >& >
       
  1406                 ( aEvent ) );
       
  1407             MVtUiDialer* dialer =  static_cast< CVtUiDialer* > (
       
  1408                 iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer ) );
       
  1409             __ASSERT_ALWAYS( dialer,
       
  1410                 VtUiPanic::Panic( EVtUiPanicRendererNotFound ) );
       
  1411             iInstance->iContextControl->MakeVisible( EFalse );
       
  1412             SetRenderingModeL( *event.Data(), &dialer->VideoWindow() );
       
  1413             }
       
  1414             break;
       
  1415 
       
  1416         // End rendering mode -> revert to previous
       
  1417         case EVtUiWsEventEndRenderingMode:
       
  1418             {
       
  1419             SetRenderingModeL( ERenderingModeDefault, iStoredDownlinkWindow );
       
  1420             iInstance->iContextControl->MakeVisible( ETrue );
       
  1421             iStoredDownlinkWindow = NULL;
       
  1422             }
       
  1423             break;
       
  1424 
       
  1425         // New number source have been activated
       
  1426         case EVtUiWsEventNumberSourceActivate:
       
  1427             {
       
  1428             const TVtUiWsEvent< MVtUiNumberSource >& event(
       
  1429                static_cast< const TVtUiWsEvent< MVtUiNumberSource >& >
       
  1430                 ( aEvent ) );
       
  1431             iNumberSource = event.Data();
       
  1432             }
       
  1433             break;
       
  1434 
       
  1435         case EVtUiWsEventNumberSourceDeactivate:
       
  1436             {
       
  1437             const TVtUiWsEvent< MVtUiNumberSource >& event(
       
  1438                static_cast< const TVtUiWsEvent< MVtUiNumberSource >& >
       
  1439                 ( aEvent ) );
       
  1440             if ( iNumberSource == event.Data() )
       
  1441                 {
       
  1442                 iNumberSource = NULL;
       
  1443                 }
       
  1444             }
       
  1445             break;
       
  1446 
       
  1447 
       
  1448         // VT goes background e.g. selected application from fastswap
       
  1449         case KAknFullOrPartialForegroundLost:
       
  1450             {
       
  1451             // If capture mode is on stop it
       
  1452             if ( iUiStates->IsCaptureModeOn() )
       
  1453                 {
       
  1454                 CmdCancelCaptureL();
       
  1455                 }
       
  1456             SetIncallBubbleAllowedInUsualL( ETrue );
       
  1457             const TInt windowGroupId =
       
  1458                 iCoeEnv->WsSession().GetFocusWindowGroup();
       
  1459 
       
  1460             // In S60 5.0 we get PartialFocusLost also for some notes and
       
  1461             // overally items that are somehow overlapping screen instead of
       
  1462             // FocusLost. In those cases we should not put app to background.
       
  1463             if( ( windowGroupId != iThisApplicationWgId ) &&
       
  1464                 ( windowGroupId != iEikonServerWgId ) &&
       
  1465                 ( windowGroupId != iAknCapServerWgId ) &&
       
  1466                 ( windowGroupId != iAknNfyServerWgId ) )
       
  1467                 {
       
  1468                 partialForeGroundlost = ETrue;
       
  1469                 }
       
  1470 
       
  1471             // Fall through to EEventFocusLost event
       
  1472             }
       
  1473         case EEventFocusLost:
       
  1474             {
       
  1475             // If focus window group is not this application nor window server,
       
  1476             // then this application can not be in focus.
       
  1477             const TInt windowGroupId =
       
  1478                 iCoeEnv->WsSession().GetFocusWindowGroup();
       
  1479 
       
  1480             if ( ( windowGroupId != iThisApplicationWgId ) &&
       
  1481                  ( windowGroupId != iEikonServerWgId ) &&
       
  1482                  ( windowGroupId != iAknCapServerWgId ) &&
       
  1483                  ( windowGroupId != iAknNfyServerWgId ) || partialForeGroundlost )
       
  1484                 {
       
  1485                 iCoeEnv->RootWin().DisableFocusChangeEvents();
       
  1486 
       
  1487                 TBool old = iUiStates->IsThisApplicationForeground();
       
  1488                 if ( old )
       
  1489                     {
       
  1490                     TRAP_IGNORE( HandleForegroundChangedL( EFalse ) );
       
  1491                     }
       
  1492                 }
       
  1493             }
       
  1494             break;
       
  1495 
       
  1496         case KAknFullOrPartialForegroundGained:
       
  1497             {
       
  1498             SetIncallBubbleAllowedInUsualL( EFalse );
       
  1499             // Now this application is focused.
       
  1500             (void)iCoeEnv->RootWin().EnableFocusChangeEvents();
       
  1501             TBool old = iUiStates->IsThisApplicationForeground();
       
  1502 
       
  1503             if ( !old )
       
  1504                 {
       
  1505                 (void) HandleLayoutChanged();
       
  1506                 TRAP_IGNORE( HandleForegroundChangedL( ETrue ) );
       
  1507                 }
       
  1508             }
       
  1509             break;
       
  1510 
       
  1511         case EEventKey:
       
  1512         case EEventKeyUp:
       
  1513         case EEventKeyDown:
       
  1514             {
       
  1515             // Key events with EModifierSpecial are received via FEP.
       
  1516             const TKeyEvent* keyEvent = aEvent.Key();
       
  1517             if ( keyEvent->iModifiers & EModifierSpecial )
       
  1518                 {
       
  1519                 TChar dtmfTone;
       
  1520                 if ( VtUiUtility::IsDTMFEvent( *keyEvent, dtmfTone ) )
       
  1521                     {
       
  1522                     if ( type == EEventKey )
       
  1523                         {
       
  1524                         StartDtmfTone( dtmfTone );
       
  1525                         }
       
  1526                     else if ( type == EEventKeyUp )
       
  1527                         {
       
  1528                         StopDtmfTone();
       
  1529                         }
       
  1530                     }
       
  1531                 }
       
  1532             }
       
  1533             break;
       
  1534 
       
  1535         default:
       
  1536             break;
       
  1537         }
       
  1538     // Offer event to component manager
       
  1539     iComponentManager->HandleWsEventL( aEvent, aDestination );
       
  1540 
       
  1541     // All events are sent to base class.
       
  1542     CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  1543     __VTPRINTEXIT( "VtUi.HandleWsEventL" )
       
  1544     }
       
  1545 
       
  1546 // -----------------------------------------------------------------------------
       
  1547 // CVtUiAppUi::PreHandleKeyEventL
       
  1548 //
       
  1549 // -----------------------------------------------------------------------------
       
  1550 //
       
  1551 TBool CVtUiAppUi::PreHandleKeyEventL( const TWsEvent& aEvent )
       
  1552     {
       
  1553     __VTPRINTENTER( "VtUi.PreHandleKeyEventL" )
       
  1554     TBool consumed( EFalse );
       
  1555     switch( aEvent.Type() )
       
  1556         {
       
  1557 
       
  1558     case EEventKey:
       
  1559         {
       
  1560         // when both these are set, then it's our simulated key press
       
  1561         const TInt
       
  1562             modifiers( EModifierKeypad | EModifierSpecial );
       
  1563 
       
  1564         const TKeyEvent* ptrKeyEventC =
       
  1565             aEvent.Key();
       
  1566 
       
  1567         const TBool isHwZoomKey(
       
  1568             ptrKeyEventC->iCode == EKeyZoomIn ||
       
  1569             ptrKeyEventC->iCode == EKeyZoomOut );
       
  1570 
       
  1571         if ( isHwZoomKey &&
       
  1572              ( ptrKeyEventC->iModifiers & modifiers ) != modifiers )
       
  1573             {
       
  1574             __VTPRINT3( DEBUG_GEN, "VtUi.PreHandleKeyEventL keyc=%d scanc=%d",
       
  1575                 ptrKeyEventC->iCode, ptrKeyEventC->iScanCode )
       
  1576             consumed = ETrue;
       
  1577 
       
  1578             // Send EEventKeyDown only when iRepeats is 0
       
  1579             if ( !ptrKeyEventC->iRepeats )
       
  1580                 {
       
  1581                 TKeyEvent keyDownEvent( *ptrKeyEventC );
       
  1582                 keyDownEvent.iRepeats = 0;
       
  1583                 iCoeEnv->SimulateKeyEventL( keyDownEvent, EEventKeyDown );
       
  1584                 }
       
  1585 
       
  1586             // Send EEventKey always
       
  1587             TKeyEvent keyEvent( *ptrKeyEventC );
       
  1588             keyEvent.iModifiers |= modifiers;
       
  1589             iCoeEnv->SimulateKeyEventL( keyEvent, EEventKey );
       
  1590 
       
  1591             // Que EEventKeyUp
       
  1592             TKeyEvent keyUpEvent( *ptrKeyEventC );
       
  1593             keyUpEvent.iRepeats = 0;
       
  1594             StoreKeyEventL( keyUpEvent );
       
  1595             }
       
  1596         else if ( ( ptrKeyEventC->iModifiers & modifiers ) == modifiers )
       
  1597             {
       
  1598             __VTPRINT( DEBUG_GEN,
       
  1599                 "VtUi.PreHandleKeyEventL own event spotted, removing mods" )
       
  1600             // event is generated by us, remove modifiers
       
  1601             TKeyEvent* ptrKeyEvent = const_cast< TKeyEvent* >( ptrKeyEventC );
       
  1602             ptrKeyEvent->iModifiers &= ~modifiers;
       
  1603             }
       
  1604         }
       
  1605         break;
       
  1606 
       
  1607     case EEventKeyUp:
       
  1608         if ( iIsStoredKeyEvent )
       
  1609             {
       
  1610             if ( iStoredKeyEvent.iScanCode == aEvent.Key()->iScanCode )
       
  1611                 {
       
  1612                 consumed = ETrue;
       
  1613                 SimulateStoredKeyEventL( EEventKeyUp );
       
  1614                 }
       
  1615             }
       
  1616         break;
       
  1617 
       
  1618     default:
       
  1619         break;
       
  1620 
       
  1621         }
       
  1622 
       
  1623     __VTPRINTEXITR( "VtUi.PreHandleKeyEventL %d", consumed )
       
  1624     return consumed;
       
  1625     }
       
  1626 
       
  1627 // -----------------------------------------------------------------------------
       
  1628 // CVtUiAppUi::SimulateStoredKeyEventL
       
  1629 //
       
  1630 // -----------------------------------------------------------------------------
       
  1631 //
       
  1632 void CVtUiAppUi::SimulateStoredKeyEventL( const TEventCode aEventCode )
       
  1633     {
       
  1634     __VTPRINTENTER( "VtUi.SimulateStoredKeyEventL" )
       
  1635     if ( iIsStoredKeyEvent )
       
  1636         {
       
  1637         // Reset flag first because SimulateKeyEventL() is synchronous
       
  1638         iIsStoredKeyEvent = EFalse;
       
  1639         iCoeEnv->SimulateKeyEventL( iStoredKeyEvent, aEventCode );
       
  1640         }
       
  1641     __VTPRINTEXITR( "VtUi.SimulateStoredKeyEventL %d", iIsStoredKeyEvent )
       
  1642     }
       
  1643 
       
  1644 // -----------------------------------------------------------------------------
       
  1645 // CVtUiAppUi::StoreKeyEventL
       
  1646 //
       
  1647 // -----------------------------------------------------------------------------
       
  1648 //
       
  1649 void CVtUiAppUi::StoreKeyEventL( const TKeyEvent& aKeyEvent )
       
  1650     {
       
  1651     __VTPRINTENTER( "VtUi.StoreKeyEventL" )
       
  1652     if ( iIsStoredKeyEvent && ( iStoredKeyEvent.iCode != aKeyEvent.iCode ) )
       
  1653         {
       
  1654         SimulateStoredKeyEventL( EEventKeyUp );
       
  1655         }
       
  1656 
       
  1657     if ( !iIsStoredKeyEvent )
       
  1658         {
       
  1659         iIsStoredKeyEvent = ETrue;
       
  1660         iStoredKeyEvent = aKeyEvent;
       
  1661         }
       
  1662     __VTPRINTEXITR( "VtUi.StoreKeyEventL %d", iIsStoredKeyEvent )
       
  1663     }
       
  1664 
       
  1665 // -----------------------------------------------------------------------------
       
  1666 // CVtUiAppUi::DoTryToStartTb
       
  1667 // -----------------------------------------------------------------------------
       
  1668 //
       
  1669 TInt CVtUiAppUi::DoTryToStartTbL( TAny* aAny )
       
  1670     {
       
  1671     CVtUiAppUi* self = static_cast< CVtUiAppUi* >( aAny );
       
  1672     self->TryToStartTbL();
       
  1673     return KErrNone;
       
  1674     }
       
  1675 
       
  1676 // -----------------------------------------------------------------------------
       
  1677 // CVtUiAppUi::UpdateVBSettingL
       
  1678 // -----------------------------------------------------------------------------
       
  1679 //
       
  1680 void CVtUiAppUi::UpdateVBSettingL()
       
  1681     {
       
  1682     // If white balance or color tone setting
       
  1683     // feauture exists update setting
       
  1684     CVtUiWhiteBalance* wb = static_cast< CVtUiWhiteBalance* >(
       
  1685     iFeatureManager->GetFeatureById( EVtUiFeatureIdWhiteBalance ) );
       
  1686 
       
  1687     CVtUiColorTone* ct = static_cast< CVtUiColorTone* >(
       
  1688     iFeatureManager->GetFeatureById( EVtUiFeatureIdColourTone ) );
       
  1689 
       
  1690     // If brightness or contrast slider
       
  1691     // feauture exists update them
       
  1692     CVtUiBrightness* br = static_cast< CVtUiBrightness* >(
       
  1693     iFeatureManager->GetFeatureById( EVtUiFeatureIdBrightness ) );
       
  1694     
       
  1695     CVtUiContrast* contr = static_cast< CVtUiContrast* >(
       
  1696     iFeatureManager->GetFeatureById( EVtUiFeatureIdContrast ) );
       
  1697     
       
  1698 
       
  1699     
       
  1700     if ( wb && iUiStates->IsWhiteBalanceSettingAvailable() )
       
  1701         {
       
  1702         __VTPRINT( DEBUG_GEN,"VtUi.UpdateVBSettingL WB update" )
       
  1703         wb->UpdateSettingL();
       
  1704         }
       
  1705 
       
  1706     if ( ct && iUiStates->IsColorToneSettingAvailable() )
       
  1707         {
       
  1708         __VTPRINT( DEBUG_GEN,"VtUi.UpdateVBSettingL CT update" )
       
  1709         ct->UpdateSettingL();
       
  1710         }
       
  1711     
       
  1712     if ( br && iUiStates->IsBrightnessSettingAvailable() )
       
  1713         {
       
  1714         __VTPRINT( DEBUG_GEN,"VtUi.UpdateVBSettingL br update" )
       
  1715         br->UpdateSlider();
       
  1716         }
       
  1717     
       
  1718     if ( contr && iUiStates->IsContrastSettingAvailable() )
       
  1719         {
       
  1720         __VTPRINT( DEBUG_GEN,"VtUi.UpdateVBSettingL contract update" )
       
  1721         contr->UpdateSlider();
       
  1722         }
       
  1723     }
       
  1724 
       
  1725 // -----------------------------------------------------------------------------
       
  1726 // CVtUiAppUi::TryToStartTb
       
  1727 // -----------------------------------------------------------------------------
       
  1728 //
       
  1729 void CVtUiAppUi::TryToStartTbL()
       
  1730     {
       
  1731     __VTPRINTENTER( "VtUi.TryToStartTbL" )
       
  1732     CVtUiToolbarBase* tb = static_cast< CVtUiToolbarBase* >(
       
  1733     iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar ) );
       
  1734     if ( tb )
       
  1735         {
       
  1736         // If menu, dialog or dialer is displayed do not start the toolbar,
       
  1737         // but let the timer run another round
       
  1738         CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
       
  1739         if ( !( menuBar && menuBar->IsDisplayed() ) &&
       
  1740              !IsDisplayingDialog() &&
       
  1741              !(
       
  1742                 iUiStates->IsDialerActivating() ||
       
  1743                 iUiStates->IsDialerOpen() ||
       
  1744                 iUiStates->IsWhiteBalanceModeOn() ||
       
  1745                 iUiStates->IsColorToneModeOn()  ||
       
  1746                 iUiStates->IsBrightnessModeOn()  ||
       
  1747                 iUiStates->IsContrastModeOn()  ||
       
  1748                 iUiStates->IsZoomModeOn() ||
       
  1749                 iUiStates->IsVolumeModeOn() ||
       
  1750                 iUiStates->IsCaptureModeOn() )
       
  1751                 )
       
  1752             {
       
  1753             if ( iTbPeriodic )
       
  1754                 {
       
  1755                 iTbPeriodic->Cancel();
       
  1756                 }
       
  1757             tb->StartL();
       
  1758             }
       
  1759         }
       
  1760     __VTPRINTEXIT( "VtUi.TryToStartTbL" )
       
  1761     }
       
  1762 
       
  1763 // -----------------------------------------------------------------------------
       
  1764 // CVtUiAppUi::SetRenderingModeL
       
  1765 // -----------------------------------------------------------------------------
       
  1766 //
       
  1767 void CVtUiAppUi::SetRenderingModeL( const TRenderingMode aMode,
       
  1768     MVtUiVideoWindow* aNewDownlink )
       
  1769     {
       
  1770     __VTPRINTENTER( "VtUi.SetRenderingModeL" )
       
  1771     __VTPRINT2( DEBUG_GEN, "VtUi.SetRenderingModeL=%d", aMode );
       
  1772     iRenderingMode = aMode;
       
  1773     if ( aNewDownlink )
       
  1774         {
       
  1775         if ( iDownlinkWindow != aNewDownlink )
       
  1776             {
       
  1777             iStoredDownlinkWindow = iDownlinkWindow;
       
  1778             iDownlinkWindow = aNewDownlink;
       
  1779             iStoredDownlinkWindow->SetRemoteVideoControl(NULL);
       
  1780             iDownlinkWindow->SetRemoteVideoControl(iInstance->iRemoteVideoControl);
       
  1781             iDownlinkWindow->LayoutRemoteVideo();
       
  1782             }
       
  1783         }
       
  1784     RefreshBlind();
       
  1785     UpdateRenderingParametersL();
       
  1786     __VTPRINTEXIT( "VtUi.SetRenderingModeL" )
       
  1787     }
       
  1788 
       
  1789 // -----------------------------------------------------------------------------
       
  1790 // CVtUiAppUi::UpdateRenderingParametersL
       
  1791 // -----------------------------------------------------------------------------
       
  1792 //
       
  1793 void CVtUiAppUi::UpdateRenderingParametersL()
       
  1794     {
       
  1795     __VTPRINTENTER( "VtUi.UpdateRenderingParametersL" )
       
  1796  
       
  1797     MVtEngMedia& media = Model().Media();
       
  1798     const TBool viewFinderStarted =
       
  1799         media.RenderingStarted( MVtEngMedia::EMediaOutgoing );
       
  1800     const TBool remoteRenderStarted =
       
  1801         media.RenderingStarted( MVtEngMedia::EMediaIncoming );
       
  1802 
       
  1803     // Clear bitmaps
       
  1804     iInstance->iContextControl->SetStreamBitmap( NULL );
       
  1805     iInstance->iMainControl->SetStreamBitmap( NULL );
       
  1806 
       
  1807     // Stop viewfinder & remote render.
       
  1808     if( viewFinderStarted )
       
  1809         {
       
  1810         ExecuteCmdL( KVtEngStopViewFinder );
       
  1811         }
       
  1812     ExecuteCmdL( KVtEngStopRenderRemote );
       
  1813 
       
  1814     const TBool uplinkWindowEqualsContextControl =
       
  1815         ( iUplinkWindow == iInstance->iContextControl );
       
  1816 
       
  1817     // Prepare viewfinder.
       
  1818     TVtEngRenderingOptions configViewfinder(
       
  1819          uplinkWindowEqualsContextControl ?
       
  1820             DetermineContextControlOptions() :
       
  1821             DetermineMainControlOptions( EFalse ) );
       
  1822     ExecuteCmdL( KVtEngPrepareViewFinder, configViewfinder );
       
  1823 
       
  1824     // Prepare remote render.
       
  1825     TRAPD ( err, {
       
  1826     TVtEngRenderingOptionsNGA configRemoteRenderNGA(
       
  1827             DetermineRemoteVideoControlOptionsNGA() );
       
  1828     ExecuteCmdL(
       
  1829             KVtEngPrepareRemoteRenderNGA,
       
  1830                 configRemoteRenderNGA );
       
  1831     } );
       
  1832     if ( err != KErrNone )
       
  1833         {
       
  1834         if ( viewFinderStarted )
       
  1835             {
       
  1836             // Start viewfinder.
       
  1837             ExecuteCmdL( KVtEngStartViewFinder );
       
  1838             }
       
  1839         User::Leave ( err );
       
  1840         }
       
  1841         
       
  1842     // Start remote render.
       
  1843     TRAP_IGNORE( ExecuteCmdL( KVtEngStartRenderRemote ) );
       
  1844 
       
  1845     if ( viewFinderStarted )
       
  1846         {
       
  1847         // Start viewfinder.
       
  1848         ExecuteCmdL( KVtEngStartViewFinder );
       
  1849         }
       
  1850 
       
  1851     // Redraw remote video last frame to make sure that in layout change
       
  1852     // situation we still have something on screen.
       
  1853     iDownlinkWindow->Redraw();
       
  1854     __VTPRINTEXIT( "VtUi.UpdateRenderingParametersL" )
       
  1855     }
       
  1856 
       
  1857 // -----------------------------------------------------------------------------
       
  1858 // CVtUiAppUi::MediaStateChangedL
       
  1859 // -----------------------------------------------------------------------------
       
  1860 //
       
  1861 void CVtUiAppUi::MediaStateChangedL()
       
  1862     {
       
  1863     CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
       
  1864     // close menu if it is shown
       
  1865     if ( menuBar && menuBar->IsDisplayed() )
       
  1866         {
       
  1867         TKeyEvent keyEvent;
       
  1868         keyEvent.iCode =  EKeyEscape;
       
  1869         menuBar->OfferKeyEventL( keyEvent, EEventKey );
       
  1870         }
       
  1871     // Refresh toolbar
       
  1872     CVtUiToolbarBase* tb = static_cast< CVtUiToolbarBase* >(
       
  1873     iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar ) );
       
  1874     if ( tb )
       
  1875         {
       
  1876         tb->RefreshL();
       
  1877         }
       
  1878     }
       
  1879 
       
  1880 // -----------------------------------------------------------------------------
       
  1881 // CVtUiAppUi::ProcessCommandL
       
  1882 // Processes commands.
       
  1883 // -----------------------------------------------------------------------------
       
  1884 //
       
  1885 void CVtUiAppUi::ProcessCommandL(
       
  1886         TInt aCommand )
       
  1887     {
       
  1888     __VTPRINTENTER( "VtUi.ProcessCommandL" )
       
  1889     MVtEngCommandHandler& command = Model().CommandHandler();
       
  1890     command.ExecuteL( KVtEngRequestLastRemoteFrame, NULL );
       
  1891     
       
  1892     // only with fixed toolbar
       
  1893     if ( AknLayoutUtils::PenEnabled() )
       
  1894         {
       
  1895         if ( iUiStates->IsFixedToolbarVisible())
       
  1896             {
       
  1897             // When option menu is opened fixed toolbar should
       
  1898             // be set hidden
       
  1899             iUiStates->SetIsFixedToolbarVisible( EFalse );
       
  1900             // Stop toolbar
       
  1901             MVtUiFeature* tb =
       
  1902             iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar );
       
  1903             if ( tb )
       
  1904                 {
       
  1905                 // timer could be active
       
  1906                 if ( iTbPeriodic )
       
  1907                     {
       
  1908                     iTbPeriodic->Cancel();
       
  1909                     }
       
  1910                 tb->Stop();
       
  1911                 }
       
  1912             if ( !iTbPeriodic )
       
  1913                 {
       
  1914                 iTbPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
  1915                 }
       
  1916             // Toolbar doesn't come visible until options menu is closed.
       
  1917             iTbPeriodic->Start( KStartTime, KPeriodTime, TCallBack( DoTryToStartTbL, this ) );
       
  1918             }
       
  1919         }
       
  1920     else
       
  1921         {
       
  1922         StopSliders(); 
       
  1923         }
       
  1924 
       
  1925     iInstance->iMainControl->SetSize( iInstance->iMainControl->Size() );
       
  1926     iInstance->iMainControl->DrawNow();
       
  1927         
       
  1928     // Handle OK options menu.
       
  1929     const TInt menuResource =
       
  1930         iUiStates->IsLaunchOkOptionsMenu() ?
       
  1931             R_VIDEOTELUI_OK_MENUBAR :
       
  1932             R_VIDEOTELUI_MENUBAR;
       
  1933 
       
  1934     iUiStates->SetLaunchOkOptionsMenu( EFalse );
       
  1935 
       
  1936     CEikMenuBar* menu = iEikonEnv->AppUiFactory()->MenuBar();
       
  1937     if ( menu )
       
  1938         {
       
  1939         menu->SetMenuTitleResourceId( menuResource );
       
  1940         //Here we again set back the type of menu to "Options" when pressed LSK
       
  1941         menu->SetMenuType( CEikMenuBar::EMenuOptions );
       
  1942         }
       
  1943     CAknAppUi::ProcessCommandL( aCommand );
       
  1944     }
       
  1945 
       
  1946 // -----------------------------------------------------------------------------
       
  1947 // CVtUiAppUi::IsActiveCommand
       
  1948 // -----------------------------------------------------------------------------
       
  1949 //
       
  1950 TBool CVtUiAppUi::IsActiveCommand( TInt aCommand ) const
       
  1951     {
       
  1952     return ( iActiveCommands.FindInOrder( aCommand ) != KErrNotFound );
       
  1953     }
       
  1954 
       
  1955 // -----------------------------------------------------------------------------
       
  1956 // CVtUiAppUi::State
       
  1957 // -----------------------------------------------------------------------------
       
  1958 //
       
  1959 TVtUiAppStateBase& CVtUiAppUi::State()
       
  1960     {
       
  1961     return *iState;
       
  1962     }
       
  1963 
       
  1964 // -----------------------------------------------------------------------------
       
  1965 // CVtUiAppUi::BitmapManager
       
  1966 // -----------------------------------------------------------------------------
       
  1967 //
       
  1968 CVtUiBitmapManager& CVtUiAppUi::BitmapManager()
       
  1969     {
       
  1970     return *iInstance->iBitmapManager;
       
  1971     }
       
  1972 
       
  1973 // -----------------------------------------------------------------------------
       
  1974 // CVtUiAppUi::TActiveCommand::TActiveCommand
       
  1975 // -----------------------------------------------------------------------------
       
  1976 //
       
  1977 CVtUiAppUi::TActiveCommand::TActiveCommand(  RArray< TInt >& aActiveCommands,
       
  1978     TInt aCommandId )
       
  1979     : iActiveCommands( aActiveCommands ), iCommandId( aCommandId )
       
  1980     {
       
  1981     }
       
  1982 
       
  1983 // -----------------------------------------------------------------------------
       
  1984 // CVtUiAppUi::TActiveCommand::~TActiveCommand
       
  1985 // -----------------------------------------------------------------------------
       
  1986 //
       
  1987 CVtUiAppUi::TActiveCommand::~TActiveCommand()
       
  1988     {
       
  1989     Close();
       
  1990     }
       
  1991 
       
  1992 // -----------------------------------------------------------------------------
       
  1993 // CVtUiAppUi::TActiveCommand::OpenL
       
  1994 // -----------------------------------------------------------------------------
       
  1995 //
       
  1996 void CVtUiAppUi::TActiveCommand::OpenL()
       
  1997     {
       
  1998     iActiveCommands.InsertInOrderL( iCommandId );
       
  1999     }
       
  2000 
       
  2001 // -----------------------------------------------------------------------------
       
  2002 // CVtUiAppUi::TActiveCommand::Close
       
  2003 // -----------------------------------------------------------------------------
       
  2004 //
       
  2005 void CVtUiAppUi::TActiveCommand::Close()
       
  2006     {
       
  2007     TInt index( iActiveCommands.FindInOrder( iCommandId ) );
       
  2008     if ( index != KErrNotFound )
       
  2009         {
       
  2010         iActiveCommands.Remove( index );
       
  2011         }
       
  2012     }
       
  2013 
       
  2014 // -----------------------------------------------------------------------------
       
  2015 // CVtUiAppUi::HandleCommandL
       
  2016 // Handles commands.
       
  2017 // -----------------------------------------------------------------------------
       
  2018 //
       
  2019 void CVtUiAppUi::HandleCommandL(
       
  2020         TInt aCommand )
       
  2021     {
       
  2022     __VTPRINTENTER( "VtUi.HandleCommand" )
       
  2023 
       
  2024     // Check if same command is already being performed.
       
  2025     if ( IsActiveCommand( aCommand ) || ( iState &&
       
  2026          iState->HandleCommandL( aCommand ) ==
       
  2027          TVtUiAppStateBase::EEventHandled ) )
       
  2028         {
       
  2029         __VTPRINTEXIT( "VtUi.HandleCommand <silently ignoring> 0" )
       
  2030         return;
       
  2031         }
       
  2032 
       
  2033     // Check if command is allowed to be performed.
       
  2034     if ( !IsCommandAllowedL( aCommand ) )
       
  2035         {
       
  2036         ShowNotAllowedNoteL();
       
  2037         __VTPRINTEXITR( "VtUi.HandleCommand %d", KErrAccessDenied )
       
  2038         return;
       
  2039         }
       
  2040 
       
  2041     // delay mute cmd received during layout change (EGWG-7QQ3GZ)
       
  2042     if ( (aCommand == EVtUiCmdDisableAudio) || (aCommand == EVtUiCmdUsePrimaryCamera)
       
  2043             ||(aCommand == EVtUiCmdUseSecondaryCamera)
       
  2044             ||(aCommand == EVtUiCmdDisableVideo) )
       
  2045         {
       
  2046         if ( iLayoutChg )
       
  2047             {
       
  2048             iDelayedCmd = aCommand;
       
  2049             __VTPRINTEXIT( "VtUi.HandleCommand mute delayed due to LayoutChange" )
       
  2050             return;
       
  2051             }
       
  2052         }
       
  2053     
       
  2054     TActiveCommand activeCommand( iActiveCommands, aCommand );
       
  2055     // Close() will be called by the destructor, when instance goes out of
       
  2056     // scope
       
  2057     activeCommand.OpenL();
       
  2058 
       
  2059     TBool refresh = EFalse;
       
  2060     CleanupPushRefreshL();
       
  2061 
       
  2062     // Execute command
       
  2063     switch ( aCommand )
       
  2064         {
       
  2065         case EAknCmdHelp:
       
  2066             CmdHelpL();
       
  2067             break;
       
  2068 
       
  2069         case EVtUiCmdOkOptions:
       
  2070             iUiStates->SetLaunchOkOptionsMenu( ETrue );
       
  2071             ProcessCommandL( EAknSoftkeyOptions );
       
  2072             break;
       
  2073 
       
  2074         case EVtUiCmdEnableMain:
       
  2075         case EVtUiCmdDisableMain:
       
  2076             // Submenu is opened automatically.
       
  2077             break;
       
  2078 
       
  2079         case EVtUiCmdEnableVideo:
       
  2080             {
       
  2081             MVtEngMedia::TShareObjectState shareObjectState;
       
  2082             VtUiUtility::GetObjectSharingState( Model().Media(),
       
  2083             		                            shareObjectState );
       
  2084             if( shareObjectState != MVtEngMedia::ESharingImage )
       
  2085                 {
       
  2086                 refresh = ETrue;
       
  2087                 EnableCommandActivatingAndCleanupPushL();
       
  2088                 CmdEnableVideoL();
       
  2089                 CleanupStack::PopAndDestroy();
       
  2090                 }
       
  2091             else
       
  2092                 {
       
  2093                 CmdStopShareImageL( refresh );
       
  2094                 EnableCommandActivatingAndCleanupPushL();
       
  2095                 CmdEnableVideoL();
       
  2096                 CleanupStack::PopAndDestroy();
       
  2097                 }
       
  2098             }
       
  2099             break;
       
  2100 
       
  2101         case EVtUiCmdEnableAudio:
       
  2102             refresh = ETrue;
       
  2103             CmdEnableAudioL();
       
  2104             break;
       
  2105 
       
  2106         case EVtUiCmdEnableBoth:
       
  2107             EnableCommandActivatingAndCleanupPushL();
       
  2108             CmdEnableAudioL();
       
  2109             MVtEngMedia::TShareObjectState shareObjectState;
       
  2110             VtUiUtility::GetObjectSharingState( Model().Media(),
       
  2111             									shareObjectState );
       
  2112             if( shareObjectState != MVtEngMedia::ESharingImage )
       
  2113                 {
       
  2114                 refresh = ETrue;
       
  2115                 CmdEnableVideoL();
       
  2116                 }
       
  2117             else
       
  2118                 {
       
  2119                 CmdStopShareImageL( refresh );
       
  2120                 CmdEnableVideoL();
       
  2121                 }
       
  2122             // EnableCommandActivatingAndCleanupPushL
       
  2123             CleanupStack::PopAndDestroy();
       
  2124             break;
       
  2125 
       
  2126         case EVtUiCmdDisableVideo:
       
  2127             refresh = ETrue;
       
  2128             EnableCommandActivatingAndCleanupPushL();
       
  2129             CmdDisableVideoL();
       
  2130             CleanupStack::PopAndDestroy();
       
  2131             break;
       
  2132 
       
  2133         case EVtUiCmdDisableAudio:
       
  2134             refresh = ETrue;
       
  2135             EnableCommandActivatingAndCleanupPushL();
       
  2136             CmdDisableAudioL();
       
  2137             CleanupStack::PopAndDestroy();
       
  2138             break;
       
  2139 
       
  2140         case EVtUiCmdDisableBoth:
       
  2141             HandleCommandL( EVtUiCmdDisableAudio );
       
  2142             HandleCommandL( EVtUiCmdDisableVideo );
       
  2143             break;
       
  2144 
       
  2145         case EVtUiCmdActivateBT:
       
  2146             refresh = ETrue;
       
  2147             EnableCommandActivatingAndCleanupPushL();
       
  2148             CmdActivateBtL();
       
  2149             CleanupStack::PopAndDestroy();
       
  2150             break;
       
  2151 
       
  2152         case EVtUiCmdDeactivateBT:
       
  2153             refresh = ETrue;
       
  2154             EnableCommandActivatingAndCleanupPushL();
       
  2155             CmdDeactivateBtL();
       
  2156             CleanupStack::PopAndDestroy();
       
  2157             break;
       
  2158 
       
  2159         case EVtUiCmdActivateLoudspeaker:
       
  2160         case EVtUiCmdSwitchFromBTToIHF:
       
  2161             refresh = ETrue;
       
  2162             EnableCommandActivatingAndCleanupPushL();
       
  2163             CmdActivateLoudspeakerL();
       
  2164             CleanupStack::PopAndDestroy();
       
  2165             break;
       
  2166 
       
  2167         case EVtUiCmdDeactivateLoudspeaker:
       
  2168             refresh = ETrue;
       
  2169             EnableCommandActivatingAndCleanupPushL();
       
  2170             CmdDeactivateLoudspeakerL();
       
  2171             CleanupStack::PopAndDestroy();
       
  2172             break;
       
  2173 
       
  2174         case EVtUiCmdUsePrimaryCamera:
       
  2175             refresh = ETrue;
       
  2176             CmdUseCameraL( ETrue );
       
  2177             break;
       
  2178 
       
  2179         case EVtUiCmdUseSecondaryCamera:
       
  2180             refresh = ETrue;
       
  2181             CmdUseCameraL( EFalse );
       
  2182             break;
       
  2183 
       
  2184         case EVtUiCmdSwapImagesPlaces:
       
  2185             refresh = ETrue;
       
  2186             CleanupPushEnableBlindL();
       
  2187             iUiStates->SetDisableBlindSetting( ETrue );
       
  2188             CmdSwapImagesPlacesL();
       
  2189             CleanupStack::PopAndDestroy(); // CleanupPushEnableBlindL
       
  2190             break;
       
  2191 
       
  2192         case EVtUiCmdZoom:
       
  2193             refresh = ETrue;
       
  2194             // Toolbar uses this same command to set zoom on and off
       
  2195             // therefore this works as a toggle button
       
  2196             SetZoomModeL( !iUiStates->IsZoomModeOn() );
       
  2197 
       
  2198             break;
       
  2199 
       
  2200         case EAknSoftkeyBack:
       
  2201             {
       
  2202             refresh = ETrue;
       
  2203             MVtUiFeature* numberEntry =
       
  2204                 iFeatureManager->GetFeatureById( EVtUiFeatureIdNumberEntry );
       
  2205             if ( numberEntry )
       
  2206                 {
       
  2207                 numberEntry->Stop();
       
  2208                 }
       
  2209             }
       
  2210             break;
       
  2211 
       
  2212         case EVtUiCmdSnapshot:
       
  2213             EnableCommandActivatingAndCleanupPushL();
       
  2214             CmdSnapshotL();
       
  2215             // EnableCommandActivatingAndCleanupPushL
       
  2216             CleanupStack::PopAndDestroy();
       
  2217             break;
       
  2218 
       
  2219         case EVtUiCmdCapture:
       
  2220             CmdCaptureL();
       
  2221             break;
       
  2222 
       
  2223         case EVtUiCmdCancelCapture:
       
  2224             CmdCancelCaptureL();
       
  2225             break;
       
  2226 
       
  2227         case EVtUiCmdGoToIdle:
       
  2228             CmdGoToIdleL();
       
  2229             break;
       
  2230 
       
  2231         // Object sharing related
       
  2232 
       
  2233         case EVtUiCmdShareObjectImage:
       
  2234             CmdInitializeShareImageL( refresh );
       
  2235             break;
       
  2236 
       
  2237         case EVtUiCmdStopSharingObjectImage:
       
  2238             EnableCommandActivatingAndCleanupPushL();
       
  2239             CmdStopShareImageL( refresh );
       
  2240             // EnableCommandActivatingAndCleanupPushL
       
  2241             CleanupStack::PopAndDestroy();
       
  2242             break;
       
  2243 
       
  2244         case EVtUiCmdAdjustVideoVideoQuality:
       
  2245         case EVtUiCmdAdjustVideoWhiteBalance:
       
  2246         case EVtUiCmdAdjustVideoBrightness:
       
  2247         case EVtUiCmdAdjustVideoContrast:
       
  2248         case EVtUiCmdAdjustVideoColourTone:
       
  2249         __VTPRINT( DEBUG_GEN, "VtUiHandleCommand.CmdAdjustVideoL" );
       
  2250             CmdAdjustVideoL( aCommand );
       
  2251             break;
       
  2252 
       
  2253         case EAknSoftkeyExit:
       
  2254         case EAknCmdExit:
       
  2255         case EEikCmdExit:
       
  2256             // handled by state
       
  2257             break;
       
  2258 
       
  2259         default:
       
  2260             iCommandManager->HandleCommandL( aCommand );
       
  2261             break;
       
  2262         }
       
  2263 
       
  2264     if ( refresh )
       
  2265         {
       
  2266         CleanupStack::PopAndDestroy(); // CleanupPushRefreshL
       
  2267         }
       
  2268     else
       
  2269         {
       
  2270         CleanupStack::Pop(); // CleanupPushRefreshL
       
  2271         }
       
  2272     __VTPRINTEXITR( "VtUi.HandleCommand %d", KErrNone )
       
  2273     }
       
  2274 
       
  2275 // -----------------------------------------------------------------------------
       
  2276 // CVtUiAppUi::DynInitMenuPaneL
       
  2277 // Initialises menu pane dynamically.
       
  2278 // -----------------------------------------------------------------------------
       
  2279 //
       
  2280 void CVtUiAppUi::DynInitMenuPaneL(
       
  2281         TInt,
       
  2282         CEikMenuPane* aMenuPane )
       
  2283     {
       
  2284     __VTPRINTENTER( "VtUi.DynInitMenuPaneL" )
       
  2285 	
       
  2286     CVtUiMenus* menus = static_cast< CVtUiMenus* >(
       
  2287         iFeatureManager->GetFeatureById( EVtUiFeatureIdMenu ) );
       
  2288     if ( menus )
       
  2289         {
       
  2290         iUiStates->Update();
       
  2291         menus->SetMenuPane( aMenuPane );
       
  2292         menus->RefreshL();
       
  2293         }
       
  2294 	__VTPRINTEXIT( "VtUi.DynInitMenuPaneL" )
       
  2295     }
       
  2296 
       
  2297 // -----------------------------------------------------------------------------
       
  2298 // CVtUiAppUi::HandleKeyEventL
       
  2299 // Handles key events.
       
  2300 // -----------------------------------------------------------------------------
       
  2301 //
       
  2302 TKeyResponse CVtUiAppUi::HandleKeyEventL(
       
  2303         const TKeyEvent& aKeyEvent,
       
  2304         TEventCode aType )
       
  2305     {
       
  2306     __VTPRINTENTER( "VtUi.HandleKeyEventL" )
       
  2307 
       
  2308     TKeyResponse resp( EKeyWasNotConsumed );
       
  2309 
       
  2310     if ( !iUiStates->IsNumberEntryOpen() ||
       
  2311          ( iUiStates->IsNumberEntryOpen() && !ShowNumberEntry() ) )
       
  2312         {
       
  2313         __VTPRINT( DEBUG_GEN, "VtUi.ToZoom" )
       
  2314 
       
  2315         const TBool isHwZoomKey( aKeyEvent.iCode == EKeyZoomIn ||
       
  2316             aKeyEvent.iCode == EKeyZoomOut );
       
  2317 
       
  2318         // if outgoing video is frozen disable zoom
       
  2319         MVtEngMedia& media = Model().Media();
       
  2320         if ( VtUiUtility::GetFreezeState ( media ) )
       
  2321             {
       
  2322              if ( aKeyEvent.iScanCode == EStdKeyUpArrow ||
       
  2323                  aKeyEvent.iScanCode == EStdKeyDownArrow ||
       
  2324                  isHwZoomKey )
       
  2325                 {
       
  2326                 __VTPRINTEXITR( "VtUi.HandleKeyEventL %d", EKeyWasConsumed )
       
  2327                 return EKeyWasConsumed;
       
  2328                 }
       
  2329             }
       
  2330 
       
  2331         // Handle volume up & down
       
  2332 
       
  2333         }
       
  2334 
       
  2335     // If key event it not yet consumed, offer it to component manager
       
  2336     if ( resp == EKeyWasNotConsumed )
       
  2337         {
       
  2338         resp = iComponentManager->OfferKeyEventL( aKeyEvent, aType );
       
  2339         }
       
  2340 
       
  2341     __VTPRINTEXITR( "VtUi.HandleKeyEventL %d", resp )
       
  2342     return resp;
       
  2343     }
       
  2344 
       
  2345 // -----------------------------------------------------------------------------
       
  2346 // CVtUiAppUi::HandleResourceChangeL
       
  2347 // Handles change of a resource.
       
  2348 // -----------------------------------------------------------------------------
       
  2349 //
       
  2350 void CVtUiAppUi::HandleResourceChangeL(
       
  2351         TInt aType )
       
  2352     {
       
  2353     __VTPRINTENTER( "VtUi.HandleResourceChangeL" )
       
  2354     const TBool layoutChange =
       
  2355         aType == KEikDynamicLayoutVariantSwitch ||
       
  2356         aType == KAknsMessageSkinChange;
       
  2357     if ( iInstance && layoutChange )
       
  2358         {
       
  2359         iInstance->iBitmapManager->InvalidateBitmaps();
       
  2360         }
       
  2361 
       
  2362     CAknAppUi::HandleResourceChangeL( aType );
       
  2363 
       
  2364     if ( iInstance )
       
  2365         {
       
  2366         if ( layoutChange )
       
  2367             {
       
  2368             CVtUiToolbarBase* tb = static_cast< CVtUiToolbarBase* >(
       
  2369                 iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar ) );
       
  2370             if( tb )
       
  2371                 {
       
  2372                 tb->HandleLayoutChangeL();
       
  2373                 }
       
  2374             // Relayout controls
       
  2375             iBlankControl->SetRect( ClientRect() );
       
  2376             iInstance->LayoutChanged();
       
  2377             }
       
  2378         if ( iInstance->iNaviPane )
       
  2379             {
       
  2380             iInstance->iNaviPane->HandleResourceChange( aType );
       
  2381             }
       
  2382         if ( layoutChange )
       
  2383             {
       
  2384             (void) HandleLayoutChanged();
       
  2385             }
       
  2386         }
       
  2387 
       
  2388     iComponentManager->HandleResourceChangeL( aType );
       
  2389 
       
  2390     __VTPRINTEXIT( "VtUi.HandleResourceChangeL");
       
  2391     }
       
  2392 
       
  2393 // -----------------------------------------------------------------------------
       
  2394 // CVtUiAppUi::HandleForegroundEventL
       
  2395 // Handles foreground status change.
       
  2396 // -----------------------------------------------------------------------------
       
  2397 //
       
  2398 void CVtUiAppUi::HandleForegroundEventL( TBool aForeground )
       
  2399     {
       
  2400     CAknAppUi::HandleForegroundEventL( aForeground );
       
  2401 
       
  2402     if ( !aForeground )
       
  2403         {
       
  2404         StopDtmfTone();
       
  2405         }
       
  2406     }
       
  2407 
       
  2408 // -----------------------------------------------------------------------------
       
  2409 // CVtUiAppUi::GetEikonEnv
       
  2410 // -----------------------------------------------------------------------------
       
  2411 //
       
  2412 CEikonEnv* CVtUiAppUi::GetEikonEnv()
       
  2413     {
       
  2414     return iEikonEnv;
       
  2415     }
       
  2416 
       
  2417 // -----------------------------------------------------------------------------
       
  2418 // CVtUiAppUi::GetCba
       
  2419 // -----------------------------------------------------------------------------
       
  2420 //
       
  2421 CEikButtonGroupContainer* CVtUiAppUi::GetCba()
       
  2422     {
       
  2423     return iCba;
       
  2424     }
       
  2425 
       
  2426 //
       
  2427 // -----------------------------------------------------------------------------
       
  2428 // CVtUiAppUi::SetZoomModeL
       
  2429 // -----------------------------------------------------------------------------
       
  2430 //
       
  2431 void CVtUiAppUi::SetZoomModeL( const TBool aEnableZoomMode,
       
  2432     const TBool aIsPermanent )
       
  2433     {
       
  2434     __VTPRINTENTER( "VtUi.SetZoomModeL" )
       
  2435     __VTPRINT2( DEBUG_GEN, "VtUi.SetZoomMo=%d", aEnableZoomMode  );
       
  2436     // If capture mode is on zoom mode cannot be changed
       
  2437     if ( iUiStates->IsCaptureModeOn() )
       
  2438         {
       
  2439         __VTPRINTEXIT( "VtUi.SetZoomModeL.CaptureOn" )
       
  2440         return;
       
  2441         }
       
  2442     CVtUiZoom* zoom = static_cast< CVtUiZoom* >(
       
  2443         iFeatureManager->GetFeatureById( EVtUiFeatureIdZoom ) );
       
  2444     if ( zoom )
       
  2445         {
       
  2446         if ( aEnableZoomMode )
       
  2447             {
       
  2448             if( aIsPermanent )
       
  2449                 {
       
  2450                 zoom->SetPermanenVisibility( aEnableZoomMode );
       
  2451                 }
       
  2452             zoom->StartL();
       
  2453             }
       
  2454         else
       
  2455             {
       
  2456             if( aIsPermanent )
       
  2457                 {
       
  2458                 zoom->SetPermanenVisibility( aEnableZoomMode );
       
  2459                 }
       
  2460             zoom->Stop();
       
  2461             }
       
  2462         }
       
  2463     iUiStates->SetZoomModeOn( aEnableZoomMode );
       
  2464     CVtUiToolbarBase* tb = static_cast< CVtUiToolbarBase* >(
       
  2465     iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar ) );
       
  2466       if ( tb )
       
  2467         {
       
  2468         tb->RefreshL();
       
  2469         }
       
  2470 
       
  2471     __VTPRINTEXIT( "VtUi.SetZoomModeL" )
       
  2472     }
       
  2473 
       
  2474 // -----------------------------------------------------------------------------
       
  2475 // CVtUiAppUi::HelpContextL
       
  2476 // Returns help context array.
       
  2477 // -----------------------------------------------------------------------------
       
  2478 //
       
  2479 CArrayFix<TCoeHelpContext>* CVtUiAppUi::HelpContextL() const
       
  2480     {
       
  2481     CArrayFix<TCoeHelpContext>* array =
       
  2482         new ( ELeave ) CArrayFixFlat<TCoeHelpContext>( KVtUiHelpContextAmount );
       
  2483     CleanupStack::PushL( array );
       
  2484 
       
  2485     array->AppendL(
       
  2486         TCoeHelpContext(
       
  2487             KVtUiTelephoneUid,
       
  2488             KINCAL_HLP_VIDEO_CALL ) );
       
  2489 
       
  2490     CleanupStack::Pop( array );
       
  2491     return array;
       
  2492     }
       
  2493 
       
  2494 // -----------------------------------------------------------------------------
       
  2495 // CVtUiAppUi::ActiveExecExecuteL
       
  2496 // -----------------------------------------------------------------------------
       
  2497 //
       
  2498 TBool CVtUiAppUi::ActiveExecExecuteL(
       
  2499         CVtUiActiveExec& /*aActiveExec*/,
       
  2500         const TInt aState,
       
  2501         TInt& aNextState,
       
  2502         TRequestStatus& aRequest )
       
  2503     {
       
  2504     return ActiveExecInitExecuteL(
       
  2505             aState,
       
  2506             aNextState,
       
  2507             aRequest );
       
  2508     }
       
  2509 
       
  2510 // -----------------------------------------------------------------------------
       
  2511 // CVtUiAppUi::ActiveExecContinue
       
  2512 // -----------------------------------------------------------------------------
       
  2513 //
       
  2514 TBool CVtUiAppUi::ActiveExecContinue(
       
  2515         CVtUiActiveExec& /*aActiveExec*/,
       
  2516         TInt& aState,
       
  2517         const TInt aError )
       
  2518     {
       
  2519     return ActiveExecInitContinue( aState, aError );
       
  2520     }
       
  2521 
       
  2522 // -----------------------------------------------------------------------------
       
  2523 // CVtUiAppUi::ActiveExecCancel
       
  2524 // -----------------------------------------------------------------------------
       
  2525 //
       
  2526 void CVtUiAppUi::ActiveExecCancel(
       
  2527         CVtUiActiveExec& /*aActiveExec*/,
       
  2528         TInt aState )
       
  2529     {
       
  2530     ActiveExecInitCancel( aState );
       
  2531     }
       
  2532 
       
  2533 // -----------------------------------------------------------------------------
       
  2534 // CVtUiAppUi::ActiveExecDone
       
  2535 // -----------------------------------------------------------------------------
       
  2536 //
       
  2537 void CVtUiAppUi::ActiveExecDone(
       
  2538         CVtUiActiveExec& /*aActiveExec*/,
       
  2539         const TInt aInitialState )
       
  2540     {    
       
  2541     ActiveExecInitDone( aInitialState );
       
  2542     }
       
  2543 
       
  2544 // state object service handlers
       
  2545 
       
  2546 
       
  2547 // -----------------------------------------------------------------------------
       
  2548 // CVtUiAppUi::ShutdownL
       
  2549 // -----------------------------------------------------------------------------
       
  2550 //
       
  2551 void CVtUiAppUi::ShutdownL()
       
  2552     {
       
  2553     __VTPRINTENTER( "VtUi.ShutdownL" )
       
  2554     
       
  2555     CVtUiWhiteBalance* wb = static_cast< CVtUiWhiteBalance* >(
       
  2556             iFeatureManager->GetFeatureById( EVtUiFeatureIdWhiteBalance ) );
       
  2557     CVtUiColorTone* ct = static_cast< CVtUiColorTone* >(
       
  2558             iFeatureManager->GetFeatureById( EVtUiFeatureIdColourTone ) );
       
  2559     
       
  2560     if ( wb->State() == MVtUiFeature::EActive )
       
  2561         {
       
  2562         __VTPRINT( DEBUG_GEN, "CVtUiWhiteBalance::DoDeactivateL" );
       
  2563         wb->DoDeactivateL ();
       
  2564         }
       
  2565     if ( ct->State() == MVtUiFeature::EActive )
       
  2566         {
       
  2567         __VTPRINT( DEBUG_GEN, "CVtUiColorTone::DoDeactivateL" );
       
  2568         ct->DoDeactivateL( );            
       
  2569         }
       
  2570     
       
  2571     // close volume slider
       
  2572     CVtUiVolume* volume = static_cast< CVtUiVolume* >(
       
  2573     iFeatureManager->GetFeatureById( EVtUiFeatureIdVolume ) );
       
  2574     if ( volume )
       
  2575          {
       
  2576          volume->Stop();
       
  2577          }
       
  2578     // if capture mode is on stop the zoom
       
  2579     if ( iUiStates->IsCaptureModeOn() )
       
  2580         {
       
  2581         CVtUiZoom* zoom = static_cast< CVtUiZoom* >(
       
  2582         iFeatureManager->GetFeatureById( EVtUiFeatureIdZoom ) );
       
  2583         if ( zoom )
       
  2584             {
       
  2585             zoom->Stop();
       
  2586             }
       
  2587         }
       
  2588 
       
  2589     iActiveExec->Start( EVtUiAppUiShutdown, *this );
       
  2590     __VTPRINTEXIT( "VtUi.ShutdownL" )
       
  2591     }
       
  2592 
       
  2593 // -----------------------------------------------------------------------------
       
  2594 // CVtUiAppUi::StartupPhase1L
       
  2595 // -----------------------------------------------------------------------------
       
  2596 //
       
  2597 void CVtUiAppUi::StartupPhase1L()
       
  2598     {
       
  2599     __VTPRINTENTER( "VtUi.StartupPhase1L" )
       
  2600     iActiveExec->Start( EVtUiAppUiStartup, *this );
       
  2601     __VTPRINTEXIT( "VtUi.StartupPhase1L" )
       
  2602     }
       
  2603 
       
  2604 // -----------------------------------------------------------------------------
       
  2605 // CVtUiAppUi::StartupPhase2L
       
  2606 // -----------------------------------------------------------------------------
       
  2607 //
       
  2608 void CVtUiAppUi::StartupPhase2L()
       
  2609     {
       
  2610     __VTPRINTENTER( "VtUi.StartupPhase2L" )
       
  2611     iActiveExec->Start( EVtUiAppUiAnswered, *this );
       
  2612     __VTPRINTEXIT( "VtUi.StartupPhase2L" )
       
  2613     }
       
  2614 
       
  2615 // -----------------------------------------------------------------------------
       
  2616 // CVtUiAppUi::ChangeState
       
  2617 // -----------------------------------------------------------------------------
       
  2618 //
       
  2619 void CVtUiAppUi::ChangeState( TVtUiAppStateBase* aState )
       
  2620     {
       
  2621     __VTPRINTENTER( "VtUi.ChangeState" )
       
  2622     iState = aState;
       
  2623     __VTPRINTEXIT( "VtUi.ChangeState" )
       
  2624     }
       
  2625 
       
  2626 // -----------------------------------------------------------------------------
       
  2627 // CVtUiAppUi::IsCommandAllowedL
       
  2628 // -----------------------------------------------------------------------------
       
  2629 //
       
  2630 TBool CVtUiAppUi::IsCommandAllowedL( const TInt aCommand )
       
  2631     {
       
  2632     return iCommandManager->IsCommandAllowedL( aCommand );
       
  2633     }
       
  2634 
       
  2635 // -----------------------------------------------------------------------------
       
  2636 // CVtUiAppUi::RefreshDisabledFlagsL
       
  2637 // -----------------------------------------------------------------------------
       
  2638 //
       
  2639 void CVtUiAppUi::RefreshDisabledFlagsL()
       
  2640     {
       
  2641     // Refresh iDisabledFlags according to the current state.
       
  2642     TInt avail;
       
  2643     MVtEngMedia& media = Model().Media();
       
  2644     VtUiUtility::GetOutgoingMediaState( media, avail );
       
  2645     avail = ~avail;
       
  2646 
       
  2647     iDisabledFlags = 0;
       
  2648     if ( avail & MVtEngMedia::EMediaAudio )
       
  2649         {
       
  2650         iDisabledFlags |= EDisabledAudio;
       
  2651         }
       
  2652     if ( avail & MVtEngMedia::EMediaVideo )
       
  2653         {
       
  2654         iDisabledFlags |= EDisabledVideo;
       
  2655         }
       
  2656 
       
  2657     // If there are not cameras, then video options should be disabled.
       
  2658     if ( !VtUiUtility::HasCameras( media ) )
       
  2659         {
       
  2660         iDisabledFlags |= EVideoOptionsDisabled;
       
  2661         }
       
  2662     }
       
  2663 
       
  2664 // -----------------------------------------------------------------------------
       
  2665 // CVtUiAppUi::RefreshCameraOptionAvailability
       
  2666 // -----------------------------------------------------------------------------
       
  2667 //
       
  2668 void CVtUiAppUi::RefreshCameraOptionAvailability(
       
  2669         TBool& aUsePrimaryCameraNotAllowed,
       
  2670         TBool& aUseSecondaryCameraNotAllowed )
       
  2671     {
       
  2672     aUsePrimaryCameraNotAllowed = ETrue;
       
  2673     aUseSecondaryCameraNotAllowed = ETrue;
       
  2674 
       
  2675     // Check sources caps and current camera to see which
       
  2676     // items should be included to the menu.
       
  2677 
       
  2678     TInt sourcesCaps = 0;
       
  2679     MVtEngMedia& media = Model().Media();
       
  2680     (void) media.GetSourcesCaps( sourcesCaps );
       
  2681 
       
  2682     MVtEngMedia::TCameraId cameraId;
       
  2683     const TBool hasCameraId =
       
  2684         ( media.GetCurrentCameraId( cameraId ) == KErrNone );
       
  2685 
       
  2686     if ( hasCameraId )
       
  2687         {
       
  2688         // Camera is in use. Now selected camera is not included
       
  2689         // to the menu.
       
  2690         switch ( cameraId )
       
  2691             {
       
  2692             case MVtEngMedia::EPrimaryCamera:
       
  2693                 sourcesCaps &=
       
  2694                     ~MVtEngMedia::ESourceCapsPrimaryCamera;
       
  2695                 break;
       
  2696 
       
  2697             case MVtEngMedia::ESecondaryCamera:
       
  2698                 sourcesCaps &=
       
  2699                     ~MVtEngMedia::ESourceCapsSecondaryCamera;
       
  2700                 break;
       
  2701 
       
  2702             default:
       
  2703                 sourcesCaps = 0;
       
  2704                 break;
       
  2705             }
       
  2706         }
       
  2707     else
       
  2708         {
       
  2709         // If camera is not in use, then the "enable video" option
       
  2710         // will automatically use one of the existing cameras.
       
  2711         // However, if there are two cameras, then we need
       
  2712         // to include secondary to the menu.
       
  2713 
       
  2714         const TInt bothCameras =
       
  2715             ( MVtEngMedia::ESourceCapsPrimaryCamera |
       
  2716             MVtEngMedia::ESourceCapsSecondaryCamera );
       
  2717         sourcesCaps &= ~bothCameras;
       
  2718         if ( sourcesCaps == bothCameras )
       
  2719             {
       
  2720             sourcesCaps &=
       
  2721                 ~MVtEngMedia::ESourceCapsPrimaryCamera;
       
  2722             }
       
  2723         else
       
  2724             {
       
  2725             sourcesCaps = 0;
       
  2726             }
       
  2727         }
       
  2728 
       
  2729     sourcesCaps = ~sourcesCaps;
       
  2730     aUsePrimaryCameraNotAllowed =
       
  2731         ( sourcesCaps & MVtEngMedia::ESourceCapsPrimaryCamera );
       
  2732     aUseSecondaryCameraNotAllowed =
       
  2733         ( sourcesCaps & MVtEngMedia::ESourceCapsSecondaryCamera );
       
  2734     }
       
  2735 
       
  2736 // -----------------------------------------------------------------------------
       
  2737 // VtUiAppUi::CmdCaptureL
       
  2738 // -----------------------------------------------------------------------------
       
  2739 //
       
  2740 void CVtUiAppUi::CmdCaptureL()
       
  2741     {
       
  2742     //firstly need to know if underlying provider supports KVtEngFreeze
       
  2743     MVtEngCommandHandler& command = Model().CommandHandler();
       
  2744     const TInt caps = command.GetCommandCaps( KVtEngFreeze );
       
  2745     if ( (caps & MVtEngCommandHandler::EAttribEnabled) == 0)
       
  2746         {
       
  2747         return;
       
  2748         }
       
  2749     // end capture mode, image captured
       
  2750     iUiStates->SetCaptureModeOn( EFalse );
       
  2751     // end zoom mode
       
  2752     SetZoomModeL( EFalse, ETrue );
       
  2753     // freeze outgoing video
       
  2754     ExecuteCmdL( KVtEngFreeze );
       
  2755     RefreshBlind();
       
  2756     }
       
  2757 
       
  2758 // -----------------------------------------------------------------------------
       
  2759 // VtUiAppUi::CmdSnapshotL
       
  2760 // -----------------------------------------------------------------------------
       
  2761 //
       
  2762 void CVtUiAppUi::CmdSnapshotL()
       
  2763 	{
       
  2764 	__VTPRINTENTER( "VtUi.CmdSnapshotL" )
       
  2765 	
       
  2766 	// zoom mode must be set on before capture mode is set on
       
  2767     SetZoomModeL( ETrue, ETrue );
       
  2768 
       
  2769 	// if outgoing video is already frozen
       
  2770     MVtEngMedia& media = Model().Media();
       
  2771     const TBool isFrozen( VtUiUtility::GetFreezeState( media ) );
       
  2772     if ( isFrozen )
       
  2773     	{
       
  2774     	ExecuteCmdL( KVtEngUnfreeze );
       
  2775 	    }
       
  2776 	if ( !IsViewFinderInMainPane() )
       
  2777 	    {
       
  2778 	    SwitchViewFinderToMainPaneL( !isFrozen );
       
  2779 	    }
       
  2780 	else if ( !isFrozen )
       
  2781 	    {
       
  2782 	    iUiStates->SetViewFindersInitialPlaceContextPane( EFalse );
       
  2783 	    }
       
  2784   
       
  2785     // set capture mode on
       
  2786 
       
  2787     iUiStates->SetCaptureModeOn( ETrue );
       
  2788     RefreshStatesL();
       
  2789     RefreshBlind();
       
  2790     __VTPRINTEXIT( "VtUi.CmdSnapshotL" )
       
  2791     }
       
  2792 
       
  2793 // -----------------------------------------------------------------------------
       
  2794 // VtUiAppUi::CmdCancelCaptureL
       
  2795 // -----------------------------------------------------------------------------
       
  2796 //
       
  2797 void CVtUiAppUi::CmdCancelCaptureL()
       
  2798     {
       
  2799     __VTPRINTENTER( "VtUi.CmdCancelCaptureL" )
       
  2800     // end capture mode, image capture canceled
       
  2801     iUiStates->SetCaptureModeOn( EFalse );
       
  2802     SetZoomModeL( EFalse, ETrue );
       
  2803     RefreshStatesL();
       
  2804 	RestoreViewFinderL();
       
  2805     RefreshBlind();
       
  2806     __VTPRINTEXIT( "VtUi.CmdCancelCaptureL" )
       
  2807     }
       
  2808 
       
  2809 // -----------------------------------------------------------------------------
       
  2810 // CVtUiAppUi::CmdEnableVideoL
       
  2811 // -----------------------------------------------------------------------------
       
  2812 //
       
  2813 void CVtUiAppUi::CmdEnableVideoL()
       
  2814     {
       
  2815 	// if outgoing video is frozen
       
  2816     MVtEngMedia& media = Model().Media();
       
  2817     if ( VtUiUtility::GetFreezeState( media ) )
       
  2818     	{
       
  2819     	ExecuteCmdL( KVtEngUnfreeze );
       
  2820     	// swap images if needed
       
  2821         RestoreViewFinderL();
       
  2822     	}
       
  2823     else
       
  2824         {
       
  2825         ExecuteCmdL( KVtEngStopViewFinder );
       
  2826         iUplinkWindow->SetStreamBitmap( NULL );
       
  2827         MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaCamera;
       
  2828         ExecuteCmdL( KVtEngSetSource, source );
       
  2829         MVtEngMedia::TCameraId id;
       
  2830         if ( Model().Media().GetCurrentCameraId( id ) == KErrInUse )
       
  2831             {
       
  2832             ShowCameraInUseNoteL();
       
  2833             }
       
  2834         ExecuteCmdL( KVtEngStartViewFinder );
       
  2835         }
       
  2836     // update VB settings
       
  2837     UpdateVBSettingL();
       
  2838     }
       
  2839 
       
  2840 // -----------------------------------------------------------------------------
       
  2841 // CVtUiAppUi::CmdEnableAudioL
       
  2842 // -----------------------------------------------------------------------------
       
  2843 //
       
  2844 void CVtUiAppUi::CmdEnableAudioL()
       
  2845     {
       
  2846     ExecuteCmdL( KVtEngUnmuteOutgoingAudio );
       
  2847     }
       
  2848 
       
  2849 // -----------------------------------------------------------------------------
       
  2850 // CVtUiAppUi::CmdDisableVideoL
       
  2851 // -----------------------------------------------------------------------------
       
  2852 //
       
  2853 void CVtUiAppUi::CmdDisableVideoL()
       
  2854     {
       
  2855     	
       
  2856 		if( iUiStates->IsZoomModeOn() )
       
  2857 	        {
       
  2858 	        // if zoom feature is active, stop that
       
  2859 	        MVtUiFeature* zm = iFeatureManager->GetFeatureById( EVtUiFeatureIdZoom );
       
  2860 	        if ( zm )
       
  2861 	            {
       
  2862 	            if ( zm->State() ==  MVtUiFeature::EActive )
       
  2863 	                {
       
  2864 	                __VTPRINT( DEBUG_GEN, "VtUi.CmdDisableVideoL zm->STOP" )
       
  2865 	                zm->Stop();
       
  2866 	                }
       
  2867 	            }
       
  2868 	        }
       
  2869     	
       
  2870     ExecuteCmdL( KVtEngStopViewFinder );
       
  2871 
       
  2872     iUplinkWindow->SetStreamBitmap( NULL );
       
  2873 
       
  2874     TInt err = KErrNotFound;
       
  2875     if ( VtUiUtility::HasStillImage( Model().Media() ) )
       
  2876         {
       
  2877         __VTPRINT( DEBUG_GEN, "VtUi.:CmdDisableVideoL.HasStill" )
       
  2878         MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaStillImage;
       
  2879         TRAP( err, ExecuteCmdL( KVtEngSetSource, source ) );
       
  2880         }
       
  2881     if ( ( err != KErrNone ) )
       
  2882         {
       
  2883         __VTPRINT( DEBUG_GEN, "VtUi.:CmdDisableVideoL.MediaNone" )
       
  2884         MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaNone;
       
  2885         ExecuteCmdL( KVtEngSetSource, source );
       
  2886         }
       
  2887 
       
  2888     ExecuteCmdL( KVtEngStartViewFinder );
       
  2889     }
       
  2890 
       
  2891 // -----------------------------------------------------------------------------
       
  2892 // CVtUiAppUi::CmdDisableAudioL
       
  2893 // -----------------------------------------------------------------------------
       
  2894 //
       
  2895 void CVtUiAppUi::CmdDisableAudioL()
       
  2896     {
       
  2897     ExecuteCmdL( KVtEngMuteOutgoingAudio );
       
  2898     }
       
  2899 
       
  2900 // -----------------------------------------------------------------------------
       
  2901 // CVtUiAppUi::CmdActivateBtL
       
  2902 // -----------------------------------------------------------------------------
       
  2903 //
       
  2904 void CVtUiAppUi::CmdActivateBtL()
       
  2905     {
       
  2906     TInt error = KErrNone;
       
  2907     CVtUiActivateBtHfDialog* dialog =
       
  2908         new ( ELeave ) CVtUiActivateBtHfDialog(
       
  2909             NULL,
       
  2910             &error,
       
  2911             Model().CommandHandler(),
       
  2912             *iEventObserver );
       
  2913     dialog->ExecuteDialogLD();
       
  2914 
       
  2915     if ( error != KErrCancel )
       
  2916         {
       
  2917         switch ( error )
       
  2918             {
       
  2919             case KErrNone:
       
  2920                 break;
       
  2921 
       
  2922             case KErrNoMemory:
       
  2923             case KErrNotSupported:
       
  2924                 // Clear failure - to be handled in active scheduler.
       
  2925                 User::Leave( error );
       
  2926                 break;
       
  2927 
       
  2928             default:
       
  2929                 // Failed - still show local information note in error situation.
       
  2930                 {
       
  2931                 HBufC* prompt =
       
  2932                     StringLoader::LoadLC(
       
  2933                         R_VIDEOTELUI_QTN_BT_DEVICE_NOT_AVAIL );
       
  2934                 CAknInformationNote* note =
       
  2935                     new ( ELeave ) CAknInformationNote( ETrue );
       
  2936                 note->ExecuteLD( *prompt );
       
  2937                 CleanupStack::PopAndDestroy( prompt );
       
  2938                 }
       
  2939                 break;
       
  2940             }
       
  2941         }
       
  2942     }
       
  2943 
       
  2944 // -----------------------------------------------------------------------------
       
  2945 // CVtUiAppUi::CmdDeactivateBtL
       
  2946 // -----------------------------------------------------------------------------
       
  2947 //
       
  2948 void CVtUiAppUi::CmdDeactivateBtL()
       
  2949     {
       
  2950     // Command to Video tel engine
       
  2951     MVtEngAudio::TVtEngRoutingSetting audioSetting =
       
  2952         MVtEngAudio::EDeactivateBT;
       
  2953 
       
  2954     ExecuteCmdL( KVtEngSetAudioRouting, audioSetting );
       
  2955     }
       
  2956 
       
  2957 // -----------------------------------------------------------------------------
       
  2958 // CVtUiAppUi::CmdActivateLoudspeakerL
       
  2959 // -----------------------------------------------------------------------------
       
  2960 //
       
  2961 void CVtUiAppUi::CmdActivateLoudspeakerL()
       
  2962     {
       
  2963     MVtEngAudio::TVtEngRoutingSetting audioSetting =
       
  2964         MVtEngAudio::EActivateHandsfree;
       
  2965     ExecuteCmdL( KVtEngSetAudioRouting, audioSetting );
       
  2966     }
       
  2967 
       
  2968 // -----------------------------------------------------------------------------
       
  2969 // CVtUiAppUi::CmdDeactivateLoudspeakerL
       
  2970 // -----------------------------------------------------------------------------
       
  2971 //
       
  2972 void CVtUiAppUi::CmdDeactivateLoudspeakerL()
       
  2973     {
       
  2974     MVtEngAudio::TVtEngRoutingSetting audioSetting =
       
  2975         MVtEngAudio::EDeactivateHansfree;
       
  2976     ExecuteCmdL( KVtEngSetAudioRouting, audioSetting );
       
  2977     }
       
  2978 
       
  2979 // -----------------------------------------------------------------------------
       
  2980 // CVtUiAppUi::CmdSwapImagesPlacesL
       
  2981 // -----------------------------------------------------------------------------
       
  2982 //
       
  2983 void CVtUiAppUi::CmdSwapImagesPlacesL()
       
  2984     {
       
  2985     __VTPRINTENTER( "VtUi.Swap" )
       
  2986 
       
  2987     MVtEngMedia& media = Model().Media();
       
  2988     const TBool viewFinderStarted =
       
  2989         media.RenderingStarted( MVtEngMedia::EMediaOutgoing );
       
  2990     const TBool remoteRenderStarted =
       
  2991         media.RenderingStarted( MVtEngMedia::EMediaIncoming );
       
  2992 
       
  2993     if ( viewFinderStarted )
       
  2994         {
       
  2995         // Stop viewfinder.
       
  2996         __VTPRINT( DEBUG_GEN, "VtUi.Swap.VF.down" )
       
  2997         ExecuteCmdL( KVtEngStopViewFinder );
       
  2998         }
       
  2999     // Stop remote render.
       
  3000     __VTPRINT( DEBUG_GEN, "VtUi.Swap.RR.down" )
       
  3001     ExecuteCmdL( KVtEngStopRenderRemote );
       
  3002 
       
  3003     // Clear windows.
       
  3004     iUplinkWindow->Reset();
       
  3005     iDownlinkWindow->Reset();
       
  3006 
       
  3007     const TBool uplinkWindowEqualsContextControl =
       
  3008         ( iUplinkWindow == iInstance->iContextControl );
       
  3009 
       
  3010     // Prepare viewfinder.
       
  3011     __VTPRINT( DEBUG_GEN, "VtUi.Swap.VF.upd" )
       
  3012     TVtEngRenderingOptions configViewfinder(
       
  3013          uplinkWindowEqualsContextControl ?
       
  3014              DetermineMainControlOptions( EFalse ) :
       
  3015              DetermineContextControlOptions() );
       
  3016     ExecuteCmdL( KVtEngPrepareViewFinder, configViewfinder );
       
  3017 
       
  3018     // Swap windows.
       
  3019     if ( ERenderingModeDialer == iRenderingMode )
       
  3020         {
       
  3021         MVtUiVideoWindow* tmpWindow = iUplinkWindow;
       
  3022         iUplinkWindow = iStoredDownlinkWindow;
       
  3023         iStoredDownlinkWindow = tmpWindow;        
       
  3024         }
       
  3025     else
       
  3026         {
       
  3027         MVtUiVideoWindow* tmpWindow = iUplinkWindow;
       
  3028         iUplinkWindow = iDownlinkWindow;
       
  3029         iDownlinkWindow = tmpWindow;        
       
  3030         }
       
  3031     iUplinkWindow->SetRemoteVideoControl(NULL);
       
  3032     iDownlinkWindow->SetRemoteVideoControl(iInstance->iRemoteVideoControl);
       
  3033     iDownlinkWindow->LayoutRemoteVideo();    
       
  3034 
       
  3035     // Prepare remote render.
       
  3036     __VTPRINT( DEBUG_GEN, "VtUi.Swap.RR.upd" )
       
  3037     TRAPD ( err, {
       
  3038     TVtEngRenderingOptionsNGA configRemoteRenderNGA(
       
  3039             DetermineRemoteVideoControlOptionsNGA() );
       
  3040     ExecuteCmdL(
       
  3041             KVtEngPrepareRemoteRenderNGA,
       
  3042                 configRemoteRenderNGA );
       
  3043     } );
       
  3044     
       
  3045     if ( err != KErrNone )
       
  3046         {
       
  3047         if ( viewFinderStarted )
       
  3048             {
       
  3049             // Start viewfinder.
       
  3050             ExecuteCmdL( KVtEngStartViewFinder );
       
  3051             }
       
  3052         User::Leave ( err );	
       
  3053         }
       
  3054     // Start remote render.
       
  3055     __VTPRINT( DEBUG_GEN, "VtUi.Swap.RR.up" )
       
  3056     if ( remoteRenderStarted )
       
  3057         {
       
  3058         ExecuteCmdL( KVtEngStartRenderRemote );
       
  3059         }
       
  3060 
       
  3061     __VTPRINT( DEBUG_GEN, "VtUi.Swap.VF.up" )
       
  3062     if ( viewFinderStarted )
       
  3063         {
       
  3064         // Start viewfinder.
       
  3065         ExecuteCmdL( KVtEngStartViewFinder );
       
  3066         }
       
  3067 
       
  3068     iDownlinkWindow->Redraw();
       
  3069 
       
  3070     // Refresh blind & waiting will be handled in HandleCommandL.
       
  3071     __VTPRINTEXIT( "VtUi.Swap" )
       
  3072     }
       
  3073 
       
  3074 // -----------------------------------------------------------------------------
       
  3075 // CVtUiAppUi::CmdUseCameraL
       
  3076 // -----------------------------------------------------------------------------
       
  3077 //
       
  3078 void CVtUiAppUi::CmdUseCameraL( const TBool aPrimaryCamera )
       
  3079     {
       
  3080     EnableCommandActivatingAndCleanupPushL();
       
  3081     MVtEngMedia& media = Model().Media();
       
  3082 
       
  3083     MVtEngMedia::TMediaSource selectedSource =
       
  3084         ( aPrimaryCamera ) ?
       
  3085             MVtEngMedia::EMediaCameraPri : MVtEngMedia::EMediaCameraSec;
       
  3086 
       
  3087     TInt available = 0;
       
  3088     VtUiUtility::GetOutgoingMediaState( media, available );
       
  3089     if ( available & MVtEngMedia::EMediaVideo )
       
  3090         {
       
  3091         ExecuteCmdL( KVtEngStopViewFinder );
       
  3092 
       
  3093         iUplinkWindow->SetStreamBitmap( NULL );
       
  3094         TRAPD( err, ExecuteCmdL( KVtEngSetSource, selectedSource ) );
       
  3095 
       
  3096         if ( err == KErrNone )
       
  3097             {
       
  3098             ExecuteCmdL( KVtEngStartViewFinder );
       
  3099             }
       
  3100         else
       
  3101             {
       
  3102             ShowOtherCameraNotUsableNoteL();
       
  3103             }
       
  3104         }
       
  3105     else
       
  3106         {
       
  3107         MVtEngMedia::TPrepareCameraParams params;
       
  3108         params.iMediaSource = selectedSource;
       
  3109         params.iInitialize = EFalse;
       
  3110         TRAPD( err, ExecuteCmdL( KVtEngPrepareCamera, params ) );
       
  3111         if ( err != KErrNone )
       
  3112             {
       
  3113             ShowOtherCameraNotUsableNoteL();
       
  3114             }
       
  3115         }
       
  3116     CleanupStack::PopAndDestroy(); // EnableCommandActivatingAndCleanupPushL
       
  3117     }
       
  3118 
       
  3119 // -----------------------------------------------------------------------------
       
  3120 // CVtUiAppUi::CmdHelpL
       
  3121 // Launches help application.
       
  3122 // -----------------------------------------------------------------------------
       
  3123 //
       
  3124 void CVtUiAppUi::CmdHelpL()
       
  3125     {
       
  3126     HlpLauncher::LaunchHelpApplicationL(
       
  3127         iEikonEnv->WsSession(),
       
  3128         AppHelpContextL() );
       
  3129     }
       
  3130 
       
  3131 // -----------------------------------------------------------------------------
       
  3132 // CVtUiAppUi::PrepareExitL
       
  3133 // -----------------------------------------------------------------------------
       
  3134 //
       
  3135 void CVtUiAppUi::PrepareExitL()
       
  3136     {
       
  3137     __VTPRINTENTER( "VtUi.PrepareExitL" )
       
  3138     // Cancel progress dialog
       
  3139     HideProgressDialogL();
       
  3140     // Cancel menu.
       
  3141     CAknAppUi::ProcessCommandL( EEikCmdCanceled ); // does not leave
       
  3142 
       
  3143     if ( !iExitTimer->IsActive() )
       
  3144         {
       
  3145         __VTPRINT( DEBUG_GEN, "VtUi.Exit.Timer.Go" )
       
  3146         iExitTimer->Start(
       
  3147             KVtUiExitTimeout,
       
  3148             KVtUiExitTimeout,
       
  3149             TCallBack( DoHandleExitTimeout, this ) );
       
  3150         }
       
  3151 
       
  3152     // Asynchronous shutdown - execute command.
       
  3153     iBlankControl->SetActive( ETrue );
       
  3154     __VTPRINTEXIT( "VtUi.PrepareExitL" )
       
  3155     }
       
  3156 
       
  3157 // -----------------------------------------------------------------------------
       
  3158 // CVtUiAppUi::CmdUpdateZoomL
       
  3159 // This method is called to update zoom step to the Video Telephone engine
       
  3160 // side from the HandleKeyEventL method.
       
  3161 // -----------------------------------------------------------------------------
       
  3162 //
       
  3163 void CVtUiAppUi::CmdUpdateZoomL()
       
  3164     {
       
  3165     __VTPRINTENTER( "VtUi.UpdZm" )
       
  3166 
       
  3167     __VTPRINTEXIT( "VtUi.UpdZm" )
       
  3168     }
       
  3169 
       
  3170 // -----------------------------------------------------------------------------
       
  3171 // CVtUiAppUi::SetZoomFactorL
       
  3172 // -----------------------------------------------------------------------------
       
  3173 //
       
  3174 void CVtUiAppUi::SetZoomFactorL( TInt aZoomStep )
       
  3175     {
       
  3176     __VTPRINTENTER( "VtUi.SetZoomFactorL" )
       
  3177     MVtEngMedia& media = Model().Media();
       
  3178     if ( VtUiUtility::IsZoomAllowed( media ) )
       
  3179         {
       
  3180         ExecuteCmdL( KVtEngSetZoomStep, aZoomStep );
       
  3181         }
       
  3182     __VTPRINTEXIT( "VtUi.SetZoomFactorL" )
       
  3183     }
       
  3184 
       
  3185 
       
  3186 // -----------------------------------------------------------------------------
       
  3187 // CVtUiAppUi::CmdUpdateVolumeL
       
  3188 // This method is called to update volume to the Video Telephone engine
       
  3189 // side
       
  3190 // -----------------------------------------------------------------------------
       
  3191 //
       
  3192 void CVtUiAppUi::CmdUpdateVolumeL( MVtEngAudio::TVtEngOutputVolume aVolume )
       
  3193     {
       
  3194     __VTPRINTENTER( "VtUi.CmdUpdateVolumeL" )
       
  3195     iVolCtrl->AdjustVolumeL( aVolume );
       
  3196     __VTPRINTEXIT( "VtUi.CmdUpdateVolumeL" )
       
  3197     }
       
  3198 
       
  3199 // -----------------------------------------------------------------------------
       
  3200 // CVtUiAppUi::CmdGoToIdleL
       
  3201 // -----------------------------------------------------------------------------
       
  3202 //
       
  3203 void CVtUiAppUi::CmdGoToIdleL()
       
  3204     {
       
  3205 	__VTPRINTENTER( "VtUi.CmdGoToIdleL" )
       
  3206     TInt idleUid = 0;
       
  3207     if ( RProperty::Get(
       
  3208              KPSUidAiInformation,
       
  3209              KActiveIdleUid,
       
  3210              idleUid ) == KErrNone )
       
  3211         {
       
  3212 		__VTPRINT2( DEBUG_GEN, "Idle UID: %d", idleUid )
       
  3213         TApaTaskList taskList( iEikonEnv->WsSession() );
       
  3214         TApaTask task = taskList.FindApp( TUid::Uid( idleUid ) );
       
  3215         if ( task.Exists() )
       
  3216             {
       
  3217 			__VTPRINT( DEBUG_GEN, "Idle task found")
       
  3218             RProperty::Set( KPSUidUikon, KUikVideoCallTopApp, KVtUiAppUid.iUid );
       
  3219             task.BringToForeground();
       
  3220             }
       
  3221         }
       
  3222 	__VTPRINTEXIT( "VtUi.CmdGoToIdleL" )
       
  3223     }
       
  3224 
       
  3225 // -----------------------------------------------------------------------------
       
  3226 // CVtUiAppUi::CmdInitializeShareImageL
       
  3227 // -----------------------------------------------------------------------------
       
  3228 //
       
  3229 void CVtUiAppUi::CmdInitializeShareImageL( TBool& aNeedRefresh )
       
  3230     {
       
  3231     __VTPRINTENTER( "VtUi.CmdInitializeShareImageL" )
       
  3232     EnableCommandActivatingAndCleanupPushL();
       
  3233 
       
  3234     MVtUiFeature* tb =
       
  3235     iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar );
       
  3236       if ( tb )
       
  3237         {
       
  3238         // timer could be active
       
  3239         if ( iTbPeriodic )
       
  3240             {
       
  3241             iTbPeriodic->Cancel();
       
  3242             }
       
  3243         tb->Stop();
       
  3244         }
       
  3245     CDesCArray* selectedFiles = new ( ELeave ) CDesCArrayFlat( 1 );
       
  3246     CleanupStack::PushL( selectedFiles );
       
  3247     CVtUiAppUi::CVtUiAppUiMGVerifier* verifier =
       
  3248         CVtUiAppUi::CVtUiAppUiMGVerifier::NewLC( *this, *iCoeEnv );
       
  3249 
       
  3250      // number erntry is not availabe while media gallery is open
       
  3251     iInstance->iNumberEntryActivation->SetActive( EFalse );
       
  3252     iUiStates->SetSelectingShare( ETrue );
       
  3253 
       
  3254     TBool result( EFalse );
       
  3255     TRAPD( err, result =
       
  3256         MGFetch::RunL( *selectedFiles, EImageFile, EFalse, verifier ) );
       
  3257 
       
  3258    // leave occured
       
  3259    if ( err != KErrNone )
       
  3260        {
       
  3261        if ( iUiStates->ExecState() == TVtUiStates::EExecStateRunning )
       
  3262            {
       
  3263            ShowUnableToOpenNoteL();
       
  3264            }
       
  3265        else
       
  3266            {
       
  3267            __VTPRINTEXIT( "VtUi.CmdInitializeShareImageL 1" )
       
  3268            Exit();
       
  3269            }
       
  3270        }
       
  3271 
       
  3272     if ( result && ( selectedFiles->Count() > 0 ) )
       
  3273         {
       
  3274         MVtEngMedia::TShareObjectState shareObjectState;
       
  3275         VtUiUtility::GetObjectSharingState( Model().Media(), shareObjectState );
       
  3276         iUiStates->SetViewFinderToMainPane(
       
  3277             shareObjectState == MVtEngMedia::ENotSharing );
       
  3278         MVtEngMedia::TShareObjectImageParameters
       
  3279             parameters( selectedFiles->operator[]( 0 ) );
       
  3280         ExecuteCmdL( KVtEngInitializeShareImage, parameters );
       
  3281         aNeedRefresh = ETrue;
       
  3282         }
       
  3283     else  // selection canceled start toolbar timer
       
  3284         {
       
  3285         if ( !iTbPeriodic )
       
  3286             {
       
  3287             iTbPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
  3288             }
       
  3289         iTbPeriodic->Cancel();
       
  3290         iTbPeriodic->Start( KStartTime, KPeriodTime, TCallBack( DoTryToStartTbL, this ) );
       
  3291         }
       
  3292     CleanupStack::PopAndDestroy( 2 ); // selectedFiles, verifier
       
  3293     // number entry is availabe again
       
  3294     iInstance->iNumberEntryActivation->SetActive( ETrue );
       
  3295     iUiStates->SetSelectingShare( EFalse );
       
  3296     CleanupStack::PopAndDestroy(); // EnableCommandActivatingAndCleanupPushL();
       
  3297     
       
  3298     __VTPRINTEXIT( "VtUi.CmdInitializeShareImageL 0" )
       
  3299     }
       
  3300 
       
  3301 // -----------------------------------------------------------------------------
       
  3302 // CVtUiAppUi::CmdShareImageL
       
  3303 // -----------------------------------------------------------------------------
       
  3304 //
       
  3305 void CVtUiAppUi::CmdShareImageL()
       
  3306     {
       
  3307     ExecuteCmdL( KVtEngStartShareImage );
       
  3308     }
       
  3309 
       
  3310 // -----------------------------------------------------------------------------
       
  3311 // CVtUiAppUi::CmdStopShareImageL
       
  3312 // -----------------------------------------------------------------------------
       
  3313 //
       
  3314 void CVtUiAppUi::CmdStopShareImageL( TBool& aNeedRefresh )
       
  3315     {
       
  3316     ExecuteCmdL( KVtEngStopShareImage );
       
  3317 	RestoreViewFinderL();
       
  3318     aNeedRefresh = ETrue;
       
  3319     // update VB settings
       
  3320     UpdateVBSettingL();
       
  3321     }
       
  3322 
       
  3323 // -----------------------------------------------------------------------------
       
  3324 // CVtUiAppUi::HandleWaitingStateChange
       
  3325 // -----------------------------------------------------------------------------
       
  3326 //
       
  3327 void CVtUiAppUi::HandleWaitingStateChange( TBool aIsWaiting )
       
  3328 	{
       
  3329     // Dialer must be closed in case of waiting call
       
  3330     MVtUiFeature* dialer =
       
  3331         iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer );
       
  3332     if ( dialer )
       
  3333         {
       
  3334         dialer->Stop();
       
  3335         }
       
  3336     iUiStates->SetWaitingCall( aIsWaiting );
       
  3337     if (aIsWaiting == EFalse && 
       
  3338         iIsWaitingCallState != EFalse && 
       
  3339         !iUiStates->IsThisApplicationForeground() )
       
  3340         {
       
  3341         iIsWaitingCallState = EFalse;
       
  3342         ChangeApplicationFocus( ETrue );
       
  3343         TRAP_IGNORE ( SetHiddenL( EFalse ) );
       
  3344         }
       
  3345 	}
       
  3346 
       
  3347 // -----------------------------------------------------------------------------
       
  3348 // CVtUiAppUi::ActiveExecInitExecuteL
       
  3349 // -----------------------------------------------------------------------------
       
  3350 //
       
  3351 TBool CVtUiAppUi::ActiveExecInitExecuteL(
       
  3352         const TInt aState,
       
  3353         TInt& aNextState,
       
  3354         TRequestStatus& aRequest )
       
  3355     {
       
  3356     __VTPRINTENTER( "VtUi.InitExec" )
       
  3357     __VTPRINT2( DEBUG_GEN, "VtUi.InitExec.st=%d", aState )
       
  3358 
       
  3359     TBool synch = EFalse;
       
  3360 
       
  3361     switch ( aState )
       
  3362         {
       
  3363         // Startup chain:
       
  3364         case EVtUiAppUiStartupCloseDialogs:
       
  3365             // Close all dialogs.
       
  3366             iBlankControl->SetActive( EFalse );
       
  3367             AknDialogShutter::ShutDialogsL( *iEikonEnv );
       
  3368             iBlankControl->SetActive( ETrue );
       
  3369 
       
  3370             synch = ETrue;
       
  3371             aNextState = EVtUiAppUiStartupInitEngine;
       
  3372             break;
       
  3373 
       
  3374         case EVtUiAppUiStartupInitEngine:
       
  3375             iUplinkWindow = iInstance->iContextControl;
       
  3376             iDownlinkWindow = iInstance->iMainControl;
       
  3377             ActiveExecInitExecuteCommandL( KVtEngInitializeEngine, aRequest );
       
  3378             aNextState = EVtUiAppUiStartupPrepareViewfinder;
       
  3379             break;
       
  3380 
       
  3381         case EVtUiAppUiStartupPrepareViewfinder:
       
  3382             ActiveExecInitPrepareViewFinderL( aRequest );
       
  3383             iUplinkWindow->SetStreamBitmap( NULL );
       
  3384             aNextState = EVtUiAppUiStartupPrepareRemoteRender;
       
  3385             break;
       
  3386 
       
  3387         case EVtUiAppUiStartupPrepareRemoteRender:
       
  3388         
       
  3389             iInstance->CreateRemoteVideoControl();
       
  3390             ActiveExecInitPrepareRemoteRenderL( aRequest );
       
  3391             iDownlinkWindow->SetStreamBitmap( NULL );
       
  3392             aNextState = EVtUiAppUiStartupRemoveBlank;
       
  3393             break;
       
  3394 
       
  3395         case EVtUiAppUiStartupRemoveBlank:
       
  3396              // Finally remove blank control.
       
  3397             iBlankControl->SetActive( EFalse );
       
  3398             aNextState = EVtUiAppUiNone;
       
  3399             synch = ETrue;
       
  3400             break;
       
  3401 
       
  3402         // Shutdown chain:
       
  3403         case EVtUiAppUiShutdownCloseDialogs:
       
  3404             {
       
  3405             // Close all dialogs.
       
  3406             iBlankControl->SetActive( EFalse );
       
  3407             AknDialogShutter::ShutDialogsL( *iEikonEnv );
       
  3408             iBlankControl->SetActive( ETrue );
       
  3409 
       
  3410             MVtUiFeature* numberEntry = iFeatureManager->GetFeatureById(
       
  3411                 EVtUiFeatureIdNumberEntry );
       
  3412             // Number entry may be active if its deactivation timer is still
       
  3413             // pending. Stop performs some cleanup which is needed before AppUi
       
  3414             // cleanup.
       
  3415             if ( numberEntry )
       
  3416                 {
       
  3417                 numberEntry->Stop();
       
  3418                 }
       
  3419 
       
  3420             synch = ETrue;
       
  3421             aNextState = EVtUiAppUiShutdownHideApplication;
       
  3422             }
       
  3423             break;
       
  3424 
       
  3425         case EVtUiAppUiShutdownHideApplication:
       
  3426             if ( iUiStates->IsThisApplicationForeground() )
       
  3427                 {
       
  3428                 BringTelephoneToForeground();
       
  3429                 }
       
  3430             else
       
  3431                 {
       
  3432                 ChangeApplicationFocus( EFalse );
       
  3433                 }
       
  3434             iDownlinkWindow->SetStreamBitmap( NULL );
       
  3435             iUplinkWindow->SetStreamBitmap( NULL );
       
  3436             SetHiddenL( ETrue );
       
  3437             iEventObserver->DeleteRemConSession();
       
  3438 
       
  3439             synch = ETrue;
       
  3440             aNextState = EVtUiAppUiShutdownResetEngine;
       
  3441             break;
       
  3442 
       
  3443         case EVtUiAppUiShutdownResetEngine:
       
  3444             {
       
  3445             aRequest = KRequestPending;
       
  3446 
       
  3447             MVtEngCommandHandler& command = Model().CommandHandler();
       
  3448             // There should not be any commands ongoing because
       
  3449             // we have canceled all dialogs (and this should
       
  3450             // be the only command without dialog).
       
  3451             command.CancelCommand( command.PendingCommand() ); // ignore error
       
  3452             command.ExecuteL( KVtEngResetEngine, NULL );
       
  3453             iShutdownRequest = &aRequest;
       
  3454 
       
  3455             aNextState = EVtUiAppUiShutdownRemoveBlank;
       
  3456             }
       
  3457             break;
       
  3458 
       
  3459         case EVtUiAppUiShutdownRemoveBlank:
       
  3460             // Finally remove blank control.
       
  3461             iBlankControl->SetActive( EFalse );
       
  3462 
       
  3463             synch = ETrue;
       
  3464             aNextState = EVtUiAppUiNone;
       
  3465             break;
       
  3466 
       
  3467         // Answered chain:
       
  3468         case EVtUiAppUiAnsweredStart:
       
  3469             {
       
  3470             CVtUiBlankDialog* dialog =
       
  3471                 new ( ELeave ) CVtUiBlankDialog( &iExecBlankDialog );
       
  3472             dialog->ExecuteDialogNoWaitLD();
       
  3473             iExecBlankDialog = dialog;
       
  3474 
       
  3475             synch = ETrue;
       
  3476             if ( iUiStates->IsLayoutChangeNeeded() )
       
  3477                 {
       
  3478                 (void) HandleLayoutChanged();
       
  3479                 }
       
  3480             aNextState = EVtUiAppUiAnsweredRefreshNavi;
       
  3481             }
       
  3482             break;
       
  3483 
       
  3484         case EVtUiAppUiAnsweredRefreshNavi:
       
  3485             RefreshNaviPaneL();
       
  3486             iEventObserver->CreateRemConSessionL();
       
  3487 
       
  3488             synch = ETrue;
       
  3489             aNextState = EVtUiAppUiAnsweredRefreshSoftkeys;
       
  3490             break;
       
  3491 
       
  3492         case EVtUiAppUiAnsweredRefreshSoftkeys:
       
  3493             RefreshSoftkeysL();
       
  3494 
       
  3495             synch = ETrue;
       
  3496             aNextState = EVtUiAppUiAnsweredStartRemoteRender;
       
  3497             break;
       
  3498 
       
  3499         case EVtUiAppUiAnsweredStartRemoteRender:
       
  3500             {
       
  3501             // Set waiting text to main control and start remote rendering.
       
  3502             // Video Telephone application should get KVtEngRemoteVideoStarted
       
  3503             // event when the first frame is received.
       
  3504             iDownlinkWindow->SetWaiting( ETrue );
       
  3505             iUiStates->SetWaitingForFirstFrame( ETrue );
       
  3506             //Must check if orientation changed between prepare remote render and start remote render
       
  3507             //If changed, update render parameter firstly
       
  3508             if ( iIsLandScapeOrientation != VtUiLayout::IsLandscapeOrientation() )
       
  3509                 {
       
  3510                  __VTPRINT( DEBUG_GEN, "layout has been changed before start RemoteRender" )
       
  3511                  UpdateRenderingParametersL();
       
  3512                 }
       
  3513 
       
  3514             ActiveExecInitExecuteCommandL( KVtEngStartRenderRemote,
       
  3515                 aRequest );
       
  3516 
       
  3517             aNextState = EVtUiAppUiAnsweredCheckCamera;            
       
  3518             }
       
  3519             break;
       
  3520 
       
  3521         case EVtUiAppUiAnsweredCheckCamera:
       
  3522             {
       
  3523             MVtEngMedia& media = Model().Media();
       
  3524             if ( VtUiUtility::HasCameras( media ) )
       
  3525                 {
       
  3526                 aNextState = EVtUiAppUiAnsweredChoose;
       
  3527                 synch = ETrue;
       
  3528                 }
       
  3529             else
       
  3530                 {
       
  3531                 if ( VtUiUtility::HasStillImage( media ) )
       
  3532                     {
       
  3533                     aNextState = EVtUiAppUiAnsweredSelectStill;
       
  3534                     }
       
  3535                 else
       
  3536                     {
       
  3537                     aNextState = EVtUiAppUiAnsweredSelectNone;
       
  3538                     }
       
  3539 
       
  3540                 synch = ETrue;
       
  3541                 }
       
  3542             }
       
  3543             break;
       
  3544 
       
  3545         case EVtUiAppUiAnsweredChoose:
       
  3546             {
       
  3547             // If camera is in use, then show note,
       
  3548             // select still image, stop.
       
  3549             //
       
  3550             // If call is mobile terminated, then show query.
       
  3551             //      If user answers 'yes' to the query,
       
  3552             //      then activate camera.
       
  3553             //      If user answers 'no' to the query,
       
  3554             //      then choose still image.
       
  3555             //
       
  3556             // If call is mobile originated, then select camera.
       
  3557             //
       
  3558             // If selecting a camera fails, then select still image.
       
  3559             // If selecting still image fails, then select none.
       
  3560             //
       
  3561             CVtEngModel& model = Model();
       
  3562             MVtEngSessionInfo& session = model.Session();
       
  3563             MVtEngMedia& media = model.Media();
       
  3564 
       
  3565             MVtEngMedia::TCameraId id;
       
  3566             TInt cameraErr = model.Media().GetCurrentCameraId( id );
       
  3567             if ( cameraErr == KErrInUse )
       
  3568                 {
       
  3569                 // Camera is in use.
       
  3570                 iUiStates->SetExecShowCameraInUse( ETrue );
       
  3571 
       
  3572                 if ( VtUiUtility::HasStillImage( media ) )
       
  3573                     {
       
  3574                     aNextState = EVtUiAppUiAnsweredSelectStill;
       
  3575                     }
       
  3576                 else
       
  3577                     {
       
  3578                     aNextState = EVtUiAppUiAnsweredSelectNone;
       
  3579                     }
       
  3580                 }
       
  3581             else
       
  3582                 {
       
  3583                 // Check the direction of the call.
       
  3584                 iUiStates->SetExecShowCameraInUse( EFalse );
       
  3585                 MVtEngSessionInfo::TDirection direction;
       
  3586                 if ( session.GetDirection( direction ) != KErrNone )
       
  3587                     {
       
  3588                     direction = MVtEngSessionInfo::EDirectionMT;
       
  3589                     }
       
  3590 
       
  3591                 if ( direction == MVtEngSessionInfo::EDirectionMT )
       
  3592                     {
       
  3593                     // Start steps towards the "Allow video" query.
       
  3594                     if ( VtUiUtility::HasStillImage( media ) )
       
  3595                         {
       
  3596                         aNextState = EVtUiAppUiAnsweredQuerySetupStill;
       
  3597                         }
       
  3598                     else
       
  3599                         {
       
  3600                         aNextState = EVtUiAppUiAnsweredQuerySetupNone;
       
  3601                         }
       
  3602                     }
       
  3603                 else
       
  3604                     {                    
       
  3605                     aNextState = EVtUiAppUiAnsweredDoPrepareCamera;
       
  3606                     }
       
  3607                 }
       
  3608             synch = ETrue;
       
  3609             }
       
  3610             break;
       
  3611 
       
  3612         case EVtUiAppUiAnsweredQuerySetupStill:
       
  3613             ActiveExecInitSetSourceL( MVtEngMedia::EMediaStillImage, aRequest );
       
  3614             aNextState = EVtUiAppUiAnsweredQuerySetupStart;
       
  3615             break;
       
  3616 
       
  3617         case EVtUiAppUiAnsweredQuerySetupNone:
       
  3618             ActiveExecInitSetSourceL( MVtEngMedia::EMediaNone, aRequest );
       
  3619             aNextState = EVtUiAppUiAnsweredQuerySetupStart;
       
  3620             break;
       
  3621 
       
  3622         case EVtUiAppUiAnsweredQuerySetupStart:
       
  3623             ActiveExecInitExecuteCommandL( KVtEngStartViewFinder, aRequest );
       
  3624             aNextState = EVtUiAppUiAnsweredQueryShow;
       
  3625             break;
       
  3626 
       
  3627         case EVtUiAppUiAnsweredQueryShow:
       
  3628             {
       
  3629             RefreshL();
       
  3630             TInt state = EPSCTsyCallStateUninitialized;
       
  3631             TInt err = RProperty::Get(
       
  3632                 KPSUidCtsyCallInformation,
       
  3633                 KCTsyCallState,
       
  3634                 state );
       
  3635             __VTPRINT3( DEBUG_GEN, "VtUi.InitExec WaitingCall State=%d, err=%d",
       
  3636             state, err )
       
  3637             if ( EPSCTsyCallStateRinging != state )
       
  3638                 {
       
  3639                 ChangeApplicationFocus( ETrue );
       
  3640                 SetHiddenL( EFalse );
       
  3641                 }
       
  3642             else
       
  3643                 {
       
  3644                 iIsWaitingCallState = ETrue;
       
  3645                 }
       
  3646 
       
  3647 			// User selectable call answer mute.
       
  3648 			// In GS one can set call ansewer status
       
  3649 			// eighter to query user, allways show, allways mute.
       
  3650 			// GS values are checked from CR key ( KSettingsVTVideoSending )
       
  3651 			// (default value is 0 = allways query).
       
  3652 			TVtUiGsMuteVariation camute;
       
  3653     		__VTPRINT2( DEBUG_GEN, "VtUi.InitExe GS CR key KSettingsVTVideoSending querystate=%d", camute.GsMuteState() )
       
  3654 			if ( camute.GsMuteState() == KAllwaysQuery && !iUiStates->IsDeviceLockOn() && EPSCTsyCallStateRinging != state)
       
  3655 				{
       
  3656             	CVtUiAllowVideoDialog* dialog =
       
  3657                 	new ( ELeave ) CVtUiAllowVideoDialog(
       
  3658                     	&iExecDialog,
       
  3659                     	CAknQueryDialog::ENoTone );
       
  3660             	dialog->ExecuteDialogLD( aRequest );
       
  3661             	iExecDialog = dialog;
       
  3662             	aNextState = EVtUiAppUiAnsweredQueryDecide;
       
  3663 				}
       
  3664 			else if ( camute.GsMuteState() == KAllwaysAllow )
       
  3665 				{
       
  3666                 aNextState = EVtUiAppUiAnsweredDoPrepareCamera;
       
  3667 				synch = ETrue;
       
  3668 				}
       
  3669 			else
       
  3670 				{
       
  3671 				aNextState = EVtUiAppUiNone;
       
  3672 				synch = ETrue;
       
  3673 				}
       
  3674 
       
  3675             }
       
  3676             break;
       
  3677 
       
  3678         case EVtUiAppUiAnsweredQueryDecide:
       
  3679             {
       
  3680             delete iExecDialog;
       
  3681             iExecDialog = NULL;
       
  3682 
       
  3683             if ( iActiveExec->RequestStatus() ==
       
  3684                  CVtUiAllowVideoDialog::EUserAllowed )
       
  3685                 {
       
  3686                 aNextState = EVtUiAppUiAnsweredDoPrepareCamera;
       
  3687                 }
       
  3688             else
       
  3689                 {
       
  3690                 aNextState = EVtUiAppUiNone;
       
  3691                 }
       
  3692 
       
  3693             synch = ETrue;
       
  3694             }
       
  3695             break;
       
  3696 
       
  3697         case EVtUiAppUiAnsweredDoPrepareCamera:
       
  3698             {
       
  3699             MVtEngMedia& media = Model().Media();
       
  3700             MVtEngMedia::TMediaSource source = MVtEngMedia::EMediaCamera;
       
  3701             ActiveExecInitPrepareCameraL( source, aRequest );
       
  3702             aNextState = EVtUiAppUiAnsweredSelectCamera;
       
  3703             }
       
  3704             break;
       
  3705 
       
  3706         case EVtUiAppUiAnsweredQuerySelectCamera:
       
  3707         case EVtUiAppUiAnsweredSelectCamera:
       
  3708             ActiveExecInitSetSourceL( MVtEngMedia::EMediaCamera, aRequest );
       
  3709             if ( aState == EVtUiAppUiAnsweredSelectCamera )
       
  3710                 {
       
  3711                 aNextState = EVtUiAppUiAnsweredStartViewfinder;
       
  3712                 }
       
  3713             else
       
  3714                 {
       
  3715                 aNextState = EVtUiAppUiAnsweredQueryStartViewfinder;
       
  3716                 }
       
  3717             break;
       
  3718 
       
  3719         case EVtUiAppUiAnsweredQuerySelectStill:
       
  3720         case EVtUiAppUiAnsweredSelectStill:
       
  3721             ActiveExecInitSetSourceL( MVtEngMedia::EMediaStillImage, aRequest );
       
  3722 
       
  3723             if ( aState == EVtUiAppUiAnsweredSelectStill )
       
  3724                 {
       
  3725                 aNextState = EVtUiAppUiAnsweredStartViewfinder;
       
  3726                 }
       
  3727             else
       
  3728                 {
       
  3729                 aNextState = EVtUiAppUiAnsweredQueryStartViewfinder;
       
  3730                 }
       
  3731             break;
       
  3732 
       
  3733         case EVtUiAppUiAnsweredQuerySelectNone:
       
  3734         case EVtUiAppUiAnsweredSelectNone:
       
  3735             ActiveExecInitSetSourceL( MVtEngMedia::EMediaNone, aRequest );
       
  3736 
       
  3737             if ( aState == EVtUiAppUiAnsweredSelectNone )
       
  3738                 {
       
  3739                 aNextState = EVtUiAppUiAnsweredStartViewfinder;
       
  3740                 }
       
  3741             else
       
  3742                 {
       
  3743                 aNextState = EVtUiAppUiAnsweredQueryStartViewfinder;
       
  3744                 }
       
  3745             break;
       
  3746 
       
  3747         case EVtUiAppUiAnsweredQueryStartViewfinder:
       
  3748         case EVtUiAppUiAnsweredStartViewfinder:
       
  3749             ActiveExecInitExecuteCommandL( KVtEngStartViewFinder, aRequest );
       
  3750 
       
  3751             if ( aState == EVtUiAppUiAnsweredStartViewfinder )
       
  3752                 {
       
  3753                 aNextState = EVtUiAppUiAnsweredFinish;
       
  3754                 }
       
  3755             else
       
  3756                 {
       
  3757                 aNextState = EVtUiAppUiAnsweredQueryFinish;
       
  3758                 }
       
  3759             break;
       
  3760 
       
  3761         case EVtUiAppUiAnsweredQueryFinish:
       
  3762         case EVtUiAppUiAnsweredFinish:
       
  3763             RefreshL();
       
  3764             if ( iUiStates->IsExecShowCameraInUse() )
       
  3765                 {
       
  3766                 ShowCameraInUseNoteL();
       
  3767                 }
       
  3768 
       
  3769             if ( aState != EVtUiAppUiAnsweredQueryFinish )
       
  3770                 {
       
  3771                 ChangeApplicationFocus( ETrue );
       
  3772                 }
       
  3773             SetHiddenL( EFalse );
       
  3774 
       
  3775             synch = ETrue;
       
  3776             aNextState = EVtUiAppUiNone;
       
  3777             break;
       
  3778 
       
  3779         default:
       
  3780             User::Leave( KErrNotSupported );
       
  3781             break;
       
  3782         }
       
  3783 
       
  3784     __VTPRINT2( DEBUG_GEN, "VtUi.InitExec.sync=%d", synch )
       
  3785     __VTPRINT2( DEBUG_GEN, "VtUi.InitExec.next=%d", aNextState )
       
  3786     __VTPRINTEXITR( "VtUi.InitExec %d", synch )
       
  3787     return synch;
       
  3788     }
       
  3789 
       
  3790 // -----------------------------------------------------------------------------
       
  3791 // CVtUiAppUi::ActiveExecInitContinue
       
  3792 // -----------------------------------------------------------------------------
       
  3793 //
       
  3794 TBool CVtUiAppUi::ActiveExecInitContinue(
       
  3795         TInt& aState,
       
  3796         const TInt aError )
       
  3797     {
       
  3798     __VTPRINTENTER( "VtUi.InitExecCont" )
       
  3799     __VTPRINT2( DEBUG_GEN, "VtUi.InitExecCont.st=%d", aState )
       
  3800     //__VTPRINT2( DEBUG_GEN, "VtUi.InitExecCont.err=%d", aError )
       
  3801 
       
  3802     const TInt state = aState;
       
  3803     switch ( state )
       
  3804         {
       
  3805         case EVtUiAppUiStartupCloseDialogs:
       
  3806         case EVtUiAppUiStartupInitEngine:
       
  3807         case EVtUiAppUiStartupPrepareViewfinder:
       
  3808         case EVtUiAppUiStartupPrepareRemoteRender:
       
  3809         case EVtUiAppUiStartupRemoveBlank:
       
  3810             // Prepare failed.
       
  3811             break;
       
  3812 
       
  3813         case EVtUiAppUiShutdownCloseDialogs:
       
  3814             if( KErrNotReady == aError )
       
  3815                 {
       
  3816                 aState = EVtUiAppUiShutdownHideApplication;
       
  3817                 break;
       
  3818                 }
       
  3819         case EVtUiAppUiShutdownResetEngine:            
       
  3820         case EVtUiAppUiShutdownRemoveBlank:
       
  3821             // shutdown failed
       
  3822             break;            
       
  3823 
       
  3824         case EVtUiAppUiShutdownHideApplication:
       
  3825             aState = EVtUiAppUiShutdownResetEngine;
       
  3826             break;
       
  3827             
       
  3828 
       
  3829         case EVtUiAppUiAnsweredStart:
       
  3830             aState = EVtUiAppUiAnsweredRefreshNavi;
       
  3831             break;
       
  3832 
       
  3833         case EVtUiAppUiAnsweredRefreshNavi:
       
  3834             aState = EVtUiAppUiAnsweredRefreshSoftkeys;
       
  3835             break;
       
  3836 
       
  3837         case EVtUiAppUiAnsweredRefreshSoftkeys:
       
  3838             aState = EVtUiAppUiAnsweredStartRemoteRender;
       
  3839             break;
       
  3840 
       
  3841         case EVtUiAppUiAnsweredStartRemoteRender:
       
  3842         case EVtUiAppUiAnsweredStartViewfinder:
       
  3843         case EVtUiAppUiAnsweredSelectNone:
       
  3844         case EVtUiAppUiAnsweredFinish:
       
  3845         case EVtUiAppUiAnsweredQueryStartViewfinder:
       
  3846         case EVtUiAppUiAnsweredQuerySelectNone:
       
  3847         case EVtUiAppUiAnsweredQueryFinish:
       
  3848             // Answered failed.
       
  3849             break;
       
  3850 
       
  3851         case EVtUiAppUiAnsweredCheckCamera:
       
  3852             aState = EVtUiAppUiAnsweredChoose;
       
  3853             break;
       
  3854 
       
  3855         case EVtUiAppUiAnsweredChoose:
       
  3856             aState = EVtUiAppUiAnsweredQuerySetupStill;
       
  3857             break;
       
  3858 
       
  3859         case EVtUiAppUiAnsweredQuerySetupStill:
       
  3860             aState = EVtUiAppUiAnsweredQuerySetupNone;
       
  3861             break;
       
  3862 
       
  3863         case EVtUiAppUiAnsweredQuerySetupStart:
       
  3864         case EVtUiAppUiAnsweredQuerySetupNone:
       
  3865             aState = EVtUiAppUiAnsweredQueryShow;
       
  3866             break;
       
  3867 
       
  3868         case EVtUiAppUiAnsweredQueryShow:
       
  3869         case EVtUiAppUiAnsweredQueryDecide:
       
  3870         case EVtUiAppUiAnsweredSelectCamera:
       
  3871             aState = EVtUiAppUiAnsweredSelectStill;
       
  3872             break;
       
  3873 
       
  3874         case EVtUiAppUiAnsweredQuerySelectCamera:
       
  3875             aState = EVtUiAppUiAnsweredQuerySelectStill;
       
  3876             break;
       
  3877 
       
  3878         case EVtUiAppUiAnsweredQuerySelectStill:
       
  3879             aState = EVtUiAppUiAnsweredQuerySelectNone;
       
  3880             break;
       
  3881 
       
  3882         case EVtUiAppUiAnsweredSelectStill:
       
  3883             aState = EVtUiAppUiAnsweredSelectNone;
       
  3884             break;
       
  3885 
       
  3886         default:
       
  3887             break;
       
  3888         }
       
  3889 
       
  3890     const TBool cont = ( aState != state );
       
  3891     __VTPRINT2( DEBUG_GEN, "VtUi.InitExecCont.cont=%d", cont )
       
  3892 
       
  3893     if ( !cont )
       
  3894         {
       
  3895         delete iExecBlankDialog;
       
  3896         iExecBlankDialog = NULL;
       
  3897         // Operation failed.
       
  3898         if ( iState )
       
  3899             {
       
  3900             TRAP_IGNORE( iState->AppUiStartupFailedL() );
       
  3901             }
       
  3902         }
       
  3903     __VTPRINTEXITR( "VtUi.InitExecCont %d", cont )
       
  3904     return cont;
       
  3905     }
       
  3906 
       
  3907 // -----------------------------------------------------------------------------
       
  3908 // CVtUiAppUi::ActiveExecInitCancel
       
  3909 // -----------------------------------------------------------------------------
       
  3910 //
       
  3911 void CVtUiAppUi::ActiveExecInitCancel(
       
  3912         const TInt /*aState*/ )
       
  3913     {
       
  3914     __VTPRINTENTER( "VtUi.InitExecCancel" )
       
  3915 
       
  3916     iBlankControl->SetActive( EFalse );
       
  3917     delete iExecDialog;
       
  3918     delete iExecBlankDialog;
       
  3919 
       
  3920     if ( iShutdownRequest )
       
  3921         {
       
  3922         User::RequestComplete( iShutdownRequest, KErrCancel );
       
  3923         iShutdownRequest = NULL;
       
  3924         }
       
  3925     __VTPRINTEXIT( "VtUi.InitExecCancel" )
       
  3926     }
       
  3927 
       
  3928 // -----------------------------------------------------------------------------
       
  3929 // CVtUiAppUi::ActiveExecInitDone
       
  3930 // -----------------------------------------------------------------------------
       
  3931 //
       
  3932 void CVtUiAppUi::ActiveExecInitDone(
       
  3933         const TInt aInitialState )
       
  3934     {
       
  3935     __VTPRINTENTER( "VtUi.ExecInitDone" )
       
  3936     __VTPRINT2( DEBUG_GEN, "VtUi.InitExecDone.ini=%d", aInitialState )
       
  3937     delete iExecBlankDialog;
       
  3938     iExecBlankDialog = NULL;
       
  3939     // Operation succeeded
       
  3940 
       
  3941     // Now we have finished.
       
  3942     if ( iState )
       
  3943         {
       
  3944         if ( aInitialState == EVtUiAppUiAnswered )
       
  3945             {
       
  3946             TRAP_IGNORE( iState->AppUiStartupPhase2DoneL() );
       
  3947             TRAP_IGNORE( AppUiInitDoneDoPostInitL() );
       
  3948             }
       
  3949         else if ( aInitialState == EVtUiAppUiShutdown )
       
  3950             {
       
  3951             TRAP_IGNORE( iState->ShutdownDoneL() );
       
  3952             }
       
  3953         else // EVtUiAppUiStartup
       
  3954             {
       
  3955             TRAP_IGNORE( iState->AppUiStartupPhase1DoneL() );
       
  3956             }
       
  3957         }
       
  3958     __VTPRINTEXIT( "VtUi.ExecInitDone" )
       
  3959     }
       
  3960 
       
  3961 // -----------------------------------------------------------------------------
       
  3962 // CVtUiAppUi::ActiveExecInitExecuteCommandL
       
  3963 // -----------------------------------------------------------------------------
       
  3964 //
       
  3965 void CVtUiAppUi::ActiveExecInitExecuteCommandL(
       
  3966         const TVtEngCommandId aCommand,
       
  3967         TRequestStatus& aRequest )
       
  3968     {
       
  3969     iExecDialog =
       
  3970         ExecuteCmdAsyncL(
       
  3971         &iExecDialog,
       
  3972         aCommand,
       
  3973         aRequest );
       
  3974     }
       
  3975 
       
  3976 // -----------------------------------------------------------------------------
       
  3977 // CVtUiAppUi::ActiveExecInitExecuteCommandL
       
  3978 // -----------------------------------------------------------------------------
       
  3979 //
       
  3980 template < class T >
       
  3981 void CVtUiAppUi::ActiveExecInitExecuteCommandL(
       
  3982         const TVtEngCommandId aCommand,
       
  3983         T& aParam,
       
  3984         TRequestStatus& aRequest )
       
  3985     {
       
  3986     iExecDialog =
       
  3987         ExecuteCmdAsyncL(
       
  3988         &iExecDialog,
       
  3989         aCommand,
       
  3990         aParam,
       
  3991         aRequest );
       
  3992     }
       
  3993 
       
  3994 // -----------------------------------------------------------------------------
       
  3995 // CVtUiAppUi::ActiveExecInitPrepareCameraL
       
  3996 // -----------------------------------------------------------------------------
       
  3997 //
       
  3998 void CVtUiAppUi::ActiveExecInitPrepareCameraL(
       
  3999         const MVtEngMedia::TMediaSource aSource,
       
  4000         TRequestStatus& aRequest )
       
  4001     {
       
  4002     MVtEngMedia::TPrepareCameraParams params;
       
  4003     params.iMediaSource = aSource;
       
  4004     params.iInitialize = ETrue;
       
  4005     iExecDialog =
       
  4006         ExecuteCmdAsyncL(
       
  4007             &iExecDialog,
       
  4008             KVtEngPrepareCamera,
       
  4009             params,
       
  4010             aRequest );
       
  4011     }
       
  4012 
       
  4013 // -----------------------------------------------------------------------------
       
  4014 // CVtUiAppUi::ActiveExecInitSetSourceL
       
  4015 // -----------------------------------------------------------------------------
       
  4016 //
       
  4017 void CVtUiAppUi::ActiveExecInitSetSourceL(
       
  4018         const MVtEngMedia::TMediaSource aSource,
       
  4019         TRequestStatus& aRequest )
       
  4020     {
       
  4021     MVtEngMedia::TMediaSource source =
       
  4022         aSource;
       
  4023     iExecDialog =
       
  4024         ExecuteCmdAsyncL(
       
  4025             &iExecDialog,
       
  4026             KVtEngSetSource,
       
  4027             source,
       
  4028             aRequest );
       
  4029     }
       
  4030 
       
  4031 // -----------------------------------------------------------------------------
       
  4032 // CVtUiAppUi::ActiveExecInitPrepareViewFinderL
       
  4033 // -----------------------------------------------------------------------------
       
  4034 //
       
  4035 void CVtUiAppUi::ActiveExecInitPrepareViewFinderL(
       
  4036         TRequestStatus& aRequest )
       
  4037     {
       
  4038     // Configure view finder to context pane.
       
  4039     if ( iEventObserver->CommandSupported( KVtEngPrepareViewFinder ) )
       
  4040         {
       
  4041         TVtEngRenderingOptions configViewfinder(
       
  4042             DetermineContextControlOptions() );
       
  4043 
       
  4044         iExecDialog =
       
  4045             ExecuteCmdAsyncL(
       
  4046                 &iExecDialog,
       
  4047                 KVtEngPrepareViewFinder,
       
  4048                 configViewfinder,
       
  4049                 aRequest );
       
  4050         }
       
  4051     else
       
  4052         {
       
  4053         // Viewfinder does not support DSA - panic.
       
  4054         VtUiPanic::Panic( EVtUiPanicPrepareViewFinderNotSupported );
       
  4055         }
       
  4056     }
       
  4057 
       
  4058 // -----------------------------------------------------------------------------
       
  4059 // CVtUiAppUi::ActiveExecInitPrepareRemoteRenderL
       
  4060 // -----------------------------------------------------------------------------
       
  4061 //
       
  4062 void CVtUiAppUi::ActiveExecInitPrepareRemoteRenderL(
       
  4063         TRequestStatus& aRequest )
       
  4064     {
       
  4065     if ( iEventObserver->CommandSupported( KVtEngPrepareRemoteRenderNGA ) )
       
  4066         {
       
  4067         // Cropping is performed when we draw the picture.
       
  4068         TVtEngRenderingOptionsNGA configRemoteRenderNGA(
       
  4069                 DetermineRemoteVideoControlOptionsNGA() );
       
  4070 
       
  4071         iExecDialog =
       
  4072             ExecuteCmdAsyncL(
       
  4073                 &iExecDialog,
       
  4074                 KVtEngPrepareRemoteRenderNGA,
       
  4075                 configRemoteRenderNGA,
       
  4076                 aRequest );
       
  4077         }
       
  4078     else
       
  4079         {
       
  4080         // Neither supported - panic.
       
  4081         VtUiPanic::Panic( EVtUiPanicPrepareRemoteRenderNotSupported );
       
  4082         }
       
  4083     }
       
  4084 
       
  4085 // -----------------------------------------------------------------------------
       
  4086 // CVtUiAppUi::ActiveExecCmdExecuteCommandL
       
  4087 // -----------------------------------------------------------------------------
       
  4088 //
       
  4089 void CVtUiAppUi::ActiveExecCmdExecuteCommandL(
       
  4090         const TVtEngCommandId aCommand,
       
  4091         TRequestStatus& aRequest )
       
  4092     {
       
  4093     iCmdExecDialog =
       
  4094         ExecuteCmdAsyncL(
       
  4095             &iCmdExecDialog,
       
  4096             aCommand,
       
  4097             aRequest );
       
  4098     }
       
  4099 
       
  4100 // -----------------------------------------------------------------------------
       
  4101 // CVtUiAppUi::ActiveExecCmdSetSourceL
       
  4102 // -----------------------------------------------------------------------------
       
  4103 //
       
  4104 void CVtUiAppUi::ActiveExecCmdSetSourceL(
       
  4105         const MVtEngMedia::TMediaSource aSource,
       
  4106         TRequestStatus& aRequest )
       
  4107     {
       
  4108     MVtEngMedia::TMediaSource source = aSource;
       
  4109     iCmdExecDialog =
       
  4110         ExecuteCmdAsyncL(
       
  4111             &iCmdExecDialog,
       
  4112             KVtEngSetSource,
       
  4113             source,
       
  4114             aRequest );
       
  4115     }
       
  4116 
       
  4117 // -----------------------------------------------------------------------------
       
  4118 // CVtUiAppUi::ActiveExecCmdPrepareCameraL
       
  4119 // -----------------------------------------------------------------------------
       
  4120 //
       
  4121 void CVtUiAppUi::ActiveExecCmdPrepareCameraL(
       
  4122         const MVtEngMedia::TMediaSource aSource,
       
  4123         TRequestStatus& aRequest )
       
  4124     {
       
  4125     MVtEngMedia::TPrepareCameraParams params;
       
  4126     params.iMediaSource = aSource;
       
  4127     params.iInitialize = ETrue;
       
  4128     iCmdExecDialog =
       
  4129         ExecuteCmdAsyncL(
       
  4130             &iCmdExecDialog,
       
  4131             KVtEngPrepareCamera,
       
  4132             params,
       
  4133             aRequest );
       
  4134     }
       
  4135 
       
  4136 // -----------------------------------------------------------------------------
       
  4137 // CVtUiAppUi::DetermineMainControlOptions
       
  4138 // -----------------------------------------------------------------------------
       
  4139 //
       
  4140 TVtEngRenderingOptions
       
  4141     CVtUiAppUi::DetermineMainControlOptions( TBool aRemoteVideo )
       
  4142     {
       
  4143     // Determine main pane options.
       
  4144     TRect screen;
       
  4145     TAknWindowLineLayout stream;
       
  4146     TAknLayoutRect rect;
       
  4147 
       
  4148     screen = iInstance->iMainControl->Rect();
       
  4149     VtUiLayout::GetSecondWindowStreamWholeLayout(
       
  4150         stream, aRemoteVideo && iUiStates->IsUseSQCif() );
       
  4151 
       
  4152     rect.LayoutRect( screen, stream );
       
  4153     screen = rect.Rect();
       
  4154 
       
  4155     return TVtEngRenderingOptions( *iEventObserver, screen.Size() );
       
  4156     }
       
  4157 
       
  4158 // -----------------------------------------------------------------------------
       
  4159 // CVtUiAppUi::DetermineContextControlOptions
       
  4160 // -----------------------------------------------------------------------------
       
  4161 //
       
  4162 TVtEngRenderingOptions CVtUiAppUi::DetermineContextControlOptions()
       
  4163     {
       
  4164     // Determine context pane options.
       
  4165     TRect screen;
       
  4166     TRect clip;
       
  4167     TAknWindowLineLayout stream;
       
  4168     TAknLayoutRect rect;
       
  4169 
       
  4170     VtUiLayout::GetApplicationParentRect( screen );
       
  4171     VtUiLayout::GetFirstWindowBackgroundLayout( stream );
       
  4172     rect.LayoutRect( screen, stream );
       
  4173     TRect background = rect.Rect();
       
  4174 
       
  4175     VtUiLayout::GetFirstWindowStreamLayout( stream );
       
  4176     rect.LayoutRect( screen, stream );
       
  4177 
       
  4178     // No cropping is performed, thus clip == screen.
       
  4179     clip = rect.Rect();
       
  4180     clip.iTl -= background.iTl;
       
  4181     clip.iBr -= background.iTl;
       
  4182 
       
  4183     screen = clip;
       
  4184 
       
  4185     return
       
  4186         TVtEngRenderingOptions(
       
  4187             *iEventObserver,
       
  4188             screen.Size() );
       
  4189     }
       
  4190 
       
  4191 // -----------------------------------------------------------------------------
       
  4192 // CVtUiAppUi::DetermineDialerControlOptions
       
  4193 // -----------------------------------------------------------------------------
       
  4194 //
       
  4195 TVtEngRenderingOptions CVtUiAppUi::DetermineDialerControlOptions()
       
  4196     {
       
  4197     MVtUiDialer* dialer =  static_cast< CVtUiDialer* > (
       
  4198         iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer ) );
       
  4199 
       
  4200     __ASSERT_ALWAYS( dialer, VtUiPanic::Panic( EVtUiPanicRendererNotFound ) );
       
  4201 
       
  4202     return
       
  4203         TVtEngRenderingOptions(
       
  4204             *iEventObserver,
       
  4205             dialer->VideoControl().Size() );
       
  4206     }
       
  4207 
       
  4208 // -----------------------------------------------------------------------------
       
  4209 // CVtUiAppUi::DetermineMainControlOptions
       
  4210 // -----------------------------------------------------------------------------
       
  4211 //
       
  4212 TVtEngRenderingOptionsDSA
       
  4213     CVtUiAppUi::DetermineMainControlOptionsDSA( TBool aRemoteVideo )
       
  4214     {
       
  4215     // Determine main pane options.
       
  4216     TRect screen;
       
  4217     TRect clip;
       
  4218     TAknWindowLineLayout stream;
       
  4219     TAknLayoutRect rect;
       
  4220     const TBool usesSQCif( aRemoteVideo && iUiStates->IsUseSQCif() );
       
  4221     screen = iInstance->iMainControl->Rect();
       
  4222     VtUiLayout::GetSecondWindowStreamLayout( stream,
       
  4223         iUiStates->IsToolbarAvailable(), usesSQCif );
       
  4224     rect.LayoutRect( screen, stream );
       
  4225     clip = rect.Rect();
       
  4226 
       
  4227     VtUiLayout::GetSecondWindowStreamWholeLayout( stream,
       
  4228         iUiStates->IsToolbarAvailable(), usesSQCif );
       
  4229     rect.LayoutRect( screen, stream );
       
  4230     screen = rect.Rect();
       
  4231 
       
  4232     return
       
  4233         TVtEngRenderingOptionsDSA(
       
  4234             *iEventObserver,
       
  4235             iEikonEnv->WsSession(),
       
  4236             *( iEikonEnv->ScreenDevice() ),
       
  4237             *( iInstance->iMainControl->DrawableWindow() ),
       
  4238             clip,
       
  4239             screen );
       
  4240     }
       
  4241 
       
  4242 // -----------------------------------------------------------------------------
       
  4243 // CVtUiAppUi::DetermineContextControlOptionsDSA
       
  4244 // -----------------------------------------------------------------------------
       
  4245 //
       
  4246 TVtEngRenderingOptionsDSA CVtUiAppUi::DetermineContextControlOptionsDSA()
       
  4247     {
       
  4248     // Determine context pane options.
       
  4249     TRect screen;
       
  4250     TRect clip;
       
  4251     TAknWindowLineLayout stream;
       
  4252     TAknLayoutRect rect;
       
  4253 
       
  4254     VtUiLayout::GetApplicationParentRect( screen );
       
  4255     VtUiLayout::GetFirstWindowBackgroundLayout( stream );
       
  4256     rect.LayoutRect( screen, stream );
       
  4257     TRect background = rect.Rect();
       
  4258 
       
  4259     VtUiLayout::GetFirstWindowStreamLayout( stream );
       
  4260     rect.LayoutRect( screen, stream );
       
  4261 
       
  4262     // No cropping is performed, thus clip == screen.
       
  4263     clip = rect.Rect();
       
  4264     clip.iTl -= background.iTl;
       
  4265     clip.iBr -= background.iTl;
       
  4266 
       
  4267     screen = clip;
       
  4268 
       
  4269     return
       
  4270         TVtEngRenderingOptionsDSA(
       
  4271             *iEventObserver,
       
  4272             iEikonEnv->WsSession(),
       
  4273             *( iEikonEnv->ScreenDevice() ),
       
  4274             *( iInstance->iContextControl->DrawableWindow() ),
       
  4275             screen,
       
  4276             clip );
       
  4277     }
       
  4278 
       
  4279 // -----------------------------------------------------------------------------
       
  4280 // CVtUiAppUi::DetermineDialerControlOptionsDSA
       
  4281 // -----------------------------------------------------------------------------
       
  4282 //
       
  4283 TVtEngRenderingOptionsDSA CVtUiAppUi::DetermineDialerControlOptionsDSA()
       
  4284     {
       
  4285     MVtUiDialer* dialer =  static_cast< CVtUiDialer* > (
       
  4286         iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer ) );
       
  4287 
       
  4288     __ASSERT_ALWAYS( dialer, VtUiPanic::Panic( EVtUiPanicRendererNotFound ) );
       
  4289 
       
  4290     CCoeControl& videoWindow( dialer->VideoControl() );
       
  4291 
       
  4292     return
       
  4293         TVtEngRenderingOptionsDSA(
       
  4294             *iEventObserver,
       
  4295             iEikonEnv->WsSession(),
       
  4296             *( iEikonEnv->ScreenDevice() ),
       
  4297             *( videoWindow.DrawableWindow() ),
       
  4298             videoWindow.Rect(),
       
  4299             videoWindow.Rect() );
       
  4300     }
       
  4301 
       
  4302 // -----------------------------------------------------------------------------
       
  4303 // CVtUiAppUi::DetermineMainControlOptionsDP
       
  4304 // -----------------------------------------------------------------------------
       
  4305 //
       
  4306 TVtEngRenderingOptionsDP
       
  4307     CVtUiAppUi::DetermineMainControlOptionsDP( TBool aRemoteVideo )
       
  4308     {
       
  4309     // Determine main pane options.
       
  4310     const TRect screen( iInstance->iMainControl->Rect() );
       
  4311     TAknWindowLineLayout stream;
       
  4312     const TBool usesSQCif( aRemoteVideo && iUiStates->IsUseSQCif() );
       
  4313 
       
  4314     // Even if the name is whole layout, this layout is (due to problem
       
  4315     // in layouts) video stream layout
       
  4316     TAknLayoutRect whole;
       
  4317     VtUiLayout::GetSecondWindowStreamWholeLayout( stream,
       
  4318         iUiStates->IsToolbarAvailable(), usesSQCif );
       
  4319     whole.LayoutRect( screen, stream );
       
  4320 
       
  4321     // Even if the name is actual layout, this layout is (due to problem
       
  4322     // in layouts) whole == clipping layout
       
  4323     TAknLayoutRect actual;
       
  4324     VtUiLayout::GetSecondWindowStreamLayout( stream,
       
  4325         iUiStates->IsToolbarAvailable(), usesSQCif );
       
  4326     actual.LayoutRect( screen, stream );
       
  4327 
       
  4328     return
       
  4329         TVtEngRenderingOptionsDP(
       
  4330             *iEventObserver,
       
  4331             iEikonEnv->WsSession(),
       
  4332             *( iEikonEnv->ScreenDevice() ),
       
  4333             *( iInstance->iMainControl->DrawableWindow() ),
       
  4334             actual.Rect(),
       
  4335             whole.Rect(),
       
  4336             iInstance->iMainControl->PositionRelativeToScreen() );
       
  4337     }
       
  4338 
       
  4339 // -----------------------------------------------------------------------------
       
  4340 // CVtUiAppUi::DetermineContextControlOptionsDP
       
  4341 // -----------------------------------------------------------------------------
       
  4342 //
       
  4343 TVtEngRenderingOptionsDP CVtUiAppUi::DetermineContextControlOptionsDP()
       
  4344     {
       
  4345     // Determine context pane options.
       
  4346     TAknWindowLineLayout stream;
       
  4347     TAknLayoutRect rect;
       
  4348 
       
  4349     TRect screen;
       
  4350     VtUiLayout::GetApplicationParentRect( screen );
       
  4351     VtUiLayout::GetFirstWindowBackgroundLayout( stream );
       
  4352     rect.LayoutRect( screen, stream );
       
  4353     const TRect background( rect.Rect() );
       
  4354 
       
  4355     VtUiLayout::GetFirstWindowStreamLayout( stream );
       
  4356     rect.LayoutRect( screen, stream );
       
  4357 
       
  4358     // No cropping is performed, thus clip == screen.
       
  4359     TRect clip( rect.Rect() );
       
  4360     clip.iTl -= background.iTl;
       
  4361     clip.iBr -= background.iTl;
       
  4362 
       
  4363     return
       
  4364         TVtEngRenderingOptionsDP(
       
  4365             *iEventObserver,
       
  4366             iEikonEnv->WsSession(),
       
  4367             *( iEikonEnv->ScreenDevice() ),
       
  4368             *( iInstance->iContextControl->DrawableWindow() ),
       
  4369             clip,
       
  4370             clip,
       
  4371             iInstance->iContextControl->PositionRelativeToScreen() );
       
  4372     }
       
  4373 
       
  4374 // -----------------------------------------------------------------------------
       
  4375 // CVtUiAppUi::DetermineDialerControlOptionsDP
       
  4376 // -----------------------------------------------------------------------------
       
  4377 //
       
  4378 TVtEngRenderingOptionsDP CVtUiAppUi::DetermineDialerControlOptionsDP()
       
  4379     {
       
  4380     MVtUiDialer* dialer =  static_cast< CVtUiDialer* > (
       
  4381         iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer ) );
       
  4382 
       
  4383     __ASSERT_ALWAYS( dialer, VtUiPanic::Panic( EVtUiPanicRendererNotFound ) );
       
  4384 
       
  4385     CCoeControl& videoWindow( dialer->VideoControl() );
       
  4386 
       
  4387     TPoint offs( videoWindow.DrawableWindow()->AbsPosition() );
       
  4388     TRect rect( videoWindow.Rect() );
       
  4389     return
       
  4390         TVtEngRenderingOptionsDP(
       
  4391             *iEventObserver,
       
  4392             iEikonEnv->WsSession(),
       
  4393             *( iEikonEnv->ScreenDevice() ),
       
  4394             *( videoWindow.DrawableWindow() ),
       
  4395             rect,
       
  4396             rect,
       
  4397             offs );
       
  4398     }
       
  4399 // -----------------------------------------------------------------------------
       
  4400 // CVtUiAppUi::DetermineRemoteVideoControlOptionsNGA
       
  4401 // -----------------------------------------------------------------------------
       
  4402 //
       
  4403 TVtEngRenderingOptionsNGA
       
  4404     CVtUiAppUi::DetermineRemoteVideoControlOptionsNGA()
       
  4405     {
       
  4406         return TVtEngRenderingOptionsNGA( *iEventObserver,
       
  4407                 iInstance->iRemoteVideoControl ->GetRWindow() , iEikonEnv->WsSession());
       
  4408     }
       
  4409 // -----------------------------------------------------------------------------
       
  4410 // CVtUiAppUi::ExecuteCmdL
       
  4411 // -----------------------------------------------------------------------------
       
  4412 //
       
  4413 void CVtUiAppUi::ExecuteCmdL( const TVtEngCommandId aCommand )
       
  4414     {
       
  4415     DoExecuteCmdL( aCommand, NULL );
       
  4416     }
       
  4417 
       
  4418 // -----------------------------------------------------------------------------
       
  4419 // CVtUiAppUi::ExecuteCmdL
       
  4420 // -----------------------------------------------------------------------------
       
  4421 //
       
  4422 template< class T >
       
  4423 void CVtUiAppUi::ExecuteCmdL(
       
  4424         const TVtEngCommandId aCommand,
       
  4425         T& aParam )
       
  4426     {
       
  4427     TPtrC8 params( reinterpret_cast< TUint8* >( &aParam ), sizeof( T ) );
       
  4428     DoExecuteCmdL( aCommand, &params );
       
  4429     }
       
  4430 
       
  4431 // -----------------------------------------------------------------------------
       
  4432 // CVtUiAppUi::DoExecuteCmdL
       
  4433 // -----------------------------------------------------------------------------
       
  4434 //
       
  4435 void CVtUiAppUi::DoExecuteCmdL(
       
  4436         const TVtEngCommandId aCommand,
       
  4437         TDesC8* aParams )
       
  4438     {
       
  4439     __VTPRINT2( DEBUG_GEN, "VtUi.DoExec.cmd=%d", aCommand )
       
  4440     MVtEngCommandHandler& command = Model().CommandHandler();
       
  4441     const TInt caps = command.GetCommandCaps( aCommand );
       
  4442 
       
  4443     if ( caps >= KErrNone )
       
  4444         {
       
  4445         const TBool asynchronous =
       
  4446             ( caps & MVtEngCommandHandler::EAttribAsync );
       
  4447 
       
  4448         if ( asynchronous  )
       
  4449             {
       
  4450             if ( aCommand == KVtEngHandleLayoutChange )
       
  4451                 {
       
  4452                 CVtEngCmdExec* cmdExec = CVtEngCmdExec::NewL(
       
  4453                     Model().CommandHandler(), *iEventObserver, *GetCba() );
       
  4454                 cmdExec->ExecuteCmdLD( aCommand );
       
  4455                 }
       
  4456             else
       
  4457                 {
       
  4458                 CVtUiExecuteCmdDialog* dlg =
       
  4459                     new ( ELeave ) CVtUiExecuteCmdDialog(
       
  4460                         NULL,
       
  4461                         Model().CommandHandler(),
       
  4462                         *iEventObserver );
       
  4463                 dlg->ExecuteCmdLD( aCommand, aParams, NULL );
       
  4464                 }
       
  4465             }
       
  4466         else
       
  4467             {
       
  4468             command.ExecuteL( aCommand, aParams );
       
  4469             RefreshStatesL();
       
  4470             }
       
  4471         }
       
  4472     else
       
  4473         {
       
  4474         // Failed.
       
  4475         User::Leave( caps );
       
  4476         }
       
  4477     }
       
  4478 
       
  4479 // -----------------------------------------------------------------------------
       
  4480 // CVtUiAppUi::HandleShutdownReady
       
  4481 // -----------------------------------------------------------------------------
       
  4482 //
       
  4483 void CVtUiAppUi::HandleShutdownReady()
       
  4484     {
       
  4485     __VTPRINTENTER( "VtUi.HandleShutdownReady" )
       
  4486 
       
  4487     if(iAsyncCallback->IsActive())
       
  4488 	    {
       
  4489 		iAsyncCallback->Cancel();
       
  4490 	    }
       
  4491 
       
  4492     iAsyncCallback->Set(
       
  4493         TCallBack( &DoExit, this ) );
       
  4494     iAsyncCallback->CallBack();
       
  4495     __VTPRINTEXIT( "VtUi.HandleShutdownReady" )
       
  4496     }
       
  4497 
       
  4498 // -----------------------------------------------------------------------------
       
  4499 // CVtUiAppUi::ContextControl
       
  4500 // -----------------------------------------------------------------------------
       
  4501 //
       
  4502 CVtUiContextControl& CVtUiAppUi::ContextControl()
       
  4503    {
       
  4504     __VTPRINTENTER( "VtUi.ContextControl" )
       
  4505    __VTPRINTEXIT( "VtUi.ContextControl" )
       
  4506    return *iInstance->iContextControl;
       
  4507    }
       
  4508 
       
  4509 // -----------------------------------------------------------------------------
       
  4510 // CVtUiAppUi::MainControl
       
  4511 // -----------------------------------------------------------------------------
       
  4512 //
       
  4513 CVtUiMainControl& CVtUiAppUi::MainControl()
       
  4514    {
       
  4515    __VTPRINTENTER( "VtUi.MainControl" )
       
  4516    __VTPRINTEXIT( "VtUi.MainControl" )
       
  4517    return *iInstance->iMainControl;
       
  4518    }
       
  4519 
       
  4520 // -----------------------------------------------------------------------------
       
  4521 // CVtUiAppUi::RemoteVideoControl
       
  4522 // -----------------------------------------------------------------------------
       
  4523 //
       
  4524 CVtUiRemoteVideoControl& CVtUiAppUi::RemoteVideoControl()
       
  4525    {
       
  4526    __VTPRINTENTER( "VtUi.RemoteVideoControl" )
       
  4527    __VTPRINTEXIT( "VtUi.RemoteVideoControl" )
       
  4528    return *iInstance->iRemoteVideoControl;
       
  4529    }
       
  4530 
       
  4531 // -----------------------------------------------------------------------------
       
  4532 // CVtUiAppUi::DoExit
       
  4533 // -----------------------------------------------------------------------------
       
  4534 //
       
  4535 TInt CVtUiAppUi::DoExit( TAny* aAppUi )
       
  4536     {
       
  4537     __VTPRINTENTER( "VtUi.DoExit" )
       
  4538     CVtUiAppUi* self = static_cast< CVtUiAppUi* >( aAppUi );
       
  4539     self->iAsyncCallback->Cancel();
       
  4540     // Before exiting ensure there are no pending actions.
       
  4541     self->ActiveExecInitCancel( 0 );
       
  4542     self->Exit();
       
  4543     __VTPRINTEXIT( "VtUi.DoExit" )
       
  4544     return KErrNone;
       
  4545     }
       
  4546 
       
  4547 // -----------------------------------------------------------------------------
       
  4548 // CVtUiAppUi::ExecuteCmdAsyncL
       
  4549 // -----------------------------------------------------------------------------
       
  4550 //
       
  4551 CEikDialog* CVtUiAppUi::ExecuteCmdAsyncL(
       
  4552         CEikDialog** aDialogPtr,
       
  4553         const TVtEngCommandId aCommand,
       
  4554         TRequestStatus& aStatus )
       
  4555     {
       
  4556     return DoExecuteCmdAsyncL( aDialogPtr, aCommand, NULL, aStatus );
       
  4557     }
       
  4558 
       
  4559 // -----------------------------------------------------------------------------
       
  4560 // CVtUiAppUi::ExecuteCmdAsyncL
       
  4561 // -----------------------------------------------------------------------------
       
  4562 //
       
  4563 template< class T >
       
  4564 CEikDialog* CVtUiAppUi::ExecuteCmdAsyncL(
       
  4565         CEikDialog** aDialogPtr,
       
  4566         const TVtEngCommandId aCommand,
       
  4567         T& aParam,
       
  4568         TRequestStatus& aStatus )
       
  4569     {
       
  4570     TPtrC8 params( reinterpret_cast< TUint8* >( &aParam ), sizeof( T ) );
       
  4571     return DoExecuteCmdAsyncL( aDialogPtr, aCommand, &params, aStatus );
       
  4572     }
       
  4573 
       
  4574 // -----------------------------------------------------------------------------
       
  4575 // CVtUiAppUi::DoExecuteCmdAsyncL
       
  4576 // -----------------------------------------------------------------------------
       
  4577 //
       
  4578 CEikDialog* CVtUiAppUi::DoExecuteCmdAsyncL(
       
  4579         CEikDialog** aDialogPtr,
       
  4580         const TVtEngCommandId aCommand,
       
  4581         TDesC8* aParams,
       
  4582         TRequestStatus& aStatus )
       
  4583     {
       
  4584     __VTPRINT2( DEBUG_GEN, "VtUi.DoExecAsync.cmd=%d", aCommand )
       
  4585     MVtEngCommandHandler& command = Model().CommandHandler();
       
  4586     const TInt caps = command.GetCommandCaps( aCommand );
       
  4587 
       
  4588     if ( caps >= KErrNone )
       
  4589         {
       
  4590         const TBool asynchronous =
       
  4591             ( caps & MVtEngCommandHandler::EAttribAsync );
       
  4592 
       
  4593         if ( asynchronous  )
       
  4594             {
       
  4595             CVtUiExecuteCmdDialog* dlg =
       
  4596                 new ( ELeave ) CVtUiExecuteCmdDialog(
       
  4597                     aDialogPtr,
       
  4598                     Model().CommandHandler(),
       
  4599                     *iEventObserver );
       
  4600             dlg->ExecuteCmdLD( aCommand, aParams, &aStatus );
       
  4601             return dlg;
       
  4602             }
       
  4603         else
       
  4604             {
       
  4605             command.ExecuteL( aCommand, aParams );
       
  4606             RefreshStatesL();
       
  4607             TRequestStatus* status = &aStatus;
       
  4608             User::RequestComplete( status, KErrNone );
       
  4609             }
       
  4610         }
       
  4611     else
       
  4612         {
       
  4613         // Failed.
       
  4614         User::Leave( caps );
       
  4615         }
       
  4616 
       
  4617     return NULL;
       
  4618     }
       
  4619 
       
  4620 // -----------------------------------------------------------------------------
       
  4621 // CVtUiAppUi::Execute
       
  4622 // -----------------------------------------------------------------------------
       
  4623 //
       
  4624 TInt CVtUiAppUi::Execute( const TVtEngCommandId aCommand, TDesC8* aParam )
       
  4625     {
       
  4626     MVtEngCommandHandler& command = Model().CommandHandler();
       
  4627     TRAPD( err, command.ExecuteL( aCommand, aParam ) );
       
  4628 #ifdef VTDEBUG
       
  4629     if ( err != KErrNone )
       
  4630         {
       
  4631         __VTPRINT3( DEBUG_GEN, "VtUi.Execute.Nok.cmd=%d,err=%d", aCommand, err )
       
  4632         }
       
  4633 #endif // VTDEBUG
       
  4634     return err;
       
  4635     }
       
  4636 
       
  4637 // -----------------------------------------------------------------------------
       
  4638 // CVtUiAppUi::HandleForegroundChangedL
       
  4639 // -----------------------------------------------------------------------------
       
  4640 //
       
  4641 void CVtUiAppUi::HandleForegroundChangedL(
       
  4642         TBool aIsForeground )
       
  4643     {
       
  4644     __VTPRINTENTER( "VtUi.HandleForegroundChangedL" )
       
  4645     __VTPRINT2( DEBUG_GEN, "VtUi.foreground=%d", (TInt) aIsForeground )
       
  4646 
       
  4647 
       
  4648     // Let the Engine know that Application's foregorund
       
  4649     // has changed. Then Engine can do some initalize/uninitalize
       
  4650     // before rendering due to the foreground state.
       
  4651     iState->PreHandleForegroundChangedL(aIsForeground);
       
  4652 
       
  4653     // These operations must be done before
       
  4654     // sending KVtEngSetUIForeground command to engine i.e. calling
       
  4655     // iState->HandleForegroundChangedL( aIsForeground )
       
  4656     if ( !aIsForeground  )
       
  4657         {
       
  4658         // if capture mode is on stop it
       
  4659         if ( iUiStates->IsCaptureModeOn() )
       
  4660             {
       
  4661             CmdCancelCaptureL();
       
  4662             }
       
  4663         // if brightness or contrast feature is active stop those
       
  4664         MVtUiFeature* br = iFeatureManager->GetFeatureById( EVtUiFeatureIdBrightness );
       
  4665         if ( br )
       
  4666             {
       
  4667             __VTPRINT( DEBUG_GEN, "VtUi.HandleForegroundChangedL br" )
       
  4668             if ( br->State() ==  MVtUiFeature::EActive )
       
  4669                 {
       
  4670                 __VTPRINT( DEBUG_GEN, "VtUi.HandleForegroundChangedL br->STOP" )
       
  4671                 br->Stop();
       
  4672                 }
       
  4673             }
       
  4674 
       
  4675         MVtUiFeature* cr = iFeatureManager->GetFeatureById( EVtUiFeatureIdContrast );
       
  4676         if ( cr )
       
  4677             {
       
  4678             __VTPRINT( DEBUG_GEN, "VtUi.HandleForegroundChangedL cr" )
       
  4679             if ( cr->State() ==  MVtUiFeature::EActive )
       
  4680                {
       
  4681                __VTPRINT( DEBUG_GEN, "VtUi.HandleForegroundChangedL cr->STOP" )
       
  4682                cr->Stop();
       
  4683                }
       
  4684             }
       
  4685 
       
  4686         }
       
  4687 
       
  4688     TBool foregroundAndReady = EFalse;
       
  4689     if ( iState )
       
  4690         {
       
  4691         foregroundAndReady = iState->HandleForegroundChangedL( aIsForeground );
       
  4692         iUiStates->SetThisApplicationForeground( aIsForeground );
       
  4693         }
       
  4694     if ( foregroundAndReady )
       
  4695         {
       
  4696         // Refresh navi pane. This will start call duration updating
       
  4697         // if necessary.
       
  4698         RefreshNaviPaneL();
       
  4699         }
       
  4700     else if ( !aIsForeground )
       
  4701         {
       
  4702 
       
  4703 
       
  4704         iEventObserver->StopBeat();
       
  4705         }
       
  4706     SetIncallBubbleAllowedInUsualL( !foregroundAndReady );
       
  4707     __VTPRINTEXIT( "VtUi.HandleForegroundChangedL" )
       
  4708     }
       
  4709 
       
  4710 // -----------------------------------------------------------------------------
       
  4711 // CVtUiAppUi::RefreshL
       
  4712 // -----------------------------------------------------------------------------
       
  4713 //
       
  4714 void CVtUiAppUi::RefreshL( const TInt aRefreshFlags )
       
  4715     {
       
  4716     if ( aRefreshFlags & EUiStates )
       
  4717         {
       
  4718         RefreshNaviPaneL();
       
  4719         }
       
  4720     if ( aRefreshFlags & EBlind )
       
  4721         {
       
  4722         RefreshBlind();
       
  4723         }
       
  4724     if ( aRefreshFlags & ENaviPane )
       
  4725         {
       
  4726         RefreshNaviPaneL();
       
  4727         }
       
  4728     if ( aRefreshFlags & ESoftkeys )
       
  4729         {
       
  4730         RefreshSoftkeysL();
       
  4731         }
       
  4732     }
       
  4733 
       
  4734 // -----------------------------------------------------------------------------
       
  4735 // CVtUiAppUi::HandleEngineResetL
       
  4736 // -----------------------------------------------------------------------------
       
  4737 //
       
  4738 void CVtUiAppUi::HandleEngineResetL()
       
  4739     {
       
  4740     __VTPRINTENTER( "VtUi.HandleEngineResetL" )
       
  4741     if ( iShutdownRequest )
       
  4742         {
       
  4743         __VTPRINT( DEBUG_GEN, "  VtUi.HandleEngineResetL shutdown" )
       
  4744         User::RequestComplete( iShutdownRequest, KErrNone );
       
  4745         iShutdownRequest = NULL;
       
  4746         }
       
  4747     __VTPRINTEXIT( "VtUi.HandleEngineResetL" )
       
  4748     }
       
  4749 
       
  4750 // -----------------------------------------------------------------------------
       
  4751 // CVtUiAppUi::StopWaitingImage
       
  4752 // -----------------------------------------------------------------------------
       
  4753 //
       
  4754 void CVtUiAppUi::StopWaitingImage()
       
  4755     {
       
  4756     if ( iInstance )
       
  4757         {
       
  4758         iDownlinkWindow->SetWaiting( EFalse );
       
  4759         iUiStates->SetWaitingForFirstFrame( EFalse );
       
  4760         RemoteVideoControl().MakeVisible(ETrue);
       
  4761         }
       
  4762     }
       
  4763 
       
  4764 void CVtUiAppUi::StopWhiteBalanceOrColortone()
       
  4765     {
       
  4766     if( iEventObserver )
       
  4767         {
       
  4768         MVtEngMedia::TCameraId currentCamId;
       
  4769         //CVtEngMediaHandler& mediaHandler = iEventObserver->Model().Media();
       
  4770         ///mediaHandler.GetCurrentCameraId( currentCamId );
       
  4771         iEventObserver->Model().Media().GetCurrentCameraId( currentCamId );
       
  4772         __VTPRINT2( DEBUG_GEN, "  CVtUiAppUi::StopWhiteBalance currentCamId is %d", currentCamId);
       
  4773         
       
  4774         CVtUiWhiteBalance* wb = static_cast< CVtUiWhiteBalance* >(
       
  4775                                 iFeatureManager->GetFeatureById( EVtUiFeatureIdWhiteBalance ) );
       
  4776         CVtUiColorTone* ct = static_cast< CVtUiColorTone* >(
       
  4777         iFeatureManager->GetFeatureById( EVtUiFeatureIdColourTone ) );
       
  4778         
       
  4779         // only when the current camera switch to the Primary to stop the wb
       
  4780         if( currentCamId == MVtEngMedia::EPrimaryCamera )
       
  4781             {
       
  4782             
       
  4783             if( wb && ( wb->State() == MVtUiFeature::EActive ) )
       
  4784                 {
       
  4785                 	
       
  4786                 wb->Stop();
       
  4787                 }
       
  4788             
       
  4789             if( ct && ( ct->State() == MVtUiFeature::EActive ) )
       
  4790                 {                    
       
  4791                 ct->Stop();
       
  4792                 }
       
  4793             
       
  4794             return;
       
  4795             }
       
  4796         if( currentCamId == MVtEngMedia::ESecondaryCamera )
       
  4797             {
       
  4798             if( wb->IsPendingCmd() )
       
  4799                 wb->HandlePendingCmdL();
       
  4800             if( ct->IsPendingCmd() )
       
  4801                 ct->HandlePendingCmdL();
       
  4802             }
       
  4803         }
       
  4804     }
       
  4805 // -----------------------------------------------------------------------------
       
  4806 // CVtUiAppUi::HandleLayoutChanged
       
  4807 // -----------------------------------------------------------------------------
       
  4808 //
       
  4809 TInt CVtUiAppUi::HandleLayoutChanged()
       
  4810     {
       
  4811     iLayoutChangeCallback->CallBack();
       
  4812     return KErrNone;
       
  4813     }
       
  4814 
       
  4815 // -----------------------------------------------------------------------------
       
  4816 // CVtUiAppUi::DelayedHandleLayoutChanged
       
  4817 // -----------------------------------------------------------------------------
       
  4818 //
       
  4819 TInt CVtUiAppUi::DelayedHandleLayoutChanged( TAny* aPtr )
       
  4820     {
       
  4821     CVtUiAppUi* self = reinterpret_cast< CVtUiAppUi* > ( aPtr );
       
  4822     self->iUiStates->SetDisableBlindSetting( ETrue );
       
  4823     TRAPD( err, self->HandleLayoutChangedL() );
       
  4824     self->iUiStates->SetDisableBlindSetting( EFalse );
       
  4825     self->RefreshBlind();
       
  4826     return err;
       
  4827     }
       
  4828 
       
  4829 // -----------------------------------------------------------------------------
       
  4830 // CVtUiAppUi::HandleLayoutChangedL
       
  4831 // -----------------------------------------------------------------------------
       
  4832 //
       
  4833 void CVtUiAppUi::HandleLayoutChangedL()
       
  4834     {
       
  4835     __VTPRINTENTER( "VtUi.LayoutChg" )
       
  4836     if ( iState )
       
  4837         {
       
  4838         iState->HandleLayoutChangedL();
       
  4839         }
       
  4840     __VTPRINTEXIT( "VtUi.LayoutChg" )
       
  4841     }
       
  4842 
       
  4843 // -----------------------------------------------------------------------------
       
  4844 // CVtUiAppUi::DoHandleLayoutChangedL
       
  4845 // -----------------------------------------------------------------------------
       
  4846 //
       
  4847 void CVtUiAppUi::DoHandleLayoutChangedL()
       
  4848     {
       
  4849     __VTPRINTENTER( "VtUi.DoLayoutChg" )
       
  4850     // Fully update rendering parameters
       
  4851     UpdateRenderingParametersL();
       
  4852     // Notify engine about layout change
       
  4853     iLayoutChg = ETrue;
       
  4854     TRAPD( error, ExecuteCmdL( KVtEngHandleLayoutChange ) );
       
  4855     iLayoutChg = EFalse;
       
  4856 
       
  4857     // Not ready error is allowed to happen (e.g. when sharing)
       
  4858     if ( error && ( error != KErrNotReady ) )
       
  4859         {
       
  4860         User::Leave( error );
       
  4861         }
       
  4862     else
       
  4863         {
       
  4864         __VTPRINT( DEBUG_GEN,
       
  4865             "VtUi.DoLayoutChg KVtEngHandleLayoutChange == KErrNotReady (ok)" )
       
  4866         TVtEngCommandId pendingCommand = Model().CommandHandler().PendingCommand();
       
  4867         if ( pendingCommand  == KVtEngMuteOutgoingAudio || 
       
  4868                 pendingCommand  == KVtEngUnmuteOutgoingAudio ||
       
  4869                 pendingCommand  == KVtEngSetAudioRouting ||
       
  4870                 pendingCommand  == KVtEngSetAudioVolume ||
       
  4871                 pendingCommand  == KVtEngSetSource ||
       
  4872                 pendingCommand  == KVtEngPrepareCamera ||
       
  4873                 pendingCommand  == KVtEngUnfreeze )
       
  4874             {
       
  4875             iUiStates->SetLayoutChangeNeeded( ETrue );
       
  4876             }
       
  4877         }
       
  4878     // Notify component manager
       
  4879     iComponentManager->HandleLayoutChangeL();
       
  4880     MVtUiFeature* dialer =
       
  4881         iFeatureManager->GetFeatureById( EVtUiFeatureIdDialer );
       
  4882     const TBool dialerActive( dialer &&
       
  4883         ( dialer->State() == MVtUiFeature::EActive ) );
       
  4884     SwitchLayoutToFlatStatusPaneL( dialerActive );
       
  4885     
       
  4886     // Update the cam's whiteBalance and colorTone cause layoutchange will renew the camera,so
       
  4887     // restore the last user setting
       
  4888     UpdateVBSettingL();
       
  4889     
       
  4890 
       
  4891     if ( iDelayedCmd != 0 )
       
  4892         {
       
  4893         __VTPRINT2( DEBUG_GEN, "VtUi.DoLayoutChg reexecute the delayed cmd=%d", iDelayedCmd);
       
  4894         HandleCommandL( iDelayedCmd );
       
  4895         iDelayedCmd = 0;
       
  4896         }
       
  4897     __VTPRINTEXIT( "VtUi.DoLayoutChg" )
       
  4898     }
       
  4899 
       
  4900 // -----------------------------------------------------------------------------
       
  4901 // CVtUiAppUi::HandleVideoFrameL
       
  4902 // -----------------------------------------------------------------------------
       
  4903 //
       
  4904 void CVtUiAppUi::HandleVideoFrameL(
       
  4905         const TBool aLocal,
       
  4906         CFbsBitmap* aBitmap )
       
  4907     {
       
  4908     if ( aLocal )
       
  4909         {
       
  4910         iUplinkWindow->SetStreamBitmap( aBitmap );
       
  4911 
       
  4912         if ( aBitmap )
       
  4913             {
       
  4914             // If white balance or color tone setting feauture is
       
  4915             // active update feature's setting page's background.
       
  4916             CVtUiWhiteBalance* wb = static_cast< CVtUiWhiteBalance* >(
       
  4917             iFeatureManager->GetFeatureById( EVtUiFeatureIdWhiteBalance ) );
       
  4918 
       
  4919             CVtUiColorTone* ct = static_cast< CVtUiColorTone* >(
       
  4920             iFeatureManager->GetFeatureById( EVtUiFeatureIdColourTone ) );
       
  4921 
       
  4922             if ( wb )
       
  4923                 {
       
  4924                   __VTPRINT( DEBUG_GEN,"VtUi.HandleVideoFrameL WB" )
       
  4925                 if ( wb->State() == MVtUiFeature::EActive )
       
  4926                     {
       
  4927                     __VTPRINT( DEBUG_GEN,"VtUi.HandleVideoFrameL WB update" )
       
  4928                     wb->UpdateBackground( aBitmap );
       
  4929                     }
       
  4930                 }
       
  4931             if ( ct )
       
  4932                 {
       
  4933                  __VTPRINT( DEBUG_GEN,"VtUi.HandleVideoFrameL CT" )
       
  4934                 if (ct->State() == MVtUiFeature::EActive)
       
  4935                     {
       
  4936                      __VTPRINT( DEBUG_GEN,"VtUi.HandleVideoFrameL CT update" )
       
  4937                     ct->UpdateBackground( aBitmap );
       
  4938                     }
       
  4939                 }
       
  4940             }
       
  4941         }
       
  4942     else
       
  4943         {
       
  4944         iDownlinkWindow->SetStreamBitmap( aBitmap );
       
  4945         }
       
  4946     }
       
  4947 
       
  4948 // -----------------------------------------------------------------------------
       
  4949 // CVtUiAppUi::SetVideoFrame
       
  4950 // -----------------------------------------------------------------------------
       
  4951 //
       
  4952 void CVtUiAppUi::SetVideoFrame(
       
  4953         const TBool aLocal,
       
  4954         CFbsBitmap* aBitmap )
       
  4955     {
       
  4956     if ( aLocal )
       
  4957         {
       
  4958         }
       
  4959     else
       
  4960         {
       
  4961         iDownlinkWindow->SetStreamBitmapReserve( aBitmap );
       
  4962         }
       
  4963     }
       
  4964 
       
  4965 // -----------------------------------------------------------------------------
       
  4966 // CVtUiAppUi::HandleVideoFrameRemoteProblemL
       
  4967 // -----------------------------------------------------------------------------
       
  4968 //
       
  4969 void CVtUiAppUi::HandleVideoFrameRemoteProblemL()
       
  4970     {
       
  4971     __VTPRINTENTER( "VtUi.HandleRemote" )
       
  4972     HandleVideoFrameL( EFalse, NULL );
       
  4973     __VTPRINTEXIT( "VtUi.HandleRemote" )
       
  4974     }
       
  4975 
       
  4976 // -----------------------------------------------------------------------------
       
  4977 // CVtUiAppUi::HandleVideoFrameLocalProblemL
       
  4978 // -----------------------------------------------------------------------------
       
  4979 //
       
  4980 void CVtUiAppUi::HandleVideoFrameLocalProblemL()
       
  4981     {
       
  4982     __VTPRINTENTER( "VtUi.HandleLocal" )
       
  4983     // Camera might have changed - better to stop zoom.
       
  4984     HandleVideoFrameL( ETrue, NULL );
       
  4985     __VTPRINTEXIT( "VtUi.HandleLocal" )
       
  4986     }
       
  4987 
       
  4988 // -----------------------------------------------------------------------------
       
  4989 // CVtUiAppUi::RemoteVideoIsSQCif
       
  4990 // -----------------------------------------------------------------------------
       
  4991 //
       
  4992 void CVtUiAppUi::RemoteVideoIsSQCif( TBool aIsSQCif )
       
  4993     {
       
  4994     iUiStates->SetUseSQCif( aIsSQCif );
       
  4995     if ( iDownlinkWindow == iInstance->iMainControl )
       
  4996         {
       
  4997         ControlUsesSQCif( aIsSQCif );
       
  4998         }
       
  4999     }
       
  5000 
       
  5001 // -----------------------------------------------------------------------------
       
  5002 // CVtUiAppUi::ControlUsesSQCif
       
  5003 // -----------------------------------------------------------------------------
       
  5004 //
       
  5005 void CVtUiAppUi::ControlUsesSQCif( TBool aIsSQCif )
       
  5006     {
       
  5007     iInstance->iMainControl->SupportSQCif( aIsSQCif );
       
  5008     }
       
  5009 
       
  5010 // -----------------------------------------------------------------------------
       
  5011 // CVtUiAppUi::ChangeRemoteVideoLayoutL
       
  5012 // -----------------------------------------------------------------------------
       
  5013 //
       
  5014 void CVtUiAppUi::ChangeRemoteVideoLayoutL()
       
  5015     {
       
  5016     HandleLayoutChanged();
       
  5017     if ( iDownlinkWindow == iInstance->iMainControl )
       
  5018         {
       
  5019         iDownlinkWindow->SetBlind( EFalse );
       
  5020         StopWaitingImage();
       
  5021         iInstance->iMainControl->DrawNow();
       
  5022         }
       
  5023     }
       
  5024 
       
  5025 // -----------------------------------------------------------------------------
       
  5026 // CVtUiAppUi::ShowImageInitializeProgressL
       
  5027 // -----------------------------------------------------------------------------
       
  5028 //
       
  5029 void CVtUiAppUi::ShowImageInitializeProgressL()
       
  5030     {
       
  5031     __VTPRINTENTER( "VtUi.ShowImageInitializeProgressL" )
       
  5032     ShowProgressDialogL( R_PROGRESS_DECODING_IMAGE_WAIT_NOTE, this );
       
  5033     __VTPRINTEXIT( "VtUi.ShowImageInitializeProgressL" )
       
  5034     }
       
  5035 
       
  5036 // -----------------------------------------------------------------------------
       
  5037 // CVtUiAppUi::HideImageInitializeProgressL
       
  5038 // -----------------------------------------------------------------------------
       
  5039 //
       
  5040 void CVtUiAppUi::HideImageInitializeProgressL()
       
  5041     {
       
  5042     __VTPRINTENTER( "VtUi.HideImageInitializeProgressL" )
       
  5043     // if volume slider is visible hide it
       
  5044     CVtUiVolume* volume = static_cast< CVtUiVolume* >(
       
  5045     iFeatureManager->GetFeatureById( EVtUiFeatureIdVolume ) );
       
  5046     if ( volume )
       
  5047          {
       
  5048          volume->Stop();
       
  5049          }
       
  5050     HideProgressDialogL();
       
  5051     __VTPRINTEXIT( "VtUi.HideImageInitializeProgressL" )
       
  5052     }
       
  5053 
       
  5054 // -----------------------------------------------------------------------------
       
  5055 // CVtUiAppUi::CheckBeatL
       
  5056 // -----------------------------------------------------------------------------
       
  5057 //
       
  5058 void CVtUiAppUi::CheckBeatL( const TBool aCallDurationEnabled )
       
  5059     {
       
  5060     // Update call duration periodically if necessary.
       
  5061     const MVtEngSessionInfo::TSessionState state = Model().Session().State( EFalse );
       
  5062     const TBool timerEnable =
       
  5063         ( aCallDurationEnabled ) &&
       
  5064         ( ( state == MVtEngSessionInfo::EConnected ) ||
       
  5065           ( state == MVtEngSessionInfo::ENegotiating ) ||
       
  5066           ( state == MVtEngSessionInfo::EOpen ) );
       
  5067 
       
  5068     if ( timerEnable && iUiStates->IsThisApplicationForeground() )
       
  5069         {
       
  5070         iEventObserver->StartBeatL();
       
  5071         }
       
  5072     else
       
  5073         {
       
  5074         iEventObserver->StopBeat();
       
  5075         }
       
  5076     }
       
  5077 
       
  5078 // -----------------------------------------------------------------------------
       
  5079 // CVtUiAppUi::HandleBeat
       
  5080 // -----------------------------------------------------------------------------
       
  5081 //
       
  5082 void CVtUiAppUi::HandleBeat()
       
  5083     {
       
  5084     TRAP_IGNORE( RefreshNaviPaneL(); );
       
  5085     }
       
  5086 
       
  5087 // -----------------------------------------------------------------------------
       
  5088 // CVtUiAppUi::ShowCameraInUseNoteL
       
  5089 // -----------------------------------------------------------------------------
       
  5090 //
       
  5091 void CVtUiAppUi::ShowCameraInUseNoteL() const
       
  5092     {
       
  5093     // The note must not be blocking.
       
  5094 
       
  5095     CAknNoteDialog* dlg = new ( ELeave ) CAknNoteDialog( NULL );
       
  5096 
       
  5097     dlg->PrepareLC( R_VIDEOTELUI_INFORMATION_NOTE );
       
  5098     dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OK_EMPTY );
       
  5099 
       
  5100     HBufC* buf = StringLoader::LoadLC( R_VIDEOTELUI_QTN_INCAL_CLOSE_CAMCORDER );
       
  5101     dlg->SetTextL( *buf );
       
  5102     CleanupStack::PopAndDestroy( buf );
       
  5103 
       
  5104     dlg->SetTone( CAknNoteDialog::EConfirmationTone );
       
  5105     dlg->SetTimeout( CAknNoteDialog::EUndefinedTimeout );
       
  5106     dlg->RunLD();
       
  5107     }
       
  5108 
       
  5109 // -----------------------------------------------------------------------------
       
  5110 // CVtUiAppUi::ShowNotAllowedNoteL
       
  5111 // -----------------------------------------------------------------------------
       
  5112 //
       
  5113 void CVtUiAppUi::ShowNotAllowedNoteL() const
       
  5114     {
       
  5115     HBufC* prompt =
       
  5116         StringLoader::LoadLC(
       
  5117             R_VIDEOTELUI_TEXT_NOT_ALLOWED );
       
  5118 
       
  5119     CAknInformationNote* note =
       
  5120         new ( ELeave ) CAknInformationNote( ETrue );
       
  5121     note->ExecuteLD( *prompt );
       
  5122     CleanupStack::PopAndDestroy( prompt );
       
  5123     }
       
  5124 
       
  5125 // -----------------------------------------------------------------------------
       
  5126 // CVtUiAppUi::ShowCallNotAllowedNoteL
       
  5127 // -----------------------------------------------------------------------------
       
  5128 //
       
  5129 void CVtUiAppUi::ShowCallNotAllowedNoteL() const
       
  5130     {
       
  5131     HBufC* prompt =
       
  5132         StringLoader::LoadLC(
       
  5133             R_VIDEOTELUI_TEXT_CALL_NOT_ALLOWED );
       
  5134 
       
  5135     CAknInformationNote* note =
       
  5136         new ( ELeave ) CAknInformationNote( ETrue );
       
  5137     note->ExecuteLD( *prompt );
       
  5138     CleanupStack::PopAndDestroy( prompt );
       
  5139     }
       
  5140 
       
  5141 // -----------------------------------------------------------------------------
       
  5142 // CVtUiAppUi::ShowOtherCameraNotUsableNoteL
       
  5143 // -----------------------------------------------------------------------------
       
  5144 //
       
  5145 void CVtUiAppUi::ShowOtherCameraNotUsableNoteL() const
       
  5146     {
       
  5147     HBufC* prompt =
       
  5148         StringLoader::LoadLC(
       
  5149             R_VIDEOTELUI_QTN_ERR_CAM_SWAP );
       
  5150 
       
  5151     CAknInformationNote* note =
       
  5152         new ( ELeave ) CAknInformationNote( ETrue );
       
  5153     note->ExecuteLD( *prompt );
       
  5154     CleanupStack::PopAndDestroy( prompt );
       
  5155     }
       
  5156 
       
  5157 // -----------------------------------------------------------------------------
       
  5158 // CVtUiAppUi::ShowUnableToOpenNoteL
       
  5159 // -----------------------------------------------------------------------------
       
  5160 //
       
  5161 void CVtUiAppUi::ShowUnableToOpenNoteL() const
       
  5162     {
       
  5163     HBufC* prompt =
       
  5164         StringLoader::LoadLC(
       
  5165             R_VIDEOTELUI_QTN_ERR_UNABLE_TO_OPEN_IMAGE );
       
  5166     CAknInformationNote* note =
       
  5167         new ( ELeave ) CAknInformationNote( ETrue );
       
  5168     note->ExecuteLD( *prompt );
       
  5169     CleanupStack::PopAndDestroy( prompt );
       
  5170     }
       
  5171 
       
  5172 // -----------------------------------------------------------------------------
       
  5173 // -----------------------------------------------------------------------------
       
  5174 //
       
  5175 void CVtUiAppUi::ShowImageDecodingErrorNoteL()
       
  5176     {
       
  5177     HBufC* prompt =
       
  5178         StringLoader::LoadLC(
       
  5179             R_VIDEOTELUI_QTN_INCAL_NOTE_DECODING_FAILED );
       
  5180     CAknInformationNote* note =
       
  5181         new ( ELeave ) CAknInformationNote( ETrue );
       
  5182     note->ExecuteLD( *prompt );
       
  5183     CleanupStack::PopAndDestroy( prompt );
       
  5184     }
       
  5185 
       
  5186 // -----------------------------------------------------------------------------
       
  5187 // CVtUiAppUi::ShowDRMNotAllowedNoteL
       
  5188 // -----------------------------------------------------------------------------
       
  5189 //
       
  5190 void CVtUiAppUi::ShowDRMNotAllowedNoteL() const
       
  5191     {
       
  5192     HBufC* prompt =
       
  5193         StringLoader::LoadLC(
       
  5194             R_VIDEOTELUI_QTN_ERR_DRM_NOT_ALLOWED );
       
  5195     CAknInformationNote* note =
       
  5196         new ( ELeave ) CAknInformationNote( ETrue );
       
  5197     note->ExecuteLD( *prompt );
       
  5198     CleanupStack::PopAndDestroy( prompt );
       
  5199     }
       
  5200 
       
  5201 // -----------------------------------------------------------------------------
       
  5202 // CVtUiAppUi::SetSoftkeysL
       
  5203 // -----------------------------------------------------------------------------
       
  5204 //
       
  5205 void CVtUiAppUi::SetSoftkeysL( const TInt aSoftkeyResourceId )
       
  5206     {
       
  5207     if ( iCurrentSoftkeys != aSoftkeyResourceId )
       
  5208         {
       
  5209         if ( iCba )
       
  5210             {
       
  5211             iCba->SetCommandSetL( aSoftkeyResourceId );
       
  5212             iCba->DrawNow();
       
  5213             }
       
  5214         iCurrentSoftkeys = aSoftkeyResourceId;
       
  5215         }
       
  5216     }
       
  5217 
       
  5218 // -----------------------------------------------------------------------------
       
  5219 // CVtUiAppUi::SetHiddenL
       
  5220 // Makes application visible / invisible in fast swap window.
       
  5221 // -----------------------------------------------------------------------------
       
  5222 //
       
  5223 void CVtUiAppUi::SetHiddenL(
       
  5224         const TBool aHidden )
       
  5225     {
       
  5226     CEikonEnv* eikonEnv = iEikonEnv;
       
  5227     CApaWindowGroupName* windowGroupName =
       
  5228         CApaWindowGroupName::NewLC(
       
  5229             eikonEnv->WsSession(),
       
  5230             iThisApplicationWgId );
       
  5231     windowGroupName->SetHidden( aHidden );
       
  5232     User::LeaveIfError(
       
  5233         windowGroupName->SetWindowGroupName(
       
  5234             eikonEnv->RootWin() ) );
       
  5235     CleanupStack::PopAndDestroy( windowGroupName );
       
  5236 
       
  5237     // Update application UID.
       
  5238     TUid applicationUid = KVtUiAppUid;
       
  5239     if ( aHidden )
       
  5240         {
       
  5241         applicationUid.iUid = KVtUiTelephoneUid.iUid;
       
  5242         }
       
  5243     __VTPRINT2( DEBUG_GEN, "VtUi.SetHiddenL applicationUid.iUid=%x",
       
  5244         applicationUid.iUid )
       
  5245     // Set application that is "default top application"
       
  5246     TInt originalTopAppUid = 0;
       
  5247     TInt err = RProperty::Get(
       
  5248         KPSUidUikon,
       
  5249         KUikVideoCallTopApp,
       
  5250         originalTopAppUid );
       
  5251     __VTPRINT3( DEBUG_GEN, "VtUi.SetHiddenL orig. topApp=%x, err=%d",
       
  5252     originalTopAppUid, err )
       
  5253     if ( originalTopAppUid != applicationUid.iUid &&
       
  5254          iUiStates->IsDetailsReceived() )
       
  5255         {
       
  5256         __VTPRINT( DEBUG_GEN, "VtUi.SetHiddenL Do write KUikVideoCallTopApp" )
       
  5257         // Update key only if differs from original value and call
       
  5258         // has been answered
       
  5259         RProperty::Set(
       
  5260             KPSUidUikon,
       
  5261             KUikVideoCallTopApp,
       
  5262             applicationUid.iUid );
       
  5263         }
       
  5264     }
       
  5265 
       
  5266 // -----------------------------------------------------------------------------
       
  5267 // CVtUiAppUi::SetCallIdL
       
  5268 // -----------------------------------------------------------------------------
       
  5269 //
       
  5270 void CVtUiAppUi::SetCallIdL( const TInt aCallId )
       
  5271     {
       
  5272     HBufC* titlePane =
       
  5273         StringLoader::LoadLC( R_VIDEOTELUI_QTN_CALL_NUMBER_VIDEO, aCallId );
       
  5274     TPtr ptr = titlePane->Des();
       
  5275     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
       
  5276     TitlePaneL()->SetText( titlePane );
       
  5277     CleanupStack::Pop( titlePane );
       
  5278     }
       
  5279 
       
  5280 // -----------------------------------------------------------------------------
       
  5281 // CVtUiAppUi::SetCallNameL
       
  5282 // -----------------------------------------------------------------------------
       
  5283 //
       
  5284 TBool CVtUiAppUi::SetCallNameL( const TDesC& aName )
       
  5285     {
       
  5286     HBufC* nameBuf = aName.Alloc();
       
  5287     if ( nameBuf )
       
  5288         {
       
  5289         TPtr ptr = nameBuf->Des();
       
  5290         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
       
  5291         TitlePaneL()->SetText( nameBuf );
       
  5292         }
       
  5293 
       
  5294     return ( nameBuf != NULL );
       
  5295     }
       
  5296 
       
  5297 // -----------------------------------------------------------------------------
       
  5298 // CVtUiAppUi::BringTelephoneForeground
       
  5299 // -----------------------------------------------------------------------------
       
  5300 //
       
  5301 void CVtUiAppUi::BringTelephoneToForeground()
       
  5302     {
       
  5303     __VTPRINTENTER( "VtUi.BringTelephoneToForeground" )
       
  5304     // If Telephone application is running, then
       
  5305     // bring it to the foreground.
       
  5306     const TInt windowGroupId = TelephoneApplicationWgId();
       
  5307     if ( windowGroupId )
       
  5308         {
       
  5309         CEikonEnv* eikonEnv = iEikonEnv;
       
  5310         TApaTask task( eikonEnv->WsSession() );
       
  5311         task.SetWgId( windowGroupId );
       
  5312         task.BringToForeground();
       
  5313         }
       
  5314 
       
  5315     // In any case, send this application to the background.
       
  5316     ChangeApplicationFocus( EFalse );
       
  5317     __VTPRINTEXIT( "VtUi.BringTelephoneToForeground" )
       
  5318     }
       
  5319 
       
  5320 // -----------------------------------------------------------------------------
       
  5321 // CVtUiAppUi::ChangeApplicationFocus
       
  5322 // -----------------------------------------------------------------------------
       
  5323 //
       
  5324 void CVtUiAppUi::ChangeApplicationFocus( const TBool aForeground )
       
  5325     {
       
  5326     __VTPRINTENTER( "VtUi.ChangeApplicationFocus" )
       
  5327     CEikonEnv* eikonEnv = iEikonEnv;
       
  5328     TApaTask task( eikonEnv->WsSession() );
       
  5329     task.SetWgId( iThisApplicationWgId );
       
  5330     if ( !aForeground )
       
  5331         {
       
  5332         task.SendToBackground();
       
  5333         }
       
  5334     else if ( !iUiStates->IsDeviceLockOn() )
       
  5335         {
       
  5336         task.BringToForeground();
       
  5337         }
       
  5338     __VTPRINTEXIT( "VtUi.ChangeApplicationFocus" )
       
  5339     }
       
  5340 
       
  5341 // -----------------------------------------------------------------------------
       
  5342 // CVtUiAppUi::TelephoneApplicationWgId
       
  5343 // -----------------------------------------------------------------------------
       
  5344 //
       
  5345 TInt CVtUiAppUi::TelephoneApplicationWgId()
       
  5346     {
       
  5347     TInt resultWgId = 0;
       
  5348 
       
  5349     TApaTaskList taskList( iEikonEnv->WsSession() );
       
  5350     TInt appUid = 0;
       
  5351 
       
  5352     // Try first Telephone application.
       
  5353     if ( RProperty::Get(
       
  5354              KPSUidTelInformation,
       
  5355              KTelPhoneUid,
       
  5356              appUid ) == KErrNone )
       
  5357         {
       
  5358         TApaTask task = taskList.FindApp( TUid::Uid( appUid ) );
       
  5359         if ( task.Exists() )
       
  5360             {
       
  5361             resultWgId = task.WgId();
       
  5362             }
       
  5363         }
       
  5364 
       
  5365     // Then Idle application.
       
  5366     if ( !resultWgId &&
       
  5367          ( RProperty::Get(
       
  5368                KPSUidAiInformation,
       
  5369                KActiveIdleUid,
       
  5370                appUid ) == KErrNone ) )
       
  5371         {
       
  5372         TApaTask task = taskList.FindApp( TUid::Uid( appUid ) );
       
  5373         if ( task.Exists() )
       
  5374             {
       
  5375             resultWgId = task.WgId();
       
  5376             }
       
  5377         }
       
  5378 
       
  5379     return resultWgId;
       
  5380     }
       
  5381 
       
  5382 // -----------------------------------------------------------------------------
       
  5383 // CVtUiAppUi::ShowNumberEntry
       
  5384 // -----------------------------------------------------------------------------
       
  5385 //
       
  5386 inline TBool CVtUiAppUi::ShowNumberEntry() const
       
  5387     {
       
  5388     return EFalse;
       
  5389     }
       
  5390 
       
  5391 // -----------------------------------------------------------------------------
       
  5392 // CVtUiAppUi::IsActiveIdleEnabledL
       
  5393 // -----------------------------------------------------------------------------
       
  5394 //
       
  5395 TBool CVtUiAppUi::IsActiveIdleEnabledL() const
       
  5396     {
       
  5397     TVtUiActiveIdleVariation activeIdleVariation;
       
  5398     return activeIdleVariation.IsActiveIdleEnabled();
       
  5399     }
       
  5400 
       
  5401 // -----------------------------------------------------------------------------
       
  5402 // CVtUiAppUi::CheckEngineFunctionality
       
  5403 // -----------------------------------------------------------------------------
       
  5404 //
       
  5405 void CVtUiAppUi::CheckEngineFunctionality()
       
  5406     {
       
  5407     const TBool prepareViewFinder =
       
  5408         iEventObserver->CommandSupportedAndSynchronous(
       
  5409              KVtEngPrepareViewFinder );
       
  5410     const TBool prepareRemoteRender =
       
  5411         iEventObserver->CommandSupportedAndSynchronous(
       
  5412             KVtEngPrepareRemoteRender );
       
  5413     const TBool prepareRemoteRenderDSA =
       
  5414         iEventObserver->CommandSupportedAndSynchronous(
       
  5415             KVtEngPrepareRemoteRenderDSA );
       
  5416     const TBool prepareRemoteRenderDP =
       
  5417         iEventObserver->CommandSupportedAndSynchronous(
       
  5418             KVtEngPrepareRemoteRenderDP );
       
  5419     const TBool stopViewFinder =
       
  5420         iEventObserver->CommandSupportedAndSynchronous(
       
  5421             KVtEngStopViewFinder );
       
  5422     const TBool startViewFinder =
       
  5423         iEventObserver->CommandSupportedAndSynchronous(
       
  5424             KVtEngStartViewFinder );
       
  5425     const TBool stopRemoteRender =
       
  5426         iEventObserver->CommandSupportedAndSynchronous(
       
  5427             KVtEngStopRenderRemote );
       
  5428     const TBool startRemoteRender =
       
  5429         iEventObserver->CommandSupportedAndSynchronous(
       
  5430             KVtEngStartRenderRemote );
       
  5431     const TBool setUIForeground =
       
  5432     	iEventObserver->CommandSupportedAndSynchronous(
       
  5433 			KVtEngSetUIForeground );
       
  5434 
       
  5435 	TVtUiDPVariation dpvariation;
       
  5436     TBool dpSupported( dpvariation.IsDPSupported() );
       
  5437 
       
  5438     if ( !prepareViewFinder ||
       
  5439          ( !prepareRemoteRender && !prepareRemoteRenderDSA && !dpSupported ) ||
       
  5440          ( !prepareRemoteRender && !prepareRemoteRenderDP && dpSupported ) ||
       
  5441          !stopViewFinder ||
       
  5442          !startViewFinder ||
       
  5443          !stopRemoteRender ||
       
  5444          !startRemoteRender ||
       
  5445          !setUIForeground )
       
  5446         {
       
  5447         // Not supported - should never occur.
       
  5448         __VTPRINT( DEBUG_GEN, "VtUi.EngineFunc.ASSERT" )
       
  5449         VtUiPanic::Panic( EVtUiPanicEngineFunctionalityAssert );
       
  5450         }
       
  5451     }
       
  5452 
       
  5453 // -----------------------------------------------------------------------------
       
  5454 // CVtUiAppUi::Model
       
  5455 // -----------------------------------------------------------------------------
       
  5456 //
       
  5457 CVtEngModel& CVtUiAppUi::Model()
       
  5458     {
       
  5459     return iEventObserver->Model();
       
  5460     }
       
  5461 
       
  5462 // -----------------------------------------------------------------------------
       
  5463 // CVtUiAppUi::VideoTelephonyVariation
       
  5464 // -----------------------------------------------------------------------------
       
  5465 //
       
  5466 const TVtUiVideoTelephonyVariation& CVtUiAppUi::VideoTelephonyVariation() const
       
  5467     {
       
  5468     return iVTVariation;
       
  5469     }
       
  5470 
       
  5471 // -----------------------------------------------------------------------------
       
  5472 // CVtUiAppUi::NumberSource
       
  5473 // -----------------------------------------------------------------------------
       
  5474 //
       
  5475 MVtUiNumberSource* CVtUiAppUi::NumberSource() const
       
  5476     {
       
  5477     return iNumberSource;
       
  5478     }
       
  5479 
       
  5480 // -----------------------------------------------------------------------------
       
  5481 // CVtUiAppUi::NaviPaneL
       
  5482 // -----------------------------------------------------------------------------
       
  5483 //
       
  5484 inline CAknNavigationControlContainer* CVtUiAppUi::NaviPaneL()
       
  5485     {
       
  5486     return
       
  5487         static_cast< CAknNavigationControlContainer* >
       
  5488             ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  5489     }
       
  5490 
       
  5491 // -----------------------------------------------------------------------------
       
  5492 // CVtUiAppUi::TitlePaneL
       
  5493 // -----------------------------------------------------------------------------
       
  5494 //
       
  5495 inline CAknTitlePane* CVtUiAppUi::TitlePaneL()
       
  5496     {
       
  5497     return
       
  5498         static_cast< CAknTitlePane* >
       
  5499             ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  5500     }
       
  5501 
       
  5502 // -----------------------------------------------------------------------------
       
  5503 // CVtUiAppUi::CleanupPushRefreshL
       
  5504 // -----------------------------------------------------------------------------
       
  5505 //
       
  5506 inline void CVtUiAppUi::CleanupPushRefreshL()
       
  5507     {
       
  5508     CleanupStack::PushL(
       
  5509         TCleanupItem( DoRefresh, this ) );
       
  5510     }
       
  5511 
       
  5512 // -----------------------------------------------------------------------------
       
  5513 // CVtUiAppUi::CleanupPushEnableBlindL
       
  5514 // -----------------------------------------------------------------------------
       
  5515 //
       
  5516 inline void CVtUiAppUi::CleanupPushEnableBlindL()
       
  5517     {
       
  5518     CleanupStack::PushL(
       
  5519         TCleanupItem( DoEnableBlindSetting, this ) );
       
  5520     }
       
  5521 
       
  5522 // -----------------------------------------------------------------------------
       
  5523 // CVtUiAppUi::EnableCommandActivatingAndCleanupPushL
       
  5524 // -----------------------------------------------------------------------------
       
  5525 //
       
  5526 void CVtUiAppUi::EnableCommandActivatingAndCleanupPushL()
       
  5527     {
       
  5528     __VTPRINTENTER( "VtUi.EnableCommandActivatingAndCleanupPushL" )
       
  5529     // add anyway to cleanup stack to avoid caring about stack balance
       
  5530     CleanupStack::PushL(
       
  5531         TCleanupItem( DoDisableCommandActivating, this ) );
       
  5532     // but in case of consecutive calls on this don't refresh (avoid flicker)
       
  5533     const TBool alreadyActivating( iUiStates->IsCommandActivating() );
       
  5534     // increases ref.count if alread set as activating
       
  5535     iUiStates->SetIsCommandActivating( ETrue );
       
  5536     if ( !alreadyActivating )
       
  5537         {
       
  5538         // refresh only when ref.count incremented from zero.
       
  5539         iCommandManager->RefreshL();
       
  5540         }
       
  5541     __VTPRINTEXIT( "VtUi.EnableCommandActivatingAndCleanupPushL" )
       
  5542     }
       
  5543 
       
  5544 // -----------------------------------------------------------------------------
       
  5545 // CVtUiAppUi::DoDisableCommandActivating
       
  5546 // -----------------------------------------------------------------------------
       
  5547 //
       
  5548 void CVtUiAppUi::DoDisableCommandActivating( TAny* aAny )
       
  5549     {
       
  5550     CVtUiAppUi* self =
       
  5551         reinterpret_cast< CVtUiAppUi* >( aAny );
       
  5552     TRAP_IGNORE( self->HandleCommandDeactivationL() );
       
  5553     }
       
  5554 
       
  5555 // -----------------------------------------------------------------------------
       
  5556 // CVtUiAppUi::HandleCommandDeactivationL
       
  5557 // -----------------------------------------------------------------------------
       
  5558 //
       
  5559 void CVtUiAppUi::HandleCommandDeactivationL()
       
  5560     {
       
  5561     __VTPRINTENTER( "VtUi.HandleCommandDeactivationL" )
       
  5562     iUiStates->SetIsCommandActivating( EFalse );
       
  5563     if ( !iUiStates->IsCommandActivating() )
       
  5564         {
       
  5565         RefreshStatesL();
       
  5566         }
       
  5567     __VTPRINTEXIT( "VtUi.HandleCommandDeactivationL" )
       
  5568     }
       
  5569 
       
  5570 // -----------------------------------------------------------------------------
       
  5571 // CVtUiAppUi::DoEnableBlindSetting
       
  5572 // -----------------------------------------------------------------------------
       
  5573 //
       
  5574 void CVtUiAppUi::DoEnableBlindSetting( TAny* aAny )
       
  5575     {
       
  5576     CVtUiAppUi* self =
       
  5577         reinterpret_cast< CVtUiAppUi* >( aAny );
       
  5578     self->iUiStates->SetDisableBlindSetting( EFalse );
       
  5579     }
       
  5580 
       
  5581 // -----------------------------------------------------------------------------
       
  5582 // CVtUiAppUi::DoRefresh
       
  5583 // -----------------------------------------------------------------------------
       
  5584 //
       
  5585 void CVtUiAppUi::DoRefresh( TAny* aAny )
       
  5586     {
       
  5587     CVtUiAppUi* self =
       
  5588         reinterpret_cast< CVtUiAppUi* >( aAny );
       
  5589     TRAP_IGNORE( self->RefreshL() );
       
  5590     }
       
  5591 
       
  5592 // -----------------------------------------------------------------------------
       
  5593 // CVtUiAppUi::DoHandleExitTimeout
       
  5594 // -----------------------------------------------------------------------------
       
  5595 //
       
  5596 TInt CVtUiAppUi::DoHandleExitTimeout( TAny* /*aAny*/ )
       
  5597     {
       
  5598     __VTPRINT( DEBUG_GEN, "VtUi.Exit.Timer.EXPIRED!" )
       
  5599     VtUiPanic::Panic( EVtUiPanicApplicationShutdownTimeout );
       
  5600 
       
  5601     return KErrNone;
       
  5602     }
       
  5603 
       
  5604 // -----------------------------------------------------------------------------
       
  5605 // VtUiAppUi::IsViewFinderInMainPane
       
  5606 // -----------------------------------------------------------------------------
       
  5607 //
       
  5608 TBool CVtUiAppUi::IsViewFinderInMainPane() const
       
  5609     {
       
  5610     return !( IsViewFinderInContextPane() );
       
  5611     }
       
  5612 
       
  5613 // -----------------------------------------------------------------------------
       
  5614 // VtUiAppUi::IsViewFinderInContextPane
       
  5615 // -----------------------------------------------------------------------------
       
  5616 //
       
  5617 TBool CVtUiAppUi::IsViewFinderInContextPane() const
       
  5618     {
       
  5619     return ( iUplinkWindow == iInstance->iContextControl );
       
  5620     }
       
  5621 
       
  5622 // -----------------------------------------------------------------------------
       
  5623 // VtUiAppUi::SwitchViewFinderToMainPaneL
       
  5624 // -----------------------------------------------------------------------------
       
  5625 //
       
  5626 void CVtUiAppUi::SwitchViewFinderToMainPaneL( TBool aUpdateState )
       
  5627     {
       
  5628     __VTPRINTENTER( "VtUi.SwitchViewFinderToMainPaneL" )
       
  5629     //change local video in to main pane
       
  5630     if( IsViewFinderInContextPane() )
       
  5631         {
       
  5632         //flag indicates the initial position of uplink window before freeze
       
  5633         if ( aUpdateState )
       
  5634             {
       
  5635             iUiStates->SetViewFindersInitialPlaceContextPane( ETrue );
       
  5636             }
       
  5637         HandleCommandL( EVtUiCmdSwapImagesPlaces );
       
  5638         }
       
  5639     else
       
  5640         {
       
  5641         if ( aUpdateState )
       
  5642             {
       
  5643             iUiStates->SetViewFindersInitialPlaceContextPane( EFalse );
       
  5644             }
       
  5645         }
       
  5646     __VTPRINTEXIT( "VtUi.SwitchViewFinderToMainPaneL" )
       
  5647     }
       
  5648 
       
  5649 // -----------------------------------------------------------------------------
       
  5650 // VtUiAppUi::SwitchViewFinderToContextPaneL
       
  5651 // -----------------------------------------------------------------------------
       
  5652 //
       
  5653 void CVtUiAppUi::SwitchViewFinderToContextPaneL( TBool aUpdateState )
       
  5654     {
       
  5655     __VTPRINTENTER( "VtUi.SwitchViewFinderToContextPaneL" )
       
  5656     //change local video in to context pane
       
  5657     if( !IsViewFinderInContextPane() )
       
  5658         {
       
  5659         //flag indicates the initial position of uplink window before freeze
       
  5660         if ( aUpdateState )
       
  5661             {
       
  5662             iUiStates->SetViewFindersInitialPlaceContextPane( EFalse );
       
  5663             }
       
  5664         HandleCommandL( EVtUiCmdSwapImagesPlaces );
       
  5665         }
       
  5666     else
       
  5667         {
       
  5668         if ( aUpdateState )
       
  5669             {
       
  5670             iUiStates->SetViewFindersInitialPlaceContextPane( ETrue );
       
  5671             }
       
  5672         }
       
  5673     __VTPRINTEXIT( "VtUi.SwitchViewFinderToContextPaneL" )
       
  5674     }
       
  5675 
       
  5676 // -----------------------------------------------------------------------------
       
  5677 // VtUiAppUi::RestoreViewFinderL
       
  5678 // -----------------------------------------------------------------------------
       
  5679 //
       
  5680 void CVtUiAppUi::RestoreViewFinderL()
       
  5681     {
       
  5682     __VTPRINTENTER( "VtUi.RestoreViewFinderL" )
       
  5683     if( IsViewFinderInContextPane() )
       
  5684         {
       
  5685         if( !iUiStates->IsViewFindersInitialPlaceContextPane() )
       
  5686             {
       
  5687             SwitchViewFinderToMainPaneL( EFalse );
       
  5688             }
       
  5689         }
       
  5690     else
       
  5691         {
       
  5692         if( iUiStates->IsViewFindersInitialPlaceContextPane() )
       
  5693             {
       
  5694             SwitchViewFinderToContextPaneL( EFalse );
       
  5695             }
       
  5696         }
       
  5697     __VTPRINTEXIT( "VtUi.RestoreViewFinderL" )
       
  5698     }
       
  5699 
       
  5700 // -----------------------------------------------------------------------------
       
  5701 // CVtUiAppUi::DialogDismissedL
       
  5702 // -----------------------------------------------------------------------------
       
  5703 //
       
  5704 void CVtUiAppUi::DialogDismissedL( TInt )
       
  5705     {
       
  5706     __VTPRINTENTER( "VtUi.DialogDismissedL" )
       
  5707     MVtUiFeature* tb =
       
  5708         iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar );
       
  5709     if ( tb )
       
  5710         {
       
  5711         if ( !iTbPeriodic )
       
  5712             {
       
  5713             iTbPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
  5714             }
       
  5715         iTbPeriodic->Cancel();
       
  5716         // try to strat toolbar feature immediately
       
  5717         iTbPeriodic->Start( 0, KPeriodTime, TCallBack( DoTryToStartTbL, this ) );
       
  5718         }
       
  5719      __VTPRINTEXIT( "VtUi.DialogDismissedL" )
       
  5720     }
       
  5721 
       
  5722 // -----------------------------------------------------------------------------
       
  5723 // CVtUiAppUi::UpdateContextPaneIconL
       
  5724 // -----------------------------------------------------------------------------
       
  5725 //
       
  5726 void CVtUiAppUi::UpdateContextPaneIconL()
       
  5727     {
       
  5728     CEikStatusPane* statusPane = StatusPane();
       
  5729 
       
  5730     if ( statusPane )
       
  5731         {
       
  5732         if ( statusPane->PaneCapabilities(
       
  5733             TUid::Uid( EEikStatusPaneUidContext ) ).IsPresent() )
       
  5734             {
       
  5735             CAknContextPane* contextPane = NULL;
       
  5736             TRAPD ( err, contextPane = static_cast<CAknContextPane*> (
       
  5737                 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) ) );
       
  5738             if ( err != KErrNone || ! contextPane )
       
  5739                 {
       
  5740                 return;
       
  5741                 }
       
  5742 
       
  5743             // Set a new context pane icon
       
  5744             CFbsBitmap* newBitmap = new(ELeave) CFbsBitmap;
       
  5745             CleanupStack::PushL( newBitmap );
       
  5746             User::LeaveIfError( newBitmap->Create( TSize( 1, 1 ), EGray2 ) );
       
  5747 
       
  5748             CFbsBitmap* newMask = new(ELeave) CFbsBitmap;
       
  5749             CleanupStack::PushL( newMask );
       
  5750             User::LeaveIfError( newMask->Create( TSize( 1, 1 ), EGray2 ) );
       
  5751 
       
  5752             // create an off-screen device and context
       
  5753             CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( newMask );
       
  5754             CleanupStack::PushL( bitmapDevice );
       
  5755             CFbsBitGc* maskGc = NULL;
       
  5756             User::LeaveIfError( bitmapDevice->CreateContext( maskGc ) );
       
  5757             User::LeaveIfNull( maskGc );
       
  5758             CleanupStack::PushL( maskGc );
       
  5759             maskGc->SetPenStyle( CGraphicsContext::ENullPen );
       
  5760             maskGc->SetBrushColor( TRgb::Gray2( 1 ) ); // transparency
       
  5761             maskGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  5762             maskGc->Clear();
       
  5763             CleanupStack::PopAndDestroy( 2 ); // maskGc, bitmapDevice
       
  5764 
       
  5765             // newBitmap, new Mask ownership transfer
       
  5766             contextPane->SetPicture( newBitmap, newMask );
       
  5767             CleanupStack::Pop( 2 ); // newBitmap, newMask
       
  5768             }
       
  5769         }
       
  5770     }
       
  5771 
       
  5772 // -----------------------------------------------------------------------------
       
  5773 // CVtUiAppUi::SetIncallBubbleAllowedInUsualL
       
  5774 // -----------------------------------------------------------------------------
       
  5775 //
       
  5776 void CVtUiAppUi::SetIncallBubbleAllowedInUsualL( TBool aAllowed )
       
  5777     {
       
  5778     __VTPRINT2( DEBUG_GEN, "Ui.SetIncallBubbleAllowedInUsualL: %d", aAllowed )
       
  5779 
       
  5780     // If call is being disconnected, we do not want to show in-call bubble
       
  5781     // anymore but dismiss it.
       
  5782     if( iUiStates->ExecState() == TVtUiStates::EExecStateResetting ||
       
  5783         iUiStates->ExecState() == TVtUiStates:: EExecStateFinalized )
       
  5784         {
       
  5785         __VTPRINT2( DEBUG_GEN, "Ui.SetIncallBubbleAllowedInUsualL forced to false: %d", aAllowed )
       
  5786         aAllowed = EFalse;
       
  5787         }
       
  5788 
       
  5789     if ( iIncallBubble )
       
  5790         {
       
  5791         iIncallBubble->SetIncallBubbleAllowedInUsualL( aAllowed );
       
  5792         }
       
  5793     __VTPRINT( DEBUG_GEN, "Ui.SetIncallBubbleAllowedInUsualL>" )
       
  5794     }
       
  5795 
       
  5796 // -----------------------------------------------------------------------------
       
  5797 // CVtUiAppUi::ShowProgressDialogL
       
  5798 // -----------------------------------------------------------------------------
       
  5799 //
       
  5800 void CVtUiAppUi::ShowProgressDialogL( TInt aResourceId,
       
  5801     MProgressDialogCallback* aCallback )
       
  5802     {
       
  5803     __VTPRINTENTER( "VtUi.ShowProgressDialogL" )
       
  5804     if( iProgressDlg )
       
  5805         {
       
  5806         User::Leave( KErrNotReady );
       
  5807         }
       
  5808     iProgressDlg = new ( ELeave ) CAknProgressDialog(
       
  5809         reinterpret_cast<  CEikDialog** >( &iProgressDlg ), ETrue );
       
  5810     iProgressDlg->SetCallback( aCallback );
       
  5811     iProgressDlg->ExecuteLD( aResourceId );
       
  5812     __VTPRINTEXIT( "VtUi.ShowProgressDialogL" )
       
  5813     }
       
  5814 
       
  5815 // -----------------------------------------------------------------------------
       
  5816 // CVtUiAppUi::HideProgressDialogL
       
  5817 // -----------------------------------------------------------------------------
       
  5818 //
       
  5819 void CVtUiAppUi::HideProgressDialogL()
       
  5820     {
       
  5821     __VTPRINTENTER( "VtUi.HideProgressDialogL" )
       
  5822     if( iProgressDlg )
       
  5823         {
       
  5824         iProgressDlg->ProcessFinishedL();
       
  5825         }
       
  5826     __VTPRINTEXIT( "VtUi.HideProgressDialogL" )
       
  5827     }
       
  5828 
       
  5829 // -----------------------------------------------------------------------------
       
  5830 // CVtUiAppUi::AsyncViewFinderToMainPaneAndShare
       
  5831 // -----------------------------------------------------------------------------
       
  5832 //
       
  5833 TInt CVtUiAppUi::AsyncViewFinderToMainPaneAndShare( TAny* aPtr )
       
  5834     {
       
  5835     __VTPRINTENTER( "VtUi.AsyncViewFinderToMainPaneAndShare" )
       
  5836     CVtUiAppUi* self = reinterpret_cast< CVtUiAppUi* >( aPtr );
       
  5837 
       
  5838     TRAPD( result, { self->SwitchViewFinderToMainPaneL();
       
  5839     								 self->CmdShareImageL();} );
       
  5840     __VTPRINTEXITR( "VtUi.AsyncViewFinderToMainPaneAndShare %d", result )
       
  5841     return result;
       
  5842     }
       
  5843 
       
  5844 // -----------------------------------------------------------------------------
       
  5845 // CVtUiAppUi::AsyncShare
       
  5846 // -----------------------------------------------------------------------------
       
  5847 //
       
  5848 TInt CVtUiAppUi::AsyncShare( TAny* aPtr )
       
  5849     {
       
  5850     __VTPRINTENTER( "VtUi.AsyncShare" )
       
  5851     CVtUiAppUi* self = reinterpret_cast< CVtUiAppUi* >( aPtr );
       
  5852     TRAPD( result, self->CmdShareImageL() );
       
  5853     __VTPRINTEXITR( "VtUi.AsyncShare %d", result )
       
  5854     return result;
       
  5855     }
       
  5856 
       
  5857 // -----------------------------------------------------------------------------
       
  5858 // CVtUiAppUi::AsyncShowErrorAndRestartShare
       
  5859 // -----------------------------------------------------------------------------
       
  5860 //
       
  5861 TInt CVtUiAppUi::AsyncShowErrorAndRestartShare( TAny* aPtr )
       
  5862     {
       
  5863     __VTPRINTENTER( "VtUi.AsyncShowErrorAndRestartShare" )
       
  5864     CVtUiAppUi* self = reinterpret_cast< CVtUiAppUi* >( aPtr );
       
  5865     TRAPD( result, { self->ShowUnableToOpenNoteL();
       
  5866                     self->HandleCommandL( EVtUiCmdShareObjectImage ); } );
       
  5867     __VTPRINTEXITR( "VtUi.AsyncShowErrorAndRestartShare %d", result )
       
  5868     return result;
       
  5869     }
       
  5870 
       
  5871 // -----------------------------------------------------------------------------
       
  5872 // CVtUiAppUi::GetCameraOrientations
       
  5873 // -----------------------------------------------------------------------------
       
  5874 //
       
  5875 void CVtUiAppUi::GetCameraOrientations()
       
  5876     {
       
  5877     __VTPRINTENTER( "VtUi.GetCameraOrientations" )
       
  5878     MVtEngMedia& media = Model().Media();
       
  5879  	media.GetCameraOrientations( iPrimaryCameraOrientation,
       
  5880  	     iSecondaryCameraOrientation );
       
  5881     __VTPRINTEXIT( "VtUi.GetCameraOrientations" )
       
  5882     }
       
  5883 
       
  5884 // -----------------------------------------------------------------------------
       
  5885 // CVtUiAppUi::SetInitialCameraOrientationL
       
  5886 // -----------------------------------------------------------------------------
       
  5887 //
       
  5888 void CVtUiAppUi::SetInitialCameraOrientationL()
       
  5889     {
       
  5890     __VTPRINTENTER( "VtUi.SetInitialCameraOrientationL" )
       
  5891     MVtEngMedia::TCameraId cameraId;
       
  5892     MVtEngMedia& media( Model().Media() );
       
  5893     media.GetCurrentCameraId( cameraId );
       
  5894     MVtEngMedia::TCameraOrientation targetOrientation(
       
  5895         cameraId == MVtEngMedia::EPrimaryCamera ?
       
  5896             iPrimaryCameraOrientation :
       
  5897             ( cameraId == MVtEngMedia::ESecondaryCamera ?
       
  5898                 iSecondaryCameraOrientation :
       
  5899                 iCurrentCameraOrientation ) );
       
  5900     if ( iCurrentCameraOrientation != targetOrientation )
       
  5901         {
       
  5902         __VTPRINT3( DEBUG_GEN,
       
  5903             "VtUi.SetInitialCameraOrientationL Old=%d New=%d",
       
  5904                 iCurrentCameraOrientation,
       
  5905                 targetOrientation )
       
  5906         SetOrientationL( engToAppOrientation[ targetOrientation ] );
       
  5907         iCurrentCameraOrientation = targetOrientation;
       
  5908         }
       
  5909     __VTPRINTEXIT( "VtUi.SetInitialCameraOrientationL" )
       
  5910     }
       
  5911 
       
  5912 // -----------------------------------------------------------------------------
       
  5913 // CVtUiAppUi::SetCameraOrientationL
       
  5914 // -----------------------------------------------------------------------------
       
  5915 //
       
  5916 void CVtUiAppUi::SetCameraOrientationL()
       
  5917     {
       
  5918     __VTPRINTENTER( "VtUi.SetCameraOrientationL" )
       
  5919     MVtEngMedia::TCameraOrientation newOrientation = iCurrentCameraOrientation;
       
  5920     MVtEngMedia::TCameraId cameraId;
       
  5921     MVtEngMedia& media = Model().Media();
       
  5922     if ( media.GetCurrentCameraId( cameraId ) == KErrNone )
       
  5923         {
       
  5924         switch ( cameraId )
       
  5925             {
       
  5926             case MVtEngMedia::EPrimaryCamera:
       
  5927                 __VTPRINT( DEBUG_GEN, "VtUi.SetCameraOrient.Primary")
       
  5928                 if( iCurrentCameraOrientation != iPrimaryCameraOrientation )
       
  5929                 	{
       
  5930                 	newOrientation = iPrimaryCameraOrientation;
       
  5931                 	}
       
  5932                 break;
       
  5933 
       
  5934             case MVtEngMedia::ESecondaryCamera:
       
  5935             	__VTPRINT( DEBUG_GEN, "VtUi.SetCameraOrient.Secondary")
       
  5936             	if ( iCurrentCameraOrientation != iSecondaryCameraOrientation )
       
  5937                     {
       
  5938                 	newOrientation = iSecondaryCameraOrientation;
       
  5939                 	}
       
  5940                     break;
       
  5941 
       
  5942             default:
       
  5943                 break;
       
  5944             }
       
  5945         }
       
  5946 
       
  5947     __VTPRINT2( DEBUG_GEN, "VtUi.SetCameraOrient.Cur=%d",
       
  5948         iCurrentCameraOrientation )
       
  5949     __VTPRINT2( DEBUG_GEN, "VtUi.SetCameraOrient.New=%d",
       
  5950         newOrientation )
       
  5951 
       
  5952     if ( iCurrentCameraOrientation != newOrientation )
       
  5953         	{
       
  5954         	// map camera orientation to appui layout orientation
       
  5955         	TAppUiOrientation newAppUiOrientation;
       
  5956         	if ( newOrientation == MVtEngMedia::EOrientationLandscape )
       
  5957         	    {
       
  5958         	    __VTPRINT( DEBUG_GEN, "VtUi.SetCameraOrient=LS")
       
  5959         	    newAppUiOrientation = EAppUiOrientationLandscape;
       
  5960         	    }
       
  5961         	else if ( newOrientation == MVtEngMedia::EOrientationPortrait )
       
  5962         	    {
       
  5963         	    __VTPRINT( DEBUG_GEN, "VtUi.SetCameraOrient=PR")
       
  5964         	    newAppUiOrientation = EAppUiOrientationPortrait;
       
  5965         	    }
       
  5966         	else
       
  5967         	    {
       
  5968         	    __VTPRINT( DEBUG_GEN, "VtUi.SetCameraOrient=OL")
       
  5969         	    newAppUiOrientation = EAppUiOrientationUnspecified;
       
  5970         	    }
       
  5971         	SetOrientationL( newAppUiOrientation );
       
  5972         	}
       
  5973     __VTPRINTEXIT( "VtUi.SetCameraOrientationL" )
       
  5974     }
       
  5975 
       
  5976 // -----------------------------------------------------------------------------
       
  5977 // CVtUiAppUi::RefreshStatesL
       
  5978 // -----------------------------------------------------------------------------
       
  5979 //
       
  5980 void CVtUiAppUi::RefreshStatesL()
       
  5981     {
       
  5982     __VTPRINTENTER( "VtUi.RefreshStatesL" )
       
  5983     // If transaction (set of commands) is pending refresh in delayed until
       
  5984     // all of them are processed.
       
  5985     if ( !iUiStates->IsCommandActivating() )
       
  5986         {
       
  5987         iUiStates->Update();
       
  5988         if ( iUiStates->IsThisApplicationForeground() )
       
  5989             {
       
  5990             iCommandManager->RefreshL();
       
  5991             }
       
  5992         }
       
  5993     __VTPRINTEXIT( "VtUi.RefreshStatesL" )
       
  5994     }
       
  5995 
       
  5996 // -----------------------------------------------------------------------------
       
  5997 // CVtUiAppUi::CmdAdjustVideoL
       
  5998 // -----------------------------------------------------------------------------
       
  5999 //
       
  6000  void CVtUiAppUi::CmdAdjustVideoL( TInt aCommand )
       
  6001     {
       
  6002         __VTPRINTENTER( "VtUi.CmdAdjustVideoL" )
       
  6003     TInt featureId( -1 );
       
  6004     switch ( aCommand )
       
  6005         {
       
  6006     case EVtUiCmdAdjustVideoVideoQuality:
       
  6007         featureId = EVtUiFeatureIdVideoQuality;
       
  6008         break;
       
  6009     case EVtUiCmdAdjustVideoWhiteBalance:
       
  6010         featureId = EVtUiFeatureIdWhiteBalance;
       
  6011         break;
       
  6012     case EVtUiCmdAdjustVideoBrightness:
       
  6013         featureId = EVtUiFeatureIdBrightness;
       
  6014         break;
       
  6015     case EVtUiCmdAdjustVideoContrast:
       
  6016         featureId = EVtUiFeatureIdContrast;
       
  6017         break;
       
  6018     case EVtUiCmdAdjustVideoColourTone:
       
  6019         featureId = EVtUiFeatureIdColourTone;
       
  6020         break;
       
  6021     default:
       
  6022         break;
       
  6023         }
       
  6024    MVtUiFeature* vb = iFeatureManager->GetFeatureById( featureId );
       
  6025    if ( vb )
       
  6026       {
       
  6027       __VTPRINT( DEBUG_GEN, "VtUi.CmdAdjustVideoL.StartL" );
       
  6028       vb->StartL();
       
  6029       }
       
  6030     __VTPRINTEXIT( "VtUi.CmdAdjustVideoL" )
       
  6031    }
       
  6032 
       
  6033 // -----------------------------------------------------------------------------
       
  6034 // CVtUiAppUi::AppUiInitDoneDoPostInitL
       
  6035 // -----------------------------------------------------------------------------
       
  6036 //
       
  6037  void CVtUiAppUi::AppUiInitDoneDoPostInitL()
       
  6038     {
       
  6039     MVtUiFeature* tb = iFeatureManager->GetFeatureById( EVtUiFeatureIdToolbar );
       
  6040     if ( tb )
       
  6041         {
       
  6042         if ( !iTbPeriodic )
       
  6043             {
       
  6044             iTbPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
  6045             }
       
  6046         iTbPeriodic->Cancel();
       
  6047         // try to strat toolbar feature immediately
       
  6048         iTbPeriodic->Start( 0, KPeriodTime, TCallBack( DoTryToStartTbL, this ) );
       
  6049         }
       
  6050     }
       
  6051 
       
  6052 // -----------------------------------------------------------------------------
       
  6053 // CVtUiAppUi::ProcessWsEventIfZoomModeIsActiveL
       
  6054 // -----------------------------------------------------------------------------
       
  6055 //
       
  6056 TBool CVtUiAppUi::ProcessWsEventIfZoomModeIsActiveL( const TWsEvent& aEvent )
       
  6057     {
       
  6058     __VTPRINTENTER( "VtUi.ProWsEvtIfZoomActivedL" )
       
  6059     const TInt type = aEvent.Type();
       
  6060     switch( type )
       
  6061         {
       
  6062         case EEventKey:
       
  6063         case EEventKeyUp:
       
  6064         case EEventKeyDown:
       
  6065             {
       
  6066             const TKeyEvent* keyEvent = aEvent.Key();
       
  6067 
       
  6068 
       
  6069             // Up and down arrow key events does the zooming,
       
  6070             // and should be forwarded to appui's key event handler.
       
  6071             // Also ETrue must be returned, so that other controls
       
  6072             // would not get these key events.
       
  6073             TEventCode eventCode = (TEventCode)aEvent.Type();
       
  6074             if ( keyEvent->iScanCode == EStdKeyUpArrow ||
       
  6075                 keyEvent->iScanCode == EStdKeyDownArrow ||
       
  6076                 keyEvent->iCode == EKeyZoomIn ||
       
  6077                 keyEvent->iCode == EKeyZoomOut )
       
  6078                 {
       
  6079                 HandleKeyEventL( *keyEvent, eventCode );
       
  6080                 __VTPRINTEXIT( "VtUi.ProWsEvtIfZoomActivedL" )
       
  6081                 return ETrue;
       
  6082                 }
       
  6083             __VTPRINT( DEBUG_GEN, "VtUi.HandleWsEventL zoom mode set" );
       
  6084             // If user selects zoom mode from options menu EEventKeyUp
       
  6085             // will be generated after that. Therefore this event must be
       
  6086             // ignored. Also EEventKeyDown are ignored. This means that
       
  6087             // only EEventKey events can dismiss the zoom mode.
       
  6088             if ( type != EEventKeyUp && type != EEventKeyDown )
       
  6089                 {
       
  6090                  // If zoom mode is on only zoom mode button is available in
       
  6091                  // toolbar. Pressing the zoom mode button in toolbar
       
  6092                  // should not dismiss the zoom mode, that is why this events
       
  6093                  // are ignored. If toolbar is not available and
       
  6094                  // also EKeyDevice3 (selection key) event should dismiss
       
  6095                  // the zoom mode.
       
  6096                  if ( keyEvent->iCode != EKeyDevice3 ||
       
  6097                      ( keyEvent->iCode == EKeyDevice3 &&
       
  6098                      !iUiStates->IsToolbarAvailable() ) )
       
  6099                     {
       
  6100                     __VTPRINT( DEBUG_GEN, "VtUi.ProWsEvtIfZoomActivedL.EKeyDevice3" );
       
  6101                     SetZoomModeL( EFalse );
       
  6102                     }
       
  6103                 }
       
  6104             }
       
  6105             break;
       
  6106 
       
  6107         case EEventPointer:
       
  6108             __VTPRINT( DEBUG_GEN, "VtUi.ProWsEvtIfZoomActivedL.EEventPointer" );
       
  6109             break;
       
  6110 
       
  6111         case KAknHardwareLayoutSwitch:
       
  6112             // Window server event used when layout changes
       
  6113             __VTPRINT( DEBUG_GEN, "VtUi.ProcessWsEventIfZoomModeIsActiveL.LayoutSwitch" );
       
  6114             break;
       
  6115 
       
  6116         case EEventScreenDeviceChanged:
       
  6117             // The screen size mode has changed, for instance when  the cover on a phone 
       
  6118             // that supports screen flipping is opened or closed. 
       
  6119             __VTPRINT( DEBUG_GEN, "VtUi.ProcessWsEventIfZoomModeIsActiveL.ScreenChanged" );
       
  6120             break;
       
  6121 
       
  6122 		case EVtUiWsEventNumberSourceDeactivate:
       
  6123             // Number source deactivated
       
  6124             __VTPRINT( DEBUG_GEN, "VtUi.ProWsEvtIfZoomActivedL.NumberDeactivate" );
       
  6125             break;
       
  6126 
       
  6127         default:
       
  6128             __VTPRINT( DEBUG_GEN, "VtUi.ProWsEvtIfZoomActivedL.default" );
       
  6129             // EVtUiWsEventNumberSourceActivate could be generated through number buttons
       
  6130             // and execution runs to default statement
       
  6131             SetZoomModeL( EFalse );
       
  6132             break;
       
  6133             }
       
  6134     __VTPRINTEXIT( "VtUi.ProWsEvtIfZoomActivedL2" )
       
  6135     return EFalse;
       
  6136     }
       
  6137 
       
  6138 // -----------------------------------------------------------------------------
       
  6139 // CVtUiAppUi::StopSliders()
       
  6140 // -----------------------------------------------------------------------------
       
  6141 //
       
  6142 void CVtUiAppUi::StopSliders()
       
  6143     {
       
  6144     __VTPRINTENTER( "VtUi.StopSliders" )
       
  6145     if( iUiStates->IsBrightnessModeOn() )
       
  6146         {
       
  6147         // if brightness feature is active, stop that
       
  6148         MVtUiFeature* br = iFeatureManager->GetFeatureById( EVtUiFeatureIdBrightness );
       
  6149         if ( br )
       
  6150             {
       
  6151             if ( br->State() ==  MVtUiFeature::EActive )
       
  6152                 {
       
  6153                 __VTPRINT( DEBUG_GEN, "VtUi.StopSliders br->STOP" )
       
  6154                 br->Stop();
       
  6155                 }
       
  6156             }	
       
  6157         }
       
  6158     // if contrast feature is active, stop that
       
  6159     if( iUiStates->IsContrastModeOn() )
       
  6160         {
       
  6161         // if contrast feature is active, stop that
       
  6162         MVtUiFeature* cr = iFeatureManager->GetFeatureById( EVtUiFeatureIdContrast );
       
  6163         if ( cr )
       
  6164             {
       
  6165             if ( cr->State() ==  MVtUiFeature::EActive )
       
  6166                 {
       
  6167                 __VTPRINT( DEBUG_GEN, "VtUi.StopSliders cr->STOP" )
       
  6168                 cr->Stop();
       
  6169                 }
       
  6170             }
       
  6171         }
       
  6172     // if volume feature is active, stop that
       
  6173     if( iUiStates->IsVolumeModeOn() )
       
  6174         {
       
  6175         // if volume feature is active, stop that
       
  6176         MVtUiFeature* vl = iFeatureManager->GetFeatureById( EVtUiFeatureIdVolume );
       
  6177         if ( vl )
       
  6178             {
       
  6179             if ( vl->State() ==  MVtUiFeature::EActive )
       
  6180                 {
       
  6181                 __VTPRINT( DEBUG_GEN, "VtUi.StopSliders vl->STOP" )
       
  6182                 vl->Stop();
       
  6183                 }
       
  6184             }
       
  6185         }
       
  6186     // if zoom feature is active, stop that
       
  6187     if( iUiStates->IsZoomModeOn() )
       
  6188         {
       
  6189         // if zoom feature is active, stop that
       
  6190         MVtUiFeature* zm = iFeatureManager->GetFeatureById( EVtUiFeatureIdZoom );
       
  6191         if ( zm )
       
  6192             {
       
  6193             if ( zm->State() ==  MVtUiFeature::EActive )
       
  6194                 {
       
  6195                 __VTPRINT( DEBUG_GEN, "VtUi.StopSliders zm->STOP" )
       
  6196                 zm->Stop();
       
  6197                 }
       
  6198             }
       
  6199         }   
       
  6200     __VTPRINTEXIT( "VtUi.StopSliders" )
       
  6201     }
       
  6202 
       
  6203 // -----------------------------------------------------------------------------
       
  6204 // CVtUiAppUi::CanSwapImagePlaces()
       
  6205 // -----------------------------------------------------------------------------
       
  6206 //
       
  6207 TBool CVtUiAppUi::CanSwapImagePlaces()
       
  6208     {
       
  6209     __VTPRINTENTER( "VtUi.CanSwapImagePlaces" )
       
  6210     TTime now; 
       
  6211     now.HomeTime();
       
  6212     // User can swap image places if the frequency is lower than maximum frequency. 
       
  6213     if ( now.MicroSecondsFrom( iLastSwapTime ).Int64() >= KVtUiMaxSwapImagesFreq ) 
       
  6214         {
       
  6215         __VTPRINT( DEBUG_GEN, "VtUi.Swap can swap image" )
       
  6216         iLastSwapTime = now;  
       
  6217         return ETrue;
       
  6218         }
       
  6219     else
       
  6220         {
       
  6221         __VTPRINT( DEBUG_GEN, "VtUi.Swap can not swap image" )
       
  6222         return EFalse;
       
  6223         }
       
  6224     __VTPRINTEXIT( "VtUi.CanSwapImagePlaces" )
       
  6225     }
       
  6226 
       
  6227 // Implementation of CVtUiAppUi::CInstance
       
  6228 
       
  6229 // -----------------------------------------------------------------------------
       
  6230 // CVtUiAppUi::CInstance::CInstance
       
  6231 // -----------------------------------------------------------------------------
       
  6232 //
       
  6233 CVtUiAppUi::CInstance::CInstance( CVtUiAppUi& aAppUi )
       
  6234     : iAppUi( aAppUi )
       
  6235     {
       
  6236     }
       
  6237 
       
  6238 void CVtUiAppUi::CInstance::CreateRemoteVideoControl()
       
  6239     {    
       
  6240     iRemoteVideoControl = CVtUiRemoteVideoControl::NewL( iAppUi );
       
  6241     iRemoteVideoControl->MakeVisible(EFalse);
       
  6242     iMainControl->SetRemoteVideoControl( iRemoteVideoControl );
       
  6243     iMainControl->LayoutRemoteVideo();
       
  6244     
       
  6245     iAppUi.AddToStackL( iRemoteVideoControl );
       
  6246     
       
  6247     iRemoteVideoControlInStack = ETrue;
       
  6248     
       
  6249     }
       
  6250 
       
  6251 // -----------------------------------------------------------------------------
       
  6252 // CVtUiAppUi::CInstance::ConstructL
       
  6253 // -----------------------------------------------------------------------------
       
  6254 //
       
  6255 void CVtUiAppUi::CInstance::ConstructL()
       
  6256     {
       
  6257     iBitmapManager = new ( ELeave ) CVtUiBitmapManager;
       
  6258 
       
  6259     TRect parent;
       
  6260     TAknWindowLineLayout control;
       
  6261 
       
  6262     VtUiLayout::GetApplicationParentRect( parent );
       
  6263     iMainControl = CVtUiMainControl::NewL( *iBitmapManager,
       
  6264          *iAppUi.iUiStates  );
       
  6265 
       
  6266     VtUiLayout::GetMainPaneLayout( control );
       
  6267     AknLayoutUtils::LayoutControl( iMainControl, parent, control );
       
  6268 
       
  6269     iAppUi.AddToStackL( iMainControl );
       
  6270     iMainControlInStack = ETrue;
       
  6271 
       
  6272     TAknLayoutRect layout;
       
  6273     layout.LayoutRect( parent, control );
       
  6274     iNumberEntryActivation =
       
  6275         new ( ELeave ) CVtUiNumberEntryActivationControl( iAppUi );
       
  6276     iNumberEntryActivation->ConstructL( layout.Rect() );
       
  6277 
       
  6278     iContextControl = CVtUiContextControl::NewL(
       
  6279             *iBitmapManager,
       
  6280             iAppUi,
       
  6281             *iAppUi.iUiStates );
       
  6282 
       
  6283     VtUiLayout::GetFirstWindowBackgroundLayout(
       
  6284         control );
       
  6285     AknLayoutUtils::LayoutControl( iContextControl, parent, control );
       
  6286     iAppUi.AddToStackL( iContextControl );
       
  6287     iContextControlInStack = ETrue;
       
  6288 
       
  6289     iNaviPane =
       
  6290         CVtUiNaviPane::NewL(
       
  6291             *( iAppUi.NaviPaneL() ),
       
  6292             iAppUi );
       
  6293 
       
  6294     }
       
  6295 
       
  6296 // -----------------------------------------------------------------------------
       
  6297 // CVtUiAppUi::CInstance::LayoutChanged
       
  6298 // -----------------------------------------------------------------------------
       
  6299 //
       
  6300 void CVtUiAppUi::CInstance::LayoutChanged()
       
  6301     {
       
  6302     // Layout controls.
       
  6303     TRect parent;
       
  6304     TAknWindowLineLayout control;
       
  6305     VtUiLayout::GetApplicationParentRect( parent );
       
  6306     VtUiLayout::GetMainPaneLayout( control );
       
  6307     AknLayoutUtils::LayoutControl( iMainControl, parent, control );
       
  6308     if(iMainControl)
       
  6309         iMainControl->LayoutRemoteVideo();
       
  6310     AknLayoutUtils::LayoutControl( iNumberEntryActivation, parent, control );
       
  6311     VtUiLayout::GetFirstWindowBackgroundLayout( control );
       
  6312     AknLayoutUtils::LayoutControl( iContextControl, parent, control );
       
  6313     if(iContextControl)
       
  6314         iContextControl->LayoutRemoteVideo();
       
  6315     
       
  6316     }
       
  6317 
       
  6318 // -----------------------------------------------------------------------------
       
  6319 // CVtUiAppUi::CInstance::VolumeKeyPressedL
       
  6320 // -----------------------------------------------------------------------------
       
  6321 //
       
  6322 void CVtUiAppUi::CInstance::VolumeKeyPressedL()
       
  6323     {
       
  6324     __VTPRINTENTER( "CVtUiAppUi.VolumeKeyPressedL" )
       
  6325     // if the application is in foreground show volume sliders
       
  6326     if ( iAppUi.IsForeground() )
       
  6327         {
       
  6328         // If application is shutting down, no need to show volume popup
       
  6329         if ( iAppUi.iState == NULL ||
       
  6330              iAppUi.iState ==
       
  6331                 TVtUiStateResetting::InstanceL( iAppUi, *iAppUi.iUiStates ) )
       
  6332             {
       
  6333             return;
       
  6334             }
       
  6335 
       
  6336         CVtUiVolume* volume = static_cast< CVtUiVolume* >(
       
  6337             iAppUi.iFeatureManager->GetFeatureById( EVtUiFeatureIdVolume ) );
       
  6338         if ( volume )
       
  6339             {
       
  6340             // If the capture mode is on we should
       
  6341             // end the capture mode
       
  6342             if( iAppUi.iUiStates->IsCaptureModeOn() )
       
  6343                 {
       
  6344                 iAppUi.CmdCancelCaptureL();
       
  6345                 }
       
  6346             volume->StartL();
       
  6347             }
       
  6348         }
       
  6349     __VTPRINTEXIT( "CVtUiAppUi.VolumeKeyPressedL" )
       
  6350     }
       
  6351 
       
  6352 // -----------------------------------------------------------------------------
       
  6353 // CVtUiAppUi::CInstance::NewL
       
  6354 // -----------------------------------------------------------------------------
       
  6355 //
       
  6356 CVtUiAppUi::CInstance* CVtUiAppUi::CInstance::NewL( CVtUiAppUi& aAppUi )
       
  6357     {
       
  6358     CInstance* self = new ( ELeave ) CInstance( aAppUi );
       
  6359     CleanupStack::PushL( self );
       
  6360     self->ConstructL();
       
  6361     CleanupStack::Pop( self );
       
  6362 
       
  6363     return self;
       
  6364     }
       
  6365 
       
  6366 // -----------------------------------------------------------------------------
       
  6367 // CVtUiAppUi::CInstance::~CInstance
       
  6368 // -----------------------------------------------------------------------------
       
  6369 //
       
  6370 CVtUiAppUi::CInstance::~CInstance()
       
  6371     {
       
  6372     if ( iMainControl && iMainControlInStack )
       
  6373         {
       
  6374         iAppUi.RemoveFromStack( iMainControl );
       
  6375         }
       
  6376     if ( iContextControl && iContextControlInStack )
       
  6377         {
       
  6378         iAppUi.RemoveFromStack( iContextControl );
       
  6379         }
       
  6380     if(iRemoteVideoControl &&iRemoteVideoControlInStack)
       
  6381         {
       
  6382         iAppUi.RemoveFromStack( iRemoteVideoControl );
       
  6383         }
       
  6384     delete iMainControl;
       
  6385     delete iContextControl;
       
  6386     delete iRemoteVideoControl;
       
  6387     delete iNumberEntryActivation;
       
  6388     delete iNaviPane;
       
  6389     delete iBitmapManager;
       
  6390     }
       
  6391 
       
  6392 // Implementation of CVtUiAppUi::CEventObserver
       
  6393 
       
  6394 // -----------------------------------------------------------------------------
       
  6395 // CVtUiAppUi::CEventObserver::CEventObserver
       
  6396 // -----------------------------------------------------------------------------
       
  6397 //
       
  6398 CVtUiAppUi::CEventObserver::CEventObserver( CVtUiAppUi& aAppUi )
       
  6399     : iAppUi( aAppUi ),
       
  6400       iCommandObservers( KVtUiCommandObserverArrayGranularity )
       
  6401     {
       
  6402     }
       
  6403 
       
  6404 // -----------------------------------------------------------------------------
       
  6405 // CVtUiAppUi::CEventObserver::ConstructL
       
  6406 // -----------------------------------------------------------------------------
       
  6407 //
       
  6408 void CVtUiAppUi::CEventObserver::ConstructL()
       
  6409     {
       
  6410     iModel = CVtEngModel::NewL( *this, *this );
       
  6411 
       
  6412     }
       
  6413 
       
  6414 // -----------------------------------------------------------------------------
       
  6415 // CVtUiAppUi::CEventObserver::NewL
       
  6416 // -----------------------------------------------------------------------------
       
  6417 //
       
  6418 CVtUiAppUi::CEventObserver* CVtUiAppUi::CEventObserver::NewL(
       
  6419         CVtUiAppUi& aAppUi )
       
  6420     {
       
  6421     CEventObserver* self = new ( ELeave ) CEventObserver( aAppUi );
       
  6422     CleanupStack::PushL( self );
       
  6423     self->ConstructL();
       
  6424     CleanupStack::Pop( self );
       
  6425     return self;
       
  6426     }
       
  6427 
       
  6428 // -----------------------------------------------------------------------------
       
  6429 // CVtUiAppUi::CEventObserver::~CEventObserver
       
  6430 // -----------------------------------------------------------------------------
       
  6431 //
       
  6432 CVtUiAppUi::CEventObserver::~CEventObserver()
       
  6433     {
       
  6434     iCommandObservers.Close();
       
  6435 
       
  6436     delete iModel;
       
  6437     delete iBeat;
       
  6438 
       
  6439     delete iRemConInterfaceSelector;
       
  6440     iRemConCoreApiTarget = NULL; // not owned.
       
  6441     }
       
  6442 
       
  6443 // -----------------------------------------------------------------------------
       
  6444 // CVtUiAppUi::CEventObserver::Model
       
  6445 // -----------------------------------------------------------------------------
       
  6446 //
       
  6447 inline CVtEngModel& CVtUiAppUi::CEventObserver::Model()
       
  6448     {
       
  6449     return *iModel;
       
  6450     }
       
  6451 
       
  6452 // -----------------------------------------------------------------------------
       
  6453 // CVtUiAppUi::CEventObserver::CreateRemConSessionL
       
  6454 // -----------------------------------------------------------------------------
       
  6455 //
       
  6456 void CVtUiAppUi::CEventObserver::CreateRemConSessionL()
       
  6457     {
       
  6458     __VTPRINTENTER( "VtUiComms.CreateRemCon" )
       
  6459     // If one of the iRemCon* pointers equals to NULL, then all of them are
       
  6460     // NULL.
       
  6461     if ( !iRemConInterfaceSelector )
       
  6462         {
       
  6463         CRemConInterfaceSelector* interfaceSelector =
       
  6464             CRemConInterfaceSelector::NewL();
       
  6465         CleanupStack::PushL( interfaceSelector );
       
  6466 
       
  6467         CRemConCoreApiTarget* coreApiTarget =
       
  6468             CRemConCoreApiTarget::NewL( *interfaceSelector, *this );
       
  6469         // The coreApiTarget instance is owned by interfaceSelector instance.
       
  6470         // This instance must implement MRemConCoreApiTargetObserver interface.
       
  6471         CleanupStack::PushL( coreApiTarget );
       
  6472         interfaceSelector->OpenTargetL();
       
  6473 
       
  6474         iRemConVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityHigh );
       
  6475 
       
  6476         CleanupStack::Pop( coreApiTarget );
       
  6477         CleanupStack::Pop( interfaceSelector );
       
  6478 
       
  6479         iRemConInterfaceSelector = interfaceSelector;
       
  6480         iRemConCoreApiTarget = coreApiTarget;
       
  6481         }
       
  6482     __VTPRINTEXIT( "VtUiComms.CreateRemCon" )
       
  6483     }
       
  6484 
       
  6485 // -----------------------------------------------------------------------------
       
  6486 // CVtUiAppUi::CEventObserver::DeleteRemConSession
       
  6487 // -----------------------------------------------------------------------------
       
  6488 //
       
  6489 void CVtUiAppUi::CEventObserver::DeleteRemConSession()
       
  6490     {
       
  6491     delete iRemConVolumeRepeatTimer;
       
  6492     iRemConVolumeRepeatTimer = NULL;
       
  6493 
       
  6494     delete iRemConInterfaceSelector;
       
  6495     iRemConInterfaceSelector = NULL;
       
  6496 
       
  6497     iRemConCoreApiTarget = NULL; // not owned.
       
  6498     }
       
  6499 
       
  6500 // -----------------------------------------------------------------------------
       
  6501 // CVtUiAppUi::CEventObserver::CommandSupported
       
  6502 // -----------------------------------------------------------------------------
       
  6503 //
       
  6504 TBool CVtUiAppUi::CEventObserver::CommandSupported(
       
  6505         const TInt aCommandId ) const
       
  6506     {
       
  6507     const TInt caps = iModel->CommandHandler().GetCommandCaps( aCommandId );
       
  6508     return
       
  6509         ( caps >= KErrNone ) &&
       
  6510         ( caps & MVtEngCommandHandler::EAttribSupported );
       
  6511     }
       
  6512 
       
  6513 // -----------------------------------------------------------------------------
       
  6514 // CVtUiAppUi::CEventObserver::CommandSupportedAndSynchronous
       
  6515 // -----------------------------------------------------------------------------
       
  6516 //
       
  6517 TBool CVtUiAppUi::CEventObserver::CommandSupportedAndSynchronous(
       
  6518         const TInt aCommandId ) const
       
  6519     {
       
  6520     const TInt caps = iModel->CommandHandler().GetCommandCaps( aCommandId );
       
  6521     return
       
  6522         ( caps >= KErrNone ) &&
       
  6523         ( caps & MVtEngCommandHandler::EAttribSupported ) &&
       
  6524         ( ~caps & MVtEngCommandHandler::EAttribAsync );
       
  6525     }
       
  6526 
       
  6527 // -----------------------------------------------------------------------------
       
  6528 // CVtUiAppUi::CEventObserver::AddObserverL
       
  6529 // -----------------------------------------------------------------------------
       
  6530 //
       
  6531 void CVtUiAppUi::CEventObserver::AddObserverL(
       
  6532         MVtEngCommandObserver& aObserver )
       
  6533     {
       
  6534     User::LeaveIfError(
       
  6535         iCommandObservers.Append( &aObserver ) );
       
  6536     }
       
  6537 
       
  6538 // -----------------------------------------------------------------------------
       
  6539 // CVtUiAppUi::CEventObserver::RemoveObserver
       
  6540 // -----------------------------------------------------------------------------
       
  6541 //
       
  6542 void CVtUiAppUi::CEventObserver::RemoveObserver(
       
  6543         MVtEngCommandObserver& aObserver )
       
  6544     {
       
  6545     const TInt pos = iCommandObservers.Find( &aObserver );
       
  6546     if ( pos != KErrNotFound )
       
  6547         {
       
  6548         if ( !iInCommandPerformed )
       
  6549             {
       
  6550             iCommandObservers.Remove( pos );
       
  6551             }
       
  6552         else
       
  6553             {
       
  6554             iCommandObservers[ pos ] = NULL;
       
  6555             }
       
  6556         }
       
  6557     }
       
  6558 
       
  6559 // -----------------------------------------------------------------------------
       
  6560 // CVtUiAppUi::CEventObserver::StartBeatL
       
  6561 // -----------------------------------------------------------------------------
       
  6562 //
       
  6563 void CVtUiAppUi::CEventObserver::StartBeatL()
       
  6564     {
       
  6565     if ( !iBeat )
       
  6566         {
       
  6567         iBeat = CHeartbeat::NewL( CActive::EPriorityStandard );
       
  6568         }
       
  6569 
       
  6570     if ( !iBeat->IsActive() )
       
  6571         {
       
  6572         iBeat->Start( ETwelveOClock, this );
       
  6573         }
       
  6574     }
       
  6575 
       
  6576 // -----------------------------------------------------------------------------
       
  6577 // CVtUiAppUi::CEventObserver::StopBeat
       
  6578 // -----------------------------------------------------------------------------
       
  6579 //
       
  6580 void CVtUiAppUi::CEventObserver::StopBeat()
       
  6581     {
       
  6582     delete iBeat;
       
  6583     iBeat = NULL;
       
  6584     }
       
  6585 
       
  6586 // -----------------------------------------------------------------------------
       
  6587 // CVtUiAppUi::CEventObserver::StopVolumeRepeatTimer
       
  6588 // -----------------------------------------------------------------------------
       
  6589 //
       
  6590 void CVtUiAppUi::CEventObserver::StopVolumeRepeatTimer()
       
  6591     {
       
  6592     iRemConVolumeRepeatTimer->Cancel();
       
  6593     }
       
  6594 
       
  6595 // -----------------------------------------------------------------------------
       
  6596 // CVtUiAppUi::CEventObserver::HandleVtEventL
       
  6597 // -----------------------------------------------------------------------------
       
  6598 //
       
  6599 void CVtUiAppUi::CEventObserver::HandleVtEventL(
       
  6600         TInt aEvent )
       
  6601     {
       
  6602     __VTPRINTENTER( "VtUiComms.HandleVtEventL" )
       
  6603     __VTPRINT2( DEBUG_GEN, "VtUi.HandleEvt=%d", aEvent )
       
  6604 
       
  6605     /** Allow application state to handle event first. It may also deny further
       
  6606       * handling by indicating the event was handled */
       
  6607     if ( iAppUi.iState &&
       
  6608         iAppUi.iState->HandleVtEventL( aEvent )
       
  6609             == TVtUiAppStateBase::EEventHandled )
       
  6610         {
       
  6611         __VTPRINTEXITR( "VtUiComms.HandleVtEventL %d", 0 )
       
  6612         return;
       
  6613         }
       
  6614 
       
  6615     TInt callBits = EVtUiRefreshStates;
       
  6616 
       
  6617     // New camera orientation
       
  6618     switch( aEvent )
       
  6619         {
       
  6620         case KVtEngSourceChanged:
       
  6621             callBits |= EVtUiSetOrientation;
       
  6622             break;
       
  6623         default:
       
  6624             break;
       
  6625         }
       
  6626         
       
  6627     switch( aEvent )
       
  6628         {
       
  6629         case KVtEngSourceChanged:
       
  6630             callBits |= EVtUiStopWBOrColortone;
       
  6631             break;
       
  6632         default:
       
  6633             break;
       
  6634         }
       
  6635     
       
  6636     switch( aEvent )
       
  6637         {
       
  6638         case KVtEngSessionWaitingCallActive:
       
  6639         case KVtEngSessionWaitingCallInactive:
       
  6640         	iAppUi.HandleWaitingStateChange(
       
  6641         		aEvent == KVtEngSessionWaitingCallActive );
       
  6642 	        break;
       
  6643         default:
       
  6644             break;
       
  6645         }
       
  6646     switch( aEvent )
       
  6647         {
       
  6648         case KVtEngShareImageInitializeBegin:
       
  6649             callBits |= EVtUiShowImageInitializingProgress;
       
  6650             break;
       
  6651 
       
  6652         case KVtEngShareImageInitializeEnd:
       
  6653             callBits |= EVtUiHideImageInitializingProgress;
       
  6654             break;
       
  6655 
       
  6656         case KVtEngShareImageDecodingError:
       
  6657             callBits |= EVtUiShowDecodingError;
       
  6658             break;
       
  6659 
       
  6660         default:
       
  6661             break;
       
  6662         }
       
  6663 
       
  6664     // Handle rendering problems.
       
  6665     switch ( aEvent )
       
  6666         {
       
  6667         case KVtEngRemoteRenderingProblem:
       
  6668             callBits |= EVtUiHandleVideoFrameRemoteProblem;
       
  6669             break;
       
  6670 
       
  6671         case KVtEngViewFinderStopped:
       
  6672         case KVtEngLocalRenderingProblem:
       
  6673             callBits |= EVtUiHandleVideoFrameLocalProblem;
       
  6674             break;
       
  6675 
       
  6676         default:
       
  6677             break;
       
  6678         }
       
  6679 
       
  6680     // Refresh navipane.
       
  6681     switch ( aEvent )
       
  6682         {
       
  6683         case KVtEngSourceChanged:
       
  6684         case KVtEngCameraChanged:
       
  6685         case KVtEngSessionStateChanged:
       
  6686         case KVtEngDurationSettingChanged:
       
  6687         case KVtEngAudioOutputVolumeChanged:
       
  6688         case KVtEngAudioRoutingChanged:
       
  6689         case KVtEngAudioMuted:
       
  6690         case KVtEngAudioUnmuted:
       
  6691             callBits |= EVtUiRefreshNaviPane;
       
  6692             break;
       
  6693 
       
  6694         default:
       
  6695             break;
       
  6696         }
       
  6697 
       
  6698     // Refresh softkeys.
       
  6699     switch ( aEvent )
       
  6700         {
       
  6701         case KVtEngSourceChanged:
       
  6702         case KVtEngSourceCapsChanged:
       
  6703         case KVtEngSessionAnswerPossible:
       
  6704         case KVtEngSessionStateChanged:
       
  6705         case KVtEngAudioRoutingChanged:
       
  6706         case KVtEngAudioRoutingAvailabilityChanged:
       
  6707         case KVtEngAudioMuted:
       
  6708         case KVtEngAudioUnmuted:
       
  6709         case KVtEngLCHProviderSwitchDone:
       
  6710             callBits |= EVtUiRefreshSoftkeys;
       
  6711             break;
       
  6712 
       
  6713         default:
       
  6714             break;
       
  6715         }
       
  6716 
       
  6717     // Refresh blind status
       
  6718     switch ( aEvent )
       
  6719         {
       
  6720         case KVtEngSourceChanged:
       
  6721         case KVtEngRemoteVideoPaused:
       
  6722         case KVtEngRemoteVideoResumed:
       
  6723         case KVtEngRemoteVideoStarted:
       
  6724         case KVtEngRemoteVideoStopped:
       
  6725         case KVtEngLCHProviderSwitchDone:
       
  6726             callBits |= EVtUiRefreshBlind;
       
  6727             break;
       
  6728 
       
  6729         default:
       
  6730             break;
       
  6731         }
       
  6732 
       
  6733     // Check if it's required to stop "waiting image" display.
       
  6734     switch ( aEvent )
       
  6735         {
       
  6736         case KVtEngRemoteVideoResumed:
       
  6737         case KVtEngRemoteVideoStarted:
       
  6738             callBits |= EVtUiStopWaitingImage;
       
  6739             break;
       
  6740 
       
  6741         default:
       
  6742             break;
       
  6743         }
       
  6744 
       
  6745     // Check if it is needed to set a new layout for remote renderer.
       
  6746     switch ( aEvent )
       
  6747         {
       
  6748         case KVtEngResolutionToQCIF:
       
  6749             callBits |= EVtUiChangeRemoteVideoLayout;
       
  6750             iAppUi.RemoteVideoIsSQCif( EFalse );
       
  6751             break;
       
  6752         case KVtEngResolutionToSQCIF:
       
  6753             callBits |= EVtUiChangeRemoteVideoLayout;
       
  6754             iAppUi.RemoteVideoIsSQCif( ETrue );
       
  6755             break;
       
  6756         default:
       
  6757             break;
       
  6758         }
       
  6759 
       
  6760     switch ( aEvent )
       
  6761         {
       
  6762         case KVtEngAudioRoutingChanged:
       
  6763         case KVtEngAudioRoutingAvailabilityChanged:
       
  6764         case KVtEngMediaOutgoingVideoChannelStatusChanged:
       
  6765         case KVtEngMediaOutgoingAudioChannelStatusChanged:
       
  6766              callBits |= EVtUiMediaStateChanged;
       
  6767             break;
       
  6768 
       
  6769         case KVtEngAudioVolumeMin:
       
  6770             iAppUi.KeySounds()->PlaySound( EAvkonSIDVolumeMinTone );
       
  6771             break;
       
  6772 
       
  6773        case KVtEngAudioVolumeMax:
       
  6774             iAppUi.KeySounds()->PlaySound( EAvkonSIDVolumeMaxTone );
       
  6775             break;
       
  6776 
       
  6777         default:
       
  6778             break;
       
  6779         }
       
  6780     
       
  6781     // Refresh Menu.
       
  6782     switch ( aEvent )
       
  6783         {
       
  6784         case KVtEngSourceChanged:
       
  6785             callBits |= EVtUiRefreshMenu;
       
  6786             callBits |= EVtUiStopBrightnessOrContrast;
       
  6787             callBits |= EVtUiRefreshZoomPopup;
       
  6788             break;
       
  6789         default:
       
  6790             break;
       
  6791         }
       
  6792 
       
  6793     TRAP_IGNORE ( DoExecuteL( callBits ) );
       
  6794     __VTPRINTEXITR( "VtUiComms.HandleVtEventL %d", 1 )
       
  6795     }
       
  6796 
       
  6797 // -----------------------------------------------------------------------------
       
  6798 // CVtUiAppUi::CEventObserver::HandleVTCommandPerformedL
       
  6799 // -----------------------------------------------------------------------------
       
  6800 //
       
  6801 void CVtUiAppUi::CEventObserver::HandleVTCommandPerformedL(
       
  6802         TVtEngCommandId aCommand,
       
  6803         const TInt aError )
       
  6804     {
       
  6805     __VTPRINTENTER( "VtUiComms.HandleVTCommandPerformedL" )
       
  6806 
       
  6807     if ( iAppUi.iState &&
       
  6808          iAppUi.iState->HandleVTCommandPerformedL( aCommand, aError ) ==
       
  6809          TVtUiAppStateBase::EEventHandled )
       
  6810         {
       
  6811         // state didn't allow further processing of command completion
       
  6812         __VTPRINTEXITR( "VtUiComms.HandleVTCommandPerformedL %d", 0 )
       
  6813         return;
       
  6814         }
       
  6815     iAppUi.RefreshStatesL();
       
  6816 
       
  6817     if ( aCommand == KVtEngMuteOutgoingAudio ||
       
  6818          aCommand == KVtEngUnmuteOutgoingAudio )
       
  6819          {
       
  6820          iAppUi.RefreshL();
       
  6821          }
       
  6822 
       
  6823     const TInt count = iCommandObservers.Count();
       
  6824     TInt nullPosition = KErrNotFound;
       
  6825 
       
  6826     iInCommandPerformed = ETrue;
       
  6827 
       
  6828     // iInCommandPerformed equals ETrue while inside the following loop;
       
  6829     // Exceptions must not be raised.
       
  6830     for ( TInt index = 0; index < count; index++ )
       
  6831         {
       
  6832         MVtEngCommandObserver* obs = iCommandObservers[ index ];
       
  6833         if ( obs )
       
  6834             {
       
  6835             TRAP_IGNORE( obs->HandleVTCommandPerformedL( aCommand, aError ) );
       
  6836             }
       
  6837         else
       
  6838             {
       
  6839             // We store only one position; eventually all NULL elements of the
       
  6840             // array will be removed.
       
  6841             nullPosition = index;
       
  6842             }
       
  6843         }
       
  6844     iInCommandPerformed = EFalse;
       
  6845 
       
  6846     if ( nullPosition != KErrNotFound )
       
  6847         {
       
  6848         iCommandObservers.Remove( nullPosition );
       
  6849         }
       
  6850 
       
  6851     // Specific handling of some commands:
       
  6852     if ( aCommand == KVtEngResetEngine ) // Engine has been reset
       
  6853         {
       
  6854         __ASSERT_ALWAYS( !aError, VtUiPanic::Panic( EVtUiPanicResetFailed ) );
       
  6855         iAppUi.HandleEngineResetL();
       
  6856         }
       
  6857     else if ( ( aCommand == KVtEngInitializeShareImage ) ||
       
  6858               ( aCommand == KVtEngStartShareImage ) )
       
  6859         {
       
  6860         __VTPRINT3( DEBUG_GEN,
       
  6861             "VtUi.HandleVTCommandPerformedL cmd=%d err=%d", aCommand, aError );
       
  6862         if( aError != KErrNone )
       
  6863             {
       
  6864             // stop toolbar feature to prevent drawing over error dialog
       
  6865            MVtUiFeature* tb = iAppUi.iFeatureManager->
       
  6866            GetFeatureById( EVtUiFeatureIdToolbar );
       
  6867             if ( tb )
       
  6868                 {
       
  6869                 tb->Stop();
       
  6870                 }
       
  6871             iAppUi.iAsyncCallback->Set(
       
  6872                 TCallBack( &AsyncShowErrorAndRestartShare, &iAppUi ) );
       
  6873             iAppUi.iAsyncCallback->CallBack();
       
  6874             }
       
  6875         else if( aCommand == KVtEngInitializeShareImage )
       
  6876             {
       
  6877             if ( iAppUi.iUiStates->IsViewFinderToMainPane()  )
       
  6878                 {
       
  6879                 iAppUi.iAsyncCallback->Set(
       
  6880                     TCallBack( &AsyncViewFinderToMainPaneAndShare, &iAppUi ) );
       
  6881                 }
       
  6882             else
       
  6883                 {
       
  6884                 iAppUi.iAsyncCallback->Set(
       
  6885                     TCallBack( &AsyncShare, &iAppUi ) );
       
  6886                 }
       
  6887             iAppUi.iAsyncCallback->CallBack();
       
  6888             }
       
  6889         }
       
  6890     else if ( iAppUi.iUiStates->IsLayoutChangeNeeded() && 
       
  6891             ( aCommand  == KVtEngMuteOutgoingAudio || 
       
  6892             aCommand  == KVtEngUnmuteOutgoingAudio ||
       
  6893             aCommand  == KVtEngSetAudioRouting ||
       
  6894             aCommand  == KVtEngSetAudioVolume ||
       
  6895             aCommand  == KVtEngSetSource ||
       
  6896             aCommand  == KVtEngPrepareCamera ||
       
  6897             aCommand  == KVtEngUnfreeze ) )
       
  6898         {
       
  6899         iAppUi.iUiStates->SetLayoutChangeNeeded( EFalse );
       
  6900         iAppUi.DoHandleLayoutChangedL();
       
  6901         }
       
  6902     __VTPRINTEXITR( "VtUiComms.HandleVTCommandPerformedL %d", 1 )
       
  6903     }
       
  6904 
       
  6905 // -----------------------------------------------------------------------------
       
  6906 // CVtUiAppUi::CEventObserver::vtHandleFrameL
       
  6907 // -----------------------------------------------------------------------------
       
  6908 //
       
  6909 void CVtUiAppUi::CEventObserver::vtHandleFrameL(
       
  6910         TFrameType aType,
       
  6911         CFbsBitmap* aBitmap )
       
  6912     {
       
  6913     static TUint32 lastTick = 0;
       
  6914     static TBool flag = EFalse;
       
  6915             
       
  6916         
       
  6917     CEikMenuBar* menuBar = (STATIC_CAST(CEikonEnv*, this->iAppUi.iCoeEnv))->AppUiFactory()->MenuBar();
       
  6918     if ( menuBar && menuBar->IsDisplayed() )
       
  6919          {
       
  6920          if ( !flag )
       
  6921             {
       
  6922             flag = ETrue;
       
  6923             lastTick = User::NTickCount();
       
  6924             }
       
  6925          else
       
  6926             {
       
  6927             TUint32 newTick = User::NTickCount();
       
  6928 
       
  6929             //don't consider time wrap
       
  6930             //one frame per 200ms
       
  6931             if ( newTick - lastTick < 400 )
       
  6932                 {
       
  6933                 __VTPRINTEXITR( "CVtUiAppUi::CEventObserver::vtSetFrame %d", 0 )
       
  6934                 return;
       
  6935                 }
       
  6936             else
       
  6937                 {
       
  6938                 lastTick = newTick;
       
  6939                 }
       
  6940             }
       
  6941          }
       
  6942     else
       
  6943         {
       
  6944         flag = EFalse;
       
  6945         }
       
  6946     	
       
  6947     TBool local = EFalse;
       
  6948     switch ( aType )
       
  6949         {
       
  6950         case ELocalVideoFrame:
       
  6951             local = ETrue;
       
  6952             break;
       
  6953 
       
  6954         case ERemoteVideoFrame:
       
  6955         default:
       
  6956             break;
       
  6957         }
       
  6958 
       
  6959     iAppUi.HandleVideoFrameL( local, aBitmap );
       
  6960     }
       
  6961 
       
  6962 // -----------------------------------------------------------------------------
       
  6963 // CVtUiAppUi::CEventObserver::vtSetFrame
       
  6964 // -----------------------------------------------------------------------------
       
  6965 //
       
  6966 void CVtUiAppUi::CEventObserver::vtSetFrame(
       
  6967         TFrameType aType,
       
  6968         CFbsBitmap* aBitmap )
       
  6969     {
       
  6970     TBool local = EFalse;
       
  6971     switch ( aType )
       
  6972         {
       
  6973         case ELocalVideoFrame:
       
  6974             local = ETrue;
       
  6975             break;
       
  6976 
       
  6977         case ERemoteVideoFrame:
       
  6978         default:
       
  6979             break;
       
  6980         }
       
  6981 
       
  6982     iAppUi.SetVideoFrame( local, aBitmap );
       
  6983     }
       
  6984 
       
  6985 // -----------------------------------------------------------------------------
       
  6986 // CVtUiAppUi::CEventObserver::Beat
       
  6987 // -----------------------------------------------------------------------------
       
  6988 //
       
  6989 void CVtUiAppUi::CEventObserver::Beat()
       
  6990     {
       
  6991     iAppUi.HandleBeat();
       
  6992     }
       
  6993 
       
  6994 // -----------------------------------------------------------------------------
       
  6995 // CVtUiAppUi::CEventObserver::Synchronize
       
  6996 // -----------------------------------------------------------------------------
       
  6997 //
       
  6998 void CVtUiAppUi::CEventObserver::Synchronize()
       
  6999     {
       
  7000     iAppUi.HandleBeat();
       
  7001     }
       
  7002 
       
  7003 // -----------------------------------------------------------------------------
       
  7004 // CVtUiAppUi::CEventObserver::DoExecuteL
       
  7005 // -----------------------------------------------------------------------------
       
  7006 //
       
  7007 void CVtUiAppUi::CEventObserver::DoExecuteL( TInt aBits )
       
  7008     {
       
  7009     __VTPRINT2( DEBUG_GEN, "VtUi.DoExec.bits=%d", aBits )
       
  7010 
       
  7011     // Array of methods - leaving methods are allowed.
       
  7012     const TMethodL methodArray[] =
       
  7013         {
       
  7014         &CVtUiAppUi::RefreshStatesL,
       
  7015         &CVtUiAppUi::HandleVideoFrameRemoteProblemL,
       
  7016         &CVtUiAppUi::HandleVideoFrameLocalProblemL,
       
  7017         &CVtUiAppUi::RefreshNaviPaneL,
       
  7018         &CVtUiAppUi::RefreshSoftkeysL,
       
  7019         &CVtUiAppUi::RefreshBlind,
       
  7020         &CVtUiAppUi::StopWaitingImage,
       
  7021         &CVtUiAppUi::ChangeRemoteVideoLayoutL,
       
  7022         &CVtUiAppUi::ShowImageInitializeProgressL,
       
  7023         &CVtUiAppUi::HideImageInitializeProgressL,
       
  7024         &CVtUiAppUi::SetCameraOrientationL,
       
  7025         &CVtUiAppUi::MediaStateChangedL,
       
  7026         &CVtUiAppUi::ShowImageDecodingErrorNoteL,
       
  7027         &CVtUiAppUi::StopWhiteBalanceOrColortone,
       
  7028         &CVtUiAppUi::RefreshMenuL,
       
  7029         &CVtUiAppUi::StopBrightnessOrContrast,
       
  7030         &CVtUiAppUi::RefreshZoomPopupL
       
  7031         };
       
  7032     const TInt count = ( sizeof( methodArray ) / sizeof ( TMethodL ) );
       
  7033 
       
  7034     // Execute selected methods.
       
  7035     while ( aBits )
       
  7036         {
       
  7037         for ( TInt index = 0; ( index < count ) && aBits; index++ )
       
  7038             {
       
  7039             const TInt mask = ( 1 << index );
       
  7040             if ( aBits & mask )
       
  7041                 {
       
  7042                 // Bit is set if corresponding method
       
  7043                 // is wanted to be executed.
       
  7044 
       
  7045                 aBits &= ~mask;
       
  7046                 TMethodL method = methodArray[ index ];
       
  7047                 ( iAppUi.*method )(); // may leave
       
  7048                 }
       
  7049             }
       
  7050         aBits = 0; // for loop executed successfully.
       
  7051         }
       
  7052     }
       
  7053 
       
  7054 // -----------------------------------------------------------------------------
       
  7055 // CVtUiAppUi::CEventObserver::HandleVolumeChange
       
  7056 // -----------------------------------------------------------------------------
       
  7057 //
       
  7058 void CVtUiAppUi::CEventObserver::HandleVolumeChange(
       
  7059         TRemConCoreApiButtonAction aButtonAct )
       
  7060     {
       
  7061    __VTPRINTENTER( "VtUi.HandleVolumeChange" )
       
  7062     // Order of the events is as follows:
       
  7063     //      Click - Immediately when key is pressed down
       
  7064     //      Press - After 0.6 seconds
       
  7065     //      Release - When key is released after 0.6 seconds
       
  7066     //
       
  7067     // Thus, the following sequences are possible from single keypress:
       
  7068     //      <Click>
       
  7069     //      <Click> <0.6 sec pause> <Press> <indefinite pause> <Release>
       
  7070 
       
  7071     switch ( aButtonAct )
       
  7072         {
       
  7073         case ERemConCoreApiButtonPress:
       
  7074         	__VTPRINT( DEBUG_GEN, "VtUi.HandleVolumeChange.ButtonPress" )
       
  7075         	TRAP_IGNORE( iAppUi.AdjustVolumeL( iRCCAOperationId ) );
       
  7076 			TRAP_IGNORE( iAppUi.RefreshVolumeL() );
       
  7077             TRAP_IGNORE( iAppUi.iInstance->VolumeKeyPressedL() );
       
  7078              
       
  7079             iRemConVolumeRepeatTimer->Start(
       
  7080                 KVtUiVolumeRepeatLongDelay,
       
  7081                 KVtUiVolumeRepeatDelay,
       
  7082                 TCallBack( DoHandleVolumeRepeat, this ) );
       
  7083           
       
  7084             break;
       
  7085 
       
  7086         case ERemConCoreApiButtonRelease:
       
  7087             __VTPRINT( DEBUG_GEN, "VtUi.HandleVolumeChange.ButtonRelease" )
       
  7088             iRCCAOperationId = ENop;
       
  7089             TRAP_IGNORE( iAppUi.iInstance->VolumeKeyPressedL() );
       
  7090             break;
       
  7091 
       
  7092         case ERemConCoreApiButtonClick:
       
  7093             __VTPRINT( DEBUG_GEN, "VtUi.HandleVolumeChange.ButtonClick" )
       
  7094              TRAP_IGNORE( iAppUi.AdjustVolumeL( iRCCAOperationId ) );
       
  7095              TRAP_IGNORE( iAppUi.RefreshVolumeL() );
       
  7096              TRAP_IGNORE( iAppUi.iInstance->VolumeKeyPressedL() );
       
  7097             break;
       
  7098 
       
  7099         default:
       
  7100             break;
       
  7101         }
       
  7102     __VTPRINTEXIT( "VtUi.HandleVolumeChange" )
       
  7103     }
       
  7104 
       
  7105 // -----------------------------------------------------------------------------
       
  7106 // CVtUiAppUi::CEventObserver::HandleRemMuteChange
       
  7107 // -----------------------------------------------------------------------------
       
  7108 //
       
  7109 void CVtUiAppUi::CEventObserver::HandleRemMuteChange(
       
  7110         TRemConCoreApiButtonAction aButtonAct )
       
  7111     {
       
  7112     __VTPRINTENTER( "VtUi.EventObserver.HandleRemMuteChange" )
       
  7113     TBool AudioEn (EFalse );
       
  7114     AudioEn = iAppUi.iUiStates->AudioState().IsAudio();
       
  7115     if( AudioEn )
       
  7116         iAppUi.HandleCommandL( EVtUiCmdDisableAudio );
       
  7117     else
       
  7118         iAppUi.HandleCommandL( EVtUiCmdEnableAudio );
       
  7119     __VTPRINTEXIT( "VtUi.EventObserver.HandleRemMuteChange" )
       
  7120     }
       
  7121 // -----------------------------------------------------------------------------
       
  7122 // CVtUiAppUi::CEventObserver::DoHandleVolumeRepeat
       
  7123 // -----------------------------------------------------------------------------
       
  7124 //
       
  7125 TInt CVtUiAppUi::CEventObserver::DoHandleVolumeRepeat( TAny* aAny )
       
  7126     {
       
  7127     __VTPRINTENTER( "VtUi.SvkRpt" )
       
  7128     CEventObserver* self = reinterpret_cast< CEventObserver* >( aAny );
       
  7129     TRAP_IGNORE( self->iAppUi.AdjustVolumeL( self->iRCCAOperationId ) );
       
  7130     TRAP_IGNORE( self->iAppUi.RefreshVolumeL() );
       
  7131     __VTPRINTEXIT( "VtUi.SvkRpt" )
       
  7132     return KErrNone;
       
  7133     }
       
  7134 
       
  7135 // -----------------------------------------------------------------------------
       
  7136 // CVtUiAppUi::RefreshVolumeL
       
  7137 // -----------------------------------------------------------------------------
       
  7138 //
       
  7139 void CVtUiAppUi::RefreshVolumeL()
       
  7140     {
       
  7141     __VTPRINTENTER( "VtUi.RefreshVolumeL" )
       
  7142     // Refresh volume
       
  7143     CVtUiVolume* volume = static_cast< CVtUiVolume* >(
       
  7144         iFeatureManager->GetFeatureById( EVtUiFeatureIdVolume ) );
       
  7145     if ( volume )
       
  7146         {
       
  7147         volume->RefreshL();
       
  7148         }
       
  7149     __VTPRINTEXIT( "VtUi.RefreshVolumeL" )
       
  7150     }
       
  7151 
       
  7152 // -----------------------------------------------------------------------------
       
  7153 // CVtUiAppUi::AdjustVolumeL
       
  7154 // -----------------------------------------------------------------------------
       
  7155 //
       
  7156 void CVtUiAppUi::AdjustVolumeL( TRemConCoreApiOperationId aOperationId )
       
  7157     {
       
  7158     __VTPRINTENTER( "VtUi.AdjustVolumeL" )
       
  7159     __VTPRINT2( DEBUG_GEN,
       
  7160         "VtUi.AdjustVolumeL aOperationId = %d", aOperationId )
       
  7161     TInt command( KVtEngCommandNone );
       
  7162     switch ( aOperationId )
       
  7163         {
       
  7164     case ERemConCoreApiVolumeDown:
       
  7165         command = KVtEngDecreaseAudioVolume;
       
  7166         break;
       
  7167 
       
  7168     case ERemConCoreApiVolumeUp:
       
  7169         command = KVtEngIncreaseAudioVolume;
       
  7170         break;
       
  7171 
       
  7172     default:
       
  7173         break;
       
  7174         }
       
  7175 
       
  7176     if ( command != KVtEngCommandNone )
       
  7177         {
       
  7178         ExecuteCmdL( command );
       
  7179         }
       
  7180     __VTPRINTEXIT( "VtUi.AdjustVolumeL" )
       
  7181     }
       
  7182 
       
  7183 // -----------------------------------------------------------------------------
       
  7184 // CVtUiAppUi::CEventObserver::MrccatoCommand
       
  7185 // -----------------------------------------------------------------------------
       
  7186 //
       
  7187 void CVtUiAppUi::CEventObserver::MrccatoCommand(
       
  7188         TRemConCoreApiOperationId aOperationId,
       
  7189         TRemConCoreApiButtonAction aButtonAct )
       
  7190     {
       
  7191      __VTPRINTENTER( "VtUi.MrccatoCommand" )
       
  7192     // Side volume keys will also dismiss zoom mode if zoom mode is active
       
  7193     if ( iAppUi.iUiStates->IsZoomModeOn() )
       
  7194         {
       
  7195         __VTPRINT( DEBUG_GEN, "VtUi.MrccatoCommand1" )
       
  7196         TRAP_IGNORE( iAppUi.SetZoomModeL( EFalse ));
       
  7197         }
       
  7198 
       
  7199     iRemConVolumeRepeatTimer->Cancel();
       
  7200     iRCCAOperationId = aOperationId;
       
  7201     switch ( aOperationId )
       
  7202         {
       
  7203         case ERemConCoreApiVolumeUp:
       
  7204             // if volume in maximum value and volume up is pressed
       
  7205             // volume indicator must still be shown for a while if
       
  7206             //  muted or call duration is shown in navipane
       
  7207             __VTPRINT( DEBUG_GEN, "VtUi.MrccatoCommand ERemConCoreApiVolumeUp" )
       
  7208             HandleVolumeChange( aButtonAct );
       
  7209             break;
       
  7210 
       
  7211         case ERemConCoreApiVolumeDown:
       
  7212             // if volume in minimun value and volume down is pressed
       
  7213             // volume indicator must still be shown for a while if
       
  7214             //  muted or call duration is shown in navipane
       
  7215             __VTPRINT( DEBUG_GEN, "VtUi.MrccatoCommand ERemConCoreApiVolumeDown" )
       
  7216             HandleVolumeChange( aButtonAct );
       
  7217             break;
       
  7218         case ERemConCoreApiMute:
       
  7219             __VTPRINT( DEBUG_GEN, "VtUi.MrccatoCommand ERemConCoreApiMute" )
       
  7220             HandleRemMuteChange( aButtonAct );
       
  7221         default:
       
  7222             // Other commands ignored.
       
  7223             break;
       
  7224         }
       
  7225  __VTPRINTEXIT( "VtUi.MrccatoCommand" )
       
  7226     }
       
  7227 
       
  7228 // Implementation of CVtUiAppUi::CVtUiAppUiMGVerifier
       
  7229 
       
  7230 // -----------------------------------------------------------------------------
       
  7231 // CVtUiAppUi::CVtUiAppUiMGVerifier::NewLC
       
  7232 // -----------------------------------------------------------------------------
       
  7233 //
       
  7234 CVtUiAppUi::CVtUiAppUiMGVerifier* CVtUiAppUi::CVtUiAppUiMGVerifier::NewLC(
       
  7235     CVtUiAppUi& aAppUi, CCoeEnv& aCoeEnv )
       
  7236     {
       
  7237     CVtUiAppUiMGVerifier* self = new ( ELeave )
       
  7238         CVtUiAppUiMGVerifier( aAppUi, aCoeEnv );
       
  7239     CleanupStack::PushL( self );
       
  7240     self->ConstructL();
       
  7241     return self;
       
  7242     }
       
  7243 
       
  7244 // -----------------------------------------------------------------------------
       
  7245 // CVtUiAppUi::CVtUiAppUiMGVerifier::~CVtUiAppUiMGVerifier
       
  7246 // -----------------------------------------------------------------------------
       
  7247 //
       
  7248 CVtUiAppUi::CVtUiAppUiMGVerifier::~CVtUiAppUiMGVerifier()
       
  7249     {
       
  7250     delete iManager;
       
  7251     }
       
  7252 
       
  7253 // -----------------------------------------------------------------------------
       
  7254 // CVtUiAppUi::CVtUiAppUiMGVerifier::VerifySelectionL
       
  7255 // -----------------------------------------------------------------------------
       
  7256 //
       
  7257 TBool CVtUiAppUi::CVtUiAppUiMGVerifier::VerifySelectionL(
       
  7258     const MDesCArray* aSelectedFiles )
       
  7259     {
       
  7260     TBool isOk( EFalse );
       
  7261     if ( aSelectedFiles->MdcaCount() > 0 )
       
  7262         {
       
  7263         TVirtualPathPtr virtualPath(
       
  7264             aSelectedFiles->MdcaPoint( 0 ), KDefaultContentObject );
       
  7265 
       
  7266         // not ptotected by default
       
  7267         TInt isProtected = 0;
       
  7268 
       
  7269         TInt err = iManager->GetAttribute( EIsProtected,
       
  7270             isProtected, virtualPath );
       
  7271         if ( isProtected )
       
  7272             {
       
  7273             iAppUi.ShowDRMNotAllowedNoteL();
       
  7274             }
       
  7275         if ( err == KErrNone )
       
  7276             {
       
  7277             isOk = !isProtected;
       
  7278             }
       
  7279         }
       
  7280     return isOk;
       
  7281     }
       
  7282 
       
  7283 // -----------------------------------------------------------------------------
       
  7284 // CVtUiAppUi::CVtUiAppUiMGVerifier::ConstructL
       
  7285 // -----------------------------------------------------------------------------
       
  7286 //
       
  7287 void CVtUiAppUi::CVtUiAppUiMGVerifier::ConstructL()
       
  7288     {
       
  7289     iManager = CManager::NewL();
       
  7290     }
       
  7291 
       
  7292 // -----------------------------------------------------------------------------
       
  7293 // CVtUiAppUi::CVtUiAppUiMGVerifier::CVtUiAppUiMGVerifier
       
  7294 // -----------------------------------------------------------------------------
       
  7295 //
       
  7296 CVtUiAppUi::CVtUiAppUiMGVerifier::CVtUiAppUiMGVerifier(
       
  7297     CVtUiAppUi& aAppUi, CCoeEnv& aCoeEnv )
       
  7298     : iAppUi( aAppUi ), iCoeEnv( &aCoeEnv )
       
  7299     {
       
  7300     }
       
  7301 
       
  7302 //  End of File