internetradio2.0/ircommon/src/irbrowsechannelitems.cpp
changeset 14 896e9dbc5f19
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
       
     1 /*
       
     2 * Copyright (c) 2006-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 #include <s32strm.h>
       
    19 
       
    20 #include "irbrowsechannelitems.h"
       
    21 #include "irdebug.h"
       
    22 
       
    23 // ======== LOCAL FUNCTIONS ========
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // CIRBrowseChannelItems::NewLC()
       
    29 // Static function
       
    30 // standard two phased constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //    
       
    33 EXPORT_C CIRBrowseChannelItems* CIRBrowseChannelItems::NewLC()
       
    34     {
       
    35     IRLOG_DEBUG( "CIRBrowseChannelItems::NewLC - Entering" );
       
    36     CIRBrowseChannelItems* self = new( ELeave )CIRBrowseChannelItems;
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     IRLOG_DEBUG( "CIRBrowseChannelItems::NewLC - Exiting." );
       
    40     return self;
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CIRBrowseChannelItems::NewL()
       
    46 // Static function
       
    47 // standard two phased constructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CIRBrowseChannelItems* CIRBrowseChannelItems::NewL()
       
    51     {
       
    52     IRLOG_DEBUG( "CIRBrowseChannelItems::NewL - Entering" );
       
    53     CIRBrowseChannelItems* self = CIRBrowseChannelItems::NewLC();
       
    54     CleanupStack::Pop( self );
       
    55     IRLOG_DEBUG( "CIRBrowseChannelItems::NewL - Exiting." );
       
    56     return self;
       
    57     }
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CIRBrowseChannelItems::ConstructL()
       
    62 // standard two phased constructor
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65  void CIRBrowseChannelItems::ConstructL() const
       
    66     {
       
    67     IRLOG_DEBUG( "CIRBrowseChannelItems::ConstructL" );
       
    68     return;
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CIRBrowseChannelItems::~CIRBrowseChannelItems()
       
    74 // standard C++ destructor
       
    75 // ---------------------------------------------------------------------------
       
    76 //    
       
    77  CIRBrowseChannelItems::~CIRBrowseChannelItems()
       
    78     {
       
    79     IRLOG_DEBUG( "CIRBrowseChannelItems::~CIRBrowseChannelItems - Entering" );
       
    80     delete iChannelName;
       
    81     iChannelName = NULL;
       
    82     delete iChannelGetOperation;
       
    83     iChannelGetOperation = NULL;
       
    84     delete iShortDescription;
       
    85     iShortDescription = NULL;
       
    86     iImgUrl.Close();
       
    87     
       
    88     delete iBannerUrl;
       
    89     iBannerUrl = NULL;
       
    90     delete iClickThroughUrl;
       
    91     iClickThroughUrl = NULL;
       
    92 
       
    93     IRLOG_DEBUG( "CIRBrowseChannelItems::~CIRBrowseChannelItems - Exiting." );
       
    94     }
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CIRBrowseChannelItems::SetTextL()
       
    99 // Set data namely channelname,channelid,description
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C void CIRBrowseChannelItems::SetTextL( const TDesC& aChannelName, 
       
   103     const TDesC& aChannelId, const TDesC& aDescription )
       
   104     {
       
   105     IRLOG_DEBUG( "CIRBrowseChannelItems::SetTextL - Entering" );
       
   106     iChannelName = aChannelName.Alloc();
       
   107     iShortDescription = aDescription.Alloc();    
       
   108     TLex var( aChannelId );
       
   109     var.Val( iChannelID );
       
   110     IRLOG_DEBUG( "CIRBrowseChannelItems::SetTextL - Exiting." );
       
   111     }
       
   112     
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CIRBrowseChannelItems::SetGetOperationL()
       
   116 // Set data get methord
       
   117 // ---------------------------------------------------------------------------
       
   118 //    
       
   119 EXPORT_C void CIRBrowseChannelItems::SetGetOperationL( 
       
   120     const TDesC& aChannelGetOperation )
       
   121     {
       
   122     IRLOG_DEBUG( "CIRBrowseChannelItems::SetGetOperationL - Entering" );
       
   123     iChannelGetOperation = aChannelGetOperation.Alloc();
       
   124     IRLOG_DEBUG( "CIRBrowseChannelItems::SetGetOperationL - Exiting." );
       
   125     }
       
   126 
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CIRBrowseChannelItems::SetSize()
       
   130 // Set data size of data
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C void CIRBrowseChannelItems::SetSize( const TDesC& aSize )
       
   134     {
       
   135     IRLOG_DEBUG( "CIRBrowseChannelItems::SetSize - Entering" );
       
   136     TLex var( aSize );
       
   137     var.Val( iSize );
       
   138     IRLOG_DEBUG( "CIRBrowseChannelItems::SetSize - Exiting." );
       
   139     }
       
   140 
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // CIRBrowseChannelItems::SetImageUrlL()
       
   144 // Set the url for the iImgUrl
       
   145 // ---------------------------------------------------------------------------
       
   146 //    
       
   147 EXPORT_C void CIRBrowseChannelItems::SetImageUrlL( const TDesC& aImgUrl )
       
   148     {
       
   149     IRLOG_DEBUG( "CIRBrowseChannelItems::SetImageUrlL - Entering" );
       
   150     iImgUrl.CreateL( aImgUrl.Length() );
       
   151     iImgUrl.Copy( aImgUrl );
       
   152     IRLOG_DEBUG( "CIRBrowseChannelItems::SetImageUrlL - Exiting." );
       
   153     }
       
   154     
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CIRBrowseChannelItems::ExternalizeL()
       
   158 // Externalizes data into persistent storage
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 EXPORT_C void CIRBrowseChannelItems::ExternalizeL( RWriteStream& aStream ) const
       
   162     {
       
   163     IRLOG_DEBUG( "CIRBrowseChannelItems::ExternalizeL - Entering" );
       
   164     if ( iChannelName )
       
   165         {
       
   166         aStream.WriteInt32L( iChannelName->Des().MaxLength() );
       
   167         aStream << *iChannelName;
       
   168         }
       
   169     else 
       
   170         {
       
   171         aStream.WriteInt32L (0 );
       
   172         }
       
   173     
       
   174     if ( ( iShortDescription ) && ( iShortDescription->Des().MaxLength() != 0 ) )
       
   175         {    
       
   176         TInt a = iShortDescription->Des().MaxLength();
       
   177         aStream.WriteInt32L( iShortDescription->Des().MaxLength() );
       
   178         aStream << *iShortDescription;
       
   179         }
       
   180     else
       
   181         {
       
   182         aStream.WriteInt32L( 0 );
       
   183         }
       
   184     
       
   185     if ( iChannelGetOperation )
       
   186         {
       
   187         aStream.WriteInt32L( iChannelGetOperation->Des().MaxLength() );
       
   188         aStream << *iChannelGetOperation;
       
   189         }
       
   190     else
       
   191         {
       
   192         aStream.WriteInt32L( 0 );
       
   193         }
       
   194     
       
   195     aStream.WriteInt32L( iBitrate1 );
       
   196     aStream.WriteInt32L( iBitrate2 );
       
   197     aStream.WriteInt32L( iBitrate3 );
       
   198     aStream.WriteUint32L( iChannelID );
       
   199     if ( iBannerUrl )
       
   200         {
       
   201         aStream.WriteInt32L( iBannerUrl->Des().MaxLength() );
       
   202         aStream << *iBannerUrl;
       
   203         }
       
   204     else
       
   205         {
       
   206         aStream.WriteInt32L( 0 );
       
   207         }
       
   208     
       
   209     if ( iClickThroughUrl )    
       
   210         {
       
   211         aStream.WriteInt32L( iClickThroughUrl->Des().MaxLength() );
       
   212         aStream << *iClickThroughUrl;
       
   213         }
       
   214     else
       
   215         {
       
   216         aStream.WriteInt32L( 0 );
       
   217         }
       
   218         
       
   219     if ( iImgUrl.Length() != 0 )
       
   220         {
       
   221         aStream.WriteInt32L( iImgUrl.MaxLength() );
       
   222         aStream << iImgUrl;
       
   223         }
       
   224     else
       
   225         {
       
   226         aStream.WriteInt32L( 0 );    
       
   227         }
       
   228 
       
   229     IRLOG_DEBUG( "CIRBrowseChannelItems::ExternalizeL - Exiting." );
       
   230     }  
       
   231 
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CIRBrowseChannelItems::InternalizeL()
       
   235 // internalizes data from persistent storage
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void CIRBrowseChannelItems::InternalizeL( RReadStream& aStream )
       
   239     {
       
   240     IRLOG_DEBUG( "CIRBrowseChannelItems::InternalizeL - Entering" );
       
   241     TInt maxlen;
       
   242     maxlen = aStream.ReadInt32L();
       
   243     if ( maxlen != 0 )
       
   244         {
       
   245         iChannelName = HBufC::NewL( aStream,maxlen );
       
   246         }
       
   247     
       
   248     maxlen = aStream.ReadInt32L();
       
   249     if ( maxlen != 0 )
       
   250         {
       
   251         iShortDescription = HBufC::NewL( aStream,maxlen );
       
   252         }
       
   253     
       
   254     maxlen = aStream.ReadInt32L();
       
   255     if ( maxlen != 0 )
       
   256         {
       
   257         iChannelGetOperation = HBufC::NewL( aStream,maxlen );
       
   258         }
       
   259     iBitrate1 = aStream.ReadInt32L();
       
   260     iBitrate2 = aStream.ReadInt32L();
       
   261     iBitrate3 = aStream.ReadInt32L();
       
   262     iChannelID = aStream.ReadUint32L();
       
   263     
       
   264     maxlen = aStream.ReadInt32L();
       
   265     if ( maxlen != 0 )
       
   266         {
       
   267         iBannerUrl = HBufC::NewL( aStream, maxlen );
       
   268         }
       
   269     
       
   270     maxlen = aStream.ReadInt32L();
       
   271     if ( maxlen != 0 )
       
   272         {
       
   273         iClickThroughUrl = HBufC::NewL( aStream, maxlen );
       
   274         }
       
   275     
       
   276     maxlen = aStream.ReadInt32L();
       
   277     if ( maxlen != 0 )
       
   278         {
       
   279         iImgUrl.Close();
       
   280         iImgUrl.CreateL( aStream, maxlen );            
       
   281         }
       
   282     
       
   283     IRLOG_DEBUG( "CIRBrowseChannelItems::InternalizeL - Exiting." );
       
   284     }  
       
   285     
       
   286 
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CIRBrowseChannelItems::SetBitrate()
       
   290 // Set data for 3bitrates
       
   291 // ---------------------------------------------------------------------------
       
   292 //
       
   293 EXPORT_C void CIRBrowseChannelItems::SetBitrate( const TDesC& aBitrate1, 
       
   294     const TDesC& aBitrate2, const TDesC& aBitrate3 )
       
   295     {
       
   296     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBitrate3 - Entering" );
       
   297     TLex var1( aBitrate1 );
       
   298     var1.Val( iBitrate1 );
       
   299     TLex var2( aBitrate2 );
       
   300     var2.Val( iBitrate2 );
       
   301     TLex var3( aBitrate3 );
       
   302     var3.Val( iBitrate3 );    
       
   303     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBitrate3 - Exiting." );
       
   304     }
       
   305     
       
   306 
       
   307 // ---------------------------------------------------------------------------
       
   308 // CIRBrowseChannelItems::SetBitrate()
       
   309 // Set data for 2 bitrates
       
   310 // ---------------------------------------------------------------------------
       
   311 //
       
   312 EXPORT_C void CIRBrowseChannelItems::SetBitrate( const TDesC& aBitrate1, 
       
   313     const TDesC& aBitrate2)
       
   314     {
       
   315     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBitrate2 - Entering" );
       
   316     TLex var1( aBitrate1 );
       
   317     var1.Val( iBitrate1 );
       
   318     TLex var2( aBitrate2 );
       
   319     var2.Val( iBitrate2 );
       
   320     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBitrate2 - Exiting." );
       
   321     }
       
   322     
       
   323 
       
   324 // ---------------------------------------------------------------------------
       
   325 // CIRBrowseChannelItems::SetBitrate()
       
   326 // Set data for 1 bitrate
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 EXPORT_C void CIRBrowseChannelItems::SetBitrate( const TDesC& aBitrate1 )
       
   330     {
       
   331     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBitrate1 - Entering" );
       
   332     TLex var1( aBitrate1 );
       
   333     var1.Val( iBitrate1 );    
       
   334     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBitrate1 - Exiting." );
       
   335     }
       
   336 
       
   337 // ---------------------------------------------------------------------------
       
   338 // CIRBrowseChannelItems::SetBannerUrl()
       
   339 // Set data namely BannerUrl
       
   340 // ---------------------------------------------------------------------------
       
   341 //
       
   342 EXPORT_C void CIRBrowseChannelItems::SetBannerUrl( const TDesC& aBannerUrl )
       
   343     {
       
   344     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBannerUrl - Entering" );
       
   345     iBannerUrl = aBannerUrl.Alloc();
       
   346     IRLOG_DEBUG( "CIRBrowseChannelItems::SetBannerUrl - Exiting." );
       
   347     }
       
   348     
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CIRBrowseChannelItems::SetBannerUrl()
       
   352 // Set data namely BannerUrl
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 EXPORT_C void CIRBrowseChannelItems::SetClickThroughUrl( const TDesC& aClickThroughUrl )
       
   356     {
       
   357     IRLOG_DEBUG( "CIRBrowseChannelItems::SetClickThroughUrl - Entering" );
       
   358     iClickThroughUrl = aClickThroughUrl.Alloc();
       
   359     IRLOG_DEBUG( "CIRBrowseChannelItems::SetClickThroughUrl - Exiting." );
       
   360     }