|
1 // Copyright (c) 2006-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 |
|
18 // INCLUDE FILES |
|
19 #include <hwrm/hwrmfmtx.h> |
|
20 #include "HWRMFmTxInternalPSKeys.h" |
|
21 #include "HWRMFmTxStatusObserver.h" |
|
22 #include "HWRMtrace.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CHWRMFmTxStatusObserver::CHWRMFmTxStatusObserver |
|
28 // C++ constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CHWRMFmTxStatusObserver::CHWRMFmTxStatusObserver(MHWRMFmTxObserver* aCallback) |
|
33 : CActive(EPriorityStandard), iCallback(aCallback) |
|
34 { |
|
35 COMPONENT_TRACE2( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::CHWRMFmTxStatusObserver(0x%x)" ), aCallback); |
|
36 |
|
37 CActiveScheduler::Add(this); |
|
38 |
|
39 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::CHWRMFmTxStatusObserver - return" ) ); |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CHWRMFmTxStatusObserver::NewL |
|
44 // Two-phased constructor |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CHWRMFmTxStatusObserver* CHWRMFmTxStatusObserver::NewL(MHWRMFmTxObserver* aCallback) |
|
48 { |
|
49 |
|
50 COMPONENT_TRACE2( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::NewLC(0x%x)" ), aCallback); |
|
51 |
|
52 CHWRMFmTxStatusObserver* newInstance = new (ELeave) CHWRMFmTxStatusObserver(aCallback); |
|
53 |
|
54 CleanupStack::PushL( newInstance ); |
|
55 |
|
56 newInstance->ConstructL(); |
|
57 |
|
58 CleanupStack::Pop( newInstance ); |
|
59 |
|
60 COMPONENT_TRACE2( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::NewLC - return 0x%x" ), newInstance ); |
|
61 |
|
62 return newInstance; |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Destructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CHWRMFmTxStatusObserver::~CHWRMFmTxStatusObserver() |
|
71 { |
|
72 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::~CHWRMFmTxStatusObserver()" )); |
|
73 |
|
74 // Cancel property separately, as the following Cancel() call doesn't seem to |
|
75 // cause DoCancel to fire. |
|
76 iProperty.Cancel(); |
|
77 |
|
78 Cancel(); |
|
79 |
|
80 iProperty.Close(); |
|
81 |
|
82 iCallback = NULL; // PCLint demands |
|
83 |
|
84 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::~CHWRMFmTxStatusObserver - return" ) ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CHWRMFmTxStatusObserver::ConstructL |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CHWRMFmTxStatusObserver::ConstructL() |
|
93 { |
|
94 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::ConstructL()" )); |
|
95 |
|
96 User::LeaveIfError(iProperty.Attach(KPSUidHWRMFmTx, KHWRMFmTxStatus)); |
|
97 |
|
98 // Call RunL to order notification and do the initial notifying of the client |
|
99 RunL(); |
|
100 |
|
101 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::ConstructL - return" ) ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CHWRMFmTxStatusObserver::RunL |
|
106 // Handle notification from P&S session. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CHWRMFmTxStatusObserver::RunL() |
|
110 { |
|
111 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::RunL()" )); |
|
112 |
|
113 // Reorder notification |
|
114 OrderNotification(); |
|
115 |
|
116 // get value from P&S |
|
117 TInt value(EFmTxStateUnknown); |
|
118 |
|
119 TInt err = iProperty.Get(value); |
|
120 |
|
121 // if no error or not found then no problem. |
|
122 // Otherwise leave as something went wrong |
|
123 if ( err == KErrNotFound || err == KErrNone ) |
|
124 { |
|
125 TFmTxState state = static_cast<TFmTxState>(value); |
|
126 |
|
127 // Only notify if value actually changed |
|
128 if ( iCallback && iFmTxState != state) |
|
129 { |
|
130 iCallback->FmTxStatusChanged(state); |
|
131 } |
|
132 iFmTxState = state; |
|
133 } |
|
134 else |
|
135 { |
|
136 User::Leave(err); |
|
137 } |
|
138 |
|
139 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::RunL - return" ) ); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CHWRMFmTxStatusObserver::RunError |
|
144 // Handle error in RunL |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 #if defined(_DEBUG) && defined(COMPONENT_TRACE_FLAG) |
|
148 TInt CHWRMFmTxStatusObserver::RunError(TInt aError) |
|
149 #else |
|
150 TInt CHWRMFmTxStatusObserver::RunError(TInt /*aError*/) |
|
151 #endif |
|
152 { |
|
153 COMPONENT_TRACE2( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::RunError(%d)" ), aError); |
|
154 |
|
155 // Error occurred either while reordering notification or getting |
|
156 // property value. Set status accordingly |
|
157 |
|
158 if ( iCallback && iFmTxState != EFmTxStateUnknown) |
|
159 { |
|
160 iCallback->FmTxStatusChanged(EFmTxStateUnknown); |
|
161 } |
|
162 |
|
163 iFmTxState = EFmTxStateUnknown; |
|
164 |
|
165 COMPONENT_TRACE2( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::RunError - return %d" ), KErrNone ); |
|
166 |
|
167 return KErrNone; |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CHWRMFmTxStatusObserver::DoCancel |
|
172 // Handle cancel order on this active object. |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CHWRMFmTxStatusObserver::DoCancel() |
|
176 { |
|
177 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::DoCancel()" )); |
|
178 |
|
179 iProperty.Cancel(); |
|
180 |
|
181 COMPONENT_TRACE1( _L( "HWRM FmTxClient - CHWRMFmTxStatusObserver::DoCancel - return" ) ); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CHWRMFmTxStatusObserver::OrderNotification |
|
186 // Order new notification from CenRep. |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CHWRMFmTxStatusObserver::OrderNotification() |
|
190 { |
|
191 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::OrderNotification()" )); |
|
192 |
|
193 iProperty.Subscribe(iStatus); |
|
194 SetActive(); |
|
195 |
|
196 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::OrderNotification - return" ) ); |
|
197 } |
|
198 |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CHWRMFmTxStatusObserver::Status |
|
202 // Return FM Tx status |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TFmTxState CHWRMFmTxStatusObserver::Status() |
|
206 { |
|
207 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::Status()" )); |
|
208 |
|
209 TInt value(EFmTxStateUnknown); |
|
210 |
|
211 TInt err = RProperty::Get(KPSUidHWRMFmTx, KHWRMFmTxStatus, value); |
|
212 |
|
213 if ( err == KErrNone ) |
|
214 { |
|
215 COMPONENT_TRACE1( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::Status - RPropert::Get ok" ) ); |
|
216 |
|
217 iFmTxState = static_cast<TFmTxState>(value); |
|
218 } |
|
219 |
|
220 COMPONENT_TRACE2( _L( "HWRM FM Tx Client - CHWRMFmTxStatusObserver::Status - return 0x%x" ), iFmTxState ); |
|
221 |
|
222 return iFmTxState; |
|
223 } |
|
224 |
|
225 |
|
226 // End of File |