photosgallery/viewframework/views/fullscreenview/src/glxfullscreenviewimp.cpp
branchRCL_3
changeset 26 5b3385a43d68
child 27 34937ec34dac
equal deleted inserted replaced
25:8e5f6eea9c9f 26:5b3385a43d68
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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 FULL-SCREEN view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // Avkon and System Headers 
       
    22 #include <eikbtgpc.h>                           // CEikButtonGroupContainer
       
    23 #include <aknViewAppUi.h>
       
    24 #include <data_caging_path_literals.hrh>        // for KDC_APP_RESOURCE_DIR
       
    25 #include <glxcollectionpluginimageviewer.hrh>
       
    26 #include <StringLoader.h>                       // String Loader
       
    27 #include <AknIconUtils.h>
       
    28 #include <e32math.h>
       
    29 
       
    30 //For animation Effects
       
    31 #include <akntranseffect.h>
       
    32 #include <akntransitionutils.h>
       
    33 #include <alf/alflayout.h>
       
    34 
       
    35 // Alf Headers
       
    36 #include <alf/ialfwidgetfactory.h>              // widget factory
       
    37 #include <alf/alfwidgetcontrol.h>               // To get CAlfControl from CAlfWidgetControl
       
    38 #include <alf/ialfviewwidget.h>                 // View Widget
       
    39 #include <alf/alfwidgetenvextension.h>          // Widget Env Extensions to create view widget
       
    40 #include <alf/alfutil.h>                        // AlfUtil
       
    41 
       
    42 // Antariksh Headers
       
    43 #include <mul/mulevent.h>
       
    44 #include <mul/imulcoverflowwidget.h>            // Coverflow widget
       
    45 #include <mul/imulsliderwidget.h>               // For Slider Widget
       
    46 #include <mpxcollectionpath.h>
       
    47 
       
    48 #include <gesturehelper.h>
       
    49 
       
    50 using namespace GestureHelper;
       
    51 
       
    52 #include <glxhdmicontroller.h>
       
    53 
       
    54 // Photos Headers
       
    55 #include <glxlog.h>                             // CGlxLogger
       
    56 #include <glxtracer.h>                          // For Log
       
    57 #include <glxmedialistmulmodelprovider.h>       // For MulModelProvider
       
    58 #include <glxcommandhandlers.hrh>               // For EGlxCmdFullScreenBack               
       
    59 #include <glxfullscreenviewdata.rsg>            // FS View Resource
       
    60 #include <glxthumbnailattributeinfo.h>          // KGlxMediaIdThumbnail
       
    61 #include <glxactivemedialistregistry.h>         // For medialist registry
       
    62 #include <glxerrormanager.h>
       
    63 #include <glxzoomcontrol.h>
       
    64 #include <glxuiutilities.rsg>
       
    65 #include <glxgeneraluiutilities.h>
       
    66 #include <glxtexturemanager.h>
       
    67 #include <glxicons.mbg>
       
    68 #include <glxsetappstate.h>
       
    69 #include <glxdrmutility.h>
       
    70 #include <glxscreenfurniture.h>
       
    71 #include "glxfullscreenviewimp.h"
       
    72 #include <glxnavigationalstate.h>
       
    73 #include <glxmedia.h>
       
    74 #include <glxnavigationalstate.h>
       
    75 #include <mpxcollectionpath.h>
       
    76 #include <glxcollectionpluginimageviewer.hrh>
       
    77 #include <glxuistd.h>
       
    78 #include "glxfullscreenbusyicon.h"
       
    79 
       
    80 using namespace Alf;
       
    81 
       
    82 const TInt KGlxScreenTimeout =10000000;
       
    83 const TInt KCoverflowDataWindowSize = 1;
       
    84 const TInt KGlxMaxSmallImageZoomLevel =150;
       
    85 const TInt KGlxMaxBigImageZoomLevel   =100;
       
    86 const TInt KGlxMinSmallImageZoomLevel =100;
       
    87 const TInt KGlxNeutralPinchPosition   =100;
       
    88 const TInt KGlxSliderTickValue        =5;
       
    89 const TInt KGlxRealTruncationPadding  =0.5;
       
    90 
       
    91 /**
       
    92  * Start Delay for the periodic timer, in microseconds
       
    93  */
       
    94 const TInt KPeriodicStartDelay = 250000; 
       
    95 /**
       
    96  * Interval delay for the periodic timer, in microseconds
       
    97  */
       
    98 const TInt KPeriodicIntervalDelay = 500000; 
       
    99 
       
   100 /** 
       
   101  * Fullscreen texture offset 
       
   102  */ 
       
   103 const TInt KTextureOffset = 2; 
       
   104 
       
   105 // This constant is used to calculate the index of the item 
       
   106 // for which texture has to removed.
       
   107 const TInt KFullScreenIterator = KTextureOffset + 1; 
       
   108 
       
   109 // This constant is used to calculate the maximum number of fullscreen textures 
       
   110 // needs to be updated during foreground event.
       
   111 const TInt KFullScreenTextureOffset = KFullScreenIterator + KTextureOffset;
       
   112 
       
   113 const TInt KGlxDecodingThreshold = 3000000; // pixels
       
   114 
       
   115 _LIT( KTfxResourceActivateFullScreen, "z:\\resource\\effects\\photos_fullscreen_open.fxml" );
       
   116 _LIT( KTfxResourceNoEffect, "");
       
   117 
       
   118 // ======== MEMBER FUNCTIONS ========
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // C++ default constructor can NOT contain any code, that
       
   122 // might leave.
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 CGlxFullScreenViewImp::CGlxFullScreenViewImp(
       
   126 		const TFullScreenViewResourceIds& aResourceIds, TInt aViewUID) :
       
   127 	iResourceIds(aResourceIds), iViewUid(aViewUID)
       
   128 	{
       
   129 	TRACER("CGlxFullScreenViewImp::CGlxFullScreenViewImp");
       
   130 	}
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // Two-phased constructor.
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 CGlxFullScreenViewImp* CGlxFullScreenViewImp::NewL(
       
   137 		MGlxMediaListFactory* aMediaListFactory,
       
   138 		const TFullScreenViewResourceIds& aResourceIds, 
       
   139 		TInt aViewUID,
       
   140 		const TDesC& aTitle)
       
   141 	{
       
   142 	TRACER("CGlxFullScreenViewImp::NewL");
       
   143 	CGlxFullScreenViewImp* self = CGlxFullScreenViewImp::NewLC (
       
   144 			aMediaListFactory, aResourceIds, aViewUID, aTitle);
       
   145 	CleanupStack::Pop (self);
       
   146 	return self;
       
   147 	}
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // Two-phased constructor.
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 CGlxFullScreenViewImp* CGlxFullScreenViewImp::NewLC(
       
   154 		MGlxMediaListFactory* aMediaListFactory,
       
   155 		const TFullScreenViewResourceIds& aResourceIds, TInt aViewUID,
       
   156 		const TDesC& aTitle)
       
   157 	{
       
   158 	TRACER("CGlxFullScreenViewImp::NewLC");
       
   159 	CGlxFullScreenViewImp* self =new (ELeave) CGlxFullScreenViewImp(aResourceIds, aViewUID);
       
   160 	CleanupStack::PushL (self);
       
   161 	self->ConstructL (aMediaListFactory, aTitle);
       
   162 	return self;
       
   163 	}
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 //  ConstructL.
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void  CGlxFullScreenViewImp::ConstructL(
       
   170 		MGlxMediaListFactory* aMediaListFactory, const TDesC& aTitle)
       
   171 	{
       
   172 	TRACER("CGlxFullScreenViewImp::ConstructL");
       
   173 	BaseConstructL (iResourceIds.iViewId);
       
   174 	ViewBaseConstructL();
       
   175 	MLViewBaseConstructL (aMediaListFactory, aTitle , EFalse);
       
   176 	
       
   177 	iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   178 	//Register the view to recieve toolbar events. ViewBase handles the events
       
   179 	SetToolbarObserver(this);
       
   180 	iImgViewerMode = EFalse;
       
   181     //Disable the toolbar always while entering fullscreen
       
   182 	EnableFSToolbar(EFalse);
       
   183     ShowToolbarOnViewActivation(EFalse);
       
   184 	
       
   185 	//Get the ScreenFurniture instance
       
   186 	iScreenFurniture = iUiUtility->ScreenFurniture();
       
   187 	
       
   188     //Get the env from the uiutilities
       
   189 	iEnv = iUiUtility->Env ();
       
   190 	
       
   191 	iZoomButtonGroup = CEikButtonGroupContainer::NewL(
       
   192 	        CEikButtonGroupContainer::ECba,  // type
       
   193 	        CEikButtonGroupContainer::EHorizontal,  // orientation
       
   194 	        this,  // command observer
       
   195 	        R_GLX_FULLSCREEN_SOFTKEYS_ZOOM ); 
       
   196 	iZoomButtonGroup->MakeVisible( EFalse );
       
   197 
       
   198 	//create the drmutility instance
       
   199 	iDrmUtility = CGlxDRMUtility::InstanceL();
       
   200    // Get object that stores the active media list registry
       
   201     iActiveMediaListRegistry = CGlxActiveMediaListRegistry::InstanceL();
       
   202     
       
   203     iIsDialogLaunched = EFalse;
       
   204     iIsMMCRemoved = EFalse;
       
   205 	
       
   206 	iMMCNotifier = CGlxMMCNotifier::NewL(*this);
       
   207 	if(!iPeriodic)
       
   208 		{
       
   209 		iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard);
       
   210 		}
       
   211 	iGlxTvOut = CGlxTv::NewL(*this);
       
   212 	
       
   213 	iNaviState = CGlxNavigationalState::InstanceL();
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // ~CGlxFullScreenViewImp()
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 CGlxFullScreenViewImp::~CGlxFullScreenViewImp()
       
   221     {
       
   222     TRACER("CGlxFullScreenViewImp::~CGlxFullScreenViewImp");
       
   223     if(iAlfEffectObs)
       
   224         {
       
   225         delete iAlfEffectObs;
       
   226         }
       
   227     if(iMMCNotifier)
       
   228         {
       
   229         delete iMMCNotifier;
       
   230         iMMCNotifier = NULL;
       
   231         }
       
   232     if(iMediaListMulModelProvider)
       
   233         {
       
   234         delete iMediaListMulModelProvider;
       
   235         }
       
   236     if(iTimer)
       
   237         {
       
   238         if(iTimer->IsActive())
       
   239             {
       
   240             iTimer->Cancel();
       
   241             }
       
   242         delete iTimer;
       
   243         }
       
   244 	if(iZoomButtonGroup)
       
   245         {
       
   246         AppUi()->RemoveFromStack( iZoomButtonGroup );
       
   247         delete iZoomButtonGroup;
       
   248         }
       
   249 	if(iGlxTvOut)
       
   250         {
       
   251         delete iGlxTvOut;
       
   252         }
       
   253     if(iActiveMediaListRegistry)
       
   254         {
       
   255         iActiveMediaListRegistry->Close();
       
   256 	    }
       
   257     if( iDrmUtility )
       
   258 		{
       
   259 		iDrmUtility->Close();
       
   260 		}
       
   261     if (iPeriodic)
       
   262  		{
       
   263  		iPeriodic->Cancel();
       
   264  		delete iPeriodic;
       
   265  		}
       
   266     
       
   267     if (iNaviState)
       
   268         {
       
   269         iNaviState->Close();
       
   270         }    
       
   271 	}
       
   272  // ---------------------------------------------------------------------------
       
   273 // From CGlxViewBase
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 TUid CGlxFullScreenViewImp::Id() const
       
   277     {
       
   278     TRACER("CGlxFullScreenViewImp::Id");
       
   279     return TUid::Uid(iViewUid);
       
   280 	}
       
   281 
       
   282 
       
   283 // ---------------------------------------------------------------------------
       
   284 // Destroys a coverflow widget
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 void CGlxFullScreenViewImp::DestroyWidgets()
       
   288     {
       
   289     TRACER("CGlxFullScreenViewImp::DestroyCoverflowWidget");
       
   290     if (iCoverFlowWidget)
       
   291         {
       
   292         iCoverFlowWidget->RemoveEventHandler(*this);
       
   293         }
       
   294     // Destror Slider widget
       
   295     DestroySliderWidget();
       
   296     
       
   297     delete iMediaListMulModelProvider;
       
   298     iMediaListMulModelProvider = NULL;
       
   299 
       
   300     IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(*iEnv); 
       
   301     // Destroying this widget calls destructor of single line meta pane
       
   302     widgetFactory.destroyWidget(iViewWidget);
       
   303 
       
   304     iCoverFlowWidget = NULL;
       
   305     iViewWidget = NULL;
       
   306     }
       
   307 
       
   308 // ---------------------------------------------------------------------------
       
   309 // Destroys a Slider widget
       
   310 // ---------------------------------------------------------------------------
       
   311 //
       
   312 void CGlxFullScreenViewImp::DestroySliderWidget()
       
   313     {
       
   314     TRACER("CGlxFullScreenViewImp::DestroySliderWidget");
       
   315     if(iSliderWidget)
       
   316         {
       
   317         iSliderWidget->RemoveEventHandler(*this);
       
   318         }
       
   319     iSliderWidget = NULL;
       
   320     iSliderModel = NULL;
       
   321     }
       
   322 // ---------------------------------------------------------------------------
       
   323 // From CAknView
       
   324 // Handles a view activation.
       
   325 // ---------------------------------------------------------------------------
       
   326 //
       
   327 void CGlxFullScreenViewImp::DoMLViewActivateL(
       
   328 		const TVwsViewId & /* aPrevViewId */, TUid /* aCustomMessageId */,
       
   329 		const TDesC8 & /* aCustomMessage */)
       
   330 	{
       
   331     TRACER("CGlxFullScreenViewImp::DoMLViewActivateL");
       
   332 	
       
   333     // hide the toolbar
       
   334     EnableFSToolbar(EFalse);
       
   335     
       
   336     if (iMediaList->Count() == 0)
       
   337         {
       
   338         GLX_LOG_INFO("CGlxFullScreenViewImp::DoMLViewActivateL() - No items!");	
       
   339 		// While in slideshow from fullscreen view,
       
   340         // 1) Connect USB in mass storage mode or 
       
   341         // 2) Delete items through file manager 
       
   342         // shall result in activating fullscreen view with no items; so, goto grid view.
       
   343         iNaviState->ActivatePreviousViewL();
       
   344         }
       
   345     else
       
   346         {
       
   347         //fix for ESLM-7YYDXC: When in FullScreen View, view mode must be 'EView'
       
   348         //While coming back from SlideShow to FullScreen view, need to set view mode.
       
   349         if (iMediaList->Count() && iNaviState->ViewingMode()
       
   350                 != NGlxNavigationalState::EView)
       
   351             {
       
   352             iNaviState->SetToViewMode();
       
   353             }
       
   354         }
       
   355 
       
   356     CMPXCollectionPath* collPath = iNaviState->StateLC();
       
   357     if (collPath->Id() == TMPXItemId(
       
   358             KGlxCollectionPluginImageViewerImplementationUid))
       
   359         {
       
   360         iImgViewerMode = ETrue;
       
   361         CreateImageViewerInstanceL();
       
   362         }
       
   363     CleanupStack::PopAndDestroy(collPath);
       
   364 
       
   365     iScrnSize = iUiUtility->DisplaySize();
       
   366     iGridIconSize = iUiUtility->GetGridIconSize();
       
   367 
       
   368     iHdmiWidth = (iScrnSize.iWidth > iScrnSize.iHeight ?iScrnSize.iWidth :iScrnSize.iHeight);
       
   369     iHdmiHeight = (iScrnSize.iWidth < iScrnSize.iHeight ?iScrnSize.iWidth :iScrnSize.iHeight);
       
   370 
       
   371     //Create hdmicontroller when it is only launched from fullscreen.  
       
   372     //From filemanager show only clone mode.
       
   373     iHdmiController = CGlxHdmiController::NewL(*this); 
       
   374     
       
   375     if( !iImgViewerMode )    
       
   376         {
       
   377         SetItemToHDMIL();
       
   378         }
       
   379     iScreenFurniture->SetActiveView(iViewUid);
       
   380     
       
   381     //set the ui state to off,when the Fullscreen launches
       
   382     SetUiState(EUiOff);
       
   383    
       
   384    	GlxSetAppState::SetState(EGlxInFullScreenView);
       
   385    	 
       
   386     // create the coverflow
       
   387     CreateCoverflowWidgetL();
       
   388     
       
   389     CreateSliderWidgetL();
       
   390     
       
   391     iBusyIcon = CGlxFullScreenBusyIcon::NewL(*iMediaList,*iUiUtility);
       
   392     // create a zoom control
       
   393     iZoomControl = CGlxZoomControl::NewL(*this, *iMediaList,
       
   394             *iZoomButtonGroup, *iSliderWidget, iGestureHelper);
       
   395 
       
   396     // hide the screen furniture
       
   397     HideUi(ETrue);
       
   398 	// Set active media list pointer, so that UPnP renderer knows about this list
       
   399     iActiveMediaListRegistry->RegisterActiveMediaList(iMediaList);
       
   400     
       
   401 	if ( !iPeriodic->IsActive() )
       
   402 		{
       
   403 	    iPeriodic->Start(KPeriodicStartDelay, KPeriodicIntervalDelay,
       
   404 	            TCallBack(&PeriodicCallback, static_cast<TAny*> (this)));
       
   405 		}
       
   406 		
       
   407 	//Set the animation effect for the coverflow widget since the animation
       
   408 	//does not work for both avkon and alf together. This can be done since the
       
   409 	//UI Screen furnitures are disabled by default while going to fullscreen.
       
   410 	//Check if the transitions are enabled from themes
       
   411     if (CAknTransitionUtils::TransitionsEnabled(
       
   412                                     AknTransEffect::EFullScreenTransitionsOff))
       
   413         {
       
   414         if(!iAlfEffectObs)
       
   415             {
       
   416             iAlfEffectObs = CAlfEffectObserver::NewL();
       
   417             }
       
   418         const_cast<CAlfLayout&> (iCoverFlowWidget->ContainerLayout()).SetEffectL(
       
   419                 KTfxResourceActivateFullScreen);
       
   420         iEffectHandle = iCoverFlowWidget->ContainerLayout().Identifier();
       
   421         iAlfEffectObs->SubscribeCallbackL(this,iEffectHandle);
       
   422         }
       
   423     
       
   424 	//Disable the status pane here as it causes flicker while animating
       
   425     CAknViewAppUi* appui = AppUi();
       
   426     if ( appui )
       
   427         {
       
   428         appui->StatusPane()->MakeVisible(EFalse);
       
   429         appui->Cba()->MakeVisible(EFalse);
       
   430         }
       
   431 
       
   432 	iViewWidget->show(true);    
       
   433 	}
       
   434 	
       
   435 
       
   436 // ---------------------------------------------------------------------------
       
   437 // Creates a coverflow widget
       
   438 // ---------------------------------------------------------------------------
       
   439 //
       
   440 void CGlxFullScreenViewImp::CreateCoverflowWidgetL()
       
   441     {
       
   442     TRACER("CGlxFullScreenViewImp::CreateCoverflowWidgetL");
       
   443 
       
   444     const char* KWidgetName("mulcoverflowwidget");
       
   445     const char* KCoverflowViewWidget("CoverflowViewWidget");
       
   446     const char* KCoverflowWidget("CoverflowWidget");
       
   447     try
       
   448         {
       
   449         // Get widget factory from CAlfEnv
       
   450         // Factory is then used to create the individual widgets & data model
       
   451 
       
   452         IAlfWidgetFactory& widgetFactory =
       
   453                 AlfWidgetEnvExtension::widgetFactory(*iEnv);
       
   454 
       
   455         // create a view widget  
       
   456         iViewWidget = widgetFactory.createViewWidget(KCoverflowViewWidget,
       
   457                 0x113);
       
   458         // hide control and status pane
       
   459         iViewWidget->enableControlPane(EFalse);
       
   460         iViewWidget->enableStatusPane(EFalse);
       
   461         iViewWidget->setRect(TRect(TPoint(0, 0), AlfUtil::ScreenSize()));
       
   462         // create coverflow widget
       
   463         iCoverFlowWidget = widgetFactory.createWidget<IMulCoverFlowWidget> (
       
   464                 KWidgetName, KCoverflowWidget, *iViewWidget, NULL);
       
   465         iCoverFlowWidget->SetFlags(IMulMultiItemWidget::EMulWidgetDoubleTap);
       
   466 
       
   467         // Widget takes the ownership
       
   468         iCoverFlowWidget->AddEventHandler(*this);
       
   469 
       
   470         iCoverFlowWidget->control()->AcquireFocus();
       
   471         iMediaListMulModelProvider = CGlxMediaListMulModelProvider::NewL(
       
   472                 *iEnv, *iCoverFlowWidget, *iMediaList, iFullScreenBindingSet,
       
   473                 mulwidget::KTemplate4, KCoverflowDataWindowSize);
       
   474 
       
   475         iGestureHelper
       
   476                 = (GestureHelper::CGestureHelper*) iCoverFlowWidget->Gesturehelper();
       
   477         }
       
   478     catch(...)
       
   479         {
       
   480         User::Leave(KErrGeneral);
       
   481         }
       
   482 
       
   483     }
       
   484 
       
   485 //----------------------------------------------------------------------------
       
   486 //Initialise the slider widget and the slider model
       
   487 //----------------------------------------------------------------------------
       
   488 //
       
   489 void CGlxFullScreenViewImp::CreateSliderWidgetL()
       
   490     {
       
   491     const char* KSliderWidgetName("mulsliderwidget");
       
   492     const char* KZoomSliderWidget("ZoomSliderWidget");
       
   493 
       
   494     try
       
   495         {
       
   496         IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(*iEnv);
       
   497     
       
   498         iSliderWidget = widgetFactory.createWidget<IMulSliderWidget>( KSliderWidgetName, 
       
   499                 KZoomSliderWidget, *iViewWidget, NULL);
       
   500     
       
   501         iSliderWidget->AddEventHandler(*this);
       
   502         iSliderWidget->SetHandleKeyEvent(EFalse);
       
   503         iSliderModel = widgetFactory.createModel<IMulSliderModel> ("mulslidermodel");
       
   504         iSliderModel->SetTemplate(ESliderTemplate3);
       
   505         iSliderWidget->setModel(iSliderModel);
       
   506         iSliderWidget->control()->disableState(IAlfWidgetControl::Focusable);
       
   507     
       
   508         //adding the range and slider tick value 
       
   509         if(iSliderModel)
       
   510             {
       
   511             iSliderModel->SetTick(KGlxSliderTickValue);
       
   512             }
       
   513         }
       
   514     catch(...)
       
   515         {
       
   516         User::Leave(KErrGeneral);
       
   517         }
       
   518     }
       
   519 
       
   520 // ---------------------------------------------------------------------------
       
   521 // ShowUiL
       
   522 // ---------------------------------------------------------------------------
       
   523 //	
       
   524 void  CGlxFullScreenViewImp::ShowUiL(TBool aStartTimer)
       
   525     {
       
   526     TRACER("CGlxFullScreenViewImp::ShowUiL");
       
   527 	if(CheckIfSliderToBeShownL())
       
   528         {
       
   529         //To set the Slider values.
       
   530         SetSliderToMin();
       
   531         //show the slider
       
   532         iSliderWidget->ShowWidget(ETrue);
       
   533         }
       
   534     else
       
   535         {
       
   536         //hide slider if UI is needed to be on and HDMI is Connected
       
   537         iSliderWidget->ShowWidget(EFalse);
       
   538         }
       
   539     
       
   540     if (iCoverFlowWidget)
       
   541         {
       
   542 		// This is done to set the item counter
       
   543         iCoverFlowWidget->SetUIMode(ETrue);
       
   544         }
       
   545 
       
   546     //Since the toolbar should not be present for ImageViewer.
       
   547     if(!iImgViewerMode)
       
   548         {
       
   549         //show the toolbar
       
   550         EnableFSToolbar(ETrue);
       
   551         }
       
   552      
       
   553     // For floating toolbar in non-touch devices
       
   554     iScreenFurniture->SetToolbarVisibility(ETrue);
       
   555     
       
   556     //show the softkeys
       
   557     CEikButtonGroupContainer* cba = Cba();
       
   558     cba->SetCommandSetL( R_GLX_FULLSCREEN_SOFTKEYS );
       
   559     cba->MakeVisible( ETrue );
       
   560     cba->DrawNow();
       
   561 
       
   562     //set the ui state to On
       
   563     SetUiState(EUiOn);
       
   564     
       
   565     //start the timer,for the screen timeout
       
   566     iTimer->Cancel();
       
   567     if(aStartTimer)
       
   568         {
       
   569         iTimer->Start(KGlxScreenTimeout,KGlxScreenTimeout,TCallBack( TimeOut,this ));
       
   570         }
       
   571     }
       
   572     
       
   573 // ---------------------------------------------------------------------------
       
   574 // HideUi
       
   575 // ---------------------------------------------------------------------------
       
   576 //	
       
   577 void  CGlxFullScreenViewImp::HideUi(TBool aHideSlider)
       
   578     {
       
   579     TRACER("CGlxFullScreenViewImp::HideUi");
       
   580     //cancel the timer
       
   581     iTimer->Cancel();
       
   582 
       
   583     // For floating toolbar in non-touch devices
       
   584     iScreenFurniture->SetToolbarVisibility(EFalse);
       
   585     
       
   586     // hide/show the slider
       
   587     if(iSliderWidget) 
       
   588         {
       
   589         iSliderWidget->ShowWidget(!aHideSlider);        
       
   590         }
       
   591 
       
   592     if (iCoverFlowWidget)
       
   593         {
       
   594         iCoverFlowWidget->SetUIMode(EFalse);
       
   595         }
       
   596     
       
   597     //Since the toolbar should not be present for ImageViewer.
       
   598     if(!iImgViewerMode)
       
   599         {
       
   600         // hide the toolbar
       
   601         CAknToolbar* toolbar = Toolbar();
       
   602         if(toolbar)
       
   603             {
       
   604             toolbar->SetToolbarVisibility(EFalse); 
       
   605             }
       
   606         }
       
   607     
       
   608     // hide the softkeys
       
   609     Cba()->MakeVisible( EFalse );
       
   610     Cba()->DrawNow();
       
   611  
       
   612     // set the ui state to On
       
   613     SetUiState(EUiOff);
       
   614     }
       
   615 
       
   616 // ---------------------------------------------------------------------------
       
   617 // SetUiState
       
   618 // ---------------------------------------------------------------------------
       
   619 //	
       
   620 void CGlxFullScreenViewImp::SetUiState (TUiState  aState)
       
   621     {
       
   622     TRACER("CGlxFullScreenViewImp::SetUiState");
       
   623     iUiState = aState;
       
   624     }
       
   625 
       
   626 // ---------------------------------------------------------------------------
       
   627 // GetUiState
       
   628 // ---------------------------------------------------------------------------
       
   629 //	
       
   630 TUiState CGlxFullScreenViewImp::GetUiState()    
       
   631     {
       
   632     TRACER("CGlxFullScreenViewImp::GetUiState");
       
   633     return iUiState;
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 // TimeOut
       
   638 // ---------------------------------------------------------------------------
       
   639 //	
       
   640 TInt CGlxFullScreenViewImp::TimeOut(TAny* aSelf)
       
   641     {
       
   642     TRACER("CGlxFullScreenViewImp::TimeOut");
       
   643     if(aSelf)
       
   644         {
       
   645         CGlxFullScreenViewImp* self = static_cast <CGlxFullScreenViewImp*> (aSelf);
       
   646         if (self)
       
   647             {
       
   648             if ( EUiOn == self->GetUiState())
       
   649                 {
       
   650                 // After time out, hide UI only when menu is not being displayed.
       
   651                 if( self->MenuBar() && !(self->MenuBar()->IsDisplayed()) )
       
   652                     {
       
   653 		            self->HideUi(ETrue);
       
   654 					}
       
   655                 }
       
   656             }            
       
   657         }
       
   658     return KErrNone;
       
   659     }
       
   660 
       
   661 // ---------------------------------------------------------------------------
       
   662 //DeactivateFullScreen function.
       
   663 // ---------------------------------------------------------------------------
       
   664 //
       
   665 void  CGlxFullScreenViewImp::DeactivateFullScreen()
       
   666     {
       
   667     TRACER("CGlxFullScreenViewImp::DeactivateFullScreen");
       
   668     if (iCoverFlowWidget)
       
   669         {
       
   670         iCoverFlowWidget->RemoveEventHandler(*this);
       
   671         iCoverFlowWidget->ShowWidget(EFalse);
       
   672         }
       
   673     if(iSliderWidget)
       
   674         {
       
   675         iSliderWidget->RemoveEventHandler(*this);
       
   676     
       
   677         //show/hide the slider based on the return value of
       
   678         //IsHidden()
       
   679 	    if(iZoomControl->Activated())
       
   680 	        {
       
   681 	        HideUi(iSliderWidget->IsHidden());
       
   682 	        }
       
   683 		}
       
   684     }
       
   685 
       
   686 // ---------------------------------------------------------------------------
       
   687 //ActivateFullScreen function.
       
   688 // ---------------------------------------------------------------------------
       
   689 //
       
   690 void CGlxFullScreenViewImp::ActivateFullScreenL()
       
   691     {
       
   692     TRACER("CGlxFullScreenViewImp::ActivateFullScreenL");
       
   693     
       
   694      if (iCoverFlowWidget)
       
   695         {
       
   696         iCoverFlowWidget->AddEventHandler(*this);
       
   697         iCoverFlowWidget->ShowWidget(ETrue);
       
   698         }
       
   699     if(iSliderWidget)
       
   700         {
       
   701         iSliderWidget->AddEventHandler(*this);
       
   702         }
       
   703     iViewWidget->setRect(TRect(TPoint(0,0),AlfUtil::ScreenSize()));
       
   704 	GlxSetAppState::SetState(EGlxInFullScreenView);   
       
   705     }
       
   706 
       
   707 // ---------------------------------------------------------------------------
       
   708 //ActivateZoomControl function.
       
   709 // ---------------------------------------------------------------------------
       
   710 //
       
   711 void CGlxFullScreenViewImp::ActivateZoomControlL(TZoomStartMode aStartMode, TPoint* apZoomFocus)
       
   712     {
       
   713     TRACER("CGlxFullScreenViewImp::ActivateZoomControlL");
       
   714     /*
       
   715      * We will not do any zoom while HDMI is connected.
       
   716      * This is as part of HDMI improvements.
       
   717      */
       
   718     if (iHdmiController && iHdmiController->IsHDMIConnected())
       
   719         {
       
   720         // Hide zoom slider in HDMI mode as Zoom is disable.
       
   721         // Let the other screen furnitures intact.
       
   722         iSliderWidget->ShowWidget( EFalse);
       
   723         return;
       
   724         }
       
   725     TInt focus = iMediaList->FocusIndex();
       
   726     TGlxMedia item = iMediaList->Item( focus );
       
   727     TInt error = GlxErrorManager::HasAttributeErrorL(item.Properties() , KGlxMediaIdThumbnail);
       
   728    
       
   729     // Check if DRM rights expired for a specific media item 
       
   730     TBool isDrmRightsValid = ETrue;
       
   731     if(item.IsDrmProtected())
       
   732     	{
       
   733         if (iImgViewerMode && iImageViewerInstance->IsPrivate())
       
   734             {
       
   735             isDrmRightsValid = iDrmUtility->DisplayItemRightsCheckL(
       
   736                     iImageViewerInstance->ImageFileHandle(), (item.Category()
       
   737                             == EMPXImage));
       
   738             }
       
   739         else
       
   740             {
       
   741             //Since it is always for the focused item - use DisplayItemRightsCheckL 
       
   742             //instead of ItemRightsValidityCheckL
       
   743             isDrmRightsValid = iDrmUtility->DisplayItemRightsCheckL(
       
   744                     item.Uri(), (item.Category() == EMPXImage));
       
   745             }
       
   746         }
       
   747     // Activate Zoom if the item is an image and its DRM rights is not expired
       
   748     if(KErrNone == error && (EMPXImage == item.Category()) && isDrmRightsValid)
       
   749         {
       
   750         if(iZoomControl && !iZoomControl->Activated())
       
   751             {
       
   752             if(iHdmiController)
       
   753                 {
       
   754                 TBool autoZoomOut = ETrue;
       
   755                 //Set autozoomout to false in pinch zoom, since we would be 
       
   756                 //zooming out on deactivate once we get the release event.
       
   757                 if(aStartMode == EZoomStartPinch)                    
       
   758                     {
       
   759                     autoZoomOut = EFalse; 
       
   760                     }
       
   761                 
       
   762                 iHdmiController->ActivateZoom(autoZoomOut);
       
   763                 }
       
   764             
       
   765             GLX_LOG_INFO1("ActivateZoomControlL: Slider MaxRange = %d   ", iSliderModel->MaxRange() );
       
   766             GLX_LOG_INFO1("ActivateZoomControlL: Slider MinRange = %d   ", iSliderModel->MinRange() );
       
   767             GLX_LOG_INFO1("ActivateZoomControlL: Slider PrimaryValue= %d", iSliderModel->PrimaryValue() );
       
   768             
       
   769             if (aStartMode == EZoomStartSlider) 
       
   770                 {
       
   771                 iZoomControl->ActivateL(iSliderModel->PrimaryValue(),aStartMode, focus,
       
   772                                         item, apZoomFocus,iImgViewerMode);
       
   773                 }
       
   774             else 
       
   775                 {
       
   776                 iZoomControl->ActivateL(GetInitialZoomLevel(),aStartMode, focus,
       
   777                                         item, apZoomFocus,iImgViewerMode);
       
   778                 }
       
   779             // Now to remove all textures other than the one we are focussing on.  
       
   780             TInt frameCount = KErrNone;
       
   781             item.GetFrameCount(frameCount);
       
   782             // If .gif file, then only call stopanimation
       
   783 			if (frameCount > 1)
       
   784                 {
       
   785                 iUiUtility->GlxTextureManager().AnimateMediaItem(
       
   786                         item.Id(), EFalse);
       
   787                 }
       
   788             TInt count = iMediaList->Count();
       
   789             while (count > 0)
       
   790                 {
       
   791                 TGlxMedia mediaItem = iMediaList->Item(count-1);	
       
   792                 if (mediaItem.Id() != item.Id() )
       
   793                     {
       
   794                     iUiUtility->GlxTextureManager().RemoveTexture(mediaItem.Id(),EFalse);
       
   795                     }
       
   796                 count--;
       
   797                 }
       
   798             }
       
   799         else
       
   800             {
       
   801             return;
       
   802             }
       
   803         DeactivateFullScreen();
       
   804         GlxSetAppState::SetState(EGlxInZoomedView);
       
   805         }
       
   806     }
       
   807 
       
   808 // ---------------------------------------------------------------------------
       
   809 //DeactivateZoomControl function.
       
   810 // ---------------------------------------------------------------------------
       
   811 //
       
   812 void CGlxFullScreenViewImp::DeactivateZoomControlL()
       
   813     {
       
   814     TRACER("CGlxFullScreenViewImp::DeactivateZoomControlL");
       
   815     ActivateFullScreenL();
       
   816     UpdateItems();
       
   817     //Deactivate HDMI controller for zoom out while pinch zooming.
       
   818     if(iHdmiController)
       
   819         {
       
   820         iHdmiController->DeactivateZoom();
       
   821         }
       
   822     if(iZoomControl->Activated())
       
   823         {        
       
   824         iZoomControl->Deactivate();
       
   825         }
       
   826     if (iMediaList->FocusIndex() != KErrNotFound)
       
   827         {
       
   828         TGlxMedia item = iMediaList->Item(iMediaList->FocusIndex());
       
   829         TInt frameCount = KErrNone;
       
   830         item.GetFrameCount(frameCount);
       
   831 		// If .gif file, then only call start animation
       
   832         if (frameCount > 1)
       
   833             {
       
   834             iUiUtility->GlxTextureManager().AnimateMediaItem(
       
   835                     item.Id(), ETrue);
       
   836             }
       
   837         }
       
   838     
       
   839     SetSliderToMin();
       
   840     //check if the slider is already visible in zoom view.
       
   841     //if yes then do not disable the slider.
       
   842     TBool sliderInvisible = ETrue;
       
   843     if (EUiOn == iZoomControl->ZoomUiState())
       
   844         {
       
   845         sliderInvisible = EFalse;
       
   846         }
       
   847     
       
   848     HideUi(sliderInvisible);
       
   849     
       
   850     if (!sliderInvisible)
       
   851         {
       
   852         //Set the UI State to On Explicitly since the slider is ON and we have
       
   853         //to disable on timeout. The timer is already cancelled in HideUi().
       
   854         SetUiState(EUiOn);
       
   855         iTimer->Start(KGlxScreenTimeout,KGlxScreenTimeout,TCallBack( TimeOut,this ));
       
   856         }
       
   857     }
       
   858 
       
   859 // ---------------------------------------------------------------------------
       
   860 // From CAknView
       
   861 // View deactivation function.
       
   862 // ---------------------------------------------------------------------------
       
   863 //
       
   864 void CGlxFullScreenViewImp::DoMLViewDeactivate()
       
   865     {
       
   866     TRACER("CGlxFullScreenViewImp::DoMLViewDeactivate");
       
   867 	//Disabling the toolbar here since it would give a crash when
       
   868 	//we try to enable the toolbar in activate without exiting photos.
       
   869     if(!iImgViewerMode)
       
   870         {    
       
   871         // hide the toolbar
       
   872         EnableFSToolbar(EFalse);
       
   873         
       
   874         //Setting Soft key to EmptySoftKeys would cause crash
       
   875 		//When Fullscreen is opened from ImageViewer.
       
   876         //And also, when Photos exits from FullScreen View.
       
   877         //So Set Soft Keys to empty only when not in Image Viewer mode 
       
   878         //& Photos is not exiting.
       
   879 		if( !iUiUtility->IsExitingState() )
       
   880 			{
       
   881 			CEikButtonGroupContainer* cba = Cba();
       
   882 			TRAP_IGNORE( cba->SetCommandSetL( R_GLX_FULLSCREEN_EMPTYSOFTKEYS ) );
       
   883 			cba->DrawNow();
       
   884 			}
       
   885         }
       
   886 	else
       
   887 		{
       
   888 		DeleteImageViewerInstance();
       
   889 		}
       
   890     
       
   891     HideUi(ETrue); 
       
   892 	// In Order to hide the softkeys immediately. The above statement does not do that as soon as we need. 
       
   893 	// So we do the below trick. The SK overlap is still there but much much less noticable. 
       
   894     CCoeEnv::Static()->WsSession().Flush(); 
       
   895 
       
   896     //Clear the last uri for which DRM Rights were consumed before going back to grid view
       
   897     //since the GridView::Activate() and FullScreen::DeActivate() can be called in any order,
       
   898     //this call is being made to be on safer side
       
   899     iDrmUtility->ClearLastConsumedItemUriL();
       
   900     iScreenFurniture->ViewDeactivated(iViewUid);
       
   901     iImgViewerMode = EFalse;
       
   902     if (iHdmiController)
       
   903         {
       
   904         delete iHdmiController;
       
   905         iHdmiController = NULL;
       
   906         }
       
   907     
       
   908     if(iZoomControl)
       
   909         {
       
   910         if(iZoomControl->Activated())
       
   911             {
       
   912             iZoomControl->Deactivate();
       
   913             }
       
   914         delete iZoomControl;
       
   915         iZoomControl = NULL;
       
   916         } 
       
   917     DestroyWidgets();
       
   918     iTimer->Cancel();
       
   919 	// Deregister active media list pointer
       
   920     iActiveMediaListRegistry->DeregisterActiveMediaList(iMediaList);
       
   921     
       
   922     /*
       
   923      * safe code-- if user press back very quickly
       
   924      * cancelling the timer while going back to prev view
       
   925      */
       
   926     if (iPeriodic->IsActive())
       
   927  		{
       
   928  		iPeriodic->Cancel();
       
   929  		}
       
   930 
       
   931     }      
       
   932 // ---------------------------------------------------------------------------
       
   933 // Foreground event handling function.
       
   934 // ---------------------------------------------------------------------------
       
   935 //
       
   936 void CGlxFullScreenViewImp::HandleForegroundEventL(TBool aForeground)
       
   937     {
       
   938     TRACER("CGlxFullScreenViewImp::HandleForegroundEventL");
       
   939     CAknView::HandleForegroundEventL(aForeground);
       
   940 
       
   941     iUiUtility->SetForegroundStatus(aForeground);
       
   942 
       
   943     if(iMMCState)
       
   944         {
       
   945         iMMCState =EFalse;
       
   946         NavigateToMainListL();
       
   947         }
       
   948     
       
   949     if(iZoomControl && iZoomControl->Activated())
       
   950         {
       
   951         iZoomControl->HandleZoomForegroundEvent(aForeground);
       
   952         }
       
   953 
       
   954     if (!aForeground)
       
   955         {
       
   956         if(iHdmiController)
       
   957 			{   
       
   958             iHdmiController->ShiftToCloningMode();
       
   959 			}
       
   960 		iUiUtility->GlxTextureManager().FlushTextures();
       
   961 		}
       
   962 	else
       
   963 		{
       
   964 		if (iMediaList)
       
   965 			{
       
   966 			/** if there is no image to show go back to the previous view */
       
   967 			if (!iMediaList->Count() && iNaviState->ViewingMode()
       
   968                     == NGlxNavigationalState::EView)
       
   969                 {
       
   970                 iUiUtility->SetViewNavigationDirection(
       
   971                         EGlxNavigationBackwards);
       
   972                 iNaviState->ActivatePreviousViewL();
       
   973                 }
       
   974 			else if (iMediaListMulModelProvider)
       
   975 				{
       
   976 	            UpdateItems();
       
   977 
       
   978 				if (iHdmiController)
       
   979 					{
       
   980 					iHdmiController->ShiftToPostingMode();
       
   981 					}
       
   982 				}
       
   983             }
       
   984         }
       
   985     }
       
   986 
       
   987 
       
   988 // ---------------------------------------------------------------------------
       
   989 // From IAlfWidgetEventHandler..
       
   990 // ---------------------------------------------------------------------------
       
   991 //
       
   992 bool CGlxFullScreenViewImp::accept( CAlfWidgetControl& /*aControl*/,
       
   993 		const TAlfEvent& /*aEvent*/) const
       
   994     {
       
   995     TRACER("CGlxFullScreenViewImp::accept()");
       
   996     return ETrue;
       
   997     }
       
   998 
       
   999 // ---------------------------------------------------------------------------
       
  1000 // From IAlfWidgetEventHandler..
       
  1001 // ---------------------------------------------------------------------------
       
  1002 //
       
  1003 AlfEventStatus CGlxFullScreenViewImp::offerEvent(
       
  1004 		CAlfWidgetControl& /*aControl*/, const TAlfEvent& aEvent)
       
  1005     {
       
  1006     TRACER("CGlxFullScreenViewImp::offerEvent");
       
  1007     // The below function call will not add any values except
       
  1008     // to reduce the codescanner warnings to one
       
  1009     return OfferEventL(aEvent);
       
  1010     }
       
  1011 
       
  1012 // ---------------------------------------------------------------------------
       
  1013 // OfferEventL()
       
  1014 // ---------------------------------------------------------------------------
       
  1015 //
       
  1016 AlfEventStatus CGlxFullScreenViewImp::OfferEventL(const TAlfEvent& aEvent)
       
  1017     {
       
  1018     TRACER("CGlxFullScreenViewImp::offerEventL");
       
  1019     if ( aEvent.IsKeyEvent())
       
  1020         {
       
  1021         switch ( aEvent.KeyEvent().iScanCode )
       
  1022             {
       
  1023             case EStdKeyNkpAsterisk :
       
  1024 				if(iUiUtility->IsPenSupported())
       
  1025 					{
       
  1026 					return EEventNotHandled;
       
  1027 					}
       
  1028             case EStdKeyIncVolume :
       
  1029                 //Listen EStdKeyApplicationD as EKeyZoomIn key is mapped to TKeyCode:: 
       
  1030                 //EKeyApplicationC for which TStdScancode is EStdKeyApplicatoinC
       
  1031             case EStdKeyApplicationC: 
       
  1032                 {
       
  1033                 if(EEventKeyDown == aEvent.Code())
       
  1034                     {
       
  1035                     HideUi(EFalse);
       
  1036                     TRAP_IGNORE( ActivateZoomControlL(EZoomStartKey));
       
  1037                     return EEventConsumed;
       
  1038                     }
       
  1039                 }
       
  1040             case EStdKeyUpArrow:            
       
  1041             case EStdKeyDownArrow:
       
  1042             case EStdKeyDevice0:
       
  1043             case EStdKeyDevice1:
       
  1044                 //Listen EStdKeyApplicationC as EKeyZoomOut key is mapped to TKeyCode:: 
       
  1045                 //EKeyApplicationD for which TStdScancode is EStdKeyApplicatoinD 
       
  1046             case EStdKeyApplicationD: 
       
  1047                 {
       
  1048                 if ( EUiOff == GetUiState()&& (
       
  1049                         aEvent.Code() == EEventKey ) )
       
  1050                     {
       
  1051                     //the Ui timer should be started once the UI screen furniture is shown
       
  1052                     ShowUiL(ETrue);
       
  1053                     } 
       
  1054                 return EEventHandled;              
       
  1055                 }
       
  1056             case EStdKeyLeftArrow:
       
  1057             case EStdKeyRightArrow:
       
  1058                 {
       
  1059                 if ( EUiOn == GetUiState() )                    
       
  1060                     {
       
  1061                     HideUi(ETrue);
       
  1062                     }
       
  1063                 return EEventHandled;
       
  1064                 }
       
  1065 			case EStdKeyApplication1C:
       
  1066            		{
       
  1067 				if(iUiUtility->IsPenSupported())
       
  1068 					{
       
  1069 					return EEventNotHandled;
       
  1070 					}
       
  1071 				else
       
  1072 					{
       
  1073 					ProcessCommandL(KGlxCmdMnShowMap);
       
  1074                     return EEventHandled;  				
       
  1075 					}
       
  1076 				}
       
  1077             default:
       
  1078                 return EEventNotHandled;
       
  1079             }
       
  1080         }
       
  1081     if(!aEvent.IsCustomEvent())
       
  1082         {   
       
  1083         GLX_LOG_INFO("Event Not Handled");          
       
  1084         return EEventNotHandled;
       
  1085         }
       
  1086 
       
  1087     if(aEvent.IsCustomEvent())
       
  1088         {
       
  1089         TInt eventId = aEvent.CustomParameter();
       
  1090         
       
  1091         switch(eventId)
       
  1092             {   
       
  1093             case KAlfActionIdDeviceLayoutChanged:
       
  1094                  {
       
  1095                  iViewWidget->setRect(TRect(TPoint(0,0),AlfUtil::ScreenSize()));
       
  1096                  
       
  1097                  iScreenFurniture->SetToolbarPosition();
       
  1098                                   
       
  1099                  return EEventNotHandled;
       
  1100                  }
       
  1101             case ETypeSelect:
       
  1102                 {
       
  1103                 TBool pensupport = iUiUtility->IsPenSupported();
       
  1104                 if ( pensupport )
       
  1105                     {
       
  1106                     if ( EUiOn == GetUiState() )                    
       
  1107                         {
       
  1108                         //Hide the slider 
       
  1109                         HideUi(ETrue);
       
  1110                         }
       
  1111                     else 
       
  1112                         {
       
  1113                         //the Ui timer should be started once the UI screen furniture is shown
       
  1114                         ShowUiL(ETrue);
       
  1115                         }
       
  1116                     }
       
  1117                 else
       
  1118                     {
       
  1119                     if ( EUiOff == GetUiState() )                    
       
  1120                         {
       
  1121                         //the Ui timer should be started once the UI screen furniture is shown
       
  1122                         ShowUiL(ETrue);
       
  1123                         }
       
  1124                     }
       
  1125                 }
       
  1126                 break;
       
  1127                 
       
  1128             case ETypeRemove:
       
  1129                 {
       
  1130                 // If From photos, delete the img.
       
  1131                 // If Image-Viewer collection and not in private Path 
       
  1132                 // handle the "C" or BackSpace key to delete the item
       
  1133                 if (!iImgViewerMode || (iImageViewerInstance
       
  1134                         && !iImageViewerInstance->IsPrivate()))
       
  1135                     {
       
  1136                     ProcessCommandL(EGlxCmdDelete);
       
  1137                     return EEventConsumed;
       
  1138                     }
       
  1139                 return EEventNotHandled;
       
  1140                 }               
       
  1141             case ETypeDoubleTap:
       
  1142                 {
       
  1143                 GLX_LOG_INFO("CGlxFullScreenViewImp::OfferEventL ETypeDoubleTap");   
       
  1144 
       
  1145                 MulDoubleTapData* DoubleTapData = (MulDoubleTapData*)(aEvent.CustomEventData()); 
       
  1146                 TPoint doubleTapPoint = DoubleTapData->mDoubleTapPoint;
       
  1147                 TInt focus = iMediaList->FocusIndex();
       
  1148                 TGlxMedia item = iMediaList->Item( focus );
       
  1149                 TSize size;
       
  1150                 item.GetDimensions( size );
       
  1151                 TRect rect = AlfUtil::ScreenSize();
       
  1152                 TInt zoomLevel = GetInitialZoomLevel();
       
  1153                 TInt tlX = (rect.Width() - (size.iWidth*zoomLevel)/100)/2;
       
  1154                 TInt tlY = (rect.Height() - (size.iHeight*zoomLevel)/100)/2;
       
  1155                 TRect imageRect(TPoint(tlX, tlY), TSize((size.iWidth*zoomLevel)/100, (size.iHeight*zoomLevel)/100));
       
  1156                 if (imageRect.Contains(doubleTapPoint))
       
  1157                     {
       
  1158                     SetSliderToMin();
       
  1159                     TRAP_IGNORE( ActivateZoomControlL(EZoomStartDoubleTap, &doubleTapPoint)  );
       
  1160                     }
       
  1161                 return EEventConsumed;
       
  1162                 }
       
  1163             case ETypeItemRemoved:
       
  1164                 {
       
  1165                 GLX_LOG_INFO("CGlxFullScreenViewImp::OfferEventL ETypeItemRemoved");
       
  1166                 TInt focusIndex = iMediaList->FocusIndex();
       
  1167                 TInt mlCount = iMediaList->Count();
       
  1168                 GLX_LOG_INFO2("CGlxFullScreenViewImp::OfferEventL focusIndex=%d, iOldFocusIndex=%d",
       
  1169                         focusIndex, iOldFocusIndex);
       
  1170                 if (mlCount && (iOldFocusIndex == focusIndex
       
  1171                         || iOldFocusIndex == mlCount) && iZoomControl
       
  1172                         && iZoomControl->Activated())
       
  1173                     {
       
  1174                     GLX_LOG_INFO("Fcused item is removed, Exit zoom view!");
       
  1175                     DeactivateZoomControlL();
       
  1176                     }
       
  1177                 SetItemToHDMIL();
       
  1178                 if (focusIndex != KErrNotFound && EUiOn == GetUiState())
       
  1179                     {
       
  1180                     // show/hide the slider
       
  1181                     if (iSliderWidget)
       
  1182                         {
       
  1183                         iSliderWidget->ShowWidget(CheckIfSliderToBeShownL());
       
  1184                         }
       
  1185                     }
       
  1186                 /** if this is the last image deleted when Photo is in foreground, go back to the previous view*/
       
  1187                 if (mlCount == 0 && IsForeground()
       
  1188                         && iNaviState->ViewingMode()
       
  1189                                 == NGlxNavigationalState::EView)
       
  1190                     {
       
  1191                     iUiUtility->SetViewNavigationDirection(
       
  1192                             EGlxNavigationBackwards);
       
  1193                     iNaviState->ActivatePreviousViewL();
       
  1194                     }
       
  1195                 TRAP_IGNORE(ShowDrmExpiryNoteL());
       
  1196                 return EEventConsumed;
       
  1197                 }
       
  1198             case ETypeHighlight:
       
  1199                 {
       
  1200                 GLX_LOG_INFO("CGlxFullScreenViewImp::OfferEventL ETypeHighlight");
       
  1201                 iMediaList->SetFocusL( NGlxListDefs::EAbsolute,(aEvent.CustomEventData())); 
       
  1202                 if (AknLayoutUtils::PenEnabled())
       
  1203                 	{
       
  1204                 	iMediaList->SetVisibleWindowIndexL(aEvent.CustomEventData()); 
       
  1205                 	}
       
  1206                 if(iMediaList->Count()> KFullScreenTextureOffset)
       
  1207                     {
       
  1208                     RemoveTexture();
       
  1209                     }
       
  1210                 SetItemToHDMIL();
       
  1211                 if ( EUiOn == GetUiState() )
       
  1212                     {
       
  1213                     HideUi(ETrue);
       
  1214                     }
       
  1215                 TRAP_IGNORE(ShowDrmExpiryNoteL());
       
  1216                 return EEventConsumed;
       
  1217                 }
       
  1218             case EVideoIconSelect:
       
  1219                 {
       
  1220                 TGlxMedia item = iMediaList->Item( iMediaList->FocusIndex() );
       
  1221                 if(item.Category() == EMPXVideo)
       
  1222                     {                                 
       
  1223                     ProcessCommandL(EGlxCmdPlay);
       
  1224                     iViewWidget->show(false);
       
  1225                     } 
       
  1226                 else
       
  1227                     { 
       
  1228                     if ( EUiOn == GetUiState() )                    
       
  1229                         {
       
  1230                         HideUi(ETrue);
       
  1231                         }
       
  1232                     else 
       
  1233                         {
       
  1234                         //the Ui timer should be started once the UI screen furniture is shown
       
  1235                         ShowUiL(ETrue);
       
  1236                         }
       
  1237                     }
       
  1238                 }         
       
  1239                 break;
       
  1240             //Zoom Start via pinch
       
  1241             case ETypePinch:
       
  1242                 // Handle only a pinch out. not a pinch in. 
       
  1243                 if (KGlxNeutralPinchPosition < aEvent.CustomEventData())
       
  1244                     {
       
  1245                     SetSliderToMin();
       
  1246                     TRAP_IGNORE( ActivateZoomControlL(EZoomStartPinch));
       
  1247                     }
       
  1248                 return EEventConsumed; // will be consumed even if we are pinching IN (trying to zoom OUT). 
       
  1249                 //slider event handling   
       
  1250             case ETypePrimaryValueChange:
       
  1251                 {
       
  1252                 iTimer->Cancel();
       
  1253                 iSliderWidget->ShowWidget( ETrue, 0 );
       
  1254                 TRAPD( err, ActivateZoomControlL(EZoomStartSlider));
       
  1255                 if (err != KErrNone)
       
  1256                     {
       
  1257                     iSliderModel->SetPrimaryValue(GetInitialZoomLevel());
       
  1258                     }
       
  1259                 }
       
  1260                 return EEventConsumed;
       
  1261             default:
       
  1262                 return EEventNotHandled;
       
  1263             }
       
  1264         }
       
  1265     return EEventNotHandled;
       
  1266     }
       
  1267 // ---------------------------------------------------------------------------
       
  1268 // From HandleViewCommandL..
       
  1269 // ---------------------------------------------------------------------------
       
  1270 //
       
  1271 TBool CGlxFullScreenViewImp::HandleViewCommandL(TInt aCommand)
       
  1272 	{
       
  1273 	TRACER("GCGlxFullScreenViewImp::HandleViewCommandL");
       
  1274 	//size calculated for rotation
       
  1275 	TSize size = iUiUtility->GetRotatedImageSize(); // ViewBase iUiUtility is use
       
  1276 	TBool consumed = EFalse;
       
  1277 	switch (aCommand)
       
  1278 		{
       
  1279 		case EGlxCmdResetView:
       
  1280 		    {		    
       
  1281 		    HideUi(ETrue);
       
  1282 		    if (iIsDialogLaunched && iIsMMCRemoved)
       
  1283 		        {
       
  1284                 ProcessCommandL(EAknSoftkeyExit);
       
  1285 		        }
       
  1286 		    consumed = ETrue;
       
  1287 		    iIsDialogLaunched = EFalse;
       
  1288 		    break;
       
  1289 		    }
       
  1290 		case EGlxCmdFullScreenBack:
       
  1291 		    DeactivateZoomControlL();
       
  1292 			//Show the screen furniture when we press back from zoom
       
  1293 		    ShowUiL(ETrue);
       
  1294 		    consumed = ETrue;
       
  1295 		    break;
       
  1296 		case EGlxCmdRenameCompleted:
       
  1297 		    {
       
  1298             SetItemToHDMIL();
       
  1299 			consumed = ETrue;
       
  1300             break;
       
  1301             }
       
  1302 		case EGlxCmdDialogLaunched:
       
  1303             {
       
  1304             iIsDialogLaunched = ETrue;
       
  1305             break;
       
  1306             }
       
  1307         case EGlxCmdDialogDismissed:
       
  1308             {
       
  1309             if (iIsDialogLaunched && iIsMMCRemoved)
       
  1310                 {
       
  1311                 ProcessCommandL(EAknSoftkeyExit);
       
  1312                 }
       
  1313             consumed = ETrue;
       
  1314             iIsDialogLaunched = EFalse;
       
  1315             break;
       
  1316             }
       
  1317 		case EAknSoftkeyBack:
       
  1318             {
       
  1319             HideUi(ETrue);
       
  1320             break;
       
  1321             }                        
       
  1322         } 
       
  1323     return consumed;
       
  1324     }
       
  1325 
       
  1326 // ---------------------------------------------------------------------------
       
  1327 // From HandleCommandL..
       
  1328 // ---------------------------------------------------------------------------
       
  1329 //
       
  1330  void CGlxFullScreenViewImp::HandleCommandL(TInt aCommandId, CAlfControl* aControl) 
       
  1331 	 {
       
  1332     TRACER("CGlxFullScreenViewImp::HandleCommandLCAlfControl");
       
  1333     //Gets a callback from zoomview if zoomlevel goes beyound the launch zoomlevel
       
  1334     // and activates the fullscreenview
       
  1335     if (aControl == iZoomControl)
       
  1336         {
       
  1337         if (aCommandId == KGlxZoomOutCommand)
       
  1338             {
       
  1339             DeactivateZoomControlL();
       
  1340             }
       
  1341         else if(aCommandId == KGlxZoomOrientationChange)
       
  1342             {
       
  1343             iViewWidget->setRect(TRect(TPoint(0,0),AlfUtil::ScreenSize()));
       
  1344             }
       
  1345         }
       
  1346 	} 
       
  1347 
       
  1348 // ---------------------------------------------------------------------------
       
  1349 // From HandleResourceChangeL..
       
  1350 // ---------------------------------------------------------------------------
       
  1351 //
       
  1352  void CGlxFullScreenViewImp::HandleResourceChangeL (TInt aType)
       
  1353      {
       
  1354      TRACER("CGlxFullScreenViewImp::HandleResourceChangeL");
       
  1355          HandleResourceChangeL ( aType);
       
  1356     }   
       
  1357 
       
  1358 //----------------------------------------------------------------------------------
       
  1359 // InitialZoomLevel:Calculate the initial Zoom Level for the Image
       
  1360 //----------------------------------------------------------------------------------
       
  1361 //
       
  1362 TInt CGlxFullScreenViewImp::GetInitialZoomLevel()
       
  1363     {
       
  1364     TRACER("CGlxFullScreenViewImp::InitialZoomLevel");
       
  1365     TInt focus     = iMediaList->FocusIndex();
       
  1366     TGlxMedia item = iMediaList->Item( focus );
       
  1367     TSize size;
       
  1368     TUint8 initialZoomLevel;
       
  1369     item.GetDimensions( size );
       
  1370     if (KGlxDecodingThreshold < (size.iWidth * size.iHeight))
       
  1371         {
       
  1372         TReal areaRatio = TReal(size.iWidth*size.iHeight)/KGlxDecodingThreshold ;
       
  1373         
       
  1374         TReal sideRatio;
       
  1375         Math::Sqrt(sideRatio, areaRatio);
       
  1376         
       
  1377         size.iHeight = size.iHeight /  sideRatio ;
       
  1378         size.iWidth  = size.iWidth  /  sideRatio ;
       
  1379         }
       
  1380     TRect rect = AlfUtil::ScreenSize();
       
  1381 
       
  1382     if( rect.Width()>= size.iWidth && rect.Height() >= size.iHeight)
       
  1383         {
       
  1384         //if Both the Width and Height are lesser than the screen size,the initial Zoom Level will be 100
       
  1385         initialZoomLevel = KGlxMinSmallImageZoomLevel;
       
  1386         }
       
  1387     else
       
  1388         {
       
  1389         //Calculate (Display Area Width)  /Image Width   * 100
       
  1390         //Calculate (Display Area Height) /Image Height  * 100
       
  1391         //Choose the Minimum Of the above.
       
  1392         TReal32 imageWidthRatio  = ((TReal32) rect.Width() / size.iWidth )*100.0F;
       
  1393         TReal32 imageHeightRatio = ((TReal32)rect.Height()/ size.iHeight )*100.0F;
       
  1394         initialZoomLevel = Min(imageWidthRatio,imageHeightRatio);
       
  1395         } 
       
  1396     
       
  1397     // A correction of 0.5 (KGlxRealTruncationPadding) is added to the resultant value. 
       
  1398     // This ensures that all return values greater than X.5 (e.g lets say 12.8) is pegged to X+1(13)
       
  1399     // instead of X(12) while calculating. 
       
  1400     // Changing the calculations to real might have been a better idea, 
       
  1401     // but that involves many changes in many places and was therefore avoided, 
       
  1402     // maybe a good idea to take up in PS2.
       
  1403     GLX_LOG_INFO1("CGlxFullScreenViewImp::GetInitialZoomLevel() = %d ", KGlxRealTruncationPadding + initialZoomLevel);
       
  1404     return KGlxRealTruncationPadding + initialZoomLevel ;
       
  1405     }
       
  1406 
       
  1407 //----------------------------------------------------------------------------------
       
  1408 // SetSliderLevel() Set the Initial Zoom Level for the Image
       
  1409 //----------------------------------------------------------------------------------
       
  1410 //
       
  1411 void CGlxFullScreenViewImp::SetSliderToMin()
       
  1412     {
       
  1413     TRACER("CGlxFullScreenViewImp::SetSliderLevel");
       
  1414 
       
  1415     TInt value = GetInitialZoomLevel();
       
  1416     if(iSliderModel)
       
  1417         {
       
  1418         iSliderModel->SetMinRange(value);
       
  1419         (value==KGlxMaxBigImageZoomLevel)?(iSliderModel->SetMaxRange(KGlxMaxSmallImageZoomLevel))
       
  1420             :(iSliderModel->SetMaxRange(KGlxMaxBigImageZoomLevel));
       
  1421         iSliderModel->SetPrimaryValue(value);
       
  1422         }
       
  1423     }
       
  1424 
       
  1425 // ---------------------------------------------------------------------------
       
  1426 // From IAlfWidgetEventHandler..
       
  1427 // ---------------------------------------------------------------------------
       
  1428 //
       
  1429 void CGlxFullScreenViewImp::setEventHandlerData(
       
  1430 		const AlfWidgetEventHandlerInitData& /*aData*/)
       
  1431     {
       
  1432     TRACER("CGlxFullScreenViewImp::setEventHandlerData");
       
  1433     }
       
  1434 
       
  1435 // ---------------------------------------------------------------------------
       
  1436 // From IAlfWidgetEventHandler..
       
  1437 // ---------------------------------------------------------------------------
       
  1438 //
       
  1439 AlfWidgetEventHandlerInitData* CGlxFullScreenViewImp::eventHandlerData()
       
  1440     {
       
  1441     TRACER("CGlxFullScreenViewImp::eventHandlerData");
       
  1442     return NULL;
       
  1443     }
       
  1444 
       
  1445 // ---------------------------------------------------------------------------
       
  1446 // From IAlfWidgetEventHandler.
       
  1447 // ---------------------------------------------------------------------------
       
  1448 //
       
  1449 void CGlxFullScreenViewImp::setActiveStates( unsigned int /*aStates*/ )
       
  1450     {
       
  1451     TRACER("CGlxFullScreenViewImp::setActiveStates");
       
  1452     }
       
  1453 
       
  1454 // ---------------------------------------------------------------------------
       
  1455 // From IAlfWidgetEventHandler.
       
  1456 // ---------------------------------------------------------------------------
       
  1457 //
       
  1458 
       
  1459 IAlfInterfaceBase* CGlxFullScreenViewImp::makeInterface( const IfId& /*aType*/ )
       
  1460     {
       
  1461     TRACER("CGlxFullScreenViewImp::makeInterface");
       
  1462     return NULL;
       
  1463     }
       
  1464 
       
  1465 //----------------------------------------------------------------------------------
       
  1466 // eventHandlerType
       
  1467 //----------------------------------------------------------------------------------
       
  1468 //
       
  1469 IAlfWidgetEventHandler::AlfEventHandlerType CGlxFullScreenViewImp::eventHandlerType() 
       
  1470 	{
       
  1471 	TRACER("CGlxFullScreenViewImp::eventHandlerType");
       
  1472 	return IAlfWidgetEventHandler::ELogicalEventHandler;
       
  1473 	}
       
  1474 
       
  1475 //----------------------------------------------------------------------------------
       
  1476 // eventExecutionPhase
       
  1477 //----------------------------------------------------------------------------------
       
  1478 //
       
  1479 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase CGlxFullScreenViewImp::eventExecutionPhase()
       
  1480 	{
       
  1481 	TRACER("CGlxFullScreenViewImp::eventHandlerType");
       
  1482     return EBubblingPhaseEventHandler;
       
  1483 	}   
       
  1484 
       
  1485 // -----------------------------------------------------------------------------
       
  1486 // Callback from periodic timer
       
  1487 // -----------------------------------------------------------------------------
       
  1488 //
       
  1489 TInt CGlxFullScreenViewImp::PeriodicCallback(TAny* aPtr )
       
  1490     {
       
  1491     TRACER("CGlxFullScreenViewImp::PeriodicCallback");
       
  1492     static_cast< CGlxFullScreenViewImp* >( aPtr )->CallPeriodicCallback();
       
  1493     return KErrNone;
       
  1494     }
       
  1495 	
       
  1496 // -----------------------------------------------------------------------------
       
  1497 // Callback from periodic timer-- non static
       
  1498 // -----------------------------------------------------------------------------
       
  1499 //
       
  1500 inline void CGlxFullScreenViewImp::CallPeriodicCallback()
       
  1501     {
       
  1502     TRACER("CGlxFullScreenViewImp::CallPeriodicCallback");
       
  1503     TRAP_IGNORE(ShowDrmExpiryNoteL());
       
  1504     }
       
  1505 	
       
  1506 // ---------------------------------------------------------------------------
       
  1507 // Shows expiry note / Consumes DRM rights for expired DRM files
       
  1508 // ---------------------------------------------------------------------------
       
  1509 //
       
  1510 void CGlxFullScreenViewImp::ShowDrmExpiryNoteL()
       
  1511 	{
       
  1512     TRACER("CGlxFullScreenViewImp::ShowDrmExpiryNoteL");
       
  1513     if (iMediaList->Count() > 0)
       
  1514         {
       
  1515         const TGlxMedia& media = iMediaList->Item(iMediaList->FocusIndex());
       
  1516         TInt tnError = GlxErrorManager::HasAttributeErrorL(
       
  1517                 media.Properties(), KGlxMediaIdThumbnail);
       
  1518         GLX_LOG_INFO1("CGlxFullScreenViewImp::ShowDrmExpiryNoteL()"
       
  1519                 " tnError=%d ", tnError);
       
  1520 
       
  1521         if (media.IsDrmProtected())
       
  1522             {
       
  1523             GLX_LOG_INFO("CGlxFullScreenViewImp::ShowDrmExpiryNoteL()"
       
  1524                     "- ConsumeDRMRightsL()");
       
  1525             //Consume DRM Rights & cancel Periodic timer for DRM images
       
  1526             //only if Quality TN is available
       
  1527             ConsumeDRMRightsL(media);
       
  1528             }
       
  1529         else
       
  1530             {
       
  1531             //Cancel the periodic timer if quality thumbnail is available
       
  1532             //and no error in fetching quality thumbnail.
       
  1533             TSize tnSize = iUiUtility->DisplaySize();
       
  1534             TMPXAttribute qtyTnAttrib = TMPXAttribute(KGlxMediaIdThumbnail,
       
  1535                     GlxFullThumbnailAttributeId(ETrue, tnSize.iWidth,
       
  1536                             tnSize.iHeight));
       
  1537             const CGlxThumbnailAttribute* qtyTn = media.ThumbnailAttribute(
       
  1538                     qtyTnAttrib);
       
  1539             if (qtyTn && tnError == KErrNone)
       
  1540                 {
       
  1541                 if (iPeriodic->IsActive())
       
  1542                     {
       
  1543                     iPeriodic->Cancel();
       
  1544                     }
       
  1545                 }
       
  1546             }
       
  1547         
       
  1548         //check if any Error message is to be displayed
       
  1549         TMPXGeneralCategory cat = media.Category();
       
  1550         TBool checkViewRights = ETrue;
       
  1551         if (media.IsDrmProtected())
       
  1552             {
       
  1553             GLX_LOG_INFO("CGlxFullScreenViewImp::ShowDrmExpiryNoteL()"
       
  1554                     "- ItemRightsValidityCheckL()");
       
  1555             if (iImgViewerMode && iImageViewerInstance->IsPrivate())
       
  1556                 {
       
  1557                 checkViewRights = iDrmUtility->ItemRightsValidityCheckL(
       
  1558                         iImageViewerInstance->ImageFileHandle(),
       
  1559                         (media.Category() == EMPXImage));
       
  1560                 }
       
  1561             else
       
  1562                 {
       
  1563                 //Since it is always for the focused item - use DisplayItemRightsCheckL instead of ItemRightsValidityCheckL
       
  1564                 checkViewRights = iDrmUtility->ItemRightsValidityCheckL(
       
  1565                         media.Uri(), (media.Category() == EMPXImage));
       
  1566                 }
       
  1567             }
       
  1568         if (checkViewRights && tnError != KErrNone)
       
  1569             {
       
  1570             if (iPeriodic->IsActive())
       
  1571                 {
       
  1572                 iPeriodic->Cancel();
       
  1573                 }
       
  1574 
       
  1575             if (iImgViewerMode)
       
  1576                 {
       
  1577                 GLX_LOG_INFO1("CGlxFullScreenViewImp::ShowDrmExpiryNoteL()"
       
  1578                         "- ShowErrorNoteL(%d)", tnError);
       
  1579                 if (tnError == KErrNoMemory || tnError == KErrNotSupported
       
  1580                         || tnError == KErrInUse || tnError == KErrDiskFull
       
  1581                         || tnError == KErrTimedOut || tnError
       
  1582                         == KErrPermissionDenied)
       
  1583                     {
       
  1584                     GlxGeneralUiUtilities::ShowErrorNoteL(tnError);
       
  1585                     }
       
  1586                 else
       
  1587                     {
       
  1588                     // Generic "Unable to open image" error note
       
  1589                     HBufC* str = StringLoader::LoadLC(
       
  1590                             R_GLX_ERR_FORMAT_UNKNOWN);
       
  1591                     CAknErrorNote* note = new (ELeave) CAknErrorNote(ETrue);
       
  1592                     note->ExecuteLD(*str); // ignore return value, not used
       
  1593                     CleanupStack::PopAndDestroy(str);
       
  1594                     }
       
  1595                 }
       
  1596             }
       
  1597         }
       
  1598     }
       
  1599 
       
  1600 // ---------------------------------------------------------------------------
       
  1601 // Consumes DRM rights / Shows DRM rights (if expired) information 
       
  1602 // for DRM files
       
  1603 // ---------------------------------------------------------------------------
       
  1604 //
       
  1605 void CGlxFullScreenViewImp::ConsumeDRMRightsL(const TGlxMedia& aMedia)
       
  1606     {
       
  1607     TRACER("CGlxFullScreenViewImp::ConsumeDRMRightsL");
       
  1608     const TDesC& uri = aMedia.Uri();
       
  1609     if (uri.Length() > 0)
       
  1610         {
       
  1611         // check if rights have expired
       
  1612         TBool expired = EFalse;
       
  1613         if (iImgViewerMode && iImageViewerInstance->IsPrivate())
       
  1614             {
       
  1615             expired = !iDrmUtility->ItemRightsValidityCheckL(
       
  1616                     iImageViewerInstance->ImageFileHandle(),
       
  1617                     ETrue);
       
  1618             }
       
  1619         else
       
  1620             {
       
  1621             expired = !iDrmUtility->ItemRightsValidityCheckL(uri, ETrue);
       
  1622             }
       
  1623 
       
  1624         if (expired)
       
  1625             {
       
  1626             if (iPeriodic->IsActive())
       
  1627                 {
       
  1628                 iPeriodic->Cancel();
       
  1629                 }
       
  1630             iBusyIcon->ShowBusyIconL(EFalse);
       
  1631             if(iImgViewerMode && iImageViewerInstance->IsPrivate())
       
  1632                 {
       
  1633                 iDrmUtility->ShowRightsInfoL(iImageViewerInstance->ImageFileHandle());
       
  1634                 }
       
  1635             else
       
  1636                 {
       
  1637                 iDrmUtility->ShowRightsInfoL(uri);
       
  1638                 }
       
  1639             return;
       
  1640             }
       
  1641 
       
  1642         TSize tnSize = iUiUtility->DisplaySize();
       
  1643         TMPXAttribute qtyTnAttrib = TMPXAttribute(KGlxMediaIdThumbnail,
       
  1644                 GlxFullThumbnailAttributeId(ETrue, tnSize.iWidth,
       
  1645                         tnSize.iHeight));
       
  1646         const CGlxThumbnailAttribute* qtyTn = aMedia.ThumbnailAttribute(
       
  1647                 qtyTnAttrib);
       
  1648 
       
  1649         TInt tnError = GlxErrorManager::HasAttributeErrorL(
       
  1650                 aMedia.Properties(), KGlxMediaIdThumbnail);
       
  1651         GLX_LOG_INFO1("CGlxFullScreenViewImp::ConsumeDRMRightsL()"
       
  1652                 " tnError=%d ", tnError);
       
  1653         if (qtyTn && tnError == KErrNone)
       
  1654             {
       
  1655             if (iPeriodic->IsActive())
       
  1656                 {
       
  1657                 iPeriodic->Cancel();
       
  1658                 }
       
  1659             GLX_LOG_INFO("CGlxFullScreenViewImp::ConsumeDRMRightsL()"
       
  1660                     "- ConsumeRights");
       
  1661             if(iImgViewerMode && iImageViewerInstance->IsPrivate())
       
  1662                 {
       
  1663                 iDrmUtility->ConsumeRightsL(iImageViewerInstance->ImageFileHandle());
       
  1664                 }
       
  1665             else
       
  1666                 {
       
  1667                 iDrmUtility->ConsumeRightsL(uri);
       
  1668                 }
       
  1669             }
       
  1670         }
       
  1671     }
       
  1672 
       
  1673 // ---------------------------------------------------------------------------
       
  1674 // 
       
  1675 // Gets the Swipe direction
       
  1676 // ---------------------------------------------------------------------------
       
  1677 //
       
  1678 TSwipe CGlxFullScreenViewImp::GetSwipeDirection()
       
  1679     {
       
  1680     TRACER("CGlxFullScreenViewImp::GetSwipeDirection");
       
  1681     
       
  1682     TInt count = iMediaList->Count();
       
  1683     TInt focusindex = iMediaList->FocusIndex();
       
  1684     TSwipe swipedirection;
       
  1685     
       
  1686     if(focusindex == 0)
       
  1687         {
       
  1688         swipedirection = (iOldFocusIndex == 1 ? EBackward : EForward);
       
  1689         }
       
  1690     else if(focusindex == count-1)
       
  1691         {
       
  1692         swipedirection = (iOldFocusIndex == 0 ? EBackward : EForward);
       
  1693         }
       
  1694     else
       
  1695         {
       
  1696         swipedirection = (focusindex-iOldFocusIndex < 0 ? EBackward : EForward) ;
       
  1697         }     
       
  1698     GLX_LOG_INFO1("CGlxFullScreenViewImp::GetSwipeDirection()"
       
  1699             " Direction = [%d] ", swipedirection);
       
  1700 
       
  1701     return swipedirection;        
       
  1702     }
       
  1703 
       
  1704 // ---------------------------------------------------------------------------
       
  1705 // 
       
  1706 // Gets the index of the item for which the texture has to be removed
       
  1707 // ---------------------------------------------------------------------------
       
  1708 //
       
  1709 TInt CGlxFullScreenViewImp::GetIndexToBeRemoved()
       
  1710     {
       
  1711     TRACER("CGlxFullScreenViewImp::GetIndexToBeRemoved");
       
  1712     
       
  1713     TSwipe swipedirection = GetSwipeDirection();
       
  1714     TInt indextoberemoved;
       
  1715     TInt count = iMediaList->Count();
       
  1716     TInt focusindex = iMediaList->FocusIndex();
       
  1717     if(swipedirection == EForward)
       
  1718         {
       
  1719         indextoberemoved = focusindex-KFullScreenIterator;
       
  1720         if(indextoberemoved < 0)
       
  1721             {
       
  1722             indextoberemoved = count+indextoberemoved;
       
  1723             }
       
  1724         }
       
  1725     else
       
  1726         {
       
  1727         indextoberemoved = focusindex+KFullScreenIterator;
       
  1728         if(indextoberemoved > count-1)
       
  1729           {
       
  1730           indextoberemoved = indextoberemoved-count;
       
  1731           }        
       
  1732         }
       
  1733     GLX_LOG_INFO1("CGlxFullScreenViewImp::GetIndexToBeRemoved index tobe removed %d",indextoberemoved );
       
  1734     return indextoberemoved;
       
  1735     }
       
  1736 
       
  1737 // ---------------------------------------------------------------------------
       
  1738 // 
       
  1739 // Remove the texture on every swipe while HDMI is connected.
       
  1740 // ---------------------------------------------------------------------------
       
  1741 //
       
  1742 void CGlxFullScreenViewImp::RemoveTexture()
       
  1743     {
       
  1744     TRACER("CGlxFullScreenViewImp::RemoveTexture");
       
  1745     
       
  1746     const TGlxMedia& item = iMediaList->Item(GetIndexToBeRemoved());
       
  1747     iUiUtility->GlxTextureManager().RemoveTexture(item.Id(),EFalse);
       
  1748     }
       
  1749 
       
  1750 // ---------------------------------------------------------------------------
       
  1751 // 
       
  1752 // Set the focused item to external display - HDMI
       
  1753 // ---------------------------------------------------------------------------
       
  1754 //
       
  1755 void CGlxFullScreenViewImp::SetItemToHDMIL()
       
  1756     {
       
  1757     TRACER("CGlxFullScreenViewImp::SetItemToHDMIL()");
       
  1758 
       
  1759     TInt focusIndex = iMediaList->FocusIndex();
       
  1760 
       
  1761     // If we dont know what item we are focussing on 
       
  1762     // or if our medialist is empty
       
  1763     // or if there is no HDMI Controller at all 
       
  1764     // then dont SetItemToHDMI :)  
       
  1765     if ((KErrNotFound == focusIndex) || (0 == iMediaList->Count()) || (NULL
       
  1766             == iHdmiController))
       
  1767         {
       
  1768         GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Cant Set Image To HDMI");
       
  1769         return;
       
  1770         }
       
  1771     
       
  1772     TGlxMedia item = iMediaList->Item(focusIndex);
       
  1773     TInt error = GlxErrorManager::HasAttributeErrorL(item.Properties(),
       
  1774             KGlxMediaIdThumbnail);
       
  1775     GLX_LOG_INFO1("CGlxFullScreenViewImp::SetItemToHDMIL - error=%d", error);
       
  1776 
       
  1777     TBool canView = ETrue;
       
  1778     if (item.IsDrmProtected())
       
  1779         {
       
  1780         canView = iDrmUtility->ItemRightsValidityCheckL(item.Uri(),
       
  1781                 (item.Category() == EMPXImage));
       
  1782         }
       
  1783     GLX_LOG_INFO1("CGlxFullScreenViewImp::SetItemToHDMIL - canView=%d", canView);        
       
  1784     
       
  1785     // Item will be supported by HDMI ONLY if
       
  1786     // it is not a video
       
  1787     // and it is DRM protected and has valid DRM Viewing rights
       
  1788     // and it has no attribute error 
       
  1789     if ((item.Category() != EMPXVideo) && canView && (error == KErrNone))
       
  1790         {
       
  1791         GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Fetch FS thumbnail");
       
  1792         TMPXAttribute fsTnAttrib = TMPXAttribute(KGlxMediaIdThumbnail,
       
  1793                 GlxFullThumbnailAttributeId(ETrue, iScrnSize.iWidth,
       
  1794                         iScrnSize.iHeight));
       
  1795         const CGlxThumbnailAttribute* fsValue = item.ThumbnailAttribute(
       
  1796                 fsTnAttrib);
       
  1797         if (fsValue)
       
  1798             {
       
  1799             GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Setting FS Bitmap");
       
  1800             CFbsBitmap* fsBitmap = new (ELeave) CFbsBitmap;
       
  1801             CleanupStack::PushL(fsBitmap);
       
  1802             fsBitmap->Duplicate( fsValue->iBitmap->Handle());
       
  1803             
       
  1804             GLX_LOG_INFO2("CGlxFullScreenViewImp::SetItemToHDMIL - FS Bitmap Size width=%d, height=%d", 
       
  1805                     fsBitmap->SizeInPixels().iWidth, fsBitmap->SizeInPixels().iHeight);
       
  1806             iHdmiController->SetImageL(item.Uri(), KNullDesC, fsBitmap);
       
  1807             CleanupStack::PopAndDestroy(fsBitmap);
       
  1808             }
       
  1809         else
       
  1810             {
       
  1811             GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Fetch Grid thumbnail");
       
  1812             TMPXAttribute gridTnAttrib = TMPXAttribute(KGlxMediaIdThumbnail,
       
  1813                     GlxFullThumbnailAttributeId(ETrue, iGridIconSize.iWidth,
       
  1814                             iGridIconSize.iHeight));
       
  1815             const CGlxThumbnailAttribute* gridvalue = item.ThumbnailAttribute(
       
  1816                     gridTnAttrib);
       
  1817 
       
  1818             if (gridvalue)
       
  1819                 {
       
  1820                 GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Setting Grid Bitmap");
       
  1821                 CFbsBitmap* gridBitmap = new (ELeave) CFbsBitmap;
       
  1822                 CleanupStack::PushL(gridBitmap);
       
  1823                 gridBitmap->Duplicate( gridvalue->iBitmap->Handle());
       
  1824                 
       
  1825                 GLX_LOG_INFO2("CGlxFullScreenViewImp::SetItemToHDMIL - gridBitmap Size width=%d, height=%d", 
       
  1826                         gridBitmap->SizeInPixels().iWidth, gridBitmap->SizeInPixels().iHeight);
       
  1827                 iHdmiController->SetImageL(item.Uri(), KNullDesC, gridBitmap);
       
  1828                 CleanupStack::PopAndDestroy(gridBitmap);
       
  1829                 }
       
  1830             else
       
  1831                 {
       
  1832                 GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Setting Default Bitmap");
       
  1833                 TFileName resFile(KDC_APP_BITMAP_DIR);
       
  1834                 resFile.Append(KGlxIconsFilename);
       
  1835                 CFbsBitmap* defaultBitmap = AknIconUtils::CreateIconL(resFile,
       
  1836                         EMbmGlxiconsQgn_prop_image_notcreated);
       
  1837                 CleanupStack::PushL(defaultBitmap);
       
  1838                 
       
  1839                 // always need to setsize on the raw bitmap for it to be visible
       
  1840                 AknIconUtils::SetSize(defaultBitmap, TSize(iHdmiWidth,iHdmiHeight),EAspectRatioPreserved);
       
  1841 
       
  1842                 GLX_LOG_INFO2("CGlxFullScreenViewImp::SetItemToHDMIL - Default Size width=%d, height=%d", 
       
  1843                         defaultBitmap->SizeInPixels().iWidth, defaultBitmap->SizeInPixels().iHeight);
       
  1844                 iHdmiController->SetImageL(item.Uri(), KNullDesC, defaultBitmap);
       
  1845                 CleanupStack::PopAndDestroy(defaultBitmap); 
       
  1846                 }
       
  1847             }
       
  1848         }
       
  1849     else
       
  1850         {
       
  1851         GLX_LOG_INFO("CGlxFullScreenViewImp::SetItemToHDMIL - Unsupported Item");
       
  1852         //Set the external display to cloning mode if
       
  1853         //the current item is something we dont support 
       
  1854         //(e.g. video, corrupted item, item with invalid DRM)
       
  1855         iHdmiController->ItemNotSupported();
       
  1856         }
       
  1857     iOldFocusIndex = iMediaList->FocusIndex();
       
  1858     }
       
  1859 
       
  1860 // ---------------------------------------------------------------------------
       
  1861 // HandleMMCInsertionL
       
  1862 // 
       
  1863 // ---------------------------------------------------------------------------
       
  1864 void CGlxFullScreenViewImp::HandleMMCInsertionL()
       
  1865     {
       
  1866     TRACER("CGlxFullScreenViewImp::HandleMMCInsertionL()");
       
  1867     iMMCState = ETrue;
       
  1868     NavigateToMainListL();
       
  1869     }
       
  1870 	
       
  1871 // ---------------------------------------------------------------------------
       
  1872 // NavigateToMainListL
       
  1873 // 
       
  1874 // ---------------------------------------------------------------------------
       
  1875 void CGlxFullScreenViewImp::NavigateToMainListL()
       
  1876     {
       
  1877     TRACER("CGlxFullScreenViewImp::NavigateToMainListL()");
       
  1878     if (!iImgViewerMode)
       
  1879         {
       
  1880         if (iZoomControl && iZoomControl->Activated())
       
  1881             {
       
  1882             DeactivateZoomControlL();
       
  1883             }
       
  1884         ProcessCommandL( EAknSoftkeyClose);
       
  1885         }
       
  1886     }
       
  1887 	
       
  1888 // ---------------------------------------------------------------------------
       
  1889 // HandleMMCRemovalL
       
  1890 // 
       
  1891 // ---------------------------------------------------------------------------
       
  1892 void CGlxFullScreenViewImp::HandleMMCRemovalL()
       
  1893     {
       
  1894     TRACER("CGlxFullScreenViewImp::HandleMMCRemovalL()");
       
  1895     iIsMMCRemoved = ETrue;
       
  1896     if(!iIsDialogLaunched)
       
  1897         {
       
  1898         if(iZoomControl && iZoomControl->Activated())
       
  1899             {
       
  1900             DeactivateZoomControlL();   
       
  1901             }
       
  1902         ProcessCommandL(EAknSoftkeyExit);
       
  1903         }
       
  1904     }
       
  1905 	
       
  1906 // ---------------------------------------------------------------------------
       
  1907 // EnableFSToolbar
       
  1908 // ---------------------------------------------------------------------------
       
  1909 //
       
  1910 void CGlxFullScreenViewImp::EnableFSToolbar(TBool aEnable)
       
  1911     {
       
  1912 	TRACER("CGlxFullScreenViewImp::EnableFSToolbar()");
       
  1913     CAknToolbar* toolbar = Toolbar();
       
  1914     if(toolbar)
       
  1915         {
       
  1916         TRAP_IGNORE(toolbar->DisableToolbarL(!aEnable));
       
  1917         toolbar->SetToolbarVisibility(aEnable); 
       
  1918         }
       
  1919     }
       
  1920 	
       
  1921 // ---------------------------------------------------------------------------
       
  1922 // HandleEffectCallback
       
  1923 // 
       
  1924 // ---------------------------------------------------------------------------
       
  1925 //
       
  1926 void CGlxFullScreenViewImp::HandleEffectCallback(TInt aType, TInt aHandle, 
       
  1927                                                  TInt /*aStatus*/)
       
  1928     {
       
  1929     TRACER("CGlxFullScreenViewImp::HandleEffectCallback()");
       
  1930     if (aHandle == iEffectHandle && aType == EAlfEffectComplete
       
  1931             && iCoverFlowWidget)
       
  1932         {
       
  1933         TRAP_IGNORE(const_cast<CAlfLayout&>
       
  1934                 (iCoverFlowWidget->ContainerLayout()).SetEffectL(
       
  1935                         KTfxResourceNoEffect));
       
  1936         }
       
  1937     }
       
  1938 
       
  1939 // -----------------------------------------------------------------------------
       
  1940 // CreateImageViewerInstanceL
       
  1941 // -----------------------------------------------------------------------------
       
  1942 //
       
  1943 void CGlxFullScreenViewImp::CreateImageViewerInstanceL()
       
  1944     {
       
  1945     TRACER("CGlxFullScreenViewImp::CreateImageViewerInstanceL");
       
  1946     iImageViewerInstance = CGlxImageViewerManager::InstanceL();    
       
  1947     __ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer));
       
  1948     }
       
  1949 
       
  1950 // -----------------------------------------------------------------------------
       
  1951 // DeleteImageViewerInstance
       
  1952 // -----------------------------------------------------------------------------
       
  1953 //
       
  1954 void CGlxFullScreenViewImp::DeleteImageViewerInstance()
       
  1955     {
       
  1956     TRACER("CGlxFullScreenViewImp::DeleteImageViewerInstance");
       
  1957     if ( iImageViewerInstance )
       
  1958         {
       
  1959         iImageViewerInstance->DeleteInstance();
       
  1960         }
       
  1961     }
       
  1962 	
       
  1963 // -----------------------------------------------------------------------------
       
  1964 // HandleTvStatusChangedL 
       
  1965 // -----------------------------------------------------------------------------
       
  1966 void CGlxFullScreenViewImp::HandleTvStatusChangedL( TTvChangeType aChangeType )
       
  1967     {
       
  1968     TRACER("CGlxFullScreenViewImp::HandleTvStatusChangedL()");
       
  1969     GLX_LOG_INFO1("CGlxFullScreenViewImp::HandleTvStatusChangedL(%d)",
       
  1970             aChangeType);
       
  1971 
       
  1972     if (aChangeType == ETvConnectionChanged)
       
  1973         {
       
  1974         // Hide UI furnitures when HDMI cable is connected/Disconnected
       
  1975         // irrespective of UI state on/off.
       
  1976         HideUi(ETrue);
       
  1977         }
       
  1978     }
       
  1979 
       
  1980 // ---------------------------------------------------------------------------
       
  1981 // CheckIfSliderToBeShownL
       
  1982 // ---------------------------------------------------------------------------
       
  1983 TBool CGlxFullScreenViewImp::CheckIfSliderToBeShownL()
       
  1984     {
       
  1985     TRACER("CGlxFullScreenViewImp::CheckIfSliderToBeShownL()");
       
  1986 
       
  1987     TInt index = iMediaList->FocusIndex();
       
  1988     const TGlxMedia& item = iMediaList->Item(index);
       
  1989     TInt error = GlxErrorManager::HasAttributeErrorL(item.Properties(),
       
  1990             KGlxMediaIdThumbnail);
       
  1991        
       
  1992     TBool isDrmRightsValid = ETrue;
       
  1993 	if(item.IsDrmProtected())
       
  1994 		{
       
  1995         if (iImgViewerMode && iImageViewerInstance->IsPrivate())
       
  1996             {
       
  1997             isDrmRightsValid = iDrmUtility->DisplayItemRightsCheckL(
       
  1998                     iImageViewerInstance->ImageFileHandle(), (item.Category()
       
  1999                             == EMPXImage));
       
  2000             }
       
  2001         else
       
  2002             {
       
  2003             //Since it is always for the focused item - use DisplayItemRightsCheckL instead of ItemRightsValidityCheckL
       
  2004             isDrmRightsValid = iDrmUtility->DisplayItemRightsCheckL(
       
  2005                     item.Uri(), (item.Category() == EMPXImage));
       
  2006             }
       
  2007         }
       
  2008 	
       
  2009     // Display slider only for non corrupted images and items with valid DRM license
       
  2010 	if (iHdmiController && iHdmiController->IsHDMIConnected())
       
  2011         {
       
  2012         //hide slider if UI is needed to be on and HDMI is Connected
       
  2013 		return EFalse;
       
  2014         }
       
  2015     else if(error == KErrNone && item.Category() == EMPXImage
       
  2016             && isDrmRightsValid )
       
  2017         {
       
  2018         return ETrue;
       
  2019         }
       
  2020     return EFalse;
       
  2021     }
       
  2022 
       
  2023 //---------------------------------------------------------------------------
       
  2024 // HandleHDMIDecodingEventL
       
  2025 //---------------------------------------------------------------------------   
       
  2026 void CGlxFullScreenViewImp::HandleHDMIDecodingEventL(
       
  2027         THdmiDecodingStatus /*aStatus*/)
       
  2028     {
       
  2029     TRACER("CGlxFullScreenViewImp::HandleHDMIDecodingEventL()");
       
  2030     }
       
  2031 
       
  2032 // ---------------------------------------------------------------------------
       
  2033 // UpdateItems
       
  2034 // ---------------------------------------------------------------------------
       
  2035 void CGlxFullScreenViewImp::UpdateItems()
       
  2036     {
       
  2037     TRACER("CGlxFullScreenViewImp::UpdateItems()");
       
  2038     TInt focusIndex = iMediaList->FocusIndex();
       
  2039     TInt count = iMediaList->Count();
       
  2040     GLX_LOG_INFO2("CGlxFullScreenViewImp::UpdateItems()"
       
  2041             " focusIndex(%d), count(%d)", focusIndex, count);
       
  2042     
       
  2043     if (focusIndex != KErrNotFound && count)
       
  2044         {        
       
  2045         // update the focus index first
       
  2046 		iMediaListMulModelProvider->UpdateItems(focusIndex, 1);
       
  2047 
       
  2048         TInt startIndex = focusIndex;
       
  2049         TInt iteratorCount = (KTextureOffset > count) ? 
       
  2050                                 count : KTextureOffset;
       
  2051         TInt textureCount = (KFullScreenTextureOffset > count)?
       
  2052                                 count : KFullScreenTextureOffset;
       
  2053 
       
  2054         startIndex = focusIndex - iteratorCount;
       
  2055         if (startIndex < 0)
       
  2056             {
       
  2057             startIndex = count + startIndex;
       
  2058             }
       
  2059 
       
  2060         TInt i = 0;
       
  2061         //Update all the textures in the window
       
  2062         while (i < textureCount)
       
  2063             {
       
  2064             if (startIndex != focusIndex)
       
  2065                 {
       
  2066                 GLX_LOG_INFO1("CGlxFullScreenViewImp::UpdateItems(%d)", startIndex);
       
  2067                 iMediaListMulModelProvider->UpdateItems(startIndex, 1);
       
  2068                 }
       
  2069             if (++startIndex == count)
       
  2070                 {
       
  2071                 startIndex = 0;
       
  2072                 }
       
  2073             i++;
       
  2074             }
       
  2075         
       
  2076         // When the focused index is first or last, 
       
  2077         // need to update the items adjacent to KFullScreenIterator also!
       
  2078         if (count > (KFullScreenTextureOffset))
       
  2079             {
       
  2080             TInt lastIndex = count - 1;
       
  2081             if (focusIndex == 0)
       
  2082                 {
       
  2083                 iMediaListMulModelProvider->UpdateItems(KFullScreenIterator,
       
  2084                         1);
       
  2085                 }
       
  2086             else if (focusIndex == lastIndex)
       
  2087                 {
       
  2088                 iMediaListMulModelProvider->UpdateItems(lastIndex
       
  2089                         - KFullScreenIterator, 1);
       
  2090                 }
       
  2091             }
       
  2092         }
       
  2093     }