os/mm/mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiverinfo.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/dvbhreceiverinfo.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,502 @@
     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 CDvbhReceiverInfo
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalComponent
    1.24 + @prototype
    1.25 +*/
    1.26 +
    1.27 +#include "dvbhreceiverinfo.h"
    1.28 +#include "dvbhreceiverinfoobserver.h"
    1.29 +#include "dvbhtypes.h"
    1.30 +#include "dvbhstubcommon.h"
    1.31 +#include <in_sock.h>
    1.32 +			
    1.33 +/**
    1.34 +* CDvbhReceiverInfo::CPrivateData contains the (implementation specific) private data of CDvbhReceiverInfo.
    1.35 +*/
    1.36 +NONSHARABLE_CLASS(CDvbhReceiverInfo::CPrivateData) : public CBase
    1.37 +    {
    1.38 +public:
    1.39 +	~CPrivateData();
    1.40 +public:
    1.41 +    // Internal observer classes to monitor for RProperty changes.
    1.42 +    CDvbhPropertyObserver*  iStatePropertyObserver;
    1.43 +    CDvbhPropertyObserver*	iSignalQualityPropertyObserver;
    1.44 +    CDvbhPropertyObserver*	iPlatformPropertyObserver;
    1.45 +    CDvbhPropertyObserver*	iNetworkTimePropertyObserver;
    1.46 +    CDvbhPropertyObserver*	iFrequencyPropertyObserver;
    1.47 +    CDvbhPropertyObserver*	iCellIdPropertyObserver;
    1.48 +    CDvbhPropertyObserver*	iNetworkIdPropertyObserver;
    1.49 +    CDvbhPropertyObserver*	iExtBatteryPropertyObserver;
    1.50 +    CDvbhPropertyObserver*	iExtConnectionPropertyObserver;
    1.51 +    CDvbhPropertyObserver*	iMtvAccConnectionPropertyObserver;
    1.52 +    CDvbhPropertyObserver*	iMtvAccAntennaConnectionPropertyObserver;
    1.53 +
    1.54 +    // Wrappers around the external observer classes. To be called upon
    1.55 +    // when a property change is detected.
    1.56 +    TDvbhStateNotifier iStateNotifier;
    1.57 +	TDvbhSignalQualityNotifier iSignalQualityNotifier;
    1.58 +	TDvbhPlatformNotifier iPlatformNotifier;	
    1.59 +	TDvbhNetworkTimeNotifier iNetworkTimeNotifier;
    1.60 +	TDvbhFrequencyNotifier iFrequencyNotifier;
    1.61 +	TDvbhCellIdNotifier iCellIdNotifier;
    1.62 +	TDvbhNetworkIdNotifier iNetworkIdNotifier;	
    1.63 +    TDvbhExtBatteryStateNotifier iExtBatteryNotifier;
    1.64 +    TDvbhExtConnectionStateNotifier iExtConnectionNotifier;
    1.65 +    TMtvAccConnectionStateNotifier iMtvAccConnectionNotifier;
    1.66 +    TMtvAccAntennaConnectionStateNotifier iMtvAccAntennaConnectionNotifier;
    1.67 +    };
    1.68 +
    1.69 +CDvbhReceiverInfo::CPrivateData::~CPrivateData()
    1.70 +	{
    1.71 +    delete iStatePropertyObserver;
    1.72 +    delete iSignalQualityPropertyObserver;
    1.73 +    delete iPlatformPropertyObserver;
    1.74 +    delete iNetworkTimePropertyObserver;
    1.75 +    delete iFrequencyPropertyObserver;
    1.76 +    delete iCellIdPropertyObserver;
    1.77 +    delete iNetworkIdPropertyObserver;
    1.78 +    delete iExtBatteryPropertyObserver;
    1.79 +    delete iExtConnectionPropertyObserver;
    1.80 +    delete iMtvAccConnectionPropertyObserver;
    1.81 +    delete iMtvAccAntennaConnectionPropertyObserver;
    1.82 +	}
    1.83 +	
    1.84 +/**
    1.85 +* Helper function to check if the current receiver state is EDvbhStateReceiving or EDvbhStateReady.
    1.86 +* If aCheckReceivingOnly is EFalse, then it returns KErrNone if the current state is either EDvbhStateReceiving or EDvbhStateReady.
    1.87 +* If aCheckReceivingOnly is ETrue, then will only return KErrNone if the current state is EDvbhStateReceiving.
    1.88 +*
    1.89 +* @param aCheckReceivingOnly ETrue if you only want to check for EDvbhStateReceiving, otherwise will check for EDvbhStateReceiving or EDvbhStateReady.
    1.90 +* @return KErrNone if the current state equals EDvbhStateReceiving or EDvbhStateReady, and aCheckReceivingOnly equals EFalse.  If aCheckReceivingOnly equals ETrue, the KErrNone only if current state is EDvbhStateReceiving.  Otherwise a system-wide error code.
    1.91 +*/
    1.92 +static TInt VerifyReadyOrReceiving(TBool aCheckReceivingOnly = EFalse)
    1.93 +	{
    1.94 +	TDvbhState state = EDvbhStateInactive;
    1.95 +	TInt result = CDvbhReceiverInfo::GetState(state);
    1.96 +	if (result != KErrNone)
    1.97 +		{
    1.98 +		return result;
    1.99 +		}		
   1.100 +		
   1.101 +	if (state != EDvbhStateReceiving && (state != EDvbhStateReady || aCheckReceivingOnly) )
   1.102 +		{
   1.103 +		return KErrNotReady;
   1.104 +		}	
   1.105 +	return KErrNone;
   1.106 +	}
   1.107 +	
   1.108 +/*
   1.109 +* Example implementation of CDvbhReceiverInfo
   1.110 +*/
   1.111 +
   1.112 +EXPORT_C CDvbhReceiverInfo* CDvbhReceiverInfo::NewL()
   1.113 +	{
   1.114 +	CDvbhReceiverInfo* self = CDvbhReceiverInfo::NewLC();
   1.115 +	CleanupStack::Pop(self);
   1.116 +	return self;
   1.117 +	}
   1.118 +
   1.119 +
   1.120 +EXPORT_C CDvbhReceiverInfo* CDvbhReceiverInfo::NewLC()
   1.121 +	{
   1.122 +	CDvbhReceiverInfo* self = new (ELeave) CDvbhReceiverInfo;
   1.123 +	CleanupStack::PushL(self);
   1.124 +	self->ConstructL();
   1.125 +	return self;	
   1.126 +	}
   1.127 +
   1.128 +EXPORT_C CDvbhReceiverInfo::CDvbhReceiverInfo()
   1.129 +	{
   1.130 +	}
   1.131 +	
   1.132 +void CDvbhReceiverInfo::ConstructL()
   1.133 +	{
   1.134 +	iData = new (ELeave) CPrivateData;
   1.135 +	}
   1.136 +	
   1.137 +EXPORT_C CDvbhReceiverInfo::~CDvbhReceiverInfo()
   1.138 +	{
   1.139 +	delete iData;
   1.140 +	}
   1.141 +
   1.142 +EXPORT_C TInt CDvbhReceiverInfo::GetState( TDvbhState& aState )
   1.143 +	{
   1.144 +	TInt state = 0;
   1.145 +	TInt result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyState, state);
   1.146 +	if (result == KErrNone)
   1.147 +		{
   1.148 +		aState = static_cast<TDvbhState>(state);
   1.149 +		}
   1.150 +	return result;	
   1.151 +	}
   1.152 +
   1.153 +EXPORT_C TInt CDvbhReceiverInfo::SetStateObserver( MDvbhStateObserver& aObserver )
   1.154 +	{
   1.155 +	delete iData->iStatePropertyObserver;
   1.156 +	iData->iStatePropertyObserver = NULL;
   1.157 +	if ((iData->iStatePropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.158 +		{
   1.159 +		return KErrNoMemory;
   1.160 +		}
   1.161 +
   1.162 +	iData->iStateNotifier.SetExternalObserver(&aObserver);
   1.163 +	return iData->iStatePropertyObserver->SetObserver(&iData->iStateNotifier);
   1.164 +	}
   1.165 +
   1.166 +EXPORT_C TInt CDvbhReceiverInfo::GetSignalQuality( TDvbhSignalQuality& aSignalQuality )
   1.167 +	{
   1.168 +	// API documentation states that this method may only be called if the receiver 
   1.169 +	// is in the Receiving state.
   1.170 +	TInt result = VerifyReadyOrReceiving(ETrue); //ETrue parameter means check for Receiving state only
   1.171 +	if (result != KErrNone)
   1.172 +		{
   1.173 +		return result;
   1.174 +		}
   1.175 +	
   1.176 +	// The receiver is in the correct state so we may proceed.
   1.177 +	TInt quality = 0;
   1.178 +	result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeySignalQuality, quality);
   1.179 +	if (result == KErrNone)
   1.180 +		{
   1.181 +		aSignalQuality = static_cast<TDvbhSignalQuality>(quality);
   1.182 +		}
   1.183 +	return result;
   1.184 +	}
   1.185 +
   1.186 +EXPORT_C TInt CDvbhReceiverInfo::SetSignalQualityObserver( MDvbhSignalQualityObserver& aObserver )
   1.187 +	{
   1.188 +	delete iData->iSignalQualityPropertyObserver;
   1.189 +	iData->iSignalQualityPropertyObserver = NULL;
   1.190 +	if ((iData->iSignalQualityPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.191 +		{
   1.192 +		return KErrNoMemory;
   1.193 +		}
   1.194 +	iData->iSignalQualityNotifier.SetExternalObserver(&aObserver);
   1.195 +	return iData->iSignalQualityPropertyObserver->SetObserver(&iData->iSignalQualityNotifier);
   1.196 +	}
   1.197 +
   1.198 +EXPORT_C TInt CDvbhReceiverInfo::GetPlatform( TDvbhPlatform& aPlatform, TIp6Addr& aESGRoot )
   1.199 +	{
   1.200 +	// API documentation states that this method may only be called if the receiver 
   1.201 +	// is in the Ready or Receiving state.
   1.202 +	TInt result = VerifyReadyOrReceiving();
   1.203 +	if (result != KErrNone)
   1.204 +		{
   1.205 +		return result;
   1.206 +		}
   1.207 +	
   1.208 +	// The receiver is in the correct state so we may proceed.
   1.209 +	TDvbhPlatformProperty platform;		
   1.210 +	TPckg<TDvbhPlatformProperty> platformPckg(platform);
   1.211 +	result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyPlatform, platformPckg);
   1.212 +	if (result == KErrNone)
   1.213 +		{
   1.214 +		aPlatform.iId = platform.iPlatform.iId;
   1.215 +		aPlatform.iName = platform.iPlatform.iName;
   1.216 +		aESGRoot = platform.iEsgRoot;
   1.217 +		}
   1.218 +	return result;
   1.219 +	}
   1.220 +
   1.221 +EXPORT_C TInt CDvbhReceiverInfo::SetPlatformObserver( MDvbhPlatformObserver& aObserver )
   1.222 +	{
   1.223 +	delete iData->iPlatformPropertyObserver;
   1.224 +	iData->iPlatformPropertyObserver = NULL;
   1.225 +	if ((iData->iPlatformPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.226 +		{
   1.227 +		return KErrNoMemory;
   1.228 +		}
   1.229 +	iData->iPlatformNotifier.SetExternalObserver(&aObserver);
   1.230 +	return iData->iPlatformPropertyObserver->SetObserver(&iData->iPlatformNotifier);
   1.231 +	}
   1.232 +
   1.233 +EXPORT_C TInt CDvbhReceiverInfo::GetNetworkTime( TTime& aNetworkTime, TBool& aValid )
   1.234 +	{		
   1.235 +	TDvbhNetworkTime networkTime;
   1.236 +	TPckg<TDvbhNetworkTime> timePckg(networkTime);
   1.237 +	TInt result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyNetworkTime, timePckg);
   1.238 +	if (result == KErrNone)
   1.239 +		{
   1.240 +		//API documentation states that KErrNotReady should be returned if a platform has
   1.241 +		//never been set on the receiver.
   1.242 +		if (networkTime.iPlatformId == KDvbhInvalidPlatform)
   1.243 +			{
   1.244 +			result = KErrNotReady;
   1.245 +			}
   1.246 +		else
   1.247 +			{
   1.248 +			//The platform is valid, but it might be old.  It will be old if there is no
   1.249 +			//current platform set, i.e. if the state is not Ready or Receiving.  Set the aValid
   1.250 +			//bool based on whether or not it the platform is old.
   1.251 +			if (VerifyReadyOrReceiving() == KErrNone)
   1.252 +				{
   1.253 +				aValid = ETrue;
   1.254 +				}
   1.255 +			else
   1.256 +				{
   1.257 +				aValid = EFalse;
   1.258 +				}
   1.259 +				
   1.260 +			//Finally, update the time
   1.261 +			aNetworkTime = networkTime.iNetworkTime;	
   1.262 +			}
   1.263 +		}
   1.264 +	return result;
   1.265 +	}
   1.266 +
   1.267 +EXPORT_C TInt CDvbhReceiverInfo::SetNetworkTimeObserver( MDvbhNetworkTimeObserver& aObserver )
   1.268 +	{
   1.269 +	delete iData->iNetworkTimePropertyObserver;
   1.270 +	iData->iNetworkTimePropertyObserver = NULL;
   1.271 +	if ((iData->iNetworkTimePropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.272 +		{
   1.273 +		return KErrNoMemory;
   1.274 +		}
   1.275 +	iData->iNetworkTimeNotifier.SetExternalObserver(&aObserver);
   1.276 +	return iData->iNetworkTimePropertyObserver->SetObserver(&iData->iNetworkTimeNotifier);
   1.277 +	}
   1.278 +
   1.279 +EXPORT_C TInt CDvbhReceiverInfo::GetPerformanceData( TDvbhPerformanceData& aPerformanceData )
   1.280 +	{
   1.281 +	TPckg<TDvbhPerformanceData> performancePckg(aPerformanceData);
   1.282 +	return RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyPerformanceData, performancePckg);
   1.283 +	}
   1.284 +
   1.285 +EXPORT_C TInt CDvbhReceiverInfo::GetFrequency( TDvbhFrequency& aFrequency )
   1.286 +	{
   1.287 +	// API documentation states that this method may only be called if the receiver 
   1.288 +	// is in the Ready or Receiving state.
   1.289 +	TInt result = VerifyReadyOrReceiving();
   1.290 +	if (result != KErrNone)
   1.291 +		{
   1.292 +		return result;
   1.293 +		}
   1.294 +	
   1.295 +	// The receiver is in the correct state so we may proceed.	
   1.296 +	TInt frequency = 0;
   1.297 +	result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyFrequency, frequency);
   1.298 +	if (result == KErrNone)
   1.299 +		{
   1.300 +		aFrequency = static_cast<TDvbhFrequency>(frequency);
   1.301 +		}
   1.302 +	return result;
   1.303 +	}
   1.304 +
   1.305 +EXPORT_C TInt CDvbhReceiverInfo::SetFrequencyObserver( MDvbhFrequencyObserver& aObserver )
   1.306 +	{
   1.307 +	delete iData->iFrequencyPropertyObserver;
   1.308 +	iData->iFrequencyPropertyObserver = NULL;
   1.309 +	if ((iData->iFrequencyPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.310 +		{
   1.311 +		return KErrNoMemory;
   1.312 +		}
   1.313 +	iData->iFrequencyNotifier.SetExternalObserver(&aObserver);
   1.314 +	return iData->iFrequencyPropertyObserver->SetObserver(&iData->iFrequencyNotifier);
   1.315 +	}
   1.316 +
   1.317 +EXPORT_C TInt CDvbhReceiverInfo::GetCellId( TDvbhCellId& aCellId )
   1.318 +	{
   1.319 +	// API documentation states that this method may only be called if the receiver 
   1.320 +	// is in the Ready or Receiving state.
   1.321 +	TInt result = VerifyReadyOrReceiving();
   1.322 +	if (result != KErrNone)
   1.323 +		{
   1.324 +		return result;
   1.325 +		}
   1.326 +	
   1.327 +	// The receiver is in the correct state so we may proceed.
   1.328 +	TInt cellId = 0;
   1.329 +	result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyCellId, cellId);
   1.330 +	if (result == KErrNone)
   1.331 +		{
   1.332 +		aCellId = static_cast<TDvbhCellId>(cellId);
   1.333 +		}
   1.334 +	return result;
   1.335 +	}
   1.336 +
   1.337 +EXPORT_C TInt CDvbhReceiverInfo::SetCellIdObserver( MDvbhCellIdObserver& aObserver )
   1.338 +	{
   1.339 +	delete iData->iCellIdPropertyObserver;
   1.340 +	iData->iCellIdPropertyObserver = NULL;
   1.341 +	if ((iData->iCellIdPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.342 +		{
   1.343 +		return KErrNoMemory;
   1.344 +		}
   1.345 +	iData->iCellIdNotifier.SetExternalObserver(&aObserver);
   1.346 +	return iData->iCellIdPropertyObserver->SetObserver(&iData->iCellIdNotifier);
   1.347 +	}
   1.348 +
   1.349 +EXPORT_C TInt CDvbhReceiverInfo::GetNetworkId( TDvbhNetworkId& aNetworkId )
   1.350 +	{
   1.351 +	// API documentation states that this method may only be called if the receiver 
   1.352 +	// is in the Ready or Receiving state.
   1.353 +	TInt result = VerifyReadyOrReceiving();
   1.354 +	if (result != KErrNone)
   1.355 +		{
   1.356 +		return result;
   1.357 +		}
   1.358 +	
   1.359 +	// The receiver is in the correct state so we may proceed.
   1.360 +	TInt networkId = 0;
   1.361 +	result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyNetworkId, networkId);
   1.362 +	if (result == KErrNone)
   1.363 +		{
   1.364 +		aNetworkId = static_cast<TDvbhNetworkId>(networkId);
   1.365 +		}
   1.366 +	return result;
   1.367 +	}
   1.368 +
   1.369 +EXPORT_C TInt CDvbhReceiverInfo::SetNetworkIdObserver( MDvbhNetworkIdObserver& aObserver )
   1.370 +	{
   1.371 +	delete iData->iNetworkIdPropertyObserver;
   1.372 +	iData->iNetworkIdPropertyObserver = NULL;
   1.373 +	if ((iData->iNetworkIdPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.374 +		{
   1.375 +		return KErrNoMemory;
   1.376 +		}
   1.377 +	iData->iNetworkIdNotifier.SetExternalObserver(&aObserver);
   1.378 +	return iData->iNetworkIdPropertyObserver->SetObserver(&iData->iNetworkIdNotifier);
   1.379 +	}
   1.380 +
   1.381 +EXPORT_C TInt CDvbhReceiverInfo::GetBatteryState( TDvbhExtBatteryState& aState )
   1.382 +	{
   1.383 +	// The receiver is in the correct state so we may proceed.
   1.384 +	TInt state = 0;
   1.385 +	TInt result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyExtBatteryState, state);
   1.386 +	if (result == KErrNone)
   1.387 +		{
   1.388 +		aState = static_cast<TDvbhExtBatteryState>(state);
   1.389 +		}
   1.390 +	return result;
   1.391 +	}
   1.392 +
   1.393 +EXPORT_C TInt CDvbhReceiverInfo::SetBatteryStateObserver( MDvbhExtBatteryStateObserver& aObserver )
   1.394 +	{
   1.395 +	delete iData->iExtBatteryPropertyObserver;
   1.396 +	iData->iExtBatteryPropertyObserver = NULL;
   1.397 +	if ((iData->iExtBatteryPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.398 +		{
   1.399 +		return KErrNoMemory;
   1.400 +		}
   1.401 +	iData->iExtBatteryNotifier.SetExternalObserver(&aObserver);
   1.402 +	return iData->iExtBatteryPropertyObserver->SetObserver(&iData->iExtBatteryNotifier);
   1.403 +	}
   1.404 +    
   1.405 +
   1.406 +EXPORT_C TInt CDvbhReceiverInfo::GetExtConnectionState( TDvbhExtConnectionState& aConnectionState, const TDvbhReceiverType& aReceiver )
   1.407 +	{
   1.408 +	// The receiver is in the correct state so we may proceed.
   1.409 +	TInt state = 0;
   1.410 +    TInt result = KErrNone;
   1.411 +    switch (aReceiver)
   1.412 +        {
   1.413 +        case EDvbhReceiverIntegrated:
   1.414 +            result = KErrArgument;
   1.415 +            break;
   1.416 +	    case EDvbhReceiverBluetooth:
   1.417 +            result = RProperty::Get(KDvbhPropertyCategory, KDvbhPropertyKeyExtConnectionState, state);
   1.418 +            break;
   1.419 +	    case EDvbhReceiverUsbAccessory:
   1.420 +            result = RProperty::Get(KDvbhPropertyCategory, KMtvAccAttachedKey, state);
   1.421 +            break;
   1.422 +        default:
   1.423 +            result = KErrArgument;
   1.424 +            break;
   1.425 +        }
   1.426 +    aConnectionState = EDvbhExtNotConnected;
   1.427 +    if (result == KErrNone)
   1.428 +		{
   1.429 +		aConnectionState = static_cast<TDvbhExtConnectionState>(state);
   1.430 +		}
   1.431 +	result = KErrNone;
   1.432 +    return result;
   1.433 +	}
   1.434 +
   1.435 +EXPORT_C TInt CDvbhReceiverInfo::SetExtConnectionStateObserver( MDvbhExtConnectionObserver& aObserver )
   1.436 +	{
   1.437 +	delete iData->iExtConnectionPropertyObserver;
   1.438 +	delete iData->iMtvAccConnectionPropertyObserver;
   1.439 +	iData->iExtConnectionPropertyObserver = NULL;
   1.440 +	iData->iMtvAccConnectionPropertyObserver = NULL;
   1.441 +	if ((iData->iExtConnectionPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.442 +		{
   1.443 +		return KErrNoMemory;
   1.444 +		}
   1.445 +	if ((iData->iMtvAccConnectionPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.446 +		{
   1.447 +		return KErrNoMemory;
   1.448 +		}
   1.449 +	iData->iExtConnectionNotifier.SetExternalObserver(&aObserver);
   1.450 +	TInt result = iData->iExtConnectionPropertyObserver->SetObserver(&iData->iExtConnectionNotifier);
   1.451 +	if (result == KErrNone)
   1.452 +	    {
   1.453 +        iData->iMtvAccConnectionNotifier.SetExternalObserver(&aObserver);
   1.454 +        result = iData->iMtvAccConnectionPropertyObserver->SetObserver(&iData->iMtvAccConnectionNotifier);
   1.455 +	    }
   1.456 +    return result;
   1.457 +	}
   1.458 +
   1.459 +
   1.460 +EXPORT_C TInt CDvbhReceiverInfo::GetExtAntennaConnectionState( TDvbhExtAntennaConnectionState& aConnectionState, const TDvbhReceiverType& aReceiver )
   1.461 +	{
   1.462 +	// The receiver is in the correct state so we may proceed.
   1.463 +	TInt state = 0;
   1.464 +    TInt result = KErrNone;
   1.465 +    switch (aReceiver)
   1.466 +        {
   1.467 +        case EDvbhReceiverIntegrated:
   1.468 +            result = KErrArgument;
   1.469 +            break;
   1.470 +	    case EDvbhReceiverBluetooth:
   1.471 +            result = KErrArgument;
   1.472 +            break;
   1.473 +	    case EDvbhReceiverUsbAccessory:
   1.474 +            result = RProperty::Get(KDvbhPropertyCategory, KMtvAccAntennaKey, state);
   1.475 +            break;
   1.476 +        default:
   1.477 +            result = KErrArgument;
   1.478 +            break;
   1.479 +        }
   1.480 +    aConnectionState = EDvbhExtAntennaNotConnected;
   1.481 +    if (result == KErrNone)
   1.482 +		{
   1.483 +		aConnectionState = static_cast<TDvbhExtAntennaConnectionState>(state);
   1.484 +		}
   1.485 +	result = KErrNone;
   1.486 +    return result;
   1.487 +	}
   1.488 +
   1.489 +EXPORT_C TInt CDvbhReceiverInfo::SetExtAntennaConnectionStateObserver( MDvbhExtAntennaConnectionObserver& aObserver )
   1.490 +	{
   1.491 +	delete iData->iMtvAccAntennaConnectionPropertyObserver;
   1.492 +	iData->iMtvAccAntennaConnectionPropertyObserver = NULL;
   1.493 +	if ((iData->iMtvAccAntennaConnectionPropertyObserver = new CDvbhPropertyObserver) == NULL)
   1.494 +		{
   1.495 +		return KErrNoMemory;
   1.496 +		}
   1.497 +	iData->iMtvAccAntennaConnectionNotifier.SetExternalObserver(&aObserver);
   1.498 +    return iData->iMtvAccAntennaConnectionPropertyObserver->SetObserver(&iData->iMtvAccAntennaConnectionNotifier);
   1.499 +	}
   1.500 +
   1.501 +EXPORT_C TInt CDvbhReceiverInfo::GetExtDeviceInfo( TDvbhAccessoryInfo& aDeviceInfo, const TDvbhReceiverType& /*aReceiver*/ )
   1.502 +    {
   1.503 +	TPckg<TDvbhAccessoryInfo> devinfoPckg(aDeviceInfo);
   1.504 +	return RProperty::Get(KDvbhPropertyCategory, KMtvAccInfoKey, devinfoPckg);
   1.505 +    }