internetradio2.0/presetpluginsrc/irchannelserverurlimpl.cpp
changeset 8 3b03c28289e6
parent 5 0930554dc389
child 10 9b7c1f7fc4a6
child 11 f683e24efca3
equal deleted inserted replaced
5:0930554dc389 8:3b03c28289e6
     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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32strm.h>
       
    20 
       
    21 #include "irchannelserverurlimpl.h"
       
    22 #include "irdebug.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CIRChannelServerUrlImpl::NewL()
       
    28 // Static function
       
    29 // standard two phased constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CIRChannelServerUrlImpl* CIRChannelServerUrlImpl::NewL()
       
    33 	{
       
    34 	IRLOG_DEBUG( "CIRChannelServerUrlImpl::NewL" );
       
    35 	CIRChannelServerUrlImpl* self=CIRChannelServerUrlImpl::NewLC();
       
    36 	CleanupStack::Pop(self);
       
    37 	IRLOG_DEBUG( "CIRChannelServerUrlImpl::NewL - Exiting." );
       
    38 	return self;
       
    39 	}
       
    40 	
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CIRChannelServerUrlImpl::NewLC()
       
    44 // Static function
       
    45 // standard two phased constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CIRChannelServerUrlImpl* CIRChannelServerUrlImpl::NewLC()
       
    49 	{
       
    50 	IRLOG_DEBUG( "CIRChannelServerUrlImpl::NewLC" );
       
    51 	CIRChannelServerUrlImpl* self=new(ELeave)CIRChannelServerUrlImpl;
       
    52 	CleanupStack::PushL(self);
       
    53 	self->ConstructL();
       
    54 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::NewLC - Exiting." );
       
    55 	return self;
       
    56 	}
       
    57 	
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CIRChannelServerUrlImpl::SetServerName()
       
    61 // sets server name 
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void CIRChannelServerUrlImpl::SetServerName(const TDesC& aServerName)
       
    65 	{
       
    66 	iServerName=aServerName.Alloc();
       
    67 	}
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CIRChannelServerUrlImpl::SetServerUrl()
       
    72 // sets server url 
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void CIRChannelServerUrlImpl::SetServerUrl(const TDesC& aServerUrl)
       
    76 	{
       
    77 	iURL=aServerUrl.Alloc();
       
    78 	}
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------	
       
    82 // CIRChannelServerUrlImpl::SetBitRate()
       
    83 // sets server bitrate 
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CIRChannelServerUrlImpl::SetBitRate(TInt aBitrate)
       
    87 	{
       
    88 	iBitrate=aBitrate;
       
    89 	}
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------------------------	
       
    93 // CIRChannelServerUrlImpl::GetServerName()
       
    94 // gets server name 
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 TDesC& CIRChannelServerUrlImpl::GetServerName()
       
    98 	{
       
    99     if( NULL == iServerName )
       
   100     {
       
   101         iServerName = HBufC::New(0);
       
   102     }
       
   103     
       
   104 	return *iServerName;
       
   105 	}
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CIRChannelServerUrlImpl::GetServerUrl()
       
   109 // gets server url 
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 TDesC& CIRChannelServerUrlImpl::GetServerUrl()
       
   113 	{
       
   114     if( NULL == iURL )
       
   115     {
       
   116         iURL = HBufC::New(0);
       
   117     }
       
   118 	return *iURL;
       
   119 	}
       
   120 	
       
   121 // ---------------------------------------------------------------------------
       
   122 // CIRChannelServerUrlImpl::GetBitRate()
       
   123 // gets server bitrate
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TInt CIRChannelServerUrlImpl::GetBitRate()
       
   127 	{
       
   128 	return iBitrate;
       
   129 	}
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl()
       
   133 // destructor 
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl()
       
   137 	{
       
   138 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl" );
       
   139 	delete iServerName;
       
   140 	delete iURL;
       
   141 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl - Exiting." );
       
   142 	}
       
   143 
       
   144 	
       
   145 // ---------------------------------------------------------------------------	
       
   146 // CIRChannelServerUrlImpl::=()
       
   147 // standard C++ copy constructor(deep copy) 
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 CIRChannelServerUrlImpl& CIRChannelServerUrlImpl::operator=(
       
   151 	const CIRChannelServerUrlImpl& churl)
       
   152 	{
       
   153 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::operator=" );
       
   154 	if(&churl == this)
       
   155 		{
       
   156 		return *this;
       
   157 		}
       
   158 	iServerName=churl.iServerName;
       
   159 	iURL=churl.iURL;
       
   160 	iBitrate=churl.iBitrate;
       
   161 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::operator= - Exiting." );
       
   162 	return *this;
       
   163 	}
       
   164 	
       
   165 
       
   166 // ---------------------------------------------------------------------------	
       
   167 // CIRChannelServerUrlImpl::ExternalizeL()
       
   168 // function to externalize url data
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void CIRChannelServerUrlImpl::ExternalizeL(RWriteStream& aWriteStream)
       
   172 	{
       
   173 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::ExternalizeL" );
       
   174 	//algo
       
   175 	//1.check if data is present for the particular member variable
       
   176 	//2.if yes get the length of the data and externalize the length and then the data
       
   177 	//3.if no data is present write the length as 0.
       
   178 	TInt len;
       
   179 	if(iServerName)
       
   180 		{
       
   181 		len=iServerName->Length();
       
   182 		aWriteStream.WriteInt32L(len);
       
   183 		aWriteStream << *iServerName;
       
   184 		}
       
   185 	else
       
   186 		{
       
   187 		len=0;
       
   188 		aWriteStream.WriteInt32L(len);
       
   189 		}
       
   190 		
       
   191 	if(iURL)
       
   192 		{
       
   193 		len=iURL->Length();
       
   194 		aWriteStream.WriteInt32L(len);
       
   195 		aWriteStream << *iURL;
       
   196 		}
       
   197 	else
       
   198 		{
       
   199 		len=0;
       
   200 		aWriteStream.WriteInt32L(len);
       
   201 		}
       
   202 		
       
   203 	aWriteStream.WriteInt32L(iBitrate);
       
   204 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::ExternalizeL - Exiting." );
       
   205 	}
       
   206 
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CIRChannelServerUrlImpl::InternalizeL()
       
   210 // function to internalize url data
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CIRChannelServerUrlImpl::InternalizeL(RReadStream& aReadStream)
       
   214 	{
       
   215 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::InternalizeL" );
       
   216 	//algo
       
   217 	//1.get the length of the data
       
   218 	//2.read that many bytes
       
   219 	//3.if read length is zero. skip..
       
   220 	TInt len;
       
   221 	len= aReadStream.ReadInt32L();
       
   222 	if(len)
       
   223 		{
       
   224 		iServerName=HBufC::NewL(aReadStream,len);	
       
   225 		}
       
   226 
       
   227 	len=aReadStream.ReadInt32L();
       
   228 	if(len)
       
   229 		{
       
   230 		iURL=HBufC::NewL(aReadStream,len);	
       
   231 		}
       
   232 	iBitrate=aReadStream.ReadInt32L();
       
   233 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::InternalizeL - Exiting." );
       
   234 	}
       
   235 	
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // CIRChannelServerUrlImpl::ConstructL()
       
   239 // standard second phase construction
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 void CIRChannelServerUrlImpl::ConstructL()
       
   243 	{
       
   244 	//no implementation
       
   245 	return;
       
   246 	}
       
   247