internetradio2.0/presetpluginsrc/irpresetimpl.cpp
changeset 8 3b03c28289e6
parent 0 09774dfdd46b
equal deleted inserted replaced
5:0930554dc389 8:3b03c28289e6
    16 */
    16 */
    17 
    17 
    18 #include <s32strm.h>
    18 #include <s32strm.h>
    19 
    19 
    20 #include "irchannelserverurl.h"
    20 #include "irchannelserverurl.h"
    21 #include "irchannelserverurlimpl.h"
       
    22 #include "irdebug.h"
    21 #include "irdebug.h"
    23 #include "irpresetimpl.h"
    22 #include "irpresetimpl.h"
    24 #include "irisdspreset.h"
    23 #include "irisdspreset.h"
    25 
    24 
    26 const TInt KUrlArrayMaxLength = 128;
    25 const TInt KUrlArrayMaxLength = 128;
    27 const TInt KUrlForBitrateMaxLength = 128;
       
    28 
    26 
    29 // ======== MEMBER FUNCTIONS ========
    27 // ======== MEMBER FUNCTIONS ========
    30 
    28 
    31 // ---------------------------------------------------------------------------
    29 // ---------------------------------------------------------------------------
    32 // CIRPresetImpl::NewL()
    30 // CIRPresetImpl::NewL()
    67 void CIRPresetImpl::ConstructL(TAny* aParams)
    65 void CIRPresetImpl::ConstructL(TAny* aParams)
    68 	{
    66 	{
    69 	IRLOG_DEBUG( "CIRPresetImpl::ConstructL" );
    67 	IRLOG_DEBUG( "CIRPresetImpl::ConstructL" );
    70 	BaseConstructL(aParams);
    68 	BaseConstructL(aParams);
    71 	iUrlArray=
    69 	iUrlArray=
    72 		new (ELeave) CArrayPtrFlat<CIRChannelServerUrlImpl>(
    70 		new (ELeave) CArrayPtrFlat<CIRChannelServerUrl>(
    73 		KUrlArrayMaxLength);
    71 		KUrlArrayMaxLength);
    74 	iUrlForBitrate=new (ELeave) CDesCArrayFlat(KUrlForBitrateMaxLength);
    72 
    75 	IRLOG_DEBUG( "CIRPresetImpl::ConstructL - Exiting." );
    73 	IRLOG_DEBUG( "CIRPresetImpl::ConstructL - Exiting." );
    76 	}
    74 	}
    77 
    75 
    78 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    79 // CIRPresetImpl::~CIRPresetImpl()
    77 // CIRPresetImpl::~CIRPresetImpl()
    95 	iDescription.Close();
    93 	iDescription.Close();
    96 	iShortDesc.Close();
    94 	iShortDesc.Close();
    97 	iGenereName.Close();
    95 	iGenereName.Close();
    98 	iGenereId.Close();
    96 	iGenereId.Close();
    99 	iMusicStoreStatus.Close();
    97 	iMusicStoreStatus.Close();
   100 	delete iUrlForBitrate;
    98 
   101 	if (iUrlArray)
    99 	if (iUrlArray)
   102 		{
   100 		{
   103 		iUrlArray->ResetAndDestroy();
   101 		iUrlArray->ResetAndDestroy();
   104 		}
   102 		}
   105 
   103 
   335 //
   333 //
   336 void CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,
   334 void CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,
   337 	const TDesC &aBitrate)
   335 	const TDesC &aBitrate)
   338 	{
   336 	{
   339 	IRLOG_DEBUG( "CIRPresetImpl::SetUrlL" );
   337 	IRLOG_DEBUG( "CIRPresetImpl::SetUrlL" );
   340 	CIRChannelServerUrlImpl* hold=CIRChannelServerUrlImpl::NewL();
   338 	CIRChannelServerUrl* hold=CIRChannelServerUrl::NewL();
   341 	hold->SetServerName(aServerName);
   339 	hold->SetServerName(aServerName);
   342 	hold->SetServerUrl(aUrl);
   340 	hold->SetServerUrl(aUrl);
   343 	TLex conv(aBitrate);
   341 	TLex conv(aBitrate);
   344 	TInt conVal = 0;
   342 	TInt conVal = 0;
   345 	conv.Val(conVal);
   343 	conv.Val(conVal);
   359 //
   357 //
   360 void CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,
   358 void CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,
   361 	TInt aBitrate)
   359 	TInt aBitrate)
   362 	{
   360 	{
   363 	IRLOG_DEBUG( "CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,TInt aBitrate)" );
   361 	IRLOG_DEBUG( "CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,TInt aBitrate)" );
   364 	CIRChannelServerUrlImpl* hold=CIRChannelServerUrlImpl::NewL();
   362 	CIRChannelServerUrl* hold=CIRChannelServerUrl::NewL();
   365 	hold->SetServerName(aServerName);
   363 	hold->SetServerName(aServerName);
   366 	hold->SetServerUrl(aUrl);
   364 	hold->SetServerUrl(aUrl);
   367 	hold->SetBitRate(aBitrate);
   365 	hold->SetBitRate(aBitrate);
   368 	iUrlArray->AppendL(hold);
   366 	iUrlArray->AppendL(hold);
   369 	IRLOG_DEBUG( "CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,TInt aBitrate) - Exiting." );
   367 	IRLOG_DEBUG( "CIRPresetImpl::SetUrlL(const TDesC &aServerName,const TDesC &aUrl,TInt aBitrate) - Exiting." );
   481 const TDesC& CIRPresetImpl::GetAdvertisementUrl() const
   479 const TDesC& CIRPresetImpl::GetAdvertisementUrl() const
   482 	{
   480 	{
   483 	return iAdvertisementUrl;
   481 	return iAdvertisementUrl;
   484 	}
   482 	}
   485 
   483 
       
   484 const TDesC& CIRPresetImpl::GetAdvertisementInUse() const
       
   485 {
       
   486     return iAdvertisementInUse;
       
   487 }
       
   488 
   486 // ---------------------------------------------------------------------------
   489 // ---------------------------------------------------------------------------
   487 // CIRPresetImpl::GetImgUrl()
   490 // CIRPresetImpl::GetImgUrl()
   488 // Function to get iImgUrl
   491 // Function to get iImgUrl
   489 // ---------------------------------------------------------------------------
   492 // ---------------------------------------------------------------------------
   490 //
   493 //
   500 //
   503 //
   501 TInt CIRPresetImpl::GetUrlCount() const
   504 TInt CIRPresetImpl::GetUrlCount() const
   502 	{
   505 	{
   503 	return iChannelUrlCount;
   506 	return iChannelUrlCount;
   504 	}
   507 	}
       
   508 
       
   509 CIRChannelServerUrl& CIRPresetImpl::GetUrl(TInt aIndex) const
       
   510 {
       
   511     ASSERT( aIndex >= 0 && aIndex < iUrlArray->Count() ); 
       
   512     return ((*iUrlArray->At(aIndex)));
       
   513 }
   505 
   514 
   506 /*
   515 /*
   507  * get the channel url at specified position
   516  * get the channel url at specified position
   508  *
   517  *
   509  */
   518  */
   511 {
   520 {
   512     return iUrlArray->At(aIndex)->GetServerUrl();
   521     return iUrlArray->At(aIndex)->GetServerUrl();
   513 }
   522 }
   514 
   523 
   515 // ---------------------------------------------------------------------------
   524 // ---------------------------------------------------------------------------
   516 // CIRPresetImpl::GetUrl()
       
   517 // Function to get iLanguageCode
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 CIRChannelServerUrlImpl& CIRPresetImpl::GetUrl(TInt aInt)const
       
   521 	{
       
   522 	ASSERT( aInt >= 0 && aInt < iUrlArray->Count() );
       
   523 	return ((*iUrlArray->At(aInt)));
       
   524 	}
       
   525 
       
   526 // ---------------------------------------------------------------------------
       
   527 // CIRPresetImpl::GetDescription()
   525 // CIRPresetImpl::GetDescription()
   528 // Function to get iDescription
   526 // Function to get iDescription
   529 // ---------------------------------------------------------------------------
   527 // ---------------------------------------------------------------------------
   530 //
   528 //
   531 const TDesC& CIRPresetImpl::GetDescription() const
   529 const TDesC& CIRPresetImpl::GetDescription() const
   578     if(&aPreset == this)
   576     if(&aPreset == this)
   579 		{
   577 		{
   580 		return *this;
   578 		return *this;
   581 		}
   579 		}
   582 	//copy data members
   580 	//copy data members
   583 	iUniqId = aPreset.iUniqId;
       
   584  	iPresetId = aPreset.iPresetId;
   581  	iPresetId = aPreset.iPresetId;
   585 
   582 
   586 	TRAP_IGNORE(SetNameL(aPreset.Name()))
   583 	TRAP_IGNORE(SetNameL(aPreset.Name()))
   587 
   584 
   588 	iLanguageCode.Close();
   585 	iLanguageCode.Close();
   664 //
   661 //
   665 void CIRPresetImpl::ExternalizeL(RWriteStream& aWriteStream)const
   662 void CIRPresetImpl::ExternalizeL(RWriteStream& aWriteStream)const
   666 	{
   663 	{
   667 	IRLOG_DEBUG( "CIRPresetImpl::ExternalizeL" );
   664 	IRLOG_DEBUG( "CIRPresetImpl::ExternalizeL" );
   668 //! externalize TInts s
   665 //! externalize TInts s
   669 	aWriteStream.WriteUint32L(iUniqId);
       
   670 	aWriteStream.WriteInt32L(iPresetId);
   666 	aWriteStream.WriteInt32L(iPresetId);
   671 	aWriteStream.WriteInt32L(iType);
   667 	aWriteStream.WriteInt32L(iType);
   672 	aWriteStream.WriteInt32L(iChannelUrlCount);
   668 	aWriteStream.WriteInt32L(iChannelUrlCount);
   673 
   669 
   674 	//Externalize HBufC s
   670 	//Externalize HBufC s
   852 		}
   848 		}
   853 	
   849 	
   854 	//added by Peter on June 23rd, 2009
   850 	//added by Peter on June 23rd, 2009
   855 	aWriteStream.WriteInt32L(iPlayedTimes);
   851 	aWriteStream.WriteInt32L(iPlayedTimes);
   856 	
   852 	
       
   853 	aWriteStream.WriteInt32L(iRenamed);
       
   854 	
   857 	IRLOG_DEBUG( "CIRPresetImpl::ExternalizeL - Exiting." );
   855 	IRLOG_DEBUG( "CIRPresetImpl::ExternalizeL - Exiting." );
   858 	}
   856 	}
   859 
   857 
   860 
   858 
   861 // ---------------------------------------------------------------------------
   859 // ---------------------------------------------------------------------------
   866 //
   864 //
   867  void CIRPresetImpl::InternalizeL(RReadStream& aReadStream)
   865  void CIRPresetImpl::InternalizeL(RReadStream& aReadStream)
   868 	{
   866 	{
   869 	IRLOG_DEBUG( "CIRPresetImpl::InternalizeL" );
   867 	IRLOG_DEBUG( "CIRPresetImpl::InternalizeL" );
   870 	//! Internalize TInts s
   868 	//! Internalize TInts s
   871 	iUniqId = aReadStream.ReadUint32L();
       
   872 	iPresetId=aReadStream.ReadInt32L();
   869 	iPresetId=aReadStream.ReadInt32L();
   873 	iType=aReadStream.ReadInt32L();
   870 	iType=aReadStream.ReadInt32L();
   874 	iChannelUrlCount=aReadStream.ReadInt32L();
   871 	iChannelUrlCount=aReadStream.ReadInt32L();
   875 	TInt len = 0;
   872 	TInt len = 0;
   876 
   873 
   976 		{
   973 		{
   977 		iLogoData.CreateL(aReadStream,len);
   974 		iLogoData.CreateL(aReadStream,len);
   978 		}
   975 		}
   979 
   976 
   980 	//internalizing the preset data
   977 	//internalizing the preset data
   981 	CIRChannelServerUrlImpl *url = NULL;
   978 	CIRChannelServerUrl *url = NULL;
   982 	for(TInt cnt=0;cnt<iChannelUrlCount;cnt++)
   979 	for(TInt cnt=0;cnt<iChannelUrlCount;cnt++)
   983 		{
   980 		{
   984 		url = CIRChannelServerUrlImpl::NewLC();
   981 		url = CIRChannelServerUrl::NewLC();
   985 		url->InternalizeL(aReadStream);
   982 		url->InternalizeL(aReadStream);
   986 		iUrlArray->AppendL(url);
   983 		iUrlArray->AppendL(url);
   987 	    CleanupStack::Pop(url);
   984 	    CleanupStack::Pop(url);
   988 		}
   985 		}
   989 	
   986 	
   990 	iPlayedTimes = aReadStream.ReadInt32L();
   987 	iPlayedTimes = aReadStream.ReadInt32L();
       
   988 	
       
   989 	iRenamed = aReadStream.ReadInt32L();
       
   990 	
   991 	IRLOG_DEBUG( "CIRPresetImpl::InternalizeL - Exiting." );
   991 	IRLOG_DEBUG( "CIRPresetImpl::InternalizeL - Exiting." );
   992 	}
   992 	}
   993 
   993 
   994 
   994 
   995 // ---------------------------------------------------------------------------
   995 // ---------------------------------------------------------------------------
   999 // ---------------------------------------------------------------------------
   999 // ---------------------------------------------------------------------------
  1000 //
  1000 //
  1001 void CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl(const CIRIsdsPreset& aIsdsPreset)
  1001 void CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl(const CIRIsdsPreset& aIsdsPreset)
  1002  	{
  1002  	{
  1003 	IRLOG_DEBUG( "CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl" );
  1003 	IRLOG_DEBUG( "CIRPresetImpl::CIRIsdsPresetToCIRPresetImpl" );
  1004 	iUniqId = aIsdsPreset.UniqId();
       
  1005  	iPresetId = aIsdsPreset.GetId();
  1004  	iPresetId = aIsdsPreset.GetId();
  1006 	iChannelUrlCount = aIsdsPreset.GetUrlCount();
  1005 	iChannelUrlCount = aIsdsPreset.GetUrlCount();
  1007 	iType = aIsdsPreset.GetChannelType();  //0 for user defined 1 for isds type.
  1006 	iType = aIsdsPreset.GetChannelType();  //0 for user defined 1 for isds type.
  1008 
  1007 
  1009     TRAP_IGNORE( SetNameL( aIsdsPreset.GetName() ) )
  1008     TRAP_IGNORE( SetNameL( aIsdsPreset.GetName() ) )
  1073 // ---------------------------------------------------------------------------
  1072 // ---------------------------------------------------------------------------
  1074 //
  1073 //
  1075 void CIRPresetImpl::CopyPresetData(CIRIsdsPreset& aIsdsPreset) const
  1074 void CIRPresetImpl::CopyPresetData(CIRIsdsPreset& aIsdsPreset) const
  1076 	{
  1075 	{
  1077 	IRLOG_DEBUG( "CIRPresetImpl::CopyPresetData" );
  1076 	IRLOG_DEBUG( "CIRPresetImpl::CopyPresetData" );
  1078 	aIsdsPreset.SetUniqId( this->Id() );
       
  1079 	aIsdsPreset.SetId( iPresetId );
  1077 	aIsdsPreset.SetId( iPresetId );
  1080 	aIsdsPreset.SetUrlCount( iChannelUrlCount );
  1078 	aIsdsPreset.SetUrlCount( iChannelUrlCount );
  1081 	aIsdsPreset.SetChannelType( iType );  //0 for user defined 1 for isds type.
  1079 	aIsdsPreset.SetChannelType( iType );  //0 for user defined 1 for isds type.
  1082 	//algo
  1080 	//algo
  1083 	//1.check if the CIRIsdsPreset,member contains any data
  1081 	//1.check if the CIRIsdsPreset,member contains any data
  1133 		}
  1131 		}
  1134 	IRLOG_DEBUG( "CIRPresetImpl::GetAvailableBitrates - Exiting." );
  1132 	IRLOG_DEBUG( "CIRPresetImpl::GetAvailableBitrates - Exiting." );
  1135 	return iBitrateArray;
  1133 	return iBitrateArray;
  1136 	}
  1134 	}
  1137 
  1135 
  1138 //----------------------------------------------------------------------------
       
  1139 // TInt UniqId()
       
  1140 //----------------------------------------------------------------------------
       
  1141 TUint32 CIRPresetImpl::UniqId()
       
  1142 	{
       
  1143 	return iUniqId;
       
  1144 	}
       
  1145 //----------------------------------------------------------------------------
       
  1146 //  SetUniqId(TInt)
       
  1147 //----------------------------------------------------------------------------
       
  1148 void CIRPresetImpl::SetUniqId( TUint32 aId)
       
  1149 	{
       
  1150 	iUniqId = aId;
       
  1151 	}
       
  1152 
       
  1153 /*
  1136 /*
  1154  * Returns the played times of the channel
  1137  * Returns the played times of the channel
  1155  */
  1138  */
  1156 TInt CIRPresetImpl::GetPlayedTimes() const
  1139 TInt CIRPresetImpl::GetPlayedTimes() const
  1157 {
  1140 {
  1163  */
  1146  */
  1164 void CIRPresetImpl::SetPlayedTimes(TInt aPlayedTimes)
  1147 void CIRPresetImpl::SetPlayedTimes(TInt aPlayedTimes)
  1165 {
  1148 {
  1166     iPlayedTimes = aPlayedTimes;
  1149     iPlayedTimes = aPlayedTimes;
  1167 }
  1150 }
       
  1151 
       
  1152 TBool CIRPresetImpl::GetRenamed() const
       
  1153 {
       
  1154     return iRenamed;
       
  1155 }
       
  1156 
       
  1157 void CIRPresetImpl::SetRenamed()
       
  1158 {
       
  1159     iRenamed = ETrue;
       
  1160 }