photosgallery/slideshow/view/src/shwslideshowview.cpp
branchRCL_3
changeset 19 420f6808bf21
parent 18 78ad99c24f08
child 21 f9e827349359
equal deleted inserted replaced
18:78ad99c24f08 19:420f6808bf21
   221 
   221 
   222 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   223 // StartEngineL
   223 // StartEngineL
   224 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   225 TInt CShwSlideshowView::StartEngineL()
   225 TInt CShwSlideshowView::StartEngineL()
   226     {
   226 	{
   227     TRACER("CShwSlideshowView::StartEngineL");
   227 	TRACER("CShwSlideshowView::StartEngineL");
   228   	GLX_LOG_INFO( "CShwSlideshowView::StartEngineL" );
   228 	GLX_LOG_INFO( "CShwSlideshowView::StartEngineL" );
   229     // Check that the list has some items
   229 	// Check that the list has some items
   230   	if( iFilteredList )
   230 	if (iFilteredList)
   231         {
   231 		{
   232 	    TInt filteredCount = iFilteredList->Count();
   232 		TInt filteredCount = iFilteredList->Count();
   233 	    TInt inputlistCount = iMediaList->Count();
   233 		TInt inputlistCount = iMediaList->Count();
   234 	    if ( ( inputlistCount < 1 )||
   234 		if ((inputlistCount < 1) || (filteredCount < 1))
   235 	         ( filteredCount  < 1 ) )
   235 			{
   236 	        {
   236 			GLX_LOG_INFO2(
   237 	      	GLX_LOG_INFO2( 
   237 					"CShwSlideshowView::PopulateListL error, counts: %d, %d",
   238 	            "CShwSlideshowView::PopulateListL error, counts: %d, %d", 
   238 					inputlistCount, filteredCount );
   239 	                inputlistCount, filteredCount );
   239 			iEngineStartFailed = ETrue;
   240 	        iEngineStartFailed = ETrue;
   240 			// need to dismiss the dialog if it's still there
   241 	        // need to dismiss the dialog if it's still there
   241 			if (iWaitDialog)
   242 	        if( iWaitDialog )
   242 				{
   243 	            {
   243 				iWaitDialog->ProcessFinishedL();
   244 	            iWaitDialog->ProcessFinishedL();
   244 				}
   245 	            }
   245 			}
   246 	        }
   246 		else
   247 	    else
   247 			{
   248 	        {
   248 			// The list should now be populated, so set the focus
   249 	        // The list should now be populated, so set the focus
   249 			SetListFocusL();
   250 	       	SetListFocusL();
   250 			// Need to take latest screen size as layout has changed
   251 	       	// Need to take latest screen size as layout has changed
   251 			TRect currentScreen;
   252 	       	TRect currentScreen;
   252 			AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen,
   253 	       	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen,currentScreen);
   253 					currentScreen);
   254 	       	iScrnSize = currentScreen.Size();
   254 			iScrnSize = currentScreen.Size();
   255 
   255 
   256 	       	iHdmiWidth = (iScrnSize.iWidth > iScrnSize.iHeight ?
   256 			iHdmiWidth
   257                                 iScrnSize.iWidth :iScrnSize.iHeight);
   257 					= (iScrnSize.iWidth > iScrnSize.iHeight ? iScrnSize.iWidth
   258 	        iHdmiHeight = (iScrnSize.iWidth < iScrnSize.iHeight ?
   258 							: iScrnSize.iHeight);
   259                                 iScrnSize.iWidth :iScrnSize.iHeight);
   259 			iHdmiHeight
   260 
   260 					= (iScrnSize.iWidth < iScrnSize.iHeight ? iScrnSize.iWidth
   261 	    	iEngine->StartL( 
   261 							: iScrnSize.iHeight);
   262 	    	    *iEnv, *iDisplay, *iFilteredList, *this, iScrnSize );
   262 			iEngine->StartL(*iEnv, *iDisplay, *iFilteredList, *this, iScrnSize);
   263 	        }
   263 			if (iHdmiController == NULL || (iHdmiController
   264         }  
   264 					&& !iHdmiController->IsHDMIConnected()))
   265     // return value needed as this is a TCallBack
   265 				{
   266     return KErrNone;
   266 				iEngine->HandleHDMIDecodingEventL(EHdmiDisconnected);
   267     }
   267 				}
       
   268 			SetItemToHDMIL();
       
   269 			iHdmiActive = ETrue;
       
   270 			}
       
   271 		}
       
   272 	// return value needed as this is a TCallBack
       
   273 	return KErrNone;
       
   274 	}
   268 
   275 
   269 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   270 // PopulateListL
   277 // PopulateListL
   271 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   272 TInt CShwSlideshowView::PopulateListL()
   279 TInt CShwSlideshowView::PopulateListL()
   449     // reset failure flag
   456     // reset failure flag
   450     iEngineStartFailed = EFalse;
   457     iEngineStartFailed = EFalse;
   451 
   458 
   452 	if(!iHdmiController)
   459 	if(!iHdmiController)
   453 		{
   460 		{
   454 	    iHdmiController = CGlxHdmiController::NewL();
   461 	    iHdmiController = CGlxHdmiController::NewL(*this);
   455 		}
   462 		}
   456 	if(!iTvConnection)
   463 	if(!iTvConnection)
   457 		{
   464 		{
   458 		iTvConnection = CGlxTv::NewL( *this );
   465 		iTvConnection = CGlxTv::NewL( *this );
   459 		}
   466 		}
   751 // From MShwEngineObserver
   758 // From MShwEngineObserver
   752 // Engine started callback.
   759 // Engine started callback.
   753 // ---------------------------------------------------------------------------
   760 // ---------------------------------------------------------------------------
   754 //
   761 //
   755 void CShwSlideshowView::EngineStartedL()
   762 void CShwSlideshowView::EngineStartedL()
   756     {
   763 	{
   757     TRACER("CShwSlideshowView::EngineStartedL");
   764 	TRACER("CShwSlideshowView::EngineStartedL");
   758   	GLX_LOG_INFO( "CShwSlideshowView::EngineStartedL()" );
   765 	GLX_LOG_INFO( "CShwSlideshowView::EngineStartedL()" );
   759     
   766 
   760     if ( iWaitDialog )
   767 	if (iWaitDialog)
   761         {
   768 		{
   762         // cancel the progress bar
   769 		// cancel the progress bar
   763         iWaitDialog->ProcessFinishedL();
   770 		iWaitDialog->ProcessFinishedL();
   764         }
   771 		}
   765     iShwState = EShwPlay;
   772 	if (iHdmiController)
   766     SetItemToHDMIL();
   773 		{
   767 	iHdmiActive = ETrue;
   774 		iHdmiController->ShiftToPostingMode();
   768     ReplaceCommandSetL(R_SHW_SOFTKEYS_END_PAUSE,R_SHW_SOFTKEYS_END_PAUSE);
   775 		}
   769     ShowShwFurnitureL();
   776 	iShwState = EShwPlay;
   770     }
   777 	ReplaceCommandSetL(R_SHW_SOFTKEYS_END_PAUSE, R_SHW_SOFTKEYS_END_PAUSE);
   771     
   778 	ShowShwFurnitureL();
       
   779 	}
       
   780 
   772 // ---------------------------------------------------------------------------
   781 // ---------------------------------------------------------------------------
   773 // From MShwEngineObserver
   782 // From MShwEngineObserver
   774 // Engine paused callback.
   783 // Engine paused callback.
   775 // ---------------------------------------------------------------------------
   784 // ---------------------------------------------------------------------------
   776 //
   785 //
  1293 void CShwSlideshowView::SetItemToHDMIL()
  1302 void CShwSlideshowView::SetItemToHDMIL()
  1294     {
  1303     {
  1295     TRACER("CShwSlideshowView::SetImageToHDMIL() ");
  1304     TRACER("CShwSlideshowView::SetImageToHDMIL() ");
  1296 
  1305 
  1297     TInt focusIndex = iFilteredList->FocusIndex();
  1306     TInt focusIndex = iFilteredList->FocusIndex();
       
  1307     TInt nextIndex = GetNextIndex();
  1298 
  1308 
  1299     // If we dont know what item we are focussing on 
  1309     // If we dont know what item we are focussing on 
  1300     // or if our filtered list is empty
  1310     // or if our filtered list is empty
  1301     // or if HDMI is not connected 
  1311     // or if HDMI is not connected 
  1302     // or if there is no HDMI Controller at all 
  1312     // or if there is no HDMI Controller at all 
  1309         return;
  1319         return;
  1310         }
  1320         }
  1311     
  1321     
  1312     TGlxMedia item = iFilteredList->Item(focusIndex);
  1322     TGlxMedia item = iFilteredList->Item(focusIndex);
  1313     TInt error = GlxErrorManager::HasAttributeErrorL(item.Properties(),
  1323     TInt error = GlxErrorManager::HasAttributeErrorL(item.Properties(),
       
  1324         KGlxMediaIdThumbnail);
       
  1325     TGlxMedia nextItem = iFilteredList->Item(nextIndex);
       
  1326     TInt nexterror = GlxErrorManager::HasAttributeErrorL(nextItem.Properties(),
  1314         KGlxMediaIdThumbnail);
  1327         KGlxMediaIdThumbnail);
  1315     
  1328     
  1316     // Item will be supported by HDMI ONLY if
  1329     // Item will be supported by HDMI ONLY if
  1317     // it is not a video
  1330     // it is not a video
  1318     // and it has no attribute error 
  1331     // and it has no attribute error 
  1332             CleanupStack::PushL(fsBitmap);
  1345             CleanupStack::PushL(fsBitmap);
  1333             fsBitmap->Duplicate( fsValue->iBitmap->Handle());
  1346             fsBitmap->Duplicate( fsValue->iBitmap->Handle());
  1334             
  1347             
  1335             GLX_LOG_INFO2("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - FS Bitmap Size width=%d, height=%d", 
  1348             GLX_LOG_INFO2("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - FS Bitmap Size width=%d, height=%d", 
  1336                     fsBitmap->SizeInPixels().iWidth, fsBitmap->SizeInPixels().iHeight);
  1349                     fsBitmap->SizeInPixels().iWidth, fsBitmap->SizeInPixels().iHeight);
  1337             iHdmiController->SetImageL(item.Uri(),fsBitmap);
  1350             if(nexterror == KErrNone)
       
  1351             	{
       
  1352                 iHdmiController->SetImageL(item.Uri(), nextItem.Uri(), fsBitmap);            	
       
  1353             	}
       
  1354             else
       
  1355             	{
       
  1356             	iHdmiController->SetImageL(item.Uri(), KNullDesC, fsBitmap);
       
  1357             	}
  1338             CleanupStack::PopAndDestroy(fsBitmap);
  1358             CleanupStack::PopAndDestroy(fsBitmap);
  1339             }
  1359             }
  1340         else
  1360         else
  1341             {
  1361             {
  1342             GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Fetch Grid thumbnail");
  1362             GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Fetch Grid thumbnail");
  1353                 CleanupStack::PushL(gridBitmap);
  1373                 CleanupStack::PushL(gridBitmap);
  1354                 gridBitmap->Duplicate( gridvalue->iBitmap->Handle());
  1374                 gridBitmap->Duplicate( gridvalue->iBitmap->Handle());
  1355                 
  1375                 
  1356                 GLX_LOG_INFO2("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - gridBitmap Size width=%d, height=%d", 
  1376                 GLX_LOG_INFO2("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - gridBitmap Size width=%d, height=%d", 
  1357                         gridBitmap->SizeInPixels().iWidth, gridBitmap->SizeInPixels().iHeight);
  1377                         gridBitmap->SizeInPixels().iWidth, gridBitmap->SizeInPixels().iHeight);
  1358                 iHdmiController->SetImageL(item.Uri(),gridBitmap);
  1378                 if(nexterror == KErrNone)
       
  1379                 	{
       
  1380                 	iHdmiController->SetImageL(item.Uri(), nextItem.Uri(), gridBitmap);
       
  1381                 	}
       
  1382                 else
       
  1383                 	{
       
  1384                 	iHdmiController->SetImageL(item.Uri(), KNullDesC, gridBitmap);                	
       
  1385                 	}
  1359                 CleanupStack::PopAndDestroy(gridBitmap);
  1386                 CleanupStack::PopAndDestroy(gridBitmap);
  1360                 }
  1387                 }
  1361             else
  1388             else
  1362                 {
  1389                 {
  1363                 GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Setting Null Bitmap");
  1390                 GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Setting Null Bitmap");
  1370                 // always need to setsize on the raw bitmap for it to be visible
  1397                 // always need to setsize on the raw bitmap for it to be visible
  1371                 AknIconUtils::SetSize(defaultBitmap, TSize(iHdmiWidth,iHdmiHeight),EAspectRatioPreserved);
  1398                 AknIconUtils::SetSize(defaultBitmap, TSize(iHdmiWidth,iHdmiHeight),EAspectRatioPreserved);
  1372                 
  1399                 
  1373                 GLX_LOG_INFO2("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Default Size width=%d, height=%d", 
  1400                 GLX_LOG_INFO2("CShwSlideshowView::SetImageToHDMIL - CGlxHdmi - Default Size width=%d, height=%d", 
  1374                         defaultBitmap->SizeInPixels().iWidth, defaultBitmap->SizeInPixels().iHeight);
  1401                         defaultBitmap->SizeInPixels().iWidth, defaultBitmap->SizeInPixels().iHeight);
  1375                 iHdmiController->SetImageL(item.Uri(),defaultBitmap);
  1402                 if(nexterror == KErrNone)
       
  1403                 	{
       
  1404                     iHdmiController->SetImageL(item.Uri(), nextItem.Uri(),
       
  1405 							defaultBitmap);                	
       
  1406                 	}
       
  1407                 else
       
  1408                 	{
       
  1409                     iHdmiController->SetImageL(item.Uri(), KNullDesC , defaultBitmap);                	
       
  1410                 	}
  1376                 CleanupStack::PopAndDestroy(defaultBitmap); 
  1411                 CleanupStack::PopAndDestroy(defaultBitmap); 
  1377                 }
  1412                 }
  1378             }
  1413             }
  1379         }
  1414         }
  1380     else
  1415     else
  1381         {
  1416         {
  1382         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - Unsupported Item");
  1417         GLX_LOG_INFO("CShwSlideshowView::SetImageToHDMIL - Unsupported Item");
  1383         //Set the external display to cloning mode if
  1418         //Set the external display to cloning mode if
  1384         //the current item is something we wont support (e.g. video, corrupted item)
  1419         //the current item is something we wont support (e.g. video, corrupted item)
  1385         iHdmiController->ItemNotSupported();
  1420         iHdmiController->ShiftToCloningMode();
  1386         }
  1421         }
  1387     }
  1422     }
  1388 // ---------------------------------------------------------------------------
  1423 // ---------------------------------------------------------------------------
  1389 // 
  1424 // 
  1390 // Gets the index of the item for which the texture has to be removed
  1425 // Gets the index of the item for which the texture has to be removed
  1473 			ProcessCommandL(EShwSlideshowCmdPause);
  1508 			ProcessCommandL(EShwSlideshowCmdPause);
  1474 			}
  1509 			}
  1475 		}
  1510 		}
  1476 
  1511 
  1477 	}
  1512 	}
       
  1513 
       
  1514 // ---------------------------------------------------------------------------
       
  1515 // GetNextIndex
       
  1516 // ---------------------------------------------------------------------------
       
  1517 //
       
  1518 TInt CShwSlideshowView::GetNextIndex()
       
  1519 	{
       
  1520 	TRACER("CShwSlideshowView::GetNextIndex");
       
  1521 	TInt count = iFilteredList->Count();
       
  1522 	TInt focusIndex = iFilteredList->FocusIndex();
       
  1523 	TInt nextIndex = focusIndex + 1;
       
  1524 	if (nextIndex > count - 1)
       
  1525 		{
       
  1526 		nextIndex = nextIndex - count;
       
  1527 		}
       
  1528 	GLX_LOG_INFO1("CShwSlideshowView::GetNextIndex-nextIndex:%d",nextIndex);
       
  1529 	return nextIndex;
       
  1530 	}
       
  1531 
       
  1532 //---------------------------------------------------------------------------
       
  1533 // From MGlxHDMIDecoderObserver
       
  1534 // Handle notification of HDMI Image Decoder.
       
  1535 //---------------------------------------------------------------------------   
       
  1536 void CShwSlideshowView::HandleHDMIDecodingEventL(THdmiDecodingStatus aStatus)
       
  1537 	{
       
  1538 	TRACER("CShwSlideshowView::HandleHDMIDecodingEventL()");
       
  1539 	iEngine->HandleHDMIDecodingEventL(aStatus);
       
  1540 	}