internetradio2.0/dataprovidersrc/irlogodownloadengine.cpp
changeset 3 ee64f059b8e1
parent 0 09774dfdd46b
child 11 f683e24efca3
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
   225 	THTTPHdrVal val(valStr);
   225 	THTTPHdrVal val(valStr);
   226 	aHeaders.SetFieldL(iLogoSession.StringPool().StringF(aHdrField, RHTTPSession::GetTable()), val);
   226 	aHeaders.SetFieldL(iLogoSession.StringPool().StringF(aHdrField, RHTTPSession::GetTable()), val);
   227 	CleanupStack::PopAndDestroy(&valStr); // valStr
   227 	CleanupStack::PopAndDestroy(&valStr); // valStr
   228 	IRLOG_DEBUG( "CIRLogoDownloadEngine::SetHeaderL - Exiting" );
   228 	IRLOG_DEBUG( "CIRLogoDownloadEngine::SetHeaderL - Exiting" );
   229 	}
   229 	}
   230 
       
   231 // ---------------------------------------------------------------------------
       
   232 // CIRLogoDownloadEngine::SetFavDbInstance(CIRFavoritesDb* aFavDb)
       
   233 // To set the favorites db instance
       
   234 // ---------------------------------------------------------------------------
       
   235 //
       
   236 EXPORT_C void CIRLogoDownloadEngine::SetFavDbInstance(CIRFavoritesDb* aFavDb)
       
   237 	{
       
   238 	IRLOG_DEBUG( "CIRLogoDownloadEngine::SetFavDbInstance - Entering" );
       
   239 	iFavDb = aFavDb;
       
   240 	iFavDb->AddObserver( *this );
       
   241 	IRLOG_DEBUG( "CIRLogoDownloadEngine::SetFavDbInstance - Exiting" );
       
   242 	}
       
   243 
       
   244 
   230 
   245 // ----------------------------------------------------------------------------------
   231 // ----------------------------------------------------------------------------------
   246 // CIRLogoDownloadEngine::SendRequestL(CIRIsdsPreset* aPreset,TInt aXValue,TInt aYValue)
   232 // CIRLogoDownloadEngine::SendRequestL(CIRIsdsPreset* aPreset,TInt aXValue,TInt aYValue)
   247 // API is called from the SearchResultsView for to download logo while doing Add to Favorites
   233 // API is called from the SearchResultsView for to download logo while doing Add to Favorites
   248 // ----------------------------------------------------------------------------------
   234 // ----------------------------------------------------------------------------------
   863 
   849 
   864 	//set the downloaded logo to the preset with the API SetLogoData()
   850 	//set the downloaded logo to the preset with the API SetLogoData()
   865 	iTempPreset->SetLogoData(*iRespBody);
   851 	iTempPreset->SetLogoData(*iRespBody);
   866 	if(iTempReqFrom == 0)//which means the request came from SearchView while doing Add to Favorite
   852 	if(iTempReqFrom == 0)//which means the request came from SearchView while doing Add to Favorite
   867 		{
   853 		{
   868 		iFavDb->ReplacePresetL(*iTempPreset);
       
   869 		iPresetModifiedStatus = ETrue;
   854 		iPresetModifiedStatus = ETrue;
   870 		}
   855 		}
   871 	else if(iTempReqFrom == 1)//which menas the request came from a view other than NowPlayingView
   856 	else if(iTempReqFrom == 1)//which menas the request came from a view other than NowPlayingView
   872 		{
   857 		{
   873 		iTempLogoHandle->PresetLogoDownloadedL(iTempPreset);
   858 		iTempLogoHandle->PresetLogoDownloadedL(iTempPreset);
   876 		{
   861 		{
   877 		//(1)logo has downloaded freshly
   862 		//(1)logo has downloaded freshly
   878 		//(2)send the logo to the NPV through PresetLogoDownloadedL
   863 		//(2)send the logo to the NPV through PresetLogoDownloadedL
   879 		//(3)check whether the preset exists in favdb; if so replace that with new logo
   864 		//(3)check whether the preset exists in favdb; if so replace that with new logo
   880 		iTempLogoHandle->PresetLogoDownloadedL(iTempPreset);
   865 		iTempLogoHandle->PresetLogoDownloadedL(iTempPreset);
   881 		//iFavDb->ReplacePresetL(*iTempPreset)
       
   882 		}
   866 		}
   883 		
   867 		
   884     
   868     
   885 	iTempPreset->SetImgUrl(urlWithPar);	
   869 	iTempPreset->SetImgUrl(urlWithPar);	
   886 	//Cache the newly downloaded logo
   870 	//Cache the newly downloaded logo
  1507 				 	{
  1491 				 	{
  1508 					iCacheTempPreset->SetLogoData(iCache->iLogoData);	 		
  1492 					iCacheTempPreset->SetLogoData(iCache->iLogoData);	 		
  1509 				 	}
  1493 				 	}
  1510 				if(iCacheReqFrom == 0)
  1494 				if(iCacheReqFrom == 0)
  1511 					{
  1495 					{
  1512 					iFavDb->ReplacePresetL(*iCacheTempPreset);
       
  1513 					iPresetModifiedStatus = ETrue;
  1496 					iPresetModifiedStatus = ETrue;
  1514 					}
  1497 					}
  1515 				else
  1498 				else
  1516 					{
  1499 					{
  1517 					iCacheTempLogoHandle->PresetLogoDownloadedL(iCacheTempPreset);
  1500 					iCacheTempLogoHandle->PresetLogoDownloadedL(iCacheTempPreset);
  1526 				 	{
  1509 				 	{
  1527 					iTempPreset->SetLogoData(iCache->iLogoData);	 		
  1510 					iTempPreset->SetLogoData(iCache->iLogoData);	 		
  1528 				 	}
  1511 				 	}
  1529 				if(iTempReqFrom == 0)
  1512 				if(iTempReqFrom == 0)
  1530 					{
  1513 					{
  1531 					iFavDb->ReplacePresetL(*iTempPreset);
       
  1532 					iPresetModifiedStatus = ETrue;
  1514 					iPresetModifiedStatus = ETrue;
  1533 					}
  1515 					}
  1534 				else
  1516 				else
  1535 					{
  1517 					{
  1536 					iTempLogoHandle->PresetLogoDownloadedL(iTempPreset);
  1518 					iTempLogoHandle->PresetLogoDownloadedL(iTempPreset);
  1565 	iLogoSession.Close();
  1547 	iLogoSession.Close();
  1566     iFirstTime = ETrue;
  1548     iFirstTime = ETrue;
  1567  	IRLOG_DEBUG( "CIRLogoDownloadEngine::ReleaseResources - Exiting" );
  1549  	IRLOG_DEBUG( "CIRLogoDownloadEngine::ReleaseResources - Exiting" );
  1568 	} 	
  1550 	} 	
  1569 
  1551 
  1570 
       
  1571 // ---------------------------------------------------------------------------
       
  1572 // CIRLogoDownloadEngine::HandlePresetChangedL( TInt aId, TUid aDataHandler, MPSPresetObserver::TPSReason aType )
       
  1573 // This is called by CIRFavoritesDb when values of presets stations has been changed	
       
  1574 // ---------------------------------------------------------------------------
       
  1575 //	
       
  1576 void CIRLogoDownloadEngine::HandlePresetChangedL( TInt aId, TUid aDataHandler,
       
  1577 					 MPSPresetObserver::TPSReason aReason )
       
  1578 	{
       
  1579  	IRLOG_DEBUG( "CIRLogoDownloadEngine::HandlePresetChangedL - Entering" );
       
  1580     if ( aDataHandler ==  KIRPreset  )
       
  1581         {
       
  1582         switch ( aReason )
       
  1583             {
       
  1584             case 0:  //MPSPresetObserver::EPSCreated
       
  1585                 {
       
  1586 /*d				CIRPreset* preset = NULL;
       
  1587                 preset = iFavDb->PresetById( aId );
       
  1588                 delete iCopyPreset;
       
  1589                 iCopyPreset = NULL;
       
  1590                 iCopyPreset = CIRIsdsPreset::NewL();
       
  1591                 preset->CopyPresetData(*iCopyPreset);
       
  1592                 if(iCopyPreset->GetChannelType()==1)
       
  1593 	                {
       
  1594 	                if(iCopyPreset->GetImgUrl().Length() != 0)
       
  1595 		                {
       
  1596 		                if(iCopyPreset->GetLogoData().Length() == 0)
       
  1597 			                {
       
  1598 			                SendRequestL(iCopyPreset);		                	
       
  1599 			                }
       
  1600 		                }
       
  1601 					else
       
  1602 						{
       
  1603 						//do nothing;
       
  1604 						}
       
  1605 	                }
       
  1606 d*/                }
       
  1607             	break;
       
  1608             case 1:  //MPSPresetObserver::EPSDeleted:
       
  1609             	break;
       
  1610             case 2:  //MPSPresetObserver::EPSModified:
       
  1611 	            {
       
  1612 	            if(!iFavDb->GetMoveStatus())
       
  1613 			        {
       
  1614 		            if(iPresetModifiedStatus)
       
  1615 			            {
       
  1616 						iPresetModifiedStatus = EFalse;		            	
       
  1617 			            }
       
  1618 		            else
       
  1619 			            {
       
  1620 						CIRPreset* preset = NULL;
       
  1621 		                preset = iFavDb->PresetById( aId );
       
  1622 		                delete iCopyPreset;
       
  1623 		                iCopyPreset = NULL;
       
  1624 		                iCopyPreset = CIRIsdsPreset::NewL();
       
  1625 		                preset->CopyPresetData(*iCopyPreset);
       
  1626 		                if(iCopyPreset->GetChannelType()==1)
       
  1627 			                {
       
  1628 			                if(iCopyPreset->GetImgUrl().Length() != 0)
       
  1629 				                {
       
  1630 				                SendRequestL(iCopyPreset,KLogoSize,KLogoSize);		                	
       
  1631 				                }
       
  1632 							else
       
  1633 								{
       
  1634 								//do nothing;
       
  1635 								}
       
  1636 			                }
       
  1637 			            }
       
  1638 			        }
       
  1639 	            }
       
  1640             	break;
       
  1641             default:
       
  1642             	break;
       
  1643             }
       
  1644         }
       
  1645  	IRLOG_DEBUG( "CIRLogoDownloadEngine::HandlePresetChangedL - Exiting" );
       
  1646 	}
       
  1647 
       
  1648 
       
  1649 // -----------------------------------------------------------------------------
  1552 // -----------------------------------------------------------------------------
  1650 // Notified by network controller when network is active, to reissue the request  
  1553 // Notified by network controller when network is active, to reissue the request  
  1651 // NotifyActiveNetworkObserversL()
  1554 // NotifyActiveNetworkObserversL()
  1652 // -----------------------------------------------------------------------------
  1555 // -----------------------------------------------------------------------------
  1653 
  1556