os/mm/mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiverinfoobserver.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/dvbhreceiverinfoobserver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,376 @@
     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 +//
    1.18 +
    1.19 +/**
    1.20 + @file 
    1.21 + @internalComponent
    1.22 + @prototype
    1.23 +*/
    1.24 +
    1.25 +#include "dvbhreceiverinfoobserver.h"
    1.26 +#include "dvbhreceiverinfo.h"
    1.27 +#include <in_sock.h>
    1.28 +	
    1.29 +//
    1.30 +// Implementation of CDvbhPropertyObserver.
    1.31 +//
    1.32 +	
    1.33 +CDvbhPropertyObserver::CDvbhPropertyObserver()
    1.34 +: CActive(CActive::EPriorityStandard)
    1.35 +	{
    1.36 +	CActiveScheduler::Add(this);
    1.37 +	}
    1.38 +	
    1.39 +
    1.40 +CDvbhPropertyObserver::~CDvbhPropertyObserver()
    1.41 +	{
    1.42 +	Cancel();
    1.43 +	iProperty.Close();
    1.44 +	}
    1.45 +
    1.46 +
    1.47 +TInt CDvbhPropertyObserver::SetObserver(MPropertyNotifier* aPropertyNotifier)
    1.48 +	{
    1.49 +	ASSERT(iPropertyNotifier == NULL);
    1.50 +	ASSERT(aPropertyNotifier != NULL);
    1.51 +	
    1.52 +	iPropertyNotifier = aPropertyNotifier;
    1.53 +	
    1.54 +	TInt result = iProperty.Attach(KDvbhPropertyCategory, iPropertyNotifier->GetPropertyKey());
    1.55 +	if (result != KErrNone)
    1.56 +		{
    1.57 +		return result;
    1.58 +		}
    1.59 +
    1.60 +	iProperty.Subscribe(iStatus);
    1.61 +	SetActive();
    1.62 +	return KErrNone;
    1.63 +	}
    1.64 +	
    1.65 +/**
    1.66 +* Simply re-subscribes to the RProperty and calls the corresponding
    1.67 +* external observer via NotifyPropertyChanged()
    1.68 +*/
    1.69 +void CDvbhPropertyObserver::RunL()
    1.70 +	{
    1.71 +	iProperty.Subscribe(iStatus);
    1.72 +	SetActive();
    1.73 +	iPropertyNotifier->NotifyPropertyChanged(iProperty);
    1.74 +	}
    1.75 +	
    1.76 +void CDvbhPropertyObserver::DoCancel()
    1.77 +	{
    1.78 +	iProperty.Cancel();
    1.79 +	}
    1.80 +	
    1.81 +
    1.82 +
    1.83 +
    1.84 +// 
    1.85 +// TDvbhNotifierBase
    1.86 +//
    1.87 +
    1.88 +TDvbhNotifierBase::TDvbhNotifierBase()
    1.89 +:iExternalObserver(NULL)
    1.90 +	{
    1.91 +	}
    1.92 +	
    1.93 +
    1.94 +void TDvbhNotifierBase::SetExternalObserver(TAny* aObserver)
    1.95 +	{
    1.96 +	ASSERT(aObserver != NULL);
    1.97 +	iExternalObserver = aObserver; 
    1.98 +	}
    1.99 +
   1.100 +
   1.101 +
   1.102 +
   1.103 +//
   1.104 +// TDvbhStateNotifier
   1.105 +//
   1.106 +	
   1.107 +TInt TDvbhStateNotifier::GetPropertyKey() const
   1.108 +	{
   1.109 +	return KDvbhPropertyKeyState;
   1.110 +	}
   1.111 +
   1.112 +/**
   1.113 +* Calls the external observer associated with the state property
   1.114 +* to notify it of a state change. 
   1.115 +*/
   1.116 +void TDvbhStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.117 +	{
   1.118 +	TInt value = 0;
   1.119 +	TInt err = aProperty.Get(value);
   1.120 +	if (err == KErrNone)
   1.121 +		{
   1.122 +		MDvbhStateObserver* stateObserver = static_cast<MDvbhStateObserver*>(iExternalObserver);
   1.123 +		stateObserver->DvbhStateChange(static_cast<TDvbhState>(value));
   1.124 +		}	
   1.125 +	}
   1.126 +
   1.127 +
   1.128 +
   1.129 +//
   1.130 +// TDvbhSignalQualityNotifier
   1.131 +//
   1.132 +
   1.133 +/**
   1.134 +* Calls the external observer associated with the SignalQuality property
   1.135 +* to notify it of a SignalQuality change. 
   1.136 +*/
   1.137 +void TDvbhSignalQualityNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.138 +	{
   1.139 +	TInt value = 0;
   1.140 +	TInt err = aProperty.Get(value);
   1.141 +	if (err == KErrNone)
   1.142 +		{
   1.143 +		MDvbhSignalQualityObserver* observer = static_cast<MDvbhSignalQualityObserver*>(iExternalObserver);
   1.144 +		observer->DvbhSignalQualityChange(static_cast<TDvbhSignalQuality>(value));
   1.145 +		}	
   1.146 +	}
   1.147 +
   1.148 +TInt TDvbhSignalQualityNotifier::GetPropertyKey() const
   1.149 +	{
   1.150 +	return KDvbhPropertyKeySignalQuality;
   1.151 +	}
   1.152 +
   1.153 +
   1.154 +
   1.155 +
   1.156 +//
   1.157 +// TDvbhPlatformNotifier
   1.158 +//
   1.159 +
   1.160 +/**
   1.161 +* Calls the external observer associated with the Platform property
   1.162 +* to notify it of a Platform change. 
   1.163 +*/
   1.164 +void TDvbhPlatformNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.165 +	{
   1.166 +	TDvbhPlatformProperty platform;
   1.167 +	TPckg<TDvbhPlatformProperty> platformPckg(platform);
   1.168 +	TInt err = aProperty.Get(platformPckg);
   1.169 +	if (err == KErrNone)
   1.170 +		{
   1.171 +		MDvbhPlatformObserver* observer = static_cast<MDvbhPlatformObserver*>(iExternalObserver);
   1.172 +		observer->DvbhPlatformChange(platform.iPlatform, platform.iEsgRoot);
   1.173 +		}	
   1.174 +	}
   1.175 +	
   1.176 +TInt TDvbhPlatformNotifier::GetPropertyKey() const
   1.177 +	{
   1.178 +	return KDvbhPropertyKeyPlatform;
   1.179 +	}
   1.180 +	
   1.181 +
   1.182 +
   1.183 +//
   1.184 +// TDvbhNetworkTimeNotifier
   1.185 +//
   1.186 +
   1.187 +/**
   1.188 +* Calls the external observer associated with the NetworkTime property
   1.189 +* to notify it of a NetworkTime change. 
   1.190 +*/
   1.191 +void TDvbhNetworkTimeNotifier::NotifyPropertyChanged(RProperty& /*aProperty*/)
   1.192 +	{
   1.193 +	MDvbhNetworkTimeObserver* observer = static_cast<MDvbhNetworkTimeObserver*>(iExternalObserver);
   1.194 +	observer->DvbhNetworkTimeUpdate();
   1.195 +	}
   1.196 +
   1.197 +TInt TDvbhNetworkTimeNotifier::GetPropertyKey() const
   1.198 +	{
   1.199 +	return KDvbhPropertyKeyNetworkTime;
   1.200 +	}
   1.201 +
   1.202 +
   1.203 +
   1.204 +	
   1.205 +//
   1.206 +// TDvbhFrequencyNotifier
   1.207 +//
   1.208 +
   1.209 +/**
   1.210 +* Calls the external observer associated with the Frequency property
   1.211 +* to notify it of a Frequency change. 
   1.212 +*/
   1.213 +void TDvbhFrequencyNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.214 +	{
   1.215 +	TInt value = 0;
   1.216 +	TInt err = aProperty.Get(value);
   1.217 +	if (err == KErrNone)
   1.218 +		{
   1.219 +		MDvbhFrequencyObserver* observer = static_cast<MDvbhFrequencyObserver*>(iExternalObserver);
   1.220 +		observer->DvbhFrequencyChange(static_cast<TDvbhFrequency>(value));
   1.221 +		}	
   1.222 +	}
   1.223 +		
   1.224 +TInt TDvbhFrequencyNotifier::GetPropertyKey() const
   1.225 +	{
   1.226 +	return KDvbhPropertyKeyFrequency;
   1.227 +	}
   1.228 +
   1.229 +
   1.230 +
   1.231 +
   1.232 +//
   1.233 +// TDvbhCellIdNotifier
   1.234 +//
   1.235 +
   1.236 +/**
   1.237 +* Calls the external observer associated with the CellId property
   1.238 +* to notify it of a CellId change. 
   1.239 +*/
   1.240 +void TDvbhCellIdNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.241 +	{
   1.242 +	TInt value = 0;
   1.243 +	TInt err = aProperty.Get(value);
   1.244 +	if (err == KErrNone)
   1.245 +		{
   1.246 +		MDvbhCellIdObserver* observer = static_cast<MDvbhCellIdObserver*>(iExternalObserver);
   1.247 +		observer->DvbhCellIdChange(static_cast<TDvbhCellId>(value));
   1.248 +		}	
   1.249 +	}	
   1.250 +
   1.251 +TInt TDvbhCellIdNotifier::GetPropertyKey() const
   1.252 +	{
   1.253 +	return KDvbhPropertyKeyCellId;
   1.254 +	}
   1.255 +
   1.256 +
   1.257 +
   1.258 +		
   1.259 +//
   1.260 +// TDvbhNetworkIdNotifier
   1.261 +//
   1.262 +
   1.263 +/**
   1.264 +* Calls the external observer associated with the NetworkId property
   1.265 +* to notify it of a NetworkId change. 
   1.266 +*/
   1.267 +void TDvbhNetworkIdNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.268 +	{
   1.269 +	TInt value = 0;
   1.270 +	TInt err = aProperty.Get(value);
   1.271 +	if (err == KErrNone)
   1.272 +		{
   1.273 +		MDvbhNetworkIdObserver* observer = static_cast<MDvbhNetworkIdObserver*>(iExternalObserver);
   1.274 +		observer->DvbhNetworkIdChange(static_cast<TDvbhNetworkId>(value));
   1.275 +		}	
   1.276 +	}
   1.277 +	
   1.278 +TInt TDvbhNetworkIdNotifier::GetPropertyKey() const
   1.279 +	{
   1.280 +	return KDvbhPropertyKeyNetworkId;
   1.281 +	}
   1.282 +
   1.283 +
   1.284 +//
   1.285 +// TDvbhExtBatteryStateNotifier
   1.286 +//
   1.287 +
   1.288 +/**
   1.289 +* Calls the external observer associated with the NetworkId property
   1.290 +* to notify it of a NetworkId change. 
   1.291 +*/
   1.292 +void TDvbhExtBatteryStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.293 +	{
   1.294 +	TInt value = 0;
   1.295 +	TInt err = aProperty.Get(value);
   1.296 +	if (err == KErrNone)
   1.297 +		{
   1.298 +		MDvbhExtBatteryStateObserver* observer = static_cast<MDvbhExtBatteryStateObserver*>(iExternalObserver);
   1.299 +		observer->DvbhExtBatteryStateChange(static_cast<TDvbhExtBatteryState>(value));
   1.300 +		}	
   1.301 +	}
   1.302 +	
   1.303 +TInt TDvbhExtBatteryStateNotifier::GetPropertyKey() const
   1.304 +	{
   1.305 +	return KDvbhPropertyKeyExtBatteryState;
   1.306 +	}
   1.307 +			
   1.308 +//
   1.309 +// TDvbhExtConnectionStateNotifier
   1.310 +//
   1.311 +
   1.312 +/**
   1.313 +* Calls the external observer associated with the NetworkId property
   1.314 +* to notify it of a NetworkId change. 
   1.315 +*/
   1.316 +void TDvbhExtConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.317 +	{
   1.318 +	TInt value = 0;
   1.319 +	TInt err = aProperty.Get(value);
   1.320 +	if (err == KErrNone)
   1.321 +		{
   1.322 +		MDvbhExtConnectionObserver* observer = static_cast<MDvbhExtConnectionObserver*>(iExternalObserver);
   1.323 +		observer->DvbhExtConnectionStateChange(static_cast<TDvbhExtConnectionState>(value), EDvbhReceiverBluetooth);
   1.324 +		}	
   1.325 +	}
   1.326 +	
   1.327 +TInt TDvbhExtConnectionStateNotifier::GetPropertyKey() const
   1.328 +	{
   1.329 +	return KDvbhPropertyKeyExtConnectionState;
   1.330 +	}
   1.331 +
   1.332 +
   1.333 +//
   1.334 +// TMtvAccConnectionStateNotifier
   1.335 +//
   1.336 +
   1.337 +/**
   1.338 +* Calls the external observer associated with the NetworkId property
   1.339 +* to notify it of a NetworkId change. 
   1.340 +*/
   1.341 +void TMtvAccConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.342 +	{
   1.343 +	TInt value = 0;
   1.344 +	TInt err = aProperty.Get(value);
   1.345 +	if (err == KErrNone)
   1.346 +		{
   1.347 +		MDvbhExtConnectionObserver* observer = static_cast<MDvbhExtConnectionObserver*>(iExternalObserver);
   1.348 +		observer->DvbhExtConnectionStateChange(static_cast<TDvbhExtConnectionState>(value), EDvbhReceiverUsbAccessory);
   1.349 +		}	
   1.350 +	}
   1.351 +	
   1.352 +TInt TMtvAccConnectionStateNotifier::GetPropertyKey() const
   1.353 +	{
   1.354 +	return KMtvAccAttachedKey;
   1.355 +	}
   1.356 +
   1.357 +//
   1.358 +// TMtvAccAntennaConnectionStateNotifier
   1.359 +//
   1.360 +
   1.361 +/**
   1.362 +* Calls the external observer associated with the NetworkId property
   1.363 +* to notify it of a NetworkId change. 
   1.364 +*/
   1.365 +void TMtvAccAntennaConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   1.366 +	{
   1.367 +	TInt value = 0;
   1.368 +	TInt err = aProperty.Get(value);
   1.369 +	if (err == KErrNone)
   1.370 +		{
   1.371 +		MDvbhExtAntennaConnectionObserver* observer = static_cast<MDvbhExtAntennaConnectionObserver*>(iExternalObserver);
   1.372 +		observer->DvbhExtAntennaConnectionStateChange(static_cast<TDvbhExtAntennaConnectionState>(value), EDvbhReceiverUsbAccessory);
   1.373 +		}	
   1.374 +	}
   1.375 +	
   1.376 +TInt TMtvAccAntennaConnectionStateNotifier::GetPropertyKey() const
   1.377 +	{
   1.378 +	return KMtvAccAntennaKey;
   1.379 +	}