1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements the class CSPPubSubListener |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "csppubsublistener.h" |
|
20 #include "mcsppubsubobserver.h" |
|
21 #include "csplogger.h" |
|
22 |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CSPPubSubListener::CSPPubSubListener |
|
28 // C++ constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CSPPubSubListener::CSPPubSubListener( |
|
33 const TUid aUid, const TInt aKey, MCSPPubSubObserver* aObserver ) : |
|
34 CActive( CActive::EPriorityStandard ), |
|
35 iUid( aUid ), iId( aKey ), iObserver( aObserver ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CSPPubSubListener::~CSPPubSubListener |
|
41 // Destructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CSPPubSubListener::~CSPPubSubListener() |
|
45 { |
|
46 CSPLOGSTRING( CSPINT, "CSPPubSubListener::~CSPPubSubListener" ) |
|
47 Cancel(); |
|
48 iProperty.Close(); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSPPubSubListener::RunL |
|
53 // From CActive. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CSPPubSubListener::RunL() |
|
57 { |
|
58 CSPLOGSTRING( CSPINT, "CSPPubSubListener::RunL" ) |
|
59 const TRequestStatus status( iStatus ); |
|
60 StartListening(); |
|
61 iObserver->HandleNotifyPSL( iUid, iId, status ); |
|
62 CSPLOGSTRING( CSPINT, "CSPPubSubListener::RunL end" ) |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CSPPubSubListener::DoCancel |
|
67 // From CActive. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CSPPubSubListener::DoCancel() |
|
71 { |
|
72 CSPLOGSTRING( CSPINT, "CSPPubSubListener::DoCancel") |
|
73 iProperty.Cancel(); |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CSPPubSubListener::RunError |
|
78 // From CActive. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 TInt CSPPubSubListener::RunError( TInt /*aError*/ ) |
|
82 { |
|
83 CSPLOGSTRING( CSPINT, "CSPPubSubListener::RunError" ) |
|
84 return KErrNone; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSPPubSubListener::NewL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CSPPubSubListener* CSPPubSubListener::NewL( const TUid aUid, |
|
92 const TInt aKey, MCSPPubSubObserver* aObserver ) |
|
93 { |
|
94 CSPLOGSTRING( CSPINT, "CSPPubSubListener::NewL" ) |
|
95 CSPPubSubListener* self = new( ELeave ) |
|
96 CSPPubSubListener( aUid, aKey, aObserver ); |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL(); |
|
99 CleanupStack::Pop(); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CSPPubSubListener::StartListening |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSPPubSubListener::StartListening() |
|
108 { |
|
109 iProperty.Subscribe( iStatus ); |
|
110 SetActive(); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CSPPubSubListener::ConstructL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CSPPubSubListener::ConstructL() |
|
118 { |
|
119 if ( iObserver ) |
|
120 { |
|
121 CActiveScheduler::Add( this ); |
|
122 } |
|
123 |
|
124 User::LeaveIfError ( iProperty.Attach( iUid, iId, EOwnerThread ) ); |
|
125 |
|
126 if ( iObserver ) |
|
127 { |
|
128 StartListening(); |
|
129 } |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CSPPubSubListener::Get |
|
134 // Read integer value. |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CSPPubSubListener::Get( TInt& aVal ) |
|
138 { |
|
139 return iProperty.Get( iUid, iId, aVal ); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSPPubSubListener::Get |
|
144 // Read binary value. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CSPPubSubListener::Get( TDes8& aVal ) |
|
148 { |
|
149 return iProperty.Get( iUid, iId, aVal ); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CSPPubSubListener::Get |
|
154 // Read string value. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 TInt CSPPubSubListener::Get( TDes16& aVal ) |
|
158 { |
|
159 return iProperty.Get( iUid, iId, aVal ); |
|
160 } |
|
161 |
|
162 // End of File |
|