photosgallery/slideshow/view/src/shwslideshowview.cpp
branchRCL_3
changeset 13 bcb43dc84c44
parent 12 ce1c7ad1f18b
child 15 191387a8b767
equal deleted inserted replaced
12:ce1c7ad1f18b 13:bcb43dc84c44
    33 #include <alf/alfenv.h>
    33 #include <alf/alfenv.h>
    34 #include <alf/alfdisplay.h>
    34 #include <alf/alfdisplay.h>
    35 #include <alf/alfutil.h>
    35 #include <alf/alfutil.h>
    36 #include <alf/alfroster.h>
    36 #include <alf/alfroster.h>
    37 
    37 
    38 //Hg 
       
    39 //#include <hg/hgcontextutility.h>
       
    40 #include <glxhdmicontroller.h>
    38 #include <glxhdmicontroller.h>
    41 #include <glxresourceutilities.h>               // for CGlxResourceUtilities
    39 #include <glxresourceutilities.h>               // for CGlxResourceUtilities
    42 #include <glxresolutionutility.h>               // for CGlxResolutionUtility
    40 #include <glxresolutionutility.h>               // for CGlxResolutionUtility
    43 #include <shwslideshowview.rsg> // view's resource
    41 #include <shwslideshowview.rsg> // view's resource
    44 #include <data_caging_path_literals.hrh>	// for resource directory path
    42 #include <data_caging_path_literals.hrh>	// for resource directory path
    78     const TInt KViewId = 0x20007199;
    76     const TInt KViewId = 0x20007199;
    79     //gontrol goup id has to be locally unique
    77     //gontrol goup id has to be locally unique
    80     const TInt KShwGestureControlGroupId = 2;
    78     const TInt KShwGestureControlGroupId = 2;
    81     const TInt KGestureControlGroupId = 44;
    79     const TInt KGestureControlGroupId = 44;
    82     //This constant is used to calculate the index of the item for which texture has to removed.
    80     //This constant is used to calculate the index of the item for which texture has to removed.
    83     //6 = 5(iterator value in forward or backward direction for fullscreen) + 1(focus index);
    81     //6 = 5(iterator value in forward or backward direction for fullscreen) + 1(focus index)
    84     const TInt KSlideShowIterator = 2; 
    82     const TInt KSlideShowIterator = 2; 
    85     //Constant which says maximum number of fullscreen textures that we have have at a time.
    83     //Constant which says maximum number of fullscreen textures that we have have at a time.
    86     //11 = (5(5 fullscreen texture backwards)+1(fucus index texture)+5(5 fullscreen texture forwards))
    84     //11 = (5(5 fullscreen texture backwards)+1(fucus index texture)+5(5 fullscreen texture forwards))
    87     const TInt KSlideShowTextureOffset = 3;
    85     const TInt KSlideShowTextureOffset = 3;
    88     }
    86     }
   122 //
   120 //
   123 CShwSlideshowView::~CShwSlideshowView()
   121 CShwSlideshowView::~CShwSlideshowView()
   124     {
   122     {
   125     TRACER("CShwSlideshowView::~CShwSlideshowView");
   123     TRACER("CShwSlideshowView::~CShwSlideshowView");
   126   	GLX_LOG_INFO( "CShwSlideshowView::~CShwSlideshowView()" );
   124   	GLX_LOG_INFO( "CShwSlideshowView::~CShwSlideshowView()" );
   127   	iHarvesterClient.Close();
   125   	
   128     // delete media list population call back
   126   	delete iMMCNotifier;
       
   127   	iMMCNotifier = NULL;
       
   128   	
       
   129   	// delete media list population call back
   129     delete iPopulateListCallBack;
   130     delete iPopulateListCallBack;
   130     
   131     
   131     // delete engine async starter
   132     // delete engine async starter
   132     delete iAsyncCallBack;
   133     delete iAsyncCallBack;
   133 
   134 
   312     BaseConstructL( R_SHW_SLIDESHOW_PLAY_VIEW );
   313     BaseConstructL( R_SHW_SLIDESHOW_PLAY_VIEW );
   313     
   314     
   314 	// Glx view base construction
   315 	// Glx view base construction
   315     ViewBaseConstructL();
   316     ViewBaseConstructL();
   316     
   317     
   317 	TInt err = iHarvesterClient.Connect();
   318     iMMCNotifier = CGlxMMCNotifier::NewL(*this);
   318 	GLX_LOG_INFO1("iHarvesterClient.Connect() err = %d",err);
   319     
   319 	if(err == KErrNone)
       
   320 		{
       
   321         iHarvesterClient.AddHarvesterEventObserver(*this, EHEObserverTypeMMC, 1000);
       
   322 		}
       
   323     // Create async engine starter with standard priority
   320     // Create async engine starter with standard priority
   324 	iAsyncCallBack = new( ELeave ) CAsyncCallBack( CActive::EPriorityStandard );
   321 	iAsyncCallBack = new( ELeave ) CAsyncCallBack( CActive::EPriorityStandard );
   325 
   322 
   326     // Create the back light timer
   323     // Create the back light timer
   327     iBackLightTimer = CShwSlideshowBackLightTimer::NewL();
   324     iBackLightTimer = CShwSlideshowBackLightTimer::NewL();
   334         NewL( *iEnv,
   331         NewL( *iEnv,
   335         	  *iUiUtility,
   332         	  *iUiUtility,
   336         	  KShwDefaultDelayMicroSeconds );
   333         	  KShwDefaultDelayMicroSeconds );
   337     // Create a control group for the volume control
   334     // Create a control group for the volume control
   338     iVolumeControlGroup = &iEnv->NewControlGroupL( KVolumeControlGroupId );
   335     iVolumeControlGroup = &iEnv->NewControlGroupL( KVolumeControlGroupId );
   339     // doc says the following takes ownership, but reality is different!
   336     // doc says the following takes ownership, but reality is different
   340 	iVolumeControlGroup->AppendL( iVolumeControl );
   337 	iVolumeControlGroup->AppendL( iVolumeControl );
   341 	
   338 	
   342     iGestureControlGroup = &iEnv->NewControlGroupL( KShwGestureControlGroupId );
   339     iGestureControlGroup = &iEnv->NewControlGroupL( KShwGestureControlGroupId );
   343 	
   340 	
   344 	// construct the gesture control group
   341 	// construct the gesture control group
   346 	iGestureControlGroup->AppendL( iShwGestureControl );
   343 	iGestureControlGroup->AppendL( iShwGestureControl );
   347 	
   344 	
   348 	GestureHelper::CGestureControl* gestureControl = GestureHelper::CGestureControl::NewLC( 
   345 	GestureHelper::CGestureControl* gestureControl = GestureHelper::CGestureControl::NewLC( 
   349             *iShwGestureControl, *iEnv, *iDisplay, KGestureControlGroupId );
   346             *iShwGestureControl, *iEnv, *iDisplay, KGestureControlGroupId );
   350     iGestureControl = gestureControl;
   347     iGestureControl = gestureControl;
   351     CleanupStack::Pop( gestureControl ); // doc says the following takes ownership, but reality is different!
   348     CleanupStack::Pop( gestureControl ); // doc says the following takes ownership, but reality is different
   352 	iGestureControlGroup->AppendL( iGestureControl );
   349 	iGestureControlGroup->AppendL( iGestureControl );
   353 
   350 
   354 	// Need a mechanism to distinguish when we receive the MusicVolume 
   351 	// Need a mechanism to distinguish when we receive the MusicVolume 
   355 	// callback for the first time
   352 	// callback for the first time
   356 	iCurrentVolume = -1;
   353 	iCurrentVolume = -1;
   382 //
   379 //
   383 void CShwSlideshowView::HandleForegroundEventL(TBool aForeground)
   380 void CShwSlideshowView::HandleForegroundEventL(TBool aForeground)
   384     {
   381     {
   385     TRACER("CShwSlideshowView::HandleForegroundEventL");
   382     TRACER("CShwSlideshowView::HandleForegroundEventL");
   386   	GLX_LOG_INFO( "CShwSlideshowView::HandleForegroundEventL()" );
   383   	GLX_LOG_INFO( "CShwSlideshowView::HandleForegroundEventL()" );
   387 
   384 	iIsForegrnd = aForeground;
   388     if( aForeground )
   385     if( aForeground )
   389         {
   386         {
   390         // we gained the foreground
   387         // we gained the foreground
   391         iPauseHandler->SwitchToForegroundL();
   388         if(iMMCState && iPrevNotInBackground)
       
   389             {
       
   390             ProcessCommandL(EAknSoftkeyClose);
       
   391             }
       
   392         else
       
   393             {
       
   394             iPauseHandler->SwitchToForegroundL();
       
   395             }
   392         }
   396         }
   393     else
   397     else
   394         {
   398         {
   395         // Something else has gained the foreground
   399         // Something else has gained the foreground
   396         iPauseHandler->SwitchToBackgroundL();
   400         iPauseHandler->SwitchToBackgroundL();
   533 
   537 
   534 	//Cancel the back light timer
   538 	//Cancel the back light timer
   535     iBackLightTimer->Cancel();
   539     iBackLightTimer->Cancel();
   536 
   540 
   537 
   541 
   538     //Stop the slideshow!
   542     //Stop the slideshow
   539     //NOTE! this needs to be done before the list is closed as the 
   543     //NOTE: this needs to be done before the list is closed as the 
   540     //destructor removes the engine as medialist observer and also
   544     //destructor removes the engine as medialist observer and also
   541     //removes the contexts from the list
   545     //removes the contexts from the list
   542     delete iEngine;
   546     delete iEngine;
   543     iEngine = NULL;
   547     iEngine = NULL;
   544 
   548 
  1018     if ( selectionCount == 0 )
  1022     if ( selectionCount == 0 )
  1019         {
  1023         {
  1020         // nothing selected, so determine which item has focus in the original list
  1024         // nothing selected, so determine which item has focus in the original list
  1021         focusIndex = iMediaList->FocusIndex();
  1025         focusIndex = iMediaList->FocusIndex();
  1022         const TGlxMedia& mediaItem = iMediaList->Item( focusIndex );
  1026         const TGlxMedia& mediaItem = iMediaList->Item( focusIndex );
  1023         // is this item in the filtered list?
  1027         // Check if this item is in the filtered list
  1024         TGlxIdSpaceId spaceId = iMediaList->IdSpaceId( focusIndex );
  1028         TGlxIdSpaceId spaceId = iMediaList->IdSpaceId( focusIndex );
  1025         focusIndex = iFilteredList->Index( spaceId, mediaItem.Id() );
  1029         focusIndex = iFilteredList->Index( spaceId, mediaItem.Id() );
  1026         if ( focusIndex == KErrNotFound )
  1030         if ( focusIndex == KErrNotFound )
  1027             {
  1031             {
  1028             // it's been filtered out so just use the first item
  1032             // it's been filtered out so just use the first item
  1269     // or if HDMI is not connected 
  1273     // or if HDMI is not connected 
  1270     // or if there is no HDMI Controller at all 
  1274     // or if there is no HDMI Controller at all 
  1271     // then dont SetImageToHDMI :)  
  1275     // then dont SetImageToHDMI :)  
  1272     if( ( KErrNotFound == focusIndex)
  1276     if( ( KErrNotFound == focusIndex)
  1273             || (0 == iFilteredList->Count())
  1277             || (0 == iFilteredList->Count())
  1274             || (NULL == iHdmiController)
  1278             || (NULL == iHdmiController)) 
  1275             || (!iHdmiController->IsHDMIConnected())) 
       
  1276         {
  1279         {
  1277         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - Cant Set Image To HDMI");
  1280         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - Cant Set Image To HDMI");
  1278         return;
  1281         return;
  1279         }
  1282         }
  1280     
  1283     
  1287     // and it has no attribute error 
  1290     // and it has no attribute error 
  1288     if ( (item.Category() != EMPXVideo) 
  1291     if ( (item.Category() != EMPXVideo) 
  1289             && (error == KErrNone) )
  1292             && (error == KErrNone) )
  1290         {
  1293         {
  1291         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Setting the Image");
  1294         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Setting the Image");
  1292         TInt frameCount(0);
  1295         iHdmiController->SetImageL(item.Uri());
  1293         TSize orignalSize;
       
  1294         item.GetFrameCount(frameCount);
       
  1295         item.GetDimensions(orignalSize);
       
  1296         iHdmiController->SetImageL(item.Uri(), orignalSize, frameCount);
       
  1297         }
  1296         }
  1298     else
  1297     else
  1299         {
  1298         {
  1300         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - Unsupported Item");
  1299         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - Unsupported Item");
  1301         //Set the external display to cloning mode if
  1300         //Set the external display to cloning mode if
  1302         //the current item is something we wont support (e.g. video, corrupted item);
  1301         //the current item is something we wont support (e.g. video, corrupted item)
  1303         iHdmiController->ItemNotSupported();
  1302         iHdmiController->ItemNotSupported();
  1304         }
  1303         }
  1305     }
  1304     }
  1306 // ---------------------------------------------------------------------------
  1305 // ---------------------------------------------------------------------------
  1307 // 
  1306 // 
  1344     const TGlxMedia& item = iFilteredList->Item(GetIndexToBeRemoved());
  1343     const TGlxMedia& item = iFilteredList->Item(GetIndexToBeRemoved());
  1345     iUiUtility->GlxTextureManager().RemoveTexture(item.Id(),EFalse);
  1344     iUiUtility->GlxTextureManager().RemoveTexture(item.Id(),EFalse);
  1346     }
  1345     }
  1347 
  1346 
  1348 // ---------------------------------------------------------------------------
  1347 // ---------------------------------------------------------------------------
  1349 // HarvestingUpdated
       
  1350 // 
  1348 // 
  1351 // ---------------------------------------------------------------------------
  1349 // HandleMMCInsertionL
  1352 //
  1350 // ---------------------------------------------------------------------------
  1353 void CShwSlideshowView::HarvestingUpdated( 
  1351 //
  1354                 HarvesterEventObserverType HarvestingUpdated, 
  1352 void CShwSlideshowView::HandleMMCInsertionL()
  1355                 HarvesterEventState aHarvesterEventState,
  1353     {
  1356                 TInt aItemsLeft )
  1354     TRACER("CShwSlideshowView::HandleMMCInsertionL()");
  1357     {
  1355     iMMCState = ETrue;
  1358     TRACER("CShwSlideshowView::HarvestingUpdated()");
  1356     iPrevNotInBackground = iIsForegrnd;
  1359     if(HarvestingUpdated == EHEObserverTypeMMC)
  1357     if(iIsForegrnd)
  1360         {
  1358         {
  1361         ProcessCommandL(EAknSoftkeyClose);
  1359         ProcessCommandL(EAknSoftkeyClose);
  1362         }
  1360         }
  1363     }
  1361     }
       
  1362 
       
  1363 // ---------------------------------------------------------------------------
       
  1364 // 
       
  1365 // HandleMMCRemovalL
       
  1366 // ---------------------------------------------------------------------------
       
  1367 //
       
  1368 void CShwSlideshowView::HandleMMCRemovalL()
       
  1369     {
       
  1370     TRACER("CShwSlideshowView::HandleMMCRemovalL()");
       
  1371     ProcessCommandL(EAknSoftkeyExit);
       
  1372     }
       
  1373 
       
  1374