First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include "dvbhreceiverinfoobserver.h"
23 #include "dvbhreceiverinfo.h"
27 // Implementation of CDvbhPropertyObserver.
30 CDvbhPropertyObserver::CDvbhPropertyObserver()
31 : CActive(CActive::EPriorityStandard)
33 CActiveScheduler::Add(this);
37 CDvbhPropertyObserver::~CDvbhPropertyObserver()
44 TInt CDvbhPropertyObserver::SetObserver(MPropertyNotifier* aPropertyNotifier)
46 ASSERT(iPropertyNotifier == NULL);
47 ASSERT(aPropertyNotifier != NULL);
49 iPropertyNotifier = aPropertyNotifier;
51 TInt result = iProperty.Attach(KDvbhPropertyCategory, iPropertyNotifier->GetPropertyKey());
52 if (result != KErrNone)
57 iProperty.Subscribe(iStatus);
63 * Simply re-subscribes to the RProperty and calls the corresponding
64 * external observer via NotifyPropertyChanged()
66 void CDvbhPropertyObserver::RunL()
68 iProperty.Subscribe(iStatus);
70 iPropertyNotifier->NotifyPropertyChanged(iProperty);
73 void CDvbhPropertyObserver::DoCancel()
85 TDvbhNotifierBase::TDvbhNotifierBase()
86 :iExternalObserver(NULL)
91 void TDvbhNotifierBase::SetExternalObserver(TAny* aObserver)
93 ASSERT(aObserver != NULL);
94 iExternalObserver = aObserver;
101 // TDvbhStateNotifier
104 TInt TDvbhStateNotifier::GetPropertyKey() const
106 return KDvbhPropertyKeyState;
110 * Calls the external observer associated with the state property
111 * to notify it of a state change.
113 void TDvbhStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
116 TInt err = aProperty.Get(value);
119 MDvbhStateObserver* stateObserver = static_cast<MDvbhStateObserver*>(iExternalObserver);
120 stateObserver->DvbhStateChange(static_cast<TDvbhState>(value));
127 // TDvbhSignalQualityNotifier
131 * Calls the external observer associated with the SignalQuality property
132 * to notify it of a SignalQuality change.
134 void TDvbhSignalQualityNotifier::NotifyPropertyChanged(RProperty& aProperty)
137 TInt err = aProperty.Get(value);
140 MDvbhSignalQualityObserver* observer = static_cast<MDvbhSignalQualityObserver*>(iExternalObserver);
141 observer->DvbhSignalQualityChange(static_cast<TDvbhSignalQuality>(value));
145 TInt TDvbhSignalQualityNotifier::GetPropertyKey() const
147 return KDvbhPropertyKeySignalQuality;
154 // TDvbhPlatformNotifier
158 * Calls the external observer associated with the Platform property
159 * to notify it of a Platform change.
161 void TDvbhPlatformNotifier::NotifyPropertyChanged(RProperty& aProperty)
163 TDvbhPlatformProperty platform;
164 TPckg<TDvbhPlatformProperty> platformPckg(platform);
165 TInt err = aProperty.Get(platformPckg);
168 MDvbhPlatformObserver* observer = static_cast<MDvbhPlatformObserver*>(iExternalObserver);
169 observer->DvbhPlatformChange(platform.iPlatform, platform.iEsgRoot);
173 TInt TDvbhPlatformNotifier::GetPropertyKey() const
175 return KDvbhPropertyKeyPlatform;
181 // TDvbhNetworkTimeNotifier
185 * Calls the external observer associated with the NetworkTime property
186 * to notify it of a NetworkTime change.
188 void TDvbhNetworkTimeNotifier::NotifyPropertyChanged(RProperty& /*aProperty*/)
190 MDvbhNetworkTimeObserver* observer = static_cast<MDvbhNetworkTimeObserver*>(iExternalObserver);
191 observer->DvbhNetworkTimeUpdate();
194 TInt TDvbhNetworkTimeNotifier::GetPropertyKey() const
196 return KDvbhPropertyKeyNetworkTime;
203 // TDvbhFrequencyNotifier
207 * Calls the external observer associated with the Frequency property
208 * to notify it of a Frequency change.
210 void TDvbhFrequencyNotifier::NotifyPropertyChanged(RProperty& aProperty)
213 TInt err = aProperty.Get(value);
216 MDvbhFrequencyObserver* observer = static_cast<MDvbhFrequencyObserver*>(iExternalObserver);
217 observer->DvbhFrequencyChange(static_cast<TDvbhFrequency>(value));
221 TInt TDvbhFrequencyNotifier::GetPropertyKey() const
223 return KDvbhPropertyKeyFrequency;
230 // TDvbhCellIdNotifier
234 * Calls the external observer associated with the CellId property
235 * to notify it of a CellId change.
237 void TDvbhCellIdNotifier::NotifyPropertyChanged(RProperty& aProperty)
240 TInt err = aProperty.Get(value);
243 MDvbhCellIdObserver* observer = static_cast<MDvbhCellIdObserver*>(iExternalObserver);
244 observer->DvbhCellIdChange(static_cast<TDvbhCellId>(value));
248 TInt TDvbhCellIdNotifier::GetPropertyKey() const
250 return KDvbhPropertyKeyCellId;
257 // TDvbhNetworkIdNotifier
261 * Calls the external observer associated with the NetworkId property
262 * to notify it of a NetworkId change.
264 void TDvbhNetworkIdNotifier::NotifyPropertyChanged(RProperty& aProperty)
267 TInt err = aProperty.Get(value);
270 MDvbhNetworkIdObserver* observer = static_cast<MDvbhNetworkIdObserver*>(iExternalObserver);
271 observer->DvbhNetworkIdChange(static_cast<TDvbhNetworkId>(value));
275 TInt TDvbhNetworkIdNotifier::GetPropertyKey() const
277 return KDvbhPropertyKeyNetworkId;
282 // TDvbhExtBatteryStateNotifier
286 * Calls the external observer associated with the NetworkId property
287 * to notify it of a NetworkId change.
289 void TDvbhExtBatteryStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
292 TInt err = aProperty.Get(value);
295 MDvbhExtBatteryStateObserver* observer = static_cast<MDvbhExtBatteryStateObserver*>(iExternalObserver);
296 observer->DvbhExtBatteryStateChange(static_cast<TDvbhExtBatteryState>(value));
300 TInt TDvbhExtBatteryStateNotifier::GetPropertyKey() const
302 return KDvbhPropertyKeyExtBatteryState;
306 // TDvbhExtConnectionStateNotifier
310 * Calls the external observer associated with the NetworkId property
311 * to notify it of a NetworkId change.
313 void TDvbhExtConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
316 TInt err = aProperty.Get(value);
319 MDvbhExtConnectionObserver* observer = static_cast<MDvbhExtConnectionObserver*>(iExternalObserver);
320 observer->DvbhExtConnectionStateChange(static_cast<TDvbhExtConnectionState>(value), EDvbhReceiverBluetooth);
324 TInt TDvbhExtConnectionStateNotifier::GetPropertyKey() const
326 return KDvbhPropertyKeyExtConnectionState;
331 // TMtvAccConnectionStateNotifier
335 * Calls the external observer associated with the NetworkId property
336 * to notify it of a NetworkId change.
338 void TMtvAccConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
341 TInt err = aProperty.Get(value);
344 MDvbhExtConnectionObserver* observer = static_cast<MDvbhExtConnectionObserver*>(iExternalObserver);
345 observer->DvbhExtConnectionStateChange(static_cast<TDvbhExtConnectionState>(value), EDvbhReceiverUsbAccessory);
349 TInt TMtvAccConnectionStateNotifier::GetPropertyKey() const
351 return KMtvAccAttachedKey;
355 // TMtvAccAntennaConnectionStateNotifier
359 * Calls the external observer associated with the NetworkId property
360 * to notify it of a NetworkId change.
362 void TMtvAccAntennaConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
365 TInt err = aProperty.Get(value);
368 MDvbhExtAntennaConnectionObserver* observer = static_cast<MDvbhExtAntennaConnectionObserver*>(iExternalObserver);
369 observer->DvbhExtAntennaConnectionStateChange(static_cast<TDvbhExtAntennaConnectionState>(value), EDvbhReceiverUsbAccessory);
373 TInt TMtvAccAntennaConnectionStateNotifier::GetPropertyKey() const
375 return KMtvAccAntennaKey;