internetradio2.0/presetpluginsrc/irchannelserverurlimpl.cpp
changeset 0 09774dfdd46b
child 3 ee64f059b8e1
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     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 	return *iServerName;
       
   100 	}
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CIRChannelServerUrlImpl::GetServerUrl()
       
   104 // gets server url 
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 TDesC& CIRChannelServerUrlImpl::GetServerUrl()
       
   108 	{
       
   109 	return *iURL;
       
   110 	}
       
   111 	
       
   112 // ---------------------------------------------------------------------------
       
   113 // CIRChannelServerUrlImpl::GetBitRate()
       
   114 // gets server bitrate
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TInt CIRChannelServerUrlImpl::GetBitRate()
       
   118 	{
       
   119 	return iBitrate;
       
   120 	}
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl()
       
   124 // destructor 
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl()
       
   128 	{
       
   129 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl" );
       
   130 	delete iServerName;
       
   131 	delete iURL;
       
   132 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::~CIRChannelServerUrlImpl - Exiting." );
       
   133 	}
       
   134 
       
   135 	
       
   136 // ---------------------------------------------------------------------------	
       
   137 // CIRChannelServerUrlImpl::=()
       
   138 // standard C++ copy constructor(deep copy) 
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 CIRChannelServerUrlImpl& CIRChannelServerUrlImpl::operator=(
       
   142 	const CIRChannelServerUrlImpl& churl)
       
   143 	{
       
   144 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::operator=" );
       
   145 	if(&churl == this)
       
   146 		{
       
   147 		return *this;
       
   148 		}
       
   149 	iServerName=churl.iServerName;
       
   150 	iURL=churl.iURL;
       
   151 	iBitrate=churl.iBitrate;
       
   152 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::operator= - Exiting." );
       
   153 	return *this;
       
   154 	}
       
   155 	
       
   156 
       
   157 // ---------------------------------------------------------------------------	
       
   158 // CIRChannelServerUrlImpl::ExternalizeL()
       
   159 // function to externalize url data
       
   160 // ---------------------------------------------------------------------------
       
   161 //
       
   162 void CIRChannelServerUrlImpl::ExternalizeL(RWriteStream& aWriteStream)
       
   163 	{
       
   164 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::ExternalizeL" );
       
   165 	//algo
       
   166 	//1.check if data is present for the particular member variable
       
   167 	//2.if yes get the length of the data and externalize the length and then the data
       
   168 	//3.if no data is present write the length as 0.
       
   169 	TInt len;
       
   170 	if(iServerName)
       
   171 		{
       
   172 		len=iServerName->Length();
       
   173 		aWriteStream.WriteInt32L(len);
       
   174 		aWriteStream << *iServerName;
       
   175 		}
       
   176 	else
       
   177 		{
       
   178 		len=0;
       
   179 		aWriteStream.WriteInt32L(len);
       
   180 		}
       
   181 		
       
   182 	if(iURL)
       
   183 		{
       
   184 		len=iURL->Length();
       
   185 		aWriteStream.WriteInt32L(len);
       
   186 		aWriteStream << *iURL;
       
   187 		}
       
   188 	else
       
   189 		{
       
   190 		len=0;
       
   191 		aWriteStream.WriteInt32L(len);
       
   192 		}
       
   193 		
       
   194 	aWriteStream.WriteInt32L(iBitrate);
       
   195 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::ExternalizeL - Exiting." );
       
   196 	}
       
   197 
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // CIRChannelServerUrlImpl::InternalizeL()
       
   201 // function to internalize url data
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CIRChannelServerUrlImpl::InternalizeL(RReadStream& aReadStream)
       
   205 	{
       
   206 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::InternalizeL" );
       
   207 	//algo
       
   208 	//1.get the length of the data
       
   209 	//2.read that many bytes
       
   210 	//3.if read length is zero. skip..
       
   211 	TInt len;
       
   212 	len= aReadStream.ReadInt32L();
       
   213 	if(len)
       
   214 		{
       
   215 		iServerName=HBufC::NewL(aReadStream,len);	
       
   216 		}
       
   217 
       
   218 	len=aReadStream.ReadInt32L();
       
   219 	if(len)
       
   220 		{
       
   221 		iURL=HBufC::NewL(aReadStream,len);	
       
   222 		}
       
   223 	iBitrate=aReadStream.ReadInt32L();
       
   224 	IRLOG_DEBUG(  "CIRChannelServerUrlImpl::InternalizeL - Exiting." );
       
   225 	}
       
   226 	
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // CIRChannelServerUrlImpl::ConstructL()
       
   230 // standard second phase construction
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 void CIRChannelServerUrlImpl::ConstructL()
       
   234 	{
       
   235 	//no implementation
       
   236 	return;
       
   237 	}
       
   238