|
1 // Copyright (c) 2004-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 */ |
|
20 |
|
21 #include "NetPSSignal.h" |
|
22 |
|
23 using namespace NetSubscribe; |
|
24 |
|
25 void CPSSubscribe::RegisterNewSignalL(TEventClientData& aData, const SSignalId& aSignalId ) |
|
26 { |
|
27 CPSSignal* pSignal = CPSSignal::NewLC(aSignalId); |
|
28 pSignal->RegisterClientL( aData ); |
|
29 iSignals.AppendL(pSignal); |
|
30 CleanupStack::Pop(pSignal); |
|
31 } |
|
32 |
|
33 CPSSignal* CPSSignal::NewLC( const SSignalId& aSignalId ) |
|
34 { |
|
35 CPSSignal* pSignal = new(ELeave)CPSSignal(aSignalId); |
|
36 CleanupStack::PushL(pSignal); |
|
37 pSignal->ConstructL(); |
|
38 return pSignal; |
|
39 } |
|
40 |
|
41 void CPSSignal::ConstructL() |
|
42 /** |
|
43 * subscribes to the property |
|
44 */ |
|
45 { |
|
46 User::LeaveIfError(iProperty.Attach(TUid::Uid(iSignalId.iTypeId.iType), iSignalId.iHandle )); |
|
47 |
|
48 iProperty.Subscribe(iStatus); |
|
49 SetActive(); |
|
50 } |
|
51 |
|
52 CPSSignal::~CPSSignal() |
|
53 { |
|
54 Cancel(); |
|
55 iProperty.Close(); |
|
56 delete iUsrData; |
|
57 } |
|
58 |
|
59 void CPSSignal::DoCancel() |
|
60 { |
|
61 iProperty.Cancel(); |
|
62 } |
|
63 |
|
64 void CPSSignal::RunL() |
|
65 { |
|
66 TInt nErr = iStatus.Int(); |
|
67 //set active first since a leave is trapped by RunError and subscription continues |
|
68 iProperty.Subscribe(iStatus); |
|
69 SetActive(); |
|
70 //get data |
|
71 TBuf8<KMaxLength> buf; |
|
72 User::LeaveIfError( iProperty.Get(buf) ); |
|
73 TPtrC8 ptr( buf ); |
|
74 if ( iUsrData ) |
|
75 { |
|
76 User::LeaveIfError( iSignalId.iTypeId.Check( ptr ) ); |
|
77 User::LeaveIfError(iUsrData->Load( ptr )); |
|
78 } |
|
79 else |
|
80 { |
|
81 iUsrData = Meta::SMetaDataECom::LoadL(ptr); |
|
82 User::LeaveIfError( iSignalId.iTypeId == iUsrData->GetTypeId() ? KErrNone : KErrArgument ); |
|
83 } |
|
84 iData.DispatchL( iUsrData, nErr ); |
|
85 } |
|
86 |