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