os/mm/mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,355 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Example implementation of RDvbhReceiver
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalComponent
    1.24 + @prototype
    1.25 +*/
    1.26 +
    1.27 +#include "dvbhreceiver.h"
    1.28 +#include "dvbhreceiverbody.h"
    1.29 +#include <in_sock.h>
    1.30 +
    1.31 +		
    1.32 +EXPORT_C RDvbhReceiver::RDvbhReceiver()
    1.33 +: iBody(NULL) //Not a C-class so no free initialisation
    1.34 +	{
    1.35 +	}	
    1.36 +	
    1.37 +EXPORT_C TInt RDvbhReceiver::GetSupportedReceiverTypes( RArray<TDvbhReceiverType>& aReceiverTypes )
    1.38 +    {
    1.39 +	//RBody::GetSupportedReceiverTypes is static.
    1.40 +	return RBody::GetSupportedReceiverTypes(aReceiverTypes);
    1.41 +    }
    1.42 +
    1.43 +EXPORT_C TInt RDvbhReceiver::GetDriverVersion( TVersion& aVersion )
    1.44 +	{
    1.45 +	//RBody::GetDriverVersion is static.
    1.46 +	return RBody::GetDriverVersion(aVersion);
    1.47 +	}	
    1.48 +	
    1.49 +EXPORT_C TInt RDvbhReceiver::Open( const TDvbhReceiverType aReceiverType )
    1.50 +	{
    1.51 +	//Delegate to OpenL
    1.52 +	TRAPD(err, OpenL( aReceiverType ));
    1.53 +	return err;
    1.54 +	}	
    1.55 +
    1.56 +EXPORT_C void RDvbhReceiver::Close()
    1.57 +	{
    1.58 +	if (iBody != NULL)
    1.59 +		{
    1.60 +		iBody->Close();
    1.61 +		delete iBody;
    1.62 +		iBody = NULL;
    1.63 +		}
    1.64 +	else
    1.65 +		{
    1.66 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
    1.67 +		}
    1.68 +	}	
    1.69 +
    1.70 +EXPORT_C TInt RDvbhReceiver::PowerOn( TRequestStatus& aStatus )
    1.71 +    {
    1.72 +    if (iBody != NULL)
    1.73 +        {
    1.74 +        return iBody->PowerOn(aStatus);
    1.75 +        }
    1.76 +    else
    1.77 +        {
    1.78 +        return KErrNotReady;
    1.79 +        }
    1.80 +    }   
    1.81 +
    1.82 +EXPORT_C void RDvbhReceiver::CancelPowerOn()
    1.83 +    {
    1.84 +    if (iBody != NULL)
    1.85 +        {
    1.86 +        return iBody->CancelPowerOn();
    1.87 +        }
    1.88 +    else
    1.89 +        {
    1.90 +        ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.
    1.91 +        }
    1.92 +    }   
    1.93 +
    1.94 +EXPORT_C void RDvbhReceiver::PowerOff( TRequestStatus& aStatus )
    1.95 +    {
    1.96 +	if (iBody != NULL)
    1.97 +		{
    1.98 +		iBody->PowerOff(aStatus);
    1.99 +		}
   1.100 +	else
   1.101 +		{
   1.102 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.103 +		}
   1.104 +    }
   1.105 +
   1.106 +EXPORT_C void RDvbhReceiver::CancelPowerOff()
   1.107 +    {
   1.108 +	if (iBody != NULL)
   1.109 +		{
   1.110 +		iBody->CancelPowerOff();
   1.111 +		}
   1.112 +	else
   1.113 +		{
   1.114 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.115 +		}
   1.116 +    }
   1.117 +
   1.118 +EXPORT_C void RDvbhReceiver::SetDisabled( TBool aDisable, TRequestStatus& aStatus )
   1.119 +	{
   1.120 +	if (iBody != NULL)
   1.121 +		{	
   1.122 +		iBody->SetDisabled(aDisable, aStatus);
   1.123 +		}
   1.124 +	else
   1.125 +		{
   1.126 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.127 +		}
   1.128 +	}	
   1.129 +
   1.130 +EXPORT_C void RDvbhReceiver::CancelSetDisabled()
   1.131 +	{
   1.132 +	if (iBody != NULL)
   1.133 +		{	
   1.134 +		iBody->CancelSetDisabled();
   1.135 +		}
   1.136 +	else
   1.137 +		{
   1.138 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.139 +		}
   1.140 +	}	
   1.141 +
   1.142 +EXPORT_C TInt RDvbhReceiver::SetScanConfiguration( const TDvbhScanConfiguration& aScanConfiguration )
   1.143 +	{
   1.144 +	if (iBody != NULL)
   1.145 +		{
   1.146 +		return iBody->SetScanConfiguration(aScanConfiguration);
   1.147 +		}
   1.148 +	else
   1.149 +		{
   1.150 +		return KErrNotReady;
   1.151 +		}
   1.152 +	}	
   1.153 +
   1.154 +EXPORT_C TInt RDvbhReceiver::GetScanConfiguration( TDvbhScanConfiguration& aScanConfiguration )
   1.155 +	{
   1.156 +	if (iBody != NULL)
   1.157 +		{
   1.158 +		return iBody->GetScanConfiguration(aScanConfiguration);
   1.159 +		}
   1.160 +	else
   1.161 +		{
   1.162 +		return KErrNotReady;
   1.163 +		}
   1.164 +	}	
   1.165 +
   1.166 +EXPORT_C TInt RDvbhReceiver::GetDvbhVersion( TVersion& aVersion )
   1.167 +	{
   1.168 +	if (iBody != NULL)
   1.169 +		{
   1.170 +		return iBody->GetDvbhVersion(aVersion);
   1.171 +		}
   1.172 +	else
   1.173 +		{
   1.174 +		return KErrNotReady;
   1.175 +		}
   1.176 +	}	
   1.177 +
   1.178 +EXPORT_C TInt RDvbhReceiver::GetHardwareInfo( TDvbhHardwareInfo& aHardwareInfo )
   1.179 +	{
   1.180 +	if (iBody != NULL)
   1.181 +		{
   1.182 +		return iBody->GetHardwareInfo(aHardwareInfo);
   1.183 +		}
   1.184 +	else
   1.185 +		{
   1.186 +		return KErrNotReady;
   1.187 +		}
   1.188 +	}	
   1.189 +
   1.190 +EXPORT_C TInt RDvbhReceiver::Scan( MDvbhScanObserver& aObserver, TRequestStatus& aStatus )
   1.191 +	{
   1.192 +	if (iBody != NULL)
   1.193 +		{
   1.194 +		return iBody->Scan(aObserver, aStatus);
   1.195 +		}
   1.196 +	else
   1.197 +		{
   1.198 +		return KErrNotReady;
   1.199 +		}
   1.200 +	}	
   1.201 +
   1.202 +EXPORT_C void RDvbhReceiver::CancelScan()
   1.203 +	{
   1.204 +	if (iBody != NULL)
   1.205 +		{	
   1.206 +		iBody->CancelScan();
   1.207 +		}
   1.208 +	else
   1.209 +		{
   1.210 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.211 +		}
   1.212 +	}	
   1.213 +
   1.214 +EXPORT_C TInt RDvbhReceiver::SetPlatform( const TDvbhNetwork& aNetwork, const TDvbhPlatform& aPlatform, TRequestStatus& aStatus )
   1.215 +	{
   1.216 +	if (iBody != NULL)
   1.217 +		{
   1.218 +		return iBody->SetPlatform(aNetwork, aPlatform, aStatus);
   1.219 +		}
   1.220 +	else
   1.221 +		{
   1.222 +		return KErrNotReady;
   1.223 +		}
   1.224 +	}	
   1.225 +
   1.226 +EXPORT_C void RDvbhReceiver::CancelSetPlatform()
   1.227 +	{
   1.228 +	if (iBody != NULL)
   1.229 +		{	
   1.230 +		iBody->CancelSetPlatform();
   1.231 +		}
   1.232 +	else
   1.233 +		{
   1.234 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.235 +		}
   1.236 +	}	
   1.237 +
   1.238 +EXPORT_C TInt RDvbhReceiver::CreateFilter( const TIp6Addr& aDestAddress, TInt& aFilterId, TRequestStatus& aStatus )
   1.239 +	{
   1.240 +	if (iBody != NULL)
   1.241 +		{
   1.242 +		return iBody->CreateFilter(aDestAddress, aFilterId, aStatus);
   1.243 +		}
   1.244 +	else
   1.245 +		{
   1.246 +		return KErrNotReady;
   1.247 +		}	
   1.248 +	}	
   1.249 +
   1.250 +EXPORT_C TInt RDvbhReceiver::CancelFilter( TInt aFilterId )
   1.251 +	{
   1.252 +	if (iBody != NULL)
   1.253 +		{
   1.254 +		return iBody->CancelFilter(aFilterId);
   1.255 +		}
   1.256 +	else
   1.257 +		{
   1.258 +		return KErrNotReady;
   1.259 +		}
   1.260 +	}	
   1.261 +
   1.262 +EXPORT_C TInt RDvbhReceiver::ReceiveIPData( MDvbhDataObserver& aObserver )
   1.263 +	{
   1.264 +	if (iBody != NULL)
   1.265 +		{
   1.266 +		return iBody->ReceiveIPData(aObserver);
   1.267 +		}
   1.268 +	else
   1.269 +		{
   1.270 +		return KErrNotReady;
   1.271 +		}
   1.272 +	}	
   1.273 +
   1.274 +EXPORT_C void RDvbhReceiver::CancelReceiveIPData()
   1.275 +	{
   1.276 +	if (iBody != NULL)
   1.277 +		{	
   1.278 +		iBody->CancelReceiveIPData();
   1.279 +		}
   1.280 +	else
   1.281 +		{
   1.282 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.283 +		}
   1.284 +	}	
   1.285 +
   1.286 +EXPORT_C TInt RDvbhReceiver::UpdateNetworkTime( TRequestStatus& aStatus )
   1.287 +	{
   1.288 +	if (iBody != NULL)
   1.289 +		{
   1.290 +		return iBody->UpdateNetworkTime(aStatus);
   1.291 +		}
   1.292 +	else
   1.293 +		{
   1.294 +		return KErrNotReady;
   1.295 +		}
   1.296 +	}	
   1.297 +
   1.298 +EXPORT_C void RDvbhReceiver::CancelUpdateNetworkTime()
   1.299 +	{
   1.300 +	if (iBody != NULL)
   1.301 +		{	
   1.302 +		iBody->CancelUpdateNetworkTime();
   1.303 +		}
   1.304 +	else
   1.305 +		{
   1.306 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.307 +		}
   1.308 +	}	
   1.309 +
   1.310 +EXPORT_C TInt RDvbhReceiver::CustomCommand(
   1.311 +            TInt aCommand,
   1.312 +            const TDesC8& aInputData,
   1.313 +            TDes8& aOutputBuffer,
   1.314 +            TRequestStatus& aStatus )
   1.315 +	{
   1.316 +	if (iBody != NULL)
   1.317 +		{
   1.318 +		return iBody->CustomCommand(aCommand, aInputData, aOutputBuffer, aStatus);
   1.319 +		}
   1.320 +	else
   1.321 +		{
   1.322 +		return KErrNotReady;
   1.323 +		}
   1.324 +	}	
   1.325 +
   1.326 +EXPORT_C void RDvbhReceiver::CancelCustomCommand( TRequestStatus& aStatus )
   1.327 +	{
   1.328 +	if (iBody != NULL)
   1.329 +		{	
   1.330 +		iBody->CancelCustomCommand(aStatus);
   1.331 +		}
   1.332 +	else
   1.333 +		{
   1.334 +		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
   1.335 +		}
   1.336 +	}	
   1.337 +
   1.338 +EXPORT_C TInt RDvbhReceiver::CustomCommand( TInt aCommand, const TDesC8& aInputData )
   1.339 +	{
   1.340 +	if (iBody != NULL)
   1.341 +		{
   1.342 +		return iBody->CustomCommand(aCommand, aInputData);
   1.343 +		}
   1.344 +	else
   1.345 +		{
   1.346 +		return KErrNotReady;
   1.347 +		}
   1.348 +	}
   1.349 +	
   1.350 +void RDvbhReceiver::OpenL( const TDvbhReceiverType aReceiverType )
   1.351 +	{
   1.352 +	if (iBody == NULL)
   1.353 +		{
   1.354 +		iBody = new (ELeave) RBody;
   1.355 +		}
   1.356 +	User::LeaveIfError(iBody->Open( aReceiverType ));
   1.357 +	}
   1.358 +