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