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