|
1 /* |
|
2 * Copyright (c) 2002-2009 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 the License "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: Notification class |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 16 % |
|
20 */ |
|
21 |
|
22 #include "rwlmserver.h" |
|
23 #include "am_debug.h" |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // --------------------------------------------------------- |
|
28 // CWLMNotify::ConstructL |
|
29 // --------------------------------------------------------- |
|
30 // |
|
31 void CWLMNotify::ConstructL() |
|
32 { |
|
33 DEBUG( "CWLMNotify::ConstructL()" ); |
|
34 CActiveScheduler::Add( this ); |
|
35 WaitForNotifications(); |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CWLMNotify::CWLMNotify |
|
40 // --------------------------------------------------------- |
|
41 // |
|
42 CWLMNotify::CWLMNotify( |
|
43 MWLMNotify& aCallback, |
|
44 RWLMServer& aServer, |
|
45 TUint32 aNotificationMask ): |
|
46 CActive( CActive::EPriorityStandard ), |
|
47 iCallback( &aCallback ), |
|
48 iServer( aServer ), |
|
49 iDataPckg(), |
|
50 iCancelRequested( EFalse ), |
|
51 iNotificationMask( aNotificationMask ) |
|
52 { |
|
53 DEBUG( "CWLMNotify::CWLMNotify()" ); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CWLMNotify::~CWLMNotify |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 CWLMNotify::~CWLMNotify() |
|
61 { |
|
62 DEBUG( "CWLMNotify::~CWLMNotify()" ); |
|
63 Cancel(); |
|
64 iCallback = NULL; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // CWLMNotify::DoCancel |
|
69 // This is been called when active object should be |
|
70 // cancelled. This is called by CActive::Cancel(). |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CWLMNotify::DoCancel() |
|
74 { |
|
75 DEBUG( "CWLMNotify::DoCancel()" ); |
|
76 iServer.CancelRequest(); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CWLMNotify::NewL |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CWLMNotify* CWLMNotify::NewL( |
|
84 MWLMNotify& aCallback, |
|
85 RWLMServer& aServer, |
|
86 TUint32 aNotificationMask ) |
|
87 { |
|
88 DEBUG( "CWLMNotify::NewL()" ); |
|
89 CWLMNotify* self = new (ELeave) CWLMNotify( aCallback, aServer, aNotificationMask ); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL(); |
|
92 CleanupStack::Pop( self ); |
|
93 return self; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CWLMNotify::RunL |
|
98 // This is called when a response is received to a |
|
99 // asynchronous message. This method dispatches |
|
100 // notifications to client's interface. |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 void CWLMNotify::RunL() |
|
104 { |
|
105 DEBUG1( "CWLMNotify::RunL() - status == %d", iStatus.Int() ); |
|
106 |
|
107 if( iStatus == KRequestPending ) |
|
108 { |
|
109 DEBUG( "CWLMNotify::RunL() - request still pending!" ); |
|
110 return; |
|
111 } |
|
112 |
|
113 if( iStatus == KErrServerTerminated ) |
|
114 { |
|
115 DEBUG( "CWLMNotify::RunL() - server terminated" ); |
|
116 return; |
|
117 } |
|
118 |
|
119 switch( iStatus.Int() ) |
|
120 { |
|
121 case EWlmNotifyConnectionStateChanged: |
|
122 { |
|
123 iCallback->ConnectionStateChanged( |
|
124 static_cast<TWlanConnectionState>( iDataPckg().data[0] )); |
|
125 break; |
|
126 } |
|
127 case EWlmNotifyBssidChanged: |
|
128 { |
|
129 iCallback->BSSIDChanged( iDataPckg().data ); |
|
130 break; |
|
131 } |
|
132 case EWlmNotifyBssLost: |
|
133 { |
|
134 iCallback->BSSLost(); |
|
135 break; |
|
136 } |
|
137 case EWlmNotifyBssRegained: |
|
138 { |
|
139 iCallback->BSSRegained(); |
|
140 break; |
|
141 } |
|
142 case EWlmNotifyNewNetworksDetected: |
|
143 { |
|
144 iCallback->NewNetworksDetected(); |
|
145 break; |
|
146 } |
|
147 case EWlmNotifyOldNetworksLost: |
|
148 { |
|
149 iCallback->OldNetworksLost(); |
|
150 break; |
|
151 } |
|
152 case EWlmNotifyTransmitPowerChanged: |
|
153 { |
|
154 TUint power( 0 ); |
|
155 // safer to copy than cast: alignment might not be correct |
|
156 Mem::Copy( &power, iDataPckg().data.Ptr(), sizeof( power ) ); |
|
157 DEBUG1( "CWLMNotify::RunL() - transmit power changed to %u", power ); |
|
158 iCallback->TransmitPowerChanged( power ); |
|
159 break; |
|
160 } |
|
161 case EWlmNotifyNotificationsCancelled: |
|
162 { |
|
163 DEBUG( "CWLMNotify::RunL() - notifications cancelled" ); |
|
164 return; // Do NOT call WaitForNotifications() |
|
165 } |
|
166 case EWlmNotifyRcpChanged: |
|
167 { |
|
168 TWlanRCPLevel rcpLevel = static_cast<TWlanRCPLevel>( iDataPckg().data[0] ); |
|
169 TUint rcp = static_cast<TUint>( iDataPckg().data[1] ); |
|
170 DEBUG2( "CWLMNotify::RunL() - EWlmNotifyRcpChanged %d, %d", rcpLevel, rcp ); |
|
171 iCallback->RcpChanged( rcpLevel, rcp ); |
|
172 break; |
|
173 } |
|
174 case EWlmNotifyTrafficStreamStatusChanged: |
|
175 { |
|
176 TUint id( 0 ); |
|
177 // safer to copy than cast: alignment might not be correct |
|
178 Mem::Copy( &id, iDataPckg().data.Ptr(), sizeof( id ) ); |
|
179 TWlanTrafficStreamStatus status = |
|
180 static_cast<TWlanTrafficStreamStatus>( iDataPckg().data[4] ); |
|
181 DEBUG2( "CWLMNotify::RunL() - status of traffic stream %u changed to %u", id, status ); |
|
182 iCallback->TrafficStreamStatusChanged( id, status ); |
|
183 break; |
|
184 } |
|
185 case EWlmNotifyAccessPointInfoChanged: |
|
186 { |
|
187 TWlanAccessPointInfo info; |
|
188 Mem::Copy( &info, iDataPckg().data.Ptr(), sizeof( info ) ); |
|
189 |
|
190 DEBUG5( "CWLMNotify::RunL() - AP info changed (Voice = %u, Video = %u, BestEffort = %u, Background = %u, WPX = %u)", |
|
191 info.isAcRequiredForVoice, |
|
192 info.isAcRequiredForVideo, |
|
193 info.isAcRequiredForBestEffort, |
|
194 info.isAcRequiredForBackground, |
|
195 info.isWpx ); |
|
196 |
|
197 iCallback->AccessPointInfoChanged( info ); |
|
198 break; |
|
199 } |
|
200 case EWlmNotifyAcTrafficModeChanged: |
|
201 { |
|
202 TWlmAccessClass accessClass( |
|
203 static_cast<TWlmAccessClass>( iDataPckg().data[0] ) ); |
|
204 TWlmAcTrafficMode mode( |
|
205 static_cast<TWlmAcTrafficMode>( iDataPckg().data[1] ) ); |
|
206 |
|
207 DEBUG2( "CWLMNotify::RunL() - traffic mode of access class (%u) changed to %u", |
|
208 accessClass, mode ); |
|
209 |
|
210 iCallback->AccessClassTrafficModeChanged( |
|
211 accessClass, |
|
212 mode ); |
|
213 break; |
|
214 } |
|
215 case EWlmNotifyAcTrafficStatusChanged: |
|
216 { |
|
217 TWlmAccessClass accessClass( |
|
218 static_cast<TWlmAccessClass>( iDataPckg().data[0] ) ); |
|
219 TWlmAcTrafficStatus status( |
|
220 static_cast<TWlmAcTrafficStatus>( iDataPckg().data[1] ) ); |
|
221 |
|
222 DEBUG2( "CWLMNotify::RunL() - traffic status of access class (%u) changed to %u", |
|
223 accessClass, status ); |
|
224 |
|
225 iCallback->AccessClassTrafficStatusChanged( |
|
226 accessClass, |
|
227 status ); |
|
228 break; |
|
229 } |
|
230 default: |
|
231 DEBUG1( "CWLMNotify::RunL() - unknown notification: %d", iStatus.Int() ); |
|
232 } |
|
233 |
|
234 // Make a new notification request if allowed |
|
235 if( !iCancelRequested ) |
|
236 { |
|
237 WaitForNotifications(); |
|
238 } |
|
239 else |
|
240 { |
|
241 DEBUG("CWLMNotify::RunL() - cancellation has been requested -> cancelling request."); |
|
242 iServer.CancelRequest(); |
|
243 } |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------- |
|
247 // CWLMNotify::WaitForNotifications |
|
248 // The loop goes: WaitForNotifications->RunL-> |
|
249 // WaitForNotifications->... |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 void CWLMNotify::WaitForNotifications() |
|
253 { |
|
254 DEBUG( "CWLMNotify::WaitForNotifications()" ); |
|
255 iServer.WaitForNotification( iStatus, iDataPckg, iNotificationMask ); |
|
256 SetActive(); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------- |
|
260 // CWLMNotify::Activate |
|
261 // --------------------------------------------------------- |
|
262 // |
|
263 void CWLMNotify::Activate( |
|
264 MWLMNotify& aCallback, |
|
265 TUint32 aNotificationMask ) |
|
266 { |
|
267 DEBUG( "CWLMNotify::Activate()" ); |
|
268 iCallback = &aCallback; |
|
269 iCancelRequested = EFalse; |
|
270 iNotificationMask = aNotificationMask; |
|
271 WaitForNotifications(); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------- |
|
275 // CWLMNotify::SetCancelled |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CWLMNotify::SetCancelled() |
|
279 { |
|
280 iCancelRequested = ETrue; |
|
281 } |