os/mm/mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiverinfoobserver.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file 
    18  @internalComponent
    19  @prototype
    20 */
    21 
    22 #include "dvbhreceiverinfoobserver.h"
    23 #include "dvbhreceiverinfo.h"
    24 #include <in_sock.h>
    25 	
    26 //
    27 // Implementation of CDvbhPropertyObserver.
    28 //
    29 	
    30 CDvbhPropertyObserver::CDvbhPropertyObserver()
    31 : CActive(CActive::EPriorityStandard)
    32 	{
    33 	CActiveScheduler::Add(this);
    34 	}
    35 	
    36 
    37 CDvbhPropertyObserver::~CDvbhPropertyObserver()
    38 	{
    39 	Cancel();
    40 	iProperty.Close();
    41 	}
    42 
    43 
    44 TInt CDvbhPropertyObserver::SetObserver(MPropertyNotifier* aPropertyNotifier)
    45 	{
    46 	ASSERT(iPropertyNotifier == NULL);
    47 	ASSERT(aPropertyNotifier != NULL);
    48 	
    49 	iPropertyNotifier = aPropertyNotifier;
    50 	
    51 	TInt result = iProperty.Attach(KDvbhPropertyCategory, iPropertyNotifier->GetPropertyKey());
    52 	if (result != KErrNone)
    53 		{
    54 		return result;
    55 		}
    56 
    57 	iProperty.Subscribe(iStatus);
    58 	SetActive();
    59 	return KErrNone;
    60 	}
    61 	
    62 /**
    63 * Simply re-subscribes to the RProperty and calls the corresponding
    64 * external observer via NotifyPropertyChanged()
    65 */
    66 void CDvbhPropertyObserver::RunL()
    67 	{
    68 	iProperty.Subscribe(iStatus);
    69 	SetActive();
    70 	iPropertyNotifier->NotifyPropertyChanged(iProperty);
    71 	}
    72 	
    73 void CDvbhPropertyObserver::DoCancel()
    74 	{
    75 	iProperty.Cancel();
    76 	}
    77 	
    78 
    79 
    80 
    81 // 
    82 // TDvbhNotifierBase
    83 //
    84 
    85 TDvbhNotifierBase::TDvbhNotifierBase()
    86 :iExternalObserver(NULL)
    87 	{
    88 	}
    89 	
    90 
    91 void TDvbhNotifierBase::SetExternalObserver(TAny* aObserver)
    92 	{
    93 	ASSERT(aObserver != NULL);
    94 	iExternalObserver = aObserver; 
    95 	}
    96 
    97 
    98 
    99 
   100 //
   101 // TDvbhStateNotifier
   102 //
   103 	
   104 TInt TDvbhStateNotifier::GetPropertyKey() const
   105 	{
   106 	return KDvbhPropertyKeyState;
   107 	}
   108 
   109 /**
   110 * Calls the external observer associated with the state property
   111 * to notify it of a state change. 
   112 */
   113 void TDvbhStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   114 	{
   115 	TInt value = 0;
   116 	TInt err = aProperty.Get(value);
   117 	if (err == KErrNone)
   118 		{
   119 		MDvbhStateObserver* stateObserver = static_cast<MDvbhStateObserver*>(iExternalObserver);
   120 		stateObserver->DvbhStateChange(static_cast<TDvbhState>(value));
   121 		}	
   122 	}
   123 
   124 
   125 
   126 //
   127 // TDvbhSignalQualityNotifier
   128 //
   129 
   130 /**
   131 * Calls the external observer associated with the SignalQuality property
   132 * to notify it of a SignalQuality change. 
   133 */
   134 void TDvbhSignalQualityNotifier::NotifyPropertyChanged(RProperty& aProperty)
   135 	{
   136 	TInt value = 0;
   137 	TInt err = aProperty.Get(value);
   138 	if (err == KErrNone)
   139 		{
   140 		MDvbhSignalQualityObserver* observer = static_cast<MDvbhSignalQualityObserver*>(iExternalObserver);
   141 		observer->DvbhSignalQualityChange(static_cast<TDvbhSignalQuality>(value));
   142 		}	
   143 	}
   144 
   145 TInt TDvbhSignalQualityNotifier::GetPropertyKey() const
   146 	{
   147 	return KDvbhPropertyKeySignalQuality;
   148 	}
   149 
   150 
   151 
   152 
   153 //
   154 // TDvbhPlatformNotifier
   155 //
   156 
   157 /**
   158 * Calls the external observer associated with the Platform property
   159 * to notify it of a Platform change. 
   160 */
   161 void TDvbhPlatformNotifier::NotifyPropertyChanged(RProperty& aProperty)
   162 	{
   163 	TDvbhPlatformProperty platform;
   164 	TPckg<TDvbhPlatformProperty> platformPckg(platform);
   165 	TInt err = aProperty.Get(platformPckg);
   166 	if (err == KErrNone)
   167 		{
   168 		MDvbhPlatformObserver* observer = static_cast<MDvbhPlatformObserver*>(iExternalObserver);
   169 		observer->DvbhPlatformChange(platform.iPlatform, platform.iEsgRoot);
   170 		}	
   171 	}
   172 	
   173 TInt TDvbhPlatformNotifier::GetPropertyKey() const
   174 	{
   175 	return KDvbhPropertyKeyPlatform;
   176 	}
   177 	
   178 
   179 
   180 //
   181 // TDvbhNetworkTimeNotifier
   182 //
   183 
   184 /**
   185 * Calls the external observer associated with the NetworkTime property
   186 * to notify it of a NetworkTime change. 
   187 */
   188 void TDvbhNetworkTimeNotifier::NotifyPropertyChanged(RProperty& /*aProperty*/)
   189 	{
   190 	MDvbhNetworkTimeObserver* observer = static_cast<MDvbhNetworkTimeObserver*>(iExternalObserver);
   191 	observer->DvbhNetworkTimeUpdate();
   192 	}
   193 
   194 TInt TDvbhNetworkTimeNotifier::GetPropertyKey() const
   195 	{
   196 	return KDvbhPropertyKeyNetworkTime;
   197 	}
   198 
   199 
   200 
   201 	
   202 //
   203 // TDvbhFrequencyNotifier
   204 //
   205 
   206 /**
   207 * Calls the external observer associated with the Frequency property
   208 * to notify it of a Frequency change. 
   209 */
   210 void TDvbhFrequencyNotifier::NotifyPropertyChanged(RProperty& aProperty)
   211 	{
   212 	TInt value = 0;
   213 	TInt err = aProperty.Get(value);
   214 	if (err == KErrNone)
   215 		{
   216 		MDvbhFrequencyObserver* observer = static_cast<MDvbhFrequencyObserver*>(iExternalObserver);
   217 		observer->DvbhFrequencyChange(static_cast<TDvbhFrequency>(value));
   218 		}	
   219 	}
   220 		
   221 TInt TDvbhFrequencyNotifier::GetPropertyKey() const
   222 	{
   223 	return KDvbhPropertyKeyFrequency;
   224 	}
   225 
   226 
   227 
   228 
   229 //
   230 // TDvbhCellIdNotifier
   231 //
   232 
   233 /**
   234 * Calls the external observer associated with the CellId property
   235 * to notify it of a CellId change. 
   236 */
   237 void TDvbhCellIdNotifier::NotifyPropertyChanged(RProperty& aProperty)
   238 	{
   239 	TInt value = 0;
   240 	TInt err = aProperty.Get(value);
   241 	if (err == KErrNone)
   242 		{
   243 		MDvbhCellIdObserver* observer = static_cast<MDvbhCellIdObserver*>(iExternalObserver);
   244 		observer->DvbhCellIdChange(static_cast<TDvbhCellId>(value));
   245 		}	
   246 	}	
   247 
   248 TInt TDvbhCellIdNotifier::GetPropertyKey() const
   249 	{
   250 	return KDvbhPropertyKeyCellId;
   251 	}
   252 
   253 
   254 
   255 		
   256 //
   257 // TDvbhNetworkIdNotifier
   258 //
   259 
   260 /**
   261 * Calls the external observer associated with the NetworkId property
   262 * to notify it of a NetworkId change. 
   263 */
   264 void TDvbhNetworkIdNotifier::NotifyPropertyChanged(RProperty& aProperty)
   265 	{
   266 	TInt value = 0;
   267 	TInt err = aProperty.Get(value);
   268 	if (err == KErrNone)
   269 		{
   270 		MDvbhNetworkIdObserver* observer = static_cast<MDvbhNetworkIdObserver*>(iExternalObserver);
   271 		observer->DvbhNetworkIdChange(static_cast<TDvbhNetworkId>(value));
   272 		}	
   273 	}
   274 	
   275 TInt TDvbhNetworkIdNotifier::GetPropertyKey() const
   276 	{
   277 	return KDvbhPropertyKeyNetworkId;
   278 	}
   279 
   280 
   281 //
   282 // TDvbhExtBatteryStateNotifier
   283 //
   284 
   285 /**
   286 * Calls the external observer associated with the NetworkId property
   287 * to notify it of a NetworkId change. 
   288 */
   289 void TDvbhExtBatteryStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   290 	{
   291 	TInt value = 0;
   292 	TInt err = aProperty.Get(value);
   293 	if (err == KErrNone)
   294 		{
   295 		MDvbhExtBatteryStateObserver* observer = static_cast<MDvbhExtBatteryStateObserver*>(iExternalObserver);
   296 		observer->DvbhExtBatteryStateChange(static_cast<TDvbhExtBatteryState>(value));
   297 		}	
   298 	}
   299 	
   300 TInt TDvbhExtBatteryStateNotifier::GetPropertyKey() const
   301 	{
   302 	return KDvbhPropertyKeyExtBatteryState;
   303 	}
   304 			
   305 //
   306 // TDvbhExtConnectionStateNotifier
   307 //
   308 
   309 /**
   310 * Calls the external observer associated with the NetworkId property
   311 * to notify it of a NetworkId change. 
   312 */
   313 void TDvbhExtConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   314 	{
   315 	TInt value = 0;
   316 	TInt err = aProperty.Get(value);
   317 	if (err == KErrNone)
   318 		{
   319 		MDvbhExtConnectionObserver* observer = static_cast<MDvbhExtConnectionObserver*>(iExternalObserver);
   320 		observer->DvbhExtConnectionStateChange(static_cast<TDvbhExtConnectionState>(value), EDvbhReceiverBluetooth);
   321 		}	
   322 	}
   323 	
   324 TInt TDvbhExtConnectionStateNotifier::GetPropertyKey() const
   325 	{
   326 	return KDvbhPropertyKeyExtConnectionState;
   327 	}
   328 
   329 
   330 //
   331 // TMtvAccConnectionStateNotifier
   332 //
   333 
   334 /**
   335 * Calls the external observer associated with the NetworkId property
   336 * to notify it of a NetworkId change. 
   337 */
   338 void TMtvAccConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   339 	{
   340 	TInt value = 0;
   341 	TInt err = aProperty.Get(value);
   342 	if (err == KErrNone)
   343 		{
   344 		MDvbhExtConnectionObserver* observer = static_cast<MDvbhExtConnectionObserver*>(iExternalObserver);
   345 		observer->DvbhExtConnectionStateChange(static_cast<TDvbhExtConnectionState>(value), EDvbhReceiverUsbAccessory);
   346 		}	
   347 	}
   348 	
   349 TInt TMtvAccConnectionStateNotifier::GetPropertyKey() const
   350 	{
   351 	return KMtvAccAttachedKey;
   352 	}
   353 
   354 //
   355 // TMtvAccAntennaConnectionStateNotifier
   356 //
   357 
   358 /**
   359 * Calls the external observer associated with the NetworkId property
   360 * to notify it of a NetworkId change. 
   361 */
   362 void TMtvAccAntennaConnectionStateNotifier::NotifyPropertyChanged(RProperty& aProperty)
   363 	{
   364 	TInt value = 0;
   365 	TInt err = aProperty.Get(value);
   366 	if (err == KErrNone)
   367 		{
   368 		MDvbhExtAntennaConnectionObserver* observer = static_cast<MDvbhExtAntennaConnectionObserver*>(iExternalObserver);
   369 		observer->DvbhExtAntennaConnectionStateChange(static_cast<TDvbhExtAntennaConnectionState>(value), EDvbhReceiverUsbAccessory);
   370 		}	
   371 	}
   372 	
   373 TInt TMtvAccAntennaConnectionStateNotifier::GetPropertyKey() const
   374 	{
   375 	return KMtvAccAntennaKey;
   376 	}