internetradio2.0/datastructuressrc/irisdspreset.cpp
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  iSDS preset structure.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32strm.h>
       
    20 
       
    21 #include "irchannelserverurl.h"
       
    22 #include "irdebug.h"
       
    23 #include "irisdspreset.h"
       
    24 
       
    25 const TInt KUrlArrayMaxLength = 128;
       
    26 const TInt KUrlForBitrateMaxLength = 128;
       
    27 
       
    28 _LIT(KComma,",");
       
    29 
       
    30 // ======== LOCAL FUNCTIONS ========
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 //CIRIsdsPreset::NewL()
       
    36 //Static function
       
    37 //standard two phased constructor
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C CIRIsdsPreset* CIRIsdsPreset::NewL()
       
    41 	{
       
    42 	IRLOG_DEBUG( "CIRIsdsPreset::NewL - Entering" );
       
    43 	CIRIsdsPreset* self = CIRIsdsPreset::NewLC();
       
    44 	CleanupStack::Pop(self);
       
    45 	IRLOG_DEBUG( "CIRIsdsPreset::NewL - Exiting." );
       
    46 	return self;
       
    47 	}
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 //CIRIsdsPreset::NewLC()
       
    52 //Static function
       
    53 //standard two phased constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CIRIsdsPreset* CIRIsdsPreset::NewLC()
       
    57 	{
       
    58 	IRLOG_DEBUG( "CIRIsdsPreset::NewLC - Entering" );
       
    59 	CIRIsdsPreset* self = new (ELeave) CIRIsdsPreset;
       
    60 	CleanupStack::PushL(self);
       
    61 	self->ConstructL();
       
    62 	IRLOG_DEBUG( "CIRIsdsPreset::NewLC - Exiting." );
       
    63 	return self;
       
    64 	}
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 //CIRIsdsPreset::~CIRIsdsPreset()
       
    69 //standard C++ destructor
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CIRIsdsPreset::~CIRIsdsPreset()
       
    73 	{
       
    74 	IRLOG_DEBUG( "CIRIsdsPreset::~CIRIsdsPreset - Entering" );
       
    75 	iName.Close();
       
    76 	iLanguageCode.Close();
       
    77 	iLanguage.Close();
       
    78 	iCountryCode.Close();
       
    79 	iCountry.Close();
       
    80 	iLastModified.Close();
       
    81 	iMusicStoreStatus.Close();
       
    82 	iAdvertisementUrl.Close();
       
    83 	iAdvertisementInUse.Close();
       
    84 	iImgUrl.Close();
       
    85 	iLogoData.Close();
       
    86 	iDescription.Close();
       
    87 	iShortDesc.Close();
       
    88 	iGenereName.Close();
       
    89 	iGenereId.Close();
       
    90 
       
    91 	if (iUrlArray)
       
    92 		{
       
    93 		iUrlArray->ResetAndDestroy();
       
    94 		}
       
    95 	delete iUrlArray;
       
    96 	IRLOG_DEBUG( "CIRIsdsPreset::~CIRIsdsPreset - Exiting." );
       
    97 	}
       
    98 
       
    99 
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 //CIRIsdsPreset::CIRIsdsPreset()
       
   103 //default C++ constructor
       
   104 //standard two phased constructor
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 CIRIsdsPreset::CIRIsdsPreset()
       
   108 	{
       
   109 	IRLOG_DEBUG( "CIRIsdsPreset::CIRIsdsPreset" );
       
   110 	}
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 //CIRIsdsPreset::ConstructL()
       
   115 //standard second phase constructor
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CIRIsdsPreset::ConstructL()
       
   119 	{
       
   120 	IRLOG_DEBUG( "CIRIsdsPreset::ConstructL - Entering" );
       
   121 	iUrlArray = new (ELeave) CArrayPtrFlat<CIRChannelServerUrl>(
       
   122 		KUrlArrayMaxLength);
       
   123 	IRLOG_DEBUG( "CIRIsdsPreset::ConstructL - Exiting." );
       
   124 	}
       
   125 
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 //CIRIsdsPreset::SetId()
       
   129 //Function to set iPresetId from a TDesC
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 EXPORT_C void CIRIsdsPreset::SetId(const TDesC &aId)
       
   133 	{
       
   134 	IRLOG_DEBUG( "CIRIsdsPreset::SetId - Entering" );
       
   135 	TLex conv(aId);
       
   136 	conv.Val(iPresetId);
       
   137 	IRLOG_DEBUG( "CIRIsdsPreset::SetId - Exiting." );
       
   138 	}
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 //CIRIsdsPreset::SetId()
       
   143 //Function to set iPresetId
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C void CIRIsdsPreset::SetId(TInt aId)
       
   147 	{
       
   148 	IRLOG_DEBUG( "CIRIsdsPreset::SetId(TInt) - Entering" );
       
   149 	iPresetId=aId;
       
   150 	IRLOG_DEBUG( "CIRIsdsPreset::SetId(TInt) - Exiting." );
       
   151 	}
       
   152 
       
   153 
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 //CIRIsdsPreset::SetName()
       
   157 //Function to set iName from a TDesC
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C void CIRIsdsPreset::SetName(const TDesC &aName)
       
   161 	{
       
   162 	IRLOG_DEBUG( "CIRIsdsPreset::SetName - Entering" );
       
   163 	iName.Close();
       
   164 	iName.Create( aName );
       
   165 	IRLOG_DEBUG( "CIRIsdsPreset::SetName - Exiting." );
       
   166 	}
       
   167 
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 //CIRIsdsPreset::SetLangInfo()
       
   171 //Function to set iLanguageCode, iLanguage
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C void CIRIsdsPreset::SetLangInfo(const TDesC &aLangId,
       
   175 	const TDesC& aLangName)
       
   176 	{
       
   177 	IRLOG_DEBUG( "CIRIsdsPreset::SetLangInfo - Entering" );
       
   178     SetLangCode( aLangId );
       
   179     SetLang( aLangName );
       
   180 	IRLOG_DEBUG( "CIRIsdsPreset::SetLangInfo - Exiting." );
       
   181 	}
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 //CIRIsdsPreset::SetLangCode()
       
   186 //Function to set iLanguageCode from a TDesC
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C void CIRIsdsPreset::SetLangCode(const TDesC &aLangId)
       
   190 	{
       
   191 	IRLOG_DEBUG( "CIRIsdsPreset::SetLangCode - Entering" );
       
   192 	iLanguageCode.Close();
       
   193 	iLanguageCode.Create( aLangId );
       
   194 	IRLOG_DEBUG( "CIRIsdsPreset::SetLangCode - Exiting." );
       
   195 	}
       
   196 
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 //CIRIsdsPreset::SetLang()
       
   200 //Function to set iLanguage from a TDesC
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 EXPORT_C void CIRIsdsPreset::SetLang(const TDesC& aLangName)
       
   204 	{
       
   205 	IRLOG_DEBUG( "CIRIsdsPreset::SetLang - Entering" );
       
   206 	iLanguage.Close();
       
   207 	iLanguage.Create( aLangName );
       
   208 	IRLOG_DEBUG( "CIRIsdsPreset::SetLang - Exiting." );
       
   209 	}
       
   210 
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 //CIRIsdsPreset::SetCountryCode()
       
   214 //Function to set iCountryCode from a TDesC
       
   215 // ---------------------------------------------------------------------------
       
   216 //
       
   217 EXPORT_C void CIRIsdsPreset::SetCountryCode(const TDesC &aCountryId)
       
   218 	{
       
   219 	IRLOG_DEBUG( "CIRIsdsPreset::SetCountryCode - Entering" );
       
   220 	iCountryCode.Close();
       
   221 	iCountryCode.Create( aCountryId );
       
   222 	IRLOG_DEBUG( "CIRIsdsPreset::SetCountryCode - Exiting." );
       
   223 	}
       
   224 
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 //CIRIsdsPreset::SetCountryName()
       
   228 //Function to set iCountry from a TDesC
       
   229 // ---------------------------------------------------------------------------
       
   230 //
       
   231 EXPORT_C void CIRIsdsPreset::SetCountryName(const TDesC& aCountryName)
       
   232 	{
       
   233 	IRLOG_DEBUG( "CIRIsdsPreset::SetCountryName - Entering" );
       
   234 	iCountry.Close();
       
   235 	iCountry.Create( aCountryName );
       
   236 	IRLOG_DEBUG( "CIRIsdsPreset::SetCountryName - Exiting." );
       
   237 	}
       
   238 
       
   239 
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 //CIRIsdsPreset::SetLangInfo()
       
   243 //Function to set iCountryCode, iCountry
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 EXPORT_C void CIRIsdsPreset::SetCountryInfo(const TDesC &aCountryId,
       
   247 	const TDesC& aCountryName)
       
   248 	{
       
   249 	IRLOG_DEBUG( "CIRIsdsPreset::SetCountryInfo - Entering" );
       
   250 	SetCountryCode( aCountryId );
       
   251     SetCountryName( aCountryName );
       
   252 	IRLOG_DEBUG( "CIRIsdsPreset::SetCountryInfo - Exiting." );
       
   253 	}
       
   254 
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 //CIRIsdsPreset::SetLastModifiedTime()
       
   258 //Function to set iLastModified
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 EXPORT_C void CIRIsdsPreset::SetLastModifiedTime(const TDesC &aLastModified)
       
   262 	{
       
   263 	IRLOG_DEBUG( "CIRIsdsPreset::SetLastModifiedTime - Entering" );
       
   264 	iLastModified.Close();
       
   265 	iLastModified.Create( aLastModified );
       
   266 	IRLOG_DEBUG( "CIRIsdsPreset::SetLastModifiedTime - Exiting." );
       
   267 	}
       
   268 
       
   269 
       
   270 // ---------------------------------------------------------------------------
       
   271 //CIRIsdsPreset::SetGenreInfo()
       
   272 //Function to set iGenereName, iGenereId
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C void CIRIsdsPreset::SetGenreInfo(const TDesC& aGenreId,
       
   276 	const TDesC& aGenreName)
       
   277 	{
       
   278 	IRLOG_DEBUG( "CIRIsdsPreset::SetGenreInfo - Entering" );
       
   279 
       
   280 	if(iGenereName.Length())
       
   281 		{
       
   282 		RBuf newBuf;
       
   283 		newBuf.Create(
       
   284 		    iGenereName.Length() + aGenreName.Length() + KComma().Length() );
       
   285 		newBuf.Append( iGenereName );
       
   286 		newBuf.Append( KComma );
       
   287 		newBuf.Append( aGenreName );
       
   288 		iGenereName.Close();
       
   289 		iGenereName.Create( newBuf );
       
   290 		newBuf.Close();
       
   291 		}
       
   292 	if(iGenereId.Length())
       
   293 		{
       
   294 		RBuf newBuf;
       
   295         newBuf.Create(
       
   296             iGenereId.Length() + aGenreId.Length() + KComma().Length() );
       
   297         newBuf.Append( iGenereId );
       
   298         newBuf.Append( KComma );
       
   299         newBuf.Append( aGenreId );
       
   300         iGenereId.Close();
       
   301         iGenereId.Create( newBuf );
       
   302         newBuf.Close();
       
   303 		}
       
   304 	if(!iGenereName.Length())
       
   305 		{
       
   306 		iGenereName.Close();
       
   307 		iGenereName.Create( aGenreName );
       
   308 		}
       
   309 	if(!iGenereId.Length())
       
   310 		{
       
   311 		iGenereId.Close();
       
   312 		iGenereId.Create( aGenreId );
       
   313 		}
       
   314 
       
   315 	IRLOG_DEBUG( "CIRIsdsPreset::SetGenreInfo - Exiting." );
       
   316 	}
       
   317 
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 //CIRIsdsPreset::SetImgUrl()
       
   321 //Function to set iImgUrl
       
   322 // ---------------------------------------------------------------------------
       
   323 //
       
   324 EXPORT_C void CIRIsdsPreset::SetImgUrl(const TDesC& aImgUrl)
       
   325 	{
       
   326 	IRLOG_DEBUG( "CIRIsdsPreset::SetImgUrl - Entering" );
       
   327 	iImgUrl.Close();
       
   328 	iImgUrl.Create( aImgUrl );
       
   329 	IRLOG_DEBUG( "CIRIsdsPreset::SetImgUrl - Exiting." );
       
   330 	}
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 //CIRIsdsPreset::SetLogoData()
       
   334 //Function to set LogoData
       
   335 // ---------------------------------------------------------------------------
       
   336 //
       
   337 
       
   338 EXPORT_C void CIRIsdsPreset::SetLogoData( const TDesC8& aData )
       
   339 	{
       
   340 	IRLOG_DEBUG( "CIRIsdsPreset::SetLogoDataL - Entering" );
       
   341 
       
   342 	iLogoData.Close();
       
   343 	iLogoData.Create( aData );
       
   344 
       
   345 	IRLOG_DEBUG( "CIRIsdsPreset::SetLogoDataL - Exiting." );
       
   346 	}
       
   347 
       
   348 // ---------------------------------------------------------------------------
       
   349 //CIRIsdsPreset::SetAdvertisementInUse()
       
   350 //Function to set iAdvertisementInUse
       
   351 // ---------------------------------------------------------------------------
       
   352 //
       
   353 EXPORT_C void CIRIsdsPreset::SetAdvertisementInUse(
       
   354 	const TDesC& aAdvertisementInUse)
       
   355 	{
       
   356 	IRLOG_DEBUG( "CIRIsdsPreset::SetAdvertisementInUse - Entering" );
       
   357 	iAdvertisementInUse.Close();
       
   358 	iAdvertisementInUse.Create( aAdvertisementInUse );
       
   359 	IRLOG_DEBUG( "CIRIsdsPreset::SetAdvertisementInUse - Exiting." );
       
   360 	}
       
   361 
       
   362 
       
   363 // ---------------------------------------------------------------------------
       
   364 //CIRIsdsPreset::SetDescription()
       
   365 //Function to set iDescription
       
   366 // ---------------------------------------------------------------------------
       
   367 //
       
   368 EXPORT_C void CIRIsdsPreset:: SetDescription(const TDesC& aDescription)
       
   369 	{
       
   370     IRLOG_DEBUG( "CIRIsdsPreset::SetDescription - Entering" );
       
   371     iDescription.Close();
       
   372     iDescription.Create( aDescription );
       
   373 	IRLOG_DEBUG( "CIRIsdsPreset::SetDescription - Exiting." );
       
   374 	}
       
   375 
       
   376 
       
   377 // ---------------------------------------------------------------------------
       
   378 //CIRIsdsPreset::SetAdvertisementUrl()
       
   379 //Function to set iAdvertisementUrl
       
   380 // ---------------------------------------------------------------------------
       
   381 //
       
   382 EXPORT_C void CIRIsdsPreset::SetAdvertisementUrl(
       
   383 	const TDesC& aAdvertisementUrl)
       
   384 	{
       
   385 	IRLOG_DEBUG( "CIRIsdsPreset::SetAdvertisementUrl - Entering" );
       
   386 	iAdvertisementUrl.Close();
       
   387 	iAdvertisementUrl.Create( aAdvertisementUrl );
       
   388 	IRLOG_DEBUG( "CIRIsdsPreset::SetAdvertisementUrl - Exiting." );
       
   389 	}
       
   390 
       
   391 
       
   392 // ---------------------------------------------------------------------------
       
   393 //CIRIsdsPreset::SetUrlCount()
       
   394 //Function to set iChannelUrlCount
       
   395 // ---------------------------------------------------------------------------
       
   396 //
       
   397 EXPORT_C void CIRIsdsPreset::SetUrlCount()
       
   398 	{
       
   399 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlCount - Entering" );
       
   400 	iChannelUrlCount=iUrlArray->Count();
       
   401 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlCount - Exiting." );
       
   402 	}
       
   403 
       
   404 
       
   405 // ---------------------------------------------------------------------------
       
   406 //CIRIsdsPreset::SetShortDesc()
       
   407 //Function to set iShortDesc
       
   408 // ---------------------------------------------------------------------------
       
   409 //
       
   410 EXPORT_C void CIRIsdsPreset:: SetShortDesc(const TDesC& aShortDesc)
       
   411 	{
       
   412     IRLOG_DEBUG( "CIRIsdsPreset::SetShortDesc - Entering" );
       
   413     iShortDesc.Close();
       
   414     iShortDesc.Create( aShortDesc );
       
   415 	IRLOG_DEBUG( "CIRIsdsPreset::SetShortDesc - Exiting." );
       
   416 	}
       
   417 
       
   418 // ---------------------------------------------------------------------------
       
   419 // CIRIsdsPreset::SetGenreName()
       
   420 // ---------------------------------------------------------------------------
       
   421 //
       
   422 EXPORT_C void CIRIsdsPreset::SetGenreName(const TDesC& aGenreName)
       
   423 	{
       
   424 	IRLOG_DEBUG( "CIRIsdsPreset::SetGenreName - Entering" );
       
   425 	iGenereName.Close();
       
   426 	iGenereName.Create( aGenreName );
       
   427 	IRLOG_DEBUG( "CIRIsdsPreset::SetGenreName - Exiting" );
       
   428 	}
       
   429 
       
   430 // ---------------------------------------------------------------------------
       
   431 // CIRIsdsPreset::SetGenreId()
       
   432 // ---------------------------------------------------------------------------
       
   433 //
       
   434 EXPORT_C void CIRIsdsPreset::SetGenreId(const TDesC& aGenreId)
       
   435 	{
       
   436 	IRLOG_DEBUG( "CIRIsdsPreset::SetGenreId - Entering" );
       
   437 	iGenereId.Close();
       
   438 	iGenereId.Create( aGenreId );
       
   439 	IRLOG_DEBUG( "CIRIsdsPreset::SetGenreId - Exiting" );
       
   440 	}
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 //CIRIsdsPreset::SetUrlCount()
       
   444 //Function to set iChannelUrlCount
       
   445 // ---------------------------------------------------------------------------
       
   446 //
       
   447 EXPORT_C void CIRIsdsPreset::SetUrlCount(TInt aCnt)
       
   448 	{
       
   449 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlCount - Entering" );
       
   450 	iChannelUrlCount=aCnt;
       
   451 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlCount - Exiting." );
       
   452 	}
       
   453 
       
   454 // ---------------------------------------------------------------------------
       
   455 //CIRIsdsPreset::SetUrl()
       
   456 //Function to set Url parameter
       
   457 // ---------------------------------------------------------------------------
       
   458 //
       
   459 EXPORT_C void CIRIsdsPreset::SetUrlL(const TDesC &aServerName,
       
   460 	const TDesC &aUrl,const TDesC &aBitrate)
       
   461 	{
       
   462 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlL(..., const TDesC) - Entering" );
       
   463 	CIRChannelServerUrl * hold=CIRChannelServerUrl::NewL();
       
   464 	hold->SetServerName(aServerName);
       
   465 	hold->SetServerUrl(aUrl);
       
   466 	TLex conv(aBitrate);
       
   467 	TInt conVal = 0;
       
   468 	conv.Val(conVal);
       
   469 	//if a negative value comes,set the bitrate to 0,so that it is accessable
       
   470 	//to all the setting combination
       
   471 	if ( conVal < 0)
       
   472 		{
       
   473 		conVal = 0;
       
   474 		}
       
   475 	hold->SetBitRate(conVal);
       
   476 	iUrlArray->AppendL(hold);
       
   477 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlL(..., const TDesC) - Exiting." );
       
   478 	}
       
   479 
       
   480 
       
   481 // ---------------------------------------------------------------------------
       
   482 //CIRIsdsPreset::SetUrl()
       
   483 //Function to set Url parameter
       
   484 // ---------------------------------------------------------------------------
       
   485 //
       
   486 EXPORT_C void CIRIsdsPreset::SetUrlL(const TDesC &aServerName,
       
   487 	const TDesC &aUrl,TInt aBitrate)
       
   488 	{
       
   489 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlL(..., TInt) - Entering" );
       
   490 	CIRChannelServerUrl * hold=CIRChannelServerUrl::NewL();
       
   491 	hold->SetServerName(aServerName);
       
   492 	hold->SetServerUrl(aUrl);
       
   493 
       
   494 	//if a negative value comes,set the bitrate to 0,so that it is accessable
       
   495 	//to all the setting combination
       
   496 	if (aBitrate < 0)
       
   497 		{
       
   498 		aBitrate = 0;
       
   499 		}
       
   500 	hold->SetBitRate(aBitrate);
       
   501 	iUrlArray->AppendL(hold);
       
   502 	IRLOG_DEBUG( "CIRIsdsPreset::SetUrlL(..., TInt) - Exiting." );
       
   503 	}
       
   504 
       
   505 
       
   506 // ---------------------------------------------------------------------------
       
   507 //CIRIsdsPreset::SetChannelType()
       
   508 //Function to set iType
       
   509 // ---------------------------------------------------------------------------
       
   510 //
       
   511 EXPORT_C void CIRIsdsPreset::SetChannelType(TInt aType)
       
   512 	{
       
   513 	IRLOG_DEBUG( "CIRIsdsPreset::SetChannelType - Entering" );
       
   514 
       
   515 	if ( aType != EUserDefined && aType!=EIsdsPreset && aType!=EAdhoc)
       
   516 		{
       
   517 		aType=EUserDefined;
       
   518 		}
       
   519 	iType = aType;
       
   520 	IRLOG_DEBUG( "CIRIsdsPreset::SetChannelType - Exiting." );
       
   521 	}
       
   522 
       
   523 // ---------------------------------------------------------------------------
       
   524 //CIRIsdsPreset::SetMusicStoreStatus()
       
   525 //Function to set iMusicStoreStatus parameter
       
   526 // ---------------------------------------------------------------------------
       
   527 //
       
   528 EXPORT_C void CIRIsdsPreset::SetMusicStoreStatus(const TDesC& aMusicStoreStatus)
       
   529 	{
       
   530 	IRLOG_DEBUG( "CIRIsdsPreset::SetMusicStoreStatus - Entering" );
       
   531 	iMusicStoreStatus.Close();
       
   532 	iMusicStoreStatus.Create( aMusicStoreStatus );	
       
   533 	IRLOG_DEBUG( "CIRIsdsPreset::SetMusicStoreStatus - Exiting" );
       
   534 	}
       
   535 
       
   536 
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 //CIRIsdsPreset::ExternalizeL()
       
   540 //externalizes the data
       
   541 // ---------------------------------------------------------------------------
       
   542 //
       
   543 EXPORT_C  void CIRIsdsPreset::ExternalizeL(RWriteStream& aWriteStream)
       
   544 	{
       
   545 	IRLOG_DEBUG( "CIRIsdsPreset::ExternalizeL - Entering" );
       
   546 //! externalize TInts s
       
   547 	aWriteStream.WriteInt32L(iPresetId);
       
   548 	aWriteStream.WriteInt32L(iType);
       
   549 	aWriteStream.WriteInt32L(iChannelUrlCount);
       
   550 
       
   551 	// Externalize RBufs
       
   552     aWriteStream << iLanguageCode;
       
   553     aWriteStream << iLanguage;
       
   554     aWriteStream << iCountryCode;
       
   555     aWriteStream << iCountry;
       
   556     aWriteStream << iGenereName;
       
   557     aWriteStream << iGenereId;
       
   558     aWriteStream << iName;
       
   559     aWriteStream << iLastModified;
       
   560     aWriteStream << iAdvertisementUrl;
       
   561     aWriteStream << iAdvertisementInUse;
       
   562     aWriteStream << iImgUrl;
       
   563     aWriteStream << iDescription;
       
   564     aWriteStream << iShortDesc;
       
   565 	aWriteStream << iMusicStoreStatus;
       
   566 	aWriteStream << iLogoData;
       
   567 
       
   568 
       
   569 	for(TInt cnt=0;cnt<iChannelUrlCount;cnt++)
       
   570 		{
       
   571 		GetUrl(cnt).ExternalizeL(aWriteStream);
       
   572 		}
       
   573 	IRLOG_DEBUG( "CIRIsdsPreset::ExternalizeL - Exiting." );
       
   574 	}
       
   575 
       
   576 
       
   577 // ---------------------------------------------------------------------------
       
   578 //CIRIsdsPreset::InternalizeL()
       
   579 //internalizes the data
       
   580 // ---------------------------------------------------------------------------
       
   581 //
       
   582 EXPORT_C void CIRIsdsPreset::InternalizeL(RReadStream& aReadStream)
       
   583 	{
       
   584 	IRLOG_DEBUG( "CIRIsdsPreset::InternalizeL - Entering" );
       
   585 	//! Internalize TInts s
       
   586 	iPresetId=aReadStream.ReadInt32L();
       
   587 	iType=aReadStream.ReadInt32L();
       
   588 	iChannelUrlCount=aReadStream.ReadInt32L();
       
   589 
       
   590 	// Internalize RBufs
       
   591 	iLanguageCode.Close();
       
   592 	iLanguageCode.CreateL(aReadStream, KMaxTInt);
       
   593 
       
   594 	iLanguage.Close();
       
   595 	iLanguage.CreateL(aReadStream, KMaxTInt);
       
   596 
       
   597 	iCountryCode.Close();
       
   598 	iCountryCode.CreateL(aReadStream, KMaxTInt);
       
   599 
       
   600 	iCountry.Close();
       
   601 	iCountry.CreateL(aReadStream, KMaxTInt);
       
   602 
       
   603 	iGenereName.Close();
       
   604 	iGenereName.CreateL(aReadStream, KMaxTInt);
       
   605 
       
   606 	iGenereId.Close();
       
   607 	iGenereId.CreateL(aReadStream, KMaxTInt);
       
   608 
       
   609 	iName.Close();
       
   610 	iName.CreateL(aReadStream, KMaxTInt);
       
   611 
       
   612 	iLastModified.Close();
       
   613 	iLastModified.CreateL(aReadStream, KMaxTInt);
       
   614 
       
   615 	iAdvertisementUrl.Close();
       
   616 	iAdvertisementUrl.CreateL(aReadStream, KMaxTInt);
       
   617 
       
   618 	iAdvertisementInUse.Close();
       
   619 	iAdvertisementInUse.CreateL(aReadStream, KMaxTInt);
       
   620 
       
   621 	iImgUrl.Close();
       
   622 	iImgUrl.CreateL(aReadStream, KMaxTInt);
       
   623 
       
   624 	iDescription.Close();
       
   625 	iDescription.CreateL(aReadStream, KMaxTInt);
       
   626 
       
   627 	iShortDesc.Close();
       
   628 	iShortDesc.CreateL(aReadStream, KMaxTInt);
       
   629 
       
   630 	iMusicStoreStatus.Close();
       
   631 	iMusicStoreStatus.CreateL(aReadStream, KMaxTInt);
       
   632 
       
   633 
       
   634     iUrlArray->ResetAndDestroy();
       
   635 
       
   636 	iLogoData.Close();
       
   637 	iLogoData.CreateL(aReadStream, KMaxTInt);
       
   638 	
       
   639 	
       
   640 	
       
   641 	CIRChannelServerUrl* url = NULL;
       
   642 	for(TInt cnt=0;cnt<iChannelUrlCount;cnt++)
       
   643 		{
       
   644 		url=CIRChannelServerUrl::NewLC();
       
   645 		url->InternalizeL(aReadStream);
       
   646 		iUrlArray->AppendL(url);
       
   647 		CleanupStack::Pop( url );
       
   648 		}
       
   649 	IRLOG_DEBUG( "CIRIsdsPreset::InternalizeL - Exiting." );
       
   650 	}
       
   651 
       
   652 
       
   653 // ---------------------------------------------------------------------------
       
   654 //CIRIsdsPreset::GetId()
       
   655 //Function to get iPresetId
       
   656 // ---------------------------------------------------------------------------
       
   657 //
       
   658 EXPORT_C TInt CIRIsdsPreset::GetId() const
       
   659 	{
       
   660 	IRLOG_DEBUG( "CIRIsdsPreset::GetId" );
       
   661 	return iPresetId;
       
   662 	}
       
   663 
       
   664 
       
   665 // ---------------------------------------------------------------------------
       
   666 //CIRIsdsPreset::GetId()
       
   667 //Function to get iName
       
   668 // ---------------------------------------------------------------------------
       
   669 //
       
   670 EXPORT_C  const TDesC& CIRIsdsPreset::GetName() const 
       
   671 	{
       
   672 	IRLOG_DEBUG( "CIRIsdsPreset::GetName" );
       
   673 	return iName;
       
   674 	}
       
   675 
       
   676 
       
   677 // ---------------------------------------------------------------------------
       
   678 //CIRIsdsPreset::GetLangId()
       
   679 //Function to get iLanguageCode
       
   680 // ---------------------------------------------------------------------------
       
   681 //
       
   682 EXPORT_C const TDesC& CIRIsdsPreset::GetLangId() const
       
   683 	{
       
   684 	IRLOG_DEBUG( "CIRIsdsPreset::GetLangId" );
       
   685 	return iLanguageCode;
       
   686 	}
       
   687 
       
   688 
       
   689 // ---------------------------------------------------------------------------
       
   690 //CIRIsdsPreset::GetLangName()
       
   691 //Function to get iLanguage
       
   692 // ---------------------------------------------------------------------------
       
   693 //
       
   694 EXPORT_C const TDesC& CIRIsdsPreset::GetLangName() const
       
   695 	{
       
   696 	IRLOG_DEBUG( "CIRIsdsPreset::GetLangName" );
       
   697 	return iLanguage;
       
   698 	}
       
   699 
       
   700 
       
   701 // ---------------------------------------------------------------------------
       
   702 //CIRIsdsPreset::GetCountryId()
       
   703 //Function to get iCountryCode
       
   704 // ---------------------------------------------------------------------------
       
   705 //
       
   706 EXPORT_C const TDesC& CIRIsdsPreset::GetCountryId() const
       
   707 	{
       
   708 	IRLOG_DEBUG( "CIRIsdsPreset::GetCountryId" );
       
   709 	return iCountryCode;
       
   710 	}
       
   711 
       
   712 
       
   713 // ---------------------------------------------------------------------------
       
   714 //CIRIsdsPreset::GetCountryName()
       
   715 //Function to get iCountry
       
   716 // ---------------------------------------------------------------------------
       
   717 //
       
   718 EXPORT_C const TDesC& CIRIsdsPreset::GetCountryName() const
       
   719 	{
       
   720 	IRLOG_DEBUG( "CIRIsdsPreset::GetCountryName" );
       
   721 	return iCountry;
       
   722 	}
       
   723 
       
   724 
       
   725 // ---------------------------------------------------------------------------
       
   726 //CIRIsdsPreset::GetLastModifiedTime()
       
   727 //Function to get iLastModified
       
   728 // ---------------------------------------------------------------------------
       
   729 //
       
   730 EXPORT_C const TDesC& CIRIsdsPreset::GetLastModifiedTime() const 
       
   731 	{
       
   732 	IRLOG_DEBUG( "CIRIsdsPreset::GetLastModifiedTime" );
       
   733 	return iLastModified;
       
   734 	}
       
   735 
       
   736 
       
   737 // ---------------------------------------------------------------------------
       
   738 //CIRIsdsPreset::GetDescription()
       
   739 //Function to get iDescription
       
   740 // ---------------------------------------------------------------------------
       
   741 //
       
   742 EXPORT_C const TDesC& CIRIsdsPreset::GetDescription() const
       
   743 	{
       
   744 	IRLOG_DEBUG( "CIRIsdsPreset::GetDescription" );
       
   745 	return iDescription;
       
   746 	}
       
   747 
       
   748 // ---------------------------------------------------------------------------
       
   749 //CIRIsdsPreset::GetShortDescription()
       
   750 //Function to get iDescription
       
   751 // ---------------------------------------------------------------------------
       
   752 //
       
   753 EXPORT_C  const TDesC& CIRIsdsPreset::GetShortDescription() const 
       
   754 	{
       
   755 	IRLOG_DEBUG( "CIRIsdsPreset::GetShortDescription" );
       
   756 	return iShortDesc;
       
   757 	}
       
   758 
       
   759 // ---------------------------------------------------------------------------
       
   760 //CIRIsdsPreset::GetChannelType()
       
   761 //Function to get iType
       
   762 // ---------------------------------------------------------------------------
       
   763 //
       
   764 EXPORT_C TInt CIRIsdsPreset::GetChannelType() const
       
   765 	{
       
   766 	IRLOG_DEBUG( "CIRIsdsPreset::GetChannelType" );
       
   767 	return iType;
       
   768 	}
       
   769 
       
   770 // ---------------------------------------------------------------------------
       
   771 //CIRIsdsPreset::GetGenreId()
       
   772 //Function to get iGenereId
       
   773 // ---------------------------------------------------------------------------
       
   774 //
       
   775 EXPORT_C const TDesC& CIRIsdsPreset::GetGenreId() const
       
   776 	{
       
   777 	IRLOG_DEBUG( "CIRIsdsPreset::GetGenreId" );
       
   778 	return iGenereId;
       
   779 	}
       
   780 
       
   781 
       
   782 // ---------------------------------------------------------------------------
       
   783 //CIRIsdsPreset::GetGenreName()
       
   784 //Function to get iGenereName
       
   785 // ---------------------------------------------------------------------------
       
   786 //
       
   787 EXPORT_C const TDesC& CIRIsdsPreset::GetGenreName() const
       
   788 	{
       
   789 	IRLOG_DEBUG( "CIRIsdsPreset::GetGenreName" );
       
   790 	return iGenereName;
       
   791 	}
       
   792 
       
   793 
       
   794 // ---------------------------------------------------------------------------
       
   795 //CIRIsdsPreset::GetAdvertisementUrl()
       
   796 //Function to get iAdvertisementUrl
       
   797 // ---------------------------------------------------------------------------
       
   798 //
       
   799 EXPORT_C const TDesC& CIRIsdsPreset::GetAdvertisementUrl() const
       
   800 	{
       
   801 	IRLOG_DEBUG( "CIRIsdsPreset::GetAdvertisementUrl" );
       
   802 	return iAdvertisementUrl;
       
   803 	}
       
   804 
       
   805 // ---------------------------------------------------------------------------
       
   806 // CIRIsdsPreset::GetAdvertisementInUse()
       
   807 // ---------------------------------------------------------------------------
       
   808 //
       
   809 EXPORT_C const TDesC& CIRIsdsPreset::GetAdvertisementInUse() const
       
   810 	{
       
   811 	IRLOG_DEBUG( "CIRIsdsPreset::GetAdvertisementInUse" );
       
   812 	return iAdvertisementInUse;
       
   813 	}
       
   814 
       
   815 // ---------------------------------------------------------------------------
       
   816 // CIRIsdsPreset::GetImgUrl()
       
   817 // Function to get iImgUrl
       
   818 // ---------------------------------------------------------------------------
       
   819 //
       
   820 EXPORT_C const TDesC& CIRIsdsPreset::GetImgUrl() const
       
   821 	{
       
   822 	IRLOG_DEBUG( "CIRIsdsPreset::GetImgUrl" );
       
   823 	return iImgUrl;
       
   824 	}
       
   825 
       
   826 // ---------------------------------------------------------------------------
       
   827 //CIRIsdsPreset::GetUrlCount()
       
   828 //Function to get iChannelUrlCount
       
   829 // ---------------------------------------------------------------------------
       
   830 //
       
   831 EXPORT_C TInt CIRIsdsPreset::GetUrlCount() const
       
   832 	{
       
   833 	IRLOG_DEBUG( "CIRIsdsPreset::GetUrlCount" );
       
   834 	return iChannelUrlCount;
       
   835 	}
       
   836 
       
   837 
       
   838 // ---------------------------------------------------------------------------
       
   839 //CIRIsdsPreset::GetUrl()
       
   840 //Function to get iLanguageCode
       
   841 // ---------------------------------------------------------------------------
       
   842 //
       
   843 EXPORT_C CIRChannelServerUrl& CIRIsdsPreset::GetUrl(TInt aInt)
       
   844 	{
       
   845 	IRLOG_DEBUG( "CIRIsdsPreset::GetUrl" );
       
   846 	ASSERT( aInt >= 0 && aInt < iUrlArray->Count() ); 
       
   847 	return ((*iUrlArray->At(aInt)));
       
   848 	}
       
   849 
       
   850 
       
   851 EXPORT_C  const TDesC& CIRIsdsPreset::GetMusicStoreStatus() const 
       
   852 	{
       
   853 	IRLOG_DEBUG( "CIRIsdsPreset::GetMusicStoreStatus" );
       
   854 	return iMusicStoreStatus;	
       
   855 	}
       
   856 
       
   857 
       
   858 
       
   859 
       
   860 // ---------------------------------------------------------------------------
       
   861 //CIRIsdsPreset::GetLogoData()
       
   862 //Function to get LogoData
       
   863 // ---------------------------------------------------------------------------
       
   864 //
       
   865 EXPORT_C  const TDesC8& CIRIsdsPreset::GetLogoData() const 
       
   866 	{
       
   867 	IRLOG_DEBUG( "CIRIsdsPreset::GetLogoData" );
       
   868 	return iLogoData;
       
   869 	}
       
   870 
       
   871 
       
   872 // ---------------------------------------------------------------------------
       
   873 //CIRIsdsPreset::=()
       
   874 //standard C++ copy constructor(deep copy)
       
   875 // ---------------------------------------------------------------------------
       
   876 //
       
   877 EXPORT_C CIRIsdsPreset& CIRIsdsPreset::operator=(const CIRIsdsPreset& aPreset)
       
   878 	{
       
   879     IRLOG_DEBUG( "CIRIsdsPreset::operator=  - Entering" );
       
   880 
       
   881     if(&aPreset == this)
       
   882 		{
       
   883 		return *this;
       
   884 		}
       
   885 
       
   886     iName.Close();
       
   887 	iName.Create(aPreset.iName);
       
   888 
       
   889 	iLanguageCode.Close();
       
   890 	iLanguageCode.Create(aPreset.iLanguageCode);
       
   891 
       
   892 	iLanguage.Close();
       
   893 	iLanguage.Create(aPreset.iLanguage);
       
   894 
       
   895 	iCountryCode.Close();
       
   896 	iCountryCode.Create(aPreset.iCountryCode);
       
   897 
       
   898 	iCountry.Close();
       
   899 	iCountry.Create(aPreset.iCountry);
       
   900 
       
   901 	iLastModified.Close();
       
   902 	iLastModified.Create(aPreset.iLastModified);
       
   903 
       
   904 	iAdvertisementUrl.Close();
       
   905 	iAdvertisementUrl.Create(aPreset.iAdvertisementUrl);
       
   906 
       
   907 	iAdvertisementInUse.Close();
       
   908 	iAdvertisementInUse.Create(aPreset.iAdvertisementInUse);
       
   909 
       
   910 	iImgUrl.Close();
       
   911 	iImgUrl.Create(aPreset.iImgUrl);
       
   912 
       
   913 	iLogoData.Close();
       
   914 	iLogoData.Create(aPreset.iLogoData);
       
   915 
       
   916 	iDescription.Close();
       
   917 	iDescription.Create(aPreset.iDescription);
       
   918 
       
   919 	iShortDesc.Close();
       
   920 	iShortDesc.Create(aPreset.iShortDesc);
       
   921 	
       
   922 	iMusicStoreStatus.Close();
       
   923 	iMusicStoreStatus.Create(aPreset.iMusicStoreStatus);
       
   924 
       
   925 	iGenereName.Close();
       
   926 	iGenereName.Create(aPreset.iGenereName);
       
   927 
       
   928 	iGenereId.Close();
       
   929 	iGenereId.Create(aPreset.iGenereId);
       
   930 
       
   931 
       
   932 	iUrlArray->ResetAndDestroy();
       
   933 		
       
   934 	for(TInt cnt=0;cnt<aPreset.iChannelUrlCount;cnt++)
       
   935 		{
       
   936 		ASSERT( cnt >= 0 && cnt < aPreset.iUrlArray->Count() );
       
   937 		TRAPD(errUrl,SetUrlL(aPreset.iUrlArray->At(cnt)->GetServerName(),
       
   938 		aPreset.iUrlArray->At(cnt)->GetServerUrl(),
       
   939 		aPreset.iUrlArray->At(cnt)->GetBitRate()))
       
   940 		if(errUrl!=KErrNone)
       
   941 			{
       
   942 			return *this ;
       
   943 			}
       
   944 		}
       
   945 	iChannelUrlCount=aPreset.iChannelUrlCount;
       
   946 	iType=aPreset.iType;  //0 for user defined 1 for isds type.
       
   947 	iPresetId = aPreset.iPresetId;
       
   948 	IRLOG_DEBUG( "CIRIsdsPreset::operator= - Exiting." );
       
   949  	return *this;
       
   950 	}
       
   951 
       
   952 
       
   953 // ---------------------------------------------------------------------------
       
   954 //CIRIsdsPreset::GetAvailableBitrates()
       
   955 //Function to get available bitrates
       
   956 // ---------------------------------------------------------------------------
       
   957 //
       
   958 EXPORT_C TInt CIRIsdsPreset::GetAvailableBitrates(RArray<TInt>& aBitrates) const
       
   959 	{
       
   960 	IRLOG_DEBUG( "CIRIsdsPreset::GetAvailableBitrates - Entering." );
       
   961 	aBitrates.Reset();
       
   962 	TInt err = KErrNone;
       
   963 	for(TInt loop=0;loop<iUrlArray->Count() && !err;loop++)
       
   964 		{
       
   965 		err = aBitrates.InsertInOrder(iUrlArray->At(loop)->GetBitRate());
       
   966 		if (err == KErrAlreadyExists)
       
   967 		    {
       
   968 		    // Do not allow duplicates, but strip them away.
       
   969 		    err = KErrNone;
       
   970 		    }
       
   971 		}
       
   972 
       
   973     if (err)
       
   974         {
       
   975         aBitrates.Reset();
       
   976         }
       
   977 	IRLOG_DEBUG( "CIRIsdsPreset::GetAvailableBitrates - Exiting." );
       
   978 	return err;
       
   979 	}
       
   980 
       
   981 
       
   982 // ---------------------------------------------------------------------------
       
   983 //CIRIsdsPreset::GetUrlForBitrateL()
       
   984 //Function to get Url for a given bitrate
       
   985 // ---------------------------------------------------------------------------
       
   986 //
       
   987 EXPORT_C CDesCArrayFlat* CIRIsdsPreset::GetUrlForBitrateL(TInt aBitrate)
       
   988 	{
       
   989 	IRLOG_DEBUG( "CIRIsdsPreset::GetUrlForBitrateL - Entering." );
       
   990 	CDesCArrayFlat* urlForBitrate = new (ELeave) CDesCArrayFlat(KUrlForBitrateMaxLength);
       
   991 	CleanupStack::PushL(urlForBitrate);
       
   992 	iBitrate=aBitrate;
       
   993 	SortInOrderL();
       
   994 	//appending the urls with bit rate less than or
       
   995 	//equal to given bit rate limit
       
   996 	for(TInt loop=0;loop<iUrlArray->Count();loop++)
       
   997 		{
       
   998 		if(aBitrate>=iUrlArray->At(loop)->GetBitRate())
       
   999 			{
       
  1000 			urlForBitrate->AppendL(iUrlArray->At(loop)->GetServerUrl());
       
  1001 			}
       
  1002 		}
       
  1003 	//appending	the url	with bit rate greater than given
       
  1004 	//bit rate limit
       
  1005 	for(TInt loop = (iUrlArray->Count()-1);loop >= 0;loop--)
       
  1006 		{
       
  1007 		if(aBitrate<iUrlArray->At(loop)->GetBitRate())
       
  1008 			{
       
  1009 			urlForBitrate->AppendL(iUrlArray->At(loop)->GetServerUrl());
       
  1010 			}
       
  1011 		}
       
  1012 	if ( urlForBitrate->MdcaCount()==0 && iUrlArray->Count() > 0 )
       
  1013 		{
       
  1014 		urlForBitrate->AppendL(iUrlArray->At(0)->GetServerUrl());
       
  1015 		}
       
  1016 
       
  1017 
       
  1018     CleanupStack::Pop(urlForBitrate);
       
  1019 	IRLOG_DEBUG( "CIRIsdsPreset::GetUrlForBitrateL - Exiting." );
       
  1020 	return urlForBitrate;
       
  1021 	}
       
  1022 
       
  1023 
       
  1024 // ---------------------------------------------------------------------------
       
  1025 //CIRIsdsPreset::GetExactUrlForBitrateL()
       
  1026 //Function to get Urls exactly matching a given bitrate for display purpose
       
  1027 // ---------------------------------------------------------------------------
       
  1028 //
       
  1029 EXPORT_C CDesCArrayFlat* CIRIsdsPreset::GetExactUrlForBitrateL(TInt aBitrate)
       
  1030 	{
       
  1031 	IRLOG_DEBUG( "CIRIsdsPreset::GetUrlForBitrateL - Entering." );
       
  1032 	CDesCArrayFlat* urlForBitrate = new (ELeave) CDesCArrayFlat(KUrlForBitrateMaxLength);
       
  1033 	CleanupStack::PushL(urlForBitrate);
       
  1034 
       
  1035 	SortInOrderL();
       
  1036 	//appending the urls with bit rate less than or
       
  1037 	//equal to given bit rate limit
       
  1038 	for(TInt loop=0;loop<iUrlArray->Count();loop++)
       
  1039 		{
       
  1040 		if(aBitrate==iUrlArray->At(loop)->GetBitRate())
       
  1041 			{
       
  1042 			urlForBitrate->AppendL(iUrlArray->At(loop)->GetServerUrl());
       
  1043 			}
       
  1044 		}
       
  1045 
       
  1046     CleanupStack::Pop(urlForBitrate);
       
  1047 	IRLOG_DEBUG( "CIRIsdsPreset::GetUrlForBitrateL - Exiting." );
       
  1048 	return urlForBitrate;
       
  1049 	}
       
  1050 
       
  1051 // ---------------------------------------------------------------------------
       
  1052 //CIRIsdsPreset::GetChannelUrlAtL()
       
  1053 //Function to get channel Url for a given index
       
  1054 // ---------------------------------------------------------------------------
       
  1055 //
       
  1056 EXPORT_C const TDesC& CIRIsdsPreset::GetChannelUrlAtL(TInt aIndex) const
       
  1057 	{
       
  1058 	IRLOG_DEBUG( "CIRIsdsPreset::GetChannelUrlAtL - Entering." );
       
  1059 	__ASSERT_ALWAYS( aIndex < iUrlArray->Count(), User::Leave( KErrArgument ) );
       
  1060 	IRLOG_DEBUG( "CIRIsdsPreset::GetChannelUrlAtL - Exiting." );
       
  1061 	return iUrlArray->At(aIndex)->GetServerUrl();
       
  1062 	}
       
  1063 
       
  1064 // ---------------------------------------------------------------------------
       
  1065 //CIRIsdsPreset::GetChannelBitrateL()
       
  1066 //Function to get channel Url for a given index
       
  1067 // ---------------------------------------------------------------------------
       
  1068 //
       
  1069 EXPORT_C  TInt CIRIsdsPreset::GetChannelBitrateL(TInt aIndex)
       
  1070 	{
       
  1071 	IRLOG_DEBUG( "CIRIsdsPreset::GetChannelUrlAtL - Entering." );
       
  1072 	__ASSERT_ALWAYS( aIndex < iUrlArray->Count(), User::Leave( KErrArgument ) );
       
  1073 	CDesCArrayFlat* urlForBitrate = new (ELeave) CDesCArrayFlat(KUrlForBitrateMaxLength);
       
  1074 	CleanupStack::PushL(urlForBitrate);
       
  1075 	SortInOrderL();
       
  1076 	//appending the urls with bit rate less than or
       
  1077 	//equal to given bit rate limit
       
  1078 	for(TInt loop=0;loop<iUrlArray->Count();loop++)
       
  1079 		{
       
  1080 		if(iBitrate>=iUrlArray->At(loop)->GetBitRate())
       
  1081 			{
       
  1082 			urlForBitrate->AppendL(iUrlArray->At(loop)->GetServerUrl());
       
  1083 			}
       
  1084 		}
       
  1085 	//appending	the url	with bit rate greater than given
       
  1086 	//bit rate limit
       
  1087 	for(TInt loop = (iUrlArray->Count()-1);loop >= 0;loop--)
       
  1088 		{
       
  1089 		if(iBitrate<iUrlArray->At(loop)->GetBitRate())
       
  1090 			{
       
  1091 			urlForBitrate->AppendL(iUrlArray->At(loop)->GetServerUrl());
       
  1092 			}
       
  1093 		}
       
  1094 	if ( urlForBitrate->MdcaCount()==0 && iUrlArray->Count() > 0 )
       
  1095 		{
       
  1096 		urlForBitrate->AppendL(iUrlArray->At(0)->GetServerUrl());
       
  1097 		}
       
  1098     for(TInt i=0;i<iUrlArray->Count();i++)
       
  1099 	    {
       
  1100 	    if(iUrlArray->At(i)->GetServerUrl().Compare(urlForBitrate->MdcaPoint(aIndex))==0)
       
  1101 		    {
       
  1102 		 IRRDEBUG2("CIRIsdsPreset:: - GetChannelBitrateL", KNullDesC);
       
  1103 		    CleanupStack::Pop(urlForBitrate);
       
  1104 			return iUrlArray->At(i)->GetBitRate();
       
  1105 		    }
       
  1106 	    }
       
  1107     CleanupStack::Pop(urlForBitrate);
       
  1108 	IRRDEBUG2("CIRIsdsPreset:: - GetChannelUrlAtL Exiting", KNullDesC);
       
  1109 	IRLOG_DEBUG( "CIRIsdsPreset::GetChannelUrlAtL - Exiting." );
       
  1110 	return 0;
       
  1111 	}
       
  1112 //----------------------------------------------------------------------------
       
  1113 // CIRIsdsPreset::SortInOrderL()
       
  1114 // simple bubble shot
       
  1115 // to sort the  bitrates in desc order
       
  1116 //----------------------------------------------------------------------------
       
  1117 //
       
  1118 void CIRIsdsPreset::SortInOrderL()
       
  1119 	{
       
  1120 	IRLOG_DEBUG( "CIRIsdsPreset::SortInOrderL - Exiting." );
       
  1121 	//temporary holder for pointer
       
  1122 	CIRChannelServerUrl* holdTemp = NULL;
       
  1123 	TInt urlcount = iUrlArray->Count();
       
  1124 	//sorts the array pointers [of urls] in the descending order of bit rate
       
  1125 	//bubble sort algorithm is used for this
       
  1126 	for (TInt sortcount = (urlcount - 1); sortcount >= 0; sortcount--)
       
  1127 	  	{
       
  1128 	    for (TInt index = 1; index <= sortcount; index++)
       
  1129 	    	{
       
  1130 	      	if (iUrlArray->At(index-1)->GetBitRate() <
       
  1131 	      			iUrlArray->At(index)->GetBitRate())
       
  1132 		       {
       
  1133 		       holdTemp = iUrlArray->At(index-1);
       
  1134 		       iUrlArray->At(index-1) = iUrlArray->At(index);
       
  1135 		       iUrlArray->At(index) = holdTemp;
       
  1136 		       }
       
  1137 	    	}
       
  1138 	  	}
       
  1139 	IRLOG_DEBUG( "CIRIsdsPreset::SortInOrderL - Exiting." );
       
  1140 	return;
       
  1141 	}