mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiver.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Example implementation of RDvbhReceiver
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @prototype
       
    22 */
       
    23 
       
    24 #include "dvbhreceiver.h"
       
    25 #include "dvbhreceiverbody.h"
       
    26 #include <in_sock.h>
       
    27 
       
    28 		
       
    29 EXPORT_C RDvbhReceiver::RDvbhReceiver()
       
    30 : iBody(NULL) //Not a C-class so no free initialisation
       
    31 	{
       
    32 	}	
       
    33 	
       
    34 EXPORT_C TInt RDvbhReceiver::GetSupportedReceiverTypes( RArray<TDvbhReceiverType>& aReceiverTypes )
       
    35     {
       
    36 	//RBody::GetSupportedReceiverTypes is static.
       
    37 	return RBody::GetSupportedReceiverTypes(aReceiverTypes);
       
    38     }
       
    39 
       
    40 EXPORT_C TInt RDvbhReceiver::GetDriverVersion( TVersion& aVersion )
       
    41 	{
       
    42 	//RBody::GetDriverVersion is static.
       
    43 	return RBody::GetDriverVersion(aVersion);
       
    44 	}	
       
    45 	
       
    46 EXPORT_C TInt RDvbhReceiver::Open( const TDvbhReceiverType aReceiverType )
       
    47 	{
       
    48 	//Delegate to OpenL
       
    49 	TRAPD(err, OpenL( aReceiverType ));
       
    50 	return err;
       
    51 	}	
       
    52 
       
    53 EXPORT_C void RDvbhReceiver::Close()
       
    54 	{
       
    55 	if (iBody != NULL)
       
    56 		{
       
    57 		iBody->Close();
       
    58 		delete iBody;
       
    59 		iBody = NULL;
       
    60 		}
       
    61 	else
       
    62 		{
       
    63 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
    64 		}
       
    65 	}	
       
    66 
       
    67 EXPORT_C TInt RDvbhReceiver::PowerOn( TRequestStatus& aStatus )
       
    68     {
       
    69     if (iBody != NULL)
       
    70         {
       
    71         return iBody->PowerOn(aStatus);
       
    72         }
       
    73     else
       
    74         {
       
    75         return KErrNotReady;
       
    76         }
       
    77     }   
       
    78 
       
    79 EXPORT_C void RDvbhReceiver::CancelPowerOn()
       
    80     {
       
    81     if (iBody != NULL)
       
    82         {
       
    83         return iBody->CancelPowerOn();
       
    84         }
       
    85     else
       
    86         {
       
    87         ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.
       
    88         }
       
    89     }   
       
    90 
       
    91 EXPORT_C void RDvbhReceiver::PowerOff( TRequestStatus& aStatus )
       
    92     {
       
    93 	if (iBody != NULL)
       
    94 		{
       
    95 		iBody->PowerOff(aStatus);
       
    96 		}
       
    97 	else
       
    98 		{
       
    99 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   100 		}
       
   101     }
       
   102 
       
   103 EXPORT_C void RDvbhReceiver::CancelPowerOff()
       
   104     {
       
   105 	if (iBody != NULL)
       
   106 		{
       
   107 		iBody->CancelPowerOff();
       
   108 		}
       
   109 	else
       
   110 		{
       
   111 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   112 		}
       
   113     }
       
   114 
       
   115 EXPORT_C void RDvbhReceiver::SetDisabled( TBool aDisable, TRequestStatus& aStatus )
       
   116 	{
       
   117 	if (iBody != NULL)
       
   118 		{	
       
   119 		iBody->SetDisabled(aDisable, aStatus);
       
   120 		}
       
   121 	else
       
   122 		{
       
   123 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   124 		}
       
   125 	}	
       
   126 
       
   127 EXPORT_C void RDvbhReceiver::CancelSetDisabled()
       
   128 	{
       
   129 	if (iBody != NULL)
       
   130 		{	
       
   131 		iBody->CancelSetDisabled();
       
   132 		}
       
   133 	else
       
   134 		{
       
   135 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   136 		}
       
   137 	}	
       
   138 
       
   139 EXPORT_C TInt RDvbhReceiver::SetScanConfiguration( const TDvbhScanConfiguration& aScanConfiguration )
       
   140 	{
       
   141 	if (iBody != NULL)
       
   142 		{
       
   143 		return iBody->SetScanConfiguration(aScanConfiguration);
       
   144 		}
       
   145 	else
       
   146 		{
       
   147 		return KErrNotReady;
       
   148 		}
       
   149 	}	
       
   150 
       
   151 EXPORT_C TInt RDvbhReceiver::GetScanConfiguration( TDvbhScanConfiguration& aScanConfiguration )
       
   152 	{
       
   153 	if (iBody != NULL)
       
   154 		{
       
   155 		return iBody->GetScanConfiguration(aScanConfiguration);
       
   156 		}
       
   157 	else
       
   158 		{
       
   159 		return KErrNotReady;
       
   160 		}
       
   161 	}	
       
   162 
       
   163 EXPORT_C TInt RDvbhReceiver::GetDvbhVersion( TVersion& aVersion )
       
   164 	{
       
   165 	if (iBody != NULL)
       
   166 		{
       
   167 		return iBody->GetDvbhVersion(aVersion);
       
   168 		}
       
   169 	else
       
   170 		{
       
   171 		return KErrNotReady;
       
   172 		}
       
   173 	}	
       
   174 
       
   175 EXPORT_C TInt RDvbhReceiver::GetHardwareInfo( TDvbhHardwareInfo& aHardwareInfo )
       
   176 	{
       
   177 	if (iBody != NULL)
       
   178 		{
       
   179 		return iBody->GetHardwareInfo(aHardwareInfo);
       
   180 		}
       
   181 	else
       
   182 		{
       
   183 		return KErrNotReady;
       
   184 		}
       
   185 	}	
       
   186 
       
   187 EXPORT_C TInt RDvbhReceiver::Scan( MDvbhScanObserver& aObserver, TRequestStatus& aStatus )
       
   188 	{
       
   189 	if (iBody != NULL)
       
   190 		{
       
   191 		return iBody->Scan(aObserver, aStatus);
       
   192 		}
       
   193 	else
       
   194 		{
       
   195 		return KErrNotReady;
       
   196 		}
       
   197 	}	
       
   198 
       
   199 EXPORT_C void RDvbhReceiver::CancelScan()
       
   200 	{
       
   201 	if (iBody != NULL)
       
   202 		{	
       
   203 		iBody->CancelScan();
       
   204 		}
       
   205 	else
       
   206 		{
       
   207 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   208 		}
       
   209 	}	
       
   210 
       
   211 EXPORT_C TInt RDvbhReceiver::SetPlatform( const TDvbhNetwork& aNetwork, const TDvbhPlatform& aPlatform, TRequestStatus& aStatus )
       
   212 	{
       
   213 	if (iBody != NULL)
       
   214 		{
       
   215 		return iBody->SetPlatform(aNetwork, aPlatform, aStatus);
       
   216 		}
       
   217 	else
       
   218 		{
       
   219 		return KErrNotReady;
       
   220 		}
       
   221 	}	
       
   222 
       
   223 EXPORT_C void RDvbhReceiver::CancelSetPlatform()
       
   224 	{
       
   225 	if (iBody != NULL)
       
   226 		{	
       
   227 		iBody->CancelSetPlatform();
       
   228 		}
       
   229 	else
       
   230 		{
       
   231 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   232 		}
       
   233 	}	
       
   234 
       
   235 EXPORT_C TInt RDvbhReceiver::CreateFilter( const TIp6Addr& aDestAddress, TInt& aFilterId, TRequestStatus& aStatus )
       
   236 	{
       
   237 	if (iBody != NULL)
       
   238 		{
       
   239 		return iBody->CreateFilter(aDestAddress, aFilterId, aStatus);
       
   240 		}
       
   241 	else
       
   242 		{
       
   243 		return KErrNotReady;
       
   244 		}	
       
   245 	}	
       
   246 
       
   247 EXPORT_C TInt RDvbhReceiver::CancelFilter( TInt aFilterId )
       
   248 	{
       
   249 	if (iBody != NULL)
       
   250 		{
       
   251 		return iBody->CancelFilter(aFilterId);
       
   252 		}
       
   253 	else
       
   254 		{
       
   255 		return KErrNotReady;
       
   256 		}
       
   257 	}	
       
   258 
       
   259 EXPORT_C TInt RDvbhReceiver::ReceiveIPData( MDvbhDataObserver& aObserver )
       
   260 	{
       
   261 	if (iBody != NULL)
       
   262 		{
       
   263 		return iBody->ReceiveIPData(aObserver);
       
   264 		}
       
   265 	else
       
   266 		{
       
   267 		return KErrNotReady;
       
   268 		}
       
   269 	}	
       
   270 
       
   271 EXPORT_C void RDvbhReceiver::CancelReceiveIPData()
       
   272 	{
       
   273 	if (iBody != NULL)
       
   274 		{	
       
   275 		iBody->CancelReceiveIPData();
       
   276 		}
       
   277 	else
       
   278 		{
       
   279 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   280 		}
       
   281 	}	
       
   282 
       
   283 EXPORT_C TInt RDvbhReceiver::UpdateNetworkTime( TRequestStatus& aStatus )
       
   284 	{
       
   285 	if (iBody != NULL)
       
   286 		{
       
   287 		return iBody->UpdateNetworkTime(aStatus);
       
   288 		}
       
   289 	else
       
   290 		{
       
   291 		return KErrNotReady;
       
   292 		}
       
   293 	}	
       
   294 
       
   295 EXPORT_C void RDvbhReceiver::CancelUpdateNetworkTime()
       
   296 	{
       
   297 	if (iBody != NULL)
       
   298 		{	
       
   299 		iBody->CancelUpdateNetworkTime();
       
   300 		}
       
   301 	else
       
   302 		{
       
   303 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   304 		}
       
   305 	}	
       
   306 
       
   307 EXPORT_C TInt RDvbhReceiver::CustomCommand(
       
   308             TInt aCommand,
       
   309             const TDesC8& aInputData,
       
   310             TDes8& aOutputBuffer,
       
   311             TRequestStatus& aStatus )
       
   312 	{
       
   313 	if (iBody != NULL)
       
   314 		{
       
   315 		return iBody->CustomCommand(aCommand, aInputData, aOutputBuffer, aStatus);
       
   316 		}
       
   317 	else
       
   318 		{
       
   319 		return KErrNotReady;
       
   320 		}
       
   321 	}	
       
   322 
       
   323 EXPORT_C void RDvbhReceiver::CancelCustomCommand( TRequestStatus& aStatus )
       
   324 	{
       
   325 	if (iBody != NULL)
       
   326 		{	
       
   327 		iBody->CancelCustomCommand(aStatus);
       
   328 		}
       
   329 	else
       
   330 		{
       
   331 		ASSERT(EFalse); //Generate a panic in debug builds to help developers detect this situation.	
       
   332 		}
       
   333 	}	
       
   334 
       
   335 EXPORT_C TInt RDvbhReceiver::CustomCommand( TInt aCommand, const TDesC8& aInputData )
       
   336 	{
       
   337 	if (iBody != NULL)
       
   338 		{
       
   339 		return iBody->CustomCommand(aCommand, aInputData);
       
   340 		}
       
   341 	else
       
   342 		{
       
   343 		return KErrNotReady;
       
   344 		}
       
   345 	}
       
   346 	
       
   347 void RDvbhReceiver::OpenL( const TDvbhReceiverType aReceiverType )
       
   348 	{
       
   349 	if (iBody == NULL)
       
   350 		{
       
   351 		iBody = new (ELeave) RBody;
       
   352 		}
       
   353 	User::LeaveIfError(iBody->Open( aReceiverType ));
       
   354 	}
       
   355