sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @prototype sl@0: */ sl@0: sl@0: #include "dvbhreceiverinfoobserver.h" sl@0: #include "dvbhreceiverinfo.h" sl@0: #include sl@0: sl@0: // sl@0: // Implementation of CDvbhPropertyObserver. sl@0: // sl@0: sl@0: CDvbhPropertyObserver::CDvbhPropertyObserver() sl@0: : CActive(CActive::EPriorityStandard) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: sl@0: CDvbhPropertyObserver::~CDvbhPropertyObserver() sl@0: { sl@0: Cancel(); sl@0: iProperty.Close(); sl@0: } sl@0: sl@0: sl@0: TInt CDvbhPropertyObserver::SetObserver(MPropertyNotifier* aPropertyNotifier) sl@0: { sl@0: ASSERT(iPropertyNotifier == NULL); sl@0: ASSERT(aPropertyNotifier != NULL); sl@0: sl@0: iPropertyNotifier = aPropertyNotifier; sl@0: sl@0: TInt result = iProperty.Attach(KDvbhPropertyCategory, iPropertyNotifier->GetPropertyKey()); sl@0: if (result != KErrNone) sl@0: { sl@0: return result; sl@0: } sl@0: sl@0: iProperty.Subscribe(iStatus); sl@0: SetActive(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: * Simply re-subscribes to the RProperty and calls the corresponding sl@0: * external observer via NotifyPropertyChanged() sl@0: */ sl@0: void CDvbhPropertyObserver::RunL() sl@0: { sl@0: iProperty.Subscribe(iStatus); sl@0: SetActive(); sl@0: iPropertyNotifier->NotifyPropertyChanged(iProperty); sl@0: } sl@0: sl@0: void CDvbhPropertyObserver::DoCancel() sl@0: { sl@0: iProperty.Cancel(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhNotifierBase sl@0: // sl@0: sl@0: TDvbhNotifierBase::TDvbhNotifierBase() sl@0: :iExternalObserver(NULL) sl@0: { sl@0: } sl@0: sl@0: sl@0: void TDvbhNotifierBase::SetExternalObserver(TAny* aObserver) sl@0: { sl@0: ASSERT(aObserver != NULL); sl@0: iExternalObserver = aObserver; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhStateNotifier sl@0: // sl@0: sl@0: TInt TDvbhStateNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyState; sl@0: } sl@0: sl@0: /** sl@0: * Calls the external observer associated with the state property sl@0: * to notify it of a state change. sl@0: */ sl@0: void TDvbhStateNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhStateObserver* stateObserver = static_cast(iExternalObserver); sl@0: stateObserver->DvbhStateChange(static_cast(value)); sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhSignalQualityNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the SignalQuality property sl@0: * to notify it of a SignalQuality change. sl@0: */ sl@0: void TDvbhSignalQualityNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhSignalQualityObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhSignalQualityChange(static_cast(value)); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhSignalQualityNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeySignalQuality; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhPlatformNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the Platform property sl@0: * to notify it of a Platform change. sl@0: */ sl@0: void TDvbhPlatformNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TDvbhPlatformProperty platform; sl@0: TPckg platformPckg(platform); sl@0: TInt err = aProperty.Get(platformPckg); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhPlatformObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhPlatformChange(platform.iPlatform, platform.iEsgRoot); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhPlatformNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyPlatform; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhNetworkTimeNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the NetworkTime property sl@0: * to notify it of a NetworkTime change. sl@0: */ sl@0: void TDvbhNetworkTimeNotifier::NotifyPropertyChanged(RProperty& /*aProperty*/) sl@0: { sl@0: MDvbhNetworkTimeObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhNetworkTimeUpdate(); sl@0: } sl@0: sl@0: TInt TDvbhNetworkTimeNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyNetworkTime; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhFrequencyNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the Frequency property sl@0: * to notify it of a Frequency change. sl@0: */ sl@0: void TDvbhFrequencyNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhFrequencyObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhFrequencyChange(static_cast(value)); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhFrequencyNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyFrequency; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhCellIdNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the CellId property sl@0: * to notify it of a CellId change. sl@0: */ sl@0: void TDvbhCellIdNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhCellIdObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhCellIdChange(static_cast(value)); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhCellIdNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyCellId; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: // TDvbhNetworkIdNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the NetworkId property sl@0: * to notify it of a NetworkId change. sl@0: */ sl@0: void TDvbhNetworkIdNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhNetworkIdObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhNetworkIdChange(static_cast(value)); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhNetworkIdNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyNetworkId; sl@0: } sl@0: sl@0: sl@0: // sl@0: // TDvbhExtBatteryStateNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the NetworkId property sl@0: * to notify it of a NetworkId change. sl@0: */ sl@0: void TDvbhExtBatteryStateNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhExtBatteryStateObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhExtBatteryStateChange(static_cast(value)); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhExtBatteryStateNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyExtBatteryState; sl@0: } sl@0: sl@0: // sl@0: // TDvbhExtConnectionStateNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the NetworkId property sl@0: * to notify it of a NetworkId change. sl@0: */ sl@0: void TDvbhExtConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhExtConnectionObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhExtConnectionStateChange(static_cast(value), EDvbhReceiverBluetooth); sl@0: } sl@0: } sl@0: sl@0: TInt TDvbhExtConnectionStateNotifier::GetPropertyKey() const sl@0: { sl@0: return KDvbhPropertyKeyExtConnectionState; sl@0: } sl@0: sl@0: sl@0: // sl@0: // TMtvAccConnectionStateNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the NetworkId property sl@0: * to notify it of a NetworkId change. sl@0: */ sl@0: void TMtvAccConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhExtConnectionObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhExtConnectionStateChange(static_cast(value), EDvbhReceiverUsbAccessory); sl@0: } sl@0: } sl@0: sl@0: TInt TMtvAccConnectionStateNotifier::GetPropertyKey() const sl@0: { sl@0: return KMtvAccAttachedKey; sl@0: } sl@0: sl@0: // sl@0: // TMtvAccAntennaConnectionStateNotifier sl@0: // sl@0: sl@0: /** sl@0: * Calls the external observer associated with the NetworkId property sl@0: * to notify it of a NetworkId change. sl@0: */ sl@0: void TMtvAccAntennaConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty) sl@0: { sl@0: TInt value = 0; sl@0: TInt err = aProperty.Get(value); sl@0: if (err == KErrNone) sl@0: { sl@0: MDvbhExtAntennaConnectionObserver* observer = static_cast(iExternalObserver); sl@0: observer->DvbhExtAntennaConnectionStateChange(static_cast(value), EDvbhReceiverUsbAccessory); sl@0: } sl@0: } sl@0: sl@0: TInt TMtvAccAntennaConnectionStateNotifier::GetPropertyKey() const sl@0: { sl@0: return KMtvAccAntennaKey; sl@0: }